@kumix/ui 0.3.0 → 0.3.1

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.
Files changed (242) hide show
  1. package/README.md +14 -1
  2. package/dist/components/custom/confirm-dialog.d.ts +16 -0
  3. package/dist/components/custom/confirm-dialog.d.ts.map +1 -0
  4. package/dist/components/custom/confirm-dialog.js +93 -0
  5. package/dist/components/custom/confirm-dialog.js.map +1 -0
  6. package/dist/components/custom/toast.d.ts +20 -0
  7. package/dist/components/custom/toast.d.ts.map +1 -0
  8. package/dist/components/custom/toast.js +73 -0
  9. package/dist/components/custom/toast.js.map +1 -0
  10. package/dist/components/motion/action-swap.js +1 -1
  11. package/dist/components/motion/animated-badge.js +2 -2
  12. package/dist/components/motion/animated-number.js +1 -1
  13. package/dist/components/motion/animated-sidebar.js +2 -2
  14. package/dist/components/motion/animated-toast-stack.js +4 -4
  15. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  16. package/dist/components/motion/attachment-upload.d.ts +47 -0
  17. package/dist/components/motion/attachment-upload.d.ts.map +1 -0
  18. package/dist/components/motion/attachment-upload.js +737 -0
  19. package/dist/components/motion/attachment-upload.js.map +1 -0
  20. package/dist/components/motion/availability-scheduler/copy-menu.d.ts +10 -0
  21. package/dist/components/motion/availability-scheduler/copy-menu.d.ts.map +1 -0
  22. package/dist/components/motion/availability-scheduler/copy-menu.js +3 -0
  23. package/dist/components/motion/availability-scheduler/day-row.d.ts +15 -0
  24. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -0
  25. package/dist/components/motion/availability-scheduler/day-row.js +181 -0
  26. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -0
  27. package/dist/components/motion/availability-scheduler/icon-button.d.ts +15 -0
  28. package/dist/components/motion/availability-scheduler/icon-button.d.ts.map +1 -0
  29. package/dist/components/motion/availability-scheduler/icon-button.js +24 -0
  30. package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -0
  31. package/dist/components/motion/availability-scheduler/index.d.ts +14 -0
  32. package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -0
  33. package/dist/components/motion/availability-scheduler/index.js +59 -0
  34. package/dist/components/motion/availability-scheduler/index.js.map +1 -0
  35. package/dist/components/motion/availability-scheduler/time-select.d.ts +10 -0
  36. package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -0
  37. package/dist/components/motion/availability-scheduler/time-select.js +26 -0
  38. package/dist/components/motion/availability-scheduler/time-select.js.map +1 -0
  39. package/dist/components/motion/bloom-menu.d.ts +17 -0
  40. package/dist/components/motion/bloom-menu.d.ts.map +1 -0
  41. package/dist/components/motion/bloom-menu.js +170 -0
  42. package/dist/components/motion/bloom-menu.js.map +1 -0
  43. package/dist/components/motion/bottom-sheet.js +1 -1
  44. package/dist/components/motion/bounce-sidebar.js +1 -1
  45. package/dist/components/motion/bouncy-accordion.js +2 -2
  46. package/dist/components/motion/button/base.js +1 -1
  47. package/dist/components/motion/button/index.d.ts +4 -0
  48. package/dist/components/motion/button/index.js +5 -0
  49. package/dist/components/motion/button/magnetic.js +1 -1
  50. package/dist/components/motion/button/stateful.js +2 -2
  51. package/dist/components/motion/center-morph-modal.js +2 -2
  52. package/dist/components/motion/checkbox.js +1 -1
  53. package/dist/components/motion/chromatic-text-reveal.js +1 -1
  54. package/dist/components/motion/command-palette.d.ts +26 -0
  55. package/dist/components/motion/command-palette.d.ts.map +1 -0
  56. package/dist/components/motion/command-palette.js +246 -0
  57. package/dist/components/motion/command-palette.js.map +1 -0
  58. package/dist/components/motion/context-menu.js +2 -2
  59. package/dist/components/motion/cylinder-carousel.js +1 -1
  60. package/dist/components/motion/dock.js +1 -1
  61. package/dist/components/motion/drawer.js +1 -1
  62. package/dist/components/motion/dynamic-island.d.ts +22 -0
  63. package/dist/components/motion/dynamic-island.d.ts.map +1 -0
  64. package/dist/components/motion/dynamic-island.js +143 -0
  65. package/dist/components/motion/dynamic-island.js.map +1 -0
  66. package/dist/components/motion/expandable-action-bar.d.ts +52 -0
  67. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -0
  68. package/dist/components/motion/expandable-action-bar.js +191 -0
  69. package/dist/components/motion/expandable-action-bar.js.map +1 -0
  70. package/dist/components/motion/expandable-tabs.d.ts +33 -0
  71. package/dist/components/motion/expandable-tabs.d.ts.map +1 -0
  72. package/dist/components/motion/expandable-tabs.js +291 -0
  73. package/dist/components/motion/expandable-tabs.js.map +1 -0
  74. package/dist/components/motion/feedback-widget.d.ts +18 -0
  75. package/dist/components/motion/feedback-widget.d.ts.map +1 -0
  76. package/dist/components/motion/feedback-widget.js +413 -0
  77. package/dist/components/motion/feedback-widget.js.map +1 -0
  78. package/dist/components/motion/file-upload.d.ts +48 -0
  79. package/dist/components/motion/file-upload.d.ts.map +1 -0
  80. package/dist/components/motion/file-upload.js +382 -0
  81. package/dist/components/motion/file-upload.js.map +1 -0
  82. package/dist/components/motion/hold-action-button.js +1 -1
  83. package/dist/components/motion/infinite-masonry.d.ts +31 -0
  84. package/dist/components/motion/infinite-masonry.d.ts.map +1 -0
  85. package/dist/components/motion/infinite-masonry.js +223 -0
  86. package/dist/components/motion/infinite-masonry.js.map +1 -0
  87. package/dist/components/motion/input.js +1 -1
  88. package/dist/components/motion/loader.js +1 -1
  89. package/dist/components/motion/magnetic.js +1 -1
  90. package/dist/components/motion/morphing-modal.js +1 -1
  91. package/dist/components/motion/not-found/glitch.d.ts +6 -0
  92. package/dist/components/motion/not-found/glitch.d.ts.map +1 -0
  93. package/dist/components/motion/not-found/glitch.js +90 -0
  94. package/dist/components/motion/not-found/glitch.js.map +1 -0
  95. package/dist/components/motion/not-found/magnetic.d.ts +6 -0
  96. package/dist/components/motion/not-found/magnetic.d.ts.map +1 -0
  97. package/dist/components/motion/not-found/magnetic.js +47 -0
  98. package/dist/components/motion/not-found/magnetic.js.map +1 -0
  99. package/dist/components/motion/not-found/shared.d.ts +32 -0
  100. package/dist/components/motion/not-found/shared.d.ts.map +1 -0
  101. package/dist/components/motion/not-found/shared.js +52 -0
  102. package/dist/components/motion/not-found/shared.js.map +1 -0
  103. package/dist/components/motion/not-found/spotlight.d.ts +6 -0
  104. package/dist/components/motion/not-found/spotlight.d.ts.map +1 -0
  105. package/dist/components/motion/not-found/spotlight.js +70 -0
  106. package/dist/components/motion/not-found/spotlight.js.map +1 -0
  107. package/dist/components/motion/not-found/stacked.d.ts +6 -0
  108. package/dist/components/motion/not-found/stacked.d.ts.map +1 -0
  109. package/dist/components/motion/not-found/stacked.js +95 -0
  110. package/dist/components/motion/not-found/stacked.js.map +1 -0
  111. package/dist/components/motion/not-found/terminal.d.ts +6 -0
  112. package/dist/components/motion/not-found/terminal.d.ts.map +1 -0
  113. package/dist/components/motion/not-found/terminal.js +90 -0
  114. package/dist/components/motion/not-found/terminal.js.map +1 -0
  115. package/dist/components/motion/notification-stack.d.ts +35 -0
  116. package/dist/components/motion/notification-stack.d.ts.map +1 -0
  117. package/dist/components/motion/notification-stack.js +187 -0
  118. package/dist/components/motion/notification-stack.js.map +1 -0
  119. package/dist/components/motion/number-ticker.js +1 -1
  120. package/dist/components/motion/otp-input.d.ts +32 -0
  121. package/dist/components/motion/otp-input.d.ts.map +1 -0
  122. package/dist/components/motion/otp-input.js +272 -0
  123. package/dist/components/motion/otp-input.js.map +1 -0
  124. package/dist/components/motion/overflow-actions.d.ts +39 -0
  125. package/dist/components/motion/overflow-actions.d.ts.map +1 -0
  126. package/dist/components/motion/overflow-actions.js +220 -0
  127. package/dist/components/motion/overflow-actions.js.map +1 -0
  128. package/dist/components/motion/parallax.js +1 -1
  129. package/dist/components/motion/popover-morph.js +2 -2
  130. package/dist/components/motion/popover-morph.js.map +1 -1
  131. package/dist/components/motion/popover.js +1 -1
  132. package/dist/components/motion/preview-rail.js +1 -1
  133. package/dist/components/motion/pull-to-refresh.js +2 -2
  134. package/dist/components/motion/pull-to-refresh.js.map +1 -1
  135. package/dist/components/motion/radio.js +1 -1
  136. package/dist/components/motion/range-slider-bubble.js +1 -1
  137. package/dist/components/motion/range-slider-fluid.js +1 -1
  138. package/dist/components/motion/range-slider-ruler.js +2 -2
  139. package/dist/components/motion/range-slider-ruler.js.map +1 -1
  140. package/dist/components/motion/range-slider-wave.js +1 -1
  141. package/dist/components/motion/range-slider.js +1 -1
  142. package/dist/components/motion/scroll-progress.js +1 -1
  143. package/dist/components/motion/scroll-reveal.js +1 -1
  144. package/dist/components/motion/select-morph.js +2 -2
  145. package/dist/components/motion/select.js +2 -2
  146. package/dist/components/motion/shader-background.js +1 -1
  147. package/dist/components/motion/shared-layout-bg.js +2 -2
  148. package/dist/components/motion/shared-layout-bg.js.map +1 -1
  149. package/dist/components/motion/slide-action-button.js +1 -1
  150. package/dist/components/motion/smooth-scroll.js +1 -1
  151. package/dist/components/motion/swipeable-list.d.ts +60 -0
  152. package/dist/components/motion/swipeable-list.d.ts.map +1 -0
  153. package/dist/components/motion/swipeable-list.js +254 -0
  154. package/dist/components/motion/swipeable-list.js.map +1 -0
  155. package/dist/components/motion/switch.js +1 -1
  156. package/dist/components/motion/table/index.js +1 -1
  157. package/dist/components/motion/table/row-handle.js +1 -1
  158. package/dist/components/motion/table/table-header.js +2 -2
  159. package/dist/components/motion/table/table-menu.js +1 -1
  160. package/dist/components/motion/tabs.js +1 -1
  161. package/dist/components/motion/text-reveal.js +1 -1
  162. package/dist/components/motion/text-shimmer.js +1 -1
  163. package/dist/components/motion/text-shimmer.js.map +1 -1
  164. package/dist/components/motion/theme-toggle.js +2 -2
  165. package/dist/components/motion/tilt-card.js +1 -1
  166. package/dist/components/motion/tooltip.js +1 -1
  167. package/dist/components/motion/wheel-picker.js +1 -1
  168. package/dist/components/reui/alert.d.ts +1 -1
  169. package/dist/components/reui/alert.js +1 -1
  170. package/dist/components/reui/autocomplete.js +1 -1
  171. package/dist/components/reui/badge.d.ts +1 -1
  172. package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
  173. package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
  174. package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
  175. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
  176. package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
  177. package/dist/components/reui/data-grid/data-grid-table.js +1 -1
  178. package/dist/components/reui/date-selector.js +2 -2
  179. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
  180. package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
  181. package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
  182. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  183. package/dist/components/reui/filters.js +2 -2
  184. package/dist/components/reui/frame.d.ts +1 -1
  185. package/dist/components/reui/frame.js +1 -1
  186. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  187. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  188. package/dist/components/reui/gantt/gantt-view.js +2 -2
  189. package/dist/components/reui/number-field.js +1 -1
  190. package/dist/components/reui/phone-input.js +2 -2
  191. package/dist/components/reui/rating.js +1 -1
  192. package/dist/components/reui/tree.js +1 -1
  193. package/dist/components/ui/accordion.js +1 -1
  194. package/dist/components/ui/alert-dialog.js +1 -1
  195. package/dist/components/ui/alert.js +1 -1
  196. package/dist/components/ui/attachment.d.ts +1 -1
  197. package/dist/components/ui/attachment.js +1 -1
  198. package/dist/components/ui/badge.d.ts +1 -1
  199. package/dist/components/ui/breadcrumb.js +1 -1
  200. package/dist/components/ui/bubble.d.ts +1 -1
  201. package/dist/components/ui/bubble.js +1 -1
  202. package/dist/components/ui/button-group.d.ts +1 -1
  203. package/dist/components/ui/button-group.js +1 -1
  204. package/dist/components/ui/button.d.ts +2 -2
  205. package/dist/components/ui/button.js +2 -2
  206. package/dist/components/ui/calendar.js +1 -1
  207. package/dist/components/ui/carousel.js +1 -1
  208. package/dist/components/ui/checkbox.js +1 -1
  209. package/dist/components/ui/combobox.js +1 -1
  210. package/dist/components/ui/command.js +1 -1
  211. package/dist/components/ui/context-menu.js +1 -1
  212. package/dist/components/ui/dialog.js +1 -1
  213. package/dist/components/ui/dropdown-menu.js +1 -1
  214. package/dist/components/ui/empty.js +1 -1
  215. package/dist/components/ui/field.d.ts +1 -1
  216. package/dist/components/ui/field.js +1 -1
  217. package/dist/components/ui/input-group.js +1 -1
  218. package/dist/components/ui/input-otp.js +1 -1
  219. package/dist/components/ui/item.d.ts +2 -2
  220. package/dist/components/ui/item.js +1 -1
  221. package/dist/components/ui/marker.d.ts +1 -1
  222. package/dist/components/ui/marker.js +1 -1
  223. package/dist/components/ui/menubar.js +1 -1
  224. package/dist/components/ui/message-scroller.js +1 -1
  225. package/dist/components/ui/native-select.js +1 -1
  226. package/dist/components/ui/navigation-menu.js +1 -1
  227. package/dist/components/ui/pagination.js +1 -1
  228. package/dist/components/ui/select.js +1 -1
  229. package/dist/components/ui/sheet.js +1 -1
  230. package/dist/components/ui/sidebar.d.ts +1 -1
  231. package/dist/components/ui/sidebar.js +1 -1
  232. package/dist/components/ui/sonner.js +1 -1
  233. package/dist/components/ui/spinner.js +1 -1
  234. package/dist/components/ui/tabs.js +1 -1
  235. package/dist/components/ui/toast.js +1 -1
  236. package/dist/components/ui/toggle.d.ts +1 -1
  237. package/dist/components/ui/toggle.js +1 -1
  238. package/dist/copy-menu-BJ-MXnkN.js +201 -0
  239. package/dist/copy-menu-BJ-MXnkN.js.map +1 -0
  240. package/dist/types-smkWN_7x.d.ts +20 -0
  241. package/dist/types-smkWN_7x.d.ts.map +1 -0
  242. package/package.json +2 -2
@@ -0,0 +1,382 @@
1
+ "use client";
2
+ import { EASE_OUT } from "../../lib/ease.js";
3
+ import { useCallback, useId, useRef, useState } from "react";
4
+ import { cn } from "@kumix/utils";
5
+ import { AlertCircle, CheckCircle2, FileArchive, FileAudio, FileCode2, FileIcon, FileImage, FileSpreadsheet, FileText, FileVideo, Loader2, RotateCcw, UploadCloud, X } from "lucide-react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
8
+ //#region src/components/motion/file-upload.tsx
9
+ const ROW_TRANSITION = {
10
+ duration: .22,
11
+ ease: EASE_OUT
12
+ };
13
+ const FAST_TRANSITION = {
14
+ duration: .16,
15
+ ease: EASE_OUT
16
+ };
17
+ const STATUS_LABEL = {
18
+ queued: "Queued",
19
+ uploading: "Uploading",
20
+ success: "Uploaded",
21
+ error: "Failed"
22
+ };
23
+ const STATUS_TONE = {
24
+ queued: "text-muted-foreground",
25
+ uploading: "text-foreground",
26
+ success: "text-emerald-600 dark:text-emerald-400",
27
+ error: "text-destructive"
28
+ };
29
+ function useControllableUpload({ value, defaultValue, onValueChange }) {
30
+ const [internalValue, setInternalValue] = useState(defaultValue ?? []);
31
+ const isControlled = value !== void 0;
32
+ return [value ?? internalValue, useCallback((next) => {
33
+ if (!isControlled) setInternalValue(next);
34
+ onValueChange?.(next);
35
+ }, [isControlled, onValueChange])];
36
+ }
37
+ function clampProgress(value, status) {
38
+ if (status === "success") return 100;
39
+ if (value === void 0 || Number.isNaN(value)) return 0;
40
+ return Math.max(0, Math.min(100, value));
41
+ }
42
+ function formatBytes(bytes) {
43
+ if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
44
+ const units = [
45
+ "B",
46
+ "KB",
47
+ "MB",
48
+ "GB",
49
+ "TB"
50
+ ];
51
+ const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
52
+ const value = bytes / 1024 ** exponent;
53
+ return `${value >= 10 || exponent === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[exponent]}`;
54
+ }
55
+ function fileKind(item) {
56
+ const extension = item.name.includes(".") ? item.name.split(".").pop() : void 0;
57
+ if (extension) return extension.toUpperCase();
58
+ if (item.type) return item.type.split("/").pop()?.toUpperCase();
59
+ return "FILE";
60
+ }
61
+ function getFileIcon(item) {
62
+ const extension = item.name.includes(".") ? item.name.split(".").pop()?.toLowerCase() : void 0;
63
+ const type = item.type ?? "";
64
+ if (type.startsWith("image/")) return FileImage;
65
+ if (type.startsWith("video/")) return FileVideo;
66
+ if (type.startsWith("audio/")) return FileAudio;
67
+ if (type.includes("zip") || type.includes("compressed") || [
68
+ "zip",
69
+ "rar",
70
+ "7z",
71
+ "tar",
72
+ "gz"
73
+ ].includes(extension ?? "")) return FileArchive;
74
+ if (type.includes("spreadsheet") || type.includes("excel") || [
75
+ "csv",
76
+ "xls",
77
+ "xlsx"
78
+ ].includes(extension ?? "")) return FileSpreadsheet;
79
+ if (type.includes("pdf") || type.startsWith("text/") || [
80
+ "pdf",
81
+ "doc",
82
+ "docx",
83
+ "md",
84
+ "txt"
85
+ ].includes(extension ?? "")) return FileText;
86
+ if ([
87
+ "css",
88
+ "html",
89
+ "js",
90
+ "jsx",
91
+ "json",
92
+ "mdx",
93
+ "ts",
94
+ "tsx",
95
+ "xml",
96
+ "yaml",
97
+ "yml"
98
+ ].includes(extension ?? "")) return FileCode2;
99
+ return FileIcon;
100
+ }
101
+ function createFileUploadItem(file, index = 0) {
102
+ return {
103
+ id: `${Date.now()}-${index}-${file.name}`,
104
+ name: file.name,
105
+ size: file.size,
106
+ type: file.type,
107
+ progress: 0,
108
+ status: "uploading",
109
+ file
110
+ };
111
+ }
112
+ function StatusIcon({ status, reduce }) {
113
+ const iconClassName = "h-4 w-4";
114
+ return /* @__PURE__ */ jsx(AnimatePresence, {
115
+ mode: "wait",
116
+ initial: false,
117
+ children: /* @__PURE__ */ jsxs(motion.span, {
118
+ initial: reduce ? { opacity: 0 } : {
119
+ opacity: 0,
120
+ transform: "translateY(4px)"
121
+ },
122
+ animate: {
123
+ opacity: 1,
124
+ transform: "translateY(0px)"
125
+ },
126
+ exit: reduce ? { opacity: 0 } : {
127
+ opacity: 0,
128
+ transform: "translateY(-4px)"
129
+ },
130
+ transition: FAST_TRANSITION,
131
+ className: cn("grid h-6 w-6 place-items-center", STATUS_TONE[status]),
132
+ children: [status === "success" ? /* @__PURE__ */ jsx(CheckCircle2, { className: iconClassName }) : status === "error" ? /* @__PURE__ */ jsx(AlertCircle, { className: iconClassName }) : status === "uploading" ? /* @__PURE__ */ jsx(Loader2, { className: cn(iconClassName, "animate-spin", reduce && "animate-none") }) : /* @__PURE__ */ jsx(FileIcon, { className: iconClassName }), /* @__PURE__ */ jsx("span", {
133
+ className: "sr-only",
134
+ children: STATUS_LABEL[status]
135
+ })]
136
+ }, status)
137
+ });
138
+ }
139
+ function FileUploadRow({ item, onRemove, onRetry, classNames }) {
140
+ const reduce = useReducedMotion() ?? false;
141
+ const status = item.status ?? "queued";
142
+ const progress = clampProgress(item.progress, status);
143
+ const progressRatio = progress / 100;
144
+ const showProgress = status === "uploading" || status === "success";
145
+ const LeadingIcon = getFileIcon(item);
146
+ return /* @__PURE__ */ jsx(motion.li, {
147
+ layout: !reduce,
148
+ initial: reduce ? { opacity: 0 } : {
149
+ opacity: 0,
150
+ transform: "translateY(8px)"
151
+ },
152
+ animate: {
153
+ opacity: 1,
154
+ transform: "translateY(0px)"
155
+ },
156
+ exit: reduce ? { opacity: 0 } : {
157
+ opacity: 0,
158
+ transform: "translateY(-6px)"
159
+ },
160
+ transition: ROW_TRANSITION,
161
+ className: cn("relative overflow-hidden rounded-2xl border border-border bg-background p-3", classNames?.item),
162
+ children: /* @__PURE__ */ jsxs("div", {
163
+ className: "flex items-center gap-3",
164
+ children: [/* @__PURE__ */ jsx("div", {
165
+ className: cn("grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-muted text-muted-foreground", classNames?.leading),
166
+ children: /* @__PURE__ */ jsx(LeadingIcon, { className: "h-5 w-5" })
167
+ }), /* @__PURE__ */ jsxs("div", {
168
+ className: cn("min-w-0 flex-1", classNames?.content),
169
+ children: [/* @__PURE__ */ jsxs("div", {
170
+ className: "flex items-start justify-between gap-3",
171
+ children: [/* @__PURE__ */ jsxs("div", {
172
+ className: "min-w-0",
173
+ children: [/* @__PURE__ */ jsx("p", {
174
+ className: cn("truncate font-medium text-foreground text-sm", classNames?.name),
175
+ children: item.name
176
+ }), /* @__PURE__ */ jsxs("p", {
177
+ className: cn("mt-0.5 text-muted-foreground text-xs", classNames?.meta),
178
+ children: [
179
+ fileKind(item),
180
+ " · ",
181
+ formatBytes(item.size),
182
+ status === "error" && item.error ? ` · ${item.error}` : null
183
+ ]
184
+ })]
185
+ }), /* @__PURE__ */ jsxs("div", {
186
+ className: "flex shrink-0 items-center gap-1",
187
+ children: [
188
+ /* @__PURE__ */ jsx(StatusIcon, {
189
+ status,
190
+ reduce
191
+ }),
192
+ status === "error" ? /* @__PURE__ */ jsx("button", {
193
+ type: "button",
194
+ onClick: () => onRetry(item),
195
+ "aria-label": `Retry ${item.name}`,
196
+ className: cn("grid h-7 w-7 place-items-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground active:scale-95", classNames?.action),
197
+ children: /* @__PURE__ */ jsx(RotateCcw, { className: "h-3.5 w-3.5" })
198
+ }) : null,
199
+ /* @__PURE__ */ jsx("button", {
200
+ type: "button",
201
+ onClick: () => onRemove(item),
202
+ "aria-label": `Remove ${item.name}`,
203
+ className: cn("grid h-7 w-7 place-items-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground active:scale-95", classNames?.action),
204
+ children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
205
+ })
206
+ ]
207
+ })]
208
+ }), showProgress ? /* @__PURE__ */ jsx("div", {
209
+ role: "progressbar",
210
+ "aria-valuemin": 0,
211
+ "aria-valuemax": 100,
212
+ "aria-valuenow": Math.round(progress),
213
+ "aria-label": `${item.name} upload progress`,
214
+ className: cn("mt-3 h-1.5 overflow-hidden rounded-full bg-muted", classNames?.progress),
215
+ children: /* @__PURE__ */ jsx(motion.div, {
216
+ className: cn("h-full rounded-full", status === "success" ? "bg-emerald-500" : "bg-foreground"),
217
+ style: {
218
+ transformOrigin: "left",
219
+ transform: reduce ? `scaleX(${progressRatio})` : void 0
220
+ },
221
+ initial: false,
222
+ animate: reduce ? void 0 : { transform: `scaleX(${progressRatio})` },
223
+ transition: {
224
+ duration: .28,
225
+ ease: EASE_OUT
226
+ }
227
+ })
228
+ }) : null]
229
+ })]
230
+ })
231
+ });
232
+ }
233
+ function FileUpload({ value, defaultValue, onValueChange, onFilesAdded, onRemove, onRetry, accept, multiple = true, maxFiles, disabled = false, variant = "default", title = "Drop files here", description = "Add files to the upload queue", browseLabel = "Browse", className, classNames }) {
234
+ const inputId = useId();
235
+ const inputRef = useRef(null);
236
+ const dragDepthRef = useRef(0);
237
+ const reduce = useReducedMotion() ?? false;
238
+ const [items, setItems] = useControllableUpload({
239
+ value,
240
+ defaultValue,
241
+ onValueChange
242
+ });
243
+ const [dragging, setDragging] = useState(false);
244
+ const commit = useCallback((next) => {
245
+ setItems(next);
246
+ }, [setItems]);
247
+ const addFiles = useCallback((incomingFiles) => {
248
+ if (disabled || incomingFiles.length === 0) return;
249
+ const remainingSlots = maxFiles === void 0 ? incomingFiles.length : maxFiles - items.length;
250
+ if (remainingSlots <= 0) return;
251
+ const files = incomingFiles.slice(0, multiple ? remainingSlots : Math.min(1, remainingSlots));
252
+ const added = files.map((file, index) => createFileUploadItem(file, index));
253
+ if (added.length === 0) return;
254
+ commit([...items, ...added]);
255
+ onFilesAdded?.(added, files);
256
+ }, [
257
+ commit,
258
+ disabled,
259
+ items,
260
+ maxFiles,
261
+ multiple,
262
+ onFilesAdded
263
+ ]);
264
+ const removeItem = useCallback((item) => {
265
+ commit(items.filter((entry) => entry.id !== item.id));
266
+ onRemove?.(item);
267
+ }, [
268
+ commit,
269
+ items,
270
+ onRemove
271
+ ]);
272
+ const retryItem = useCallback((item) => {
273
+ const retryingItem = {
274
+ ...item,
275
+ error: void 0,
276
+ progress: 0,
277
+ status: "uploading"
278
+ };
279
+ commit(items.map((entry) => entry.id === item.id ? retryingItem : entry));
280
+ onRetry?.(retryingItem);
281
+ }, [
282
+ commit,
283
+ items,
284
+ onRetry
285
+ ]);
286
+ const resetDrag = useCallback(() => {
287
+ dragDepthRef.current = 0;
288
+ setDragging(false);
289
+ }, []);
290
+ const maxReached = maxFiles !== void 0 && items.length >= maxFiles;
291
+ const centered = variant === "centered";
292
+ return /* @__PURE__ */ jsxs("div", {
293
+ className: cn("w-full space-y-3", className, classNames?.root),
294
+ children: [
295
+ /* @__PURE__ */ jsx("input", {
296
+ ref: inputRef,
297
+ id: inputId,
298
+ type: "file",
299
+ "aria-label": "Upload files",
300
+ accept,
301
+ multiple,
302
+ disabled: disabled || maxReached,
303
+ tabIndex: -1,
304
+ className: "sr-only",
305
+ onChange: (event) => {
306
+ addFiles(Array.from(event.currentTarget.files ?? []));
307
+ event.currentTarget.value = "";
308
+ }
309
+ }),
310
+ /* @__PURE__ */ jsxs("button", {
311
+ type: "button",
312
+ disabled: disabled || maxReached,
313
+ "data-dragging": dragging,
314
+ onClick: () => inputRef.current?.click(),
315
+ onDragEnter: (event) => {
316
+ if (disabled || maxReached) return;
317
+ event.preventDefault();
318
+ dragDepthRef.current += 1;
319
+ setDragging(true);
320
+ },
321
+ onDragOver: (event) => {
322
+ if (disabled || maxReached) return;
323
+ event.preventDefault();
324
+ event.dataTransfer.dropEffect = "copy";
325
+ setDragging(true);
326
+ },
327
+ onDragLeave: (event) => {
328
+ if (disabled || maxReached) return;
329
+ event.preventDefault();
330
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
331
+ if (dragDepthRef.current === 0) setDragging(false);
332
+ },
333
+ onDrop: (event) => {
334
+ if (disabled || maxReached) return;
335
+ event.preventDefault();
336
+ resetDrag();
337
+ addFiles(Array.from(event.dataTransfer.files));
338
+ },
339
+ className: cn("group relative flex w-full overflow-hidden rounded-3xl border border-border border-dashed bg-background outline-none", "transition-[border-color,transform] duration-200 active:scale-[0.99]", "hover:border-foreground/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", "data-[dragging=true]:border-foreground", "disabled:pointer-events-none disabled:opacity-55", centered ? "min-h-56 flex-col items-center justify-center gap-3 p-7 text-center" : "items-center gap-4 p-5 text-left", classNames?.dropzone),
340
+ children: [
341
+ /* @__PURE__ */ jsx(motion.span, {
342
+ "aria-hidden": "true",
343
+ className: cn("grid shrink-0 place-items-center bg-muted text-foreground", centered ? "h-16 w-16 rounded-[1.35rem] border border-border" : "h-14 w-14 rounded-[1.25rem]"),
344
+ animate: reduce ? void 0 : { transform: dragging ? "translateY(-2px)" : "translateY(0px)" },
345
+ transition: FAST_TRANSITION,
346
+ children: /* @__PURE__ */ jsx(UploadCloud, { className: centered ? "h-7 w-7" : "h-6 w-6" })
347
+ }),
348
+ /* @__PURE__ */ jsxs("span", {
349
+ className: cn("min-w-0", centered ? "max-w-xs" : "flex-1"),
350
+ children: [/* @__PURE__ */ jsx("span", {
351
+ className: cn("block font-semibold text-foreground", centered ? "text-base" : "text-sm"),
352
+ children: maxReached ? "Upload limit reached" : title
353
+ }), /* @__PURE__ */ jsx("span", {
354
+ className: cn("block text-muted-foreground text-xs", centered ? "mt-1 leading-5" : "mt-0.5"),
355
+ children: maxReached ? `${items.length} of ${maxFiles} files added` : description
356
+ })]
357
+ }),
358
+ /* @__PURE__ */ jsx("span", {
359
+ className: cn("shrink-0 rounded-full border border-border font-medium text-foreground text-xs transition-colors duration-150 group-hover:bg-muted", centered ? "mt-1 px-4 py-2" : "px-3.5 py-2"),
360
+ children: browseLabel
361
+ })
362
+ ]
363
+ }),
364
+ /* @__PURE__ */ jsx("ul", {
365
+ className: cn("space-y-2", classNames?.queue),
366
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
367
+ initial: false,
368
+ children: items.map((item) => /* @__PURE__ */ jsx(FileUploadRow, {
369
+ item,
370
+ onRemove: removeItem,
371
+ onRetry: retryItem,
372
+ classNames
373
+ }, item.id))
374
+ })
375
+ })
376
+ ]
377
+ });
378
+ }
379
+ //#endregion
380
+ export { FileUpload, createFileUploadItem };
381
+
382
+ //# sourceMappingURL=file-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-upload.js","names":[],"sources":["../../../src/components/motion/file-upload.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useId, useRef, useState } from \"react\";\nimport {\n AlertCircle,\n CheckCircle2,\n FileArchive,\n FileAudio,\n FileCode2,\n FileIcon,\n FileImage,\n FileSpreadsheet,\n FileText,\n FileVideo,\n Loader2,\n RotateCcw,\n UploadCloud,\n X,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type FileUploadStatus = \"queued\" | \"uploading\" | \"success\" | \"error\";\nexport type FileUploadVariant = \"default\" | \"centered\";\n\nexport type FileUploadItem = {\n id: string;\n name: string;\n size: number;\n type?: string;\n progress?: number;\n status?: FileUploadStatus;\n error?: string;\n file?: File;\n};\n\nexport type FileUploadClassNames = {\n root?: string;\n dropzone?: string;\n queue?: string;\n item?: string;\n leading?: string;\n content?: string;\n name?: string;\n meta?: string;\n progress?: string;\n action?: string;\n};\n\nexport interface FileUploadProps {\n value?: FileUploadItem[];\n defaultValue?: FileUploadItem[];\n onValueChange?: (items: FileUploadItem[]) => void;\n onFilesAdded?: (items: FileUploadItem[], files: File[]) => void;\n onRemove?: (item: FileUploadItem) => void;\n onRetry?: (item: FileUploadItem) => void;\n accept?: string;\n multiple?: boolean;\n maxFiles?: number;\n disabled?: boolean;\n variant?: FileUploadVariant;\n title?: string;\n description?: string;\n browseLabel?: string;\n className?: string;\n classNames?: FileUploadClassNames;\n}\n\nconst ROW_TRANSITION = { duration: 0.22, ease: EASE_OUT } as const;\nconst FAST_TRANSITION = { duration: 0.16, ease: EASE_OUT } as const;\n\nconst STATUS_LABEL: Record<FileUploadStatus, string> = {\n queued: \"Queued\",\n uploading: \"Uploading\",\n success: \"Uploaded\",\n error: \"Failed\",\n};\n\nconst STATUS_TONE: Record<FileUploadStatus, string> = {\n queued: \"text-muted-foreground\",\n uploading: \"text-foreground\",\n success: \"text-emerald-600 dark:text-emerald-400\",\n error: \"text-destructive\",\n};\n\nfunction useControllableUpload({\n value,\n defaultValue,\n onValueChange,\n}: {\n value?: FileUploadItem[];\n defaultValue?: FileUploadItem[];\n onValueChange?: (items: FileUploadItem[]) => void;\n}) {\n const [internalValue, setInternalValue] = useState(defaultValue ?? []);\n const isControlled = value !== undefined;\n const items = value ?? internalValue;\n\n const setItems = useCallback(\n (next: FileUploadItem[]) => {\n if (!isControlled) {\n setInternalValue(next);\n }\n\n onValueChange?.(next);\n },\n [isControlled, onValueChange],\n );\n\n return [items, setItems] as const;\n}\n\nfunction clampProgress(value: number | undefined, status: FileUploadStatus) {\n if (status === \"success\") return 100;\n if (value === undefined || Number.isNaN(value)) return 0;\n return Math.max(0, Math.min(100, value));\n}\n\nfunction formatBytes(bytes: number) {\n if (!Number.isFinite(bytes) || bytes <= 0) return \"0 B\";\n\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);\n const value = bytes / 1024 ** exponent;\n\n return `${value >= 10 || exponent === 0 ? value.toFixed(0) : value.toFixed(1)} ${\n units[exponent]\n }`;\n}\n\nfunction fileKind(item: FileUploadItem) {\n const extension = item.name.includes(\".\") ? item.name.split(\".\").pop() : undefined;\n\n if (extension) return extension.toUpperCase();\n if (item.type) return item.type.split(\"/\").pop()?.toUpperCase();\n return \"FILE\";\n}\n\nfunction getFileIcon(item: FileUploadItem) {\n const extension = item.name.includes(\".\") ? item.name.split(\".\").pop()?.toLowerCase() : undefined;\n const type = item.type ?? \"\";\n\n if (type.startsWith(\"image/\")) return FileImage;\n if (type.startsWith(\"video/\")) return FileVideo;\n if (type.startsWith(\"audio/\")) return FileAudio;\n if (\n type.includes(\"zip\") ||\n type.includes(\"compressed\") ||\n [\"zip\", \"rar\", \"7z\", \"tar\", \"gz\"].includes(extension ?? \"\")\n ) {\n return FileArchive;\n }\n if (\n type.includes(\"spreadsheet\") ||\n type.includes(\"excel\") ||\n [\"csv\", \"xls\", \"xlsx\"].includes(extension ?? \"\")\n ) {\n return FileSpreadsheet;\n }\n if (\n type.includes(\"pdf\") ||\n type.startsWith(\"text/\") ||\n [\"pdf\", \"doc\", \"docx\", \"md\", \"txt\"].includes(extension ?? \"\")\n ) {\n return FileText;\n }\n if (\n [\"css\", \"html\", \"js\", \"jsx\", \"json\", \"mdx\", \"ts\", \"tsx\", \"xml\", \"yaml\", \"yml\"].includes(\n extension ?? \"\",\n )\n ) {\n return FileCode2;\n }\n\n return FileIcon;\n}\n\nexport function createFileUploadItem(file: File, index = 0): FileUploadItem {\n return {\n id: `${Date.now()}-${index}-${file.name}`,\n name: file.name,\n size: file.size,\n type: file.type,\n progress: 0,\n status: \"uploading\",\n file,\n };\n}\n\nfunction StatusIcon({ status, reduce }: { status: FileUploadStatus; reduce: boolean }) {\n const iconClassName = \"h-4 w-4\";\n\n return (\n <AnimatePresence mode=\"wait\" initial={false}>\n <motion.span\n key={status}\n initial={reduce ? { opacity: 0 } : { opacity: 0, transform: \"translateY(4px)\" }}\n animate={{ opacity: 1, transform: \"translateY(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, transform: \"translateY(-4px)\" }}\n transition={FAST_TRANSITION}\n className={cn(\"grid h-6 w-6 place-items-center\", STATUS_TONE[status])}\n >\n {status === \"success\" ? (\n <CheckCircle2 className={iconClassName} />\n ) : status === \"error\" ? (\n <AlertCircle className={iconClassName} />\n ) : status === \"uploading\" ? (\n <Loader2 className={cn(iconClassName, \"animate-spin\", reduce && \"animate-none\")} />\n ) : (\n <FileIcon className={iconClassName} />\n )}\n <span className=\"sr-only\">{STATUS_LABEL[status]}</span>\n </motion.span>\n </AnimatePresence>\n );\n}\n\nfunction FileUploadRow({\n item,\n onRemove,\n onRetry,\n classNames,\n}: {\n item: FileUploadItem;\n onRemove: (item: FileUploadItem) => void;\n onRetry: (item: FileUploadItem) => void;\n classNames?: FileUploadClassNames;\n}) {\n const reduce = useReducedMotion() ?? false;\n const status = item.status ?? \"queued\";\n const progress = clampProgress(item.progress, status);\n const progressRatio = progress / 100;\n const showProgress = status === \"uploading\" || status === \"success\";\n const LeadingIcon = getFileIcon(item);\n\n return (\n <motion.li\n layout={!reduce}\n initial={reduce ? { opacity: 0 } : { opacity: 0, transform: \"translateY(8px)\" }}\n animate={{ opacity: 1, transform: \"translateY(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, transform: \"translateY(-6px)\" }}\n transition={ROW_TRANSITION}\n className={cn(\n \"relative overflow-hidden rounded-2xl border border-border bg-background p-3\",\n classNames?.item,\n )}\n >\n <div className=\"flex items-center gap-3\">\n <div\n className={cn(\n \"grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-muted text-muted-foreground\",\n classNames?.leading,\n )}\n >\n <LeadingIcon className=\"h-5 w-5\" />\n </div>\n\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className={cn(\"truncate font-medium text-foreground text-sm\", classNames?.name)}>\n {item.name}\n </p>\n <p className={cn(\"mt-0.5 text-muted-foreground text-xs\", classNames?.meta)}>\n {fileKind(item)} · {formatBytes(item.size)}\n {status === \"error\" && item.error ? ` · ${item.error}` : null}\n </p>\n </div>\n\n <div className=\"flex shrink-0 items-center gap-1\">\n <StatusIcon status={status} reduce={reduce} />\n {status === \"error\" ? (\n <button\n type=\"button\"\n onClick={() => onRetry(item)}\n aria-label={`Retry ${item.name}`}\n className={cn(\n \"grid h-7 w-7 place-items-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground active:scale-95\",\n classNames?.action,\n )}\n >\n <RotateCcw className=\"h-3.5 w-3.5\" />\n </button>\n ) : null}\n <button\n type=\"button\"\n onClick={() => onRemove(item)}\n aria-label={`Remove ${item.name}`}\n className={cn(\n \"grid h-7 w-7 place-items-center rounded-full text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground active:scale-95\",\n classNames?.action,\n )}\n >\n <X className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n </div>\n\n {showProgress ? (\n <div\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(progress)}\n aria-label={`${item.name} upload progress`}\n className={cn(\n \"mt-3 h-1.5 overflow-hidden rounded-full bg-muted\",\n classNames?.progress,\n )}\n >\n <motion.div\n className={cn(\n \"h-full rounded-full\",\n status === \"success\" ? \"bg-emerald-500\" : \"bg-foreground\",\n )}\n style={{\n transformOrigin: \"left\",\n transform: reduce ? `scaleX(${progressRatio})` : undefined,\n }}\n initial={false}\n animate={reduce ? undefined : { transform: `scaleX(${progressRatio})` }}\n transition={{ duration: 0.28, ease: EASE_OUT }}\n />\n </div>\n ) : null}\n </div>\n </div>\n </motion.li>\n );\n}\n\nexport function FileUpload({\n value,\n defaultValue,\n onValueChange,\n onFilesAdded,\n onRemove,\n onRetry,\n accept,\n multiple = true,\n maxFiles,\n disabled = false,\n variant = \"default\",\n title = \"Drop files here\",\n description = \"Add files to the upload queue\",\n browseLabel = \"Browse\",\n className,\n classNames,\n}: FileUploadProps) {\n const inputId = useId();\n const inputRef = useRef<HTMLInputElement>(null);\n const dragDepthRef = useRef(0);\n const reduce = useReducedMotion() ?? false;\n const [items, setItems] = useControllableUpload({\n value,\n defaultValue,\n onValueChange,\n });\n const [dragging, setDragging] = useState(false);\n\n const commit = useCallback(\n (next: FileUploadItem[]) => {\n setItems(next);\n },\n [setItems],\n );\n\n const addFiles = useCallback(\n (incomingFiles: File[]) => {\n if (disabled || incomingFiles.length === 0) return;\n\n const remainingSlots =\n maxFiles === undefined ? incomingFiles.length : maxFiles - items.length;\n if (remainingSlots <= 0) return;\n\n const files = incomingFiles.slice(0, multiple ? remainingSlots : Math.min(1, remainingSlots));\n const added = files.map((file, index) => createFileUploadItem(file, index));\n\n if (added.length === 0) return;\n\n commit([...items, ...added]);\n onFilesAdded?.(added, files);\n },\n [commit, disabled, items, maxFiles, multiple, onFilesAdded],\n );\n\n const removeItem = useCallback(\n (item: FileUploadItem) => {\n commit(items.filter((entry) => entry.id !== item.id));\n onRemove?.(item);\n },\n [commit, items, onRemove],\n );\n\n const retryItem = useCallback(\n (item: FileUploadItem) => {\n const retryingItem = {\n ...item,\n error: undefined,\n progress: 0,\n status: \"uploading\" as const,\n };\n\n commit(items.map((entry) => (entry.id === item.id ? retryingItem : entry)));\n onRetry?.(retryingItem);\n },\n [commit, items, onRetry],\n );\n\n const resetDrag = useCallback(() => {\n dragDepthRef.current = 0;\n setDragging(false);\n }, []);\n\n const maxReached = maxFiles !== undefined && items.length >= maxFiles;\n const centered = variant === \"centered\";\n\n return (\n <div className={cn(\"w-full space-y-3\", className, classNames?.root)}>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n aria-label=\"Upload files\"\n accept={accept}\n multiple={multiple}\n disabled={disabled || maxReached}\n tabIndex={-1}\n className=\"sr-only\"\n onChange={(event) => {\n addFiles(Array.from(event.currentTarget.files ?? []));\n event.currentTarget.value = \"\";\n }}\n />\n\n <button\n type=\"button\"\n disabled={disabled || maxReached}\n data-dragging={dragging}\n onClick={() => inputRef.current?.click()}\n onDragEnter={(event) => {\n if (disabled || maxReached) return;\n event.preventDefault();\n dragDepthRef.current += 1;\n setDragging(true);\n }}\n onDragOver={(event) => {\n if (disabled || maxReached) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n setDragging(true);\n }}\n onDragLeave={(event) => {\n if (disabled || maxReached) return;\n event.preventDefault();\n dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n if (dragDepthRef.current === 0) setDragging(false);\n }}\n onDrop={(event) => {\n if (disabled || maxReached) return;\n event.preventDefault();\n resetDrag();\n addFiles(Array.from(event.dataTransfer.files));\n }}\n className={cn(\n \"group relative flex w-full overflow-hidden rounded-3xl border border-border border-dashed bg-background outline-none\",\n \"transition-[border-color,transform] duration-200 active:scale-[0.99]\",\n \"hover:border-foreground/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n \"data-[dragging=true]:border-foreground\",\n \"disabled:pointer-events-none disabled:opacity-55\",\n centered\n ? \"min-h-56 flex-col items-center justify-center gap-3 p-7 text-center\"\n : \"items-center gap-4 p-5 text-left\",\n classNames?.dropzone,\n )}\n >\n <motion.span\n aria-hidden=\"true\"\n className={cn(\n \"grid shrink-0 place-items-center bg-muted text-foreground\",\n centered\n ? \"h-16 w-16 rounded-[1.35rem] border border-border\"\n : \"h-14 w-14 rounded-[1.25rem]\",\n )}\n animate={\n reduce\n ? undefined\n : {\n transform: dragging ? \"translateY(-2px)\" : \"translateY(0px)\",\n }\n }\n transition={FAST_TRANSITION}\n >\n <UploadCloud className={centered ? \"h-7 w-7\" : \"h-6 w-6\"} />\n </motion.span>\n\n <span className={cn(\"min-w-0\", centered ? \"max-w-xs\" : \"flex-1\")}>\n <span\n className={cn(\n \"block font-semibold text-foreground\",\n centered ? \"text-base\" : \"text-sm\",\n )}\n >\n {maxReached ? \"Upload limit reached\" : title}\n </span>\n <span\n className={cn(\n \"block text-muted-foreground text-xs\",\n centered ? \"mt-1 leading-5\" : \"mt-0.5\",\n )}\n >\n {maxReached ? `${items.length} of ${maxFiles} files added` : description}\n </span>\n </span>\n\n <span\n className={cn(\n \"shrink-0 rounded-full border border-border font-medium text-foreground text-xs transition-colors duration-150 group-hover:bg-muted\",\n centered ? \"mt-1 px-4 py-2\" : \"px-3.5 py-2\",\n )}\n >\n {browseLabel}\n </span>\n </button>\n\n <ul className={cn(\"space-y-2\", classNames?.queue)}>\n <AnimatePresence initial={false}>\n {items.map((item) => (\n <FileUploadRow\n key={item.id}\n item={item}\n onRemove={removeItem}\n onRetry={retryItem}\n classNames={classNames}\n />\n ))}\n </AnimatePresence>\n </ul>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAsEA,MAAM,iBAAiB;CAAE,UAAU;CAAM,MAAM;AAAS;AACxD,MAAM,kBAAkB;CAAE,UAAU;CAAM,MAAM;AAA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AAI,GAAG,aAAa,UAAU,CAAC;KAC3D,IAAI,aAAa,YAAY,GAAG,YAAY,KAAK;IACnD;IACA,SAAS,UAAU;KACjB,IAAI,YAAY,YAAY;KAC5B,MAAM,eAAe;KACrB,UAAU;KACV,SAAS,MAAM,KAAK,MAAM,aAAa,KAAK,CAAC;IAC/C;IACA,WAAW,GACT,wHACA,wEACA,4IACA,0CACA,oDACA,WACI,wEACA,oCACJ,YAAY,QACd;IAvCF,UAAA;KAyCE,oBAAC,OAAO,MAAR;MACE,eAAY;MACZ,WAAW,GACT,6DACA,WACI,qDACA,6BACN;MACA,SACE,SACI,KAAA,IACA,EACE,WAAW,WAAW,qBAAqB,kBAC7C;MAEN,YAAY;MAEZ,UAAA,oBAAC,aAAD,EAAa,WAAW,WAAW,YAAY,UAAY,CAAA;KAChD,CAAA;KAEb,qBAAC,QAAD;MAAM,WAAW,GAAG,WAAW,WAAW,aAAa,QAAQ;MAA/D,UAAA,CACE,oBAAC,QAAD;OACE,WAAW,GACT,uCACA,WAAW,cAAc,SAC3B;OAEC,UAAA,aAAa,yBAAyB;MACnC,CAAA,GACN,oBAAC,QAAD;OACE,WAAW,GACT,uCACA,WAAW,mBAAmB,QAChC;OAEC,UAAA,aAAa,GAAG,MAAM,OAAO,MAAM,SAAS,gBAAgB;MACzD,CAAA,CACF;;KAEN,oBAAC,QAAD;MACE,WAAW,GACT,sIACA,WAAW,mBAAmB,aAChC;MAEC,UAAA;KACG,CAAA;IACA;;GAER,oBAAC,MAAD;IAAI,WAAW,GAAG,aAAa,YAAY,KAAK;IAC9C,UAAA,oBAAC,iBAAD;KAAiB,SAAS;KACvB,UAAA,MAAM,KAAK,SACV,oBAAC,eAAD;MAEQ;MACN,UAAU;MACV,SAAS;MACG;KACb,GALM,KAAK,EAKX,CACF;IACc,CAAA;GACf,CAAA;EACD;;AAET"}
@@ -2,8 +2,8 @@
2
2
  import { EASE_OUT, SPRING_PRESS } from "../../lib/ease.js";
3
3
  import { forwardRef, useRef, useState } from "react";
4
4
  import { cn } from "@kumix/utils";
5
- import { motion, useReducedMotion } from "motion/react";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { motion, useReducedMotion } from "motion/react";
7
7
  //#region src/components/motion/hold-action-button.tsx
8
8
  const HoldActionButton = forwardRef(function HoldActionButton({ children, type = "vertical", holdingLabel = "Keep holding", completeLabel = "Done", holdDuration = 1600, onHoldComplete, fillClassName, labelClassName, className, disabled, ...rest }, ref) {
9
9
  const reduce = useReducedMotion();
@@ -0,0 +1,31 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/infinite-masonry.d.ts
3
+ type InfiniteMasonryKey = string | number | bigint;
4
+ interface InfiniteMasonryProps<T> {
5
+ items: readonly T[];
6
+ getItemKey: (item: T, index: number) => InfiniteMasonryKey;
7
+ renderItem: (item: T, index: number) => ReactNode;
8
+ onLoadMore: () => void | Promise<void>;
9
+ hasMore: boolean;
10
+ loading?: boolean;
11
+ error?: ReactNode;
12
+ onRetry?: () => void;
13
+ estimateSize?: (item: T, index: number) => number;
14
+ renderLoadingItem?: (index: number) => ReactNode;
15
+ emptyState?: ReactNode;
16
+ endState?: ReactNode;
17
+ minColumnWidth?: number;
18
+ maxColumns?: number;
19
+ gap?: number;
20
+ overscan?: number;
21
+ prefetch?: number;
22
+ animateItems?: boolean;
23
+ ariaLabel?: string;
24
+ className?: string;
25
+ contentClassName?: string;
26
+ itemClassName?: string;
27
+ }
28
+ declare function InfiniteMasonry<T>({ items, getItemKey, renderItem, onLoadMore, hasMore, loading, error, onRetry, estimateSize, renderLoadingItem, emptyState, endState, minColumnWidth, maxColumns, gap, overscan, prefetch, animateItems, ariaLabel, className, contentClassName, itemClassName }: InfiniteMasonryProps<T>): import("react").JSX.Element;
29
+ //#endregion
30
+ export { InfiniteMasonry, InfiniteMasonryKey, InfiniteMasonryProps };
31
+ //# sourceMappingURL=infinite-masonry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infinite-masonry.d.ts","names":[],"sources":["../../../src/components/motion/infinite-masonry.tsx"],"mappings":";;KAUY;UAEK,qBAAqB;EACpC,gBAAgB;EAChB,aAAa,MAAM,GAAG,kBAAkB;EACxC,aAAa,MAAM,GAAG,kBAAkB;EACxC,yBAAyB;EACzB;EACA;EACA,QAAQ;EACR;EACA,gBAAgB,MAAM,GAAG;EACzB,qBAAqB,kBAAkB;EACvC,aAAa;EACb,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAiHc,gBAAgB,KAC9B,OACA,YACA,YACA,YACA,SACA,SACA,OACA,SACA,cACA,mBACA,YACA,UACA,gBACA,YACA,KACA,UACA,UACA,cACA,WACA,WACA,kBACA,iBACC,qBAAqB,qBAAE,IAAA"}