myoperator-ui 0.0.101 → 0.0.103
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.js +416 -131
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3869,55 +3869,363 @@ export { Alert, AlertTitle, AlertDescription, alertVariants };
|
|
|
3869
3869
|
name: "toast",
|
|
3870
3870
|
description: "A toast notification component for displaying brief messages at screen corners, with auto-dismiss and stacking support",
|
|
3871
3871
|
dependencies: [
|
|
3872
|
-
"
|
|
3872
|
+
"@radix-ui/react-toast",
|
|
3873
|
+
"class-variance-authority",
|
|
3874
|
+
"lucide-react",
|
|
3873
3875
|
"clsx",
|
|
3874
3876
|
"tailwind-merge"
|
|
3875
3877
|
],
|
|
3876
3878
|
files: [
|
|
3877
3879
|
{
|
|
3878
3880
|
name: "toast.tsx",
|
|
3879
|
-
content: prefixTailwindClasses(`import
|
|
3881
|
+
content: prefixTailwindClasses(`import * as React from "react";
|
|
3882
|
+
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
3883
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3884
|
+
import { X, CheckCircle2, XCircle, AlertTriangle, Info } from "lucide-react";
|
|
3880
3885
|
|
|
3881
3886
|
import { cn } from "../../lib/utils";
|
|
3882
3887
|
|
|
3883
|
-
|
|
3884
|
-
* Position options for the toast container.
|
|
3885
|
-
*/
|
|
3886
|
-
export type ToastPosition =
|
|
3887
|
-
| "top-left"
|
|
3888
|
-
| "top-center"
|
|
3889
|
-
| "top-right"
|
|
3890
|
-
| "bottom-left"
|
|
3891
|
-
| "bottom-center"
|
|
3892
|
-
| "bottom-right";
|
|
3888
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
3893
3889
|
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3890
|
+
const ToastViewport = React.forwardRef<
|
|
3891
|
+
React.ElementRef<typeof ToastPrimitives.Viewport>,
|
|
3892
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
|
|
3893
|
+
>(({ className, ...props }, ref) => (
|
|
3894
|
+
<ToastPrimitives.Viewport
|
|
3895
|
+
ref={ref}
|
|
3896
|
+
className={cn(
|
|
3897
|
+
"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]",
|
|
3898
|
+
className
|
|
3899
|
+
)}
|
|
3900
|
+
{...props}
|
|
3901
|
+
/>
|
|
3902
|
+
));
|
|
3903
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
3904
|
+
|
|
3905
|
+
const toastVariants = cva(
|
|
3906
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-lg border p-4 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",
|
|
3907
|
+
{
|
|
3908
|
+
variants: {
|
|
3909
|
+
variant: {
|
|
3910
|
+
default: "border-[#E9EAEB] bg-white text-[#181D27]",
|
|
3911
|
+
success: "border-[#17B26A]/20 bg-[#ECFDF3] text-[#067647]",
|
|
3912
|
+
error: "border-[#F04438]/20 bg-[#FEF3F2] text-[#B42318]",
|
|
3913
|
+
warning: "border-[#F79009]/20 bg-[#FFFAEB] text-[#B54708]",
|
|
3914
|
+
info: "border-[#4275D6]/20 bg-[#EBF5FF] text-[#1849A9]",
|
|
3915
|
+
},
|
|
3916
|
+
},
|
|
3917
|
+
defaultVariants: {
|
|
3918
|
+
variant: "default",
|
|
3919
|
+
},
|
|
3920
|
+
}
|
|
3921
|
+
);
|
|
3922
|
+
|
|
3923
|
+
const Toast = React.forwardRef<
|
|
3924
|
+
React.ElementRef<typeof ToastPrimitives.Root>,
|
|
3925
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
|
|
3926
|
+
VariantProps<typeof toastVariants>
|
|
3927
|
+
>(({ className, variant, ...props }, ref) => {
|
|
3928
|
+
return (
|
|
3929
|
+
<ToastPrimitives.Root
|
|
3930
|
+
ref={ref}
|
|
3931
|
+
className={cn(toastVariants({ variant }), className)}
|
|
3932
|
+
{...props}
|
|
3933
|
+
/>
|
|
3934
|
+
);
|
|
3935
|
+
});
|
|
3936
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
3937
|
+
|
|
3938
|
+
const ToastAction = React.forwardRef<
|
|
3939
|
+
React.ElementRef<typeof ToastPrimitives.Action>,
|
|
3940
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
|
|
3941
|
+
>(({ className, ...props }, ref) => (
|
|
3942
|
+
<ToastPrimitives.Action
|
|
3943
|
+
ref={ref}
|
|
3944
|
+
className={cn(
|
|
3945
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded border border-[#E9EAEB] bg-transparent px-3 text-sm font-medium transition-colors hover:bg-[#F5F5F5] focus:outline-none focus:ring-2 focus:ring-[#4275D6] focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
3946
|
+
"group-[.success]:border-[#17B26A]/30 group-[.success]:hover:border-[#17B26A]/50 group-[.success]:hover:bg-[#17B26A]/10",
|
|
3947
|
+
"group-[.error]:border-[#F04438]/30 group-[.error]:hover:border-[#F04438]/50 group-[.error]:hover:bg-[#F04438]/10",
|
|
3948
|
+
"group-[.warning]:border-[#F79009]/30 group-[.warning]:hover:border-[#F79009]/50 group-[.warning]:hover:bg-[#F79009]/10",
|
|
3949
|
+
"group-[.info]:border-[#4275D6]/30 group-[.info]:hover:border-[#4275D6]/50 group-[.info]:hover:bg-[#4275D6]/10",
|
|
3950
|
+
className
|
|
3951
|
+
)}
|
|
3952
|
+
{...props}
|
|
3953
|
+
/>
|
|
3954
|
+
));
|
|
3955
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
3956
|
+
|
|
3957
|
+
const ToastClose = React.forwardRef<
|
|
3958
|
+
React.ElementRef<typeof ToastPrimitives.Close>,
|
|
3959
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
|
|
3960
|
+
>(({ className, ...props }, ref) => (
|
|
3961
|
+
<ToastPrimitives.Close
|
|
3962
|
+
ref={ref}
|
|
3963
|
+
className={cn(
|
|
3964
|
+
"absolute right-2 top-2 rounded-md p-1 text-[#717680] opacity-0 transition-opacity hover:text-[#181D27] focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100",
|
|
3965
|
+
"group-[.success]:text-[#067647] group-[.success]:hover:text-[#067647]",
|
|
3966
|
+
"group-[.error]:text-[#B42318] group-[.error]:hover:text-[#B42318]",
|
|
3967
|
+
"group-[.warning]:text-[#B54708] group-[.warning]:hover:text-[#B54708]",
|
|
3968
|
+
"group-[.info]:text-[#1849A9] group-[.info]:hover:text-[#1849A9]",
|
|
3969
|
+
className
|
|
3970
|
+
)}
|
|
3971
|
+
toast-close=""
|
|
3972
|
+
{...props}
|
|
3973
|
+
>
|
|
3974
|
+
<X className="h-4 w-4" />
|
|
3975
|
+
</ToastPrimitives.Close>
|
|
3976
|
+
));
|
|
3977
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
3978
|
+
|
|
3979
|
+
const ToastTitle = React.forwardRef<
|
|
3980
|
+
React.ElementRef<typeof ToastPrimitives.Title>,
|
|
3981
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
|
|
3982
|
+
>(({ className, ...props }, ref) => (
|
|
3983
|
+
<ToastPrimitives.Title
|
|
3984
|
+
ref={ref}
|
|
3985
|
+
className={cn("text-sm font-semibold", className)}
|
|
3986
|
+
{...props}
|
|
3987
|
+
/>
|
|
3988
|
+
));
|
|
3989
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
3990
|
+
|
|
3991
|
+
const ToastDescription = React.forwardRef<
|
|
3992
|
+
React.ElementRef<typeof ToastPrimitives.Description>,
|
|
3993
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
|
3994
|
+
>(({ className, ...props }, ref) => (
|
|
3995
|
+
<ToastPrimitives.Description
|
|
3996
|
+
ref={ref}
|
|
3997
|
+
className={cn("text-sm opacity-90", className)}
|
|
3998
|
+
{...props}
|
|
3999
|
+
/>
|
|
4000
|
+
));
|
|
4001
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
4002
|
+
|
|
4003
|
+
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
4004
|
+
|
|
4005
|
+
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
|
4006
|
+
|
|
4007
|
+
export {
|
|
4008
|
+
type ToastProps,
|
|
4009
|
+
type ToastActionElement,
|
|
4010
|
+
ToastProvider,
|
|
4011
|
+
ToastViewport,
|
|
4012
|
+
Toast,
|
|
4013
|
+
ToastTitle,
|
|
4014
|
+
ToastDescription,
|
|
4015
|
+
ToastClose,
|
|
4016
|
+
ToastAction,
|
|
4017
|
+
toastVariants,
|
|
4018
|
+
};
|
|
4019
|
+
|
|
4020
|
+
// ============================================================================
|
|
4021
|
+
// Toast Hook & Toaster Component
|
|
4022
|
+
// ============================================================================
|
|
4023
|
+
|
|
4024
|
+
const TOAST_LIMIT = 5;
|
|
4025
|
+
const TOAST_REMOVE_DELAY = 5000;
|
|
4026
|
+
|
|
4027
|
+
type ToasterToast = ToastProps & {
|
|
4028
|
+
id: string;
|
|
4029
|
+
title?: React.ReactNode;
|
|
4030
|
+
description?: React.ReactNode;
|
|
4031
|
+
action?: ToastActionElement;
|
|
4032
|
+
};
|
|
4033
|
+
|
|
4034
|
+
const actionTypes = {
|
|
4035
|
+
ADD_TOAST: "ADD_TOAST",
|
|
4036
|
+
UPDATE_TOAST: "UPDATE_TOAST",
|
|
4037
|
+
DISMISS_TOAST: "DISMISS_TOAST",
|
|
4038
|
+
REMOVE_TOAST: "REMOVE_TOAST",
|
|
4039
|
+
} as const;
|
|
4040
|
+
|
|
4041
|
+
let count = 0;
|
|
4042
|
+
|
|
4043
|
+
function genId() {
|
|
4044
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
4045
|
+
return count.toString();
|
|
3916
4046
|
}
|
|
3917
4047
|
|
|
4048
|
+
type ActionType = typeof actionTypes;
|
|
4049
|
+
|
|
4050
|
+
type Action =
|
|
4051
|
+
| {
|
|
4052
|
+
type: ActionType["ADD_TOAST"];
|
|
4053
|
+
toast: ToasterToast;
|
|
4054
|
+
}
|
|
4055
|
+
| {
|
|
4056
|
+
type: ActionType["UPDATE_TOAST"];
|
|
4057
|
+
toast: Partial<ToasterToast>;
|
|
4058
|
+
}
|
|
4059
|
+
| {
|
|
4060
|
+
type: ActionType["DISMISS_TOAST"];
|
|
4061
|
+
toastId?: ToasterToast["id"];
|
|
4062
|
+
}
|
|
4063
|
+
| {
|
|
4064
|
+
type: ActionType["REMOVE_TOAST"];
|
|
4065
|
+
toastId?: ToasterToast["id"];
|
|
4066
|
+
};
|
|
4067
|
+
|
|
4068
|
+
interface State {
|
|
4069
|
+
toasts: ToasterToast[];
|
|
4070
|
+
}
|
|
4071
|
+
|
|
4072
|
+
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
4073
|
+
|
|
4074
|
+
const addToRemoveQueue = (toastId: string) => {
|
|
4075
|
+
if (toastTimeouts.has(toastId)) {
|
|
4076
|
+
return;
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4079
|
+
const timeout = setTimeout(() => {
|
|
4080
|
+
toastTimeouts.delete(toastId);
|
|
4081
|
+
dispatch({
|
|
4082
|
+
type: "REMOVE_TOAST",
|
|
4083
|
+
toastId: toastId,
|
|
4084
|
+
});
|
|
4085
|
+
}, TOAST_REMOVE_DELAY);
|
|
4086
|
+
|
|
4087
|
+
toastTimeouts.set(toastId, timeout);
|
|
4088
|
+
};
|
|
4089
|
+
|
|
4090
|
+
export const reducer = (state: State, action: Action): State => {
|
|
4091
|
+
switch (action.type) {
|
|
4092
|
+
case "ADD_TOAST":
|
|
4093
|
+
return {
|
|
4094
|
+
...state,
|
|
4095
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
4096
|
+
};
|
|
4097
|
+
|
|
4098
|
+
case "UPDATE_TOAST":
|
|
4099
|
+
return {
|
|
4100
|
+
...state,
|
|
4101
|
+
toasts: state.toasts.map((t) =>
|
|
4102
|
+
t.id === action.toast.id ? { ...t, ...action.toast } : t
|
|
4103
|
+
),
|
|
4104
|
+
};
|
|
4105
|
+
|
|
4106
|
+
case "DISMISS_TOAST": {
|
|
4107
|
+
const { toastId } = action;
|
|
4108
|
+
|
|
4109
|
+
if (toastId) {
|
|
4110
|
+
addToRemoveQueue(toastId);
|
|
4111
|
+
} else {
|
|
4112
|
+
state.toasts.forEach((toast) => {
|
|
4113
|
+
addToRemoveQueue(toast.id);
|
|
4114
|
+
});
|
|
4115
|
+
}
|
|
4116
|
+
|
|
4117
|
+
return {
|
|
4118
|
+
...state,
|
|
4119
|
+
toasts: state.toasts.map((t) =>
|
|
4120
|
+
t.id === toastId || toastId === undefined
|
|
4121
|
+
? {
|
|
4122
|
+
...t,
|
|
4123
|
+
open: false,
|
|
4124
|
+
}
|
|
4125
|
+
: t
|
|
4126
|
+
),
|
|
4127
|
+
};
|
|
4128
|
+
}
|
|
4129
|
+
case "REMOVE_TOAST":
|
|
4130
|
+
if (action.toastId === undefined) {
|
|
4131
|
+
return {
|
|
4132
|
+
...state,
|
|
4133
|
+
toasts: [],
|
|
4134
|
+
};
|
|
4135
|
+
}
|
|
4136
|
+
return {
|
|
4137
|
+
...state,
|
|
4138
|
+
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
4139
|
+
};
|
|
4140
|
+
}
|
|
4141
|
+
};
|
|
4142
|
+
|
|
4143
|
+
const listeners: Array<(state: State) => void> = [];
|
|
4144
|
+
|
|
4145
|
+
let memoryState: State = { toasts: [] };
|
|
4146
|
+
|
|
4147
|
+
function dispatch(action: Action) {
|
|
4148
|
+
memoryState = reducer(memoryState, action);
|
|
4149
|
+
listeners.forEach((listener) => {
|
|
4150
|
+
listener(memoryState);
|
|
4151
|
+
});
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
type Toast = Omit<ToasterToast, "id">;
|
|
4155
|
+
|
|
4156
|
+
function toast({ ...props }: Toast) {
|
|
4157
|
+
const id = genId();
|
|
4158
|
+
|
|
4159
|
+
const update = (props: ToasterToast) =>
|
|
4160
|
+
dispatch({
|
|
4161
|
+
type: "UPDATE_TOAST",
|
|
4162
|
+
toast: { ...props, id },
|
|
4163
|
+
});
|
|
4164
|
+
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
4165
|
+
|
|
4166
|
+
dispatch({
|
|
4167
|
+
type: "ADD_TOAST",
|
|
4168
|
+
toast: {
|
|
4169
|
+
...props,
|
|
4170
|
+
id,
|
|
4171
|
+
open: true,
|
|
4172
|
+
onOpenChange: (open) => {
|
|
4173
|
+
if (!open) dismiss();
|
|
4174
|
+
},
|
|
4175
|
+
},
|
|
4176
|
+
});
|
|
4177
|
+
|
|
4178
|
+
return {
|
|
4179
|
+
id: id,
|
|
4180
|
+
dismiss,
|
|
4181
|
+
update,
|
|
4182
|
+
};
|
|
4183
|
+
}
|
|
4184
|
+
|
|
4185
|
+
// Convenience methods for different variants
|
|
4186
|
+
toast.success = (props: Omit<Toast, "variant">) =>
|
|
4187
|
+
toast({ ...props, variant: "success" });
|
|
4188
|
+
toast.error = (props: Omit<Toast, "variant">) =>
|
|
4189
|
+
toast({ ...props, variant: "error" });
|
|
4190
|
+
toast.warning = (props: Omit<Toast, "variant">) =>
|
|
4191
|
+
toast({ ...props, variant: "warning" });
|
|
4192
|
+
toast.info = (props: Omit<Toast, "variant">) =>
|
|
4193
|
+
toast({ ...props, variant: "info" });
|
|
4194
|
+
toast.dismiss = (toastId?: string) =>
|
|
4195
|
+
dispatch({ type: "DISMISS_TOAST", toastId });
|
|
4196
|
+
|
|
4197
|
+
function useToast() {
|
|
4198
|
+
const [state, setState] = React.useState<State>(memoryState);
|
|
4199
|
+
|
|
4200
|
+
React.useEffect(() => {
|
|
4201
|
+
listeners.push(setState);
|
|
4202
|
+
return () => {
|
|
4203
|
+
const index = listeners.indexOf(setState);
|
|
4204
|
+
if (index > -1) {
|
|
4205
|
+
listeners.splice(index, 1);
|
|
4206
|
+
}
|
|
4207
|
+
};
|
|
4208
|
+
}, [state]);
|
|
4209
|
+
|
|
4210
|
+
return {
|
|
4211
|
+
...state,
|
|
4212
|
+
toast,
|
|
4213
|
+
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
4214
|
+
};
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4217
|
+
// Variant icons mapping
|
|
4218
|
+
const variantIcons = {
|
|
4219
|
+
default: null,
|
|
4220
|
+
success: CheckCircle2,
|
|
4221
|
+
error: XCircle,
|
|
4222
|
+
warning: AlertTriangle,
|
|
4223
|
+
info: Info,
|
|
4224
|
+
};
|
|
4225
|
+
|
|
3918
4226
|
/**
|
|
3919
|
-
*
|
|
3920
|
-
* Place this component once at the root of your app
|
|
4227
|
+
* Toaster component that renders toast notifications.
|
|
4228
|
+
* Place this component once at the root of your app.
|
|
3921
4229
|
*
|
|
3922
4230
|
* @example
|
|
3923
4231
|
* \`\`\`tsx
|
|
@@ -3934,125 +4242,102 @@ export interface ToasterProps {
|
|
|
3934
4242
|
* }
|
|
3935
4243
|
* \`\`\`
|
|
3936
4244
|
*/
|
|
3937
|
-
function Toaster({
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
duration = 4000,
|
|
3941
|
-
gap = 8,
|
|
3942
|
-
offset = 16,
|
|
3943
|
-
expand = true,
|
|
3944
|
-
visibleToasts = 3,
|
|
3945
|
-
className,
|
|
3946
|
-
richColors = true,
|
|
3947
|
-
...props
|
|
3948
|
-
}: ToasterProps) {
|
|
4245
|
+
function Toaster() {
|
|
4246
|
+
const { toasts } = useToast();
|
|
4247
|
+
|
|
3949
4248
|
return (
|
|
3950
|
-
<
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
"group-[.toast]:text-[#717680]",
|
|
3983
|
-
"group-[.toast]:hover:text-[#181D27]",
|
|
3984
|
-
"group-[.toast]:border-[#E9EAEB]",
|
|
3985
|
-
"group-[.toast]:bg-white"
|
|
3986
|
-
),
|
|
3987
|
-
// Variant-specific styles (when richColors is true)
|
|
3988
|
-
success: cn(
|
|
3989
|
-
"group-[.toaster]:bg-[#ECFDF3] group-[.toaster]:border-[#17B26A]/20",
|
|
3990
|
-
"group-[.toaster]:text-[#067647]",
|
|
3991
|
-
"[&_[data-icon]]:text-[#17B26A]"
|
|
3992
|
-
),
|
|
3993
|
-
error: cn(
|
|
3994
|
-
"group-[.toaster]:bg-[#FEF3F2] group-[.toaster]:border-[#F04438]/20",
|
|
3995
|
-
"group-[.toaster]:text-[#B42318]",
|
|
3996
|
-
"[&_[data-icon]]:text-[#F04438]"
|
|
3997
|
-
),
|
|
3998
|
-
warning: cn(
|
|
3999
|
-
"group-[.toaster]:bg-[#FFFAEB] group-[.toaster]:border-[#F79009]/20",
|
|
4000
|
-
"group-[.toaster]:text-[#B54708]",
|
|
4001
|
-
"[&_[data-icon]]:text-[#F79009]"
|
|
4002
|
-
),
|
|
4003
|
-
info: cn(
|
|
4004
|
-
"group-[.toaster]:bg-[#EBF5FF] group-[.toaster]:border-[#4275D6]/20",
|
|
4005
|
-
"group-[.toaster]:text-[#1849A9]",
|
|
4006
|
-
"[&_[data-icon]]:text-[#4275D6]"
|
|
4007
|
-
),
|
|
4008
|
-
},
|
|
4009
|
-
}}
|
|
4010
|
-
{...props}
|
|
4011
|
-
/>
|
|
4249
|
+
<ToastProvider>
|
|
4250
|
+
{toasts.map(function ({ id, title, description, action, variant, ...props }) {
|
|
4251
|
+
const Icon = variant ? variantIcons[variant] : null;
|
|
4252
|
+
|
|
4253
|
+
return (
|
|
4254
|
+
<Toast key={id} variant={variant} className={variant} {...props}>
|
|
4255
|
+
<div className="flex gap-3">
|
|
4256
|
+
{Icon && (
|
|
4257
|
+
<Icon
|
|
4258
|
+
className={cn(
|
|
4259
|
+
"h-5 w-5 shrink-0",
|
|
4260
|
+
variant === "success" && "text-[#17B26A]",
|
|
4261
|
+
variant === "error" && "text-[#F04438]",
|
|
4262
|
+
variant === "warning" && "text-[#F79009]",
|
|
4263
|
+
variant === "info" && "text-[#4275D6]"
|
|
4264
|
+
)}
|
|
4265
|
+
/>
|
|
4266
|
+
)}
|
|
4267
|
+
<div className="grid gap-1">
|
|
4268
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
4269
|
+
{description && (
|
|
4270
|
+
<ToastDescription>{description}</ToastDescription>
|
|
4271
|
+
)}
|
|
4272
|
+
</div>
|
|
4273
|
+
</div>
|
|
4274
|
+
{action}
|
|
4275
|
+
<ToastClose />
|
|
4276
|
+
</Toast>
|
|
4277
|
+
);
|
|
4278
|
+
})}
|
|
4279
|
+
<ToastViewport />
|
|
4280
|
+
</ToastProvider>
|
|
4012
4281
|
);
|
|
4013
4282
|
}
|
|
4014
4283
|
|
|
4015
|
-
|
|
4016
|
-
export { Toaster, toast };
|
|
4284
|
+
export { useToast, toast, Toaster };
|
|
4017
4285
|
|
|
4018
4286
|
/**
|
|
4019
|
-
*
|
|
4287
|
+
* Toast notification system using Radix UI primitives.
|
|
4020
4288
|
*
|
|
4021
4289
|
* @example
|
|
4022
4290
|
* \`\`\`tsx
|
|
4291
|
+
* // In your App.tsx or layout
|
|
4292
|
+
* import { Toaster } from "@/components/ui/toast"
|
|
4293
|
+
*
|
|
4294
|
+
* function App() {
|
|
4295
|
+
* return (
|
|
4296
|
+
* <>
|
|
4297
|
+
* <YourApp />
|
|
4298
|
+
* <Toaster />
|
|
4299
|
+
* </>
|
|
4300
|
+
* )
|
|
4301
|
+
* }
|
|
4302
|
+
* \`\`\`
|
|
4303
|
+
*
|
|
4304
|
+
* @example
|
|
4305
|
+
* \`\`\`tsx
|
|
4306
|
+
* // Trigger toasts from anywhere
|
|
4023
4307
|
* import { toast } from "@/components/ui/toast"
|
|
4024
4308
|
*
|
|
4025
4309
|
* // Simple message
|
|
4026
|
-
* toast("Event has been created")
|
|
4310
|
+
* toast({ title: "Event has been created" })
|
|
4027
4311
|
*
|
|
4028
|
-
* //
|
|
4029
|
-
* toast.success(
|
|
4312
|
+
* // Success toast
|
|
4313
|
+
* toast.success({
|
|
4314
|
+
* title: "Success!",
|
|
4030
4315
|
* description: "Your changes have been saved."
|
|
4031
4316
|
* })
|
|
4032
4317
|
*
|
|
4033
4318
|
* // Error toast
|
|
4034
|
-
* toast.error(
|
|
4319
|
+
* toast.error({
|
|
4320
|
+
* title: "Error",
|
|
4035
4321
|
* description: "Something went wrong. Please try again."
|
|
4036
4322
|
* })
|
|
4037
4323
|
*
|
|
4038
|
-
* //
|
|
4039
|
-
* toast(
|
|
4040
|
-
*
|
|
4041
|
-
*
|
|
4042
|
-
* onClick: () => console.log("Undo clicked")
|
|
4043
|
-
* }
|
|
4324
|
+
* // Warning toast
|
|
4325
|
+
* toast.warning({
|
|
4326
|
+
* title: "Warning",
|
|
4327
|
+
* description: "This action cannot be undone."
|
|
4044
4328
|
* })
|
|
4045
4329
|
*
|
|
4046
|
-
* //
|
|
4047
|
-
* toast.
|
|
4048
|
-
*
|
|
4049
|
-
*
|
|
4050
|
-
* error: "Failed to save"
|
|
4330
|
+
* // Info toast
|
|
4331
|
+
* toast.info({
|
|
4332
|
+
* title: "Info",
|
|
4333
|
+
* description: "You have 3 new notifications."
|
|
4051
4334
|
* })
|
|
4052
4335
|
*
|
|
4053
|
-
* //
|
|
4054
|
-
*
|
|
4055
|
-
*
|
|
4336
|
+
* // With action button
|
|
4337
|
+
* toast({
|
|
4338
|
+
* title: "Event created",
|
|
4339
|
+
* action: <ToastAction altText="Undo">Undo</ToastAction>
|
|
4340
|
+
* })
|
|
4056
4341
|
*
|
|
4057
4342
|
* // Dismiss all toasts
|
|
4058
4343
|
* toast.dismiss()
|