carbon-react 120.3.1 → 120.5.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/__spec_helper__/test-utils.d.ts +4 -1
- package/esm/__spec_helper__/test-utils.js +18 -2
- package/esm/components/message/message.component.d.ts +1 -1
- package/esm/components/message/message.component.js +1 -1
- package/esm/components/message/message.style.js +3 -2
- package/esm/components/message/type-icon/type-icon.component.js +6 -1
- package/esm/components/message/type-icon/type-icon.style.js +4 -2
- package/esm/components/multi-action-button/multi-action-button.style.js +2 -2
- package/esm/components/sidebar/sidebar.style.js +2 -2
- package/esm/components/tile/tile.component.d.ts +5 -1
- package/esm/components/tile/tile.component.js +5 -1
- package/esm/components/tile/tile.style.d.ts +3 -2
- package/esm/components/tile/tile.style.js +12 -12
- package/esm/components/toast/toast.component.d.ts +4 -1
- package/esm/components/toast/toast.component.js +27 -5
- package/esm/components/toast/toast.config.js +1 -1
- package/esm/components/toast/toast.style.d.ts +4 -0
- package/esm/components/toast/toast.style.js +36 -3
- package/esm/style/utils/element-sizing.d.ts +6 -0
- package/esm/style/utils/{width.js → element-sizing.js} +5 -4
- package/lib/__spec_helper__/test-utils.d.ts +4 -1
- package/lib/__spec_helper__/test-utils.js +19 -2
- package/lib/components/message/message.component.d.ts +1 -1
- package/lib/components/message/message.component.js +1 -1
- package/lib/components/message/message.style.js +3 -2
- package/lib/components/message/type-icon/type-icon.component.js +6 -1
- package/lib/components/message/type-icon/type-icon.style.js +4 -2
- package/lib/components/multi-action-button/multi-action-button.style.js +2 -2
- package/lib/components/sidebar/sidebar.style.js +2 -2
- package/lib/components/tile/tile.component.d.ts +5 -1
- package/lib/components/tile/tile.component.js +5 -1
- package/lib/components/tile/tile.style.d.ts +3 -2
- package/lib/components/tile/tile.style.js +12 -12
- package/lib/components/toast/toast.component.d.ts +4 -1
- package/lib/components/toast/toast.component.js +27 -5
- package/lib/components/toast/toast.config.js +1 -1
- package/lib/components/toast/toast.style.d.ts +4 -0
- package/lib/components/toast/toast.style.js +36 -3
- package/lib/style/utils/element-sizing.d.ts +6 -0
- package/lib/style/utils/{width.js → element-sizing.js} +5 -4
- package/package.json +1 -1
- package/esm/style/utils/width.d.ts +0 -3
- package/lib/style/utils/width.d.ts +0 -3
|
@@ -44,10 +44,13 @@ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.
|
|
|
44
44
|
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
45
45
|
width: string;
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
|
+
declare const testStyledSystemHeight: (component: (heightProperties?: {
|
|
48
|
+
height: string;
|
|
49
|
+
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
50
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
51
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
52
|
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
53
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
54
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
52
55
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
53
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
56
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -83,7 +83,8 @@ const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"
|
|
|
83
83
|
const paddingProps = [["p", "padding"], ["pl", "paddingLeft"], ["pr", "paddingRight"], ["pt", "paddingTop"], ["pb", "paddingBottom"], ["px", "paddingLeft"], ["px", "paddingRight"], ["py", "paddingTop"], ["py", "paddingBottom"]];
|
|
84
84
|
const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#FFFFFF"], ["opacity", "opacity", "0.5"]];
|
|
85
85
|
const widthProps = ["width", "width", "200px"];
|
|
86
|
-
const
|
|
86
|
+
const heightProps = ["height", "height", "200px"];
|
|
87
|
+
const layoutProps = [widthProps, heightProps, ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
87
88
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
88
89
|
const gridProps = [["gridColumn", "gridColumn", "1 / span 2"], ["gridRow", "gridRow", "1 / span 2"], ["gridArea", "gridArea", "myArea"], ["gridAutoFlow", "gridAutoFlow", "column"], ["gridAutoRows", "gridAutoRows", "150px"], ["gridAutoColumns", "gridAutoColumns", "50px"], ["gridTemplateRows", "gridTemplateRows", "100px 300px"], ["gridTemplateColumns", "gridTemplateColumns", "auto auto auto auto"], ["gridTemplateAreas", "gridTemplateAreas", "myArea myArea . . ."]];
|
|
89
90
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
@@ -241,6 +242,21 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
241
242
|
});
|
|
242
243
|
});
|
|
243
244
|
};
|
|
245
|
+
const testStyledSystemHeight = (component, styleContainer) => {
|
|
246
|
+
describe("when a height prop is specified using styled system props", () => {
|
|
247
|
+
it("then height should have been set correctly", () => {
|
|
248
|
+
const [styledSystemProp, propName, value] = heightProps;
|
|
249
|
+
const props = {
|
|
250
|
+
[styledSystemProp]: value
|
|
251
|
+
};
|
|
252
|
+
const wrapper = mount(component({
|
|
253
|
+
...props
|
|
254
|
+
}));
|
|
255
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
256
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
};
|
|
244
260
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
245
261
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
246
262
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -339,4 +355,4 @@ const expectConsoleOutput = (message, type = "error") => {
|
|
|
339
355
|
global.console[type] = consoleType;
|
|
340
356
|
};
|
|
341
357
|
};
|
|
342
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput };
|
|
358
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
|
-
export declare type MessageVariant = "error" | "info" | "success" | "warning";
|
|
3
|
+
export declare type MessageVariant = "error" | "info" | "success" | "warning" | "neutral";
|
|
4
4
|
export interface MessageProps extends MarginProps {
|
|
5
5
|
/** set content to component */
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -217,7 +217,7 @@ Message.propTypes = {
|
|
|
217
217
|
"showCloseIcon": PropTypes.bool,
|
|
218
218
|
"title": PropTypes.node,
|
|
219
219
|
"transparent": PropTypes.bool,
|
|
220
|
-
"variant": PropTypes.oneOf(["error", "info", "success", "warning"])
|
|
220
|
+
"variant": PropTypes.oneOf(["error", "info", "neutral", "success", "warning"])
|
|
221
221
|
};
|
|
222
222
|
export { Message };
|
|
223
223
|
Message.displayName = "Message";
|
|
@@ -4,9 +4,10 @@ import BaseTheme from "../../style/themes/base";
|
|
|
4
4
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
5
5
|
const messageVariants = {
|
|
6
6
|
error: "var(--colorsSemanticNegative500)",
|
|
7
|
-
info: "var(--
|
|
7
|
+
info: "var(--colorsSemanticInfo500)",
|
|
8
8
|
success: "var(--colorsSemanticPositive500)",
|
|
9
|
-
warning: "var(--colorsSemanticCaution500)"
|
|
9
|
+
warning: "var(--colorsSemanticCaution500)",
|
|
10
|
+
neutral: "var(--colorsSemanticNeutral500)"
|
|
10
11
|
};
|
|
11
12
|
const MessageStyle = styled.div`
|
|
12
13
|
position: relative;
|
|
@@ -6,11 +6,16 @@ const TypeIcon = ({
|
|
|
6
6
|
variant = "info",
|
|
7
7
|
transparent = false
|
|
8
8
|
}) => {
|
|
9
|
+
function iconToRender() {
|
|
10
|
+
if (variant === "neutral") return "info";
|
|
11
|
+
if (variant === "success") return "tick_circle";
|
|
12
|
+
return variant;
|
|
13
|
+
}
|
|
9
14
|
return /*#__PURE__*/React.createElement(TypeIconStyle, {
|
|
10
15
|
variant: variant,
|
|
11
16
|
transparent: transparent
|
|
12
17
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
13
|
-
type:
|
|
18
|
+
type: iconToRender()
|
|
14
19
|
}));
|
|
15
20
|
};
|
|
16
21
|
export default TypeIcon;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
const messageVariants = {
|
|
3
3
|
error: "var(--colorsSemanticNegative500)",
|
|
4
|
-
info: "var(--
|
|
4
|
+
info: "var(--colorsSemanticInfo500)",
|
|
5
5
|
success: "var(--colorsSemanticPositive500)",
|
|
6
|
-
warning: "var(--colorsSemanticCaution500)"
|
|
6
|
+
warning: "var(--colorsSemanticCaution500)",
|
|
7
|
+
neutral: "var(--colorsSemanticNeutral500)",
|
|
8
|
+
notification: "var(--colorsSemanticInfo500)"
|
|
7
9
|
};
|
|
8
10
|
const TypeIconStyle = styled.div`
|
|
9
11
|
align-items: center;
|
|
@@ -3,7 +3,7 @@ import { margin } from "styled-system";
|
|
|
3
3
|
import StyledButton from "../button/button.style";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
5
|
import StyledIcon from "../icon/icon.style";
|
|
6
|
-
import
|
|
6
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
7
7
|
import { borderRadiusStyling } from "../split-button/split-button-children.style";
|
|
8
8
|
const StyledMultiActionButton = styled.div`
|
|
9
9
|
${margin}
|
|
@@ -14,7 +14,7 @@ const StyledMultiActionButton = styled.div`
|
|
|
14
14
|
${({
|
|
15
15
|
width
|
|
16
16
|
}) => width && css`
|
|
17
|
-
${
|
|
17
|
+
${computeSizing({
|
|
18
18
|
width
|
|
19
19
|
})}
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import
|
|
2
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
4
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
5
5
|
import { calculateFormSpacingValues, calculateWidthValue } from "../../style/utils/form-style-utils";
|
|
@@ -39,7 +39,7 @@ const StyledSidebar = styled.div`
|
|
|
39
39
|
${!width && size && css`
|
|
40
40
|
width: ${SIDEBAR_SIZES_CSS[size]};
|
|
41
41
|
`}
|
|
42
|
-
${width &&
|
|
42
|
+
${width && computeSizing({
|
|
43
43
|
width
|
|
44
44
|
})}
|
|
45
45
|
|
|
@@ -26,6 +26,10 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
26
26
|
borderVariant?: "default" | "selected" | "positive" | "negative" | "caution" | "info";
|
|
27
27
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
28
|
roundness?: "default" | "large";
|
|
29
|
+
/**
|
|
30
|
+
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
height?: string | number;
|
|
29
33
|
}
|
|
30
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, ...props }: TileProps) => React.JSX.Element;
|
|
34
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...props }: TileProps) => React.JSX.Element;
|
|
31
35
|
export default Tile;
|
|
@@ -7,8 +7,9 @@ export const Tile = ({
|
|
|
7
7
|
p = 3,
|
|
8
8
|
children,
|
|
9
9
|
orientation = "horizontal",
|
|
10
|
-
width,
|
|
10
|
+
width = "100%",
|
|
11
11
|
roundness = "default",
|
|
12
|
+
height,
|
|
12
13
|
...props
|
|
13
14
|
}) => {
|
|
14
15
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -24,12 +25,14 @@ export const Tile = ({
|
|
|
24
25
|
}
|
|
25
26
|
const {
|
|
26
27
|
width: contentWidth,
|
|
28
|
+
height: contentHeight,
|
|
27
29
|
...childProps
|
|
28
30
|
} = child.props;
|
|
29
31
|
const key = child.key || `tile-content-${index + 1}`;
|
|
30
32
|
return /*#__PURE__*/React.createElement(TileContent, _extends({
|
|
31
33
|
key: key,
|
|
32
34
|
width: contentWidth,
|
|
35
|
+
height: contentHeight,
|
|
33
36
|
isHorizontal: isHorizontal,
|
|
34
37
|
isVertical: isVertical
|
|
35
38
|
}, isVertical && {
|
|
@@ -43,6 +46,7 @@ export const Tile = ({
|
|
|
43
46
|
return /*#__PURE__*/React.createElement(StyledTile, _extends({
|
|
44
47
|
variant: variant,
|
|
45
48
|
width: width,
|
|
49
|
+
height: height,
|
|
46
50
|
"data-component": "tile",
|
|
47
51
|
isHorizontal: isHorizontal,
|
|
48
52
|
p: p,
|
|
@@ -3,10 +3,11 @@ import { TileProps } from "./tile.component";
|
|
|
3
3
|
interface TileContentProps {
|
|
4
4
|
isHorizontal?: boolean;
|
|
5
5
|
isVertical?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: TileProps["width"];
|
|
7
|
+
height?: TileProps["height"];
|
|
7
8
|
}
|
|
8
9
|
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
9
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
11
|
isHorizontal?: boolean | undefined;
|
|
11
12
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
12
13
|
export { StyledTile, TileContent };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { space } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
|
-
import
|
|
4
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
5
5
|
const getBorderColor = borderVariant => {
|
|
6
6
|
switch (borderVariant) {
|
|
7
7
|
case "selected":
|
|
@@ -22,7 +22,8 @@ const TileContent = styled.div`
|
|
|
22
22
|
${({
|
|
23
23
|
isHorizontal,
|
|
24
24
|
isVertical,
|
|
25
|
-
width
|
|
25
|
+
width,
|
|
26
|
+
height
|
|
26
27
|
}) => css`
|
|
27
28
|
${space}
|
|
28
29
|
|
|
@@ -64,10 +65,11 @@ const TileContent = styled.div`
|
|
|
64
65
|
}
|
|
65
66
|
`}
|
|
66
67
|
|
|
67
|
-
${width && css`
|
|
68
|
+
${(width || height) && css`
|
|
68
69
|
flex-grow: 0;
|
|
69
|
-
${
|
|
70
|
-
width
|
|
70
|
+
${computeSizing({
|
|
71
|
+
width: width || /* istanbul ignore next */undefined,
|
|
72
|
+
height: height || undefined
|
|
71
73
|
})}
|
|
72
74
|
`}
|
|
73
75
|
`}
|
|
@@ -79,7 +81,8 @@ const StyledTile = styled.div`
|
|
|
79
81
|
isHorizontal,
|
|
80
82
|
variant,
|
|
81
83
|
width,
|
|
82
|
-
roundness
|
|
84
|
+
roundness,
|
|
85
|
+
height
|
|
83
86
|
}) => css`
|
|
84
87
|
${space}
|
|
85
88
|
|
|
@@ -104,13 +107,10 @@ const StyledTile = styled.div`
|
|
|
104
107
|
display: flex;
|
|
105
108
|
flex-direction: ${isHorizontal ? "row" : "column"};
|
|
106
109
|
position: relative;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
${computeWidth({
|
|
111
|
-
width
|
|
110
|
+
${computeSizing({
|
|
111
|
+
width: width || /* istanbul ignore next */undefined,
|
|
112
|
+
height: height || undefined
|
|
112
113
|
})}
|
|
113
|
-
`}
|
|
114
114
|
`}
|
|
115
115
|
`;
|
|
116
116
|
TileContent.defaultProps = {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare type ToastVariants = "error" | "info" | "success" | "warning" | "notice";
|
|
2
|
+
declare type ToastVariants = "error" | "info" | "success" | "warning" | "notice" | "neutral" | "notification";
|
|
3
|
+
declare type AlignOptions = "left" | "center" | "right";
|
|
3
4
|
export interface ToastProps {
|
|
5
|
+
/** Sets the alignment of the component. */
|
|
6
|
+
align?: AlignOptions;
|
|
4
7
|
/** The rendered children of the component. */
|
|
5
8
|
children: React.ReactNode;
|
|
6
9
|
/** Customizes the appearance in the DLS theme */
|
|
@@ -9,7 +9,10 @@ import IconButton from "../icon-button";
|
|
|
9
9
|
import Events from "../../__internal__/utils/helpers/events";
|
|
10
10
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
11
11
|
import useModalManager from "../../hooks/__internal__/useModalManager";
|
|
12
|
+
import Logger from "../../__internal__/utils/logger";
|
|
13
|
+
let isDeprecationWarningTriggered = false;
|
|
12
14
|
const Toast = /*#__PURE__*/React.forwardRef(({
|
|
15
|
+
align,
|
|
13
16
|
children,
|
|
14
17
|
className,
|
|
15
18
|
id,
|
|
@@ -24,6 +27,7 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
24
27
|
...restProps
|
|
25
28
|
}, ref) => {
|
|
26
29
|
const isNotice = variant === "notice";
|
|
30
|
+
const isNotification = variant === "notification";
|
|
27
31
|
const locale = useLocale();
|
|
28
32
|
const toastRef = useRef(null);
|
|
29
33
|
const timer = useRef(null);
|
|
@@ -35,6 +39,10 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
35
39
|
if (ref && typeof ref === "object" && "current" in ref) {
|
|
36
40
|
refToPass = ref;
|
|
37
41
|
}
|
|
42
|
+
if (isCenter !== undefined && !isDeprecationWarningTriggered) {
|
|
43
|
+
isDeprecationWarningTriggered = true;
|
|
44
|
+
Logger.deprecate(`isCenter prop in ${Toast.displayName} is being deprecated in favour of the align prop.`);
|
|
45
|
+
}
|
|
38
46
|
const dismissToast = useCallback(ev => {
|
|
39
47
|
if (onDismiss && Events.isEscKey(ev)) {
|
|
40
48
|
ev.stopImmediatePropagation();
|
|
@@ -87,10 +95,19 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
87
95
|
type: "close"
|
|
88
96
|
}));
|
|
89
97
|
}
|
|
98
|
+
const iconToRender = {
|
|
99
|
+
notification: "alert",
|
|
100
|
+
neutral: "info",
|
|
101
|
+
success: "tick_circle",
|
|
102
|
+
error: "error",
|
|
103
|
+
info: "info",
|
|
104
|
+
warning: "warning"
|
|
105
|
+
};
|
|
106
|
+
const toastIcon = iconToRender[variant] || "none";
|
|
90
107
|
function renderToastContent() {
|
|
91
108
|
if (!open) return null;
|
|
92
109
|
let toastVariant;
|
|
93
|
-
if (
|
|
110
|
+
if (!isNotice && !isNotification) {
|
|
94
111
|
toastVariant = variant;
|
|
95
112
|
}
|
|
96
113
|
return /*#__PURE__*/React.createElement(CSSTransition, {
|
|
@@ -103,7 +120,9 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
103
120
|
},
|
|
104
121
|
nodeRef: toastContentNodeRef
|
|
105
122
|
}, /*#__PURE__*/React.createElement(ToastStyle, _extends({
|
|
123
|
+
align: align,
|
|
106
124
|
isNotice: isNotice,
|
|
125
|
+
isNotification: isNotification,
|
|
107
126
|
className: className
|
|
108
127
|
}, tagComponent(restProps["data-component"] || "toast", restProps), {
|
|
109
128
|
isCenter: isCenter,
|
|
@@ -114,10 +133,10 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
114
133
|
}, !disableAutoFocus && {
|
|
115
134
|
tabIndex,
|
|
116
135
|
onBlur: () => setTabIndex(undefined)
|
|
117
|
-
}),
|
|
118
|
-
variant: variant
|
|
136
|
+
}), !isNotice && /*#__PURE__*/React.createElement(TypeIcon, {
|
|
137
|
+
variant: isNotification ? "info" : variant
|
|
119
138
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
120
|
-
type:
|
|
139
|
+
type: toastIcon
|
|
121
140
|
})), /*#__PURE__*/React.createElement(ToastContentStyle, {
|
|
122
141
|
isNotice: isNotice,
|
|
123
142
|
isDismiss: !!onDismiss
|
|
@@ -125,15 +144,18 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
125
144
|
}
|
|
126
145
|
return /*#__PURE__*/React.createElement(StyledPortal, {
|
|
127
146
|
id: targetPortalId,
|
|
147
|
+
align: align,
|
|
128
148
|
isCenter: isCenter,
|
|
129
149
|
isNotice: isNotice
|
|
130
150
|
}, /*#__PURE__*/React.createElement(ToastWrapper, {
|
|
151
|
+
align: align,
|
|
131
152
|
isCenter: isCenter,
|
|
132
153
|
ref: refToPass,
|
|
133
154
|
isNotice: isNotice
|
|
134
155
|
}, /*#__PURE__*/React.createElement(TransitionGroup, null, renderToastContent())));
|
|
135
156
|
});
|
|
136
157
|
Toast.propTypes = {
|
|
158
|
+
"align": PropTypes.oneOf(["center", "left", "right"]),
|
|
137
159
|
"children": PropTypes.node,
|
|
138
160
|
"className": PropTypes.string,
|
|
139
161
|
"data-component": PropTypes.string,
|
|
@@ -145,7 +167,7 @@ Toast.propTypes = {
|
|
|
145
167
|
"open": PropTypes.bool,
|
|
146
168
|
"targetPortalId": PropTypes.string,
|
|
147
169
|
"timeout": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
148
|
-
"variant": PropTypes.oneOf(["error", "info", "notice", "success", "warning"])
|
|
170
|
+
"variant": PropTypes.oneOf(["error", "info", "neutral", "notice", "notification", "success", "warning"])
|
|
149
171
|
};
|
|
150
172
|
export { Toast };
|
|
151
173
|
Toast.displayName = "Toast";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// eslint-disable-next-line import/prefer-default-export
|
|
2
|
-
export const TOAST_COLORS = ["error", "info", "success", "warning"];
|
|
2
|
+
export const TOAST_COLORS = ["error", "info", "success", "warning", "neutral", "notification"];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import TypeIcon from "../message/type-icon/type-icon.style";
|
|
3
3
|
declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
|
|
4
|
+
align?: "left" | "right" | "center" | undefined;
|
|
4
5
|
isCenter?: boolean | undefined;
|
|
5
6
|
isNotice?: boolean | undefined;
|
|
6
7
|
}, never>;
|
|
@@ -8,15 +9,18 @@ declare const ToastStyle: import("styled-components").StyledComponent<"div", any
|
|
|
8
9
|
variant?: import("../message/message.component").MessageVariant | undefined;
|
|
9
10
|
transparent?: boolean | undefined;
|
|
10
11
|
} & import("styled-system").MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
12
|
+
align?: "left" | "right" | "center" | undefined;
|
|
11
13
|
maxWidth?: string | undefined;
|
|
12
14
|
isCenter?: boolean | undefined;
|
|
13
15
|
isNotice?: boolean | undefined;
|
|
16
|
+
isNotification?: boolean | undefined;
|
|
14
17
|
}, never>;
|
|
15
18
|
declare const ToastContentStyle: import("styled-components").StyledComponent<"div", any, Pick<import("../message/message-content/message-content.component").MessageContentProps, "showCloseIcon"> & {
|
|
16
19
|
isNotice?: boolean | undefined;
|
|
17
20
|
isDismiss?: boolean | undefined;
|
|
18
21
|
}, never>;
|
|
19
22
|
declare const ToastWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
23
|
+
align?: "left" | "right" | "center" | undefined;
|
|
20
24
|
isCenter?: boolean | undefined;
|
|
21
25
|
isNotice?: boolean | undefined;
|
|
22
26
|
}, never>;
|
|
@@ -10,7 +10,8 @@ const StyledPortal = styled(Portal)`
|
|
|
10
10
|
${({
|
|
11
11
|
theme,
|
|
12
12
|
isCenter,
|
|
13
|
-
isNotice
|
|
13
|
+
isNotice,
|
|
14
|
+
align
|
|
14
15
|
}) => css`
|
|
15
16
|
position: fixed;
|
|
16
17
|
top: 0;
|
|
@@ -22,6 +23,22 @@ const StyledPortal = styled(Portal)`
|
|
|
22
23
|
transform: translateX(-50%);
|
|
23
24
|
`}
|
|
24
25
|
|
|
26
|
+
${align === "left" && css`
|
|
27
|
+
left: 12%;
|
|
28
|
+
transform: translateX(-50%);
|
|
29
|
+
`}
|
|
30
|
+
|
|
31
|
+
${align === "center" && css`
|
|
32
|
+
margin-left: 50%;
|
|
33
|
+
transform: translateX(-50%);
|
|
34
|
+
`}
|
|
35
|
+
|
|
36
|
+
${align === "right" && css`
|
|
37
|
+
display: flex;
|
|
38
|
+
right: 0;
|
|
39
|
+
transform: translateX(-50%);
|
|
40
|
+
`}
|
|
41
|
+
|
|
25
42
|
${isNotice && css`
|
|
26
43
|
bottom: 0;
|
|
27
44
|
top: auto;
|
|
@@ -37,7 +54,9 @@ const alternativeAnimationName = ".toast-alternative";
|
|
|
37
54
|
const ToastStyle = styled(MessageStyle)`
|
|
38
55
|
${({
|
|
39
56
|
maxWidth,
|
|
40
|
-
isCenter
|
|
57
|
+
isCenter,
|
|
58
|
+
align,
|
|
59
|
+
isNotification
|
|
41
60
|
}) => css`
|
|
42
61
|
box-shadow: 0 10px 30px 0 rgba(0, 20, 29, 0.1),
|
|
43
62
|
0 30px 60px 0 rgba(0, 20, 29, 0.1);
|
|
@@ -45,7 +64,11 @@ const ToastStyle = styled(MessageStyle)`
|
|
|
45
64
|
margin-top: 30px;
|
|
46
65
|
max-width: ${!maxWidth ? "300px" : maxWidth};
|
|
47
66
|
position: relative;
|
|
48
|
-
margin-right: ${isCenter ? "auto" : "30px"};
|
|
67
|
+
margin-right: ${isCenter || align === "right" ? "auto" : "30px"};
|
|
68
|
+
|
|
69
|
+
${isNotification && css`
|
|
70
|
+
border: 1px solid var(--colorsSemanticInfo500);
|
|
71
|
+
`}
|
|
49
72
|
`}
|
|
50
73
|
|
|
51
74
|
:focus {
|
|
@@ -139,6 +162,16 @@ const ToastContentStyle = styled(MessageContentStyle)`
|
|
|
139
162
|
`}
|
|
140
163
|
`;
|
|
141
164
|
const ToastWrapper = styled.div`
|
|
165
|
+
${({
|
|
166
|
+
align
|
|
167
|
+
}) => align && css`
|
|
168
|
+
position: relative;
|
|
169
|
+
width: auto;
|
|
170
|
+
height: auto;
|
|
171
|
+
justify-content: ${align};
|
|
172
|
+
display: flex;
|
|
173
|
+
`}
|
|
174
|
+
|
|
142
175
|
${({
|
|
143
176
|
isCenter
|
|
144
177
|
}) => isCenter && css`
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// eslint-disable-next-line no-restricted-imports
|
|
2
1
|
import { layout } from "styled-system";
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
* styled-system/layout allows users to use a width, height, minWidth, maxWidth, minHeight, maxHeight,
|
|
6
5
|
* size, display, verticalAlign, overflow, overflowX and overflowY props most of which are usually not needed.
|
|
7
|
-
* That's why the purpose of this function is to pass only the`width`
|
|
6
|
+
* That's why the purpose of this function is to pass only the `width` and `height` props to the `layout` function.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
export default (({
|
|
11
|
-
width
|
|
10
|
+
width,
|
|
11
|
+
height
|
|
12
12
|
}) => layout({
|
|
13
|
-
width
|
|
13
|
+
width,
|
|
14
|
+
height
|
|
14
15
|
}));
|
|
@@ -44,10 +44,13 @@ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.
|
|
|
44
44
|
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
45
45
|
width: string;
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
|
+
declare const testStyledSystemHeight: (component: (heightProperties?: {
|
|
48
|
+
height: string;
|
|
49
|
+
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
50
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
51
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
52
|
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
53
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
54
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
52
55
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
53
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
56
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "mockMatchMedia", {
|
|
|
10
10
|
return _mockMatchMedia.mockMatchMedia;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.toCSSCase = exports.testStyledSystemWidth = exports.testStyledSystemSpacing = exports.testStyledSystemPosition = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemLayout = exports.testStyledSystemGrid = exports.testStyledSystemFlexBox = exports.testStyledSystemColor = exports.testStyledSystemBackground = exports.simulate = exports.selectedItemOf = void 0;
|
|
13
|
+
exports.toCSSCase = exports.testStyledSystemWidth = exports.testStyledSystemSpacing = exports.testStyledSystemPosition = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemLayout = exports.testStyledSystemHeight = exports.testStyledSystemGrid = exports.testStyledSystemFlexBox = exports.testStyledSystemColor = exports.testStyledSystemBackground = exports.simulate = exports.selectedItemOf = void 0;
|
|
14
14
|
var _enzyme = require("enzyme");
|
|
15
15
|
var _sprintfJs = require("sprintf-js");
|
|
16
16
|
var _baseTheme = require("../style/themes/base/base-theme.config");
|
|
@@ -110,7 +110,8 @@ const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"
|
|
|
110
110
|
const paddingProps = [["p", "padding"], ["pl", "paddingLeft"], ["pr", "paddingRight"], ["pt", "paddingTop"], ["pb", "paddingBottom"], ["px", "paddingLeft"], ["px", "paddingRight"], ["py", "paddingTop"], ["py", "paddingBottom"]];
|
|
111
111
|
const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#FFFFFF"], ["opacity", "opacity", "0.5"]];
|
|
112
112
|
const widthProps = ["width", "width", "200px"];
|
|
113
|
-
const
|
|
113
|
+
const heightProps = ["height", "height", "200px"];
|
|
114
|
+
const layoutProps = [widthProps, heightProps, ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
114
115
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
115
116
|
const gridProps = [["gridColumn", "gridColumn", "1 / span 2"], ["gridRow", "gridRow", "1 / span 2"], ["gridArea", "gridArea", "myArea"], ["gridAutoFlow", "gridAutoFlow", "column"], ["gridAutoRows", "gridAutoRows", "150px"], ["gridAutoColumns", "gridAutoColumns", "50px"], ["gridTemplateRows", "gridTemplateRows", "100px 300px"], ["gridTemplateColumns", "gridTemplateColumns", "auto auto auto auto"], ["gridTemplateAreas", "gridTemplateAreas", "myArea myArea . . ."]];
|
|
116
117
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
@@ -274,6 +275,22 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
274
275
|
});
|
|
275
276
|
};
|
|
276
277
|
exports.testStyledSystemWidth = testStyledSystemWidth;
|
|
278
|
+
const testStyledSystemHeight = (component, styleContainer) => {
|
|
279
|
+
describe("when a height prop is specified using styled system props", () => {
|
|
280
|
+
it("then height should have been set correctly", () => {
|
|
281
|
+
const [styledSystemProp, propName, value] = heightProps;
|
|
282
|
+
const props = {
|
|
283
|
+
[styledSystemProp]: value
|
|
284
|
+
};
|
|
285
|
+
const wrapper = (0, _enzyme.mount)(component({
|
|
286
|
+
...props
|
|
287
|
+
}));
|
|
288
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
289
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
exports.testStyledSystemHeight = testStyledSystemHeight;
|
|
277
294
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
278
295
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
279
296
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
|
-
export declare type MessageVariant = "error" | "info" | "success" | "warning";
|
|
3
|
+
export declare type MessageVariant = "error" | "info" | "success" | "warning" | "neutral";
|
|
4
4
|
export interface MessageProps extends MarginProps {
|
|
5
5
|
/** set content to component */
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -227,7 +227,7 @@ Message.propTypes = {
|
|
|
227
227
|
"showCloseIcon": _propTypes.default.bool,
|
|
228
228
|
"title": _propTypes.default.node,
|
|
229
229
|
"transparent": _propTypes.default.bool,
|
|
230
|
-
"variant": _propTypes.default.oneOf(["error", "info", "success", "warning"])
|
|
230
|
+
"variant": _propTypes.default.oneOf(["error", "info", "neutral", "success", "warning"])
|
|
231
231
|
};
|
|
232
232
|
Message.displayName = "Message";
|
|
233
233
|
var _default = Message;
|
|
@@ -13,9 +13,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
14
|
const messageVariants = {
|
|
15
15
|
error: "var(--colorsSemanticNegative500)",
|
|
16
|
-
info: "var(--
|
|
16
|
+
info: "var(--colorsSemanticInfo500)",
|
|
17
17
|
success: "var(--colorsSemanticPositive500)",
|
|
18
|
-
warning: "var(--colorsSemanticCaution500)"
|
|
18
|
+
warning: "var(--colorsSemanticCaution500)",
|
|
19
|
+
neutral: "var(--colorsSemanticNeutral500)"
|
|
19
20
|
};
|
|
20
21
|
const MessageStyle = _styledComponents.default.div`
|
|
21
22
|
position: relative;
|
|
@@ -13,11 +13,16 @@ const TypeIcon = ({
|
|
|
13
13
|
variant = "info",
|
|
14
14
|
transparent = false
|
|
15
15
|
}) => {
|
|
16
|
+
function iconToRender() {
|
|
17
|
+
if (variant === "neutral") return "info";
|
|
18
|
+
if (variant === "success") return "tick_circle";
|
|
19
|
+
return variant;
|
|
20
|
+
}
|
|
16
21
|
return /*#__PURE__*/_react.default.createElement(_typeIcon.default, {
|
|
17
22
|
variant: variant,
|
|
18
23
|
transparent: transparent
|
|
19
24
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
20
|
-
type:
|
|
25
|
+
type: iconToRender()
|
|
21
26
|
}));
|
|
22
27
|
};
|
|
23
28
|
var _default = TypeIcon;
|
|
@@ -9,9 +9,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
9
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
10
|
const messageVariants = {
|
|
11
11
|
error: "var(--colorsSemanticNegative500)",
|
|
12
|
-
info: "var(--
|
|
12
|
+
info: "var(--colorsSemanticInfo500)",
|
|
13
13
|
success: "var(--colorsSemanticPositive500)",
|
|
14
|
-
warning: "var(--colorsSemanticCaution500)"
|
|
14
|
+
warning: "var(--colorsSemanticCaution500)",
|
|
15
|
+
neutral: "var(--colorsSemanticNeutral500)",
|
|
16
|
+
notification: "var(--colorsSemanticInfo500)"
|
|
15
17
|
};
|
|
16
18
|
const TypeIconStyle = _styledComponents.default.div`
|
|
17
19
|
align-items: center;
|
|
@@ -9,7 +9,7 @@ var _styledSystem = require("styled-system");
|
|
|
9
9
|
var _button = _interopRequireDefault(require("../button/button.style"));
|
|
10
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
11
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
12
|
-
var
|
|
12
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
13
13
|
var _splitButtonChildren = require("../split-button/split-button-children.style");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -23,7 +23,7 @@ const StyledMultiActionButton = _styledComponents.default.div`
|
|
|
23
23
|
${({
|
|
24
24
|
width
|
|
25
25
|
}) => width && (0, _styledComponents.css)`
|
|
26
|
-
${(0,
|
|
26
|
+
${(0, _elementSizing.default)({
|
|
27
27
|
width
|
|
28
28
|
})}
|
|
29
29
|
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var
|
|
8
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
10
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
11
11
|
var _formStyleUtils = require("../../style/utils/form-style-utils");
|
|
@@ -48,7 +48,7 @@ const StyledSidebar = _styledComponents.default.div`
|
|
|
48
48
|
${!width && size && (0, _styledComponents.css)`
|
|
49
49
|
width: ${_sidebar.SIDEBAR_SIZES_CSS[size]};
|
|
50
50
|
`}
|
|
51
|
-
${width && (0,
|
|
51
|
+
${width && (0, _elementSizing.default)({
|
|
52
52
|
width
|
|
53
53
|
})}
|
|
54
54
|
|
|
@@ -26,6 +26,10 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
26
26
|
borderVariant?: "default" | "selected" | "positive" | "negative" | "caution" | "info";
|
|
27
27
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
28
|
roundness?: "default" | "large";
|
|
29
|
+
/**
|
|
30
|
+
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
height?: string | number;
|
|
29
33
|
}
|
|
30
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, ...props }: TileProps) => React.JSX.Element;
|
|
34
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...props }: TileProps) => React.JSX.Element;
|
|
31
35
|
export default Tile;
|
|
@@ -14,8 +14,9 @@ const Tile = ({
|
|
|
14
14
|
p = 3,
|
|
15
15
|
children,
|
|
16
16
|
orientation = "horizontal",
|
|
17
|
-
width,
|
|
17
|
+
width = "100%",
|
|
18
18
|
roundness = "default",
|
|
19
|
+
height,
|
|
19
20
|
...props
|
|
20
21
|
}) => {
|
|
21
22
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -31,12 +32,14 @@ const Tile = ({
|
|
|
31
32
|
}
|
|
32
33
|
const {
|
|
33
34
|
width: contentWidth,
|
|
35
|
+
height: contentHeight,
|
|
34
36
|
...childProps
|
|
35
37
|
} = child.props;
|
|
36
38
|
const key = child.key || `tile-content-${index + 1}`;
|
|
37
39
|
return /*#__PURE__*/_react.default.createElement(_tile.TileContent, _extends({
|
|
38
40
|
key: key,
|
|
39
41
|
width: contentWidth,
|
|
42
|
+
height: contentHeight,
|
|
40
43
|
isHorizontal: isHorizontal,
|
|
41
44
|
isVertical: isVertical
|
|
42
45
|
}, isVertical && {
|
|
@@ -50,6 +53,7 @@ const Tile = ({
|
|
|
50
53
|
return /*#__PURE__*/_react.default.createElement(_tile.StyledTile, _extends({
|
|
51
54
|
variant: variant,
|
|
52
55
|
width: width,
|
|
56
|
+
height: height,
|
|
53
57
|
"data-component": "tile",
|
|
54
58
|
isHorizontal: isHorizontal,
|
|
55
59
|
p: p,
|
|
@@ -3,10 +3,11 @@ import { TileProps } from "./tile.component";
|
|
|
3
3
|
interface TileContentProps {
|
|
4
4
|
isHorizontal?: boolean;
|
|
5
5
|
isVertical?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: TileProps["width"];
|
|
7
|
+
height?: TileProps["height"];
|
|
7
8
|
}
|
|
8
9
|
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
9
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
11
|
isHorizontal?: boolean | undefined;
|
|
11
12
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
12
13
|
export { StyledTile, TileContent };
|
|
@@ -7,7 +7,7 @@ exports.TileContent = exports.StyledTile = void 0;
|
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
|
-
var
|
|
10
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -31,7 +31,8 @@ const TileContent = _styledComponents.default.div`
|
|
|
31
31
|
${({
|
|
32
32
|
isHorizontal,
|
|
33
33
|
isVertical,
|
|
34
|
-
width
|
|
34
|
+
width,
|
|
35
|
+
height
|
|
35
36
|
}) => (0, _styledComponents.css)`
|
|
36
37
|
${_styledSystem.space}
|
|
37
38
|
|
|
@@ -73,10 +74,11 @@ const TileContent = _styledComponents.default.div`
|
|
|
73
74
|
}
|
|
74
75
|
`}
|
|
75
76
|
|
|
76
|
-
${width && (0, _styledComponents.css)`
|
|
77
|
+
${(width || height) && (0, _styledComponents.css)`
|
|
77
78
|
flex-grow: 0;
|
|
78
|
-
${(0,
|
|
79
|
-
width
|
|
79
|
+
${(0, _elementSizing.default)({
|
|
80
|
+
width: width || /* istanbul ignore next */undefined,
|
|
81
|
+
height: height || undefined
|
|
80
82
|
})}
|
|
81
83
|
`}
|
|
82
84
|
`}
|
|
@@ -89,7 +91,8 @@ const StyledTile = _styledComponents.default.div`
|
|
|
89
91
|
isHorizontal,
|
|
90
92
|
variant,
|
|
91
93
|
width,
|
|
92
|
-
roundness
|
|
94
|
+
roundness,
|
|
95
|
+
height
|
|
93
96
|
}) => (0, _styledComponents.css)`
|
|
94
97
|
${_styledSystem.space}
|
|
95
98
|
|
|
@@ -114,13 +117,10 @@ const StyledTile = _styledComponents.default.div`
|
|
|
114
117
|
display: flex;
|
|
115
118
|
flex-direction: ${isHorizontal ? "row" : "column"};
|
|
116
119
|
position: relative;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
${(0, _width.default)({
|
|
121
|
-
width
|
|
120
|
+
${(0, _elementSizing.default)({
|
|
121
|
+
width: width || /* istanbul ignore next */undefined,
|
|
122
|
+
height: height || undefined
|
|
122
123
|
})}
|
|
123
|
-
`}
|
|
124
124
|
`}
|
|
125
125
|
`;
|
|
126
126
|
exports.StyledTile = StyledTile;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare type ToastVariants = "error" | "info" | "success" | "warning" | "notice";
|
|
2
|
+
declare type ToastVariants = "error" | "info" | "success" | "warning" | "notice" | "neutral" | "notification";
|
|
3
|
+
declare type AlignOptions = "left" | "center" | "right";
|
|
3
4
|
export interface ToastProps {
|
|
5
|
+
/** Sets the alignment of the component. */
|
|
6
|
+
align?: AlignOptions;
|
|
4
7
|
/** The rendered children of the component. */
|
|
5
8
|
children: React.ReactNode;
|
|
6
9
|
/** Customizes the appearance in the DLS theme */
|
|
@@ -14,11 +14,14 @@ var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
|
14
14
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
15
15
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
16
16
|
var _useModalManager = _interopRequireDefault(require("../../hooks/__internal__/useModalManager"));
|
|
17
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
21
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
22
|
+
let isDeprecationWarningTriggered = false;
|
|
21
23
|
const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
24
|
+
align,
|
|
22
25
|
children,
|
|
23
26
|
className,
|
|
24
27
|
id,
|
|
@@ -33,6 +36,7 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
33
36
|
...restProps
|
|
34
37
|
}, ref) => {
|
|
35
38
|
const isNotice = variant === "notice";
|
|
39
|
+
const isNotification = variant === "notification";
|
|
36
40
|
const locale = (0, _useLocale.default)();
|
|
37
41
|
const toastRef = (0, _react.useRef)(null);
|
|
38
42
|
const timer = (0, _react.useRef)(null);
|
|
@@ -44,6 +48,10 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
44
48
|
if (ref && typeof ref === "object" && "current" in ref) {
|
|
45
49
|
refToPass = ref;
|
|
46
50
|
}
|
|
51
|
+
if (isCenter !== undefined && !isDeprecationWarningTriggered) {
|
|
52
|
+
isDeprecationWarningTriggered = true;
|
|
53
|
+
_logger.default.deprecate(`isCenter prop in ${Toast.displayName} is being deprecated in favour of the align prop.`);
|
|
54
|
+
}
|
|
47
55
|
const dismissToast = (0, _react.useCallback)(ev => {
|
|
48
56
|
if (onDismiss && _events.default.isEscKey(ev)) {
|
|
49
57
|
ev.stopImmediatePropagation();
|
|
@@ -96,10 +104,19 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
96
104
|
type: "close"
|
|
97
105
|
}));
|
|
98
106
|
}
|
|
107
|
+
const iconToRender = {
|
|
108
|
+
notification: "alert",
|
|
109
|
+
neutral: "info",
|
|
110
|
+
success: "tick_circle",
|
|
111
|
+
error: "error",
|
|
112
|
+
info: "info",
|
|
113
|
+
warning: "warning"
|
|
114
|
+
};
|
|
115
|
+
const toastIcon = iconToRender[variant] || "none";
|
|
99
116
|
function renderToastContent() {
|
|
100
117
|
if (!open) return null;
|
|
101
118
|
let toastVariant;
|
|
102
|
-
if (
|
|
119
|
+
if (!isNotice && !isNotification) {
|
|
103
120
|
toastVariant = variant;
|
|
104
121
|
}
|
|
105
122
|
return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
|
@@ -112,7 +129,9 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
112
129
|
},
|
|
113
130
|
nodeRef: toastContentNodeRef
|
|
114
131
|
}, /*#__PURE__*/_react.default.createElement(_toast.ToastStyle, _extends({
|
|
132
|
+
align: align,
|
|
115
133
|
isNotice: isNotice,
|
|
134
|
+
isNotification: isNotification,
|
|
116
135
|
className: className
|
|
117
136
|
}, (0, _tags.default)(restProps["data-component"] || "toast", restProps), {
|
|
118
137
|
isCenter: isCenter,
|
|
@@ -123,10 +142,10 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
123
142
|
}, !disableAutoFocus && {
|
|
124
143
|
tabIndex,
|
|
125
144
|
onBlur: () => setTabIndex(undefined)
|
|
126
|
-
}),
|
|
127
|
-
variant: variant
|
|
145
|
+
}), !isNotice && /*#__PURE__*/_react.default.createElement(_toast.TypeIcon, {
|
|
146
|
+
variant: isNotification ? "info" : variant
|
|
128
147
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
129
|
-
type:
|
|
148
|
+
type: toastIcon
|
|
130
149
|
})), /*#__PURE__*/_react.default.createElement(_toast.ToastContentStyle, {
|
|
131
150
|
isNotice: isNotice,
|
|
132
151
|
isDismiss: !!onDismiss
|
|
@@ -134,9 +153,11 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
134
153
|
}
|
|
135
154
|
return /*#__PURE__*/_react.default.createElement(_toast.StyledPortal, {
|
|
136
155
|
id: targetPortalId,
|
|
156
|
+
align: align,
|
|
137
157
|
isCenter: isCenter,
|
|
138
158
|
isNotice: isNotice
|
|
139
159
|
}, /*#__PURE__*/_react.default.createElement(_toast.ToastWrapper, {
|
|
160
|
+
align: align,
|
|
140
161
|
isCenter: isCenter,
|
|
141
162
|
ref: refToPass,
|
|
142
163
|
isNotice: isNotice
|
|
@@ -144,6 +165,7 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
144
165
|
});
|
|
145
166
|
exports.Toast = Toast;
|
|
146
167
|
Toast.propTypes = {
|
|
168
|
+
"align": _propTypes.default.oneOf(["center", "left", "right"]),
|
|
147
169
|
"children": _propTypes.default.node,
|
|
148
170
|
"className": _propTypes.default.string,
|
|
149
171
|
"data-component": _propTypes.default.string,
|
|
@@ -155,7 +177,7 @@ Toast.propTypes = {
|
|
|
155
177
|
"open": _propTypes.default.bool,
|
|
156
178
|
"targetPortalId": _propTypes.default.string,
|
|
157
179
|
"timeout": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
158
|
-
"variant": _propTypes.default.oneOf(["error", "info", "notice", "success", "warning"])
|
|
180
|
+
"variant": _propTypes.default.oneOf(["error", "info", "neutral", "notice", "notification", "success", "warning"])
|
|
159
181
|
};
|
|
160
182
|
Toast.displayName = "Toast";
|
|
161
183
|
var _default = Toast;
|
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TOAST_COLORS = void 0;
|
|
7
7
|
// eslint-disable-next-line import/prefer-default-export
|
|
8
|
-
const TOAST_COLORS = ["error", "info", "success", "warning"];
|
|
8
|
+
const TOAST_COLORS = ["error", "info", "success", "warning", "neutral", "notification"];
|
|
9
9
|
exports.TOAST_COLORS = TOAST_COLORS;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import TypeIcon from "../message/type-icon/type-icon.style";
|
|
3
3
|
declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
|
|
4
|
+
align?: "left" | "right" | "center" | undefined;
|
|
4
5
|
isCenter?: boolean | undefined;
|
|
5
6
|
isNotice?: boolean | undefined;
|
|
6
7
|
}, never>;
|
|
@@ -8,15 +9,18 @@ declare const ToastStyle: import("styled-components").StyledComponent<"div", any
|
|
|
8
9
|
variant?: import("../message/message.component").MessageVariant | undefined;
|
|
9
10
|
transparent?: boolean | undefined;
|
|
10
11
|
} & import("styled-system").MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
12
|
+
align?: "left" | "right" | "center" | undefined;
|
|
11
13
|
maxWidth?: string | undefined;
|
|
12
14
|
isCenter?: boolean | undefined;
|
|
13
15
|
isNotice?: boolean | undefined;
|
|
16
|
+
isNotification?: boolean | undefined;
|
|
14
17
|
}, never>;
|
|
15
18
|
declare const ToastContentStyle: import("styled-components").StyledComponent<"div", any, Pick<import("../message/message-content/message-content.component").MessageContentProps, "showCloseIcon"> & {
|
|
16
19
|
isNotice?: boolean | undefined;
|
|
17
20
|
isDismiss?: boolean | undefined;
|
|
18
21
|
}, never>;
|
|
19
22
|
declare const ToastWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
23
|
+
align?: "left" | "right" | "center" | undefined;
|
|
20
24
|
isCenter?: boolean | undefined;
|
|
21
25
|
isNotice?: boolean | undefined;
|
|
22
26
|
}, never>;
|
|
@@ -25,7 +25,8 @@ const StyledPortal = (0, _styledComponents.default)(_portal.default)`
|
|
|
25
25
|
${({
|
|
26
26
|
theme,
|
|
27
27
|
isCenter,
|
|
28
|
-
isNotice
|
|
28
|
+
isNotice,
|
|
29
|
+
align
|
|
29
30
|
}) => (0, _styledComponents.css)`
|
|
30
31
|
position: fixed;
|
|
31
32
|
top: 0;
|
|
@@ -37,6 +38,22 @@ const StyledPortal = (0, _styledComponents.default)(_portal.default)`
|
|
|
37
38
|
transform: translateX(-50%);
|
|
38
39
|
`}
|
|
39
40
|
|
|
41
|
+
${align === "left" && (0, _styledComponents.css)`
|
|
42
|
+
left: 12%;
|
|
43
|
+
transform: translateX(-50%);
|
|
44
|
+
`}
|
|
45
|
+
|
|
46
|
+
${align === "center" && (0, _styledComponents.css)`
|
|
47
|
+
margin-left: 50%;
|
|
48
|
+
transform: translateX(-50%);
|
|
49
|
+
`}
|
|
50
|
+
|
|
51
|
+
${align === "right" && (0, _styledComponents.css)`
|
|
52
|
+
display: flex;
|
|
53
|
+
right: 0;
|
|
54
|
+
transform: translateX(-50%);
|
|
55
|
+
`}
|
|
56
|
+
|
|
40
57
|
${isNotice && (0, _styledComponents.css)`
|
|
41
58
|
bottom: 0;
|
|
42
59
|
top: auto;
|
|
@@ -53,7 +70,9 @@ const alternativeAnimationName = ".toast-alternative";
|
|
|
53
70
|
const ToastStyle = (0, _styledComponents.default)(_message.default)`
|
|
54
71
|
${({
|
|
55
72
|
maxWidth,
|
|
56
|
-
isCenter
|
|
73
|
+
isCenter,
|
|
74
|
+
align,
|
|
75
|
+
isNotification
|
|
57
76
|
}) => (0, _styledComponents.css)`
|
|
58
77
|
box-shadow: 0 10px 30px 0 rgba(0, 20, 29, 0.1),
|
|
59
78
|
0 30px 60px 0 rgba(0, 20, 29, 0.1);
|
|
@@ -61,7 +80,11 @@ const ToastStyle = (0, _styledComponents.default)(_message.default)`
|
|
|
61
80
|
margin-top: 30px;
|
|
62
81
|
max-width: ${!maxWidth ? "300px" : maxWidth};
|
|
63
82
|
position: relative;
|
|
64
|
-
margin-right: ${isCenter ? "auto" : "30px"};
|
|
83
|
+
margin-right: ${isCenter || align === "right" ? "auto" : "30px"};
|
|
84
|
+
|
|
85
|
+
${isNotification && (0, _styledComponents.css)`
|
|
86
|
+
border: 1px solid var(--colorsSemanticInfo500);
|
|
87
|
+
`}
|
|
65
88
|
`}
|
|
66
89
|
|
|
67
90
|
:focus {
|
|
@@ -157,6 +180,16 @@ const ToastContentStyle = (0, _styledComponents.default)(_messageContent.default
|
|
|
157
180
|
`;
|
|
158
181
|
exports.ToastContentStyle = ToastContentStyle;
|
|
159
182
|
const ToastWrapper = _styledComponents.default.div`
|
|
183
|
+
${({
|
|
184
|
+
align
|
|
185
|
+
}) => align && (0, _styledComponents.css)`
|
|
186
|
+
position: relative;
|
|
187
|
+
width: auto;
|
|
188
|
+
height: auto;
|
|
189
|
+
justify-content: ${align};
|
|
190
|
+
display: flex;
|
|
191
|
+
`}
|
|
192
|
+
|
|
160
193
|
${({
|
|
161
194
|
isCenter
|
|
162
195
|
}) => isCenter && (0, _styledComponents.css)`
|
|
@@ -5,15 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledSystem = require("styled-system");
|
|
8
|
-
// eslint-disable-next-line no-restricted-imports
|
|
9
8
|
/*
|
|
10
9
|
* styled-system/layout allows users to use a width, height, minWidth, maxWidth, minHeight, maxHeight,
|
|
11
10
|
* size, display, verticalAlign, overflow, overflowX and overflowY props most of which are usually not needed.
|
|
12
|
-
* That's why the purpose of this function is to pass only the`width`
|
|
11
|
+
* That's why the purpose of this function is to pass only the `width` and `height` props to the `layout` function.
|
|
13
12
|
*/
|
|
14
13
|
var _default = ({
|
|
15
|
-
width
|
|
14
|
+
width,
|
|
15
|
+
height
|
|
16
16
|
}) => (0, _styledSystem.layout)({
|
|
17
|
-
width
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
18
19
|
});
|
|
19
20
|
exports.default = _default;
|
package/package.json
CHANGED