@particle-academy/react-fancy 5.11.0 → 5.12.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.cjs +17 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9180,7 +9180,8 @@ var VARIANT_ICON_COLORS = {
|
|
|
9180
9180
|
info: "text-blue-500"
|
|
9181
9181
|
};
|
|
9182
9182
|
function ToastItem({ data, onDismiss }) {
|
|
9183
|
-
const { id, title, description, variant = "default",
|
|
9183
|
+
const { id, title, description, variant = "default", action } = data;
|
|
9184
|
+
const duration = data.duration ?? (action ? 0 : 5e3);
|
|
9184
9185
|
react.useEffect(() => {
|
|
9185
9186
|
if (duration <= 0) return;
|
|
9186
9187
|
const timer = setTimeout(() => onDismiss(id), duration);
|
|
@@ -9191,6 +9192,9 @@ function ToastItem({ data, onDismiss }) {
|
|
|
9191
9192
|
{
|
|
9192
9193
|
"data-react-fancy-toast-item": "",
|
|
9193
9194
|
role: "alert",
|
|
9195
|
+
onKeyDown: (e) => {
|
|
9196
|
+
if (e.key === "Escape") onDismiss(id);
|
|
9197
|
+
},
|
|
9194
9198
|
className: cn(
|
|
9195
9199
|
"fancy-toast-in pointer-events-auto w-80 rounded-xl border p-4 shadow-lg",
|
|
9196
9200
|
VARIANT_STYLES[variant]
|
|
@@ -9206,6 +9210,18 @@ function ToastItem({ data, onDismiss }) {
|
|
|
9206
9210
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-zinc-900 dark:text-zinc-100", children: title }),
|
|
9207
9211
|
description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-zinc-500 dark:text-zinc-400", children: description })
|
|
9208
9212
|
] }),
|
|
9213
|
+
action && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9214
|
+
"button",
|
|
9215
|
+
{
|
|
9216
|
+
type: "button",
|
|
9217
|
+
onClick: () => {
|
|
9218
|
+
action.onClick();
|
|
9219
|
+
onDismiss(id);
|
|
9220
|
+
},
|
|
9221
|
+
className: "shrink-0 self-center rounded-md px-2 py-1 text-xs font-medium text-zinc-700 underline-offset-2 transition-colors hover:bg-zinc-100 hover:underline dark:text-zinc-200 dark:hover:bg-zinc-800",
|
|
9222
|
+
children: action.label
|
|
9223
|
+
}
|
|
9224
|
+
),
|
|
9209
9225
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9210
9226
|
"button",
|
|
9211
9227
|
{
|