@ultraviolet/ui 1.33.0 → 1.35.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 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
  /**
@@ -3099,6 +3103,11 @@ type ToastContainerProps = {
3099
3103
  */
3100
3104
  position?: ToastOptions['position'];
3101
3105
  'data-testid'?: string;
3106
+ className?: string;
3107
+ /**
3108
+ * Delay before the toast is automatically closed, if not set the default value is 6000ms
3109
+ */
3110
+ autoClose?: number;
3102
3111
  };
3103
3112
  /**
3104
3113
  * Display short information about an event that happen in the interface in a floating alert.
@@ -3108,7 +3117,7 @@ type ToastContainerProps = {
3108
3117
  * Toaster is separated in two parts, first the `ToastContainer` which is where the div of the toast will be rendered,
3109
3118
  * and second the `toast()` function which is used to display the toast.
3110
3119
  */
3111
- declare const ToastContainer: ({ newestOnTop, limit, position, "data-testid": dataTestId, }: ToastContainerProps) => _emotion_react_jsx_runtime.JSX.Element;
3120
+ declare const ToastContainer: ({ newestOnTop, limit, position, "data-testid": dataTestId, className, autoClose, }: ToastContainerProps) => _emotion_react_jsx_runtime.JSX.Element;
3112
3121
 
3113
3122
  /**
3114
3123
  * Toggle component is used to toggle between two states (on/off, true/false, etc.).
@@ -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, ";box-shadow:", theme.shadows.dropdown, ";min-height:44px;margin-bottom:", theme.space['2'], ";", PREFIX, "__toast-body{margin:0;padding:0;}&", PREFIX, "__toast--success{background-color:", theme.colors.success.background, ";color:", theme.colors.success.text, ";", PREFIX, "__progress-bar--success{background-color:", theme.colors.success.backgroundStrong, ";height:4px;}}&", PREFIX, "__toast--info{background-color:", theme.colors.info.background, ";color:", theme.colors.info.text, ";", PREFIX, "__progress-bar--info{background-color:", theme.colors.info.backgroundStrong, ";height:4px;}}&", PREFIX, "__toast--error{background-color:", theme.colors.danger.background, ";color:", theme.colors.danger.text, ";", PREFIX, "__progress-bar--danger{background-color:", theme.colors.danger.backgroundStrong, ";height:4px;}}")
15
+ toast: theme => /*#__PURE__*/css("border-radius:", theme.radii.default, ";min-height:52px;padding:", theme.space['2'], ";text-size:", theme.typography.bodySmallStrong.fontSize, ";", PREFIX, "__toast-container{width:344px;}", 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 CloseButtonWrapper = /*#__PURE__*/_styled("button", {
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
- })("margin-left:", ({
30
- theme
31
- }) => theme.space['1'], ";");
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
- }) => jsx(CloseButtonWrapper, {
35
- type: "button",
28
+ closeToast,
29
+ sentiment = 'success'
30
+ }) => jsx(StyledButton, {
31
+ "aria-label": "close",
32
+ icon: "close",
36
33
  onClick: closeToast,
37
- children: jsx(IconWithLeftMargin, {
38
- name: "close",
39
- size: 18
40
- })
34
+ sentiment: sentiment,
35
+ size: "xsmall"
41
36
  });
42
37
  const Content = ({
43
- sentiment,
44
38
  children
45
- }) => jsxs(Stack, {
39
+ }) => jsx(Stack, {
46
40
  gap: 2,
47
41
  direction: "row",
48
- children: [jsx(Icon, {
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
- }), options),
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
- }), options),
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
- }), options)
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.
@@ -81,7 +95,9 @@ const ToastContainer = ({
81
95
  newestOnTop,
82
96
  limit,
83
97
  position = 'top-right',
84
- 'data-testid': dataTestId
98
+ 'data-testid': dataTestId,
99
+ className,
100
+ autoClose
85
101
  }) => {
86
102
  const theme = useTheme();
87
103
  return jsxs(Fragment, {
@@ -92,14 +108,15 @@ const ToastContainer = ({
92
108
  css: localCss
93
109
  }) => jsx(ToastContainer$1, {
94
110
  "data-testid": dataTestId,
95
- closeButton: jsx(CloseButton, {}),
96
111
  toastClassName: localCss(styles.toast(theme)),
97
- autoClose: AUTOCLOSE_DELAY,
112
+ autoClose: autoClose ?? AUTOCLOSE_DELAY,
98
113
  icon: false,
99
114
  newestOnTop: newestOnTop,
100
115
  limit: limit,
101
116
  position: position,
102
- css: /*#__PURE__*/css("top:100px;right:calc(0% + ", theme.space['2'], ");")
117
+ stacked: true,
118
+ hideProgressBar: true,
119
+ className: className
103
120
  })
104
121
  })]
105
122
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.33.0",
3
+ "version": "1.35.0",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {