@zentauri-ui/zentauri-components 0.0.84 → 0.0.92
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 +47 -29
- package/dist/chunk-BZSIXBA7.js +70 -0
- package/dist/chunk-BZSIXBA7.js.map +1 -0
- package/dist/chunk-E5UX537J.js +11 -0
- package/dist/chunk-E5UX537J.js.map +1 -0
- package/dist/chunk-MEWYFWBX.mjs +14 -0
- package/dist/chunk-MEWYFWBX.mjs.map +1 -0
- package/dist/chunk-VJHD7QZH.mjs +73 -0
- package/dist/chunk-VJHD7QZH.mjs.map +1 -0
- package/dist/ui/accordion.d.mts +70 -0
- package/dist/ui/accordion.d.ts +70 -0
- package/dist/ui/accordion.js +280 -0
- package/dist/ui/accordion.js.map +1 -0
- package/dist/ui/accordion.mjs +282 -0
- package/dist/ui/accordion.mjs.map +1 -0
- package/dist/ui/alert.d.mts +66 -0
- package/dist/ui/alert.d.ts +66 -0
- package/dist/ui/alert.js +218 -0
- package/dist/ui/alert.js.map +1 -0
- package/dist/ui/alert.mjs +220 -0
- package/dist/ui/alert.mjs.map +1 -0
- package/dist/ui/badge.d.mts +37 -0
- package/dist/ui/badge.d.ts +37 -0
- package/dist/ui/badge.js +159 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/badge.mjs +161 -0
- package/dist/ui/badge.mjs.map +1 -0
- package/dist/ui/buttons.d.mts +27 -0
- package/dist/ui/buttons.d.ts +27 -0
- package/dist/ui/buttons.js +107 -0
- package/dist/ui/buttons.js.map +1 -0
- package/dist/ui/buttons.mjs +109 -0
- package/dist/ui/buttons.mjs.map +1 -0
- package/dist/ui/card.d.mts +77 -0
- package/dist/ui/card.d.ts +77 -0
- package/dist/ui/card.js +252 -0
- package/dist/ui/card.js.map +1 -0
- package/dist/ui/card.mjs +254 -0
- package/dist/ui/card.mjs.map +1 -0
- package/dist/ui/divider.d.mts +39 -0
- package/dist/ui/divider.d.ts +39 -0
- package/dist/ui/divider.js +194 -0
- package/dist/ui/divider.js.map +1 -0
- package/dist/ui/divider.mjs +196 -0
- package/dist/ui/divider.mjs.map +1 -0
- package/dist/ui/drawer.d.mts +81 -0
- package/dist/ui/drawer.d.ts +81 -0
- package/dist/ui/drawer.js +377 -0
- package/dist/ui/drawer.js.map +1 -0
- package/dist/ui/drawer.mjs +379 -0
- package/dist/ui/drawer.mjs.map +1 -0
- package/dist/ui/dropdown.d.mts +50 -0
- package/dist/ui/dropdown.d.ts +50 -0
- package/dist/ui/dropdown.js +272 -0
- package/dist/ui/dropdown.js.map +1 -0
- package/dist/ui/dropdown.mjs +274 -0
- package/dist/ui/dropdown.mjs.map +1 -0
- package/dist/ui/empty-state.d.mts +55 -0
- package/dist/ui/empty-state.d.ts +55 -0
- package/dist/ui/empty-state.js +148 -0
- package/dist/ui/empty-state.js.map +1 -0
- package/dist/ui/empty-state.mjs +150 -0
- package/dist/ui/empty-state.mjs.map +1 -0
- package/dist/ui/inputs.d.mts +35 -0
- package/dist/ui/inputs.d.ts +35 -0
- package/dist/ui/inputs.js +426 -0
- package/dist/ui/inputs.js.map +1 -0
- package/dist/ui/inputs.mjs +428 -0
- package/dist/ui/inputs.mjs.map +1 -0
- package/dist/ui/modal.d.mts +84 -0
- package/dist/ui/modal.d.ts +84 -0
- package/dist/ui/modal.js +378 -0
- package/dist/ui/modal.js.map +1 -0
- package/dist/ui/modal.mjs +380 -0
- package/dist/ui/modal.mjs.map +1 -0
- package/dist/ui/pagination.d.mts +114 -0
- package/dist/ui/pagination.d.ts +114 -0
- package/dist/ui/pagination.js +425 -0
- package/dist/ui/pagination.js.map +1 -0
- package/dist/ui/pagination.mjs +427 -0
- package/dist/ui/pagination.mjs.map +1 -0
- package/dist/ui/progress.d.mts +61 -0
- package/dist/ui/progress.d.ts +61 -0
- package/dist/ui/progress.js +231 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/progress.mjs +233 -0
- package/dist/ui/progress.mjs.map +1 -0
- package/dist/ui/select.d.mts +73 -0
- package/dist/ui/select.d.ts +73 -0
- package/dist/ui/select.js +321 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/select.mjs +323 -0
- package/dist/ui/select.mjs.map +1 -0
- package/dist/ui/skeleton.d.mts +90 -0
- package/dist/ui/skeleton.d.ts +90 -0
- package/dist/ui/skeleton.js +538 -0
- package/dist/ui/skeleton.js.map +1 -0
- package/dist/ui/skeleton.mjs +540 -0
- package/dist/ui/skeleton.mjs.map +1 -0
- package/dist/ui/spinner.d.mts +27 -0
- package/dist/ui/spinner.d.ts +27 -0
- package/dist/ui/spinner.js +187 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/spinner.mjs +189 -0
- package/dist/ui/spinner.mjs.map +1 -0
- package/dist/ui/table.d.mts +81 -0
- package/dist/ui/table.d.ts +81 -0
- package/dist/ui/table.js +287 -0
- package/dist/ui/table.js.map +1 -0
- package/dist/ui/table.mjs +289 -0
- package/dist/ui/table.mjs.map +1 -0
- package/dist/ui/tabs.d.mts +58 -0
- package/dist/ui/tabs.d.ts +58 -0
- package/dist/ui/tabs.js +268 -0
- package/dist/ui/tabs.js.map +1 -0
- package/dist/ui/tabs.mjs +270 -0
- package/dist/ui/tabs.mjs.map +1 -0
- package/dist/ui/toast.d.mts +86 -0
- package/dist/ui/toast.d.ts +86 -0
- package/dist/ui/toast.js +252 -0
- package/dist/ui/toast.js.map +1 -0
- package/dist/ui/toast.mjs +254 -0
- package/dist/ui/toast.mjs.map +1 -0
- package/dist/ui/toggle.d.mts +37 -0
- package/dist/ui/toggle.d.ts +37 -0
- package/dist/ui/toggle.js +152 -0
- package/dist/ui/toggle.js.map +1 -0
- package/dist/ui/toggle.mjs +154 -0
- package/dist/ui/toggle.mjs.map +1 -0
- package/dist/ui/tooltip.d.mts +46 -0
- package/dist/ui/tooltip.d.ts +46 -0
- package/dist/ui/tooltip.js +208 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/dist/ui/tooltip.mjs +210 -0
- package/dist/ui/tooltip.mjs.map +1 -0
- package/dist/variants-Dd9pe-ov.d.mts +8 -0
- package/dist/variants-Dd9pe-ov.d.ts +8 -0
- package/package.json +15 -14
- package/dist/ui/index.cjs +0 -5764
- package/dist/ui/index.cjs.map +0 -1
- package/dist/ui/index.d.cts +0 -1164
- package/dist/ui/index.d.ts +0 -1164
- package/dist/ui/index.js +0 -5626
- package/dist/ui/index.js.map +0 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
cn
|
|
5
|
+
} from "../chunk-MEWYFWBX.mjs";
|
|
6
|
+
|
|
7
|
+
// src/ui/toast/toast.tsx
|
|
8
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
9
|
+
import {
|
|
10
|
+
createContext,
|
|
11
|
+
useCallback,
|
|
12
|
+
useContext,
|
|
13
|
+
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useRef,
|
|
16
|
+
useState
|
|
17
|
+
} from "react";
|
|
18
|
+
import { createPortal } from "react-dom";
|
|
19
|
+
|
|
20
|
+
// src/ui/toast/animations.ts
|
|
21
|
+
var toastAnimationPresets = {
|
|
22
|
+
none: {},
|
|
23
|
+
slide: {
|
|
24
|
+
initial: { opacity: 0, x: 24 },
|
|
25
|
+
animate: { opacity: 1, x: 0 },
|
|
26
|
+
exit: { opacity: 0, x: 16 },
|
|
27
|
+
transition: { type: "spring", stiffness: 380, damping: 28 }
|
|
28
|
+
},
|
|
29
|
+
fade: {
|
|
30
|
+
initial: { opacity: 0 },
|
|
31
|
+
animate: { opacity: 1 },
|
|
32
|
+
exit: { opacity: 0 },
|
|
33
|
+
transition: { duration: 0.18 }
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/ui/toast/variants.ts
|
|
38
|
+
import { cva } from "class-variance-authority";
|
|
39
|
+
var toastViewportVariants = cva("fixed z-[60] flex max-h-screen flex-col gap-2 p-4", {
|
|
40
|
+
variants: {
|
|
41
|
+
position: {
|
|
42
|
+
"top-left": "left-0 top-0 items-start",
|
|
43
|
+
"top-center": "left-1/2 top-0 -translate-x-1/2 items-center",
|
|
44
|
+
"top-right": "right-0 top-0 items-end",
|
|
45
|
+
"bottom-left": "bottom-0 left-0 items-start",
|
|
46
|
+
"bottom-center": "bottom-0 left-1/2 -translate-x-1/2 items-center",
|
|
47
|
+
"bottom-right": "bottom-0 right-0 items-end"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
position: "bottom-right"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
var toastRootVariants = cva(
|
|
55
|
+
"pointer-events-auto w-[min(100vw-2rem,380px)] rounded-xl border border-white/10 bg-slate-950 p-4 text-slate-50 shadow-[0_18px_48px_rgba(15,23,42,0.45)]",
|
|
56
|
+
{
|
|
57
|
+
variants: {
|
|
58
|
+
appearance: {
|
|
59
|
+
default: "bg-slate-950",
|
|
60
|
+
success: "border-emerald-500/40 bg-emerald-950",
|
|
61
|
+
warning: "border-amber-500/40 bg-amber-950",
|
|
62
|
+
error: "border-rose-500/50 bg-rose-950",
|
|
63
|
+
info: "border-sky-500/40 bg-sky-950",
|
|
64
|
+
ghost: "border-transparent bg-transparent text-slate-200",
|
|
65
|
+
purple: "border-purple-600 bg-purple-950/70 backdrop-blur-xl",
|
|
66
|
+
pink: "border-pink-600 bg-pink-950/70 backdrop-blur-xl",
|
|
67
|
+
orange: "border-orange-600 bg-orange-950/70 backdrop-blur-xl",
|
|
68
|
+
yellow: "border-yellow-600 bg-yellow-950/70 backdrop-blur-xl",
|
|
69
|
+
teal: "border-teal-600 bg-teal-950/70 backdrop-blur-xl",
|
|
70
|
+
indigo: "border-indigo-600 bg-indigo-950/70 backdrop-blur-xl",
|
|
71
|
+
emerald: "border-emerald-600 bg-emerald-950/70 backdrop-blur-xl",
|
|
72
|
+
gray: "border-gray-600 bg-gray-950/70 backdrop-blur-xl",
|
|
73
|
+
amber: "border-amber-600 bg-amber-950/70 backdrop-blur-xl",
|
|
74
|
+
violet: "border-violet-600 bg-violet-950/70 backdrop-blur-xl",
|
|
75
|
+
"gradient-blue": "border-gradient-to-r from-blue-600 to-purple-600 bg-gradient-to-r from-blue-950/70 to-purple-950/70 backdrop-blur-xl",
|
|
76
|
+
"gradient-green": "border-gradient-to-r from-green-600 to-lime-600 bg-gradient-to-r from-green-950/70 to-lime-950/70 backdrop-blur-xl",
|
|
77
|
+
"gradient-red": "border-gradient-to-r from-red-600 to-pink-600 bg-gradient-to-r from-red-950/70 to-pink-950/70 backdrop-blur-xl",
|
|
78
|
+
"gradient-yellow": "border-gradient-to-r from-yellow-600 to-orange-600 bg-gradient-to-r from-yellow-950/70 to-orange-950/70 backdrop-blur-xl",
|
|
79
|
+
"gradient-purple": "border-gradient-to-r from-purple-600 to-pink-600 bg-gradient-to-r from-purple-950/70 to-pink-950/70 backdrop-blur-xl",
|
|
80
|
+
"gradient-teal": "border-gradient-to-r from-teal-600 to-cyan-600 bg-gradient-to-r from-teal-950/70 to-cyan-950/70 backdrop-blur-xl",
|
|
81
|
+
"gradient-indigo": "border-gradient-to-r from-indigo-600 to-purple-600 bg-gradient-to-r from-indigo-950/70 to-purple-950/70 backdrop-blur-xl",
|
|
82
|
+
"gradient-pink": "border-gradient-to-r from-pink-600 to-rose-600 bg-gradient-to-r from-pink-950/70 to-rose-950/70 backdrop-blur-xl",
|
|
83
|
+
"gradient-orange": "border-gradient-to-r from-orange-600 to-red-600 bg-gradient-to-r from-orange-950/70 to-red-950/70 backdrop-blur-xl"
|
|
84
|
+
},
|
|
85
|
+
size: {
|
|
86
|
+
sm: "p-3 text-xs",
|
|
87
|
+
md: "p-4 text-sm",
|
|
88
|
+
lg: "p-5 text-base"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
defaultVariants: {
|
|
92
|
+
appearance: "default",
|
|
93
|
+
size: "md"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// src/ui/toast/toast.tsx
|
|
99
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
100
|
+
var ToastStoreContext = createContext(null);
|
|
101
|
+
var toastDispatcher = null;
|
|
102
|
+
function toast(input) {
|
|
103
|
+
if (!toastDispatcher) {
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
106
|
+
return toastDispatcher(input);
|
|
107
|
+
}
|
|
108
|
+
function useToast() {
|
|
109
|
+
const ctx = useContext(ToastStoreContext);
|
|
110
|
+
if (!ctx) {
|
|
111
|
+
throw new Error("useToast must be used within <ToastProvider>");
|
|
112
|
+
}
|
|
113
|
+
return { toast: ctx.push, dismiss: ctx.dismiss };
|
|
114
|
+
}
|
|
115
|
+
function ToastProvider({ children }) {
|
|
116
|
+
const [toasts, setToasts] = useState([]);
|
|
117
|
+
const timers = useRef(/* @__PURE__ */ new Map());
|
|
118
|
+
const dismiss = useCallback((id) => {
|
|
119
|
+
const timerId = timers.current.get(id);
|
|
120
|
+
if (timerId) {
|
|
121
|
+
window.clearTimeout(timerId);
|
|
122
|
+
timers.current.delete(id);
|
|
123
|
+
}
|
|
124
|
+
setToasts((prev) => prev.filter((toastItem) => toastItem.id !== id));
|
|
125
|
+
}, []);
|
|
126
|
+
const push = useCallback(
|
|
127
|
+
(input) => {
|
|
128
|
+
const id = input.id ?? `toast-${Math.random().toString(16).slice(2)}`;
|
|
129
|
+
const durationMs = input.durationMs ?? 4500;
|
|
130
|
+
const record = {
|
|
131
|
+
...input,
|
|
132
|
+
id,
|
|
133
|
+
durationMs,
|
|
134
|
+
animation: input.animation ?? "slide"
|
|
135
|
+
};
|
|
136
|
+
setToasts((prev) => [...prev, record]);
|
|
137
|
+
const timerId = window.setTimeout(() => dismiss(id), durationMs);
|
|
138
|
+
timers.current.set(id, timerId);
|
|
139
|
+
return id;
|
|
140
|
+
},
|
|
141
|
+
[dismiss]
|
|
142
|
+
);
|
|
143
|
+
const ctx = useMemo(
|
|
144
|
+
() => ({
|
|
145
|
+
toasts,
|
|
146
|
+
push,
|
|
147
|
+
dismiss
|
|
148
|
+
}),
|
|
149
|
+
[dismiss, push, toasts]
|
|
150
|
+
);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
toastDispatcher = push;
|
|
153
|
+
return () => {
|
|
154
|
+
toastDispatcher = null;
|
|
155
|
+
};
|
|
156
|
+
}, [push]);
|
|
157
|
+
return /* @__PURE__ */ jsx(ToastStoreContext.Provider, { value: ctx, children });
|
|
158
|
+
}
|
|
159
|
+
ToastProvider.displayName = "ToastProvider";
|
|
160
|
+
function ToastViewport({ position = "bottom-right", className }) {
|
|
161
|
+
const ctx = useContext(ToastStoreContext);
|
|
162
|
+
if (!ctx) {
|
|
163
|
+
throw new Error("ToastViewport must be used within <ToastProvider>");
|
|
164
|
+
}
|
|
165
|
+
const portalTarget = typeof document !== "undefined" ? document.body : null;
|
|
166
|
+
if (!portalTarget) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return createPortal(
|
|
170
|
+
/* @__PURE__ */ jsx("div", { className: cn(toastViewportVariants({ position }), className), "data-slot": "toast-viewport", children: /* @__PURE__ */ jsx(AnimatePresence, { children: ctx.toasts.map((item) => /* @__PURE__ */ jsxs(
|
|
171
|
+
Toast,
|
|
172
|
+
{
|
|
173
|
+
toastId: item.id,
|
|
174
|
+
appearance: item.appearance,
|
|
175
|
+
size: item.size,
|
|
176
|
+
animation: item.animation,
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ jsx(ToastTitle, { children: item.title }),
|
|
179
|
+
item.description ? /* @__PURE__ */ jsx(ToastDescription, { children: item.description }) : null,
|
|
180
|
+
/* @__PURE__ */ jsx(ToastClose, { onClick: () => ctx.dismiss(item.id) })
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
item.id
|
|
184
|
+
)) }) }),
|
|
185
|
+
portalTarget
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
ToastViewport.displayName = "ToastViewport";
|
|
189
|
+
function Toast({ toastId: _toastId, appearance, size, animation = "slide", className, children }) {
|
|
190
|
+
const motionProps = toastAnimationPresets[animation];
|
|
191
|
+
const live = appearance === "error" ? "assertive" : "polite";
|
|
192
|
+
return /* @__PURE__ */ jsx(
|
|
193
|
+
motion.div,
|
|
194
|
+
{
|
|
195
|
+
layout: true,
|
|
196
|
+
"data-slot": "toast",
|
|
197
|
+
role: appearance === "error" ? "alert" : "status",
|
|
198
|
+
"aria-live": live,
|
|
199
|
+
"aria-atomic": "true",
|
|
200
|
+
className: cn("relative", toastRootVariants({ appearance, size }), className),
|
|
201
|
+
initial: animation === "none" ? false : motionProps.initial,
|
|
202
|
+
animate: animation === "none" ? void 0 : motionProps.animate,
|
|
203
|
+
exit: animation === "none" ? void 0 : motionProps.exit,
|
|
204
|
+
transition: motionProps.transition,
|
|
205
|
+
children
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
Toast.displayName = "Toast";
|
|
210
|
+
function ToastTitle({ className, children }) {
|
|
211
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "toast-title", className: cn("font-semibold", className), children });
|
|
212
|
+
}
|
|
213
|
+
ToastTitle.displayName = "ToastTitle";
|
|
214
|
+
function ToastDescription({ className, children }) {
|
|
215
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "toast-description", className: cn("text-sm text-slate-300", className), children });
|
|
216
|
+
}
|
|
217
|
+
ToastDescription.displayName = "ToastDescription";
|
|
218
|
+
function ToastAction({ className, children }) {
|
|
219
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "toast-action", className: cn("mt-3", className), children });
|
|
220
|
+
}
|
|
221
|
+
ToastAction.displayName = "ToastAction";
|
|
222
|
+
function ToastClose({ className, children, onClick, ...rest }) {
|
|
223
|
+
return /* @__PURE__ */ jsx(
|
|
224
|
+
"button",
|
|
225
|
+
{
|
|
226
|
+
type: "button",
|
|
227
|
+
"data-slot": "toast-close",
|
|
228
|
+
"aria-label": "Dismiss notification",
|
|
229
|
+
className: cn(
|
|
230
|
+
"absolute right-3 top-3 inline-flex size-8 items-center justify-center rounded-md text-slate-200 transition hover:bg-white/10",
|
|
231
|
+
className
|
|
232
|
+
),
|
|
233
|
+
onClick,
|
|
234
|
+
...rest,
|
|
235
|
+
children: children ?? "\xD7"
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
ToastClose.displayName = "ToastClose";
|
|
240
|
+
export {
|
|
241
|
+
Toast,
|
|
242
|
+
ToastAction,
|
|
243
|
+
ToastClose,
|
|
244
|
+
ToastDescription,
|
|
245
|
+
ToastProvider,
|
|
246
|
+
ToastTitle,
|
|
247
|
+
ToastViewport,
|
|
248
|
+
toast,
|
|
249
|
+
toastAnimationPresets,
|
|
250
|
+
toastRootVariants,
|
|
251
|
+
toastViewportVariants,
|
|
252
|
+
useToast
|
|
253
|
+
};
|
|
254
|
+
//# sourceMappingURL=toast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/toast/toast.tsx","../../src/ui/toast/animations.ts","../../src/ui/toast/variants.ts"],"sourcesContent":["\"use client\";\n\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"../../lib/utils\";\n\nimport { toastAnimationPresets } from \"./animations\";\nimport type {\n ToastContextValue,\n ToastInput,\n ToastProps,\n ToastProviderProps,\n ToastSectionProps,\n ToastViewportProps,\n} from \"./types\";\nimport { toastRootVariants, toastViewportVariants } from \"./variants\";\n\ntype InternalToast = Required<Pick<ToastInput, \"id\">> &\n Omit<ToastInput, \"id\"> & {\n durationMs: number;\n animation: NonNullable<ToastInput[\"animation\"]>;\n };\n\ntype ToastStoreContextValue = {\n toasts: InternalToast[];\n push: (input: ToastInput) => string;\n dismiss: (id: string) => void;\n};\n\nconst ToastStoreContext = createContext<ToastStoreContextValue | null>(null);\n\nlet toastDispatcher: ToastStoreContextValue[\"push\"] | null = null;\n\nexport function toast(input: ToastInput) {\n if (!toastDispatcher) {\n return \"\";\n }\n return toastDispatcher(input);\n}\n\nexport function useToast(): ToastContextValue {\n const ctx = useContext(ToastStoreContext);\n if (!ctx) {\n throw new Error(\"useToast must be used within <ToastProvider>\");\n }\n return { toast: ctx.push, dismiss: ctx.dismiss };\n}\n\nexport function ToastProvider({ children }: ToastProviderProps) {\n const [toasts, setToasts] = useState<InternalToast[]>([]);\n const timers = useRef<Map<string, number>>(new Map());\n\n const dismiss = useCallback((id: string) => {\n const timerId = timers.current.get(id);\n if (timerId) {\n window.clearTimeout(timerId);\n timers.current.delete(id);\n }\n setToasts((prev) => prev.filter((toastItem) => toastItem.id !== id));\n }, []);\n\n const push = useCallback(\n (input: ToastInput) => {\n const id = input.id ?? `toast-${Math.random().toString(16).slice(2)}`;\n const durationMs = input.durationMs ?? 4500;\n const record: InternalToast = {\n ...input,\n id,\n durationMs,\n animation: input.animation ?? \"slide\",\n };\n setToasts((prev) => [...prev, record]);\n const timerId = window.setTimeout(() => dismiss(id), durationMs);\n timers.current.set(id, timerId);\n return id;\n },\n [dismiss],\n );\n\n const ctx = useMemo(\n () => ({\n toasts,\n push,\n dismiss,\n }),\n [dismiss, push, toasts],\n );\n\n useEffect(() => {\n toastDispatcher = push;\n return () => {\n toastDispatcher = null;\n };\n }, [push]);\n\n return <ToastStoreContext.Provider value={ctx}>{children}</ToastStoreContext.Provider>;\n}\n\nToastProvider.displayName = \"ToastProvider\";\n\nexport function ToastViewport({ position = \"bottom-right\", className }: ToastViewportProps) {\n const ctx = useContext(ToastStoreContext);\n if (!ctx) {\n throw new Error(\"ToastViewport must be used within <ToastProvider>\");\n }\n\n const portalTarget = typeof document !== \"undefined\" ? document.body : null;\n if (!portalTarget) {\n return null;\n }\n\n return createPortal(\n <div className={cn(toastViewportVariants({ position }), className)} data-slot=\"toast-viewport\">\n <AnimatePresence>\n {ctx.toasts.map((item) => (\n <Toast\n key={item.id}\n toastId={item.id}\n appearance={item.appearance}\n size={item.size}\n animation={item.animation}\n >\n <ToastTitle>{item.title}</ToastTitle>\n {item.description ? <ToastDescription>{item.description}</ToastDescription> : null}\n <ToastClose onClick={() => ctx.dismiss(item.id)} />\n </Toast>\n ))}\n </AnimatePresence>\n </div>,\n portalTarget,\n );\n}\n\nToastViewport.displayName = \"ToastViewport\";\n\nexport function Toast({ toastId: _toastId, appearance, size, animation = \"slide\", className, children }: ToastProps) {\n const motionProps = toastAnimationPresets[animation];\n const live = appearance === \"error\" ? \"assertive\" : \"polite\";\n\n return (\n <motion.div\n layout\n data-slot=\"toast\"\n role={appearance === \"error\" ? \"alert\" : \"status\"}\n aria-live={live}\n aria-atomic=\"true\"\n className={cn(\"relative\", toastRootVariants({ appearance, size }), className)}\n initial={animation === \"none\" ? false : motionProps.initial}\n animate={animation === \"none\" ? undefined : motionProps.animate}\n exit={animation === \"none\" ? undefined : motionProps.exit}\n transition={motionProps.transition}\n >\n {children}\n </motion.div>\n );\n}\n\nToast.displayName = \"Toast\";\n\nexport function ToastTitle({ className, children }: ToastSectionProps) {\n return <div data-slot=\"toast-title\" className={cn(\"font-semibold\", className)}>{children}</div>;\n}\n\nToastTitle.displayName = \"ToastTitle\";\n\nexport function ToastDescription({ className, children }: ToastSectionProps) {\n return (\n <div data-slot=\"toast-description\" className={cn(\"text-sm text-slate-300\", className)}>\n {children}\n </div>\n );\n}\n\nToastDescription.displayName = \"ToastDescription\";\n\nexport function ToastAction({ className, children }: ToastSectionProps) {\n return <div data-slot=\"toast-action\" className={cn(\"mt-3\", className)}>{children}</div>;\n}\n\nToastAction.displayName = \"ToastAction\";\n\nexport function ToastClose({ className, children, onClick, ...rest }: ToastSectionProps & { onClick?: () => void }) {\n return (\n <button\n type=\"button\"\n data-slot=\"toast-close\"\n aria-label=\"Dismiss notification\"\n className={cn(\n \"absolute right-3 top-3 inline-flex size-8 items-center justify-center rounded-md text-slate-200 transition hover:bg-white/10\",\n className,\n )}\n onClick={onClick}\n {...rest}\n >\n {children ?? \"×\"}\n </button>\n );\n}\n\nToastClose.displayName = \"ToastClose\";\n","import type { HTMLMotionProps } from \"framer-motion\";\n\nexport type ToastAnimation = \"none\" | \"slide\" | \"fade\";\n\ntype ToastPresetMotionProps = Pick<\n HTMLMotionProps<\"div\">,\n \"initial\" | \"animate\" | \"exit\" | \"transition\"\n>;\n\nexport type ToastAnimationPresets = Record<ToastAnimation, ToastPresetMotionProps>;\n\nexport const toastAnimationPresets: ToastAnimationPresets = {\n none: {},\n slide: {\n initial: { opacity: 0, x: 24 },\n animate: { opacity: 1, x: 0 },\n exit: { opacity: 0, x: 16 },\n transition: { type: \"spring\", stiffness: 380, damping: 28 },\n },\n fade: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n transition: { duration: 0.18 },\n },\n};\n","import { cva } from \"class-variance-authority\";\n\nexport const toastViewportVariants = cva(\"fixed z-[60] flex max-h-screen flex-col gap-2 p-4\", {\n variants: {\n position: {\n \"top-left\": \"left-0 top-0 items-start\",\n \"top-center\": \"left-1/2 top-0 -translate-x-1/2 items-center\",\n \"top-right\": \"right-0 top-0 items-end\",\n \"bottom-left\": \"bottom-0 left-0 items-start\",\n \"bottom-center\": \"bottom-0 left-1/2 -translate-x-1/2 items-center\",\n \"bottom-right\": \"bottom-0 right-0 items-end\",\n },\n },\n defaultVariants: {\n position: \"bottom-right\",\n },\n});\n\nexport const toastRootVariants = cva(\n \"pointer-events-auto w-[min(100vw-2rem,380px)] rounded-xl border border-white/10 bg-slate-950 p-4 text-slate-50 shadow-[0_18px_48px_rgba(15,23,42,0.45)]\",\n {\n variants: {\n appearance: {\n default: \"bg-slate-950\",\n success: \"border-emerald-500/40 bg-emerald-950\",\n warning: \"border-amber-500/40 bg-amber-950\",\n error: \"border-rose-500/50 bg-rose-950\",\n info: \"border-sky-500/40 bg-sky-950\",\n ghost: \"border-transparent bg-transparent text-slate-200\",\n purple: \"border-purple-600 bg-purple-950/70 backdrop-blur-xl\",\n pink: \"border-pink-600 bg-pink-950/70 backdrop-blur-xl\",\n orange: \"border-orange-600 bg-orange-950/70 backdrop-blur-xl\",\n yellow: \"border-yellow-600 bg-yellow-950/70 backdrop-blur-xl\",\n teal: \"border-teal-600 bg-teal-950/70 backdrop-blur-xl\",\n indigo: \"border-indigo-600 bg-indigo-950/70 backdrop-blur-xl\",\n emerald: \"border-emerald-600 bg-emerald-950/70 backdrop-blur-xl\",\n gray: \"border-gray-600 bg-gray-950/70 backdrop-blur-xl\",\n amber: \"border-amber-600 bg-amber-950/70 backdrop-blur-xl\",\n violet: \"border-violet-600 bg-violet-950/70 backdrop-blur-xl\",\n \"gradient-blue\": \"border-gradient-to-r from-blue-600 to-purple-600 bg-gradient-to-r from-blue-950/70 to-purple-950/70 backdrop-blur-xl\",\n \"gradient-green\": \"border-gradient-to-r from-green-600 to-lime-600 bg-gradient-to-r from-green-950/70 to-lime-950/70 backdrop-blur-xl\",\n \"gradient-red\": \"border-gradient-to-r from-red-600 to-pink-600 bg-gradient-to-r from-red-950/70 to-pink-950/70 backdrop-blur-xl\",\n \"gradient-yellow\": \"border-gradient-to-r from-yellow-600 to-orange-600 bg-gradient-to-r from-yellow-950/70 to-orange-950/70 backdrop-blur-xl\",\n \"gradient-purple\": \"border-gradient-to-r from-purple-600 to-pink-600 bg-gradient-to-r from-purple-950/70 to-pink-950/70 backdrop-blur-xl\",\n \"gradient-teal\": \"border-gradient-to-r from-teal-600 to-cyan-600 bg-gradient-to-r from-teal-950/70 to-cyan-950/70 backdrop-blur-xl\",\n \"gradient-indigo\": \"border-gradient-to-r from-indigo-600 to-purple-600 bg-gradient-to-r from-indigo-950/70 to-purple-950/70 backdrop-blur-xl\",\n \"gradient-pink\": \"border-gradient-to-r from-pink-600 to-rose-600 bg-gradient-to-r from-pink-950/70 to-rose-950/70 backdrop-blur-xl\",\n \"gradient-orange\": \"border-gradient-to-r from-orange-600 to-red-600 bg-gradient-to-r from-orange-950/70 to-red-950/70 backdrop-blur-xl\",\n },\n size: {\n sm: \"p-3 text-xs\",\n md: \"p-4 text-sm\",\n lg: \"p-5 text-base\",\n },\n },\n defaultVariants: {\n appearance: \"default\",\n size: \"md\",\n },\n },\n);\n"],"mappings":";;;;;;;AAEA,SAAS,iBAAiB,cAAc;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;;;ACDtB,IAAM,wBAA+C;AAAA,EAC1D,MAAM,CAAC;AAAA,EACP,OAAO;AAAA,IACL,SAAS,EAAE,SAAS,GAAG,GAAG,GAAG;AAAA,IAC7B,SAAS,EAAE,SAAS,GAAG,GAAG,EAAE;AAAA,IAC5B,MAAM,EAAE,SAAS,GAAG,GAAG,GAAG;AAAA,IAC1B,YAAY,EAAE,MAAM,UAAU,WAAW,KAAK,SAAS,GAAG;AAAA,EAC5D;AAAA,EACA,MAAM;AAAA,IACJ,SAAS,EAAE,SAAS,EAAE;AAAA,IACtB,SAAS,EAAE,SAAS,EAAE;AAAA,IACtB,MAAM,EAAE,SAAS,EAAE;AAAA,IACnB,YAAY,EAAE,UAAU,KAAK;AAAA,EAC/B;AACF;;;ACzBA,SAAS,WAAW;AAEb,IAAM,wBAAwB,IAAI,qDAAqD;AAAA,EAC5F,UAAU;AAAA,IACR,UAAU;AAAA,MACR,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,aAAa;AAAA,MACb,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,EACZ;AACF,CAAC;AAEM,IAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,YAAY;AAAA,QACV,SAAS;AAAA,QACT,SAAS;AAAA,QACT,SAAS;AAAA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AAS,GAAsB;AAC3E,SACE,oBAAC,SAAI,aAAU,qBAAoB,WAAW,GAAG,0BAA0B,SAAS,GACjF,UACH;AAEJ;AAEA,iBAAiB,cAAc;AAExB,SAAS,YAAY,EAAE,WAAW,SAAS,GAAsB;AACtE,SAAO,oBAAC,SAAI,aAAU,gBAAe,WAAW,GAAG,QAAQ,SAAS,GAAI,UAAS;AACnF;AAEA,YAAY,cAAc;AAEnB,SAAS,WAAW,EAAE,WAAW,UAAU,SAAS,GAAG,KAAK,GAAiD;AAClH,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,aAAU;AAAA,MACV,cAAW;AAAA,MACX,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAEH,sBAAY;AAAA;AAAA,EACf;AAEJ;AAEA,WAAW,cAAc;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
4
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
|
|
7
|
+
type ToggleAnimation = "none" | "spring";
|
|
8
|
+
type ToggleThumbPreset = Pick<HTMLMotionProps<"span">, "transition" | "layout">;
|
|
9
|
+
type ToggleAnimationPresets = Record<ToggleAnimation, ToggleThumbPreset>;
|
|
10
|
+
declare const toggleThumbAnimationPresets: ToggleAnimationPresets;
|
|
11
|
+
|
|
12
|
+
declare const toggleTrackVariants: (props?: ({
|
|
13
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
14
|
+
appearance?: "default" | "success" | "destructive" | "neutral" | "indigo" | "purple" | "pink" | "orange" | "yellow" | "green" | "teal" | "cyan" | "lime" | "emerald" | "rose" | "slate" | "zinc" | "gray" | "stone" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
15
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
|
+
declare const toggleThumbVariants: (props?: ({
|
|
17
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
18
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
19
|
+
|
|
20
|
+
type ToggleTrackVariantProps = VariantProps<typeof toggleTrackVariants>;
|
|
21
|
+
type ToggleThumbVariantProps = VariantProps<typeof toggleThumbVariants>;
|
|
22
|
+
type ToggleProps = ToggleTrackVariantProps & ToggleThumbVariantProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "role" | "ref"> & {
|
|
23
|
+
animation?: ToggleAnimation;
|
|
24
|
+
checked?: boolean;
|
|
25
|
+
defaultChecked?: boolean;
|
|
26
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
27
|
+
"aria-label"?: string;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
ref?: Ref<HTMLButtonElement>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare function Toggle(props: ToggleProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
declare namespace Toggle {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Toggle, type ToggleAnimation, type ToggleProps, toggleThumbAnimationPresets, toggleThumbVariants, toggleTrackVariants };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
4
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
|
|
7
|
+
type ToggleAnimation = "none" | "spring";
|
|
8
|
+
type ToggleThumbPreset = Pick<HTMLMotionProps<"span">, "transition" | "layout">;
|
|
9
|
+
type ToggleAnimationPresets = Record<ToggleAnimation, ToggleThumbPreset>;
|
|
10
|
+
declare const toggleThumbAnimationPresets: ToggleAnimationPresets;
|
|
11
|
+
|
|
12
|
+
declare const toggleTrackVariants: (props?: ({
|
|
13
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
14
|
+
appearance?: "default" | "success" | "destructive" | "neutral" | "indigo" | "purple" | "pink" | "orange" | "yellow" | "green" | "teal" | "cyan" | "lime" | "emerald" | "rose" | "slate" | "zinc" | "gray" | "stone" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
15
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
|
+
declare const toggleThumbVariants: (props?: ({
|
|
17
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
18
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
19
|
+
|
|
20
|
+
type ToggleTrackVariantProps = VariantProps<typeof toggleTrackVariants>;
|
|
21
|
+
type ToggleThumbVariantProps = VariantProps<typeof toggleThumbVariants>;
|
|
22
|
+
type ToggleProps = ToggleTrackVariantProps & ToggleThumbVariantProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "role" | "ref"> & {
|
|
23
|
+
animation?: ToggleAnimation;
|
|
24
|
+
checked?: boolean;
|
|
25
|
+
defaultChecked?: boolean;
|
|
26
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
27
|
+
"aria-label"?: string;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
ref?: Ref<HTMLButtonElement>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare function Toggle(props: ToggleProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
declare namespace Toggle {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Toggle, type ToggleAnimation, type ToggleProps, toggleThumbAnimationPresets, toggleThumbVariants, toggleTrackVariants };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkE5UX537Jjs = require('../chunk-E5UX537J.js');
|
|
4
|
+
|
|
5
|
+
// src/ui/toggle/toggle.tsx
|
|
6
|
+
var _framermotion = require('framer-motion');
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
|
|
9
|
+
// src/ui/toggle/animations.ts
|
|
10
|
+
var toggleThumbAnimationPresets = {
|
|
11
|
+
none: {},
|
|
12
|
+
spring: {
|
|
13
|
+
layout: true,
|
|
14
|
+
transition: { type: "spring", stiffness: 520, damping: 32 }
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/ui/toggle/variants.ts
|
|
19
|
+
var _classvarianceauthority = require('class-variance-authority');
|
|
20
|
+
var toggleTrackVariants = _classvarianceauthority.cva.call(void 0,
|
|
21
|
+
"relative inline-flex shrink-0 cursor-pointer rounded-full border border-white/10 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-300 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950 data-[state=checked]:border-cyan-500/40 disabled:cursor-not-allowed disabled:opacity-50",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
size: {
|
|
25
|
+
sm: "h-5 w-9",
|
|
26
|
+
md: "h-6 w-11",
|
|
27
|
+
lg: "h-7 w-[3.25rem]"
|
|
28
|
+
},
|
|
29
|
+
appearance: {
|
|
30
|
+
default: "data-[state=checked]:bg-cyan-600/80",
|
|
31
|
+
success: "data-[state=checked]:border-emerald-500/40 data-[state=checked]:bg-emerald-600/80",
|
|
32
|
+
destructive: "data-[state=checked]:border-rose-500/40 data-[state=checked]:bg-rose-600/80",
|
|
33
|
+
neutral: "data-[state=checked]:border-slate-400/40 data-[state=checked]:bg-slate-600/90",
|
|
34
|
+
indigo: "data-[state=checked]:border-indigo-500/40 data-[state=checked]:bg-indigo-600/80",
|
|
35
|
+
purple: "data-[state=checked]:border-purple-500/40 data-[state=checked]:bg-purple-600/80",
|
|
36
|
+
pink: "data-[state=checked]:border-pink-500/40 data-[state=checked]:bg-pink-600/80",
|
|
37
|
+
orange: "data-[state=checked]:border-orange-500/40 data-[state=checked]:bg-orange-600/80",
|
|
38
|
+
yellow: "data-[state=checked]:border-yellow-500/40 data-[state=checked]:bg-yellow-600/80",
|
|
39
|
+
green: "data-[state=checked]:border-green-500/40 data-[state=checked]:bg-green-600/80",
|
|
40
|
+
teal: "data-[state=checked]:border-teal-500/40 data-[state=checked]:bg-teal-600/80",
|
|
41
|
+
cyan: "data-[state=checked]:border-cyan-500/40 data-[state=checked]:bg-cyan-600/80",
|
|
42
|
+
lime: "data-[state=checked]:border-lime-500/40 data-[state=checked]:bg-lime-600/80",
|
|
43
|
+
emerald: "data-[state=checked]:border-emerald-500/40 data-[state=checked]:bg-emerald-600/80",
|
|
44
|
+
rose: "data-[state=checked]:border-rose-500/40 data-[state=checked]:bg-rose-600/80",
|
|
45
|
+
slate: "data-[state=checked]:border-slate-400/40 data-[state=checked]:bg-slate-600/90",
|
|
46
|
+
zinc: "data-[state=checked]:border-zinc-400/40 data-[state=checked]:bg-zinc-600/90",
|
|
47
|
+
gray: "data-[state=checked]:border-gray-400/40 data-[state=checked]:bg-gray-600/90",
|
|
48
|
+
stone: "data-[state=checked]:border-stone-400/40 data-[state=checked]:bg-stone-600/90",
|
|
49
|
+
"gradient-blue": "data-[state=checked]:bg-linear-to-r from-blue-600 to-purple-600",
|
|
50
|
+
"gradient-green": "data-[state=checked]:bg-linear-to-r from-green-600 to-lime-600",
|
|
51
|
+
"gradient-red": "data-[state=checked]:bg-linear-to-r from-red-600 to-pink-600",
|
|
52
|
+
"gradient-yellow": "data-[state=checked]:bg-linear-to-r from-yellow-600 to-orange-600",
|
|
53
|
+
"gradient-purple": "data-[state=checked]:bg-linear-to-r from-purple-600 to-pink-600",
|
|
54
|
+
"gradient-teal": "data-[state=checked]:bg-linear-to-r from-teal-600 to-cyan-600",
|
|
55
|
+
"gradient-indigo": "data-[state=checked]:bg-linear-to-r from-indigo-600 to-purple-600",
|
|
56
|
+
"gradient-pink": "data-[state=checked]:bg-linear-to-r from-pink-600 to-rose-600",
|
|
57
|
+
"gradient-orange": "data-[state=checked]:bg-linear-to-r from-orange-600 to-red-600"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
size: "md",
|
|
62
|
+
appearance: "default"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
var toggleThumbVariants = _classvarianceauthority.cva.call(void 0,
|
|
67
|
+
"pointer-events-none block rounded-full bg-white shadow-[0_1px_2px_rgba(15,23,42,0.35)] ring-0",
|
|
68
|
+
{
|
|
69
|
+
variants: {
|
|
70
|
+
size: {
|
|
71
|
+
sm: "size-4",
|
|
72
|
+
md: "size-5",
|
|
73
|
+
lg: "size-6"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
defaultVariants: {
|
|
77
|
+
size: "md"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// src/ui/toggle/toggle.tsx
|
|
83
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
84
|
+
function Toggle(props) {
|
|
85
|
+
const {
|
|
86
|
+
className,
|
|
87
|
+
size,
|
|
88
|
+
appearance,
|
|
89
|
+
animation = "spring",
|
|
90
|
+
checked,
|
|
91
|
+
defaultChecked = false,
|
|
92
|
+
onCheckedChange,
|
|
93
|
+
disabled,
|
|
94
|
+
ref,
|
|
95
|
+
"aria-label": ariaLabel = "Toggle",
|
|
96
|
+
children,
|
|
97
|
+
...rest
|
|
98
|
+
} = props;
|
|
99
|
+
const isControlled = checked !== void 0;
|
|
100
|
+
const [uncontrolled, setUncontrolled] = _react.useState.call(void 0, defaultChecked);
|
|
101
|
+
const resolved = isControlled ? Boolean(checked) : uncontrolled;
|
|
102
|
+
const thumbMotion = toggleThumbAnimationPresets[animation];
|
|
103
|
+
const setChecked = _react.useCallback.call(void 0,
|
|
104
|
+
(next) => {
|
|
105
|
+
if (!isControlled) {
|
|
106
|
+
setUncontrolled(next);
|
|
107
|
+
}
|
|
108
|
+
_optionalChain([onCheckedChange, 'optionalCall', _ => _(next)]);
|
|
109
|
+
},
|
|
110
|
+
[isControlled, onCheckedChange]
|
|
111
|
+
);
|
|
112
|
+
const thumbShiftPx = size === "sm" ? 14 : size === "lg" ? 26 : 20;
|
|
113
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
ref,
|
|
117
|
+
type: "button",
|
|
118
|
+
role: "switch",
|
|
119
|
+
"data-slot": "toggle",
|
|
120
|
+
"aria-checked": resolved,
|
|
121
|
+
"aria-label": ariaLabel,
|
|
122
|
+
"data-state": resolved ? "checked" : "unchecked",
|
|
123
|
+
disabled,
|
|
124
|
+
className: _chunkE5UX537Jjs.cn.call(void 0, toggleTrackVariants({ size, appearance }), className),
|
|
125
|
+
onClick: () => {
|
|
126
|
+
if (!disabled) {
|
|
127
|
+
setChecked(!resolved);
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
...rest,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", children }),
|
|
133
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
134
|
+
_framermotion.motion.span,
|
|
135
|
+
{
|
|
136
|
+
className: _chunkE5UX537Jjs.cn.call(void 0, toggleThumbVariants({ size }), "absolute left-1 top-1/2 -translate-y-1/2"),
|
|
137
|
+
animate: { x: resolved ? thumbShiftPx : 0 },
|
|
138
|
+
transition: thumbMotion.transition
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
Toggle.displayName = "Toggle";
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
exports.Toggle = Toggle; exports.toggleThumbAnimationPresets = toggleThumbAnimationPresets; exports.toggleThumbVariants = toggleThumbVariants; exports.toggleTrackVariants = toggleTrackVariants;
|
|
152
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/shubham/Desktop/Repos/NEXT%20JS/zentauri-ui/packages/components/dist/ui/toggle.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B;AACA;AACA,6CAAsC;AACtC,8BAA6C;AAC7C;AACA;AACA,IAAI,4BAA4B,EAAE;AAClC,EAAE,IAAI,EAAE,CAAC,CAAC;AACV,EAAE,MAAM,EAAE;AACV,IAAI,MAAM,EAAE,IAAI;AAChB,IAAI,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;AAC9D,EAAE;AACF,CAAC;AACD;AACA;AACA,kEAA8C;AAC9C,IAAI,oBAAoB,EAAE,yCAAG;AAC7B,EAAE,yUAAyU;AAC3U,EAAE;AACF,IAAI,QAAQ,EAAE;AACd,MAAM,IAAI,EAAE;AACZ,QAAQ,EAAE,EAAE,SAAS;AACrB,QAAQ,EAAE,EAAE,UAAU;AACtB,QAAQ,EAAE,EAAE;A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