carbon-react 105.0.0 → 105.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/__internal__/popover/popover.component.d.ts +1 -1
- package/esm/__internal__/popover/popover.component.js +15 -5
- package/esm/components/button/button.component.js +1 -1
- package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +2 -1
- package/esm/components/menu/menu.component.js +2 -1
- package/esm/components/menu/menu.context.d.ts +1 -0
- package/esm/components/menu/menu.context.js +2 -1
- package/esm/components/menu/menu.d.ts +1 -0
- package/esm/components/modal/modal.component.js +2 -1
- package/esm/components/multi-action-button/multi-action-button.component.js +1 -1
- package/esm/components/select/__internal__/select-text/select-text.component.d.ts +1 -5
- package/esm/components/select/__internal__/select-text/select-text.component.js +4 -28
- package/esm/components/select/select-textbox/select-textbox.component.js +5 -2
- package/esm/components/split-button/split-button.component.js +1 -1
- package/esm/components/tile/tile.component.d.ts +3 -2
- package/esm/components/tile/tile.component.js +14 -2
- package/esm/components/tile/tile.d.ts +2 -0
- package/esm/components/toast/toast.component.d.ts +1 -1
- package/esm/components/toast/toast.component.js +10 -2
- package/esm/components/vertical-divider/index.d.ts +1 -2
- package/esm/components/vertical-divider/vertical-divider.component.d.ts +11 -9
- package/esm/components/vertical-divider/vertical-divider.component.js +1410 -25
- package/esm/components/vertical-divider/vertical-divider.style.d.ts +4 -2
- package/esm/components/vertical-divider/vertical-divider.style.js +1 -1
- package/lib/__internal__/popover/popover.component.d.ts +1 -1
- package/lib/__internal__/popover/popover.component.js +15 -4
- package/lib/components/button/button.component.js +1 -1
- package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +2 -1
- package/lib/components/menu/menu.component.js +2 -1
- package/lib/components/menu/menu.context.d.ts +1 -0
- package/lib/components/menu/menu.context.js +2 -1
- package/lib/components/menu/menu.d.ts +1 -0
- package/lib/components/modal/modal.component.js +2 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +1 -1
- package/lib/components/select/__internal__/select-text/select-text.component.d.ts +1 -5
- package/lib/components/select/__internal__/select-text/select-text.component.js +4 -33
- package/lib/components/select/select-textbox/select-textbox.component.js +5 -2
- package/lib/components/split-button/split-button.component.js +1 -1
- package/lib/components/tile/tile.component.d.ts +3 -2
- package/lib/components/tile/tile.component.js +17 -2
- package/lib/components/tile/tile.d.ts +2 -0
- package/lib/components/toast/toast.component.d.ts +1 -1
- package/lib/components/toast/toast.component.js +13 -2
- package/lib/components/vertical-divider/index.d.ts +1 -2
- package/lib/components/vertical-divider/vertical-divider.component.d.ts +11 -9
- package/lib/components/vertical-divider/vertical-divider.component.js +1459 -28
- package/lib/components/vertical-divider/vertical-divider.style.d.ts +4 -2
- package/lib/components/vertical-divider/vertical-divider.style.js +1 -1
- package/package.json +1 -1
- package/esm/components/vertical-divider/vertical-divider.d.ts +0 -113
- package/lib/components/vertical-divider/vertical-divider.d.ts +0 -113
|
@@ -16,7 +16,7 @@ declare namespace Popover {
|
|
|
16
16
|
const modifiers: PropTypes.Requireable<any[]>;
|
|
17
17
|
const onFirstUpdate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
18
|
const disablePortal: PropTypes.Requireable<boolean>;
|
|
19
|
-
const reference: PropTypes.
|
|
19
|
+
const reference: PropTypes.Validator<PropTypes.InferProps<{
|
|
20
20
|
current: PropTypes.Requireable<any>;
|
|
21
21
|
}>>;
|
|
22
22
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { useEffect, useLayoutEffect, useRef } from "react";
|
|
1
|
+
import React, { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { createPopper } from "@popperjs/core";
|
|
5
5
|
import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
|
|
6
6
|
import StyledBackdrop from "./popover.style";
|
|
7
7
|
import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
|
|
8
|
+
import { ModalContext } from "../../components/modal/modal.component";
|
|
8
9
|
|
|
9
10
|
const Popover = ({
|
|
10
11
|
children,
|
|
@@ -16,10 +17,18 @@ const Popover = ({
|
|
|
16
17
|
disableBackgroundUI
|
|
17
18
|
}) => {
|
|
18
19
|
const elementDOM = useRef();
|
|
20
|
+
const {
|
|
21
|
+
isInModal
|
|
22
|
+
} = useContext(ModalContext);
|
|
23
|
+
let mountNode = document.body;
|
|
24
|
+
|
|
25
|
+
if (isInModal && reference.current) {
|
|
26
|
+
mountNode = reference.current.closest("[role='dialog']");
|
|
27
|
+
}
|
|
19
28
|
|
|
20
29
|
if (!elementDOM.current && !disablePortal) {
|
|
21
30
|
elementDOM.current = document.createElement("div");
|
|
22
|
-
|
|
31
|
+
mountNode.appendChild(elementDOM.current);
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
const popperInstance = useRef();
|
|
@@ -68,10 +77,11 @@ const Popover = ({
|
|
|
68
77
|
useEffect(() => {
|
|
69
78
|
return () => {
|
|
70
79
|
if (!disablePortal) {
|
|
71
|
-
|
|
80
|
+
mountNode.removeChild(elementDOM.current);
|
|
81
|
+
elementDOM.current = null;
|
|
72
82
|
}
|
|
73
83
|
};
|
|
74
|
-
}, [disablePortal]);
|
|
84
|
+
}, [disablePortal, mountNode]);
|
|
75
85
|
|
|
76
86
|
if (disableBackgroundUI) {
|
|
77
87
|
content = /*#__PURE__*/React.createElement(StyledBackdrop, null, content);
|
|
@@ -102,6 +112,6 @@ Popover.propTypes = {
|
|
|
102
112
|
// Reference element, children will be positioned in relation to this element - should be a ref
|
|
103
113
|
reference: PropTypes.shape({
|
|
104
114
|
current: PropTypes.any
|
|
105
|
-
})
|
|
115
|
+
}).isRequired
|
|
106
116
|
};
|
|
107
117
|
export default Popover;
|
|
@@ -78,7 +78,7 @@ const Button = ({
|
|
|
78
78
|
if (!deprecatedWarnTriggered && as) {
|
|
79
79
|
deprecatedWarnTriggered = true;
|
|
80
80
|
Logger.deprecate( // eslint-disable-next-line max-len
|
|
81
|
-
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
81
|
+
"The `as` prop is deprecated and will soon be removed from the `Button` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const [internalRef, setInternalRef] = useState(null);
|
|
@@ -98,7 +98,8 @@ const MenuFullscreen = ({
|
|
|
98
98
|
}, React.Children.map(children, (child, index) => /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
99
99
|
value: {
|
|
100
100
|
inFullscreenView: true,
|
|
101
|
-
menuType
|
|
101
|
+
menuType,
|
|
102
|
+
inMenu: true
|
|
102
103
|
}
|
|
103
104
|
}, child, index < React.Children.count(children) - 1 && /*#__PURE__*/React.createElement(MenuDivider, null)))))))));
|
|
104
105
|
};
|
|
@@ -27,7 +27,7 @@ const MultiActionButton = ({
|
|
|
27
27
|
if (!deprecatedWarnTriggered && as) {
|
|
28
28
|
deprecatedWarnTriggered = true;
|
|
29
29
|
Logger.deprecate( // eslint-disable-next-line max-len
|
|
30
|
-
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
30
|
+
"The `as` prop is deprecated and will soon be removed from the `MultiActionButton` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const ref = useRef();
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export default SelectText;
|
|
2
|
-
declare function SelectText({ disabled, formattedValue, onClick, onKeyDown,
|
|
2
|
+
declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onMouseDown, placeholder, readOnly, textId, transparent, }: {
|
|
3
3
|
disabled: any;
|
|
4
4
|
formattedValue?: string | undefined;
|
|
5
5
|
onClick: any;
|
|
6
6
|
onKeyDown: any;
|
|
7
|
-
onFocus: any;
|
|
8
|
-
onBlur: any;
|
|
9
7
|
onMouseDown: any;
|
|
10
8
|
placeholder: any;
|
|
11
9
|
readOnly: any;
|
|
@@ -16,9 +14,7 @@ declare namespace SelectText {
|
|
|
16
14
|
namespace propTypes {
|
|
17
15
|
const disabled: PropTypes.Requireable<boolean>;
|
|
18
16
|
const formattedValue: PropTypes.Requireable<string>;
|
|
19
|
-
const onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
17
|
const onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
21
|
-
const onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
18
|
const onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
19
|
const onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
20
|
const placeholder: PropTypes.Requireable<string>;
|
|
@@ -1,38 +1,22 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import StyledSelectText from "./select-text.style";
|
|
4
|
-
import { InputContext } from "../../../../__internal__/input-behaviour";
|
|
5
4
|
|
|
6
5
|
const SelectText = ({
|
|
7
6
|
disabled,
|
|
8
7
|
formattedValue = "",
|
|
9
8
|
onClick,
|
|
10
9
|
onKeyDown,
|
|
11
|
-
onFocus,
|
|
12
|
-
onBlur,
|
|
13
10
|
onMouseDown,
|
|
14
11
|
placeholder,
|
|
15
12
|
readOnly,
|
|
16
13
|
textId,
|
|
17
14
|
transparent
|
|
18
15
|
}) => {
|
|
19
|
-
const inputContext = useContext(InputContext);
|
|
20
16
|
const hasPlaceholder = !disabled && !readOnly && !formattedValue;
|
|
21
17
|
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (onFocus) {
|
|
26
|
-
onFocus(event);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function handleBlur(event) {
|
|
31
|
-
inputContext.onBlur(event);
|
|
32
|
-
|
|
33
|
-
if (onBlur) {
|
|
34
|
-
onBlur(event);
|
|
35
|
-
}
|
|
18
|
+
function handleClick(event) {
|
|
19
|
+
onClick(event);
|
|
36
20
|
}
|
|
37
21
|
|
|
38
22
|
return /*#__PURE__*/React.createElement(StyledSelectText, {
|
|
@@ -41,9 +25,7 @@ const SelectText = ({
|
|
|
41
25
|
disabled: disabled,
|
|
42
26
|
hasPlaceholder: hasPlaceholder,
|
|
43
27
|
id: textId,
|
|
44
|
-
|
|
45
|
-
onClick: onClick,
|
|
46
|
-
onFocus: handleFocus,
|
|
28
|
+
onClick: handleClick,
|
|
47
29
|
onKeyDown: onKeyDown,
|
|
48
30
|
onMouseDown: onMouseDown,
|
|
49
31
|
readOnly: readOnly,
|
|
@@ -60,15 +42,9 @@ SelectText.propTypes = {
|
|
|
60
42
|
/** Value to be displayed */
|
|
61
43
|
formattedValue: PropTypes.string,
|
|
62
44
|
|
|
63
|
-
/** Callback function for when the Select Textbox loses it's focus. */
|
|
64
|
-
onBlur: PropTypes.func,
|
|
65
|
-
|
|
66
45
|
/** Callback function for when the component is clicked. */
|
|
67
46
|
onClick: PropTypes.func,
|
|
68
47
|
|
|
69
|
-
/** Callback function for when the Select Textbox is focused. */
|
|
70
|
-
onFocus: PropTypes.func,
|
|
71
|
-
|
|
72
48
|
/** Callback function for when the key is pressed when focused on Select Text. */
|
|
73
49
|
onKeyDown: PropTypes.func,
|
|
74
50
|
|
|
@@ -150,8 +150,11 @@ const SelectTextbox = ({
|
|
|
150
150
|
textId: textId.current,
|
|
151
151
|
transparent: transparent,
|
|
152
152
|
onKeyDown: handleSelectTextKeydown,
|
|
153
|
-
placeholder: placeholder || l.select.placeholder()
|
|
154
|
-
|
|
153
|
+
placeholder: placeholder || l.select.placeholder(),
|
|
154
|
+
onClick: handleTextboxClick,
|
|
155
|
+
disabled: disabled,
|
|
156
|
+
readOnly: readOnly
|
|
157
|
+
}, restProps));
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
function handleSelectTextKeydown(event) {
|
|
@@ -37,7 +37,7 @@ const SplitButton = ({
|
|
|
37
37
|
if (!deprecatedWarnTriggered && as) {
|
|
38
38
|
deprecatedWarnTriggered = true;
|
|
39
39
|
Logger.deprecate( // eslint-disable-next-line max-len
|
|
40
|
-
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
40
|
+
"The `as` prop is deprecated and will soon be removed from the `SplitButton` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const theme = useContext(ThemeContext) || baseTheme;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default Tile;
|
|
2
|
-
declare function Tile({ as, p, children, orientation, width, ...props }: {
|
|
2
|
+
declare function Tile({ as, variant, p, children, orientation, width, ...props }: {
|
|
3
3
|
[x: string]: any;
|
|
4
|
-
as
|
|
4
|
+
as: any;
|
|
5
|
+
variant?: string | undefined;
|
|
5
6
|
p?: number | undefined;
|
|
6
7
|
children: any;
|
|
7
8
|
orientation?: string | undefined;
|
|
@@ -4,15 +4,24 @@ import React from "react";
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import propTypes from "@styled-system/prop-types";
|
|
6
6
|
import { StyledTile, TileContent } from "./tile.style.js";
|
|
7
|
+
import Logger from "../../__internal__/utils/logger";
|
|
8
|
+
let deprecatedWarnTriggered = false;
|
|
7
9
|
|
|
8
10
|
const Tile = ({
|
|
9
|
-
as
|
|
11
|
+
as,
|
|
12
|
+
variant = "tile",
|
|
10
13
|
p = 3,
|
|
11
14
|
children,
|
|
12
15
|
orientation = "horizontal",
|
|
13
16
|
width,
|
|
14
17
|
...props
|
|
15
18
|
}) => {
|
|
19
|
+
if (!deprecatedWarnTriggered && as) {
|
|
20
|
+
deprecatedWarnTriggered = true;
|
|
21
|
+
Logger.deprecate( // eslint-disable-next-line max-len
|
|
22
|
+
"The `as` prop is deprecated and will soon be removed from the `Tile` component interface. You should use the `variant` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
const isHorizontal = () => orientation === "horizontal";
|
|
17
26
|
|
|
18
27
|
const isVertical = () => orientation === "vertical";
|
|
@@ -41,7 +50,7 @@ const Tile = ({
|
|
|
41
50
|
}), /*#__PURE__*/React.cloneElement(child, childProps));
|
|
42
51
|
});
|
|
43
52
|
return /*#__PURE__*/React.createElement(StyledTile, _extends({
|
|
44
|
-
tileTheme: as,
|
|
53
|
+
tileTheme: as || variant,
|
|
45
54
|
width: width,
|
|
46
55
|
"data-component": "tile",
|
|
47
56
|
isHorizontal: isHorizontal(orientation),
|
|
@@ -56,6 +65,9 @@ Tile.propTypes = {
|
|
|
56
65
|
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
57
66
|
as: PropTypes.oneOf(["tile", "transparent"]),
|
|
58
67
|
|
|
68
|
+
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
69
|
+
variant: PropTypes.oneOf(["tile", "transparent"]),
|
|
70
|
+
|
|
59
71
|
/**
|
|
60
72
|
* The content to render within the tile. Each child will be wrapped with
|
|
61
73
|
* a TileContent wrapper, which allows any individual child component to take a
|
|
@@ -4,6 +4,8 @@ import { SpaceProps } from "styled-system";
|
|
|
4
4
|
export interface TileProps extends SpaceProps {
|
|
5
5
|
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
6
6
|
as?: "tile" | "transparent";
|
|
7
|
+
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
8
|
+
variant?: "tile" | "transparent";
|
|
7
9
|
/**
|
|
8
10
|
* The content to render within the tile. Each child will be wrapped with
|
|
9
11
|
* a TileContent wrapper, which allows any individual child component to take a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Toast;
|
|
2
2
|
declare function Toast({ as, children, className, id, isCenter, maxWidth, onDismiss, open, targetPortalId, timeout, variant, ...restProps }: {
|
|
3
3
|
[x: string]: any;
|
|
4
|
-
as
|
|
4
|
+
as: any;
|
|
5
5
|
children: any;
|
|
6
6
|
className: any;
|
|
7
7
|
id: any;
|
|
@@ -11,9 +11,11 @@ import IconButton from "../icon-button";
|
|
|
11
11
|
import ModalManager from "../modal/__internal__/modal-manager";
|
|
12
12
|
import Events from "../../__internal__/utils/helpers/events";
|
|
13
13
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
14
|
+
import Logger from "../../__internal__/utils/logger";
|
|
15
|
+
let deprecatedWarnTriggered = false;
|
|
14
16
|
|
|
15
17
|
const Toast = ({
|
|
16
|
-
as
|
|
18
|
+
as,
|
|
17
19
|
children,
|
|
18
20
|
className,
|
|
19
21
|
id,
|
|
@@ -26,6 +28,12 @@ const Toast = ({
|
|
|
26
28
|
variant,
|
|
27
29
|
...restProps
|
|
28
30
|
}) => {
|
|
31
|
+
if (!deprecatedWarnTriggered && as) {
|
|
32
|
+
deprecatedWarnTriggered = true;
|
|
33
|
+
Logger.deprecate( // eslint-disable-next-line max-len
|
|
34
|
+
"The `as` prop is deprecated and will soon be removed from the `Toast` component interface. You should use the `variant` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
const locale = useLocale();
|
|
30
38
|
const toastRef = useRef();
|
|
31
39
|
const timer = useRef();
|
|
@@ -74,7 +82,7 @@ const Toast = ({
|
|
|
74
82
|
if (!open) return null;
|
|
75
83
|
const toastProps = {
|
|
76
84
|
isCenter,
|
|
77
|
-
variant: variant || as,
|
|
85
|
+
variant: variant || as || "success",
|
|
78
86
|
id,
|
|
79
87
|
maxWidth
|
|
80
88
|
};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default } from "./vertical-divider";
|
|
2
|
-
export * from "./vertical-divider";
|
|
1
|
+
export { default } from "./vertical-divider.component";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
declare type TintRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100;
|
|
4
|
+
export interface VerticalDividerPropTypes extends SpaceProps {
|
|
5
|
+
h?: number | string;
|
|
6
|
+
height?: number | string;
|
|
7
|
+
displayInline?: boolean;
|
|
8
|
+
/** the supported rage is 1-100 */
|
|
9
|
+
tint?: TintRange;
|
|
10
10
|
}
|
|
11
|
+
declare const VerticalDivider: ({ h, height, displayInline, tint, ...props }: VerticalDividerPropTypes) => JSX.Element;
|
|
12
|
+
export default VerticalDivider;
|