@kumix/ui 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/agents/agent-activity/activity-row.d.ts +1 -1
- package/dist/components/agents/agent-activity/index.d.ts +2 -2
- package/dist/components/agents/agent-activity/index.d.ts.map +1 -1
- package/dist/components/agents/agent-activity/index.js +9 -3
- package/dist/components/agents/agent-activity/index.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +7 -39
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +11 -16
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/bottom-sheet.js +25 -7
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/combobox/content.d.ts +16 -0
- package/dist/components/motion/combobox/content.d.ts.map +1 -0
- package/dist/components/motion/combobox/content.js +91 -0
- package/dist/components/motion/combobox/content.js.map +1 -0
- package/dist/components/motion/combobox/context.d.ts +63 -0
- package/dist/components/motion/combobox/context.d.ts.map +1 -0
- package/dist/components/motion/combobox/context.js +235 -0
- package/dist/components/motion/combobox/context.js.map +1 -0
- package/dist/components/motion/combobox/list.d.ts +40 -0
- package/dist/components/motion/combobox/list.d.ts.map +1 -0
- package/dist/components/motion/combobox/list.js +143 -0
- package/dist/components/motion/combobox/list.js.map +1 -0
- package/dist/components/motion/combobox/trigger.d.ts +21 -0
- package/dist/components/motion/combobox/trigger.d.ts.map +1 -0
- package/dist/components/motion/combobox/trigger.js +115 -0
- package/dist/components/motion/combobox/trigger.js.map +1 -0
- package/dist/components/motion/combobox.d.ts +5 -0
- package/dist/components/motion/combobox.js +6 -0
- package/dist/components/motion/popover.d.ts.map +1 -1
- package/dist/components/motion/popover.js +22 -25
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/project-folder.d.ts +27 -0
- package/dist/components/motion/project-folder.d.ts.map +1 -0
- package/dist/components/motion/project-folder.js +310 -0
- package/dist/components/motion/project-folder.js.map +1 -0
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +2 -0
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/text-scramble.d.ts +17 -0
- package/dist/components/motion/text-scramble.d.ts.map +1 -0
- package/dist/components/motion/text-scramble.js +64 -0
- package/dist/components/motion/text-scramble.js.map +1 -0
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/filters.js +3 -3
- package/dist/components/reui/frame.d.ts +2 -2
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js +3 -3
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/ui/attachment.d.ts +2 -2
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/sidebar.d.ts +2 -2
- package/dist/components/ui/sidebar.js +2 -2
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/{types-j36vVGtZ.d.ts → types-kSZH1k8K.d.ts} +11 -1
- package/dist/{types-j36vVGtZ.d.ts.map → types-kSZH1k8K.d.ts.map} +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useHoverCapable } from "../../hooks/use-hover-capable.js";
|
|
3
|
+
import { SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
|
|
4
|
+
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
5
|
+
import { cn } from "@kumix/utils";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
|
|
8
|
+
import { X } from "lucide-react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
//#region src/components/motion/project-folder.tsx
|
|
11
|
+
const MAX_PREVIEWS = 5;
|
|
12
|
+
const FOCUSABLE_SELECTOR = [
|
|
13
|
+
"a[href]",
|
|
14
|
+
"button:not([disabled])",
|
|
15
|
+
"input:not([disabled])",
|
|
16
|
+
"select:not([disabled])",
|
|
17
|
+
"textarea:not([disabled])",
|
|
18
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
19
|
+
].join(",");
|
|
20
|
+
function getPreviewTransform(index, count) {
|
|
21
|
+
const offset = index - (count - 1) / 2;
|
|
22
|
+
const distance = Math.abs(offset);
|
|
23
|
+
const centerLift = Math.max(0, 2 - distance) * 8;
|
|
24
|
+
return {
|
|
25
|
+
x: offset * 44,
|
|
26
|
+
y: 8 - centerLift,
|
|
27
|
+
rotate: offset * 6,
|
|
28
|
+
scale: distance === 0 ? 1.04 : distance === 1 ? .95 : .88,
|
|
29
|
+
opacity: distance === 0 ? 1 : distance === 1 ? .78 : .58,
|
|
30
|
+
zIndex: 10 - distance
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function ProjectFolder({ title, description = "Updated recently", previews = [], count = previews.length, itemLabel = "file", open, defaultOpen = false, onOpenChange, expanded, defaultExpanded = false, onExpandedChange, onClick, disabled = false, ariaLabel, className }) {
|
|
34
|
+
const reduce = useReducedMotion();
|
|
35
|
+
const canHover = useHoverCapable();
|
|
36
|
+
const layoutGroupId = useId();
|
|
37
|
+
const dialogTitleId = `${layoutGroupId}-title`;
|
|
38
|
+
const hoveredRef = useRef(false);
|
|
39
|
+
const focusedRef = useRef(false);
|
|
40
|
+
const restoringFocusRef = useRef(false);
|
|
41
|
+
const folderButtonRef = useRef(null);
|
|
42
|
+
const closeButtonRef = useRef(null);
|
|
43
|
+
const dialogRef = useRef(null);
|
|
44
|
+
const [mounted, setMounted] = useState(false);
|
|
45
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
46
|
+
const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
|
|
47
|
+
const [isClosing, setIsClosing] = useState(false);
|
|
48
|
+
const openControlled = open !== void 0;
|
|
49
|
+
const expandedControlled = expanded !== void 0;
|
|
50
|
+
const isExpanded = expanded ?? internalExpanded;
|
|
51
|
+
const isOpen = (open ?? internalOpen) || isExpanded;
|
|
52
|
+
const previewItems = previews.slice(0, MAX_PREVIEWS);
|
|
53
|
+
const transition = reduce ? { duration: 0 } : SPRING_LAYOUT;
|
|
54
|
+
const countText = `${count} ${itemLabel}${count === 1 ? "" : "s"}`;
|
|
55
|
+
const setOpen = useCallback((next) => {
|
|
56
|
+
if (disabled) return;
|
|
57
|
+
if (!openControlled) setInternalOpen(next);
|
|
58
|
+
onOpenChange?.(next);
|
|
59
|
+
}, [
|
|
60
|
+
disabled,
|
|
61
|
+
onOpenChange,
|
|
62
|
+
openControlled
|
|
63
|
+
]);
|
|
64
|
+
const setExpanded = useCallback((next) => {
|
|
65
|
+
if (disabled || previewItems.length === 0) return;
|
|
66
|
+
if (!expandedControlled) setInternalExpanded(next);
|
|
67
|
+
onExpandedChange?.(next);
|
|
68
|
+
}, [
|
|
69
|
+
disabled,
|
|
70
|
+
expandedControlled,
|
|
71
|
+
onExpandedChange,
|
|
72
|
+
previewItems.length
|
|
73
|
+
]);
|
|
74
|
+
const finishClose = useCallback(() => {
|
|
75
|
+
setIsClosing(false);
|
|
76
|
+
restoringFocusRef.current = true;
|
|
77
|
+
requestAnimationFrame(() => folderButtonRef.current?.focus());
|
|
78
|
+
}, []);
|
|
79
|
+
const closeOverlay = useCallback(() => {
|
|
80
|
+
setIsClosing(true);
|
|
81
|
+
setOpen(false);
|
|
82
|
+
setExpanded(false);
|
|
83
|
+
}, [setExpanded, setOpen]);
|
|
84
|
+
useEffect(() => setMounted(true), []);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (reduce && isClosing) finishClose();
|
|
87
|
+
}, [
|
|
88
|
+
finishClose,
|
|
89
|
+
isClosing,
|
|
90
|
+
reduce
|
|
91
|
+
]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!isExpanded) return;
|
|
94
|
+
const previousOverflow = document.body.style.overflow;
|
|
95
|
+
const focusFrame = requestAnimationFrame(() => closeButtonRef.current?.focus());
|
|
96
|
+
document.body.style.overflow = "hidden";
|
|
97
|
+
const handleKeyDown = (event) => {
|
|
98
|
+
if (event.key === "Escape") {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
closeOverlay();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (event.key !== "Tab" || !dialogRef.current) return;
|
|
104
|
+
const focusable = Array.from(dialogRef.current.querySelectorAll(FOCUSABLE_SELECTOR)).filter((element) => element.tabIndex >= 0);
|
|
105
|
+
const first = focusable[0];
|
|
106
|
+
const last = focusable.at(-1);
|
|
107
|
+
if (!first || !last) return;
|
|
108
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
last.focus();
|
|
111
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
first.focus();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
117
|
+
return () => {
|
|
118
|
+
cancelAnimationFrame(focusFrame);
|
|
119
|
+
document.body.style.overflow = previousOverflow;
|
|
120
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
121
|
+
};
|
|
122
|
+
}, [closeOverlay, isExpanded]);
|
|
123
|
+
const handleFolderClick = () => {
|
|
124
|
+
setIsClosing(false);
|
|
125
|
+
setExpanded(true);
|
|
126
|
+
setOpen(true);
|
|
127
|
+
onClick?.();
|
|
128
|
+
};
|
|
129
|
+
const overlay = isExpanded || isClosing ? /* @__PURE__ */ jsxs("div", {
|
|
130
|
+
ref: dialogRef,
|
|
131
|
+
role: "dialog",
|
|
132
|
+
"aria-modal": "true",
|
|
133
|
+
"aria-labelledby": dialogTitleId,
|
|
134
|
+
"aria-hidden": isExpanded ? void 0 : "true",
|
|
135
|
+
className: cn("fixed inset-0 z-50 flex items-start justify-center overflow-y-auto sm:items-center", isClosing && "pointer-events-none"),
|
|
136
|
+
children: [/* @__PURE__ */ jsx(AnimatePresence, {
|
|
137
|
+
initial: false,
|
|
138
|
+
children: isExpanded ? /* @__PURE__ */ jsx(motion.button, {
|
|
139
|
+
type: "button",
|
|
140
|
+
tabIndex: -1,
|
|
141
|
+
"aria-label": "Close file overlay",
|
|
142
|
+
onClick: closeOverlay,
|
|
143
|
+
initial: { opacity: 0 },
|
|
144
|
+
animate: { opacity: 1 },
|
|
145
|
+
exit: { opacity: 0 },
|
|
146
|
+
transition: reduce ? { duration: 0 } : { duration: .18 },
|
|
147
|
+
className: "absolute inset-0 cursor-default bg-background/80 backdrop-blur-xl"
|
|
148
|
+
}, "project-files-backdrop") : null
|
|
149
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
150
|
+
className: "relative z-10 w-full max-w-5xl px-6 py-8",
|
|
151
|
+
children: [/* @__PURE__ */ jsx(AnimatePresence, {
|
|
152
|
+
initial: false,
|
|
153
|
+
children: isExpanded ? /* @__PURE__ */ jsxs(motion.div, {
|
|
154
|
+
initial: {
|
|
155
|
+
opacity: 0,
|
|
156
|
+
y: reduce ? 0 : 8
|
|
157
|
+
},
|
|
158
|
+
animate: {
|
|
159
|
+
opacity: 1,
|
|
160
|
+
y: 0
|
|
161
|
+
},
|
|
162
|
+
exit: {
|
|
163
|
+
opacity: 0,
|
|
164
|
+
y: reduce ? 0 : -8
|
|
165
|
+
},
|
|
166
|
+
transition: reduce ? { duration: 0 } : { duration: .18 },
|
|
167
|
+
className: "mb-6 flex items-center justify-between gap-4",
|
|
168
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
169
|
+
id: dialogTitleId,
|
|
170
|
+
className: "font-medium text-foreground text-xl",
|
|
171
|
+
children: title
|
|
172
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
173
|
+
className: "mt-1 text-muted-foreground text-sm",
|
|
174
|
+
children: countText
|
|
175
|
+
})] }), /* @__PURE__ */ jsx("button", {
|
|
176
|
+
ref: closeButtonRef,
|
|
177
|
+
type: "button",
|
|
178
|
+
onClick: closeOverlay,
|
|
179
|
+
"aria-label": `Close ${title}`,
|
|
180
|
+
className: "flex size-10 items-center justify-center rounded-full border border-foreground/10 bg-background/50 text-muted-foreground backdrop-blur-xl transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
181
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
182
|
+
className: "size-4",
|
|
183
|
+
"aria-hidden": "true"
|
|
184
|
+
})
|
|
185
|
+
})]
|
|
186
|
+
}, "project-files-header") : null
|
|
187
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
188
|
+
className: "grid grid-cols-2 place-items-center gap-3 sm:grid-cols-3 lg:grid-cols-5",
|
|
189
|
+
children: isExpanded ? previewItems.map((preview) => /* @__PURE__ */ jsx(motion.div, {
|
|
190
|
+
layoutId: `file-${preview.id}`,
|
|
191
|
+
transition,
|
|
192
|
+
className: "aspect-3/4 w-full max-w-40 overflow-hidden rounded-xl border border-foreground/10 bg-background/50 backdrop-blur-xl",
|
|
193
|
+
children: preview.content
|
|
194
|
+
}, preview.id)) : null
|
|
195
|
+
})]
|
|
196
|
+
})]
|
|
197
|
+
}) : null;
|
|
198
|
+
return /* @__PURE__ */ jsxs(LayoutGroup, {
|
|
199
|
+
id: layoutGroupId,
|
|
200
|
+
children: [/* @__PURE__ */ jsxs(motion.button, {
|
|
201
|
+
ref: folderButtonRef,
|
|
202
|
+
type: "button",
|
|
203
|
+
disabled,
|
|
204
|
+
"aria-label": ariaLabel,
|
|
205
|
+
"aria-haspopup": "dialog",
|
|
206
|
+
"aria-expanded": isExpanded,
|
|
207
|
+
"data-open": isOpen ? "true" : "false",
|
|
208
|
+
"data-expanded": isExpanded ? "true" : "false",
|
|
209
|
+
tabIndex: isExpanded ? -1 : void 0,
|
|
210
|
+
onPointerEnter: () => {
|
|
211
|
+
if (!canHover) return;
|
|
212
|
+
hoveredRef.current = true;
|
|
213
|
+
setOpen(true);
|
|
214
|
+
},
|
|
215
|
+
onPointerLeave: () => {
|
|
216
|
+
if (!canHover) return;
|
|
217
|
+
hoveredRef.current = false;
|
|
218
|
+
if (!isExpanded && !isClosing) setOpen(focusedRef.current);
|
|
219
|
+
},
|
|
220
|
+
onFocus: () => {
|
|
221
|
+
if (restoringFocusRef.current) {
|
|
222
|
+
restoringFocusRef.current = false;
|
|
223
|
+
focusedRef.current = false;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
focusedRef.current = true;
|
|
227
|
+
setOpen(true);
|
|
228
|
+
},
|
|
229
|
+
onBlur: () => {
|
|
230
|
+
focusedRef.current = false;
|
|
231
|
+
if (!isExpanded && !isClosing) setOpen(hoveredRef.current);
|
|
232
|
+
},
|
|
233
|
+
onClick: handleFolderClick,
|
|
234
|
+
whileTap: reduce || disabled ? void 0 : { scale: .98 },
|
|
235
|
+
transition: reduce ? { duration: 0 } : SPRING_PRESS,
|
|
236
|
+
className: cn("perspective-[1200px] relative block h-56 w-72 select-none rounded-2xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
239
|
+
"aria-hidden": "true",
|
|
240
|
+
animate: { rotateX: isOpen && !reduce ? 15 : 0 },
|
|
241
|
+
transition,
|
|
242
|
+
className: "absolute inset-0 origin-[center_bottom] rounded-2xl border border-foreground/10 bg-background/25 backdrop-blur-xl"
|
|
243
|
+
}),
|
|
244
|
+
/* @__PURE__ */ jsx("span", {
|
|
245
|
+
"aria-hidden": "true",
|
|
246
|
+
className: "pointer-events-none absolute inset-0",
|
|
247
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
248
|
+
className: "absolute top-0 left-1/2 block h-0 w-0",
|
|
249
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
250
|
+
initial: false,
|
|
251
|
+
children: !isExpanded ? previewItems.map((preview, index) => {
|
|
252
|
+
const opened = getPreviewTransform(index, previewItems.length);
|
|
253
|
+
return /* @__PURE__ */ jsx(motion.span, {
|
|
254
|
+
layoutId: `file-${preview.id}`,
|
|
255
|
+
initial: false,
|
|
256
|
+
animate: isOpen && !reduce ? {
|
|
257
|
+
x: opened.x * 1.4,
|
|
258
|
+
y: opened.y - 8,
|
|
259
|
+
rotate: opened.rotate * 1.3,
|
|
260
|
+
scale: opened.scale * 1.02,
|
|
261
|
+
opacity: Math.min(1, opened.opacity + .18)
|
|
262
|
+
} : {
|
|
263
|
+
x: opened.x,
|
|
264
|
+
y: opened.y,
|
|
265
|
+
rotate: opened.rotate,
|
|
266
|
+
scale: opened.scale,
|
|
267
|
+
opacity: opened.opacity
|
|
268
|
+
},
|
|
269
|
+
transition,
|
|
270
|
+
onLayoutAnimationComplete: () => {
|
|
271
|
+
if (isClosing && index === 0) finishClose();
|
|
272
|
+
},
|
|
273
|
+
className: "absolute top-0 left-0 -ml-12 block h-40 w-24 overflow-hidden rounded-lg border border-foreground/10 bg-background/45 backdrop-blur-lg",
|
|
274
|
+
style: { zIndex: opened.zIndex },
|
|
275
|
+
children: preview.content
|
|
276
|
+
}, preview.id);
|
|
277
|
+
}) : null
|
|
278
|
+
})
|
|
279
|
+
})
|
|
280
|
+
}),
|
|
281
|
+
/* @__PURE__ */ jsxs(motion.span, {
|
|
282
|
+
initial: false,
|
|
283
|
+
animate: { rotateX: isOpen && !reduce ? -25 : 0 },
|
|
284
|
+
transition,
|
|
285
|
+
className: "backface-hidden absolute inset-x-0 bottom-0 z-20 origin-[center_bottom] overflow-hidden rounded-2xl border border-foreground/10 bg-background/60 backdrop-blur-2xl",
|
|
286
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
287
|
+
className: "flex h-16 items-center px-4",
|
|
288
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
289
|
+
className: "line-clamp-2 font-medium text-foreground text-xl leading-tight",
|
|
290
|
+
children: title
|
|
291
|
+
})
|
|
292
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
293
|
+
className: "flex h-12 items-center justify-between gap-3 border-foreground/10 border-t px-4",
|
|
294
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
295
|
+
className: "shrink-0 font-medium text-foreground/70 text-sm",
|
|
296
|
+
children: countText
|
|
297
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
298
|
+
className: "truncate text-muted-foreground text-sm",
|
|
299
|
+
children: description
|
|
300
|
+
})]
|
|
301
|
+
})]
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
}), mounted ? createPortal(overlay, document.body) : null]
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
export { ProjectFolder };
|
|
309
|
+
|
|
310
|
+
//# sourceMappingURL=project-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-folder.js","names":[],"sources":["../../../src/components/motion/project-folder.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { X } from \"lucide-react\";\nimport {\n AnimatePresence,\n LayoutGroup,\n motion,\n type Transition,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useHoverCapable } from \"../../hooks/use-hover-capable\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"../../lib/ease\";\n\nexport type ProjectFolderPreview = {\n id: string;\n content: ReactNode;\n};\n\nexport interface ProjectFolderProps {\n title: string;\n description?: string;\n previews?: ProjectFolderPreview[];\n count?: number;\n itemLabel?: string;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n expanded?: boolean;\n defaultExpanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n onClick?: () => void;\n disabled?: boolean;\n ariaLabel?: string;\n className?: string;\n}\n\nconst MAX_PREVIEWS = 5;\nconst FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(\",\");\n\nfunction getPreviewTransform(index: number, count: number) {\n const offset = index - (count - 1) / 2;\n const distance = Math.abs(offset);\n const centerLift = Math.max(0, 2 - distance) * 8;\n\n return {\n x: offset * 44,\n y: 8 - centerLift,\n rotate: offset * 6,\n scale: distance === 0 ? 1.04 : distance === 1 ? 0.95 : 0.88,\n opacity: distance === 0 ? 1 : distance === 1 ? 0.78 : 0.58,\n zIndex: 10 - distance,\n };\n}\n\nexport function ProjectFolder({\n title,\n description = \"Updated recently\",\n previews = [],\n count = previews.length,\n itemLabel = \"file\",\n open,\n defaultOpen = false,\n onOpenChange,\n expanded,\n defaultExpanded = false,\n onExpandedChange,\n onClick,\n disabled = false,\n ariaLabel,\n className,\n}: ProjectFolderProps) {\n const reduce = useReducedMotion();\n const canHover = useHoverCapable();\n const layoutGroupId = useId();\n const dialogTitleId = `${layoutGroupId}-title`;\n const hoveredRef = useRef(false);\n const focusedRef = useRef(false);\n const restoringFocusRef = useRef(false);\n const folderButtonRef = useRef<HTMLButtonElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n const [mounted, setMounted] = useState(false);\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);\n const [isClosing, setIsClosing] = useState(false);\n const openControlled = open !== undefined;\n const expandedControlled = expanded !== undefined;\n const isExpanded = expanded ?? internalExpanded;\n const isOpen = (open ?? internalOpen) || isExpanded;\n const previewItems = previews.slice(0, MAX_PREVIEWS);\n const transition: Transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n const countText = `${count} ${itemLabel}${count === 1 ? \"\" : \"s\"}`;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (disabled) return;\n if (!openControlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [disabled, onOpenChange, openControlled],\n );\n\n const setExpanded = useCallback(\n (next: boolean) => {\n if (disabled || previewItems.length === 0) return;\n if (!expandedControlled) setInternalExpanded(next);\n onExpandedChange?.(next);\n },\n [disabled, expandedControlled, onExpandedChange, previewItems.length],\n );\n\n const finishClose = useCallback(() => {\n setIsClosing(false);\n restoringFocusRef.current = true;\n requestAnimationFrame(() => folderButtonRef.current?.focus());\n }, []);\n\n const closeOverlay = useCallback(() => {\n setIsClosing(true);\n setOpen(false);\n setExpanded(false);\n }, [setExpanded, setOpen]);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (reduce && isClosing) finishClose();\n }, [finishClose, isClosing, reduce]);\n\n useEffect(() => {\n if (!isExpanded) return;\n\n const previousOverflow = document.body.style.overflow;\n const focusFrame = requestAnimationFrame(() => closeButtonRef.current?.focus());\n\n document.body.style.overflow = \"hidden\";\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeOverlay();\n return;\n }\n if (event.key !== \"Tab\" || !dialogRef.current) return;\n\n const focusable = Array.from(\n dialogRef.current.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR),\n ).filter((element) => element.tabIndex >= 0);\n const first = focusable[0];\n const last = focusable.at(-1);\n if (!first || !last) return;\n\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => {\n cancelAnimationFrame(focusFrame);\n document.body.style.overflow = previousOverflow;\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [closeOverlay, isExpanded]);\n\n const handleFolderClick = () => {\n setIsClosing(false);\n setExpanded(true);\n setOpen(true);\n onClick?.();\n };\n\n const overlay =\n isExpanded || isClosing ? (\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={dialogTitleId}\n aria-hidden={isExpanded ? undefined : \"true\"}\n className={cn(\n \"fixed inset-0 z-50 flex items-start justify-center overflow-y-auto sm:items-center\",\n isClosing && \"pointer-events-none\",\n )}\n >\n <AnimatePresence initial={false}>\n {isExpanded ? (\n <motion.button\n key=\"project-files-backdrop\"\n type=\"button\"\n tabIndex={-1}\n aria-label=\"Close file overlay\"\n onClick={closeOverlay}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18 }}\n className=\"absolute inset-0 cursor-default bg-background/80 backdrop-blur-xl\"\n />\n ) : null}\n </AnimatePresence>\n\n <div className=\"relative z-10 w-full max-w-5xl px-6 py-8\">\n <AnimatePresence initial={false}>\n {isExpanded ? (\n <motion.div\n key=\"project-files-header\"\n initial={{ opacity: 0, y: reduce ? 0 : 8 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: reduce ? 0 : -8 }}\n transition={reduce ? { duration: 0 } : { duration: 0.18 }}\n className=\"mb-6 flex items-center justify-between gap-4\"\n >\n <div>\n <h2 id={dialogTitleId} className=\"font-medium text-foreground text-xl\">\n {title}\n </h2>\n <p className=\"mt-1 text-muted-foreground text-sm\">{countText}</p>\n </div>\n <button\n ref={closeButtonRef}\n type=\"button\"\n onClick={closeOverlay}\n aria-label={`Close ${title}`}\n className=\"flex size-10 items-center justify-center rounded-full border border-foreground/10 bg-background/50 text-muted-foreground backdrop-blur-xl transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </button>\n </motion.div>\n ) : null}\n </AnimatePresence>\n\n <div className=\"grid grid-cols-2 place-items-center gap-3 sm:grid-cols-3 lg:grid-cols-5\">\n {isExpanded\n ? previewItems.map((preview) => (\n <motion.div\n key={preview.id}\n layoutId={`file-${preview.id}`}\n transition={transition}\n className=\"aspect-3/4 w-full max-w-40 overflow-hidden rounded-xl border border-foreground/10 bg-background/50 backdrop-blur-xl\"\n >\n {preview.content}\n </motion.div>\n ))\n : null}\n </div>\n </div>\n </div>\n ) : null;\n\n return (\n <LayoutGroup id={layoutGroupId}>\n <motion.button\n ref={folderButtonRef}\n type=\"button\"\n disabled={disabled}\n aria-label={ariaLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={isExpanded}\n data-open={isOpen ? \"true\" : \"false\"}\n data-expanded={isExpanded ? \"true\" : \"false\"}\n tabIndex={isExpanded ? -1 : undefined}\n onPointerEnter={() => {\n if (!canHover) return;\n hoveredRef.current = true;\n setOpen(true);\n }}\n onPointerLeave={() => {\n if (!canHover) return;\n hoveredRef.current = false;\n if (!isExpanded && !isClosing) setOpen(focusedRef.current);\n }}\n onFocus={() => {\n if (restoringFocusRef.current) {\n restoringFocusRef.current = false;\n focusedRef.current = false;\n return;\n }\n focusedRef.current = true;\n setOpen(true);\n }}\n onBlur={() => {\n focusedRef.current = false;\n if (!isExpanded && !isClosing) setOpen(hoveredRef.current);\n }}\n onClick={handleFolderClick}\n whileTap={reduce || disabled ? undefined : { scale: 0.98 }}\n transition={reduce ? { duration: 0 } : SPRING_PRESS}\n className={cn(\n \"perspective-[1200px] relative block h-56 w-72 select-none rounded-2xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n >\n <motion.span\n aria-hidden=\"true\"\n animate={{ rotateX: isOpen && !reduce ? 15 : 0 }}\n transition={transition}\n className=\"absolute inset-0 origin-[center_bottom] rounded-2xl border border-foreground/10 bg-background/25 backdrop-blur-xl\"\n />\n\n <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\">\n <span className=\"absolute top-0 left-1/2 block h-0 w-0\">\n <AnimatePresence initial={false}>\n {!isExpanded\n ? previewItems.map((preview, index) => {\n const opened = getPreviewTransform(index, previewItems.length);\n return (\n <motion.span\n key={preview.id}\n layoutId={`file-${preview.id}`}\n initial={false}\n animate={\n isOpen && !reduce\n ? {\n x: opened.x * 1.4,\n y: opened.y - 8,\n rotate: opened.rotate * 1.3,\n scale: opened.scale * 1.02,\n opacity: Math.min(1, opened.opacity + 0.18),\n }\n : {\n x: opened.x,\n y: opened.y,\n rotate: opened.rotate,\n scale: opened.scale,\n opacity: opened.opacity,\n }\n }\n transition={transition}\n onLayoutAnimationComplete={() => {\n if (isClosing && index === 0) finishClose();\n }}\n className=\"absolute top-0 left-0 -ml-12 block h-40 w-24 overflow-hidden rounded-lg border border-foreground/10 bg-background/45 backdrop-blur-lg\"\n style={{ zIndex: opened.zIndex }}\n >\n {preview.content}\n </motion.span>\n );\n })\n : null}\n </AnimatePresence>\n </span>\n </span>\n\n <motion.span\n initial={false}\n animate={{ rotateX: isOpen && !reduce ? -25 : 0 }}\n transition={transition}\n className=\"backface-hidden absolute inset-x-0 bottom-0 z-20 origin-[center_bottom] overflow-hidden rounded-2xl border border-foreground/10 bg-background/60 backdrop-blur-2xl\"\n >\n <span className=\"flex h-16 items-center px-4\">\n <span className=\"line-clamp-2 font-medium text-foreground text-xl leading-tight\">\n {title}\n </span>\n </span>\n <span className=\"flex h-12 items-center justify-between gap-3 border-foreground/10 border-t px-4\">\n <span className=\"shrink-0 font-medium text-foreground/70 text-sm\">{countText}</span>\n <span className=\"truncate text-muted-foreground text-sm\">{description}</span>\n </span>\n </motion.span>\n </motion.button>\n\n {mounted ? createPortal(overlay, document.body) : null}\n </LayoutGroup>\n );\n}\n"],"mappings":";;;;;;;;;;AAwCA,MAAM,eAAe;AACrB,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;AAEV,SAAS,oBAAoB,OAAe,OAAe;CACzD,MAAM,SAAS,SAAS,QAAQ,KAAK;CACrC,MAAM,WAAW,KAAK,IAAI,MAAM;CAChC,MAAM,aAAa,KAAK,IAAI,GAAG,IAAI,QAAQ,IAAI;CAE/C,OAAO;EACL,GAAG,SAAS;EACZ,GAAG,IAAI;EACP,QAAQ,SAAS;EACjB,OAAO,aAAa,IAAI,OAAO,aAAa,IAAI,MAAO;EACvD,SAAS,aAAa,IAAI,IAAI,aAAa,IAAI,MAAO;EACtD,QAAQ,KAAK;CACf;AACF;AAEA,SAAgB,cAAc,EAC5B,OACA,cAAc,oBACd,WAAW,CAAC,GACZ,QAAQ,SAAS,QACjB,YAAY,QACZ,MACA,cAAc,OACd,cACA,UACA,kBAAkB,OAClB,kBACA,SACA,WAAW,OACX,WACA,aACqB;CACrB,MAAM,SAAS,iBAAiB;CAChC,MAAM,WAAW,gBAAgB;CACjC,MAAM,gBAAgB,MAAM;CAC5B,MAAM,gBAAgB,GAAG,cAAc;CACvC,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,aAAa,OAAO,KAAK;CAC/B,MAAM,oBAAoB,OAAO,KAAK;CACtC,MAAM,kBAAkB,OAA0B,IAAI;CACtD,MAAM,iBAAiB,OAA0B,IAAI;CACrD,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,CAAC,SAA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GAAG,OAAO;UACV,QAAQ,OAAO;UACf,OAAO,OAAO;UACd,SAAS,OAAO;SAClB;SAEM;SACZ,iCAAiC;UAC/B,IAAI,aAAa,UAAU,GAAG,YAAY;SAC5C;SACA,WAAU;SACV,OAAO,EAAE,QAAQ,OAAO,OAAO;SAE9B,UAAA,QAAQ;QACE,GA5BN,QAAQ,EA4BF;OAEjB,CAAC,IACD;MACW,CAAA;KACb,CAAA;IACF,CAAA;IAEN,qBAAC,OAAO,MAAR;KACE,SAAS;KACT,SAAS,EAAE,SAAS,UAAU,CAAC,SAAS,MAAM,EAAE;KACpC;KACZ,WAAU;KAJZ,UAAA,CAME,oBAAC,QAAD;MAAM,WAAU;MACd,UAAA,oBAAC,QAAD;OAAM,WAAU;OACb,UAAA;MACG,CAAA;KACF,CAAA,GACN,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACE,oBAAC,QAAD;OAAM,WAAU;OAAmD,UAAA;MAAgB,CAAA,GACnF,oBAAC,QAAD;OAAM,WAAU;OAA0C,UAAA;MAAkB,CAAA,CACxE;KACK,CAAA,CAAA;;GACA;EAEd,CAAA,GAAA,UAAU,aAAa,SAAS,SAAS,IAAI,IAAI,IACvC;;AAEjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","names":[],"sources":["../../../src/components/motion/tabs.tsx"],"mappings":";;KAgBK;iBA0BW,OACd,cACA,OACA,eACA,SACA,UACA;EAEA;EACA;EACA,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV;oBACD,IAAA;iBAsCe,WAAW,UAAU;EAAe,UAAU;EAAW;oBAAoB,IAAA;iBAS7E,cACd,OACA,UACA,WACA;EAEA;EACA,UAAU;EACV;EACA;oBACD,IAAA;
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","names":[],"sources":["../../../src/components/motion/tabs.tsx"],"mappings":";;KAgBK;iBA0BW,OACd,cACA,OACA,eACA,SACA,UACA;EAEA;EACA;EACA,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV;oBACD,IAAA;iBAsCe,WAAW,UAAU;EAAe,UAAU;EAAW;oBAAoB,IAAA;iBAS7E,cACd,OACA,UACA,WACA;EAEA;EACA,UAAU;EACV;EACA;oBACD,IAAA;iBA4De,cACd,OACA,UACA;EAEA;EACA,UAAU;EACV;oBACD,IAAA"}
|
|
@@ -74,6 +74,7 @@ function TabsTrigger({ value, children, className, indicatorClassName }) {
|
|
|
74
74
|
className: cn("relative isolate -mb-px inline-flex min-h-[44px] items-center px-3 pt-1 pb-2.5 font-medium text-sm transition-colors", active ? "text-foreground" : "text-muted-foreground hover:text-foreground", className),
|
|
75
75
|
children: [children, active ? /* @__PURE__ */ jsx(motion.span, {
|
|
76
76
|
layoutId,
|
|
77
|
+
layout: "position",
|
|
77
78
|
className: cn("absolute right-0 -bottom-px left-0 h-px bg-primary", indicatorClassName)
|
|
78
79
|
}) : null]
|
|
79
80
|
});
|
|
@@ -82,6 +83,7 @@ function TabsTrigger({ value, children, className, indicatorClassName }) {
|
|
|
82
83
|
className: "relative",
|
|
83
84
|
children: [active ? /* @__PURE__ */ jsx(motion.span, {
|
|
84
85
|
layoutId,
|
|
86
|
+
layout: "position",
|
|
85
87
|
style: { borderRadius: variant === "pill" ? 9999 : 8 },
|
|
86
88
|
className: cn("absolute inset-0 bg-primary", radius, indicatorClassName)
|
|
87
89
|
}) : null, /* @__PURE__ */ jsx("button", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/motion/tabs.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { MotionConfig, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\ntype Variant = \"pill\" | \"underline\" | \"segment\";\n\ntype Ctx = {\n value: string;\n setValue: (v: string) => void;\n layoutId: string;\n variant: Variant;\n};\n\nconst TabsCtx = createContext<Ctx | null>(null);\n\nfunction useTabs() {\n const ctx = useContext(TabsCtx);\n if (!ctx) throw new Error(\"Tabs.* must be used inside <Tabs>\");\n return ctx;\n}\n\n// Weighty spring for the active-tab indicator: a touch of overshoot so it\n// settles with life instead of snapping.\nconst transition: Transition = {\n type: \"spring\",\n stiffness: 170,\n damping: 24,\n mass: 1.2,\n};\n\nexport function Tabs({\n defaultValue,\n value,\n onValueChange,\n variant = \"pill\",\n children,\n className,\n}: {\n defaultValue?: string;\n value?: string;\n onValueChange?: (v: string) => void;\n variant?: Variant;\n children: ReactNode;\n className?: string;\n}) {\n const [internal, setInternal] = useState(defaultValue ?? \"\");\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (v: string) => {\n if (!controlled) setInternal(v);\n onValueChange?.(v);\n },\n [controlled, onValueChange],\n );\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId, variant }),\n [current, layoutId, setValue, variant],\n );\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : transition}>\n <TabsCtx.Provider value={contextValue}>\n {/* layoutRoot: the indicator's layoutId measures in page coordinates, so\n inside fixed/scrolled containers it would replay scroll offsets as\n movement. The pill only ever travels within the list, so scoping\n projection to the Tabs wrapper is always correct. */}\n <motion.div layoutRoot className={className}>\n {children}\n </motion.div>\n </TabsCtx.Provider>\n </MotionConfig>\n );\n}\n\nconst listClasses: Record<Variant, string> = {\n pill: \"inline-flex items-center gap-1 rounded-full bg-card p-1\",\n underline: \"inline-flex items-center gap-1 border-b border-border\",\n segment: \"inline-flex items-center gap-0 rounded-lg bg-card p-0.5\",\n};\n\nexport function TabsList({ children, className }: { children: ReactNode; className?: string }) {\n const { variant } = useTabs();\n return (\n <div role=\"tablist\" className={cn(listClasses[variant], className)}>\n {children}\n </div>\n );\n}\n\nexport function TabsTrigger({\n value,\n children,\n className,\n indicatorClassName,\n}: {\n value: string;\n children: ReactNode;\n className?: string;\n indicatorClassName?: string;\n}) {\n const { value: current, setValue, layoutId, variant } = useTabs();\n const active = current === value;\n\n if (variant === \"underline\") {\n return (\n <button\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setValue(value)}\n className={cn(\n \"relative isolate -mb-px inline-flex min-h-[44px] items-center px-3 pt-1 pb-2.5 font-medium text-sm transition-colors\",\n active ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n className,\n )}\n >\n {children}\n {active ? (\n <motion.span\n layoutId={layoutId}\n className={cn(\"absolute right-0 -bottom-px left-0 h-px bg-primary\", indicatorClassName)}\n />\n ) : null}\n </button>\n );\n }\n\n const radius = variant === \"pill\" ? \"rounded-full\" : \"rounded-md\";\n\n return (\n <div className=\"relative\">\n {active ? (\n <motion.span\n layoutId={layoutId}\n style={{ borderRadius: variant === \"pill\" ? 9999 : 8 }}\n className={cn(\"absolute inset-0 bg-primary\", radius, indicatorClassName)}\n />\n ) : null}\n <button\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setValue(value)}\n className={cn(\n \"relative z-10 inline-flex items-center justify-center whitespace-nowrap bg-transparent px-3.5 py-1.5 font-medium text-sm outline-none\",\n \"transition-colors\",\n active ? \"text-primary-foreground\" : \"text-muted-foreground hover:text-foreground\",\n radius,\n className,\n )}\n >\n {children}\n </button>\n </div>\n );\n}\n\nexport function TabsContent({\n value,\n children,\n className,\n}: {\n value: string;\n children: ReactNode;\n className?: string;\n}) {\n const { value: current } = useTabs();\n const reduce = useReducedMotion();\n const active = current === value;\n // Inactive panels stay mounted but hidden, so their content (e.g. source\n // code) is present in the server-rendered HTML for crawlers and assistive\n // tech, instead of being dropped from the DOM.\n if (!active) {\n return (\n <div hidden className={className}>\n {children}\n </div>\n );\n }\n return (\n <motion.div\n key={value}\n initial={{ opacity: 0, y: reduce ? 0 : 4 }}\n animate={{ opacity: 1, y: 0 }}\n transition={{ duration: 0.18, ease: EAS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,MAAM,EAAE,OAAO,SAAS,UAAU,UAAU,YAAY,QAAQ;CAChE,MAAM,SAAS,YAAY;CAE3B,IAAI,YAAY,aACd,OACE,qBAAC,UAAD;EACE,MAAK;EACL,MAAK;EACL,iBAAe;EACf,eAAe,SAAS,KAAK;EAC7B,WAAW,GACT,wHACA,SAAS,oBAAoB,+CAC7B,SACF;EATF,UAAA,CAWG,UACA,SACC,oBAAC,OAAO,MAAR;GACY;GACV,WAAW,GAAG,sDAAsD,kBAAkB;EACvF,CAAA,IACC,IACE;;CAIZ,MAAM,SAAS,YAAY,SAAS,iBAAiB;CAErD,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,SACC,oBAAC,OAAO,MAAR;GACY;GACV,OAAO,EAAE,cAAc,YAAY,SAAS,OAAO,EAAE;GACrD,WAAW,GAAG,+BAA+B,QAAQ,kBAAkB;EACxE,CAAA,IACC,MACJ,oBAAC,UAAD;GACE,MAAK;GACL,MAAK;GACL,iBAAe;GACf,eAAe,SAAS,KAAK;GAC7B,WAAW,GACT,yIACA,qBACA,SAAS,4BAA4B,+CACrC,QACA,SACF;GAEC;EACK,CAAA,CACL;;AAET;AAEA,SAAgB,YAAY,EAC1B,OACA,UACA,aAKC;CACD,MAAM,EAAE,OAAO,YAAY,QAAQ;CACnC,MAAM,SAAS,iBAAiB;CAKhC,IAAI,EAJW,YAAY,QAKzB,OACE,oBAAC,OAAD;EAAK,QAAA;EAAkB;EACpB;CACE,CAAA;CAGT,OACE,oBAAC,OAAO,KAAR;EAEE,SAAS;GAAE,SAAS;GAAG,GAAG,SAAS,IAAI;EAAE;EACzC,SAAS;GAAE,SAAS;GAAG,GAAG;EAAE;EAC5B,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;EAC7C,WAAW,GAAG,QAAQ,SAAS;EAE9B;CACS,GAPL,KAOK;AAEhB"}
|
|
1
|
+
{"version":3,"file":"tabs.js","names":[],"sources":["../../../src/components/motion/tabs.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { MotionConfig, motion, type Transition, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\ntype Variant = \"pill\" | \"underline\" | \"segment\";\n\ntype Ctx = {\n value: string;\n setValue: (v: string) => void;\n layoutId: string;\n variant: Variant;\n};\n\nconst TabsCtx = createContext<Ctx | null>(null);\n\nfunction useTabs() {\n const ctx = useContext(TabsCtx);\n if (!ctx) throw new Error(\"Tabs.* must be used inside <Tabs>\");\n return ctx;\n}\n\n// Weighty spring for the active-tab indicator: a touch of overshoot so it\n// settles with life instead of snapping.\nconst transition: Transition = {\n type: \"spring\",\n stiffness: 170,\n damping: 24,\n mass: 1.2,\n};\n\nexport function Tabs({\n defaultValue,\n value,\n onValueChange,\n variant = \"pill\",\n children,\n className,\n}: {\n defaultValue?: string;\n value?: string;\n onValueChange?: (v: string) => void;\n variant?: Variant;\n children: ReactNode;\n className?: string;\n}) {\n const [internal, setInternal] = useState(defaultValue ?? \"\");\n const layoutId = useId();\n const reduce = useReducedMotion();\n const controlled = value !== undefined;\n const current = controlled ? value : internal;\n const setValue = useCallback(\n (v: string) => {\n if (!controlled) setInternal(v);\n onValueChange?.(v);\n },\n [controlled, onValueChange],\n );\n const contextValue = useMemo(\n () => ({ value: current, setValue, layoutId, variant }),\n [current, layoutId, setValue, variant],\n );\n return (\n <MotionConfig transition={reduce ? { duration: 0 } : transition}>\n <TabsCtx.Provider value={contextValue}>\n {/* layoutRoot: the indicator's layoutId measures in page coordinates, so\n inside fixed/scrolled containers it would replay scroll offsets as\n movement. The pill only ever travels within the list, so scoping\n projection to the Tabs wrapper is always correct. */}\n <motion.div layoutRoot className={className}>\n {children}\n </motion.div>\n </TabsCtx.Provider>\n </MotionConfig>\n );\n}\n\nconst listClasses: Record<Variant, string> = {\n pill: \"inline-flex items-center gap-1 rounded-full bg-card p-1\",\n underline: \"inline-flex items-center gap-1 border-b border-border\",\n segment: \"inline-flex items-center gap-0 rounded-lg bg-card p-0.5\",\n};\n\nexport function TabsList({ children, className }: { children: ReactNode; className?: string }) {\n const { variant } = useTabs();\n return (\n <div role=\"tablist\" className={cn(listClasses[variant], className)}>\n {children}\n </div>\n );\n}\n\nexport function TabsTrigger({\n value,\n children,\n className,\n indicatorClassName,\n}: {\n value: string;\n children: ReactNode;\n className?: string;\n indicatorClassName?: string;\n}) {\n const { value: current, setValue, layoutId, variant } = useTabs();\n const active = current === value;\n\n if (variant === \"underline\") {\n return (\n <button\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setValue(value)}\n className={cn(\n \"relative isolate -mb-px inline-flex min-h-[44px] items-center px-3 pt-1 pb-2.5 font-medium text-sm transition-colors\",\n active ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n className,\n )}\n >\n {children}\n {active ? (\n <motion.span\n layoutId={layoutId}\n layout=\"position\"\n className={cn(\"absolute right-0 -bottom-px left-0 h-px bg-primary\", indicatorClassName)}\n />\n ) : null}\n </button>\n );\n }\n\n const radius = variant === \"pill\" ? \"rounded-full\" : \"rounded-md\";\n\n return (\n <div className=\"relative\">\n {active ? (\n <motion.span\n layoutId={layoutId}\n layout=\"position\"\n style={{ borderRadius: variant === \"pill\" ? 9999 : 8 }}\n className={cn(\"absolute inset-0 bg-primary\", radius, indicatorClassName)}\n />\n ) : null}\n <button\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setValue(value)}\n className={cn(\n \"relative z-10 inline-flex items-center justify-center whitespace-nowrap bg-transparent px-3.5 py-1.5 font-medium text-sm outline-none\",\n \"transition-colors\",\n active ? \"text-primary-foreground\" : \"text-muted-foreground hover:text-foreground\",\n radius,\n className,\n )}\n >\n {children}\n </button>\n </div>\n );\n}\n\nexport function TabsContent({\n value,\n children,\n className,\n}: {\n value: string;\n children: ReactNode;\n className?: string;\n}) {\n const { value: current } = useTabs();\n const reduce = useReducedMotion();\n const active = current === value;\n // Inactive panels stay mounted but hidden, so their content (e.g. source\n // code) is present in the server-rendered HTML for crawlers and assistive\n // tech, instead of being dropped from the DOM.\n if (!active) {\n return (\n <div hidden className={className}>\n {children}\n </div>\n );\n }\n return (\n <motion.div\n key={value}\n initial={{ opacity: 0, y: reduce ? 0 : 4 }}\n animate={{ opacity: 1, y: 0 }}\n transition={{ duration: 0.18, ease: EASE_OUT }}\n className={cn(\"mt-4\", className)}\n >\n {children}\n </motion.div>\n );\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,UAAU,cAA0B,IAAI;AAE9C,SAAS,UAAU;CACjB,MAAM,MAAM,WAAW,OAAO;CAC9B,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,mCAAmC;CAC7D,OAAO;AACT;AAIA,MAAM,aAAyB;CAC7B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,KAAK,EACnB,cACA,OACA,eACA,UAAU,QACV,UACA,aAQC;CACD,MAAM,CAAC,UAAU,eAAe,SAAS,gBAAgB,EAAE;CAC3D,MAAM,WAAW,MAAM;CACvB,MAAM,SAAS,iBAAiB;CAChC,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM,UAAU,aAAa,QAAQ;CACrC,MAAM,WAAW,aACd,MAAc;EACb,IAAI,CAAC,YAAY,YAAY,CAAC;EAC9B,gBAAgB,CAAC;CACnB,GACA,CAAC,YAAY,aAAa,CAC5B;CACA,MAAM,eAAe,eACZ;EAAE,OAAO;EAAS;EAAU;EAAU;CAAQ,IACrD;EAAC;EAAS;EAAU;EAAU;CAAO,CACvC;CACA,OACE,oBAAC,cAAD;EAAc,YAAY,SAAS,EAAE,UAAU,EAAE,IAAI;EACnD,UAAA,oBAAC,QAAQ,UAAT;GAAkB,OAAO;GAKvB,UAAA,oBAAC,OAAO,KAAR;IAAY,YAAA;IAAsB;IAC/B;GACS,CAAA;EACI,CAAA;CACN,CAAA;AAElB;AA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AAO,KAAR;EAEE,SAAS;GAAE,SAAS;GAAG,GAAG,SAAS,IAAI;EAAE;EACzC,SAAS;GAAE,SAAS;GAAG,GAAG;EAAE;EAC5B,YAAY;GAAE,UAAU;GAAM,MAAM;EAAS;EAC7C,WAAW,GAAG,QAAQ,SAAS;EAE9B;CACS,GAPL,KAOK;AAEhB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
|
+
//#region src/components/motion/text-scramble.d.ts
|
|
3
|
+
interface TextScrambleProps {
|
|
4
|
+
/** Final text revealed by the scramble animation. */
|
|
5
|
+
text: string;
|
|
6
|
+
/** Maximum animation duration in milliseconds. */
|
|
7
|
+
duration?: number;
|
|
8
|
+
/** Characters sampled while unresolved positions are scrambling. */
|
|
9
|
+
glyphs?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
/** Character scramble that resolves to `text` and respects reduced motion. */
|
|
14
|
+
declare function TextScramble({ text, duration, glyphs, className, style }: TextScrambleProps): import("react").JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { TextScramble, TextScrambleProps };
|
|
17
|
+
//# sourceMappingURL=text-scramble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-scramble.d.ts","names":[],"sources":["../../../src/components/motion/text-scramble.tsx"],"mappings":";;UASiB;;EAEf;;EAEA;;EAEA;EACA;EACA,QAAQ;;;iBAIM,eACd,MACA,UACA,QACA,WACA,SACC,oCAAiB,IAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { cn } from "@kumix/utils";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useReducedMotion } from "motion/react";
|
|
6
|
+
//#region src/components/motion/text-scramble.tsx
|
|
7
|
+
const DEFAULT_GLYPHS = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&@$?/";
|
|
8
|
+
/** Character scramble that resolves to `text` and respects reduced motion. */
|
|
9
|
+
function TextScramble({ text, duration, glyphs = DEFAULT_GLYPHS, className, style }) {
|
|
10
|
+
const reduce = useReducedMotion() ?? false;
|
|
11
|
+
const [display, setDisplay] = useState(text);
|
|
12
|
+
const mounted = useRef(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!mounted.current) {
|
|
15
|
+
mounted.current = true;
|
|
16
|
+
setDisplay(text);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (reduce || !glyphs) {
|
|
20
|
+
setDisplay(text);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const characters = text.split("");
|
|
24
|
+
const startedAt = performance.now();
|
|
25
|
+
const animationDuration = duration ?? Math.min(760, Math.max(420, characters.length * 32));
|
|
26
|
+
let frame = 0;
|
|
27
|
+
let lastUpdate = 0;
|
|
28
|
+
const animate = (now) => {
|
|
29
|
+
if (now - lastUpdate >= 40) {
|
|
30
|
+
lastUpdate = now;
|
|
31
|
+
const progress = Math.min((now - startedAt) / animationDuration, 1);
|
|
32
|
+
const settled = Math.floor(progress * characters.length);
|
|
33
|
+
setDisplay(characters.map((character, index) => {
|
|
34
|
+
if (index < settled || character === " ") return character;
|
|
35
|
+
return glyphs[Math.floor(Math.random() * glyphs.length)];
|
|
36
|
+
}).join(""));
|
|
37
|
+
}
|
|
38
|
+
if (now - startedAt < animationDuration) frame = requestAnimationFrame(animate);
|
|
39
|
+
else setDisplay(text);
|
|
40
|
+
};
|
|
41
|
+
frame = requestAnimationFrame(animate);
|
|
42
|
+
return () => cancelAnimationFrame(frame);
|
|
43
|
+
}, [
|
|
44
|
+
duration,
|
|
45
|
+
glyphs,
|
|
46
|
+
reduce,
|
|
47
|
+
text
|
|
48
|
+
]);
|
|
49
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
50
|
+
className: cn("inline-block whitespace-pre", className),
|
|
51
|
+
style,
|
|
52
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: "sr-only",
|
|
54
|
+
children: text
|
|
55
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
children: reduce ? text : display
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { TextScramble };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=text-scramble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-scramble.js","names":[],"sources":["../../../src/components/motion/text-scramble.tsx"],"sourcesContent":["\"use client\";\n\nimport { type CSSProperties, useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\n\nconst DEFAULT_GLYPHS = \"ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&@$?/\";\n\nexport interface TextScrambleProps {\n /** Final text revealed by the scramble animation. */\n text: string;\n /** Maximum animation duration in milliseconds. */\n duration?: number;\n /** Characters sampled while unresolved positions are scrambling. */\n glyphs?: string;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Character scramble that resolves to `text` and respects reduced motion. */\nexport function TextScramble({\n text,\n duration,\n glyphs = DEFAULT_GLYPHS,\n className,\n style,\n}: TextScrambleProps) {\n const reduce = useReducedMotion() ?? false;\n const [display, setDisplay] = useState(text);\n const mounted = useRef(false);\n\n useEffect(() => {\n if (!mounted.current) {\n mounted.current = true;\n setDisplay(text);\n return;\n }\n\n if (reduce || !glyphs) {\n setDisplay(text);\n return;\n }\n\n const characters = text.split(\"\");\n const startedAt = performance.now();\n const animationDuration = duration ?? Math.min(760, Math.max(420, characters.length * 32));\n let frame = 0;\n let lastUpdate = 0;\n\n const animate = (now: number) => {\n if (now - lastUpdate >= 40) {\n lastUpdate = now;\n const progress = Math.min((now - startedAt) / animationDuration, 1);\n const settled = Math.floor(progress * characters.length);\n setDisplay(\n characters\n .map((character, index) => {\n if (index < settled || character === \" \") return character;\n return glyphs[Math.floor(Math.random() * glyphs.length)];\n })\n .join(\"\"),\n );\n }\n\n if (now - startedAt < animationDuration) {\n frame = requestAnimationFrame(animate);\n } else {\n setDisplay(text);\n }\n };\n\n frame = requestAnimationFrame(animate);\n return () => cancelAnimationFrame(frame);\n }, [duration, glyphs, reduce, text]);\n\n return (\n <span className={cn(\"inline-block whitespace-pre\", className)} style={style}>\n <span className=\"sr-only\">{text}</span>\n <span aria-hidden=\"true\">{reduce ? text : display}</span>\n </span>\n );\n}\n"],"mappings":";;;;;;AAOA,MAAM,iBAAiB;;AAcvB,SAAgB,aAAa,EAC3B,MACA,UACA,SAAS,gBACT,WACA,SACoB;CACpB,MAAM,SAAS,iBAAiB,KAAK;CACrC,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAC3C,MAAM,UAAU,OAAO,KAAK;CAE5B,gBAAgB;EACd,IAAI,CAAC,QAAQ,SAAS;GACpB,QAAQ,UAAU;GAClB,WAAW,IAAI;GACf;EACF;EAEA,IAAI,UAAU,CAAC,QAAQ;GACrB,WAAW,IAAI;GACf;EACF;EAEA,MAAM,aAAa,KAAK,MAAM,EAAE;EAChC,MAAM,YAAY,YAAY,IAAI;EAClC,MAAM,oBAAoB,YAAY,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,WAAW,SAAS,EAAE,CAAC;EACzF,IAAI,QAAQ;EACZ,IAAI,aAAa;EAEjB,MAAM,WAAW,QAAgB;GAC/B,IAAI,MAAM,cAAc,IAAI;IAC1B,aAAa;IACb,MAAM,WAAW,KAAK,KAAK,MAAM,aAAa,mBAAmB,CAAC;IAClE,MAAM,UAAU,KAAK,MAAM,WAAW,WAAW,MAAM;IACvD,WACE,WACG,KAAK,WAAW,UAAU;KACzB,IAAI,QAAQ,WAAW,cAAc,KAAK,OAAO;KACjD,OAAO,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,OAAO,MAAM;IACxD,CAAC,CAAC,CACD,KAAK,EAAE,CACZ;GACF;GAEA,IAAI,MAAM,YAAY,mBACpB,QAAQ,sBAAsB,OAAO;QAErC,WAAW,IAAI;EAEnB;EAEA,QAAQ,sBAAsB,OAAO;EACrC,aAAa,qBAAqB,KAAK;CACzC,GAAG;EAAC;EAAU;EAAQ;EAAQ;CAAI,CAAC;CAEnC,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,+BAA+B,SAAS;EAAU;EAAtE,UAAA,CACE,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAW,CAAA,GACtC,oBAAC,QAAD;GAAM,eAAY;GAAQ,UAAA,SAAS,OAAO;EAAc,CAAA,CACpD;;AAEV"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VariantProps } from "class-variance-authority";
|
|
2
2
|
//#region src/components/reui/alert.d.ts
|
|
3
3
|
declare const alertVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "default" | "destructive" | "info" | "success" | "warning" | "invert" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): import("react").JSX.Element;
|
|
7
7
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import { Autocomplete as Autocomplete$1 } from "@base-ui/react/autocomplete";
|
|
3
3
|
//#region src/components/reui/autocomplete.d.ts
|
|
4
4
|
declare const inputVariants: (props?: ({
|
|
5
|
-
size?: "
|
|
5
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare const Autocomplete: typeof Autocomplete$1.Root;
|
|
8
8
|
declare function AutocompleteValue({ ...props }: Autocomplete$1.Value.Props): import("react").JSX.Element;
|
|
@@ -2,8 +2,8 @@ import { VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import { useRender } from "@base-ui/react/use-render";
|
|
3
3
|
//#region src/components/reui/badge.d.ts
|
|
4
4
|
declare const badgeVariants: (props?: ({
|
|
5
|
-
variant?: "
|
|
6
|
-
size?: "
|
|
5
|
+
variant?: "outline" | "default" | "destructive" | "info" | "success" | "warning" | "invert" | "secondary" | "focus" | "primary-light" | "warning-light" | "success-light" | "info-light" | "destructive-light" | "invert-light" | "focus-light" | "primary-outline" | "warning-outline" | "success-outline" | "info-outline" | "destructive-outline" | "invert-outline" | "focus-outline" | null | undefined;
|
|
6
|
+
size?: "default" | "sm" | "lg" | "xs" | "xl" | null | undefined;
|
|
7
7
|
radius?: "default" | "full" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
interface BadgeProps extends useRender.ComponentProps<"span"> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Button } from "../../ui/button.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Badge } from "../badge.js";
|
|
4
4
|
import { Input } from "../../ui/input.js";
|
|
5
|
+
import { Separator } from "../../ui/separator.js";
|
|
5
6
|
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
6
|
-
import { Badge } from "../badge.js";
|
|
7
7
|
import { useMemo, useState } from "react";
|
|
8
8
|
import { cn } from "@kumix/utils";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useIsMobile } from "../../hooks/use-mobile.js";
|
|
3
3
|
import { Button } from "../ui/button.js";
|
|
4
|
+
import { ScrollArea } from "../ui/scroll-area.js";
|
|
4
5
|
import { Calendar, CalendarDayButton } from "../ui/calendar.js";
|
|
5
6
|
import { Input } from "../ui/input.js";
|
|
6
|
-
import { ScrollArea } from "../ui/scroll-area.js";
|
|
7
7
|
import { Tabs, TabsList, TabsTrigger } from "../ui/tabs.js";
|
|
8
8
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { cn } from "@kumix/utils";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
3
2
|
import { ScrollArea } from "../../ui/scroll-area.js";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
4
4
|
import { getDayKey, getRangeKey, resolveOffDay, toZoned, zonedStartOfDay } from "./event-calendar-lib.js";
|
|
5
5
|
import { EventCalendarViewContext, useEventCalendar, useEventCalendarDay, useEventCalendarSelector, useEventCalendarSettings, useEventCalendarViewConfig, useEventCalendarViewSettings, useEventCalendarWeek } from "./event-calendar.js";
|
|
6
6
|
import { useEventCalendarGestures, wasRecentChipPress, wasRecentDrag } from "./event-calendar-dnd.js";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Button } from "../../ui/button.js";
|
|
3
3
|
import { Calendar } from "../../ui/calendar.js";
|
|
4
4
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger } from "../../ui/dropdown-menu.js";
|
|
5
|
-
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
6
5
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip.js";
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
|
|
7
7
|
import { toZoned } from "./event-calendar-lib.js";
|
|
8
8
|
import { useEventCalendarNavigation, useEventCalendarSettings, useEventCalendarView, useEventCalendarViewConfig } from "./event-calendar.js";
|
|
9
9
|
import { useState } from "react";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use no memo";
|
|
3
3
|
import { Button } from "../ui/button.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ScrollArea } from "../ui/scroll-area.js";
|
|
5
5
|
import { Input } from "../ui/input.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ButtonGroup, ButtonGroupText } from "../ui/button-group.js";
|
|
7
7
|
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "../ui/dropdown-menu.js";
|
|
8
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText } from "../ui/input-group.js";
|
|
8
9
|
import { Kbd } from "../ui/kbd.js";
|
|
9
|
-
import { ScrollArea } from "../ui/scroll-area.js";
|
|
10
10
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip.js";
|
|
11
11
|
import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { cn } from "@kumix/utils";
|
|
@@ -13,8 +13,8 @@ import { VariantProps } from "class-variance-authority";
|
|
|
13
13
|
* :not() or !important needed
|
|
14
14
|
*/
|
|
15
15
|
declare const frameVariants: (props?: ({
|
|
16
|
-
variant?: "
|
|
17
|
-
spacing?: "
|
|
16
|
+
variant?: "ghost" | "default" | "inverse" | null | undefined;
|
|
17
|
+
spacing?: "default" | "sm" | "lg" | "xs" | null | undefined;
|
|
18
18
|
stacked?: boolean | null | undefined;
|
|
19
19
|
dense?: boolean | null | undefined;
|
|
20
20
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "../../ui/context-menu.js";
|
|
3
2
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../ui/tooltip.js";
|
|
3
|
+
import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "../../ui/context-menu.js";
|
|
4
4
|
import { flattenResources, toZoned } from "./gantt-lib.js";
|
|
5
5
|
import { useGantt, useGanttSelector, useGanttViewConfig } from "./gantt.js";
|
|
6
6
|
import { useGanttGestures, wasRecentDrag } from "./gantt-dnd.js";
|