@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,737 @@
1
+ "use client";
2
+ import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ease.js";
3
+ import { Tooltip } from "./tooltip.js";
4
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
5
+ import { cn } from "@kumix/utils";
6
+ import { AlertCircle, Check, ExternalLink, FileImage, Link, LoaderCircle, Mic, Paperclip, Pause, Play, RotateCcw, Upload, X } from "lucide-react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { AnimatePresence, LayoutGroup, motion, useReducedMotion } from "motion/react";
9
+ import { createPortal } from "react-dom";
10
+ //#region src/components/motion/attachment-upload.tsx
11
+ const ITEM_TRANSITION = {
12
+ duration: .2,
13
+ ease: EASE_OUT
14
+ };
15
+ const DEFAULT_MAX_FILE_SIZE = 524288e3;
16
+ const UPLOAD_PROGRESS_MS = 900;
17
+ const UPLOAD_COMPLETE_HOLD_MS = 1e3;
18
+ const REMOVE_PENDING_MS = 420;
19
+ const WAVEFORM_BARS = [
20
+ 18,
21
+ 31,
22
+ 24,
23
+ 39,
24
+ 30,
25
+ 43,
26
+ 27,
27
+ 18,
28
+ 9,
29
+ 29,
30
+ 38,
31
+ 24,
32
+ 34,
33
+ 18,
34
+ 26,
35
+ 37,
36
+ 21,
37
+ 14,
38
+ 7,
39
+ 11,
40
+ 22,
41
+ 35,
42
+ 18,
43
+ 26,
44
+ 41,
45
+ 29,
46
+ 17,
47
+ 33
48
+ ].map((height, index) => ({
49
+ id: `wave-${index}-${height}`,
50
+ height
51
+ }));
52
+ function useControllableList({ value, defaultValue, onValueChange }) {
53
+ const [internalValue, setInternalValue] = useState(defaultValue ?? []);
54
+ const controlled = value !== void 0;
55
+ return [value ?? internalValue, useCallback((next) => {
56
+ if (!controlled) setInternalValue(next);
57
+ onValueChange?.(next);
58
+ }, [controlled, onValueChange])];
59
+ }
60
+ function formatBytes(bytes) {
61
+ if (bytes === void 0 || !Number.isFinite(bytes) || bytes <= 0) return null;
62
+ const units = [
63
+ "B",
64
+ "KB",
65
+ "MB",
66
+ "GB"
67
+ ];
68
+ const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
69
+ const value = bytes / 1024 ** exponent;
70
+ return `${value >= 10 || exponent === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[exponent]}`;
71
+ }
72
+ function formatDuration(seconds) {
73
+ const safeSeconds = Math.max(0, Math.round(seconds ?? 0));
74
+ return `${Math.floor(safeSeconds / 60)}:${String(safeSeconds % 60).padStart(2, "0")}`;
75
+ }
76
+ function formatMaxSize(bytes) {
77
+ const megabytes = bytes / 1048576;
78
+ return `${Number.isInteger(megabytes) ? megabytes : megabytes.toFixed(1)} MB`;
79
+ }
80
+ function inferKind(file) {
81
+ if (file.type.startsWith("image/")) return "image";
82
+ if (file.type.startsWith("audio/")) return "audio";
83
+ return "file";
84
+ }
85
+ function AttachmentIcon({ kind }) {
86
+ if (kind === "link") return /* @__PURE__ */ jsx(Link, { className: "size-4" });
87
+ if (kind === "image") return /* @__PURE__ */ jsx(FileImage, { className: "size-4" });
88
+ if (kind === "audio") return /* @__PURE__ */ jsx(Mic, { className: "size-4" });
89
+ return /* @__PURE__ */ jsx(Paperclip, { className: "size-4" });
90
+ }
91
+ function imageSource(item) {
92
+ if (item.kind !== "image") return void 0;
93
+ return item.previewUrl ?? item.href;
94
+ }
95
+ function RowAction({ label, onClick, state, retryable = false, reduce = false }) {
96
+ if (state === "uploading") return /* @__PURE__ */ jsx("span", {
97
+ "aria-hidden": "true",
98
+ className: "size-9 shrink-0"
99
+ });
100
+ if (state === "complete") return /* @__PURE__ */ jsx(Tooltip, {
101
+ content: "Upload complete",
102
+ side: "top",
103
+ delay: 100,
104
+ children: /* @__PURE__ */ jsx(motion.span, {
105
+ role: "status",
106
+ "aria-label": `Upload complete for ${label}`,
107
+ initial: reduce ? { opacity: 0 } : {
108
+ opacity: 0,
109
+ scale: .75
110
+ },
111
+ animate: {
112
+ opacity: 1,
113
+ scale: 1
114
+ },
115
+ transition: ITEM_TRANSITION,
116
+ className: "grid size-9 shrink-0 place-items-center rounded-xl text-emerald-600 dark:text-emerald-400",
117
+ children: /* @__PURE__ */ jsx(Check, { className: "size-4" })
118
+ })
119
+ });
120
+ if (state === "removing") return /* @__PURE__ */ jsx(Tooltip, {
121
+ content: "Removing attachment",
122
+ side: "top",
123
+ delay: 100,
124
+ children: /* @__PURE__ */ jsx("span", {
125
+ role: "status",
126
+ "aria-label": `Removing ${label}`,
127
+ className: "grid size-9 shrink-0 place-items-center rounded-xl text-muted-foreground",
128
+ children: /* @__PURE__ */ jsx(motion.span, {
129
+ animate: reduce ? void 0 : { rotate: 360 },
130
+ transition: {
131
+ duration: .7,
132
+ ease: "linear",
133
+ repeat: Infinity
134
+ },
135
+ className: "grid place-items-center",
136
+ children: /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4" })
137
+ })
138
+ })
139
+ });
140
+ if (state === "failed") {
141
+ if (!retryable) return /* @__PURE__ */ jsx(Tooltip, {
142
+ content: "Upload failed",
143
+ side: "top",
144
+ delay: 100,
145
+ children: /* @__PURE__ */ jsx("span", {
146
+ role: "status",
147
+ "aria-label": `Upload failed for ${label}`,
148
+ className: "grid size-9 shrink-0 place-items-center rounded-xl text-destructive",
149
+ children: /* @__PURE__ */ jsx(AlertCircle, { className: "size-4" })
150
+ })
151
+ });
152
+ return /* @__PURE__ */ jsx(Tooltip, {
153
+ content: "Retry upload",
154
+ side: "top",
155
+ delay: 100,
156
+ children: /* @__PURE__ */ jsx(motion.button, {
157
+ type: "button",
158
+ "aria-label": `Retry ${label}`,
159
+ onClick,
160
+ whileTap: reduce ? void 0 : { scale: .92 },
161
+ transition: SPRING_PRESS,
162
+ className: "grid size-9 shrink-0 place-items-center rounded-xl text-destructive outline-none transition-colors hover:bg-destructive/10 focus-visible:ring-2 focus-visible:ring-ring",
163
+ children: /* @__PURE__ */ jsx(RotateCcw, { className: "size-4" })
164
+ })
165
+ });
166
+ }
167
+ return /* @__PURE__ */ jsx(Tooltip, {
168
+ content: "Remove attachment",
169
+ side: "top",
170
+ delay: 100,
171
+ children: /* @__PURE__ */ jsx(motion.button, {
172
+ type: "button",
173
+ "aria-label": `Remove ${label}`,
174
+ onClick,
175
+ whileTap: reduce ? void 0 : { scale: .92 },
176
+ transition: SPRING_PRESS,
177
+ className: "grid size-9 shrink-0 place-items-center rounded-xl text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
178
+ children: /* @__PURE__ */ jsx(X, { className: "size-4" })
179
+ })
180
+ });
181
+ }
182
+ function ImageThumbnail({ item, layoutId, onPreview, reduce }) {
183
+ const src = imageSource(item);
184
+ if (!src) return /* @__PURE__ */ jsx("span", {
185
+ "aria-hidden": "true",
186
+ className: "grid size-8 shrink-0 place-items-center rounded-lg bg-muted text-muted-foreground",
187
+ children: /* @__PURE__ */ jsx(FileImage, { className: "size-4" })
188
+ });
189
+ return /* @__PURE__ */ jsx(Tooltip, {
190
+ side: "top",
191
+ delay: 160,
192
+ wrapperClassName: "shrink-0",
193
+ className: "rounded-xl p-1 shadow-xl",
194
+ content: /* @__PURE__ */ jsxs("span", {
195
+ className: "block w-32",
196
+ children: [/* @__PURE__ */ jsx("img", {
197
+ src,
198
+ alt: "",
199
+ className: "h-20 w-full rounded-lg object-cover"
200
+ }), /* @__PURE__ */ jsx("span", {
201
+ className: "block px-1 pt-1 pb-0.5 text-center font-medium text-[10px] text-muted-foreground",
202
+ children: "Click to preview"
203
+ })]
204
+ }),
205
+ children: /* @__PURE__ */ jsx(motion.button, {
206
+ type: "button",
207
+ "aria-label": `Preview ${item.name}`,
208
+ onClick: (event) => {
209
+ event.currentTarget.blur();
210
+ onPreview(item);
211
+ },
212
+ whileTap: reduce ? void 0 : { scale: .94 },
213
+ transition: SPRING_PRESS,
214
+ className: "group/image relative size-9 shrink-0 overflow-hidden rounded-[10px] bg-muted outline-none ring-1 ring-border/70 focus-visible:ring-2 focus-visible:ring-ring",
215
+ children: /* @__PURE__ */ jsx(motion.img, {
216
+ layoutId,
217
+ src,
218
+ alt: "",
219
+ className: "size-full object-cover",
220
+ transition: { layout: SPRING_LAYOUT }
221
+ })
222
+ })
223
+ });
224
+ }
225
+ function ImagePreviewDialog({ item, layoutId, onClose, reduce }) {
226
+ const closeRef = useRef(null);
227
+ useEffect(() => {
228
+ if (!item) return;
229
+ const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
230
+ const previousOverflow = document.body.style.overflow;
231
+ document.body.style.overflow = "hidden";
232
+ closeRef.current?.focus();
233
+ const handleKeyDown = (event) => {
234
+ if (event.key === "Escape") onClose();
235
+ if (event.key === "Tab") {
236
+ event.preventDefault();
237
+ closeRef.current?.focus();
238
+ }
239
+ };
240
+ document.addEventListener("keydown", handleKeyDown);
241
+ return () => {
242
+ document.removeEventListener("keydown", handleKeyDown);
243
+ document.body.style.overflow = previousOverflow;
244
+ previousFocus?.focus();
245
+ };
246
+ }, [item, onClose]);
247
+ if (typeof document === "undefined") return null;
248
+ const src = item ? imageSource(item) : void 0;
249
+ const content = item && src ? /* @__PURE__ */ jsxs("div", {
250
+ className: "pointer-events-none fixed inset-0 z-10000",
251
+ children: [/* @__PURE__ */ jsx(motion.button, {
252
+ type: "button",
253
+ "aria-label": "Close image preview",
254
+ tabIndex: -1,
255
+ className: "pointer-events-auto absolute inset-0 size-full cursor-default bg-black/45 backdrop-blur-xl",
256
+ initial: { opacity: 0 },
257
+ animate: { opacity: 1 },
258
+ exit: reduce ? void 0 : { opacity: 0 },
259
+ transition: {
260
+ duration: reduce ? .1 : .2,
261
+ ease: EASE_OUT
262
+ },
263
+ onClick: onClose
264
+ }), /* @__PURE__ */ jsx("div", {
265
+ className: "absolute inset-0 flex items-center justify-center p-4 sm:p-8",
266
+ children: /* @__PURE__ */ jsxs(motion.div, {
267
+ role: "dialog",
268
+ "aria-modal": "true",
269
+ "aria-label": `Preview of ${item.name}`,
270
+ initial: { opacity: 0 },
271
+ animate: { opacity: 1 },
272
+ exit: reduce ? void 0 : { opacity: 0 },
273
+ transition: ITEM_TRANSITION,
274
+ className: "pointer-events-auto relative",
275
+ children: [/* @__PURE__ */ jsx(motion.img, {
276
+ layoutId: reduce ? void 0 : layoutId,
277
+ src,
278
+ alt: item.name,
279
+ className: "max-h-[90vh] max-w-[90vw] rounded-2xl object-contain shadow-2xl",
280
+ transition: { layout: SPRING_LAYOUT }
281
+ }), /* @__PURE__ */ jsx(motion.button, {
282
+ ref: closeRef,
283
+ type: "button",
284
+ "aria-label": "Close image preview",
285
+ onClick: onClose,
286
+ initial: reduce ? { opacity: 0 } : {
287
+ opacity: 0,
288
+ scale: .8
289
+ },
290
+ animate: {
291
+ opacity: 1,
292
+ scale: 1
293
+ },
294
+ exit: reduce ? void 0 : {
295
+ opacity: 0,
296
+ scale: .8
297
+ },
298
+ whileTap: reduce ? void 0 : { scale: .92 },
299
+ transition: SPRING_PRESS,
300
+ className: "absolute -top-3 -right-3 grid size-9 place-items-center rounded-full bg-background text-foreground shadow-xl outline-none ring-1 ring-border/70 transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",
301
+ children: /* @__PURE__ */ jsx(X, { className: "size-4" })
302
+ })]
303
+ })
304
+ })]
305
+ }) : null;
306
+ return createPortal(reduce ? content : /* @__PURE__ */ jsx(AnimatePresence, { children: content }), document.body);
307
+ }
308
+ function AttachmentRow({ item, playing, uploading, uploadComplete, failed, removing, arrivalIndex, imageLayoutId, onAudioToggle, onImagePreview, onRemove, onRetry, reduce, className }) {
309
+ const size = formatBytes(item.size);
310
+ const progress = item.duration && item.duration > 0 ? Math.min(1, Math.max(0, (item.currentTime ?? 0) / item.duration)) : 0;
311
+ const actionState = removing ? "removing" : uploading ? "uploading" : uploadComplete ? "complete" : failed ? "failed" : "idle";
312
+ const arrivalDelay = Math.min(Math.max(arrivalIndex, 0), 5) * .055;
313
+ const rowTransition = !reduce && arrivalIndex >= 0 ? {
314
+ ...SPRING_LAYOUT,
315
+ delay: arrivalDelay,
316
+ opacity: {
317
+ duration: .16,
318
+ ease: EASE_OUT,
319
+ delay: arrivalDelay
320
+ }
321
+ } : ITEM_TRANSITION;
322
+ const showUploadProgress = uploading || uploadComplete;
323
+ const uploadProgress = /* @__PURE__ */ jsx(motion.span, {
324
+ role: "progressbar",
325
+ "aria-label": `Uploading ${item.name}`,
326
+ className: "pointer-events-none absolute inset-0 -z-10 origin-left bg-emerald-400/25 dark:bg-emerald-500/20",
327
+ initial: {
328
+ opacity: 1,
329
+ scaleX: 0
330
+ },
331
+ animate: {
332
+ opacity: 1,
333
+ scaleX: 1
334
+ },
335
+ exit: reduce ? void 0 : { opacity: 0 },
336
+ transition: {
337
+ duration: reduce ? .1 : UPLOAD_PROGRESS_MS / 1e3,
338
+ ease: EASE_OUT
339
+ }
340
+ });
341
+ return /* @__PURE__ */ jsxs(motion.li, {
342
+ layout: !reduce,
343
+ initial: reduce ? { opacity: 0 } : arrivalIndex >= 0 ? {
344
+ opacity: 0,
345
+ y: -16,
346
+ scale: .985
347
+ } : {
348
+ opacity: 0,
349
+ y: 6
350
+ },
351
+ animate: {
352
+ opacity: 1,
353
+ y: 0,
354
+ scale: 1
355
+ },
356
+ exit: reduce ? void 0 : {
357
+ opacity: 0,
358
+ y: -4
359
+ },
360
+ transition: rowTransition,
361
+ className: cn("flex min-h-14 items-center gap-1 rounded-2xl bg-muted/70 p-1", className),
362
+ children: [/* @__PURE__ */ jsxs("div", {
363
+ className: "relative isolate flex min-w-0 flex-1 items-center gap-3 self-stretch overflow-hidden rounded-xl bg-background px-2 py-1",
364
+ children: [
365
+ failed ? /* @__PURE__ */ jsx("span", {
366
+ "aria-hidden": "true",
367
+ className: "pointer-events-none absolute inset-0 -z-10 bg-destructive/10"
368
+ }) : null,
369
+ item.kind === "image" ? /* @__PURE__ */ jsx(ImageThumbnail, {
370
+ item,
371
+ layoutId: imageLayoutId,
372
+ onPreview: onImagePreview,
373
+ reduce
374
+ }) : /* @__PURE__ */ jsx("span", {
375
+ "aria-hidden": "true",
376
+ className: "grid size-7 shrink-0 place-items-center text-muted-foreground",
377
+ children: /* @__PURE__ */ jsx(AttachmentIcon, { kind: item.kind })
378
+ }),
379
+ item.kind === "audio" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
380
+ /* @__PURE__ */ jsx("span", {
381
+ className: "w-9 shrink-0 text-muted-foreground text-xs tabular-nums",
382
+ children: formatDuration(item.currentTime)
383
+ }),
384
+ /* @__PURE__ */ jsx("span", {
385
+ "aria-hidden": "true",
386
+ className: "flex h-11 min-w-0 flex-1 items-center gap-[3px] overflow-hidden",
387
+ children: WAVEFORM_BARS.map((bar, index) => /* @__PURE__ */ jsx(motion.span, {
388
+ className: cn("w-[3px] shrink-0 rounded-full", index / WAVEFORM_BARS.length <= progress ? "bg-foreground" : "bg-muted-foreground/35"),
389
+ style: { height: bar.height },
390
+ animate: reduce || !playing ? void 0 : { scaleY: [
391
+ .72,
392
+ 1,
393
+ .78
394
+ ] },
395
+ transition: {
396
+ duration: .55,
397
+ ease: EASE_OUT,
398
+ repeat: Infinity,
399
+ delay: index * .018
400
+ }
401
+ }, bar.id))
402
+ }),
403
+ /* @__PURE__ */ jsx("span", {
404
+ className: "w-9 shrink-0 text-right text-muted-foreground text-xs tabular-nums",
405
+ children: formatDuration(item.duration)
406
+ }),
407
+ /* @__PURE__ */ jsx(motion.button, {
408
+ type: "button",
409
+ "aria-label": `${playing ? "Pause" : "Play"} ${item.name}`,
410
+ onClick: () => onAudioToggle?.(item),
411
+ whileTap: { scale: .94 },
412
+ transition: SPRING_PRESS,
413
+ className: "grid size-9 shrink-0 place-items-center rounded-full bg-foreground text-background outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
414
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
415
+ mode: "wait",
416
+ initial: false,
417
+ children: /* @__PURE__ */ jsx(motion.span, {
418
+ initial: reduce ? { opacity: 0 } : {
419
+ opacity: 0,
420
+ scale: .8
421
+ },
422
+ animate: {
423
+ opacity: 1,
424
+ scale: 1
425
+ },
426
+ exit: reduce ? { opacity: 0 } : {
427
+ opacity: 0,
428
+ scale: .8
429
+ },
430
+ transition: ITEM_TRANSITION,
431
+ children: playing ? /* @__PURE__ */ jsx(Pause, { className: "size-4 fill-current" }) : /* @__PURE__ */ jsx(Play, { className: "size-4 translate-x-px fill-current" })
432
+ }, playing ? "pause" : "play")
433
+ })
434
+ })
435
+ ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
436
+ /* @__PURE__ */ jsxs("span", {
437
+ className: "min-w-0 flex-1",
438
+ children: [/* @__PURE__ */ jsx("span", {
439
+ className: "block truncate font-medium text-foreground text-sm",
440
+ children: item.name
441
+ }), failed ? /* @__PURE__ */ jsx("span", {
442
+ className: "block truncate text-[11px] text-destructive",
443
+ children: item.error ?? "Upload failed"
444
+ }) : null]
445
+ }),
446
+ /* @__PURE__ */ jsx("span", {
447
+ className: "shrink-0 text-muted-foreground text-xs",
448
+ children: item.kind === "link" ? "Web" : size
449
+ }),
450
+ item.kind === "link" && item.href ? /* @__PURE__ */ jsx("a", {
451
+ href: item.href,
452
+ target: "_blank",
453
+ rel: "noreferrer noopener",
454
+ "aria-label": `Open ${item.name}`,
455
+ className: "grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
456
+ children: /* @__PURE__ */ jsx(ExternalLink, { className: "size-4" })
457
+ }) : null
458
+ ] }),
459
+ reduce ? showUploadProgress ? uploadProgress : null : /* @__PURE__ */ jsx(AnimatePresence, { children: showUploadProgress ? uploadProgress : null })
460
+ ]
461
+ }), /* @__PURE__ */ jsx(RowAction, {
462
+ label: item.name,
463
+ onClick: () => {
464
+ if (actionState === "failed") {
465
+ onRetry?.(item);
466
+ return;
467
+ }
468
+ onRemove(item);
469
+ },
470
+ state: actionState,
471
+ retryable: onRetry !== void 0,
472
+ reduce
473
+ })]
474
+ });
475
+ }
476
+ function AttachmentUpload({ value, defaultValue, onValueChange, onFilesAdded, onFilesRejected, onRemove, onRetry, playingId, onAudioToggle, accept, multiple = true, maxFiles = 12, maxFileSize = DEFAULT_MAX_FILE_SIZE, disabled = false, title = "Drag and drop or browse files", description, attachmentsLabel = "Attachments", className, classNames }) {
477
+ const inputId = useId();
478
+ const inputRef = useRef(null);
479
+ const dragDepthRef = useRef(0);
480
+ const ownedUrlsRef = useRef(/* @__PURE__ */ new Set());
481
+ const lifecycleTimersRef = useRef(/* @__PURE__ */ new Set());
482
+ const reduce = useReducedMotion() ?? false;
483
+ const [dragging, setDragging] = useState(false);
484
+ const [previewItem, setPreviewItem] = useState(null);
485
+ const [uploadingIds, setUploadingIds] = useState(() => /* @__PURE__ */ new Set());
486
+ const [uploadCompleteIds, setUploadCompleteIds] = useState(() => /* @__PURE__ */ new Set());
487
+ const [removingIds, setRemovingIds] = useState(() => /* @__PURE__ */ new Set());
488
+ const [items, setItems] = useControllableList({
489
+ value,
490
+ defaultValue,
491
+ onValueChange
492
+ });
493
+ const itemsRef = useRef(items);
494
+ itemsRef.current = items;
495
+ useEffect(() => () => {
496
+ for (const url of ownedUrlsRef.current) URL.revokeObjectURL(url);
497
+ ownedUrlsRef.current.clear();
498
+ for (const timer of lifecycleTimersRef.current) clearTimeout(timer);
499
+ lifecycleTimersRef.current.clear();
500
+ }, []);
501
+ const maxReached = items.length >= maxFiles;
502
+ const scheduleLifecycle = useCallback((callback, delay) => {
503
+ const timer = setTimeout(() => {
504
+ lifecycleTimersRef.current.delete(timer);
505
+ callback();
506
+ }, delay);
507
+ lifecycleTimersRef.current.add(timer);
508
+ }, []);
509
+ const addFiles = useCallback((incomingFiles) => {
510
+ if (disabled || incomingFiles.length === 0) return;
511
+ const availableSlots = Math.max(0, maxFiles - items.length);
512
+ if (availableSlots === 0) {
513
+ onFilesRejected?.(incomingFiles, "max-files");
514
+ return;
515
+ }
516
+ const selectedFiles = incomingFiles.slice(0, multiple ? availableSlots : Math.min(1, availableSlots));
517
+ const oversized = selectedFiles.filter((file) => file.size > maxFileSize);
518
+ const accepted = selectedFiles.filter((file) => file.size <= maxFileSize);
519
+ if (oversized.length > 0) onFilesRejected?.(oversized, "too-large");
520
+ if (incomingFiles.length > selectedFiles.length) onFilesRejected?.(incomingFiles.slice(selectedFiles.length), "max-files");
521
+ const added = accepted.map((file, index) => {
522
+ const kind = inferKind(file);
523
+ const objectUrl = URL.createObjectURL(file);
524
+ ownedUrlsRef.current.add(objectUrl);
525
+ return {
526
+ id: `${Date.now()}-${index}-${file.name}`,
527
+ name: file.name,
528
+ kind,
529
+ size: file.size,
530
+ previewUrl: kind === "image" ? objectUrl : void 0,
531
+ href: objectUrl,
532
+ currentTime: kind === "audio" ? 0 : void 0,
533
+ duration: kind === "audio" ? 0 : void 0,
534
+ file
535
+ };
536
+ });
537
+ if (added.length === 0) return;
538
+ setItems([...items, ...added]);
539
+ const addedIds = added.map((item) => item.id);
540
+ setUploadingIds((current) => /* @__PURE__ */ new Set([...current, ...addedIds]));
541
+ scheduleLifecycle(() => {
542
+ setUploadingIds((current) => {
543
+ const next = new Set(current);
544
+ for (const id of addedIds) next.delete(id);
545
+ return next;
546
+ });
547
+ setUploadCompleteIds((current) => /* @__PURE__ */ new Set([...current, ...addedIds]));
548
+ scheduleLifecycle(() => {
549
+ setUploadCompleteIds((current) => {
550
+ const next = new Set(current);
551
+ for (const id of addedIds) next.delete(id);
552
+ return next;
553
+ });
554
+ }, UPLOAD_COMPLETE_HOLD_MS);
555
+ }, reduce ? 140 : UPLOAD_PROGRESS_MS);
556
+ onFilesAdded?.(added, accepted);
557
+ }, [
558
+ disabled,
559
+ items,
560
+ maxFileSize,
561
+ maxFiles,
562
+ multiple,
563
+ onFilesAdded,
564
+ onFilesRejected,
565
+ reduce,
566
+ scheduleLifecycle,
567
+ setItems
568
+ ]);
569
+ const finalizeRemove = useCallback((item) => {
570
+ const ownedUrl = [item.previewUrl, item.href].find((url) => url !== void 0 && ownedUrlsRef.current.has(url));
571
+ if (ownedUrl) {
572
+ URL.revokeObjectURL(ownedUrl);
573
+ ownedUrlsRef.current.delete(ownedUrl);
574
+ }
575
+ setPreviewItem((current) => current?.id === item.id ? null : current);
576
+ setUploadingIds((current) => {
577
+ const next = new Set(current);
578
+ next.delete(item.id);
579
+ return next;
580
+ });
581
+ setUploadCompleteIds((current) => {
582
+ const next = new Set(current);
583
+ next.delete(item.id);
584
+ return next;
585
+ });
586
+ setItems(itemsRef.current.filter((entry) => entry.id !== item.id));
587
+ onRemove?.(item);
588
+ }, [onRemove, setItems]);
589
+ const requestRemove = useCallback((item) => {
590
+ if (removingIds.has(item.id)) return;
591
+ setRemovingIds((current) => new Set(current).add(item.id));
592
+ scheduleLifecycle(() => {
593
+ finalizeRemove(item);
594
+ setRemovingIds((current) => {
595
+ const next = new Set(current);
596
+ next.delete(item.id);
597
+ return next;
598
+ });
599
+ }, reduce ? 140 : REMOVE_PENDING_MS);
600
+ }, [
601
+ finalizeRemove,
602
+ reduce,
603
+ removingIds,
604
+ scheduleLifecycle
605
+ ]);
606
+ const resetDrag = useCallback(() => {
607
+ dragDepthRef.current = 0;
608
+ setDragging(false);
609
+ }, []);
610
+ const closePreview = useCallback(() => setPreviewItem(null), []);
611
+ useEffect(() => {
612
+ if (previewItem && !items.some((item) => item.id === previewItem.id)) setPreviewItem(null);
613
+ }, [items, previewItem]);
614
+ const uploadOrder = Array.from(uploadingIds);
615
+ const previewLayoutId = previewItem ? `attachment-image-${previewItem.id}` : void 0;
616
+ return /* @__PURE__ */ jsx(LayoutGroup, {
617
+ id: inputId,
618
+ children: /* @__PURE__ */ jsxs("div", {
619
+ className: cn("w-full", className),
620
+ children: [
621
+ /* @__PURE__ */ jsx("input", {
622
+ ref: inputRef,
623
+ id: inputId,
624
+ type: "file",
625
+ "aria-label": "Upload attachments",
626
+ accept,
627
+ multiple,
628
+ disabled: disabled || maxReached,
629
+ tabIndex: -1,
630
+ className: "sr-only",
631
+ onChange: (event) => {
632
+ addFiles(Array.from(event.currentTarget.files ?? []));
633
+ event.currentTarget.value = "";
634
+ }
635
+ }),
636
+ /* @__PURE__ */ jsxs(motion.button, {
637
+ type: "button",
638
+ disabled: disabled || maxReached,
639
+ "data-dragging": dragging,
640
+ animate: reduce ? void 0 : { scale: dragging ? 1.006 : 1 },
641
+ whileTap: reduce ? void 0 : { scale: .995 },
642
+ transition: SPRING_PRESS,
643
+ onClick: () => inputRef.current?.click(),
644
+ onDragEnter: (event) => {
645
+ if (disabled || maxReached) return;
646
+ event.preventDefault();
647
+ dragDepthRef.current += 1;
648
+ setDragging(true);
649
+ },
650
+ onDragOver: (event) => {
651
+ if (disabled || maxReached) return;
652
+ event.preventDefault();
653
+ event.dataTransfer.dropEffect = "copy";
654
+ setDragging(true);
655
+ },
656
+ onDragLeave: (event) => {
657
+ if (disabled || maxReached) return;
658
+ event.preventDefault();
659
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
660
+ if (dragDepthRef.current === 0) setDragging(false);
661
+ },
662
+ onDrop: (event) => {
663
+ if (disabled || maxReached) return;
664
+ event.preventDefault();
665
+ resetDrag();
666
+ addFiles(Array.from(event.dataTransfer.files));
667
+ },
668
+ className: cn("group relative isolate flex min-h-52 w-full flex-col items-center justify-center overflow-hidden rounded-[2rem] bg-muted/65 p-2 text-center outline-none", "transition-colors duration-200 hover:bg-muted/85", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", "data-[dragging=true]:bg-muted", "disabled:pointer-events-none disabled:opacity-55", classNames?.dropzone),
669
+ children: [
670
+ /* @__PURE__ */ jsx("span", {
671
+ "aria-hidden": "true",
672
+ className: "absolute inset-2 -z-10 rounded-[1.5rem] border border-muted-foreground/25 border-dashed bg-background transition-[border-color,background-color] duration-200 group-hover:border-muted-foreground/45 group-data-[dragging=true]:border-foreground/65 group-data-[dragging=true]:bg-muted/20"
673
+ }),
674
+ /* @__PURE__ */ jsx(motion.span, {
675
+ "aria-hidden": "true",
676
+ animate: reduce ? void 0 : {
677
+ y: dragging ? -4 : 0,
678
+ scale: dragging ? 1.08 : 1
679
+ },
680
+ transition: ITEM_TRANSITION,
681
+ className: "mb-3 grid size-11 place-items-center rounded-2xl bg-muted text-foreground transition-colors duration-200 group-hover:bg-muted/80 group-data-[dragging=true]:bg-foreground group-data-[dragging=true]:text-background",
682
+ children: /* @__PURE__ */ jsx(Upload, { className: "size-[18px]" })
683
+ }),
684
+ /* @__PURE__ */ jsx("span", {
685
+ className: "font-semibold text-foreground text-sm tracking-[-0.01em]",
686
+ children: maxReached ? "Attachment limit reached" : title
687
+ }),
688
+ /* @__PURE__ */ jsx("span", {
689
+ className: "mt-1 text-muted-foreground text-xs leading-5",
690
+ children: maxReached ? `${items.length} of ${maxFiles} attachments added` : description ?? `Maximum ${formatMaxSize(maxFileSize)} file size`
691
+ })
692
+ ]
693
+ }),
694
+ items.length > 0 ? /* @__PURE__ */ jsxs("section", {
695
+ className: "mt-8",
696
+ "aria-labelledby": `${inputId}-attachments`,
697
+ children: [/* @__PURE__ */ jsx("h3", {
698
+ id: `${inputId}-attachments`,
699
+ className: "font-semibold text-foreground text-sm",
700
+ children: attachmentsLabel
701
+ }), items.length > 0 ? /* @__PURE__ */ jsx("ul", {
702
+ className: cn("mt-3 space-y-2", classNames?.list),
703
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
704
+ initial: uploadOrder.length > 0,
705
+ children: items.map((item) => /* @__PURE__ */ jsx(AttachmentRow, {
706
+ item,
707
+ playing: playingId === item.id,
708
+ uploading: uploadingIds.has(item.id) || item.status === "uploading",
709
+ uploadComplete: uploadCompleteIds.has(item.id) || item.status === "complete",
710
+ failed: item.status === "failed",
711
+ removing: removingIds.has(item.id),
712
+ arrivalIndex: uploadOrder.indexOf(item.id),
713
+ imageLayoutId: reduce ? void 0 : `attachment-image-${item.id}`,
714
+ onAudioToggle,
715
+ onImagePreview: setPreviewItem,
716
+ onRemove: requestRemove,
717
+ onRetry,
718
+ reduce,
719
+ className: classNames?.row
720
+ }, item.id))
721
+ })
722
+ }) : null]
723
+ }) : null,
724
+ /* @__PURE__ */ jsx(ImagePreviewDialog, {
725
+ item: previewItem,
726
+ layoutId: reduce ? void 0 : previewLayoutId,
727
+ onClose: closePreview,
728
+ reduce
729
+ })
730
+ ]
731
+ })
732
+ });
733
+ }
734
+ //#endregion
735
+ export { AttachmentUpload };
736
+
737
+ //# sourceMappingURL=attachment-upload.js.map