@sproutsocial/seeds-react-toast 1.0.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/.eslintignore +6 -0
- package/.eslintrc.js +4 -0
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +12 -0
- package/dist/esm/index.js +247 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +288 -0
- package/dist/index.js.map +1 -0
- package/jest.config.js +9 -0
- package/package.json +45 -0
- package/src/Toast.stories.tsx +300 -0
- package/src/Toast.tsx +173 -0
- package/src/ToastTypes.ts +38 -0
- package/src/index.ts +3 -0
- package/src/styled.d.ts +7 -0
- package/src/styles.ts +115 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +12 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
yarn run v1.22.22
|
|
2
|
+
$ tsup --dts
|
|
3
|
+
CLI Building entry: src/index.ts
|
|
4
|
+
CLI Using tsconfig: tsconfig.json
|
|
5
|
+
CLI tsup v8.0.2
|
|
6
|
+
CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-toast/tsup.config.ts
|
|
7
|
+
CLI Target: es2022
|
|
8
|
+
CLI Cleaning output folder
|
|
9
|
+
CJS Build start
|
|
10
|
+
ESM Build start
|
|
11
|
+
CJS dist/index.js 9.51 KB
|
|
12
|
+
CJS dist/index.js.map 13.09 KB
|
|
13
|
+
CJS ⚡️ Build success in 276ms
|
|
14
|
+
ESM dist/esm/index.js 6.76 KB
|
|
15
|
+
ESM dist/esm/index.js.map 12.64 KB
|
|
16
|
+
ESM ⚡️ Build success in 277ms
|
|
17
|
+
DTS Build start
|
|
18
|
+
DTS ⚡️ Build success in 49568ms
|
|
19
|
+
DTS dist/index.d.ts 3.18 KB
|
|
20
|
+
DTS dist/index.d.mts 3.18 KB
|
|
21
|
+
Done in 60.27s.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// src/Toast.tsx
|
|
2
|
+
import {
|
|
3
|
+
toast as toastifyToast,
|
|
4
|
+
cssTransition
|
|
5
|
+
} from "react-toastify";
|
|
6
|
+
import Box2 from "@sproutsocial/seeds-react-box";
|
|
7
|
+
import Icon from "@sproutsocial/seeds-react-icon";
|
|
8
|
+
import Text from "@sproutsocial/seeds-react-text";
|
|
9
|
+
|
|
10
|
+
// src/styles.ts
|
|
11
|
+
import styled from "styled-components";
|
|
12
|
+
import "react-toastify/dist/ReactToastify.css";
|
|
13
|
+
import Box from "@sproutsocial/seeds-react-box";
|
|
14
|
+
import { ToastContainer } from "react-toastify";
|
|
15
|
+
var TOAST_Z_INDEX = 9999;
|
|
16
|
+
var Container = styled(Box)`
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: ${({ theme }) => theme.space[350]};
|
|
20
|
+
font-family: ${({ theme }) => theme.fontFamily};
|
|
21
|
+
${({ theme }) => theme.typography[200]}
|
|
22
|
+
position: relative;
|
|
23
|
+
padding: ${({ theme }) => theme.space[350]};
|
|
24
|
+
`;
|
|
25
|
+
var ToastRoot = styled(ToastContainer).attrs({
|
|
26
|
+
toastClassName: "Toastify-toast-overrides",
|
|
27
|
+
hideProgressBar: true,
|
|
28
|
+
closeButton: false,
|
|
29
|
+
icon: false,
|
|
30
|
+
position: "bottom-right"
|
|
31
|
+
})`
|
|
32
|
+
--toastify-z-index: ${TOAST_Z_INDEX};
|
|
33
|
+
--toastify-toast-offset: ${({ theme }) => theme.space[400]};
|
|
34
|
+
--toastify-toast-width: 360px;
|
|
35
|
+
--toastify-toast-min-height: 48px;
|
|
36
|
+
--toastify-toast-max-height: 70vh;
|
|
37
|
+
--toastify-toast-bd-radius: ${({ theme }) => theme.radii[400]};
|
|
38
|
+
--toastify-toast-background: ${({ theme }) => theme.colors.container.background.base};
|
|
39
|
+
/* there's margin-bottom on the last toast so we can remove this */
|
|
40
|
+
--toastify-toast-bottom: 0;
|
|
41
|
+
|
|
42
|
+
padding: 0;
|
|
43
|
+
|
|
44
|
+
.Toastify-toast-overrides {
|
|
45
|
+
background: ${({ theme }) => theme.colors.container.background.base};
|
|
46
|
+
color: ${({ theme }) => theme.colors.text.body};
|
|
47
|
+
box-shadow: ${({ theme }) => theme.shadows.low};
|
|
48
|
+
padding: 0;
|
|
49
|
+
margin-bottom: var(--toastify-toast-offset);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.Toastify__toast-body {
|
|
53
|
+
padding: 0;
|
|
54
|
+
margin: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Override React Toastify's mobile width styles */
|
|
58
|
+
@media only screen and (max-width: 480px) {
|
|
59
|
+
.Toastify-container-overrides {
|
|
60
|
+
min-width: initial !important;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Zoom animation */
|
|
65
|
+
@keyframes SproutToast__zoom-in {
|
|
66
|
+
from {
|
|
67
|
+
opacity: 0;
|
|
68
|
+
transform: scale3d(0.3, 0.3, 0.3);
|
|
69
|
+
}
|
|
70
|
+
50% {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
@keyframes SproutToast__zoom-out {
|
|
75
|
+
from {
|
|
76
|
+
opacity: 1;
|
|
77
|
+
}
|
|
78
|
+
50% {
|
|
79
|
+
opacity: 0;
|
|
80
|
+
transform: scale3d(0.3, 0.3, 0.3) translate3d(0, var(--y), 0);
|
|
81
|
+
}
|
|
82
|
+
to {
|
|
83
|
+
opacity: 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
.SproutToast__zoom-in {
|
|
87
|
+
animation: SproutToast__zoom-in ${({ theme }) => theme.duration.medium}
|
|
88
|
+
${({ theme }) => theme.easing.ease_out} both;
|
|
89
|
+
}
|
|
90
|
+
.SproutToast__zoom-out {
|
|
91
|
+
animation: SproutToast__zoom-out ${({ theme }) => theme.duration.slow}
|
|
92
|
+
${({ theme }) => theme.easing.ease_in} both;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* No animation (it's still necessary to define classes for no animation to work properly) */
|
|
96
|
+
@keyframes SproutToast__none-in {
|
|
97
|
+
from {
|
|
98
|
+
opacity: 0;
|
|
99
|
+
}
|
|
100
|
+
to {
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
@keyframes SproutToast__none-out {
|
|
105
|
+
from {
|
|
106
|
+
opacity: 1;
|
|
107
|
+
}
|
|
108
|
+
to {
|
|
109
|
+
opacity: 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
.SproutToast__none-in {
|
|
113
|
+
animation: SproutToast__none-in 0s both;
|
|
114
|
+
}
|
|
115
|
+
.SproutToast__none-out {
|
|
116
|
+
animation: SproutToast__none-out 0s both;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
// src/Toast.tsx
|
|
121
|
+
import styled2 from "styled-components";
|
|
122
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
123
|
+
var toastDismiss = (...input) => (
|
|
124
|
+
// @ts-ignore Not sure what this type is supposed to be
|
|
125
|
+
toastifyToast.dismiss(...input)
|
|
126
|
+
);
|
|
127
|
+
var toastIsActive = (...input) => toastifyToast.isActive(...input);
|
|
128
|
+
var toastUpdate = (...input) => toastifyToast.update(...input);
|
|
129
|
+
var NoTransition = cssTransition({
|
|
130
|
+
enter: "SproutToast__none-in",
|
|
131
|
+
exit: "SproutToast__none-out"
|
|
132
|
+
});
|
|
133
|
+
var SproutZoomTransition = cssTransition({
|
|
134
|
+
enter: "SproutToast__zoom-in",
|
|
135
|
+
exit: "SproutToast__zoom-out"
|
|
136
|
+
});
|
|
137
|
+
var ToastContainer2 = (props) => /* @__PURE__ */ jsx(ToastRoot, { ...props });
|
|
138
|
+
var themeIcon = {
|
|
139
|
+
success: "circle-check-outline",
|
|
140
|
+
info: "circle-i-outline",
|
|
141
|
+
warning: "triangle-exclamation-outline",
|
|
142
|
+
error: "triangle-exclamation-outline"
|
|
143
|
+
};
|
|
144
|
+
function toast(options) {
|
|
145
|
+
const {
|
|
146
|
+
closeOnClick = true,
|
|
147
|
+
content,
|
|
148
|
+
onClose,
|
|
149
|
+
persist,
|
|
150
|
+
toastId: inputToastId,
|
|
151
|
+
useTransition = true,
|
|
152
|
+
position = "bottom-right",
|
|
153
|
+
autoClose = persist ? false : 6e3,
|
|
154
|
+
transition = useTransition ? SproutZoomTransition : NoTransition,
|
|
155
|
+
...rest
|
|
156
|
+
} = options;
|
|
157
|
+
let toastId = inputToastId;
|
|
158
|
+
if (!toastId && typeof content === "string") {
|
|
159
|
+
toastId = content;
|
|
160
|
+
}
|
|
161
|
+
const renderToast = (toastInput) => {
|
|
162
|
+
const renderedContent = typeof content === "function" ? content(toastInput) : content;
|
|
163
|
+
if (options.theme === "custom") {
|
|
164
|
+
return renderedContent;
|
|
165
|
+
}
|
|
166
|
+
const theme = options.theme || "info";
|
|
167
|
+
const iconName = options.icon || themeIcon[theme];
|
|
168
|
+
const containerColor = options.color || {
|
|
169
|
+
success: "container.border.success",
|
|
170
|
+
error: "container.border.error",
|
|
171
|
+
info: "container.border.info",
|
|
172
|
+
warning: "container.border.warning"
|
|
173
|
+
}[theme];
|
|
174
|
+
const iconColor = options.color || {
|
|
175
|
+
success: "icon.success",
|
|
176
|
+
error: "icon.error",
|
|
177
|
+
info: "icon.info",
|
|
178
|
+
warning: "icon.warning"
|
|
179
|
+
}[theme];
|
|
180
|
+
return (
|
|
181
|
+
// TODO: if this closes when clicked, there should be a label saying "Click to close" that can be overridden
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
ToastContentContainer,
|
|
184
|
+
{
|
|
185
|
+
icon: /* @__PURE__ */ jsx(Icon, { name: iconName, color: iconColor }),
|
|
186
|
+
close: /* @__PURE__ */ jsx(Icon, { name: "x-outline", color: "icon.base", "aria-hidden": true }),
|
|
187
|
+
highlightColor: containerColor,
|
|
188
|
+
children: renderedContent
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
const toastOptions = {
|
|
194
|
+
autoClose,
|
|
195
|
+
closeOnClick,
|
|
196
|
+
onClose,
|
|
197
|
+
toastId: toastId || void 0,
|
|
198
|
+
transition,
|
|
199
|
+
position,
|
|
200
|
+
...rest,
|
|
201
|
+
icon: void 0,
|
|
202
|
+
color: void 0
|
|
203
|
+
};
|
|
204
|
+
if (toastId && toastIsActive(toastId)) {
|
|
205
|
+
toastifyToast.update(toastId, {
|
|
206
|
+
...toastOptions,
|
|
207
|
+
render: renderToast
|
|
208
|
+
});
|
|
209
|
+
} else {
|
|
210
|
+
toastId = toastifyToast(renderToast, toastOptions);
|
|
211
|
+
}
|
|
212
|
+
return toastId;
|
|
213
|
+
}
|
|
214
|
+
var ToastContentContainer = ({
|
|
215
|
+
children,
|
|
216
|
+
icon,
|
|
217
|
+
close,
|
|
218
|
+
highlightColor
|
|
219
|
+
}) => {
|
|
220
|
+
return /* @__PURE__ */ jsxs(Container, { "data-qa-toast": "", children: [
|
|
221
|
+
highlightColor ? /* @__PURE__ */ jsx(ToastHighlight, { bg: highlightColor, "aria-hidden": true }) : null,
|
|
222
|
+
/* @__PURE__ */ jsx(Box2, { css: "line-height: 1;", children: icon }),
|
|
223
|
+
/* @__PURE__ */ jsx(Box2, { flex: 1, children: /* @__PURE__ */ jsx(Text, { as: "div", color: "text.body", "data-qa-toast-content": "", children }) }),
|
|
224
|
+
/* @__PURE__ */ jsx(Box2, { css: "line-height: 1;", children: close })
|
|
225
|
+
] });
|
|
226
|
+
};
|
|
227
|
+
var ToastHighlight = styled2(Box2)`
|
|
228
|
+
position: absolute;
|
|
229
|
+
top: 0;
|
|
230
|
+
bottom: 0;
|
|
231
|
+
left: 0;
|
|
232
|
+
width: 2px;
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
// src/ToastTypes.ts
|
|
236
|
+
import "@sproutsocial/seeds-react-icon";
|
|
237
|
+
export {
|
|
238
|
+
TOAST_Z_INDEX,
|
|
239
|
+
ToastContainer2 as ToastContainer,
|
|
240
|
+
ToastContentContainer,
|
|
241
|
+
ToastHighlight,
|
|
242
|
+
toast,
|
|
243
|
+
toastDismiss,
|
|
244
|
+
toastIsActive,
|
|
245
|
+
toastUpdate
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Toast.tsx","../../src/styles.ts","../../src/ToastTypes.ts"],"sourcesContent":["import type { PropsWithChildren, ReactNode, ComponentProps } from \"react\";\nimport {\n toast as toastifyToast,\n cssTransition,\n type ToastContent,\n} from \"react-toastify\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon, { type TypeIconName } from \"@sproutsocial/seeds-react-icon\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { Container, ToastRoot } from \"./styles\";\nimport type { TypeToastOptions, TypeToastTheme } from \"./ToastTypes\";\nimport styled from \"styled-components\";\n\nexport const toastDismiss: typeof toastifyToast.dismiss = (...input) =>\n // @ts-ignore Not sure what this type is supposed to be\n toastifyToast.dismiss(...input);\nexport const toastIsActive: typeof toastifyToast.isActive = (...input) =>\n toastifyToast.isActive(...input);\nexport const toastUpdate: typeof toastifyToast.update = (...input) =>\n toastifyToast.update(...input);\n\nconst NoTransition = cssTransition({\n enter: \"SproutToast__none-in\",\n exit: \"SproutToast__none-out\",\n});\nconst SproutZoomTransition = cssTransition({\n enter: \"SproutToast__zoom-in\",\n exit: \"SproutToast__zoom-out\",\n});\n\nexport const ToastContainer = (\n props: Partial<ComponentProps<typeof ToastRoot>>\n) => <ToastRoot {...props} />;\n\nconst themeIcon: Record<TypeToastTheme, TypeIconName> = {\n success: \"circle-check-outline\",\n info: \"circle-i-outline\",\n warning: \"triangle-exclamation-outline\",\n error: \"triangle-exclamation-outline\",\n} as const;\n\nexport function toast<TData = unknown>(\n options: TypeToastOptions<TData>\n): ReturnType<typeof toastifyToast> {\n const {\n closeOnClick = true,\n content,\n onClose,\n persist,\n toastId: inputToastId,\n useTransition = true,\n position = \"bottom-right\",\n autoClose = persist ? false : 6000,\n transition = useTransition ? SproutZoomTransition : NoTransition,\n ...rest\n } = options;\n\n let toastId = inputToastId;\n if (!toastId && typeof content === \"string\") {\n toastId = content;\n }\n\n const renderToast: ToastContent<TData> = (toastInput) => {\n const renderedContent =\n typeof content === \"function\" ? content(toastInput) : content;\n\n if (options.theme === \"custom\") {\n return renderedContent;\n }\n\n const theme = options.theme || \"info\";\n const iconName = options.icon || themeIcon[theme];\n const containerColor =\n options.color ||\n (\n {\n success: \"container.border.success\",\n error: \"container.border.error\",\n info: \"container.border.info\",\n warning: \"container.border.warning\",\n } as const\n )[theme];\n const iconColor =\n options.color ||\n (\n {\n success: \"icon.success\",\n error: \"icon.error\",\n info: \"icon.info\",\n warning: \"icon.warning\",\n } as const\n )[theme];\n\n return (\n // TODO: if this closes when clicked, there should be a label saying \"Click to close\" that can be overridden\n <ToastContentContainer\n icon={<Icon name={iconName} color={iconColor} />}\n close={<Icon name=\"x-outline\" color=\"icon.base\" aria-hidden />}\n highlightColor={containerColor}\n >\n {renderedContent}\n </ToastContentContainer>\n );\n };\n\n const toastOptions = {\n autoClose,\n closeOnClick,\n onClose,\n toastId: toastId || undefined,\n transition,\n position,\n ...rest,\n icon: undefined,\n color: undefined,\n } as const;\n\n if (toastId && toastIsActive(toastId)) {\n toastifyToast.update<TData>(toastId, {\n ...toastOptions,\n render: renderToast,\n });\n } else {\n toastId = toastifyToast<TData>(renderToast, toastOptions);\n }\n\n return toastId;\n}\n\nexport default ToastContainer;\n\nexport const ToastContentContainer = ({\n children,\n icon,\n close,\n highlightColor,\n}: PropsWithChildren<{\n /**\n * A ReactNode in the icon slot\n */\n icon: ReactNode;\n /**\n * A ReactNode in the close button slot\n */\n close: ReactNode;\n highlightColor?: ComponentProps<typeof Box>[\"bg\"];\n}>) => {\n return (\n <Container data-qa-toast=\"\">\n {highlightColor ? (\n <ToastHighlight bg={highlightColor} aria-hidden />\n ) : null}\n\n <Box css=\"line-height: 1;\">{icon}</Box>\n\n <Box flex={1}>\n <Text as=\"div\" color=\"text.body\" data-qa-toast-content=\"\">\n {children}\n </Text>\n </Box>\n\n <Box css=\"line-height: 1;\">{close}</Box>\n </Container>\n );\n};\n\nexport const ToastHighlight = styled(Box)<ComponentProps<typeof Box>>`\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n width: 2px;\n`;\n","import styled from \"styled-components\";\nimport type { ComponentProps } from \"react\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport \"react-toastify/dist/ReactToastify.css\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport { ToastContainer } from \"react-toastify\";\n\nexport const TOAST_Z_INDEX = 9999;\n\nexport const Container = styled(Box)<ComponentProps<typeof Box>>`\n display: flex;\n align-items: center;\n gap: ${({ theme }) => theme.space[350]};\n font-family: ${({ theme }) => theme.fontFamily};\n ${({ theme }) => theme.typography[200]}\n position: relative;\n padding: ${({ theme }) => theme.space[350]};\n`;\n\nexport const ToastRoot = styled(ToastContainer).attrs({\n toastClassName: \"Toastify-toast-overrides\",\n hideProgressBar: true,\n closeButton: false,\n icon: false,\n position: \"bottom-right\",\n})`\n --toastify-z-index: ${TOAST_Z_INDEX};\n --toastify-toast-offset: ${({ theme }) => theme.space[400]};\n --toastify-toast-width: 360px;\n --toastify-toast-min-height: 48px;\n --toastify-toast-max-height: 70vh;\n --toastify-toast-bd-radius: ${({ theme }) => theme.radii[400]};\n --toastify-toast-background: ${({ theme }) =>\n theme.colors.container.background.base};\n /* there's margin-bottom on the last toast so we can remove this */\n --toastify-toast-bottom: 0;\n\n padding: 0;\n\n .Toastify-toast-overrides {\n background: ${({ theme }) => theme.colors.container.background.base};\n color: ${({ theme }) => theme.colors.text.body};\n box-shadow: ${({ theme }) => theme.shadows.low};\n padding: 0;\n margin-bottom: var(--toastify-toast-offset);\n }\n\n .Toastify__toast-body {\n padding: 0;\n margin: 0;\n }\n\n /* Override React Toastify's mobile width styles */\n @media only screen and (max-width: 480px) {\n .Toastify-container-overrides {\n min-width: initial !important;\n }\n }\n\n /* Zoom animation */\n @keyframes SproutToast__zoom-in {\n from {\n opacity: 0;\n transform: scale3d(0.3, 0.3, 0.3);\n }\n 50% {\n opacity: 1;\n }\n }\n @keyframes SproutToast__zoom-out {\n from {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n transform: scale3d(0.3, 0.3, 0.3) translate3d(0, var(--y), 0);\n }\n to {\n opacity: 0;\n }\n }\n .SproutToast__zoom-in {\n animation: SproutToast__zoom-in ${({ theme }) => theme.duration.medium}\n ${({ theme }) => theme.easing.ease_out} both;\n }\n .SproutToast__zoom-out {\n animation: SproutToast__zoom-out ${({ theme }) => theme.duration.slow}\n ${({ theme }) => theme.easing.ease_in} both;\n }\n\n /* No animation (it's still necessary to define classes for no animation to work properly) */\n @keyframes SproutToast__none-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n @keyframes SproutToast__none-out {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n .SproutToast__none-in {\n animation: SproutToast__none-in 0s both;\n }\n .SproutToast__none-out {\n animation: SproutToast__none-out 0s both;\n }\n`;\n","import type { ComponentProps } from \"react\";\nimport { type Icon, type TypeIconName } from \"@sproutsocial/seeds-react-icon\";\nimport type { ToastContent, ToastOptions } from \"react-toastify\";\n\nexport type TypeToastTheme = \"info\" | \"success\" | \"warning\" | \"error\";\n\ninterface BaseToastOptions<TData>\n extends Omit<ToastOptions<TData>, \"closeButton\" | \"icon\" | \"type\"> {\n theme?: TypeToastTheme | \"custom\";\n content: ToastContent<TData>;\n persist?: boolean;\n useTransition?: boolean;\n}\n\ninterface ThemedToastOptions<TData> extends BaseToastOptions<TData> {\n /**\n * One of `info`, `success`, `warning`, or `error`.\n */\n theme?: TypeToastTheme;\n /**\n * @deprecated Use `custom` theme instead.\n */\n color?: ComponentProps<typeof Icon>[\"color\"];\n /**\n * @deprecated Use `custom` theme instead.\n */\n icon?: TypeIconName;\n}\ninterface CustomToastOptions<TData> extends BaseToastOptions<TData> {\n /**\n * If you need to break out of the supported styles you can use the `custom` theme. You can use `ToastContentContainer` with `Icon` and `ToastHighlight` to build your custom toast.\n */\n theme: \"custom\";\n}\n\nexport type TypeToastOptions<TData> =\n | ThemedToastOptions<TData>\n | CustomToastOptions<TData>;\n"],"mappings":";AACA;AAAA,EACE,SAAS;AAAA,EACT;AAAA,OAEK;AACP,OAAOA,UAAS;AAChB,OAAO,UAAiC;AACxC,OAAO,UAAU;;;ACRjB,OAAO,YAAY;AAInB,OAAO;AACP,OAAO,SAAS;AAChB,SAAS,sBAAsB;AAExB,IAAM,gBAAgB;AAEtB,IAAM,YAAY,OAAO,GAAG;AAAA;AAAA;AAAA,SAG1B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,iBACvB,CAAC,EAAE,MAAM,MAAM,MAAM,UAAU;AAAA,IAC5C,CAAC,EAAE,MAAM,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA;AAAA,aAE3B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAGrC,IAAM,YAAY,OAAO,cAAc,EAAE,MAAM;AAAA,EACpD,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;AAAA,wBACuB,aAAa;AAAA,6BACR,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,gCAI5B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,iCAC9B,CAAC,EAAE,MAAM,MACtC,MAAM,OAAO,UAAU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A;AAAA,IACA,SAAS,WAAW;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAEA,MAAI,WAAW,cAAc,OAAO,GAAG;AACrC,kBAAc,OAAc,SAAS;AAAA,MACnC,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC;AAAA,EACH,OAAO;AACL,cAAU,cAAqB,aAAa,YAAY;AAAA,EAC1D;AAEA,SAAO;AACT;AAIO,IAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAUO;AACL,SACE,qBAAC,aAAU,iBAAc,IACtB;AAAA,qBACC,oBAAC,kBAAe,IAAI,gBAAgB,eAAW,MAAC,IAC9C;AAAA,IAEJ,oBAACC,MAAA,EAAI,KAAI,mBAAmB,gBAAK;AAAA,IAEjC,oBAACA,MAAA,EAAI,MAAM,GACT,8BAAC,QAAK,IAAG,OAAM,OAAM,aAAY,yBAAsB,IACpD,UACH,GACF;AAAA,IAEA,oBAACA,MAAA,EAAI,KAAI,mBAAmB,iBAAM;AAAA,KACpC;AAEJ;AAEO,IAAM,iBAAiBC,QAAOD,IAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AErKxC,OAA6C;","names":["Box","styled","ToastContainer","Box","styled"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as styled_components from 'styled-components';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ComponentProps, PropsWithChildren, ReactNode } from 'react';
|
|
4
|
+
import * as _sproutsocial_seeds_react_box from '@sproutsocial/seeds-react-box';
|
|
5
|
+
import _sproutsocial_seeds_react_box__default from '@sproutsocial/seeds-react-box';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import { ToastContainer as ToastContainer$1, ToastOptions, ToastContent, toast as toast$1 } from 'react-toastify';
|
|
8
|
+
import { Icon, TypeIconName } from '@sproutsocial/seeds-react-icon';
|
|
9
|
+
|
|
10
|
+
declare const TOAST_Z_INDEX = 9999;
|
|
11
|
+
declare const ToastRoot: styled_components.StyledComponent<typeof ToastContainer$1, styled_components.DefaultTheme, {
|
|
12
|
+
toastClassName: "Toastify-toast-overrides";
|
|
13
|
+
hideProgressBar: true;
|
|
14
|
+
closeButton: false;
|
|
15
|
+
icon: false;
|
|
16
|
+
position: "bottom-right";
|
|
17
|
+
}, "position" | "toastClassName" | "closeButton" | "hideProgressBar" | "icon">;
|
|
18
|
+
|
|
19
|
+
type TypeToastTheme = "info" | "success" | "warning" | "error";
|
|
20
|
+
interface BaseToastOptions<TData> extends Omit<ToastOptions<TData>, "closeButton" | "icon" | "type"> {
|
|
21
|
+
theme?: TypeToastTheme | "custom";
|
|
22
|
+
content: ToastContent<TData>;
|
|
23
|
+
persist?: boolean;
|
|
24
|
+
useTransition?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface ThemedToastOptions<TData> extends BaseToastOptions<TData> {
|
|
27
|
+
/**
|
|
28
|
+
* One of `info`, `success`, `warning`, or `error`.
|
|
29
|
+
*/
|
|
30
|
+
theme?: TypeToastTheme;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use `custom` theme instead.
|
|
33
|
+
*/
|
|
34
|
+
color?: ComponentProps<typeof Icon>["color"];
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use `custom` theme instead.
|
|
37
|
+
*/
|
|
38
|
+
icon?: TypeIconName;
|
|
39
|
+
}
|
|
40
|
+
interface CustomToastOptions<TData> extends BaseToastOptions<TData> {
|
|
41
|
+
/**
|
|
42
|
+
* If you need to break out of the supported styles you can use the `custom` theme. You can use `ToastContentContainer` with `Icon` and `ToastHighlight` to build your custom toast.
|
|
43
|
+
*/
|
|
44
|
+
theme: "custom";
|
|
45
|
+
}
|
|
46
|
+
type TypeToastOptions<TData> = ThemedToastOptions<TData> | CustomToastOptions<TData>;
|
|
47
|
+
|
|
48
|
+
declare const toastDismiss: typeof toast$1.dismiss;
|
|
49
|
+
declare const toastIsActive: typeof toast$1.isActive;
|
|
50
|
+
declare const toastUpdate: typeof toast$1.update;
|
|
51
|
+
declare const ToastContainer: (props: Partial<ComponentProps<typeof ToastRoot>>) => react_jsx_runtime.JSX.Element;
|
|
52
|
+
declare function toast<TData = unknown>(options: TypeToastOptions<TData>): ReturnType<typeof toast$1>;
|
|
53
|
+
|
|
54
|
+
declare const ToastContentContainer: ({ children, icon, close, highlightColor, }: PropsWithChildren<{
|
|
55
|
+
/**
|
|
56
|
+
* A ReactNode in the icon slot
|
|
57
|
+
*/
|
|
58
|
+
icon: ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* A ReactNode in the close button slot
|
|
61
|
+
*/
|
|
62
|
+
close: ReactNode;
|
|
63
|
+
highlightColor?: ComponentProps<typeof _sproutsocial_seeds_react_box__default>["bg"];
|
|
64
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
65
|
+
declare const ToastHighlight: styled_components.StyledComponent<react.ForwardRefExoticComponent<Omit<_sproutsocial_seeds_react_box.TypeBoxProps, "ref"> & react.RefAttributes<HTMLDivElement>>, styled_components.DefaultTheme, Omit<_sproutsocial_seeds_react_box.TypeBoxProps, "ref"> & react.RefAttributes<HTMLDivElement>, never>;
|
|
66
|
+
|
|
67
|
+
export { TOAST_Z_INDEX, ToastContainer, ToastContentContainer, ToastHighlight, type TypeToastOptions, type TypeToastTheme, toast, toastDismiss, toastIsActive, toastUpdate };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as styled_components from 'styled-components';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ComponentProps, PropsWithChildren, ReactNode } from 'react';
|
|
4
|
+
import * as _sproutsocial_seeds_react_box from '@sproutsocial/seeds-react-box';
|
|
5
|
+
import _sproutsocial_seeds_react_box__default from '@sproutsocial/seeds-react-box';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import { ToastContainer as ToastContainer$1, ToastOptions, ToastContent, toast as toast$1 } from 'react-toastify';
|
|
8
|
+
import { Icon, TypeIconName } from '@sproutsocial/seeds-react-icon';
|
|
9
|
+
|
|
10
|
+
declare const TOAST_Z_INDEX = 9999;
|
|
11
|
+
declare const ToastRoot: styled_components.StyledComponent<typeof ToastContainer$1, styled_components.DefaultTheme, {
|
|
12
|
+
toastClassName: "Toastify-toast-overrides";
|
|
13
|
+
hideProgressBar: true;
|
|
14
|
+
closeButton: false;
|
|
15
|
+
icon: false;
|
|
16
|
+
position: "bottom-right";
|
|
17
|
+
}, "position" | "toastClassName" | "closeButton" | "hideProgressBar" | "icon">;
|
|
18
|
+
|
|
19
|
+
type TypeToastTheme = "info" | "success" | "warning" | "error";
|
|
20
|
+
interface BaseToastOptions<TData> extends Omit<ToastOptions<TData>, "closeButton" | "icon" | "type"> {
|
|
21
|
+
theme?: TypeToastTheme | "custom";
|
|
22
|
+
content: ToastContent<TData>;
|
|
23
|
+
persist?: boolean;
|
|
24
|
+
useTransition?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface ThemedToastOptions<TData> extends BaseToastOptions<TData> {
|
|
27
|
+
/**
|
|
28
|
+
* One of `info`, `success`, `warning`, or `error`.
|
|
29
|
+
*/
|
|
30
|
+
theme?: TypeToastTheme;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use `custom` theme instead.
|
|
33
|
+
*/
|
|
34
|
+
color?: ComponentProps<typeof Icon>["color"];
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use `custom` theme instead.
|
|
37
|
+
*/
|
|
38
|
+
icon?: TypeIconName;
|
|
39
|
+
}
|
|
40
|
+
interface CustomToastOptions<TData> extends BaseToastOptions<TData> {
|
|
41
|
+
/**
|
|
42
|
+
* If you need to break out of the supported styles you can use the `custom` theme. You can use `ToastContentContainer` with `Icon` and `ToastHighlight` to build your custom toast.
|
|
43
|
+
*/
|
|
44
|
+
theme: "custom";
|
|
45
|
+
}
|
|
46
|
+
type TypeToastOptions<TData> = ThemedToastOptions<TData> | CustomToastOptions<TData>;
|
|
47
|
+
|
|
48
|
+
declare const toastDismiss: typeof toast$1.dismiss;
|
|
49
|
+
declare const toastIsActive: typeof toast$1.isActive;
|
|
50
|
+
declare const toastUpdate: typeof toast$1.update;
|
|
51
|
+
declare const ToastContainer: (props: Partial<ComponentProps<typeof ToastRoot>>) => react_jsx_runtime.JSX.Element;
|
|
52
|
+
declare function toast<TData = unknown>(options: TypeToastOptions<TData>): ReturnType<typeof toast$1>;
|
|
53
|
+
|
|
54
|
+
declare const ToastContentContainer: ({ children, icon, close, highlightColor, }: PropsWithChildren<{
|
|
55
|
+
/**
|
|
56
|
+
* A ReactNode in the icon slot
|
|
57
|
+
*/
|
|
58
|
+
icon: ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* A ReactNode in the close button slot
|
|
61
|
+
*/
|
|
62
|
+
close: ReactNode;
|
|
63
|
+
highlightColor?: ComponentProps<typeof _sproutsocial_seeds_react_box__default>["bg"];
|
|
64
|
+
}>) => react_jsx_runtime.JSX.Element;
|
|
65
|
+
declare const ToastHighlight: styled_components.StyledComponent<react.ForwardRefExoticComponent<Omit<_sproutsocial_seeds_react_box.TypeBoxProps, "ref"> & react.RefAttributes<HTMLDivElement>>, styled_components.DefaultTheme, Omit<_sproutsocial_seeds_react_box.TypeBoxProps, "ref"> & react.RefAttributes<HTMLDivElement>, never>;
|
|
66
|
+
|
|
67
|
+
export { TOAST_Z_INDEX, ToastContainer, ToastContentContainer, ToastHighlight, type TypeToastOptions, type TypeToastTheme, toast, toastDismiss, toastIsActive, toastUpdate };
|