@ultraviolet/ui 1.33.0 → 1.34.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/dist/index.d.ts +4 -0
- package/dist/src/components/Toaster/index.js +55 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3081,8 +3081,12 @@ declare const TimeInput: TimeInputType;
|
|
|
3081
3081
|
|
|
3082
3082
|
declare const toast: {
|
|
3083
3083
|
error: (children: ReactNode, options?: ToastOptions) => number | string;
|
|
3084
|
+
/**
|
|
3085
|
+
* @deprecated "Deprecated, please use another variant instead"
|
|
3086
|
+
*/
|
|
3084
3087
|
info: (children: ReactNode, options?: ToastOptions) => number | string;
|
|
3085
3088
|
success: (children: ReactNode, options?: ToastOptions) => number | string;
|
|
3089
|
+
warning: (children: ReactNode, options?: ToastOptions) => number | string;
|
|
3086
3090
|
};
|
|
3087
3091
|
type ToastContainerProps = {
|
|
3088
3092
|
/**
|
|
@@ -1,73 +1,87 @@
|
|
|
1
1
|
import _styled from '@emotion/styled/base';
|
|
2
2
|
import { useTheme, Global, ClassNames, css } from '@emotion/react';
|
|
3
|
-
import { Icon } from '@ultraviolet/icons';
|
|
4
3
|
import { toast as toast$1, ToastContainer as ToastContainer$1 } from 'react-toastify';
|
|
5
4
|
import css_248z from '../../../react-toastify/dist/ReactToastify.min.css.js';
|
|
5
|
+
import { Button } from '../Button/index.js';
|
|
6
6
|
import { Stack } from '../Stack/index.js';
|
|
7
7
|
import { Text } from '../Text/index.js';
|
|
8
8
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
9
9
|
|
|
10
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
10
11
|
const PREFIX = '.Toastify';
|
|
11
12
|
const AUTOCLOSE_DELAY = 6000; // Delay to close the toast in ms
|
|
12
13
|
|
|
13
|
-
const TOAST_ICONS = {
|
|
14
|
-
warning: 'alert',
|
|
15
|
-
info: 'information-outline',
|
|
16
|
-
success: 'checkbox-circle-outline',
|
|
17
|
-
danger: 'alert'
|
|
18
|
-
};
|
|
19
14
|
const styles = {
|
|
20
|
-
toast: theme => /*#__PURE__*/css("border-radius:", theme.radii.default, ";
|
|
15
|
+
toast: theme => /*#__PURE__*/css("border-radius:", theme.radii.default, ";min-height:52px;width:344px;padding:", theme.space['2'], ";text-size:", theme.typography.bodySmallStrong.fontSize, ";", PREFIX, "__toast-body{margin:0;}&", PREFIX, "__toast--success{background-color:", theme.colors.neutral.backgroundStronger, ";color:", theme.colors.neutral.textStronger, ";}&", PREFIX, "__toast--info{background-color:", theme.colors.info.backgroundStrong, ";color:", theme.colors.neutral.textStronger, ";}&", PREFIX, "__toast--error{background-color:", theme.colors.danger.backgroundStrong, ";color:", theme.colors.neutral.textStronger, ";}&", PREFIX, "__toast--warning{background-color:", theme.colors.warning.backgroundStrong, ";color:", theme.colors.warning.textStrong, ";}")
|
|
21
16
|
};
|
|
22
|
-
const
|
|
23
|
-
target: "e1eb63991"
|
|
24
|
-
})("background:none;border:none;cursor:pointer;color:inherit;padding:0;margin:0;margin-bottom:", ({
|
|
25
|
-
theme
|
|
26
|
-
}) => theme.space['2'], ";");
|
|
27
|
-
const IconWithLeftMargin = /*#__PURE__*/_styled(Icon, {
|
|
17
|
+
const StyledButton = /*#__PURE__*/_styled(Button, {
|
|
28
18
|
target: "e1eb63990"
|
|
29
|
-
})("
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
20
|
+
name: "1nobnvq",
|
|
21
|
+
styles: "background:none;margin:auto;&:hover,&:active{background:none;}"
|
|
22
|
+
} : {
|
|
23
|
+
name: "1nobnvq",
|
|
24
|
+
styles: "background:none;margin:auto;&:hover,&:active{background:none;}",
|
|
25
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
26
|
+
});
|
|
32
27
|
const CloseButton = ({
|
|
33
|
-
closeToast
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
closeToast,
|
|
29
|
+
sentiment = 'success'
|
|
30
|
+
}) => jsx(StyledButton, {
|
|
31
|
+
"aria-label": "close",
|
|
32
|
+
icon: "close",
|
|
36
33
|
onClick: closeToast,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
size: 18
|
|
40
|
-
})
|
|
34
|
+
sentiment: sentiment,
|
|
35
|
+
size: "xsmall"
|
|
41
36
|
});
|
|
42
37
|
const Content = ({
|
|
43
|
-
sentiment,
|
|
44
38
|
children
|
|
45
|
-
}) =>
|
|
39
|
+
}) => jsx(Stack, {
|
|
46
40
|
gap: 2,
|
|
47
41
|
direction: "row",
|
|
48
|
-
children:
|
|
49
|
-
name: TOAST_ICONS[sentiment],
|
|
50
|
-
size: 24
|
|
51
|
-
}), jsx(Text, {
|
|
42
|
+
children: jsx(Text, {
|
|
52
43
|
variant: "body",
|
|
53
44
|
as: "span",
|
|
54
|
-
sentiment: sentiment,
|
|
55
45
|
children: children
|
|
56
|
-
})
|
|
46
|
+
})
|
|
57
47
|
});
|
|
58
48
|
const toast = {
|
|
59
49
|
error: (children, options) => toast$1.error(jsx(Content, {
|
|
60
|
-
sentiment: "danger",
|
|
61
50
|
children: children
|
|
62
|
-
}),
|
|
51
|
+
}), {
|
|
52
|
+
...options,
|
|
53
|
+
closeButton: jsx(CloseButton, {
|
|
54
|
+
sentiment: "danger"
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated "Deprecated, please use another variant instead"
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
63
61
|
info: (children, options) => toast$1.info(jsx(Content, {
|
|
64
|
-
sentiment: "info",
|
|
65
62
|
children: children
|
|
66
|
-
}),
|
|
63
|
+
}), {
|
|
64
|
+
...options,
|
|
65
|
+
closeButton: jsx(CloseButton, {
|
|
66
|
+
sentiment: "info"
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
67
69
|
success: (children, options) => toast$1.success(jsx(Content, {
|
|
68
|
-
sentiment: "success",
|
|
69
70
|
children: children
|
|
70
|
-
}),
|
|
71
|
+
}), {
|
|
72
|
+
...options,
|
|
73
|
+
closeButton: jsx(CloseButton, {
|
|
74
|
+
sentiment: "success"
|
|
75
|
+
})
|
|
76
|
+
}),
|
|
77
|
+
warning: (children, options) => toast$1.warn(jsx(Content, {
|
|
78
|
+
children: children
|
|
79
|
+
}), {
|
|
80
|
+
...options,
|
|
81
|
+
closeButton: jsx(CloseButton, {
|
|
82
|
+
sentiment: "warning"
|
|
83
|
+
})
|
|
84
|
+
})
|
|
71
85
|
};
|
|
72
86
|
/**
|
|
73
87
|
* Display short information about an event that happen in the interface in a floating alert.
|
|
@@ -92,14 +106,15 @@ const ToastContainer = ({
|
|
|
92
106
|
css: localCss
|
|
93
107
|
}) => jsx(ToastContainer$1, {
|
|
94
108
|
"data-testid": dataTestId,
|
|
95
|
-
closeButton: jsx(CloseButton, {}),
|
|
96
109
|
toastClassName: localCss(styles.toast(theme)),
|
|
97
110
|
autoClose: AUTOCLOSE_DELAY,
|
|
98
111
|
icon: false,
|
|
99
112
|
newestOnTop: newestOnTop,
|
|
100
113
|
limit: limit,
|
|
101
114
|
position: position,
|
|
102
|
-
css: /*#__PURE__*/css("top:100px;right:calc(0% + ", theme.space['2'], ");")
|
|
115
|
+
css: /*#__PURE__*/css("top:100px;right:calc(0% + ", theme.space['2'], ");"),
|
|
116
|
+
stacked: true,
|
|
117
|
+
hideProgressBar: true
|
|
103
118
|
})
|
|
104
119
|
})]
|
|
105
120
|
});
|