@nuvia/components 0.1.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/README.md +96 -0
- package/dist/hooks/use-mobile.cjs +44 -0
- package/dist/hooks/use-mobile.cjs.map +1 -0
- package/dist/hooks/use-mobile.js +22 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-toast.cjs +146 -0
- package/dist/hooks/use-toast.cjs.map +1 -0
- package/dist/hooks/use-toast.js +122 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/index.cjs +4117 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +3800 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/fonts.cjs +15 -0
- package/dist/lib/fonts.cjs.map +1 -0
- package/dist/lib/fonts.js +13 -0
- package/dist/lib/fonts.js.map +1 -0
- package/dist/lib/utils.cjs +18 -0
- package/dist/lib/utils.cjs.map +1 -0
- package/dist/lib/utils.js +14 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/providers/theme.cjs +24 -0
- package/dist/providers/theme.cjs.map +1 -0
- package/dist/providers/theme.js +22 -0
- package/dist/providers/theme.js.map +1 -0
- package/dist/ui/accordion.cjs +75 -0
- package/dist/ui/accordion.cjs.map +1 -0
- package/dist/ui/accordion.js +49 -0
- package/dist/ui/accordion.js.map +1 -0
- package/dist/ui/alert-dialog.cjs +189 -0
- package/dist/ui/alert-dialog.cjs.map +1 -0
- package/dist/ui/alert-dialog.js +156 -0
- package/dist/ui/alert-dialog.js.map +1 -0
- package/dist/ui/alert.cjs +81 -0
- package/dist/ui/alert.cjs.map +1 -0
- package/dist/ui/alert.js +57 -0
- package/dist/ui/alert.js.map +1 -0
- package/dist/ui/aspect-ratio.cjs +29 -0
- package/dist/ui/aspect-ratio.cjs.map +1 -0
- package/dist/ui/aspect-ratio.js +7 -0
- package/dist/ui/aspect-ratio.js.map +1 -0
- package/dist/ui/auto-complete.cjs +284 -0
- package/dist/ui/auto-complete.cjs.map +1 -0
- package/dist/ui/auto-complete.js +262 -0
- package/dist/ui/auto-complete.js.map +1 -0
- package/dist/ui/avatar.cjs +70 -0
- package/dist/ui/avatar.cjs.map +1 -0
- package/dist/ui/avatar.js +45 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/badge.cjs +34 -0
- package/dist/ui/badge.cjs.map +1 -0
- package/dist/ui/badge.js +31 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/breadcrumb.cjs +120 -0
- package/dist/ui/breadcrumb.cjs.map +1 -0
- package/dist/ui/breadcrumb.js +92 -0
- package/dist/ui/breadcrumb.js.map +1 -0
- package/dist/ui/button.cjs +80 -0
- package/dist/ui/button.cjs.map +1 -0
- package/dist/ui/button.js +57 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/calendar.cjs +135 -0
- package/dist/ui/calendar.cjs.map +1 -0
- package/dist/ui/calendar.js +113 -0
- package/dist/ui/calendar.js.map +1 -0
- package/dist/ui/card.cjs +89 -0
- package/dist/ui/card.cjs.map +1 -0
- package/dist/ui/card.js +62 -0
- package/dist/ui/card.js.map +1 -0
- package/dist/ui/carousel.cjs +269 -0
- package/dist/ui/carousel.cjs.map +1 -0
- package/dist/ui/carousel.js +240 -0
- package/dist/ui/carousel.js.map +1 -0
- package/dist/ui/chart.cjs +267 -0
- package/dist/ui/chart.cjs.map +1 -0
- package/dist/ui/chart.js +239 -0
- package/dist/ui/chart.js.map +1 -0
- package/dist/ui/checkbox.cjs +55 -0
- package/dist/ui/checkbox.cjs.map +1 -0
- package/dist/ui/checkbox.js +32 -0
- package/dist/ui/checkbox.js.map +1 -0
- package/dist/ui/chip.cjs +79 -0
- package/dist/ui/chip.cjs.map +1 -0
- package/dist/ui/chip.js +55 -0
- package/dist/ui/chip.js.map +1 -0
- package/dist/ui/collapsible.cjs +33 -0
- package/dist/ui/collapsible.cjs.map +1 -0
- package/dist/ui/collapsible.js +9 -0
- package/dist/ui/collapsible.js.map +1 -0
- package/dist/ui/combobox.cjs +254 -0
- package/dist/ui/combobox.cjs.map +1 -0
- package/dist/ui/combobox.js +232 -0
- package/dist/ui/combobox.js.map +1 -0
- package/dist/ui/command.cjs +199 -0
- package/dist/ui/command.cjs.map +1 -0
- package/dist/ui/command.js +168 -0
- package/dist/ui/command.js.map +1 -0
- package/dist/ui/context-menu.cjs +181 -0
- package/dist/ui/context-menu.cjs.map +1 -0
- package/dist/ui/context-menu.js +144 -0
- package/dist/ui/context-menu.js.map +1 -0
- package/dist/ui/dialog.cjs +132 -0
- package/dist/ui/dialog.cjs.map +1 -0
- package/dist/ui/dialog.js +100 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/drawer.cjs +128 -0
- package/dist/ui/drawer.cjs.map +1 -0
- package/dist/ui/drawer.js +97 -0
- package/dist/ui/drawer.js.map +1 -0
- package/dist/ui/dropdown-menu.cjs +194 -0
- package/dist/ui/dropdown-menu.cjs.map +1 -0
- package/dist/ui/dropdown-menu.js +157 -0
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/ui/form.cjs +179 -0
- package/dist/ui/form.cjs.map +1 -0
- package/dist/ui/form.js +149 -0
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/hover-card.cjs +53 -0
- package/dist/ui/hover-card.cjs.map +1 -0
- package/dist/ui/hover-card.js +28 -0
- package/dist/ui/hover-card.js.map +1 -0
- package/dist/ui/input-otp.cjs +76 -0
- package/dist/ui/input-otp.cjs.map +1 -0
- package/dist/ui/input-otp.js +51 -0
- package/dist/ui/input-otp.js.map +1 -0
- package/dist/ui/input.cjs +51 -0
- package/dist/ui/input.cjs.map +1 -0
- package/dist/ui/input.js +29 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/label.cjs +55 -0
- package/dist/ui/label.cjs.map +1 -0
- package/dist/ui/label.js +32 -0
- package/dist/ui/label.js.map +1 -0
- package/dist/ui/lottie-animation.cjs +85 -0
- package/dist/ui/lottie-animation.cjs.map +1 -0
- package/dist/ui/lottie-animation.js +79 -0
- package/dist/ui/lottie-animation.js.map +1 -0
- package/dist/ui/menubar.cjs +210 -0
- package/dist/ui/menubar.cjs.map +1 -0
- package/dist/ui/menubar.js +172 -0
- package/dist/ui/menubar.js.map +1 -0
- package/dist/ui/multi-combobox.cjs +319 -0
- package/dist/ui/multi-combobox.cjs.map +1 -0
- package/dist/ui/multi-combobox.js +297 -0
- package/dist/ui/multi-combobox.js.map +1 -0
- package/dist/ui/navigation-menu.cjs +136 -0
- package/dist/ui/navigation-menu.cjs.map +1 -0
- package/dist/ui/navigation-menu.js +105 -0
- package/dist/ui/navigation-menu.js.map +1 -0
- package/dist/ui/pagination.cjs +172 -0
- package/dist/ui/pagination.cjs.map +1 -0
- package/dist/ui/pagination.js +144 -0
- package/dist/ui/pagination.js.map +1 -0
- package/dist/ui/popover.cjs +55 -0
- package/dist/ui/popover.cjs.map +1 -0
- package/dist/ui/popover.js +29 -0
- package/dist/ui/popover.js.map +1 -0
- package/dist/ui/progress.cjs +54 -0
- package/dist/ui/progress.cjs.map +1 -0
- package/dist/ui/progress.js +31 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/radio-group.cjs +62 -0
- package/dist/ui/radio-group.cjs.map +1 -0
- package/dist/ui/radio-group.js +38 -0
- package/dist/ui/radio-group.js.map +1 -0
- package/dist/ui/resizable.cjs +65 -0
- package/dist/ui/resizable.cjs.map +1 -0
- package/dist/ui/resizable.js +41 -0
- package/dist/ui/resizable.js.map +1 -0
- package/dist/ui/scroll-area.cjs +66 -0
- package/dist/ui/scroll-area.cjs.map +1 -0
- package/dist/ui/scroll-area.js +42 -0
- package/dist/ui/scroll-area.js.map +1 -0
- package/dist/ui/select.cjs +152 -0
- package/dist/ui/select.cjs.map +1 -0
- package/dist/ui/select.js +120 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/separator.cjs +52 -0
- package/dist/ui/separator.cjs.map +1 -0
- package/dist/ui/separator.js +29 -0
- package/dist/ui/separator.js.map +1 -0
- package/dist/ui/sheet.cjs +143 -0
- package/dist/ui/sheet.cjs.map +1 -0
- package/dist/ui/sheet.js +111 -0
- package/dist/ui/sheet.js.map +1 -0
- package/dist/ui/sidebar.cjs +816 -0
- package/dist/ui/sidebar.cjs.map +1 -0
- package/dist/ui/sidebar.js +768 -0
- package/dist/ui/sidebar.js.map +1 -0
- package/dist/ui/skeleton.cjs +25 -0
- package/dist/ui/skeleton.cjs.map +1 -0
- package/dist/ui/skeleton.js +23 -0
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/ui/slider.cjs +51 -0
- package/dist/ui/slider.cjs.map +1 -0
- package/dist/ui/slider.js +28 -0
- package/dist/ui/slider.js.map +1 -0
- package/dist/ui/sonner.cjs +46 -0
- package/dist/ui/sonner.cjs.map +1 -0
- package/dist/ui/sonner.js +41 -0
- package/dist/ui/sonner.js.map +1 -0
- package/dist/ui/spinner.cjs +83 -0
- package/dist/ui/spinner.cjs.map +1 -0
- package/dist/ui/spinner.js +81 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/switch.cjs +67 -0
- package/dist/ui/switch.cjs.map +1 -0
- package/dist/ui/switch.js +44 -0
- package/dist/ui/switch.js.map +1 -0
- package/dist/ui/table.cjs +118 -0
- package/dist/ui/table.cjs.map +1 -0
- package/dist/ui/table.js +89 -0
- package/dist/ui/table.js.map +1 -0
- package/dist/ui/tabs.cjs +79 -0
- package/dist/ui/tabs.cjs.map +1 -0
- package/dist/ui/tabs.js +53 -0
- package/dist/ui/tabs.js.map +1 -0
- package/dist/ui/textarea.cjs +48 -0
- package/dist/ui/textarea.cjs.map +1 -0
- package/dist/ui/textarea.js +26 -0
- package/dist/ui/textarea.js.map +1 -0
- package/dist/ui/toast.cjs +125 -0
- package/dist/ui/toast.cjs.map +1 -0
- package/dist/ui/toast.js +96 -0
- package/dist/ui/toast.js.map +1 -0
- package/dist/ui/toaster.cjs +251 -0
- package/dist/ui/toaster.cjs.map +1 -0
- package/dist/ui/toaster.js +228 -0
- package/dist/ui/toaster.js.map +1 -0
- package/dist/ui/toggle-group.cjs +101 -0
- package/dist/ui/toggle-group.cjs.map +1 -0
- package/dist/ui/toggle-group.js +76 -0
- package/dist/ui/toggle-group.js.map +1 -0
- package/dist/ui/toggle.cjs +66 -0
- package/dist/ui/toggle.cjs.map +1 -0
- package/dist/ui/toggle.js +42 -0
- package/dist/ui/toggle.js.map +1 -0
- package/dist/ui/tooltip.cjs +54 -0
- package/dist/ui/tooltip.cjs.map +1 -0
- package/dist/ui/tooltip.js +28 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/package.json +116 -0
- package/src/styles/globals.css +529 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var ToastPrimitives = require('@radix-ui/react-toast');
|
|
5
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
require('sonner');
|
|
8
|
+
var tailwindMerge = require('tailwind-merge');
|
|
9
|
+
var reactIcons = require('@radix-ui/react-icons');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
31
|
+
var ToastPrimitives__namespace = /*#__PURE__*/_interopNamespace(ToastPrimitives);
|
|
32
|
+
|
|
33
|
+
var cn = (...inputs) => tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
34
|
+
var ToastProvider = ToastPrimitives__namespace.Provider;
|
|
35
|
+
var ToastViewport = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
ToastPrimitives__namespace.Viewport,
|
|
37
|
+
{
|
|
38
|
+
ref,
|
|
39
|
+
className: cn(
|
|
40
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
41
|
+
className
|
|
42
|
+
),
|
|
43
|
+
...props
|
|
44
|
+
}
|
|
45
|
+
));
|
|
46
|
+
ToastViewport.displayName = ToastPrimitives__namespace.Viewport.displayName;
|
|
47
|
+
var toastVariants = classVarianceAuthority.cva(
|
|
48
|
+
"group border-border pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-xl border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
49
|
+
{
|
|
50
|
+
variants: {
|
|
51
|
+
variant: {
|
|
52
|
+
default: "border bg-background text-foreground",
|
|
53
|
+
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
variant: "default"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
var Toast = React__namespace.forwardRef(({ className, variant, ...props }, ref) => {
|
|
62
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
63
|
+
ToastPrimitives__namespace.Root,
|
|
64
|
+
{
|
|
65
|
+
ref,
|
|
66
|
+
className: cn(toastVariants({ variant }), className),
|
|
67
|
+
...props
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
Toast.displayName = ToastPrimitives__namespace.Root.displayName;
|
|
72
|
+
var ToastAction = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
+
ToastPrimitives__namespace.Action,
|
|
74
|
+
{
|
|
75
|
+
ref,
|
|
76
|
+
className: cn(
|
|
77
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-xl border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
78
|
+
className
|
|
79
|
+
),
|
|
80
|
+
...props
|
|
81
|
+
}
|
|
82
|
+
));
|
|
83
|
+
ToastAction.displayName = ToastPrimitives__namespace.Action.displayName;
|
|
84
|
+
var ToastClose = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
+
ToastPrimitives__namespace.Close,
|
|
86
|
+
{
|
|
87
|
+
ref,
|
|
88
|
+
className: cn(
|
|
89
|
+
"absolute right-1 top-1 rounded-xl p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
90
|
+
className
|
|
91
|
+
),
|
|
92
|
+
"toast-close": "",
|
|
93
|
+
...props,
|
|
94
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.Cross2Icon, { className: "h-4 w-4" })
|
|
95
|
+
}
|
|
96
|
+
));
|
|
97
|
+
ToastClose.displayName = ToastPrimitives__namespace.Close.displayName;
|
|
98
|
+
var ToastTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
99
|
+
ToastPrimitives__namespace.Title,
|
|
100
|
+
{
|
|
101
|
+
ref,
|
|
102
|
+
className: cn("text-sm font-semibold [&+div]:text-xs", className),
|
|
103
|
+
...props
|
|
104
|
+
}
|
|
105
|
+
));
|
|
106
|
+
ToastTitle.displayName = ToastPrimitives__namespace.Title.displayName;
|
|
107
|
+
var ToastDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
+
ToastPrimitives__namespace.Description,
|
|
109
|
+
{
|
|
110
|
+
ref,
|
|
111
|
+
className: cn("text-sm opacity-90", className),
|
|
112
|
+
...props
|
|
113
|
+
}
|
|
114
|
+
));
|
|
115
|
+
ToastDescription.displayName = ToastPrimitives__namespace.Description.displayName;
|
|
116
|
+
|
|
117
|
+
exports.Toast = Toast;
|
|
118
|
+
exports.ToastAction = ToastAction;
|
|
119
|
+
exports.ToastClose = ToastClose;
|
|
120
|
+
exports.ToastDescription = ToastDescription;
|
|
121
|
+
exports.ToastProvider = ToastProvider;
|
|
122
|
+
exports.ToastTitle = ToastTitle;
|
|
123
|
+
exports.ToastViewport = ToastViewport;
|
|
124
|
+
//# sourceMappingURL=toast.cjs.map
|
|
125
|
+
//# sourceMappingURL=toast.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/ui/toast.tsx"],"names":["twMerge","clsx","ToastPrimitives","React","jsx","cva","Cross2Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAM,KAAK,CAAA,GAAI,MAAA,KAAiCA,qBAAA,CAAQC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ner\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport const cn = (...inputs: ClassValue[]): string => twMerge(clsx(inputs));\n\nexport const capitalize = (str: string) =>\n str?.charAt(0)?.toUpperCase() + str?.slice(1);\n\nexport const handleError = (error: { message: string }): void => {\n toast.error(error.message);\n};\n","\"use client\"\n\nimport * as React from \"react\"\nimport * as ToastPrimitives from \"@radix-ui/react-toast\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../lib/utils\"\nimport { Cross2Icon } from \"@radix-ui/react-icons\"\n\nconst ToastProvider = ToastPrimitives.Provider\n\nconst ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Viewport>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Viewport\n ref={ref}\n className={cn(\n \"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]\",\n className\n )}\n {...props}\n />\n))\nToastViewport.displayName = ToastPrimitives.Viewport.displayName\n\nconst toastVariants = cva(\n \"group border-border pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-xl border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full\",\n {\n variants: {\n variant: {\n default: \"border bg-background text-foreground\",\n destructive:\n \"destructive group border-destructive bg-destructive text-destructive-foreground\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nconst Toast = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Root>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &\n VariantProps<typeof toastVariants>\n>(({ className, variant, ...props }, ref) => {\n return (\n <ToastPrimitives.Root\n ref={ref}\n className={cn(toastVariants({ variant }), className)}\n {...props}\n />\n )\n})\nToast.displayName = ToastPrimitives.Root.displayName\n\nconst ToastAction = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Action>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Action\n ref={ref}\n className={cn(\n \"inline-flex h-8 shrink-0 items-center justify-center rounded-xl border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive\",\n className\n )}\n {...props}\n />\n))\nToastAction.displayName = ToastPrimitives.Action.displayName\n\nconst ToastClose = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Close>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Close\n ref={ref}\n className={cn(\n \"absolute right-1 top-1 rounded-xl p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600\",\n className\n )}\n toast-close=\"\"\n {...props}\n >\n <Cross2Icon className=\"h-4 w-4\" />\n </ToastPrimitives.Close>\n))\nToastClose.displayName = ToastPrimitives.Close.displayName\n\nconst ToastTitle = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Title>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Title\n ref={ref}\n className={cn(\"text-sm font-semibold [&+div]:text-xs\", className)}\n {...props}\n />\n))\nToastTitle.displayName = ToastPrimitives.Title.displayName\n\nconst ToastDescription = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Description>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Description\n ref={ref}\n className={cn(\"text-sm opacity-90\", className)}\n {...props}\n />\n))\nToastDescription.displayName = ToastPrimitives.Description.displayName\n\ntype ToastProps = React.ComponentPropsWithoutRef<typeof Toast>\n\ntype ToastActionElement = React.ReactElement<typeof ToastAction>\n\nexport {\n type ToastProps,\n type ToastActionElement,\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastClose,\n ToastAction,\n}\n"]}
|
package/dist/ui/toast.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import 'sonner';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { Cross2Icon } from '@radix-ui/react-icons';
|
|
8
|
+
import { jsx } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var cn = (...inputs) => twMerge(clsx(inputs));
|
|
11
|
+
var ToastProvider = ToastPrimitives.Provider;
|
|
12
|
+
var ToastViewport = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
13
|
+
ToastPrimitives.Viewport,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
className: cn(
|
|
17
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
18
|
+
className
|
|
19
|
+
),
|
|
20
|
+
...props
|
|
21
|
+
}
|
|
22
|
+
));
|
|
23
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
24
|
+
var toastVariants = cva(
|
|
25
|
+
"group border-border pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-xl border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
26
|
+
{
|
|
27
|
+
variants: {
|
|
28
|
+
variant: {
|
|
29
|
+
default: "border bg-background text-foreground",
|
|
30
|
+
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
var Toast = React.forwardRef(({ className, variant, ...props }, ref) => {
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
ToastPrimitives.Root,
|
|
41
|
+
{
|
|
42
|
+
ref,
|
|
43
|
+
className: cn(toastVariants({ variant }), className),
|
|
44
|
+
...props
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
49
|
+
var ToastAction = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
50
|
+
ToastPrimitives.Action,
|
|
51
|
+
{
|
|
52
|
+
ref,
|
|
53
|
+
className: cn(
|
|
54
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-xl border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
55
|
+
className
|
|
56
|
+
),
|
|
57
|
+
...props
|
|
58
|
+
}
|
|
59
|
+
));
|
|
60
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
61
|
+
var ToastClose = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
62
|
+
ToastPrimitives.Close,
|
|
63
|
+
{
|
|
64
|
+
ref,
|
|
65
|
+
className: cn(
|
|
66
|
+
"absolute right-1 top-1 rounded-xl p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
67
|
+
className
|
|
68
|
+
),
|
|
69
|
+
"toast-close": "",
|
|
70
|
+
...props,
|
|
71
|
+
children: /* @__PURE__ */ jsx(Cross2Icon, { className: "h-4 w-4" })
|
|
72
|
+
}
|
|
73
|
+
));
|
|
74
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
75
|
+
var ToastTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
76
|
+
ToastPrimitives.Title,
|
|
77
|
+
{
|
|
78
|
+
ref,
|
|
79
|
+
className: cn("text-sm font-semibold [&+div]:text-xs", className),
|
|
80
|
+
...props
|
|
81
|
+
}
|
|
82
|
+
));
|
|
83
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
84
|
+
var ToastDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
85
|
+
ToastPrimitives.Description,
|
|
86
|
+
{
|
|
87
|
+
ref,
|
|
88
|
+
className: cn("text-sm opacity-90", className),
|
|
89
|
+
...props
|
|
90
|
+
}
|
|
91
|
+
));
|
|
92
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
93
|
+
|
|
94
|
+
export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport };
|
|
95
|
+
//# sourceMappingURL=toast.js.map
|
|
96
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/utils.ts","../../src/ui/toast.tsx"],"names":[],"mappings":";;;;;;;;;AAKO,IAAM,KAAK,CAAA,GAAI,MAAA,KAAiC,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;ACG3E,IAAM,aAAA,GAAgC,eAAA,CAAA;AAEtC,IAAM,aAAA,GAAsB,iBAG1B,CAAC,EAAE,WAAW,GAAG,KAAA,IAAS,GAAA,qBAC1B,GAAA;AAAA,EAAiB,eAAA,CAAA,QAAA;AAAA,EAAhB;AAAA,IACC,GAAA;AAAA,IACA,SAAA,EAAW,EAAA;AAAA,MACT,mIAAA;AAAA,MACA;AAAA,KACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,aAAA,CAAc,cAA8B,eAAA,CAAA,QAAA,CAAS,WAAA;AAErD,IAAM,aAAA,GAAgB,GAAA;AAAA,EACpB,ymBAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,sCAAA;AAAA,QACT,WAAA,EACE;AAAA;AACJ,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS;AAAA;AACX;AAEJ,CAAA;AAEA,IAAM,KAAA,GAAc,iBAIlB,CAAC,EAAE,WAAW,OAAA,EAAS,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AAC3C,EAAA,uBACE,GAAA;AAAA,IAAiB,eAAA,CAAA,IAAA;AAAA,IAAhB;AAAA,MACC,GAAA;AAAA,MACA,WAAW,EAAA,CAAG,aAAA,CAAc,EAAE,OAA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AAS,GAAA,qBAC1B,GAAA;AAAA,EAAiB,eAAA,CAAA,WAAA;AAAA,EAAhB;AAAA,IACC,GAAA;AAAA,IACA,SAAA,EAAW,EAAA,CAAG,oBAAA,EAAsB,SAAS,CAAA;AAAA,IAC5C,GAAG;AAAA;AACN,CACD;AACD,gBAAA,CAAiB,cAA8B,eAAA,CAAA,WAAA,CAAY,WAAA","file":"toast.js","sourcesContent":["import { clsx } from \"clsx\";\nimport type { ClassValue } from \"clsx\";\nimport { toast } from \"sonner\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport const cn = (...inputs: ClassValue[]): string => twMerge(clsx(inputs));\n\nexport const capitalize = (str: string) =>\n str?.charAt(0)?.toUpperCase() + str?.slice(1);\n\nexport const handleError = (error: { message: string }): void => {\n toast.error(error.message);\n};\n","\"use client\"\n\nimport * as React from \"react\"\nimport * as ToastPrimitives from \"@radix-ui/react-toast\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../lib/utils\"\nimport { Cross2Icon } from \"@radix-ui/react-icons\"\n\nconst ToastProvider = ToastPrimitives.Provider\n\nconst ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Viewport>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Viewport\n ref={ref}\n className={cn(\n \"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]\",\n className\n )}\n {...props}\n />\n))\nToastViewport.displayName = ToastPrimitives.Viewport.displayName\n\nconst toastVariants = cva(\n \"group border-border pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-xl border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full\",\n {\n variants: {\n variant: {\n default: \"border bg-background text-foreground\",\n destructive:\n \"destructive group border-destructive bg-destructive text-destructive-foreground\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nconst Toast = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Root>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &\n VariantProps<typeof toastVariants>\n>(({ className, variant, ...props }, ref) => {\n return (\n <ToastPrimitives.Root\n ref={ref}\n className={cn(toastVariants({ variant }), className)}\n {...props}\n />\n )\n})\nToast.displayName = ToastPrimitives.Root.displayName\n\nconst ToastAction = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Action>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Action\n ref={ref}\n className={cn(\n \"inline-flex h-8 shrink-0 items-center justify-center rounded-xl border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive\",\n className\n )}\n {...props}\n />\n))\nToastAction.displayName = ToastPrimitives.Action.displayName\n\nconst ToastClose = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Close>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Close\n ref={ref}\n className={cn(\n \"absolute right-1 top-1 rounded-xl p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600\",\n className\n )}\n toast-close=\"\"\n {...props}\n >\n <Cross2Icon className=\"h-4 w-4\" />\n </ToastPrimitives.Close>\n))\nToastClose.displayName = ToastPrimitives.Close.displayName\n\nconst ToastTitle = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Title>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Title\n ref={ref}\n className={cn(\"text-sm font-semibold [&+div]:text-xs\", className)}\n {...props}\n />\n))\nToastTitle.displayName = ToastPrimitives.Title.displayName\n\nconst ToastDescription = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Description>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Description\n ref={ref}\n className={cn(\"text-sm opacity-90\", className)}\n {...props}\n />\n))\nToastDescription.displayName = ToastPrimitives.Description.displayName\n\ntype ToastProps = React.ComponentPropsWithoutRef<typeof Toast>\n\ntype ToastActionElement = React.ReactElement<typeof ToastAction>\n\nexport {\n type ToastProps,\n type ToastActionElement,\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastClose,\n ToastAction,\n}\n"]}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React2 = require('react');
|
|
4
|
+
var ToastPrimitives = require('@radix-ui/react-toast');
|
|
5
|
+
var classVarianceAuthority = require('class-variance-authority');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
require('sonner');
|
|
8
|
+
var tailwindMerge = require('tailwind-merge');
|
|
9
|
+
var reactIcons = require('@radix-ui/react-icons');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
31
|
+
var ToastPrimitives__namespace = /*#__PURE__*/_interopNamespace(ToastPrimitives);
|
|
32
|
+
|
|
33
|
+
var TOAST_LIMIT = 1;
|
|
34
|
+
var TOAST_REMOVE_DELAY = 1e6;
|
|
35
|
+
var count = 0;
|
|
36
|
+
function genId() {
|
|
37
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
38
|
+
return count.toString();
|
|
39
|
+
}
|
|
40
|
+
var toastTimeouts = /* @__PURE__ */ new Map();
|
|
41
|
+
var addToRemoveQueue = (toastId) => {
|
|
42
|
+
if (toastTimeouts.has(toastId)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const timeout = setTimeout(() => {
|
|
46
|
+
toastTimeouts.delete(toastId);
|
|
47
|
+
dispatch({
|
|
48
|
+
type: "REMOVE_TOAST",
|
|
49
|
+
toastId
|
|
50
|
+
});
|
|
51
|
+
}, TOAST_REMOVE_DELAY);
|
|
52
|
+
toastTimeouts.set(toastId, timeout);
|
|
53
|
+
};
|
|
54
|
+
var reducer = (state, action) => {
|
|
55
|
+
switch (action.type) {
|
|
56
|
+
case "ADD_TOAST":
|
|
57
|
+
return {
|
|
58
|
+
...state,
|
|
59
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT)
|
|
60
|
+
};
|
|
61
|
+
case "UPDATE_TOAST":
|
|
62
|
+
return {
|
|
63
|
+
...state,
|
|
64
|
+
toasts: state.toasts.map(
|
|
65
|
+
(t) => t.id === action.toast.id ? { ...t, ...action.toast } : t
|
|
66
|
+
)
|
|
67
|
+
};
|
|
68
|
+
case "DISMISS_TOAST": {
|
|
69
|
+
const { toastId } = action;
|
|
70
|
+
if (toastId) {
|
|
71
|
+
addToRemoveQueue(toastId);
|
|
72
|
+
} else {
|
|
73
|
+
state.toasts.forEach((toast3) => {
|
|
74
|
+
addToRemoveQueue(toast3.id);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...state,
|
|
79
|
+
toasts: state.toasts.map(
|
|
80
|
+
(t) => t.id === toastId || toastId === void 0 ? {
|
|
81
|
+
...t,
|
|
82
|
+
open: false
|
|
83
|
+
} : t
|
|
84
|
+
)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
case "REMOVE_TOAST":
|
|
88
|
+
if (action.toastId === void 0) {
|
|
89
|
+
return {
|
|
90
|
+
...state,
|
|
91
|
+
toasts: []
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
...state,
|
|
96
|
+
toasts: state.toasts.filter((t) => t.id !== action.toastId)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var listeners = [];
|
|
101
|
+
var memoryState = { toasts: [] };
|
|
102
|
+
function dispatch(action) {
|
|
103
|
+
memoryState = reducer(memoryState, action);
|
|
104
|
+
listeners.forEach((listener) => {
|
|
105
|
+
listener(memoryState);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function toast({ ...props }) {
|
|
109
|
+
const id = genId();
|
|
110
|
+
const update = (props2) => dispatch({
|
|
111
|
+
type: "UPDATE_TOAST",
|
|
112
|
+
toast: { ...props2, id }
|
|
113
|
+
});
|
|
114
|
+
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
115
|
+
dispatch({
|
|
116
|
+
type: "ADD_TOAST",
|
|
117
|
+
toast: {
|
|
118
|
+
...props,
|
|
119
|
+
id,
|
|
120
|
+
open: true,
|
|
121
|
+
onOpenChange: (open) => {
|
|
122
|
+
if (!open) dismiss();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
id,
|
|
128
|
+
dismiss,
|
|
129
|
+
update
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function useToast() {
|
|
133
|
+
const [state, setState] = React2__namespace.useState(memoryState);
|
|
134
|
+
React2__namespace.useEffect(() => {
|
|
135
|
+
listeners.push(setState);
|
|
136
|
+
return () => {
|
|
137
|
+
const index = listeners.indexOf(setState);
|
|
138
|
+
if (index > -1) {
|
|
139
|
+
listeners.splice(index, 1);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}, [state]);
|
|
143
|
+
return {
|
|
144
|
+
...state,
|
|
145
|
+
toast,
|
|
146
|
+
dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId })
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
var cn = (...inputs) => tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
150
|
+
var ToastProvider = ToastPrimitives__namespace.Provider;
|
|
151
|
+
var ToastViewport = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
+
ToastPrimitives__namespace.Viewport,
|
|
153
|
+
{
|
|
154
|
+
ref,
|
|
155
|
+
className: cn(
|
|
156
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
157
|
+
className
|
|
158
|
+
),
|
|
159
|
+
...props
|
|
160
|
+
}
|
|
161
|
+
));
|
|
162
|
+
ToastViewport.displayName = ToastPrimitives__namespace.Viewport.displayName;
|
|
163
|
+
var toastVariants = classVarianceAuthority.cva(
|
|
164
|
+
"group border-border pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-xl border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
165
|
+
{
|
|
166
|
+
variants: {
|
|
167
|
+
variant: {
|
|
168
|
+
default: "border bg-background text-foreground",
|
|
169
|
+
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
defaultVariants: {
|
|
173
|
+
variant: "default"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
var Toast = React2__namespace.forwardRef(({ className, variant, ...props }, ref) => {
|
|
178
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
179
|
+
ToastPrimitives__namespace.Root,
|
|
180
|
+
{
|
|
181
|
+
ref,
|
|
182
|
+
className: cn(toastVariants({ variant }), className),
|
|
183
|
+
...props
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
Toast.displayName = ToastPrimitives__namespace.Root.displayName;
|
|
188
|
+
var ToastAction = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
189
|
+
ToastPrimitives__namespace.Action,
|
|
190
|
+
{
|
|
191
|
+
ref,
|
|
192
|
+
className: cn(
|
|
193
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-xl border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
194
|
+
className
|
|
195
|
+
),
|
|
196
|
+
...props
|
|
197
|
+
}
|
|
198
|
+
));
|
|
199
|
+
ToastAction.displayName = ToastPrimitives__namespace.Action.displayName;
|
|
200
|
+
var ToastClose = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
201
|
+
ToastPrimitives__namespace.Close,
|
|
202
|
+
{
|
|
203
|
+
ref,
|
|
204
|
+
className: cn(
|
|
205
|
+
"absolute right-1 top-1 rounded-xl p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
206
|
+
className
|
|
207
|
+
),
|
|
208
|
+
"toast-close": "",
|
|
209
|
+
...props,
|
|
210
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.Cross2Icon, { className: "h-4 w-4" })
|
|
211
|
+
}
|
|
212
|
+
));
|
|
213
|
+
ToastClose.displayName = ToastPrimitives__namespace.Close.displayName;
|
|
214
|
+
var ToastTitle = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
215
|
+
ToastPrimitives__namespace.Title,
|
|
216
|
+
{
|
|
217
|
+
ref,
|
|
218
|
+
className: cn("text-sm font-semibold [&+div]:text-xs", className),
|
|
219
|
+
...props
|
|
220
|
+
}
|
|
221
|
+
));
|
|
222
|
+
ToastTitle.displayName = ToastPrimitives__namespace.Title.displayName;
|
|
223
|
+
var ToastDescription = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
224
|
+
ToastPrimitives__namespace.Description,
|
|
225
|
+
{
|
|
226
|
+
ref,
|
|
227
|
+
className: cn("text-sm opacity-90", className),
|
|
228
|
+
...props
|
|
229
|
+
}
|
|
230
|
+
));
|
|
231
|
+
ToastDescription.displayName = ToastPrimitives__namespace.Description.displayName;
|
|
232
|
+
function Toaster() {
|
|
233
|
+
const { toasts } = useToast();
|
|
234
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ToastProvider, { children: [
|
|
235
|
+
toasts.map(function({ id, title, description, action, ...props }) {
|
|
236
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Toast, { ...props, children: [
|
|
237
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-1", children: [
|
|
238
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(ToastTitle, { children: title }),
|
|
239
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(ToastDescription, { children: description })
|
|
240
|
+
] }),
|
|
241
|
+
action,
|
|
242
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToastClose, {})
|
|
243
|
+
] }, id);
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToastViewport, {})
|
|
246
|
+
] });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
exports.Toaster = Toaster;
|
|
250
|
+
//# sourceMappingURL=toaster.cjs.map
|
|
251
|
+
//# sourceMappingURL=toaster.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/use-toast.ts","../../src/lib/utils.ts","../../src/ui/toast.tsx","../../src/ui/toaster.tsx"],"names":["toast","props","React","twMerge","clsx","ToastPrimitives","React2","jsx","cva","Cross2Icon","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAM,WAAA,GAAc,CAAA;AACpB,IAAM,kBAAA,GAAqB,GAAA;AAgB3B,IAAI,KAAA,GAAQ,CAAA;AAEZ,SAAS,KAAA,GAAQ;AACf,EAAA,KAAA,GAAA,CAAS,KAAA,GAAQ,KAAK,MAAA,CAAO,gBAAA;AAC7B,EAAA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A,CAAI,SAAU,EAAE,EAAA,EAAI,OAAO,WAAA,EAAa,MAAA,EAAQ,GAAG,KAAA,EAAM,EAAG;AAClE,MAAA,uBACEK,eAAA,CAAC,KAAA,EAAA,EAAgB,GAAG,KAAA,EAClB,QAAA,EAAA;AAAA,wBAAAA,eAAA,CAAC,KAAA,EAAA,EAAI,WAAU,YAAA,EACZ,QAAA,EAAA;AAAA,UAAA,KAAA,oBAASH,cAAAA,CAAC,UAAA,EAAA,EAAY,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,UAC5B,WAAA,oBACCA,cAAAA,CAAC,gBAAA,EAAA,EAAkB,QAAA,EAAA,WAAA,EAAY;AAAA,SAAA,EAEnC,CAAA;AAAA,QACC,MAAA;AAAA,wBACDA,eAAC,UAAA,EAAA,EAAW;AAAA,OAAA,EAAA,EARF,EASZ,CAAA;AAAA,IAEJ,CAAC,CAAA;AAAA,oBACDA,eAAC,aAAA,EAAA,EAAc;AAAA,GAAA,EACjB,CAAA;AAEJ","file":"toaster.cjs","sourcesContent":["\"use client\";\n\n// Inspired by react-hot-toast library\nimport * as React from \"react\";\n\nimport type { ToastActionElement, ToastProps } from \"../ui/toast\";\n\nconst TOAST_LIMIT = 1;\nconst TOAST_REMOVE_DELAY = 1000000;\n\ntype ToasterToast = ToastProps & {\n id: string;\n title?: React.ReactNode;\n description?: React.ReactNode;\n action?: ToastActionElement;\n};\n\nconst actionTypes = {\n ADD_TOAST: \"ADD_TOAST\",\n UPDATE_TOAST: \"UPDATE_TOAST\",\n DISMISS_TOAST: \"DISMISS_TOAST\",\n REMOVE_TOAST: \"REMOVE_TOAST\",\n} as const;\n\nlet count = 0;\n\nfunction genId() {\n count = (count + 1) % Number.MAX_SAFE_INTEGER;\n return count.toString();\n}\n\ntype ActionType = typeof actionTypes;\n\ntype Action =\n | {\n type: ActionType[\"ADD_TOAST\"];\n toast: ToasterToast;\n }\n | {\n type: ActionType[\"UPDATE_TOAST\"];\n toast: Partial<ToasterToast>;\n }\n | {\n type: ActionType[\"DISMISS_TOAST\"];\n toastId?: ToasterToast[\"id\"];\n }\n | {\n type: ActionType[\"REMOVE_TOAST\"];\n toastId?: ToasterToast[\"id\"];\n };\n\ninterface State {\n toasts: ToasterToast[];\n}\n\nconst toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();\n\nconst addToRemoveQueue = (toastId: string) => {\n if (toastTimeouts.has(toastId)) {\n return;\n }\n\n const timeout = setTimeout(() => {\n toastTimeouts.delete(toastId);\n dispatch({\n type: \"REMOVE_TOAST\",\n toastId: toastId,\n });\n }, TOAST_REMOVE_DELAY);\n\n toastTimeouts.set(toastId, timeout);\n};\n\nexport const reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case \"ADD_TOAST\":\n return {\n ...state,\n toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),\n };\n\n case \"UPDATE_TOAST\":\n return {\n ...state,\n toasts: state.toasts.map((t) =>\n t.id === action.toast.id ? { ...t, ...action.toast } : t\n ),\n };\n\n case \"DISMISS_TOAST\": {\n const { toastId } = action;\n\n // ! Side effects ! - This could be extracted into a dismissToast() action,\n // but I'll keep it here for simplicity\n if (toastId) {\n addToRemoveQueue(toastId);\n } else {\n state.toasts.forEach((toast) => {\n addToRemoveQueue(toast.id);\n });\n }\n\n return {\n ...state,\n toasts: state.toasts.map((t) =>\n t.id === toastId || toastId === undefined\n ? {\n ...t,\n open: false,\n }\n : t\n ),\n };\n }\n case \"REMOVE_TOAST\":\n if (action.toastId === undefined) {\n return {\n ...state,\n toasts: [],\n };\n }\n return {\n ...state,\n toasts: state.toasts.filter((t) => t.id !== action.toastId),\n };\n }\n};\n\nconst listeners: Array<(state: State) => void> = [];\n\nlet memoryState: State = { toasts: [] };\n\nfunction dispatch(action: Action) {\n memoryState = reducer(memoryState, action);\n listeners.forEach((listener) => {\n listener(memoryState);\n });\n}\n\ntype Toast = Omit<ToasterToast, \"id\">;\n\nfunction toast({ ...props }: Toast) {\n const id = genId();\n\n const update = (props: ToasterToast) =>\n dispatch({\n type: \"UPDATE_TOAST\",\n toast: { ...props, id },\n });\n const dismiss = () => dispatch({ type: \"DISMISS_TOAST\", toastId: id });\n\n dispatch({\n type: \"ADD_TOAST\",\n toast: {\n ...props,\n id,\n open: true,\n onOpenChange: (open) => {\n if (!open) dismiss();\n },\n },\n });\n\n return {\n id: id,\n dismiss,\n update,\n };\n}\n\nfunction useToast() {\n const [state, setState] = React.useState<State>(memoryState);\n\n React.useEffect(() => {\n listeners.push(setState);\n return () => {\n const index = listeners.indexOf(setState);\n if (index > -1) {\n listeners.splice(index, 1);\n }\n };\n }, [state]);\n\n return {\n ...state,\n toast,\n dismiss: (toastId?: string) => dispatch({ type: \"DISMISS_TOAST\", toastId }),\n };\n}\n\nexport { useToast, toast };\n","import { clsx } from \"clsx\";\nimport type { ClassValue } from \"clsx\";\nimport { toast } from \"sonner\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport const cn = (...inputs: ClassValue[]): string => twMerge(clsx(inputs));\n\nexport const capitalize = (str: string) =>\n str?.charAt(0)?.toUpperCase() + str?.slice(1);\n\nexport const handleError = (error: { message: string }): void => {\n toast.error(error.message);\n};\n","\"use client\"\n\nimport * as React from \"react\"\nimport * as ToastPrimitives from \"@radix-ui/react-toast\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../lib/utils\"\nimport { Cross2Icon } from \"@radix-ui/react-icons\"\n\nconst ToastProvider = ToastPrimitives.Provider\n\nconst ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Viewport>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Viewport\n ref={ref}\n className={cn(\n \"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]\",\n className\n )}\n {...props}\n />\n))\nToastViewport.displayName = ToastPrimitives.Viewport.displayName\n\nconst toastVariants = cva(\n \"group border-border pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-xl border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full\",\n {\n variants: {\n variant: {\n default: \"border bg-background text-foreground\",\n destructive:\n \"destructive group border-destructive bg-destructive text-destructive-foreground\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nconst Toast = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Root>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &\n VariantProps<typeof toastVariants>\n>(({ className, variant, ...props }, ref) => {\n return (\n <ToastPrimitives.Root\n ref={ref}\n className={cn(toastVariants({ variant }), className)}\n {...props}\n />\n )\n})\nToast.displayName = ToastPrimitives.Root.displayName\n\nconst ToastAction = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Action>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Action\n ref={ref}\n className={cn(\n \"inline-flex h-8 shrink-0 items-center justify-center rounded-xl border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive\",\n className\n )}\n {...props}\n />\n))\nToastAction.displayName = ToastPrimitives.Action.displayName\n\nconst ToastClose = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Close>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Close\n ref={ref}\n className={cn(\n \"absolute right-1 top-1 rounded-xl p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600\",\n className\n )}\n toast-close=\"\"\n {...props}\n >\n <Cross2Icon className=\"h-4 w-4\" />\n </ToastPrimitives.Close>\n))\nToastClose.displayName = ToastPrimitives.Close.displayName\n\nconst ToastTitle = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Title>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Title\n ref={ref}\n className={cn(\"text-sm font-semibold [&+div]:text-xs\", className)}\n {...props}\n />\n))\nToastTitle.displayName = ToastPrimitives.Title.displayName\n\nconst ToastDescription = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Description>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Description\n ref={ref}\n className={cn(\"text-sm opacity-90\", className)}\n {...props}\n />\n))\nToastDescription.displayName = ToastPrimitives.Description.displayName\n\ntype ToastProps = React.ComponentPropsWithoutRef<typeof Toast>\n\ntype ToastActionElement = React.ReactElement<typeof ToastAction>\n\nexport {\n type ToastProps,\n type ToastActionElement,\n ToastProvider,\n ToastViewport,\n Toast,\n ToastTitle,\n ToastDescription,\n ToastClose,\n ToastAction,\n}\n","\"use client\"\n\nimport { useToast } from \"../hooks/use-toast\"\nimport {\n Toast,\n ToastClose,\n ToastDescription,\n ToastProvider,\n ToastTitle,\n ToastViewport,\n} from \"./toast\"\n\nexport function Toaster() {\n const { toasts } = useToast()\n\n return (\n <ToastProvider>\n {toasts.map(function ({ id, title, description, action, ...props }) {\n return (\n <Toast key={id} {...props}>\n <div className=\"grid gap-1\">\n {title && <ToastTitle>{title}</ToastTitle>}\n {description && (\n <ToastDescription>{description}</ToastDescription>\n )}\n </div>\n {action}\n <ToastClose />\n </Toast>\n )\n })}\n <ToastViewport />\n </ToastProvider>\n )\n}\n"]}
|