@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,380 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
cn
|
|
5
|
+
} from "../chunk-MEWYFWBX.mjs";
|
|
6
|
+
|
|
7
|
+
// src/ui/modal/modal.tsx
|
|
8
|
+
import {
|
|
9
|
+
AnimatePresence,
|
|
10
|
+
motion,
|
|
11
|
+
useReducedMotion
|
|
12
|
+
} from "framer-motion";
|
|
13
|
+
import {
|
|
14
|
+
createContext,
|
|
15
|
+
useCallback,
|
|
16
|
+
useContext,
|
|
17
|
+
useEffect,
|
|
18
|
+
useId,
|
|
19
|
+
useMemo,
|
|
20
|
+
useRef,
|
|
21
|
+
useState
|
|
22
|
+
} from "react";
|
|
23
|
+
import { createPortal } from "react-dom";
|
|
24
|
+
|
|
25
|
+
// src/ui/modal/animations.ts
|
|
26
|
+
var modalOverlayAnimationPresets = {
|
|
27
|
+
none: {},
|
|
28
|
+
fade: {
|
|
29
|
+
initial: { opacity: 0 },
|
|
30
|
+
animate: { opacity: 1 },
|
|
31
|
+
exit: { opacity: 0 },
|
|
32
|
+
transition: { duration: 0.2 }
|
|
33
|
+
},
|
|
34
|
+
scale: {
|
|
35
|
+
initial: { opacity: 0, scale: 0.96 },
|
|
36
|
+
animate: { opacity: 1, scale: 1 },
|
|
37
|
+
exit: { opacity: 0, scale: 0.96 },
|
|
38
|
+
transition: { type: "spring", stiffness: 420, damping: 32 }
|
|
39
|
+
},
|
|
40
|
+
"slide-up": {
|
|
41
|
+
initial: { opacity: 0, y: 24 },
|
|
42
|
+
animate: { opacity: 1, y: 0 },
|
|
43
|
+
exit: { opacity: 0, y: 16 },
|
|
44
|
+
transition: { type: "spring", stiffness: 380, damping: 30 }
|
|
45
|
+
},
|
|
46
|
+
"slide-down": {
|
|
47
|
+
initial: { opacity: 0, y: -24 },
|
|
48
|
+
animate: { opacity: 1, y: 0 },
|
|
49
|
+
exit: { opacity: 0, y: -16 },
|
|
50
|
+
transition: { type: "spring", stiffness: 380, damping: 30 }
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/ui/modal/variants.ts
|
|
55
|
+
import { cva } from "class-variance-authority";
|
|
56
|
+
var modalOverlayVariants = cva(
|
|
57
|
+
"fixed inset-0 z-50 bg-slate-950/70 backdrop-blur-sm data-[state=open]:animate-in"
|
|
58
|
+
);
|
|
59
|
+
var modalTriggerVariants = cva(
|
|
60
|
+
"relative inline-flex shrink-0 cursor-pointer rounded-md border",
|
|
61
|
+
{
|
|
62
|
+
variants: {
|
|
63
|
+
appearance: {
|
|
64
|
+
default: "bg-slate-950",
|
|
65
|
+
glass: "border-white/15 bg-slate-950/70 backdrop-blur-xl",
|
|
66
|
+
sky: "border-sky-600 bg-sky-950/70 backdrop-blur-xl",
|
|
67
|
+
rose: "border-rose-600 bg-rose-950/70 backdrop-blur-xl",
|
|
68
|
+
purple: "border-purple-600 bg-purple-950/70 backdrop-blur-xl",
|
|
69
|
+
pink: "border-pink-600 bg-pink-950/70 backdrop-blur-xl",
|
|
70
|
+
orange: "border-orange-600 bg-orange-950/70 backdrop-blur-xl",
|
|
71
|
+
yellow: "border-yellow-600 bg-yellow-950/70 backdrop-blur-xl",
|
|
72
|
+
teal: "border-teal-600 bg-teal-950/70 backdrop-blur-xl",
|
|
73
|
+
indigo: "border-indigo-600 bg-indigo-950/70 backdrop-blur-xl",
|
|
74
|
+
emerald: "border-emerald-600 bg-emerald-950/70 backdrop-blur-xl",
|
|
75
|
+
gray: "border-gray-600 bg-gray-950/70 backdrop-blur-xl",
|
|
76
|
+
amber: "border-amber-600 bg-amber-950/70 backdrop-blur-xl",
|
|
77
|
+
violet: "border-violet-600 bg-violet-950/70 backdrop-blur-xl",
|
|
78
|
+
"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",
|
|
79
|
+
"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",
|
|
80
|
+
"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",
|
|
81
|
+
"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",
|
|
82
|
+
"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",
|
|
83
|
+
"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",
|
|
84
|
+
"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",
|
|
85
|
+
"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",
|
|
86
|
+
"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"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
defaultVariants: {
|
|
90
|
+
appearance: "default"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
var modalContentVariants = cva(
|
|
95
|
+
"fixed left-1/2 z-50 w-[calc(100%-2rem)] max-h-[min(90vh,720px)] translate-x-[-50%] overflow-y-auto border border-white/10 bg-slate-950 p-6 text-slate-50 shadow-[0_24px_80px_rgba(15,23,42,0.55)] focus:outline-none",
|
|
96
|
+
{
|
|
97
|
+
variants: {
|
|
98
|
+
size: {
|
|
99
|
+
sm: "max-w-md",
|
|
100
|
+
md: "max-w-lg",
|
|
101
|
+
lg: "max-w-2xl",
|
|
102
|
+
xl: "max-w-4xl",
|
|
103
|
+
full: "max-w-[calc(100%-2rem)]"
|
|
104
|
+
},
|
|
105
|
+
position: {
|
|
106
|
+
center: "top-1/2 translate-y-[-50%]",
|
|
107
|
+
top: "top-10 translate-y-0",
|
|
108
|
+
bottom: "bottom-10 translate-y-0"
|
|
109
|
+
},
|
|
110
|
+
appearance: {
|
|
111
|
+
default: "bg-slate-950",
|
|
112
|
+
glass: "border-white/15 bg-slate-950/70 backdrop-blur-xl",
|
|
113
|
+
sky: "border-sky-600 bg-sky-950/70 backdrop-blur-xl",
|
|
114
|
+
rose: "border-rose-600 bg-rose-950/70 backdrop-blur-xl",
|
|
115
|
+
purple: "border-purple-600 bg-purple-950/70 backdrop-blur-xl",
|
|
116
|
+
pink: "border-pink-600 bg-pink-950/70 backdrop-blur-xl",
|
|
117
|
+
orange: "border-orange-600 bg-orange-950/70 backdrop-blur-xl",
|
|
118
|
+
yellow: "border-yellow-600 bg-yellow-950/70 backdrop-blur-xl",
|
|
119
|
+
teal: "border-teal-600 bg-teal-950/70 backdrop-blur-xl",
|
|
120
|
+
indigo: "border-indigo-600 bg-indigo-950/70 backdrop-blur-xl",
|
|
121
|
+
emerald: "border-emerald-600 bg-emerald-950/70 backdrop-blur-xl",
|
|
122
|
+
gray: "border-gray-600 bg-gray-950/70 backdrop-blur-xl",
|
|
123
|
+
amber: "border-amber-600 bg-amber-950/70 backdrop-blur-xl",
|
|
124
|
+
violet: "border-violet-600 bg-violet-950/70 backdrop-blur-xl",
|
|
125
|
+
"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",
|
|
126
|
+
"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",
|
|
127
|
+
"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",
|
|
128
|
+
"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",
|
|
129
|
+
"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",
|
|
130
|
+
"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",
|
|
131
|
+
"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",
|
|
132
|
+
"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",
|
|
133
|
+
"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"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
defaultVariants: {
|
|
137
|
+
size: "md",
|
|
138
|
+
position: "center",
|
|
139
|
+
appearance: "default"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// src/ui/modal/modal.tsx
|
|
145
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
146
|
+
var ModalContext = createContext(null);
|
|
147
|
+
function useModalContext(component) {
|
|
148
|
+
const ctx = useContext(ModalContext);
|
|
149
|
+
if (!ctx) {
|
|
150
|
+
throw new Error(`${component} must be used within <Modal>`);
|
|
151
|
+
}
|
|
152
|
+
return ctx;
|
|
153
|
+
}
|
|
154
|
+
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';
|
|
155
|
+
function useBodyScrollLock(locked) {
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (!locked) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const previousOverflow = document.body.style.overflow;
|
|
161
|
+
document.body.style.overflow = "hidden";
|
|
162
|
+
return () => {
|
|
163
|
+
document.body.style.overflow = previousOverflow;
|
|
164
|
+
};
|
|
165
|
+
}, [locked]);
|
|
166
|
+
}
|
|
167
|
+
function Modal({ open, defaultOpen = false, onOpenChange, children }) {
|
|
168
|
+
const isControlled = open !== void 0;
|
|
169
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
170
|
+
const resolvedOpen = isControlled ? Boolean(open) : uncontrolledOpen;
|
|
171
|
+
const setOpen = useCallback(
|
|
172
|
+
(next) => {
|
|
173
|
+
if (!isControlled) {
|
|
174
|
+
setUncontrolledOpen(next);
|
|
175
|
+
}
|
|
176
|
+
onOpenChange?.(next);
|
|
177
|
+
},
|
|
178
|
+
[isControlled, onOpenChange]
|
|
179
|
+
);
|
|
180
|
+
const baseId = useId();
|
|
181
|
+
const titleId = `${baseId}-title`;
|
|
182
|
+
const descriptionId = `${baseId}-description`;
|
|
183
|
+
const contentRef = useRef(null);
|
|
184
|
+
const ctx = useMemo(
|
|
185
|
+
() => ({
|
|
186
|
+
open: resolvedOpen,
|
|
187
|
+
setOpen,
|
|
188
|
+
titleId,
|
|
189
|
+
descriptionId,
|
|
190
|
+
contentRef
|
|
191
|
+
}),
|
|
192
|
+
[descriptionId, resolvedOpen, setOpen, titleId]
|
|
193
|
+
);
|
|
194
|
+
return /* @__PURE__ */ jsx(ModalContext.Provider, { value: ctx, children });
|
|
195
|
+
}
|
|
196
|
+
Modal.displayName = "Modal";
|
|
197
|
+
function ModalTrigger({ className, children, appearance, onClick, ref, ...rest }) {
|
|
198
|
+
const { setOpen } = useModalContext("ModalTrigger");
|
|
199
|
+
return /* @__PURE__ */ jsx(
|
|
200
|
+
"button",
|
|
201
|
+
{
|
|
202
|
+
ref,
|
|
203
|
+
type: "button",
|
|
204
|
+
"data-slot": "modal-trigger",
|
|
205
|
+
className: cn(modalTriggerVariants({ appearance }), className),
|
|
206
|
+
onClick: (event) => {
|
|
207
|
+
onClick?.(event);
|
|
208
|
+
if (!event.defaultPrevented) {
|
|
209
|
+
setOpen(true);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
...rest,
|
|
213
|
+
children
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
ModalTrigger.displayName = "ModalTrigger";
|
|
218
|
+
function ModalContent({
|
|
219
|
+
className,
|
|
220
|
+
size,
|
|
221
|
+
position,
|
|
222
|
+
appearance,
|
|
223
|
+
animation = "scale",
|
|
224
|
+
children,
|
|
225
|
+
ref,
|
|
226
|
+
id,
|
|
227
|
+
style
|
|
228
|
+
}) {
|
|
229
|
+
const { open, setOpen, titleId, descriptionId, contentRef } = useModalContext("ModalContent");
|
|
230
|
+
const reduceMotion = useReducedMotion();
|
|
231
|
+
const overlayMotion = modalOverlayAnimationPresets[reduceMotion ? "fade" : animation];
|
|
232
|
+
const panelMotion = modalOverlayAnimationPresets[reduceMotion ? "fade" : animation];
|
|
233
|
+
useBodyScrollLock(open);
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
if (!open) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const handleKeyDown = (event) => {
|
|
239
|
+
if (event.key === "Escape") {
|
|
240
|
+
setOpen(false);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
244
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
245
|
+
}, [open, setOpen]);
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
if (!open) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const node = contentRef.current;
|
|
251
|
+
if (!node) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const focusables = Array.from(
|
|
255
|
+
node.querySelectorAll(FOCUSABLE_SELECTOR)
|
|
256
|
+
).filter((element) => element.offsetParent !== null || element === node);
|
|
257
|
+
const target = focusables[0] ?? node;
|
|
258
|
+
const previouslyFocused = document.activeElement;
|
|
259
|
+
target.focus();
|
|
260
|
+
const handleFocusIn = (event) => {
|
|
261
|
+
if (!node.contains(event.target)) {
|
|
262
|
+
event.stopPropagation();
|
|
263
|
+
target.focus();
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
document.addEventListener("focusin", handleFocusIn);
|
|
267
|
+
return () => {
|
|
268
|
+
document.removeEventListener("focusin", handleFocusIn);
|
|
269
|
+
previouslyFocused?.focus?.();
|
|
270
|
+
};
|
|
271
|
+
}, [contentRef, open]);
|
|
272
|
+
const portalTarget = typeof document !== "undefined" ? document.body : null;
|
|
273
|
+
if (!portalTarget) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
return createPortal(
|
|
277
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50", "data-slot": "modal-portal", children: [
|
|
278
|
+
/* @__PURE__ */ jsx(
|
|
279
|
+
motion.button,
|
|
280
|
+
{
|
|
281
|
+
type: "button",
|
|
282
|
+
"aria-hidden": true,
|
|
283
|
+
tabIndex: -1,
|
|
284
|
+
"data-slot": "modal-overlay",
|
|
285
|
+
className: modalOverlayVariants(),
|
|
286
|
+
onClick: () => setOpen(false),
|
|
287
|
+
initial: animation === "none" ? false : overlayMotion.initial,
|
|
288
|
+
animate: animation === "none" ? void 0 : overlayMotion.animate,
|
|
289
|
+
exit: animation === "none" ? void 0 : overlayMotion.exit,
|
|
290
|
+
transition: overlayMotion.transition
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
/* @__PURE__ */ jsx(
|
|
294
|
+
motion.div,
|
|
295
|
+
{
|
|
296
|
+
ref: (node) => {
|
|
297
|
+
contentRef.current = node;
|
|
298
|
+
if (typeof ref === "function") {
|
|
299
|
+
ref(node);
|
|
300
|
+
} else if (ref) {
|
|
301
|
+
ref.current = node;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
role: "dialog",
|
|
305
|
+
"aria-modal": "true",
|
|
306
|
+
"aria-labelledby": titleId,
|
|
307
|
+
"aria-describedby": descriptionId,
|
|
308
|
+
"data-slot": "modal-content",
|
|
309
|
+
tabIndex: -1,
|
|
310
|
+
className: cn(modalContentVariants({ size, position, appearance }), className),
|
|
311
|
+
initial: animation === "none" ? false : panelMotion.initial,
|
|
312
|
+
animate: animation === "none" ? void 0 : panelMotion.animate,
|
|
313
|
+
exit: animation === "none" ? void 0 : panelMotion.exit,
|
|
314
|
+
transition: panelMotion.transition,
|
|
315
|
+
id,
|
|
316
|
+
style,
|
|
317
|
+
children
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
] }) : null }),
|
|
321
|
+
portalTarget
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
ModalContent.displayName = "ModalContent";
|
|
325
|
+
function ModalHeader({ className, children }) {
|
|
326
|
+
return /* @__PURE__ */ jsx("header", { "data-slot": "modal-header", className: cn("mb-4 flex flex-col gap-2", className), children });
|
|
327
|
+
}
|
|
328
|
+
ModalHeader.displayName = "ModalHeader";
|
|
329
|
+
function ModalBody({ className, children }) {
|
|
330
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "modal-body", className: cn("text-sm text-slate-300", className), children });
|
|
331
|
+
}
|
|
332
|
+
ModalBody.displayName = "ModalBody";
|
|
333
|
+
function ModalFooter({ className, children }) {
|
|
334
|
+
return /* @__PURE__ */ jsx("footer", { "data-slot": "modal-footer", className: cn("mt-6 flex justify-end gap-2", className), children });
|
|
335
|
+
}
|
|
336
|
+
ModalFooter.displayName = "ModalFooter";
|
|
337
|
+
function ModalTitle({ className, children }) {
|
|
338
|
+
const { titleId } = useModalContext("ModalTitle");
|
|
339
|
+
return /* @__PURE__ */ jsx("h2", { id: titleId, "data-slot": "modal-title", className: cn("text-lg font-semibold", className), children });
|
|
340
|
+
}
|
|
341
|
+
ModalTitle.displayName = "ModalTitle";
|
|
342
|
+
function ModalDescription({ className, children }) {
|
|
343
|
+
const { descriptionId } = useModalContext("ModalDescription");
|
|
344
|
+
return /* @__PURE__ */ jsx("p", { id: descriptionId, "data-slot": "modal-description", className: cn("text-sm text-slate-400", className), children });
|
|
345
|
+
}
|
|
346
|
+
ModalDescription.displayName = "ModalDescription";
|
|
347
|
+
function ModalClose({ className, children, ...rest }) {
|
|
348
|
+
const { setOpen } = useModalContext("ModalClose");
|
|
349
|
+
return /* @__PURE__ */ jsx(
|
|
350
|
+
"button",
|
|
351
|
+
{
|
|
352
|
+
type: "button",
|
|
353
|
+
"data-slot": "modal-close",
|
|
354
|
+
className: cn(
|
|
355
|
+
"absolute right-4 top-4 inline-flex size-9 items-center justify-center rounded-md text-slate-200 transition hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/30",
|
|
356
|
+
className
|
|
357
|
+
),
|
|
358
|
+
"aria-label": "Close dialog",
|
|
359
|
+
onClick: () => setOpen(false),
|
|
360
|
+
...rest,
|
|
361
|
+
children: children ?? "\xD7"
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
ModalClose.displayName = "ModalClose";
|
|
366
|
+
export {
|
|
367
|
+
Modal,
|
|
368
|
+
ModalBody,
|
|
369
|
+
ModalClose,
|
|
370
|
+
ModalContent,
|
|
371
|
+
ModalDescription,
|
|
372
|
+
ModalFooter,
|
|
373
|
+
ModalHeader,
|
|
374
|
+
ModalTitle,
|
|
375
|
+
ModalTrigger,
|
|
376
|
+
modalContentVariants,
|
|
377
|
+
modalOverlayAnimationPresets,
|
|
378
|
+
modalOverlayVariants
|
|
379
|
+
};
|
|
380
|
+
//# sourceMappingURL=modal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/modal/modal.tsx","../../src/ui/modal/animations.ts","../../src/ui/modal/variants.ts"],"sourcesContent":["\"use client\";\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from \"framer-motion\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"../../lib/utils\";\n\nimport { modalOverlayAnimationPresets } from \"./animations\";\nimport type {\n ModalContentProps,\n ModalProps,\n ModalSectionProps,\n ModalTriggerProps,\n} from \"./types\";\nimport { modalContentVariants, modalOverlayVariants, modalTriggerVariants } from \"./variants\";\n\ntype ModalCtx = {\n open: boolean;\n setOpen: (next: boolean) => void;\n titleId: string;\n descriptionId: string;\n contentRef: React.RefObject<HTMLDivElement | null>;\n};\n\nconst ModalContext = createContext<ModalCtx | null>(null);\n\nfunction useModalContext(component: string): ModalCtx {\n const ctx = useContext(ModalContext);\n if (!ctx) {\n throw new Error(`${component} must be used within <Modal>`);\n }\n return ctx;\n}\n\nconst FOCUSABLE_SELECTOR =\n 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex=\"-1\"])';\n\nfunction useBodyScrollLock(locked: boolean) {\n useEffect(() => {\n if (!locked) {\n return;\n }\n const previousOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = previousOverflow;\n };\n }, [locked]);\n}\n\nexport function Modal({ open, defaultOpen = false, onOpenChange, children }: ModalProps) {\n const isControlled = open !== undefined;\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const resolvedOpen = isControlled ? Boolean(open) : uncontrolledOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange],\n );\n\n const baseId = useId();\n const titleId = `${baseId}-title`;\n const descriptionId = `${baseId}-description`;\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const ctx = useMemo(\n () => ({\n open: resolvedOpen,\n setOpen,\n titleId,\n descriptionId,\n contentRef,\n }),\n [descriptionId, resolvedOpen, setOpen, titleId],\n );\n\n return <ModalContext.Provider value={ctx}>{children}</ModalContext.Provider>;\n}\n\nModal.displayName = \"Modal\";\n\nexport function ModalTrigger({ className, children, appearance, onClick, ref, ...rest }: ModalTriggerProps) {\n const { setOpen } = useModalContext(\"ModalTrigger\");\n return (\n <button\n ref={ref}\n type=\"button\"\n data-slot=\"modal-trigger\"\n className={cn(modalTriggerVariants({ appearance }), className)}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n setOpen(true);\n }\n }}\n {...rest}\n >\n {children}\n </button>\n );\n}\n\nModalTrigger.displayName = \"ModalTrigger\";\n\nexport function ModalContent({\n className,\n size,\n position,\n appearance,\n animation = \"scale\",\n children,\n ref,\n id,\n style,\n}: ModalContentProps) {\n const { open, setOpen, titleId, descriptionId, contentRef } = useModalContext(\"ModalContent\");\n const reduceMotion = useReducedMotion();\n const overlayMotion = modalOverlayAnimationPresets[reduceMotion ? \"fade\" : animation];\n const panelMotion = modalOverlayAnimationPresets[reduceMotion ? \"fade\" : animation];\n\n useBodyScrollLock(open);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n setOpen(false);\n }\n };\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => window.removeEventListener(\"keydown\", handleKeyDown);\n }, [open, setOpen]);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n const node = contentRef.current;\n if (!node) {\n return;\n }\n const focusables = Array.from(\n node.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR),\n ).filter((element) => element.offsetParent !== null || element === node);\n const target = focusables[0] ?? node;\n const previouslyFocused = document.activeElement as HTMLElement | null;\n target.focus();\n\n const handleFocusIn = (event: FocusEvent) => {\n if (!node.contains(event.target as Node)) {\n event.stopPropagation();\n target.focus();\n }\n };\n document.addEventListener(\"focusin\", handleFocusIn);\n return () => {\n document.removeEventListener(\"focusin\", handleFocusIn);\n previouslyFocused?.focus?.();\n };\n }, [contentRef, open]);\n\n const portalTarget = typeof document !== \"undefined\" ? document.body : null;\n\n if (!portalTarget) {\n return null;\n }\n\n return createPortal(\n <AnimatePresence>\n {open ? (\n <div className=\"fixed inset-0 z-50\" data-slot=\"modal-portal\">\n <motion.button\n type=\"button\"\n aria-hidden\n tabIndex={-1}\n data-slot=\"modal-overlay\"\n className={modalOverlayVariants()}\n onClick={() => setOpen(false)}\n initial={animation === \"none\" ? false : overlayMotion.initial}\n animate={animation === \"none\" ? undefined : overlayMotion.animate}\n exit={animation === \"none\" ? undefined : overlayMotion.exit}\n transition={overlayMotion.transition}\n />\n <motion.div\n ref={(node) => {\n contentRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.RefObject<HTMLDivElement | null>).current = node;\n }\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={descriptionId}\n data-slot=\"modal-content\"\n tabIndex={-1}\n className={cn(modalContentVariants({ size, position, appearance }), className)}\n initial={animation === \"none\" ? false : panelMotion.initial}\n animate={animation === \"none\" ? undefined : panelMotion.animate}\n exit={animation === \"none\" ? undefined : panelMotion.exit}\n transition={panelMotion.transition}\n id={id}\n style={style}\n >\n {children}\n </motion.div>\n </div>\n ) : null}\n </AnimatePresence>,\n portalTarget,\n );\n}\n\nModalContent.displayName = \"ModalContent\";\n\nexport function ModalHeader({ className, children }: ModalSectionProps) {\n return (\n <header data-slot=\"modal-header\" className={cn(\"mb-4 flex flex-col gap-2\", className)}>\n {children}\n </header>\n );\n}\n\nModalHeader.displayName = \"ModalHeader\";\n\nexport function ModalBody({ className, children }: ModalSectionProps) {\n return (\n <div data-slot=\"modal-body\" className={cn(\"text-sm text-slate-300\", className)}>\n {children}\n </div>\n );\n}\n\nModalBody.displayName = \"ModalBody\";\n\nexport function ModalFooter({ className, children }: ModalSectionProps) {\n return (\n <footer data-slot=\"modal-footer\" className={cn(\"mt-6 flex justify-end gap-2\", className)}>\n {children}\n </footer>\n );\n}\n\nModalFooter.displayName = \"ModalFooter\";\n\nexport function ModalTitle({ className, children }: ModalSectionProps) {\n const { titleId } = useModalContext(\"ModalTitle\");\n return (\n <h2 id={titleId} data-slot=\"modal-title\" className={cn(\"text-lg font-semibold\", className)}>\n {children}\n </h2>\n );\n}\n\nModalTitle.displayName = \"ModalTitle\";\n\nexport function ModalDescription({ className, children }: ModalSectionProps) {\n const { descriptionId } = useModalContext(\"ModalDescription\");\n return (\n <p id={descriptionId} data-slot=\"modal-description\" className={cn(\"text-sm text-slate-400\", className)}>\n {children}\n </p>\n );\n}\n\nModalDescription.displayName = \"ModalDescription\";\n\nexport function ModalClose({ className, children, ...rest }: ModalSectionProps) {\n const { setOpen } = useModalContext(\"ModalClose\");\n return (\n <button\n type=\"button\"\n data-slot=\"modal-close\"\n className={cn(\n \"absolute right-4 top-4 inline-flex size-9 items-center justify-center rounded-md text-slate-200 transition hover:bg-white/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/30\",\n className,\n )}\n aria-label=\"Close dialog\"\n onClick={() => setOpen(false)}\n {...rest}\n >\n {children ?? \"×\"}\n </button>\n );\n}\n\nModalClose.displayName = \"ModalClose\";\n","import type { HTMLMotionProps } from \"framer-motion\";\n\nimport type { ModalAnimation } from \"./types\";\n\ntype ModalPresetMotionProps = Pick<\n HTMLMotionProps<\"div\">,\n \"initial\" | \"animate\" | \"exit\" | \"transition\"\n>;\n\nexport type ModalAnimationPresets = Record<ModalAnimation, ModalPresetMotionProps>;\n\nexport const modalOverlayAnimationPresets: ModalAnimationPresets = {\n none: {},\n fade: {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n transition: { duration: 0.2 },\n },\n scale: {\n initial: { opacity: 0, scale: 0.96 },\n animate: { opacity: 1, scale: 1 },\n exit: { opacity: 0, scale: 0.96 },\n transition: { type: \"spring\", stiffness: 420, damping: 32 },\n },\n \"slide-up\": {\n initial: { opacity: 0, y: 24 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: 16 },\n transition: { type: \"spring\", stiffness: 380, damping: 30 },\n },\n \"slide-down\": {\n initial: { opacity: 0, y: -24 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: -16 },\n transition: { type: \"spring\", stiffness: 380, damping: 30 },\n },\n};\n","import { cva } from \"class-variance-authority\";\n\nexport const modalOverlayVariants = cva(\n \"fixed inset-0 z-50 bg-slate-950/70 backdrop-blur-sm data-[state=open]:animate-in\",\n);\n\nexport const modalTriggerVariants = cva(\n \"relative inline-flex shrink-0 cursor-pointer rounded-md border\",\n {\n variants: {\n appearance: {\n default: \"bg-slate-950\",\n glass: \"border-white/15 bg-slate-950/70 backdrop-blur-xl\",\n sky: \"border-sky-600 bg-sky-950/70 backdrop-blur-xl\",\n rose: \"border-rose-600 bg-rose-950/70 backdrop-blur-xl\",\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 },\n defaultVariants: {\n appearance: \"default\",\n },\n },\n);\n\nexport const modalContentVariants = cva(\n \"fixed left-1/2 z-50 w-[calc(100%-2rem)] max-h-[min(90vh,720px)] translate-x-[-50%] overflow-y-auto border border-white/10 bg-slate-950 p-6 text-slate-50 shadow-[0_24px_80px_rgba(15,23,42,0.55)] focus:outline-none\",\n {\n variants: {\n size: {\n sm: \"max-w-md\",\n md: \"max-w-lg\",\n lg: \"max-w-2xl\",\n xl: \"max-w-4xl\",\n full: \"max-w-[calc(100%-2rem)]\",\n },\n position: {\n center: \"top-1/2 translate-y-[-50%]\",\n top: \"top-10 translate-y-0\",\n bottom: \"bottom-10 translate-y-0\",\n },\n appearance: {\n default: \"bg-slate-950\",\n glass: \"border-white/15 bg-slate-950/70 backdrop-blur-xl\",\n sky: \"border-sky-600 bg-sky-950/70 backdrop-blur-xl\",\n rose: \"border-rose-600 bg-rose-950/70 backdrop-blur-xl\",\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 },\n defaultVariants: {\n size: \"md\",\n position: \"center\",\n appearance: \"default\",\n },\n },\n);\n"],"mappings":";;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;;;ACNtB,IAAM,+BAAsD;AAAA,EACjE,MAAM,CAAC;AAAA,EACP,MAAM;AAAA,IACJ,SAAS,EAAE,SAAS,EAAE;AAAA,IACtB,SAAS,EAAE,SAAS,EAAE;AAAA,IACtB,MAAM,EAAE,SAAS,EAAE;AAAA,IACnB,YAAY,EAAE,UAAU,IAAI;AAAA,EAC9B;AAAA,EACA,OAAO;AAAA,IACL,SAAS,EAAE,SAAS,GAAG,OAAO,KAAK;AAAA,IACnC,SAAS,EAAE,SAAS,GAAG,OAAO,EAAE;AAAA,IAChC,MAAM,EAAE,SAAS,GAAG,OAAO,KAAK;AAAA,IAChC,YAAY,EAAE,MAAM,UAAU,WAAW,KAAK,SAAS,GAAG;AAAA,EAC5D;AAAA,EACA,YAAY;AAAA,IACV,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,cAAc;AAAA,IACZ,SAAS,EAAE,SAAS,GAAG,GAAG,IAAI;AAAA,IAC9B,SAAS,EAAE,SAAS,GAAG,GAAG,EAAE;AAAA,IAC5B,MAAM,EAAE,SAAS,GAAG,GAAG,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AY;AAChD,SACE,oBAAC,QAAG,IAAI,SAAS,aAAU,eAAc,WAAW,GAAG,yBAAyB,SAAS,GACtF,UACH;AAEJ;AAEA,WAAW,cAAc;AAElB,SAAS,iBAAiB,EAAE,WAAW,SAAS,GAAsB;AAC3E,QAAM,EAAE,cAAc,IAAI,gBAAgB,kBAAkB;AAC5D,SACE,oBAAC,OAAE,IAAI,eAAe,aAAU,qBAAoB,WAAW,GAAG,0BAA0B,SAAS,GAClG,UACH;AAEJ;AAEA,iBAAiB,cAAc;AAExB,SAAS,WAAW,EAAE,WAAW,UAAU,GAAG,KAAK,GAAsB;AAC9E,QAAM,EAAE,QAAQ,IAAI,gBAAgB,YAAY;AAChD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA,cAAW;AAAA,MACX,SAAS,MAAM,QAAQ,KAAK;AAAA,MAC3B,GAAG;AAAA,MAEH,sBAAY;AAAA;AAAA,EACf;AAEJ;AAEA,WAAW,cAAc;","names":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as class_variance_authority from 'class-variance-authority';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
6
|
+
import { b as buttonVariants } from '../variants-Dd9pe-ov.mjs';
|
|
7
|
+
|
|
8
|
+
declare const Pagination: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "onChange"> & class_variance_authority.VariantProps<(props?: ({
|
|
9
|
+
appearance?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "glass" | "emerald" | "indigo" | "purple" | "pink" | "rose" | "sky" | "teal" | "yellow" | "orange" | "gray" | "amber" | "violet" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
10
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "icon" | null | undefined;
|
|
11
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
12
|
+
pageCount: number;
|
|
13
|
+
page?: number;
|
|
14
|
+
defaultPage?: number;
|
|
15
|
+
onPageChange?: (page: number) => void;
|
|
16
|
+
siblingCount?: number;
|
|
17
|
+
boundaryCount?: number;
|
|
18
|
+
showPrevNext?: boolean;
|
|
19
|
+
prevLabel?: string;
|
|
20
|
+
nextLabel?: string;
|
|
21
|
+
ellipsisLabel?: string;
|
|
22
|
+
getPageHref?: (page: number) => string | undefined;
|
|
23
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
24
|
+
|
|
25
|
+
type PaginationPageItem$1 = {
|
|
26
|
+
type: "page";
|
|
27
|
+
value: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: "ellipsis";
|
|
30
|
+
key: string;
|
|
31
|
+
};
|
|
32
|
+
type BuildPaginationItemsParams = {
|
|
33
|
+
pageCount: number;
|
|
34
|
+
currentPage: number;
|
|
35
|
+
siblingCount: number;
|
|
36
|
+
boundaryCount: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Builds the ordered list of page numbers and ellipsis markers for a pagination control.
|
|
40
|
+
*
|
|
41
|
+
* Args:
|
|
42
|
+
* pageCount: Total number of pages (must be >= 0).
|
|
43
|
+
* currentPage: Active page index (1-based).
|
|
44
|
+
* siblingCount: How many page buttons to show on each side of the current page.
|
|
45
|
+
* boundaryCount: How many pages to pin at the start and end of the range.
|
|
46
|
+
*
|
|
47
|
+
* Returns:
|
|
48
|
+
* A list of items suitable for rendering, e.g. [1, ellipsis, 4,5,6, ellipsis, 20].
|
|
49
|
+
*/
|
|
50
|
+
declare function buildPaginationItems({ pageCount, currentPage, siblingCount, boundaryCount, }: BuildPaginationItemsParams): PaginationPageItem$1[];
|
|
51
|
+
declare function clampPage(page: number, pageCount: number): number;
|
|
52
|
+
|
|
53
|
+
type PaginationAppearance = NonNullable<VariantProps<typeof buttonVariants>["appearance"]>;
|
|
54
|
+
type PaginationSize = NonNullable<VariantProps<typeof buttonVariants>["size"]>;
|
|
55
|
+
type PaginationPageItem = PaginationPageItem$1;
|
|
56
|
+
type UsePaginationParams = {
|
|
57
|
+
pageCount: number;
|
|
58
|
+
page?: number;
|
|
59
|
+
defaultPage?: number;
|
|
60
|
+
siblingCount?: number;
|
|
61
|
+
boundaryCount?: number;
|
|
62
|
+
onPageChange?: (page: number) => void;
|
|
63
|
+
};
|
|
64
|
+
type UsePaginationResult = {
|
|
65
|
+
/** 1-based active page, clamped to `[1, pageCount]`. */
|
|
66
|
+
currentPage: number;
|
|
67
|
+
pageCount: number;
|
|
68
|
+
items: PaginationPageItem[];
|
|
69
|
+
setPage: (page: number) => void;
|
|
70
|
+
goPrev: () => void;
|
|
71
|
+
goNext: () => void;
|
|
72
|
+
canGoPrev: boolean;
|
|
73
|
+
canGoNext: boolean;
|
|
74
|
+
};
|
|
75
|
+
type PaginationProps = Omit<ComponentPropsWithoutRef<"nav">, "onChange"> & VariantProps<typeof buttonVariants> & {
|
|
76
|
+
pageCount: number;
|
|
77
|
+
page?: number;
|
|
78
|
+
defaultPage?: number;
|
|
79
|
+
onPageChange?: (page: number) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Number of page buttons to show on each side of the current page (the “middle” window).
|
|
82
|
+
* @defaultValue 1
|
|
83
|
+
*/
|
|
84
|
+
siblingCount?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Number of pages to keep visible at the start and end of the range.
|
|
87
|
+
* @defaultValue 1
|
|
88
|
+
*/
|
|
89
|
+
boundaryCount?: number;
|
|
90
|
+
showPrevNext?: boolean;
|
|
91
|
+
prevLabel?: string;
|
|
92
|
+
nextLabel?: string;
|
|
93
|
+
ellipsisLabel?: string;
|
|
94
|
+
/**
|
|
95
|
+
* When set, page controls render as anchors suitable for URL-based pagination.
|
|
96
|
+
*/
|
|
97
|
+
getPageHref?: (page: number) => string | undefined;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
declare function usePagination({ pageCount, page, defaultPage, siblingCount, boundaryCount, onPageChange, }: UsePaginationParams): UsePaginationResult;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Layout and chrome for the page list cluster. Appearance and size keys align with
|
|
104
|
+
* `components/ui/buttons/variants.ts` for consistent design-system tokens.
|
|
105
|
+
*/
|
|
106
|
+
declare const paginationListVariants: (props?: ({
|
|
107
|
+
appearance?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "glass" | "emerald" | "indigo" | "purple" | "pink" | "rose" | "sky" | "teal" | "yellow" | "orange" | "gray" | "amber" | "violet" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
108
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "icon" | null | undefined;
|
|
109
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
110
|
+
declare const paginationEllipsisVariants: (props?: ({
|
|
111
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "icon" | null | undefined;
|
|
112
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
113
|
+
|
|
114
|
+
export { Pagination, type PaginationAppearance, type PaginationPageItem, type PaginationProps, type PaginationSize, type UsePaginationParams, type UsePaginationResult, buildPaginationItems, clampPage, paginationEllipsisVariants, paginationListVariants, usePagination };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as class_variance_authority from 'class-variance-authority';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
6
|
+
import { b as buttonVariants } from '../variants-Dd9pe-ov.js';
|
|
7
|
+
|
|
8
|
+
declare const Pagination: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "onChange"> & class_variance_authority.VariantProps<(props?: ({
|
|
9
|
+
appearance?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "glass" | "emerald" | "indigo" | "purple" | "pink" | "rose" | "sky" | "teal" | "yellow" | "orange" | "gray" | "amber" | "violet" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
10
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "icon" | null | undefined;
|
|
11
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
12
|
+
pageCount: number;
|
|
13
|
+
page?: number;
|
|
14
|
+
defaultPage?: number;
|
|
15
|
+
onPageChange?: (page: number) => void;
|
|
16
|
+
siblingCount?: number;
|
|
17
|
+
boundaryCount?: number;
|
|
18
|
+
showPrevNext?: boolean;
|
|
19
|
+
prevLabel?: string;
|
|
20
|
+
nextLabel?: string;
|
|
21
|
+
ellipsisLabel?: string;
|
|
22
|
+
getPageHref?: (page: number) => string | undefined;
|
|
23
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
24
|
+
|
|
25
|
+
type PaginationPageItem$1 = {
|
|
26
|
+
type: "page";
|
|
27
|
+
value: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: "ellipsis";
|
|
30
|
+
key: string;
|
|
31
|
+
};
|
|
32
|
+
type BuildPaginationItemsParams = {
|
|
33
|
+
pageCount: number;
|
|
34
|
+
currentPage: number;
|
|
35
|
+
siblingCount: number;
|
|
36
|
+
boundaryCount: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Builds the ordered list of page numbers and ellipsis markers for a pagination control.
|
|
40
|
+
*
|
|
41
|
+
* Args:
|
|
42
|
+
* pageCount: Total number of pages (must be >= 0).
|
|
43
|
+
* currentPage: Active page index (1-based).
|
|
44
|
+
* siblingCount: How many page buttons to show on each side of the current page.
|
|
45
|
+
* boundaryCount: How many pages to pin at the start and end of the range.
|
|
46
|
+
*
|
|
47
|
+
* Returns:
|
|
48
|
+
* A list of items suitable for rendering, e.g. [1, ellipsis, 4,5,6, ellipsis, 20].
|
|
49
|
+
*/
|
|
50
|
+
declare function buildPaginationItems({ pageCount, currentPage, siblingCount, boundaryCount, }: BuildPaginationItemsParams): PaginationPageItem$1[];
|
|
51
|
+
declare function clampPage(page: number, pageCount: number): number;
|
|
52
|
+
|
|
53
|
+
type PaginationAppearance = NonNullable<VariantProps<typeof buttonVariants>["appearance"]>;
|
|
54
|
+
type PaginationSize = NonNullable<VariantProps<typeof buttonVariants>["size"]>;
|
|
55
|
+
type PaginationPageItem = PaginationPageItem$1;
|
|
56
|
+
type UsePaginationParams = {
|
|
57
|
+
pageCount: number;
|
|
58
|
+
page?: number;
|
|
59
|
+
defaultPage?: number;
|
|
60
|
+
siblingCount?: number;
|
|
61
|
+
boundaryCount?: number;
|
|
62
|
+
onPageChange?: (page: number) => void;
|
|
63
|
+
};
|
|
64
|
+
type UsePaginationResult = {
|
|
65
|
+
/** 1-based active page, clamped to `[1, pageCount]`. */
|
|
66
|
+
currentPage: number;
|
|
67
|
+
pageCount: number;
|
|
68
|
+
items: PaginationPageItem[];
|
|
69
|
+
setPage: (page: number) => void;
|
|
70
|
+
goPrev: () => void;
|
|
71
|
+
goNext: () => void;
|
|
72
|
+
canGoPrev: boolean;
|
|
73
|
+
canGoNext: boolean;
|
|
74
|
+
};
|
|
75
|
+
type PaginationProps = Omit<ComponentPropsWithoutRef<"nav">, "onChange"> & VariantProps<typeof buttonVariants> & {
|
|
76
|
+
pageCount: number;
|
|
77
|
+
page?: number;
|
|
78
|
+
defaultPage?: number;
|
|
79
|
+
onPageChange?: (page: number) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Number of page buttons to show on each side of the current page (the “middle” window).
|
|
82
|
+
* @defaultValue 1
|
|
83
|
+
*/
|
|
84
|
+
siblingCount?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Number of pages to keep visible at the start and end of the range.
|
|
87
|
+
* @defaultValue 1
|
|
88
|
+
*/
|
|
89
|
+
boundaryCount?: number;
|
|
90
|
+
showPrevNext?: boolean;
|
|
91
|
+
prevLabel?: string;
|
|
92
|
+
nextLabel?: string;
|
|
93
|
+
ellipsisLabel?: string;
|
|
94
|
+
/**
|
|
95
|
+
* When set, page controls render as anchors suitable for URL-based pagination.
|
|
96
|
+
*/
|
|
97
|
+
getPageHref?: (page: number) => string | undefined;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
declare function usePagination({ pageCount, page, defaultPage, siblingCount, boundaryCount, onPageChange, }: UsePaginationParams): UsePaginationResult;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Layout and chrome for the page list cluster. Appearance and size keys align with
|
|
104
|
+
* `components/ui/buttons/variants.ts` for consistent design-system tokens.
|
|
105
|
+
*/
|
|
106
|
+
declare const paginationListVariants: (props?: ({
|
|
107
|
+
appearance?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "glass" | "emerald" | "indigo" | "purple" | "pink" | "rose" | "sky" | "teal" | "yellow" | "orange" | "gray" | "amber" | "violet" | "gradient-blue" | "gradient-green" | "gradient-red" | "gradient-yellow" | "gradient-purple" | "gradient-teal" | "gradient-indigo" | "gradient-pink" | "gradient-orange" | null | undefined;
|
|
108
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "icon" | null | undefined;
|
|
109
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
110
|
+
declare const paginationEllipsisVariants: (props?: ({
|
|
111
|
+
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "10xl" | "icon" | null | undefined;
|
|
112
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
113
|
+
|
|
114
|
+
export { Pagination, type PaginationAppearance, type PaginationPageItem, type PaginationProps, type PaginationSize, type UsePaginationParams, type UsePaginationResult, buildPaginationItems, clampPage, paginationEllipsisVariants, paginationListVariants, usePagination };
|