lightswind
Version:
A collection of beautifully crafted React Components, Blocks & Templates for Modern Developers. Create stunning web applications effortlessly by using our 160+ professional and animated react components.
110 lines • 7.23 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToastAction = exports.ToastClose = exports.ToastDescription = exports.ToastTitle = exports.Toast = exports.ToastViewport = exports.ToastProvider = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const utils_1 = require("@/components/lib/utils");
const lucide_react_1 = require("lucide-react");
const class_variance_authority_1 = require("class-variance-authority");
const framer_motion_1 = require("framer-motion");
/* Toast Components */
const ToastProvider = ({ children }) => {
return (0, jsx_runtime_1.jsx)("div", { className: "toast-provider", children: children });
};
exports.ToastProvider = ToastProvider;
const toastViewportVariants = (0, class_variance_authority_1.cva)("fixed z-[100] flex flex-col gap-2 p-4 w-full md:max-w-[420px] pointer-events-none", {
variants: {
position: {
"top-right": "top-0 right-0 flex-col-reverse",
"top-left": "top-0 left-0 flex-col-reverse",
"bottom-right": "bottom-0 right-0 flex-col",
"bottom-left": "bottom-0 left-0 flex-col",
"top-center": "top-0 left-1/2 -translate-x-1/2 flex-col-reverse items-center",
"bottom-center": "bottom-0 left-1/2 -translate-x-1/2 flex-col items-center",
},
},
defaultVariants: {
position: "top-right",
},
});
const ToastViewport = React.forwardRef(({ className, position = "top-right", ...props }, ref) => ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: (0, utils_1.cn)(toastViewportVariants({ position }), className), ...props })));
exports.ToastViewport = ToastViewport;
ToastViewport.displayName = "ToastViewport";
const toastVariants = (0, class_variance_authority_1.cva)(`group relative flex w-96 items-center justify-between overflow-hidden rounded-md border p-4 pr-8 shadow-lg transition-all
bg-background text-foreground`, {
variants: {
variant: {
default: "border bg-background text-foreground",
destructive: "border-red-500 bg-red-100 text-red-800",
success: "border-green-500 bg-green-100 text-green-800",
warning: "border-yellow-500 bg-yellow-100 text-yellow-800",
info: "border-primarylw bg-[color-mix(in_srgb,var(--primarylw)_15%,white)] dark:bg-[color-mix(in_srgb,var(--primarylw)_15%,black)] text-primarylw",
},
},
defaultVariants: {
variant: "default",
},
});
const Toast = React.forwardRef(({ className, variant = "default", duration = 5000, open = true, onOpenChange, onClose, children, ...props }, ref) => {
return ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { ref: ref, layout: true, initial: { opacity: 0, scale: 0.7, y: -20 }, animate: { opacity: 1, scale: 1, y: 0 }, exit: { opacity: 0, scale: 0.7, y: -20 }, transition: {
type: "spring",
damping: 25,
stiffness: 400,
mass: 1
}, className: (0, utils_1.cn)(toastVariants({ variant }), "relative z-50 mb-2 overflow-hidden", className), ...props, children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [children, (0, jsx_runtime_1.jsx)("div", { className: "absolute bottom-0 left-0 right-0 h-1 bg-black/5 dark:bg-white/5", children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: { width: "0%" }, animate: { width: "100%" }, transition: { duration: duration / 1000, ease: "linear" }, className: (0, utils_1.cn)("h-full", variant === "destructive" ? "bg-red-600" :
variant === "success" ? "bg-green-600" :
variant === "warning" ? "bg-yellow-600" :
variant === "info" ? "bg-primarylw" :
"bg-gray-600") }) })] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
onOpenChange?.(false);
onClose?.();
}, className: "absolute right-2 top-2 rounded-md p-1 text-foreground/70 opacity-70 transition-opacity hover:text-foreground hover:opacity-100", children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })] }));
});
exports.Toast = Toast;
Toast.displayName = "Toast";
const ToastClose = React.forwardRef(({ className, ...props }, ref) => ((0, jsx_runtime_1.jsx)("button", { ref: ref, className: (0, utils_1.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/70 opacity-70 transition-opacity hover:text-foreground hover:opacity-100", className), "aria-label": "Close toast", ...props, children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { className: "h-4 w-4" }) })));
exports.ToastClose = ToastClose;
ToastClose.displayName = "ToastClose";
const ToastTitle = React.forwardRef(({ className, ...props }, ref) => ((0, jsx_runtime_1.jsx)("h2", { ref: ref, className: (0, utils_1.cn)("text-sm font-semibold", className), ...props })));
exports.ToastTitle = ToastTitle;
ToastTitle.displayName = "ToastTitle";
const ToastDescription = React.forwardRef(({ className, ...props }, ref) => ((0, jsx_runtime_1.jsx)("p", { ref: ref, className: (0, utils_1.cn)("text-sm opacity-90", className), ...props })));
exports.ToastDescription = ToastDescription;
ToastDescription.displayName = "ToastDescription";
const ToastAction = React.forwardRef(({ className, ...props }, ref) => ((0, jsx_runtime_1.jsx)("button", { ref: ref, className: (0, utils_1.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-muted focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50", className), ...props })));
exports.ToastAction = ToastAction;
ToastAction.displayName = "ToastAction";
//# sourceMappingURL=toast.js.map