carbon-react 109.2.1 → 109.2.4
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__/validations/validation-icon.component.js +1 -1
- 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/anchor-navigation/anchor-navigation.component.js +2 -2
- package/esm/components/badge/badge.style.d.ts +1 -4
- package/esm/components/button/button.component.d.ts +1 -4
- package/esm/components/button/button.component.js +28 -14
- package/esm/components/button-bar/button-bar.component.js +1 -1
- package/esm/components/decimal/decimal.component.js +3 -3
- package/esm/components/drawer/drawer.component.js +1 -1
- package/esm/components/duelling-picklist/picklist-group/picklist-group.style.js +2 -2
- package/esm/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
- package/esm/components/icon/icon.component.js +1 -1
- package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -0
- package/esm/components/multi-action-button/multi-action-button.component.js +1 -6
- 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/split-button/split-button.component.js +1 -6
- package/esm/components/tooltip/tooltip.component.js +1 -1
- package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +39 -37
- package/lib/__internal__/validations/validation-icon.component.js +1 -1
- 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/anchor-navigation/anchor-navigation.component.js +2 -2
- package/lib/components/badge/badge.style.d.ts +1 -4
- package/lib/components/button/button.component.d.ts +1 -4
- package/lib/components/button/button.component.js +31 -12
- package/lib/components/button-bar/button-bar.component.js +1 -1
- package/lib/components/decimal/decimal.component.js +3 -3
- package/lib/components/drawer/drawer.component.js +1 -1
- package/lib/components/duelling-picklist/picklist-group/picklist-group.style.js +4 -2
- package/lib/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
- package/lib/components/icon/icon.component.js +1 -1
- package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -0
- package/lib/components/multi-action-button/multi-action-button.component.js +1 -6
- 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/split-button/split-button.component.js +1 -6
- package/lib/components/tooltip/tooltip.component.js +1 -1
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +38 -36
- package/package.json +17 -14
- 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
|
@@ -38,7 +38,7 @@ const ValidationIcon = ({
|
|
|
38
38
|
const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ["bottom", "left", "right", "top"].includes(override));
|
|
39
39
|
|
|
40
40
|
if (tooltipFlipOverrides) {
|
|
41
|
-
invariant(
|
|
41
|
+
!flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? invariant(false, `The tooltipFlipOverrides prop supplied to ValidationIcon must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const {
|
|
@@ -18,7 +18,7 @@ const AccordionGroup = ({
|
|
|
18
18
|
});
|
|
19
19
|
return hasAccordionChildren;
|
|
20
20
|
}, [children]);
|
|
21
|
-
invariant(
|
|
21
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `AccordionGroup accepts only children of type \`${Accordion.displayName}\`.`) : invariant(false) : void 0;
|
|
22
22
|
const filteredChildren = useMemo(() => React.Children.toArray(children).filter(child => {
|
|
23
23
|
return /*#__PURE__*/React.isValidElement(child);
|
|
24
24
|
}), [children]);
|
|
@@ -60,8 +60,8 @@ const ActionPopoverItem = ({
|
|
|
60
60
|
}) => {
|
|
61
61
|
const l = useLocale();
|
|
62
62
|
const context = useContext(ActionPopoverContext);
|
|
63
|
-
invariant(
|
|
64
|
-
|
|
63
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverItem must be used within an ActionPopover component") : invariant(false) : void 0;
|
|
64
|
+
!( /*#__PURE__*/React.isValidElement(submenu) ? submenu.type === ActionPopoverMenu : true) ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverItem only accepts submenu of type `ActionPopoverMenu`") : invariant(false) : void 0;
|
|
65
65
|
const {
|
|
66
66
|
setOpenPopover,
|
|
67
67
|
isOpenPopover,
|
|
@@ -21,11 +21,11 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
|
|
|
21
21
|
...rest
|
|
22
22
|
}, ref) => {
|
|
23
23
|
const context = useContext(ActionPopoverContext);
|
|
24
|
-
invariant(
|
|
24
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverMenu must be used within an ActionPopover component") : invariant(false) : void 0;
|
|
25
25
|
const {
|
|
26
26
|
focusButton
|
|
27
27
|
} = context;
|
|
28
|
-
|
|
28
|
+
!(setOpen && setFocusIndex && typeof focusIndex !== "undefined") ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverMenu must be used within an ActionPopover or ActionPopoverItem component") : invariant(false) : void 0;
|
|
29
29
|
const hasProperChildren = useMemo(() => {
|
|
30
30
|
const incorrectChild = React.Children.toArray(children).find(child => {
|
|
31
31
|
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
@@ -36,7 +36,7 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
|
|
|
36
36
|
});
|
|
37
37
|
return !incorrectChild;
|
|
38
38
|
}, [children]);
|
|
39
|
-
invariant(
|
|
39
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `ActionPopoverMenu only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`) : invariant(false) : void 0;
|
|
40
40
|
const items = useMemo(() => {
|
|
41
41
|
return React.Children.toArray(children).filter(child => {
|
|
42
42
|
return /*#__PURE__*/React.isValidElement(child) && child.type === ActionPopoverItem;
|
|
@@ -49,7 +49,7 @@ const ActionPopover = ({
|
|
|
49
49
|
});
|
|
50
50
|
return !incorrectChild;
|
|
51
51
|
}, [children]);
|
|
52
|
-
invariant(
|
|
52
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `ActionPopover only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`) : invariant(false) : void 0;
|
|
53
53
|
const mappedPlacement = useMemo(() => {
|
|
54
54
|
if (placement === "top" && !rightAlignMenu) {
|
|
55
55
|
return "top-end";
|
|
@@ -13,14 +13,14 @@ const AnchorNavigation = ({
|
|
|
13
13
|
children,
|
|
14
14
|
stickyNavigation
|
|
15
15
|
}) => {
|
|
16
|
-
|
|
16
|
+
!isFragment(stickyNavigation) ? process.env.NODE_ENV !== "production" ? invariant(false, "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.") : invariant(false) : void 0;
|
|
17
17
|
const hasCorrectItemStructure = useMemo(() => {
|
|
18
18
|
const incorrectChild = React.Children.toArray(stickyNavigation.props.children).find(child => {
|
|
19
19
|
return ! /*#__PURE__*/React.isValidElement(child) || child.type.displayName !== AnchorNavigationItem.displayName;
|
|
20
20
|
});
|
|
21
21
|
return !incorrectChild;
|
|
22
22
|
}, [stickyNavigation]);
|
|
23
|
-
invariant(
|
|
23
|
+
!hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? invariant(false, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${AnchorNavigationItem.displayName}\``) : invariant(false) : void 0;
|
|
24
24
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
25
25
|
const sectionRefs = useRef(React.Children.map(stickyNavigation.props.children, child => child.props.target));
|
|
26
26
|
const anchorRefs = useRef(Array.from({
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
-
declare const StyledButton: import("styled-components").StyledComponent<{
|
|
5
|
-
({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: import("../button").ButtonProps): JSX.Element;
|
|
6
|
-
displayName: string;
|
|
7
|
-
}, any, {}, never>;
|
|
4
|
+
declare const StyledButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, {}, never>;
|
|
8
5
|
declare const StyledCrossIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
9
6
|
export { StyledBadgeWrapper, StyledButton, StyledCrossIcon, StyledCounter };
|
|
@@ -58,10 +58,7 @@ export interface ButtonProps extends SpaceProps {
|
|
|
58
58
|
/** HTML rel attribute */
|
|
59
59
|
rel?: string;
|
|
60
60
|
}
|
|
61
|
-
declare const Button:
|
|
62
|
-
({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: ButtonProps): JSX.Element;
|
|
63
|
-
displayName: string;
|
|
64
|
-
};
|
|
61
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
65
62
|
declare const ButtonWithForwardRef: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
66
63
|
export { ButtonWithForwardRef };
|
|
67
64
|
export default Button;
|
|
@@ -7,6 +7,7 @@ import Icon from "../icon";
|
|
|
7
7
|
import StyledButton, { StyledButtonSubtext } from "./button.style";
|
|
8
8
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
9
9
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
10
|
+
import Logger from "../../__internal__/utils/logger";
|
|
10
11
|
|
|
11
12
|
function renderChildren({
|
|
12
13
|
/* eslint-disable react/prop-types */
|
|
@@ -73,8 +74,8 @@ renderChildren.propTypes = {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
|
-
|
|
77
|
-
const Button = ({
|
|
77
|
+
let deprecatedForwardRefWarnTriggered = false;
|
|
78
|
+
const Button = /*#__PURE__*/React.forwardRef(({
|
|
78
79
|
size = "medium",
|
|
79
80
|
subtext = "",
|
|
80
81
|
children,
|
|
@@ -95,11 +96,16 @@ const Button = ({
|
|
|
95
96
|
iconTooltipPosition,
|
|
96
97
|
fullWidth = false,
|
|
97
98
|
...rest
|
|
98
|
-
}) => {
|
|
99
|
-
|
|
99
|
+
}, ref) => {
|
|
100
|
+
!!!(children || iconType) ? process.env.NODE_ENV !== "production" ? invariant(false, "Either prop `iconType` must be defined or this node must have children.") : invariant(false) : void 0;
|
|
100
101
|
|
|
101
102
|
if (subtext) {
|
|
102
|
-
|
|
103
|
+
!(size === "large") ? process.env.NODE_ENV !== "production" ? invariant(false, "subtext prop has no effect unless the button is large.") : invariant(false) : void 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!deprecatedForwardRefWarnTriggered && forwardRef) {
|
|
107
|
+
deprecatedForwardRefWarnTriggered = true;
|
|
108
|
+
Logger.deprecate("The `forwardRef` prop in `Button` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
const [internalRef, setInternalRef] = useState();
|
|
@@ -129,10 +135,11 @@ const Button = ({
|
|
|
129
135
|
|
|
130
136
|
const setRefs = useCallback(reference => {
|
|
131
137
|
setInternalRef(reference);
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
if (typeof
|
|
135
|
-
|
|
138
|
+
const activeRef = ref || forwardRef;
|
|
139
|
+
if (!activeRef) return;
|
|
140
|
+
if (typeof activeRef === "object") activeRef.current = reference;
|
|
141
|
+
if (typeof activeRef === "function") activeRef(reference);
|
|
142
|
+
}, [ref, forwardRef]);
|
|
136
143
|
return /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
137
144
|
"aria-label": !children && iconType ? ariaLabel || iconType : undefined,
|
|
138
145
|
as: !disabled && href ? "a" : "button",
|
|
@@ -169,8 +176,7 @@ const Button = ({
|
|
|
169
176
|
iconTooltipPosition,
|
|
170
177
|
tooltipTarget: internalRef
|
|
171
178
|
}));
|
|
172
|
-
};
|
|
173
|
-
|
|
179
|
+
});
|
|
174
180
|
Button.propTypes = {
|
|
175
181
|
"aria-label": PropTypes.string,
|
|
176
182
|
"buttonType": PropTypes.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
@@ -507,9 +513,17 @@ Button.propTypes = {
|
|
|
507
513
|
"target": PropTypes.string,
|
|
508
514
|
"type": PropTypes.string
|
|
509
515
|
};
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
516
|
+
let deprecatedButtonForwardRefWarnTriggered = false;
|
|
517
|
+
const ButtonWithForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
518
|
+
if (!deprecatedButtonForwardRefWarnTriggered) {
|
|
519
|
+
deprecatedButtonForwardRefWarnTriggered = true;
|
|
520
|
+
Logger.deprecate("The `ButtonWithForwardRef` component is deprecated and will soon be removed. Please use a basic `Button` component with `ref` instead.");
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
524
|
+
ref: ref
|
|
525
|
+
}, props));
|
|
526
|
+
});
|
|
513
527
|
ButtonWithForwardRef.propTypes = {
|
|
514
528
|
"aria-label": PropTypes.string,
|
|
515
529
|
"buttonType": PropTypes.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
@@ -24,7 +24,7 @@ const ButtonBar = ({
|
|
|
24
24
|
});
|
|
25
25
|
return !incorrectChild;
|
|
26
26
|
}, [children]);
|
|
27
|
-
invariant(
|
|
27
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, "ButtonBar accepts only `Button` or `IconButton` elements.") : invariant(false) : void 0;
|
|
28
28
|
|
|
29
29
|
const getBtnProps = child => {
|
|
30
30
|
var _child$props, _child$props2, _child$props2$childre, _child$props2$childre2;
|
|
@@ -31,10 +31,10 @@ const Decimal = ({
|
|
|
31
31
|
const emptyValue = allowEmptyValue ? "" : "0.00";
|
|
32
32
|
const getSafeValueProp = useCallback(initialValue => {
|
|
33
33
|
// We're intentionally preventing the use of number values to help prevent any unintentional rounding issues
|
|
34
|
-
|
|
34
|
+
!(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? invariant(false, "Decimal `value` prop must be a string") : invariant(false) : void 0;
|
|
35
35
|
|
|
36
36
|
if (initialValue && !allowEmptyValue) {
|
|
37
|
-
|
|
37
|
+
!(initialValue !== "") ? process.env.NODE_ENV !== "production" ? invariant(false, "Decimal `value` must not be an empty string. Please use `allowEmptyValue` or `0.00`") : invariant(false) : void 0;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
return initialValue;
|
|
@@ -164,7 +164,7 @@ const Decimal = ({
|
|
|
164
164
|
const prevControlledRef = useRef();
|
|
165
165
|
useEffect(() => {
|
|
166
166
|
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";
|
|
167
|
-
|
|
167
|
+
!(prevControlledRef.current !== isControlled) ? process.env.NODE_ENV !== "production" ? invariant(false, message) : invariant(false) : void 0;
|
|
168
168
|
prevControlledRef.current = isControlled;
|
|
169
169
|
}, [isControlled]);
|
|
170
170
|
const prevValue = usePrevious(value);
|
|
@@ -69,7 +69,7 @@ const Drawer = ({
|
|
|
69
69
|
const previousValue = usePrevious(expanded);
|
|
70
70
|
useEffect(() => {
|
|
71
71
|
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";
|
|
72
|
-
|
|
72
|
+
!(isControlled.current === (expanded !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, message) : invariant(false) : void 0;
|
|
73
73
|
|
|
74
74
|
if (isControlled.current && previousValue !== expanded) {
|
|
75
75
|
setIsExpanded(expanded);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import
|
|
2
|
+
import Button from "../../button";
|
|
3
3
|
import { StyledButton } from "../picklist-item/picklist-item.style";
|
|
4
4
|
const StyledGroupWrapper = styled.li`
|
|
5
5
|
${({
|
|
@@ -25,7 +25,7 @@ const StyledPicklistGroup = styled.li`
|
|
|
25
25
|
width: 100%;
|
|
26
26
|
margin-bottom: 4px;
|
|
27
27
|
`;
|
|
28
|
-
const StyledGroupButton = styled(
|
|
28
|
+
const StyledGroupButton = styled(Button)`
|
|
29
29
|
${({
|
|
30
30
|
iconType
|
|
31
31
|
}) => css`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import
|
|
2
|
+
import Button from "../../button";
|
|
3
3
|
import Icon from "../../icon";
|
|
4
4
|
import StyledIcon from "../../icon/icon.style";
|
|
5
5
|
const StyledPicklistItem = styled.li`
|
|
@@ -30,7 +30,7 @@ const StyledPicklistItem = styled.li`
|
|
|
30
30
|
}
|
|
31
31
|
`}
|
|
32
32
|
`;
|
|
33
|
-
const StyledButton = styled(
|
|
33
|
+
const StyledButton = styled(Button)`
|
|
34
34
|
${({
|
|
35
35
|
iconType
|
|
36
36
|
}) => css`
|
|
@@ -36,7 +36,7 @@ const Icon = /*#__PURE__*/React.forwardRef(({
|
|
|
36
36
|
const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ICON_TOOLTIP_POSITIONS.includes(override));
|
|
37
37
|
|
|
38
38
|
if (tooltipFlipOverrides) {
|
|
39
|
-
invariant(
|
|
39
|
+
!flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? invariant(false, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const isInteractive = !!tooltipMessage && !disabled;
|
|
@@ -215,6 +215,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
215
215
|
menuType: menuContext.menuType,
|
|
216
216
|
asPassiveItem: asPassiveItem
|
|
217
217
|
}, /*#__PURE__*/React.createElement(StyledMenuItemWrapper, _extends({}, rest, {
|
|
218
|
+
onClick: onClick,
|
|
218
219
|
className: className,
|
|
219
220
|
menuType: menuContext.menuType,
|
|
220
221
|
ref: ref,
|
|
@@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useState, useRef, useMemo } from "react"
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
|
|
6
6
|
import { StyledMultiActionButton, StyledButtonChildrenContainer } from "./multi-action-button.style";
|
|
7
|
-
import Button
|
|
7
|
+
import Button from "../button";
|
|
8
8
|
import Events from "../../__internal__/utils/helpers/events";
|
|
9
9
|
import Popover from "../../__internal__/popover";
|
|
10
10
|
import { filterStyledSystemMarginProps, filterOutStyledSystemSpacingProps } from "../../style/utils";
|
|
@@ -67,11 +67,6 @@ const MultiActionButton = ({
|
|
|
67
67
|
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
if (child.type === Button) {
|
|
72
|
-
return /*#__PURE__*/React.createElement(ButtonWithForwardRef, _extends({}, child.props, props));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
70
|
return /*#__PURE__*/React.cloneElement(child, props);
|
|
76
71
|
});
|
|
77
72
|
};
|
|
@@ -25,12 +25,12 @@ const Note = ({
|
|
|
25
25
|
onLinkAdded,
|
|
26
26
|
...rest
|
|
27
27
|
}) => {
|
|
28
|
-
|
|
29
|
-
invariant(
|
|
30
|
-
invariant(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
!(width > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> width must be greater than 0") : invariant(false) : void 0;
|
|
29
|
+
!createdDate ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> createdDate is required") : invariant(false) : void 0;
|
|
30
|
+
!noteContent ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> noteContent is required") : invariant(false) : void 0;
|
|
31
|
+
!(!status || status.text) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> status.text is required") : invariant(false) : void 0;
|
|
32
|
+
!(!status || status.timeStamp) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> status.timeStamp is required") : invariant(false) : void 0;
|
|
33
|
+
!(!inlineControl || inlineControl.type === ActionPopover) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> inlineControl must be an instance of <ActionPopover>") : invariant(false) : void 0;
|
|
34
34
|
|
|
35
35
|
const renderStatus = () => {
|
|
36
36
|
if (!status) {
|
|
@@ -78,7 +78,7 @@ const NumeralDate = ({
|
|
|
78
78
|
const [internalMessages, setInternalMessages] = useState({});
|
|
79
79
|
useEffect(() => {
|
|
80
80
|
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";
|
|
81
|
-
|
|
81
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
|
|
82
82
|
}, [value]);
|
|
83
83
|
const validationMessages = {
|
|
84
84
|
dd: l.numeralDate.validation.day(),
|
|
@@ -34,7 +34,7 @@ const Search = ({
|
|
|
34
34
|
}) => {
|
|
35
35
|
const isControlled = value !== undefined;
|
|
36
36
|
const initialValue = isControlled ? value : defaultValue;
|
|
37
|
-
|
|
37
|
+
!(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? invariant(false, "This component has no initial value") : invariant(false) : void 0;
|
|
38
38
|
const [searchValue, setSearchValue] = useState(initialValue);
|
|
39
39
|
const [isFocused, setIsFocused] = useState(false);
|
|
40
40
|
const [searchIsActive, setSearchIsActive] = useState(initialValue.length >= threshold);
|
|
@@ -168,8 +168,8 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
168
168
|
useEffect(() => {
|
|
169
169
|
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";
|
|
170
170
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
|
|
172
|
+
!(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? invariant(false, onChangeMissingMessage) : invariant(false) : void 0;
|
|
173
173
|
|
|
174
174
|
if (isControlled.current) {
|
|
175
175
|
setSelectedValue(prevValue => {
|
|
@@ -203,7 +203,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
203
203
|
useEffect(() => {
|
|
204
204
|
const hasListActionButton = listActionButton !== undefined;
|
|
205
205
|
const onListActionMissingMessage = "onListAction prop required when using listActionButton prop";
|
|
206
|
-
|
|
206
|
+
!(!hasListActionButton || hasListActionButton && onListAction) ? process.env.NODE_ENV !== "production" ? invariant(false, onListActionMissingMessage) : invariant(false) : void 0;
|
|
207
207
|
}, [listActionButton, onListAction]);
|
|
208
208
|
useEffect(() => {
|
|
209
209
|
if (isControlled.current) {
|
|
@@ -201,8 +201,8 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
201
201
|
useEffect(() => {
|
|
202
202
|
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";
|
|
203
203
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
|
|
205
|
+
!(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? invariant(false, onChangeMissingMessage) : invariant(false) : void 0;
|
|
206
206
|
|
|
207
207
|
if (isControlled.current) {
|
|
208
208
|
setSelectedValue(value);
|
|
@@ -149,8 +149,8 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
149
149
|
useEffect(() => {
|
|
150
150
|
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";
|
|
151
151
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
|
|
153
|
+
!(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? invariant(false, onChangeMissingMessage) : invariant(false) : void 0;
|
|
154
154
|
|
|
155
155
|
if (isControlled.current) {
|
|
156
156
|
setSelectedValue(value);
|
|
@@ -6,7 +6,7 @@ import PropTypes from "prop-types";
|
|
|
6
6
|
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
7
7
|
import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
|
|
8
8
|
import Icon from "../icon";
|
|
9
|
-
import Button
|
|
9
|
+
import Button from "../button";
|
|
10
10
|
import StyledSplitButton from "./split-button.style";
|
|
11
11
|
import StyledSplitButtonToggle from "./split-button-toggle.style";
|
|
12
12
|
import StyledSplitButtonChildrenContainer from "./split-button-children.style";
|
|
@@ -217,11 +217,6 @@ const SplitButton = ({
|
|
|
217
217
|
(_toggleButton$current = toggleButton.current) === null || _toggleButton$current === void 0 ? void 0 : _toggleButton$current.focus();
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
|
-
|
|
221
|
-
if (child.type === Button) {
|
|
222
|
-
return /*#__PURE__*/React.createElement(ButtonWithForwardRef, _extends({}, child.props, childProps));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
220
|
return /*#__PURE__*/React.cloneElement(child, childProps);
|
|
226
221
|
});
|
|
227
222
|
}
|
|
@@ -29,7 +29,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
|
|
|
29
29
|
...rest
|
|
30
30
|
}, ref) => {
|
|
31
31
|
const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => TOOLTIP_POSITIONS.includes(placement));
|
|
32
|
-
invariant(
|
|
32
|
+
!isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? invariant(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
|
|
33
33
|
|
|
34
34
|
const tooltip = (attrs, content) => {
|
|
35
35
|
const currentPosition = attrs["data-placement"] || position;
|
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import { useRef, useCallback
|
|
1
|
+
import { useRef, useCallback } from "react";
|
|
2
2
|
import guid from "../../../__internal__/utils/helpers/guid";
|
|
3
3
|
import ScrollBlockManager from "./scroll-block-manager"; // TODO: This component can be refactored to remove redundant code after
|
|
4
4
|
// we can confirm that all Sage products use version 105.0.0^
|
|
5
5
|
|
|
6
6
|
const scrollBlockManager = new ScrollBlockManager();
|
|
7
7
|
|
|
8
|
+
const getRules = () => {
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
const {
|
|
11
|
+
documentElement,
|
|
12
|
+
body
|
|
13
|
+
} = document || {};
|
|
14
|
+
const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
|
|
15
|
+
const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
|
|
16
|
+
return [// TODO: First two entries of this array with the documentElement can be removed
|
|
17
|
+
{
|
|
18
|
+
element: documentElement,
|
|
19
|
+
property: "position",
|
|
20
|
+
blockingValue: "relative"
|
|
21
|
+
}, {
|
|
22
|
+
element: documentElement,
|
|
23
|
+
property: "overflow",
|
|
24
|
+
blockingValue: "hidden"
|
|
25
|
+
}, {
|
|
26
|
+
element: body,
|
|
27
|
+
property: "position",
|
|
28
|
+
blockingValue: "relative"
|
|
29
|
+
}, {
|
|
30
|
+
element: body,
|
|
31
|
+
property: "overflow",
|
|
32
|
+
blockingValue: "hidden"
|
|
33
|
+
}, {
|
|
34
|
+
element: body,
|
|
35
|
+
property: "paddingRight",
|
|
36
|
+
blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
|
|
37
|
+
}];
|
|
38
|
+
};
|
|
39
|
+
|
|
8
40
|
const useScrollBlock = () => {
|
|
9
41
|
const {
|
|
10
42
|
current: containerGuid
|
|
11
43
|
} = useRef(guid());
|
|
12
44
|
const originalValuesRef = useRef([]);
|
|
13
|
-
const rules = useMemo(() => {
|
|
14
|
-
/* istanbul ignore next */
|
|
15
|
-
const {
|
|
16
|
-
documentElement,
|
|
17
|
-
body
|
|
18
|
-
} = document || {};
|
|
19
|
-
const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
|
|
20
|
-
const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
|
|
21
|
-
return [// TODO: First two entries of this array with the documentElement can be removed
|
|
22
|
-
{
|
|
23
|
-
element: documentElement,
|
|
24
|
-
property: "position",
|
|
25
|
-
blockingValue: "relative"
|
|
26
|
-
}, {
|
|
27
|
-
element: documentElement,
|
|
28
|
-
property: "overflow",
|
|
29
|
-
blockingValue: "hidden"
|
|
30
|
-
}, {
|
|
31
|
-
element: body,
|
|
32
|
-
property: "position",
|
|
33
|
-
blockingValue: "relative"
|
|
34
|
-
}, {
|
|
35
|
-
element: body,
|
|
36
|
-
property: "overflow",
|
|
37
|
-
blockingValue: "hidden"
|
|
38
|
-
}, {
|
|
39
|
-
element: body,
|
|
40
|
-
property: "paddingRight",
|
|
41
|
-
blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
|
|
42
|
-
}];
|
|
43
|
-
}, []);
|
|
44
45
|
const restoreValues = useCallback(() => {
|
|
45
|
-
|
|
46
|
+
getRules().forEach(({
|
|
46
47
|
element,
|
|
47
48
|
property
|
|
48
49
|
}, index) => {
|
|
49
50
|
element.style[property] = originalValuesRef.current[index];
|
|
50
51
|
});
|
|
51
|
-
}, [
|
|
52
|
+
}, []);
|
|
52
53
|
const blockScroll = useCallback(() => {
|
|
54
|
+
const rules = getRules();
|
|
53
55
|
const isBlocked = scrollBlockManager.isBlocked();
|
|
54
56
|
scrollBlockManager.registerComponent(containerGuid);
|
|
55
57
|
|
|
@@ -73,7 +75,7 @@ const useScrollBlock = () => {
|
|
|
73
75
|
}) => {
|
|
74
76
|
element.style[property] = blockingValue;
|
|
75
77
|
});
|
|
76
|
-
}, [restoreValues, containerGuid
|
|
78
|
+
}, [restoreValues, containerGuid]);
|
|
77
79
|
const allowScroll = useCallback(() => {
|
|
78
80
|
scrollBlockManager.unregisterComponent(containerGuid);
|
|
79
81
|
const isBlocked = scrollBlockManager.isBlocked();
|
|
@@ -88,14 +90,14 @@ const useScrollBlock = () => {
|
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
const originalValues = scrollBlockManager.getOriginalValues();
|
|
91
|
-
|
|
93
|
+
getRules().forEach(({
|
|
92
94
|
element,
|
|
93
95
|
property
|
|
94
96
|
}, index) => {
|
|
95
97
|
element.style[property] = originalValues[index];
|
|
96
98
|
});
|
|
97
99
|
scrollBlockManager.saveOriginalValues([]);
|
|
98
|
-
}, [containerGuid
|
|
100
|
+
}, [containerGuid]);
|
|
99
101
|
return {
|
|
100
102
|
blockScroll,
|
|
101
103
|
allowScroll
|
|
@@ -57,7 +57,7 @@ const ValidationIcon = ({
|
|
|
57
57
|
const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ["bottom", "left", "right", "top"].includes(override));
|
|
58
58
|
|
|
59
59
|
if (tooltipFlipOverrides) {
|
|
60
|
-
(0, _invariant.default)(
|
|
60
|
+
!flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The tooltipFlipOverrides prop supplied to ValidationIcon must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const {
|
|
@@ -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";
|