@pittorica/toast-react 0.22.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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/Toast.d.ts +16 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.stories.d.ts +5 -0
- package/dist/Toast.stories.d.ts.map +1 -0
- package/dist/Toast.test.d.ts +5 -0
- package/dist/Toast.test.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +444 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Davide Di Criscito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @pittorica/toast-react
|
|
2
|
+
|
|
3
|
+
The `Toast` component.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pittorica/toast-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { Toast } from '@pittorica/toast-react';
|
|
15
|
+
// TODO: Add usage example
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
This project is licensed under the MIT License.
|
|
21
|
+
|
|
22
|
+
**Copyright (c) 2025 Davide Di Criscito**
|
|
23
|
+
|
|
24
|
+
For the full details, see the [LICENSE](LICENSE) file.
|
package/dist/Toast.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface ToastData {
|
|
3
|
+
id: string;
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
duration?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Dispatches a global toast notification.
|
|
10
|
+
*/
|
|
11
|
+
export declare const toast: (data: Omit<ToastData, "id">) => void;
|
|
12
|
+
/**
|
|
13
|
+
* ToastProvider renders notifications sent via the toast() function.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ToastProvider: () => import("react").ReactPortal | null;
|
|
16
|
+
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAUf,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAIhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,0CAuEzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.stories.d.ts","sourceRoot":"","sources":["../src/Toast.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIvD,QAAA,MAAM,IAAI,EAAE,IAUX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,WAAW,EAAE,QA6BzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.test.d.ts","sourceRoot":"","sources":["../src/Toast.test.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,2BAA2B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { jsx as y, jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as P, createElement as L, useState as X, useRef as V, useCallback as D, useEffect as G } from "react";
|
|
3
|
+
import { createPortal as H } from "react-dom";
|
|
4
|
+
/**
|
|
5
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license.
|
|
8
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
var J = {
|
|
11
|
+
outline: {
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
+
width: 24,
|
|
14
|
+
height: 24,
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeWidth: 2,
|
|
19
|
+
strokeLinecap: "round",
|
|
20
|
+
strokeLinejoin: "round"
|
|
21
|
+
},
|
|
22
|
+
filled: {
|
|
23
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
+
width: 24,
|
|
25
|
+
height: 24,
|
|
26
|
+
viewBox: "0 0 24 24",
|
|
27
|
+
fill: "currentColor",
|
|
28
|
+
stroke: "none"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the MIT license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/
|
|
37
|
+
const K = (e, i, r, t) => {
|
|
38
|
+
const o = P(
|
|
39
|
+
({ color: s = "currentColor", size: n = 24, stroke: c = 2, title: l, className: p, children: d, ...f }, m) => L(
|
|
40
|
+
"svg",
|
|
41
|
+
{
|
|
42
|
+
ref: m,
|
|
43
|
+
...J[e],
|
|
44
|
+
width: n,
|
|
45
|
+
height: n,
|
|
46
|
+
className: ["tabler-icon", `tabler-icon-${i}`, p].join(" "),
|
|
47
|
+
fill: s,
|
|
48
|
+
...f
|
|
49
|
+
},
|
|
50
|
+
[
|
|
51
|
+
l && L("title", { key: "svg-title" }, l),
|
|
52
|
+
...t.map(([g, u]) => L(g, u)),
|
|
53
|
+
...Array.isArray(d) ? d : [d]
|
|
54
|
+
]
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
return o.displayName = `${r}`, o;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* @license @tabler/icons-react v3.36.1 - MIT
|
|
61
|
+
*
|
|
62
|
+
* This source code is licensed under the MIT license.
|
|
63
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
64
|
+
*/
|
|
65
|
+
const Q = [["path", { d: "M12 2l.324 .001l.318 .004l.616 .017l.299 .013l.579 .034l.553 .046c4.785 .464 6.732 2.411 7.196 7.196l.046 .553l.034 .579c.005 .098 .01 .198 .013 .299l.017 .616l.005 .642l-.005 .642l-.017 .616l-.013 .299l-.034 .579l-.046 .553c-.464 4.785 -2.411 6.732 -7.196 7.196l-.553 .046l-.579 .034c-.098 .005 -.198 .01 -.299 .013l-.616 .017l-.642 .005l-.642 -.005l-.616 -.017l-.299 -.013l-.579 -.034l-.553 -.046c-4.785 -.464 -6.732 -2.411 -7.196 -7.196l-.046 -.553l-.034 -.579a28.058 28.058 0 0 1 -.013 -.299l-.017 -.616c-.003 -.21 -.005 -.424 -.005 -.642l.001 -.324l.004 -.318l.017 -.616l.013 -.299l.034 -.579l.046 -.553c.464 -4.785 2.411 -6.732 7.196 -7.196l.553 -.046l.579 -.034c.098 -.005 .198 -.01 .299 -.013l.616 -.017c.21 -.003 .424 -.005 .642 -.005zm-1.489 7.14a1 1 0 0 0 -1.218 1.567l1.292 1.293l-1.292 1.293l-.083 .094a1 1 0 0 0 1.497 1.32l1.293 -1.292l1.293 1.292l.094 .083a1 1 0 0 0 1.32 -1.497l-1.292 -1.293l1.292 -1.293l.083 -.094a1 1 0 0 0 -1.497 -1.32l-1.293 1.292l-1.293 -1.292l-.094 -.083z", fill: "currentColor", key: "svg-0", strokeWidth: "0" }]], U = K("filled", "square-rounded-x-filled", "SquareRoundedXFilled", Q);
|
|
66
|
+
function z(e) {
|
|
67
|
+
var i, r, t = "";
|
|
68
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
69
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
70
|
+
var o = e.length;
|
|
71
|
+
for (i = 0; i < o; i++) e[i] && (r = z(e[i])) && (t && (t += " "), t += r);
|
|
72
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
73
|
+
return t;
|
|
74
|
+
}
|
|
75
|
+
function Y() {
|
|
76
|
+
for (var e, i, r = 0, t = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (i = z(e)) && (t && (t += " "), t += i);
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
const C = ({
|
|
80
|
+
ref: e,
|
|
81
|
+
as: i = "div",
|
|
82
|
+
children: r,
|
|
83
|
+
display: t,
|
|
84
|
+
m: o,
|
|
85
|
+
mt: s,
|
|
86
|
+
mr: n,
|
|
87
|
+
mb: c,
|
|
88
|
+
ml: l,
|
|
89
|
+
p,
|
|
90
|
+
pt: d,
|
|
91
|
+
pr: f,
|
|
92
|
+
pb: m,
|
|
93
|
+
pl: g,
|
|
94
|
+
width: u,
|
|
95
|
+
height: h,
|
|
96
|
+
position: v,
|
|
97
|
+
style: b,
|
|
98
|
+
className: $,
|
|
99
|
+
href: w,
|
|
100
|
+
target: N,
|
|
101
|
+
rel: x,
|
|
102
|
+
htmlFor: T,
|
|
103
|
+
type: A,
|
|
104
|
+
disabled: k,
|
|
105
|
+
...R
|
|
106
|
+
}) => {
|
|
107
|
+
const a = {};
|
|
108
|
+
t && (a.display = t), u && (a.width = u), h && (a.height = h), v && (a.position = v), o && (a.margin = `var(--pittorica-space-${o})`), s && (a.marginTop = `var(--pittorica-space-${s})`), n && (a.marginRight = `var(--pittorica-space-${n})`), c && (a.marginBottom = `var(--pittorica-space-${c})`), l && (a.marginLeft = `var(--pittorica-space-${l})`), p && (a.padding = `var(--pittorica-space-${p})`), d && (a.paddingTop = `var(--pittorica-space-${d})`), f && (a.paddingRight = `var(--pittorica-space-${f})`), m && (a.paddingBottom = `var(--pittorica-space-${m})`), g && (a.paddingLeft = `var(--pittorica-space-${g})`);
|
|
109
|
+
const B = {
|
|
110
|
+
...b,
|
|
111
|
+
...a
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ y(
|
|
114
|
+
i,
|
|
115
|
+
{
|
|
116
|
+
ref: e,
|
|
117
|
+
className: Y("pittorica-box", $),
|
|
118
|
+
style: B,
|
|
119
|
+
href: w,
|
|
120
|
+
target: N,
|
|
121
|
+
rel: x,
|
|
122
|
+
htmlFor: T,
|
|
123
|
+
type: A,
|
|
124
|
+
disabled: k,
|
|
125
|
+
...R,
|
|
126
|
+
children: r
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
C.displayName = "Box";
|
|
131
|
+
function S(e) {
|
|
132
|
+
var i, r, t = "";
|
|
133
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
134
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
135
|
+
var o = e.length;
|
|
136
|
+
for (i = 0; i < o; i++) e[i] && (r = S(e[i])) && (t && (t += " "), t += r);
|
|
137
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
138
|
+
return t;
|
|
139
|
+
}
|
|
140
|
+
function Z() {
|
|
141
|
+
for (var e, i, r = 0, t = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (i = S(e)) && (t && (t += " "), t += i);
|
|
142
|
+
return t;
|
|
143
|
+
}
|
|
144
|
+
function W(e) {
|
|
145
|
+
var i, r, t = "";
|
|
146
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
147
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
148
|
+
var o = e.length;
|
|
149
|
+
for (i = 0; i < o; i++) e[i] && (r = W(e[i])) && (t && (t += " "), t += r);
|
|
150
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
151
|
+
return t;
|
|
152
|
+
}
|
|
153
|
+
function tt() {
|
|
154
|
+
for (var e, i, r = 0, t = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (i = W(e)) && (t && (t += " "), t += i);
|
|
155
|
+
return t;
|
|
156
|
+
}
|
|
157
|
+
const q = ({
|
|
158
|
+
ref: e,
|
|
159
|
+
as: i = "div",
|
|
160
|
+
children: r,
|
|
161
|
+
display: t,
|
|
162
|
+
m: o,
|
|
163
|
+
mt: s,
|
|
164
|
+
mr: n,
|
|
165
|
+
mb: c,
|
|
166
|
+
ml: l,
|
|
167
|
+
p,
|
|
168
|
+
pt: d,
|
|
169
|
+
pr: f,
|
|
170
|
+
pb: m,
|
|
171
|
+
pl: g,
|
|
172
|
+
width: u,
|
|
173
|
+
height: h,
|
|
174
|
+
position: v,
|
|
175
|
+
style: b,
|
|
176
|
+
className: $,
|
|
177
|
+
href: w,
|
|
178
|
+
target: N,
|
|
179
|
+
rel: x,
|
|
180
|
+
htmlFor: T,
|
|
181
|
+
type: A,
|
|
182
|
+
disabled: k,
|
|
183
|
+
...R
|
|
184
|
+
}) => {
|
|
185
|
+
const a = {};
|
|
186
|
+
t && (a.display = t), u && (a.width = u), h && (a.height = h), v && (a.position = v), o && (a.margin = `var(--pittorica-space-${o})`), s && (a.marginTop = `var(--pittorica-space-${s})`), n && (a.marginRight = `var(--pittorica-space-${n})`), c && (a.marginBottom = `var(--pittorica-space-${c})`), l && (a.marginLeft = `var(--pittorica-space-${l})`), p && (a.padding = `var(--pittorica-space-${p})`), d && (a.paddingTop = `var(--pittorica-space-${d})`), f && (a.paddingRight = `var(--pittorica-space-${f})`), m && (a.paddingBottom = `var(--pittorica-space-${m})`), g && (a.paddingLeft = `var(--pittorica-space-${g})`);
|
|
187
|
+
const B = {
|
|
188
|
+
...b,
|
|
189
|
+
...a
|
|
190
|
+
};
|
|
191
|
+
return /* @__PURE__ */ y(
|
|
192
|
+
i,
|
|
193
|
+
{
|
|
194
|
+
ref: e,
|
|
195
|
+
className: tt("pittorica-box", $),
|
|
196
|
+
style: B,
|
|
197
|
+
href: w,
|
|
198
|
+
target: N,
|
|
199
|
+
rel: x,
|
|
200
|
+
htmlFor: T,
|
|
201
|
+
type: A,
|
|
202
|
+
disabled: k,
|
|
203
|
+
...R,
|
|
204
|
+
children: r
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
};
|
|
208
|
+
q.displayName = "Box";
|
|
209
|
+
const _ = ({
|
|
210
|
+
children: e,
|
|
211
|
+
variant: i = "filled",
|
|
212
|
+
color: r = "indigo",
|
|
213
|
+
size: t = "3",
|
|
214
|
+
className: o,
|
|
215
|
+
style: s,
|
|
216
|
+
ref: n,
|
|
217
|
+
...c
|
|
218
|
+
}) => {
|
|
219
|
+
const l = r !== "inherit" && !(r != null && r.startsWith("#")) && !(r != null && r.startsWith("rgb")), p = {
|
|
220
|
+
...s,
|
|
221
|
+
"--pittorica-source-color": l ? `var(--pittorica-${r}-9)` : r,
|
|
222
|
+
"--pittorica-on-source-color": "#ffffff"
|
|
223
|
+
};
|
|
224
|
+
return /* @__PURE__ */ y(
|
|
225
|
+
q,
|
|
226
|
+
{
|
|
227
|
+
...c,
|
|
228
|
+
as: c.href ? "a" : "button",
|
|
229
|
+
ref: n,
|
|
230
|
+
className: Z(
|
|
231
|
+
"pittorica-icon-button",
|
|
232
|
+
`pittorica-icon-button--${i}`,
|
|
233
|
+
`pittorica-icon-button--${t}`,
|
|
234
|
+
o
|
|
235
|
+
),
|
|
236
|
+
style: p,
|
|
237
|
+
children: e
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
_.displayName = "IconButton";
|
|
242
|
+
function I(e) {
|
|
243
|
+
var i, r, t = "";
|
|
244
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
245
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
246
|
+
var o = e.length;
|
|
247
|
+
for (i = 0; i < o; i++) e[i] && (r = I(e[i])) && (t && (t += " "), t += r);
|
|
248
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
249
|
+
return t;
|
|
250
|
+
}
|
|
251
|
+
function et() {
|
|
252
|
+
for (var e, i, r = 0, t = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (i = I(e)) && (t && (t += " "), t += i);
|
|
253
|
+
return t;
|
|
254
|
+
}
|
|
255
|
+
function M(e) {
|
|
256
|
+
var i, r, t = "";
|
|
257
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
258
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
259
|
+
var o = e.length;
|
|
260
|
+
for (i = 0; i < o; i++) e[i] && (r = M(e[i])) && (t && (t += " "), t += r);
|
|
261
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
262
|
+
return t;
|
|
263
|
+
}
|
|
264
|
+
function rt() {
|
|
265
|
+
for (var e, i, r = 0, t = "", o = arguments.length; r < o; r++) (e = arguments[r]) && (i = M(e)) && (t && (t += " "), t += i);
|
|
266
|
+
return t;
|
|
267
|
+
}
|
|
268
|
+
const O = ({
|
|
269
|
+
ref: e,
|
|
270
|
+
as: i = "div",
|
|
271
|
+
children: r,
|
|
272
|
+
display: t,
|
|
273
|
+
m: o,
|
|
274
|
+
mt: s,
|
|
275
|
+
mr: n,
|
|
276
|
+
mb: c,
|
|
277
|
+
ml: l,
|
|
278
|
+
p,
|
|
279
|
+
pt: d,
|
|
280
|
+
pr: f,
|
|
281
|
+
pb: m,
|
|
282
|
+
pl: g,
|
|
283
|
+
width: u,
|
|
284
|
+
height: h,
|
|
285
|
+
position: v,
|
|
286
|
+
style: b,
|
|
287
|
+
className: $,
|
|
288
|
+
href: w,
|
|
289
|
+
target: N,
|
|
290
|
+
rel: x,
|
|
291
|
+
htmlFor: T,
|
|
292
|
+
type: A,
|
|
293
|
+
disabled: k,
|
|
294
|
+
...R
|
|
295
|
+
}) => {
|
|
296
|
+
const a = {};
|
|
297
|
+
t && (a.display = t), u && (a.width = u), h && (a.height = h), v && (a.position = v), o && (a.margin = `var(--pittorica-space-${o})`), s && (a.marginTop = `var(--pittorica-space-${s})`), n && (a.marginRight = `var(--pittorica-space-${n})`), c && (a.marginBottom = `var(--pittorica-space-${c})`), l && (a.marginLeft = `var(--pittorica-space-${l})`), p && (a.padding = `var(--pittorica-space-${p})`), d && (a.paddingTop = `var(--pittorica-space-${d})`), f && (a.paddingRight = `var(--pittorica-space-${f})`), m && (a.paddingBottom = `var(--pittorica-space-${m})`), g && (a.paddingLeft = `var(--pittorica-space-${g})`);
|
|
298
|
+
const B = {
|
|
299
|
+
...b,
|
|
300
|
+
...a
|
|
301
|
+
};
|
|
302
|
+
return /* @__PURE__ */ y(
|
|
303
|
+
i,
|
|
304
|
+
{
|
|
305
|
+
ref: e,
|
|
306
|
+
className: rt("pittorica-box", $),
|
|
307
|
+
style: B,
|
|
308
|
+
href: w,
|
|
309
|
+
target: N,
|
|
310
|
+
rel: x,
|
|
311
|
+
htmlFor: T,
|
|
312
|
+
type: A,
|
|
313
|
+
disabled: k,
|
|
314
|
+
...R,
|
|
315
|
+
children: r
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
};
|
|
319
|
+
O.displayName = "Box";
|
|
320
|
+
const it = (e, i) => i ? typeof i == "string" ? [`pittorica-text--${e}-${i}`] : Object.entries(i).filter(([r, t]) => t !== void 0).map(
|
|
321
|
+
([r, t]) => r === "initial" ? `pittorica-text--${e}-${t}` : `pittorica-text--${r}-${e}-${t}`
|
|
322
|
+
) : [], F = ({
|
|
323
|
+
children: e,
|
|
324
|
+
as: i = "span",
|
|
325
|
+
size: r = "3",
|
|
326
|
+
weight: t = "regular",
|
|
327
|
+
align: o,
|
|
328
|
+
truncate: s = !1,
|
|
329
|
+
color: n,
|
|
330
|
+
className: c,
|
|
331
|
+
style: l,
|
|
332
|
+
href: p,
|
|
333
|
+
target: d,
|
|
334
|
+
rel: f,
|
|
335
|
+
htmlFor: m,
|
|
336
|
+
...g
|
|
337
|
+
}) => {
|
|
338
|
+
const u = (n == null ? void 0 : n.startsWith("#")) || (n == null ? void 0 : n.startsWith("rgb")), h = [
|
|
339
|
+
"danger",
|
|
340
|
+
"success",
|
|
341
|
+
"error",
|
|
342
|
+
"info",
|
|
343
|
+
"indigo",
|
|
344
|
+
"crimson",
|
|
345
|
+
"teal",
|
|
346
|
+
"amber",
|
|
347
|
+
"slate",
|
|
348
|
+
"blue",
|
|
349
|
+
"red"
|
|
350
|
+
].includes(n), v = (() => {
|
|
351
|
+
if (n) {
|
|
352
|
+
if (n === "inherit") return "inherit";
|
|
353
|
+
if (u) return n;
|
|
354
|
+
if (h) return `var(--pittorica-${n}-9)`;
|
|
355
|
+
}
|
|
356
|
+
})(), b = {
|
|
357
|
+
...l,
|
|
358
|
+
textAlign: o,
|
|
359
|
+
color: v
|
|
360
|
+
}, $ = it("size", r);
|
|
361
|
+
return /* @__PURE__ */ y(
|
|
362
|
+
O,
|
|
363
|
+
{
|
|
364
|
+
as: i,
|
|
365
|
+
className: et(
|
|
366
|
+
"pittorica-text",
|
|
367
|
+
{ "pittorica-text--truncate": s },
|
|
368
|
+
$,
|
|
369
|
+
c
|
|
370
|
+
),
|
|
371
|
+
"data-weight": t,
|
|
372
|
+
style: b,
|
|
373
|
+
href: p,
|
|
374
|
+
target: d,
|
|
375
|
+
rel: f,
|
|
376
|
+
htmlFor: m,
|
|
377
|
+
...g,
|
|
378
|
+
children: e
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
}, j = "pittorica-toast", st = (e) => {
|
|
382
|
+
const i = Math.random().toString(36).slice(2, 9), r = new CustomEvent(j, { detail: { ...e, id: i } });
|
|
383
|
+
globalThis.dispatchEvent(r);
|
|
384
|
+
}, lt = () => {
|
|
385
|
+
const [e, i] = X([]), r = V(/* @__PURE__ */ new Set()), t = D((o) => {
|
|
386
|
+
i((s) => s.filter((n) => n.id !== o));
|
|
387
|
+
}, []);
|
|
388
|
+
return G(() => {
|
|
389
|
+
const o = (s) => {
|
|
390
|
+
const c = s.detail;
|
|
391
|
+
if (i((l) => [...l, c]), c.duration !== 0) {
|
|
392
|
+
const l = setTimeout(() => {
|
|
393
|
+
t(c.id), r.current.delete(l);
|
|
394
|
+
}, c.duration || 3e3);
|
|
395
|
+
r.current.add(l);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
return globalThis.addEventListener(j, o), () => {
|
|
399
|
+
globalThis.removeEventListener(j, o);
|
|
400
|
+
for (const s of r.current) clearTimeout(s);
|
|
401
|
+
r.current.clear();
|
|
402
|
+
};
|
|
403
|
+
}, [t]), typeof document > "u" ? null : H(
|
|
404
|
+
/* @__PURE__ */ y(
|
|
405
|
+
C,
|
|
406
|
+
{
|
|
407
|
+
className: "pittorica-toast-viewport",
|
|
408
|
+
role: "region",
|
|
409
|
+
"aria-label": "Notifications",
|
|
410
|
+
children: e.map((o) => /* @__PURE__ */ E(
|
|
411
|
+
C,
|
|
412
|
+
{
|
|
413
|
+
className: "pittorica-toast-root",
|
|
414
|
+
role: "status",
|
|
415
|
+
"aria-live": "polite",
|
|
416
|
+
children: [
|
|
417
|
+
/* @__PURE__ */ E(C, { className: "pittorica-toast-content", children: [
|
|
418
|
+
/* @__PURE__ */ y(F, { size: "2", weight: "bold", style: { display: "block" }, children: o.title }),
|
|
419
|
+
o.description && /* @__PURE__ */ y(F, { size: "2", color: "slate", style: { display: "block" }, children: o.description })
|
|
420
|
+
] }),
|
|
421
|
+
/* @__PURE__ */ y(
|
|
422
|
+
_,
|
|
423
|
+
{
|
|
424
|
+
variant: "text",
|
|
425
|
+
color: "slate",
|
|
426
|
+
size: "1",
|
|
427
|
+
onClick: () => t(o.id),
|
|
428
|
+
"aria-label": "Close",
|
|
429
|
+
children: /* @__PURE__ */ y(U, { size: 18 })
|
|
430
|
+
}
|
|
431
|
+
)
|
|
432
|
+
]
|
|
433
|
+
},
|
|
434
|
+
o.id
|
|
435
|
+
))
|
|
436
|
+
}
|
|
437
|
+
),
|
|
438
|
+
document.body
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
export {
|
|
442
|
+
lt as ToastProvider,
|
|
443
|
+
st as toast
|
|
444
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pittorica/toast-react",
|
|
3
|
+
"version": "0.22.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@tabler/icons-react": "^3.36.1",
|
|
13
|
+
"clsx": "^2.1.1",
|
|
14
|
+
"@pittorica/box-react": "0.22.0",
|
|
15
|
+
"@pittorica/icon-button-react": "0.22.0",
|
|
16
|
+
"@pittorica/text-react": "0.22.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
20
|
+
"@testing-library/react": "^14.0.0",
|
|
21
|
+
"@types/react": "^19.2.3",
|
|
22
|
+
"@types/react-dom": "^19.2.3",
|
|
23
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
24
|
+
"jsdom": "^22.0.0",
|
|
25
|
+
"typescript": "^5.0.0",
|
|
26
|
+
"vite": "^5.0.0",
|
|
27
|
+
"vitest": "^2.1.9",
|
|
28
|
+
"@pittorica/button-react": "0.22.0",
|
|
29
|
+
"@pittorica/flex-react": "0.22.0",
|
|
30
|
+
"pittorica": "0.22.0",
|
|
31
|
+
"@pittorica/theme-react": "0.22.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=19",
|
|
35
|
+
"react-dom": ">=19"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "npm run clean && npm run build:js && npm run build:types",
|
|
39
|
+
"build:js": "vite build",
|
|
40
|
+
"build:types": "tsc -p tsconfig.json",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"dev": "vite",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest"
|
|
45
|
+
}
|
|
46
|
+
}
|