@joewinke/jatui 0.1.10 → 0.1.19

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 (91) hide show
  1. package/README.md +123 -0
  2. package/package.json +3 -1
  3. package/src/lib/actions/railNav.ts +473 -0
  4. package/src/lib/components/AnnotationLayer.svelte +108 -0
  5. package/src/lib/components/AnnotationPanel.svelte +319 -0
  6. package/src/lib/components/AudioWaveform.svelte +9 -5
  7. package/src/lib/components/AvailabilityModal.svelte +7 -3
  8. package/src/lib/components/AvatarUpload.svelte +27 -4
  9. package/src/lib/components/BookingForm.svelte +11 -9
  10. package/src/lib/components/BurndownChart.svelte +778 -0
  11. package/src/lib/components/Button.svelte +10 -1
  12. package/src/lib/components/CalendarPicker.svelte +3 -3
  13. package/src/lib/components/Card.svelte +2 -2
  14. package/src/lib/components/ChipInput.svelte +21 -15
  15. package/src/lib/components/ColorSelector.svelte +17 -13
  16. package/src/lib/components/CommentThread.svelte +773 -0
  17. package/src/lib/components/ConfirmDialog.svelte +348 -0
  18. package/src/lib/components/ConfirmModal.svelte +78 -11
  19. package/src/lib/components/ContextMenu.svelte +188 -0
  20. package/src/lib/components/CountdownTimer.svelte +1 -1
  21. package/src/lib/components/DateRangePicker.svelte +6 -4
  22. package/src/lib/components/Drawer.svelte +36 -3
  23. package/src/lib/components/EntityPreviewCard.svelte +104 -0
  24. package/src/lib/components/FileDropzone.svelte +493 -0
  25. package/src/lib/components/FilePicker.svelte +83 -14
  26. package/src/lib/components/FileThumbnail.svelte +80 -0
  27. package/src/lib/components/FilterDropdown.svelte +11 -11
  28. package/src/lib/components/HunkDiffView.svelte +348 -0
  29. package/src/lib/components/ImageLightbox.svelte +274 -0
  30. package/src/lib/components/ImageUpload.svelte +58 -9
  31. package/src/lib/components/InlineEdit.svelte +15 -9
  32. package/src/lib/components/InputDialog.svelte +327 -0
  33. package/src/lib/components/LazyImage.svelte +1 -0
  34. package/src/lib/components/LinkShortener.svelte +1 -1
  35. package/src/lib/components/LoadingSpinner.svelte +6 -2
  36. package/src/lib/components/MarkupEditor.svelte +485 -0
  37. package/src/lib/components/MarkupOverlay.svelte +55 -0
  38. package/src/lib/components/MediaWorkbench.svelte +871 -0
  39. package/src/lib/components/MilestoneCard.svelte +1 -1
  40. package/src/lib/components/MilestoneTimeline.svelte +1 -1
  41. package/src/lib/components/Modal.svelte +39 -4
  42. package/src/lib/components/PDFViewer.svelte +105 -0
  43. package/src/lib/components/PdfThumbnail.svelte +3 -1
  44. package/src/lib/components/PhoneInput.svelte +183 -63
  45. package/src/lib/components/ResizablePanel.svelte +4 -4
  46. package/src/lib/components/SearchDropdown.svelte +26 -13
  47. package/src/lib/components/SelectInput.svelte +26 -4
  48. package/src/lib/components/SidebarUserFooter.svelte +1 -1
  49. package/src/lib/components/SignaturePad.svelte +8 -4
  50. package/src/lib/components/SmartImageEditor.svelte +720 -0
  51. package/src/lib/components/SortDropdown.svelte +9 -3
  52. package/src/lib/components/Sparkline.svelte +9 -0
  53. package/src/lib/components/StatusBadge.svelte +20 -18
  54. package/src/lib/components/TextArea.svelte +24 -5
  55. package/src/lib/components/TextInput.svelte +29 -6
  56. package/src/lib/components/ThemeSelector.svelte +15 -4
  57. package/src/lib/components/TimeSlotPicker.svelte +7 -7
  58. package/src/lib/components/UserAvatar.svelte +14 -1
  59. package/src/lib/components/VariablePicker.svelte +170 -0
  60. package/src/lib/components/VoicePlayer.svelte +4 -3
  61. package/src/lib/components/markup.ts +287 -0
  62. package/src/lib/components/messaging/ChannelInfoModal.svelte +9 -9
  63. package/src/lib/components/messaging/ChannelList.svelte +1 -1
  64. package/src/lib/components/messaging/ChannelMembersModal.svelte +1 -1
  65. package/src/lib/components/messaging/CreateChannelModal.svelte +1 -1
  66. package/src/lib/components/messaging/DirectMessageList.svelte +1 -1
  67. package/src/lib/components/messaging/EmojiSelector.svelte +2 -1
  68. package/src/lib/components/messaging/MentionAutocomplete.svelte +1 -1
  69. package/src/lib/components/messaging/MessageAttachment.svelte +3 -3
  70. package/src/lib/components/messaging/MessageAttachmentUpload.svelte +3 -3
  71. package/src/lib/components/messaging/MessageInput.svelte +1 -1
  72. package/src/lib/components/messaging/MessageItem.svelte +6 -3
  73. package/src/lib/components/messaging/NotificationSettingsModal.svelte +1 -1
  74. package/src/lib/components/messaging/QuotedMessageDisplay.svelte +6 -1
  75. package/src/lib/components/messaging/StartDMModal.svelte +1 -1
  76. package/src/lib/components/pipeline/Pipeline.svelte +4 -4
  77. package/src/lib/components/pipeline/PipelineCard.svelte +1 -1
  78. package/src/lib/components/pipeline/PipelineColumn.svelte +8 -3
  79. package/src/lib/index.ts +105 -1
  80. package/src/lib/stores/confirmDialog.svelte.ts +48 -0
  81. package/src/lib/stores/inputDialog.svelte.ts +51 -0
  82. package/src/lib/styles/rail.css +63 -0
  83. package/src/lib/types/annotation.ts +38 -0
  84. package/src/lib/types/comments.ts +97 -0
  85. package/src/lib/types/entityPreview.ts +45 -0
  86. package/src/lib/types/filePicker.ts +2 -0
  87. package/src/lib/types/smartImageEditor.ts +39 -0
  88. package/src/lib/types/templateVars.ts +36 -0
  89. package/src/lib/utils/dateFormatters.ts +12 -10
  90. package/src/lib/utils/phone.ts +80 -0
  91. package/src/lib/utils/taskUtils.ts +21 -7
@@ -0,0 +1,493 @@
1
+ <script module lang="ts">
2
+ export interface FileDropzoneFile {
3
+ /** The raw File object for pending (pre-upload) files */
4
+ file?: File
5
+ /** Name to display */
6
+ name: string
7
+ /** MIME type */
8
+ mimeType: string
9
+ /** File size in bytes */
10
+ size?: number
11
+ /** URL for already-uploaded files (for FileThumbnail) */
12
+ url?: string
13
+ /** Arbitrary metadata for the consumer */
14
+ meta?: Record<string, unknown>
15
+ }
16
+ </script>
17
+
18
+ <script lang="ts">
19
+ import FileThumbnail from "./FileThumbnail.svelte"
20
+
21
+ // Lightweight extension→MIME map (avoids mime-types dependency)
22
+ const EXT_TO_MIME: Record<string, string> = {
23
+ png: "image/png",
24
+ jpg: "image/jpeg",
25
+ jpeg: "image/jpeg",
26
+ gif: "image/gif",
27
+ webp: "image/webp",
28
+ svg: "image/svg+xml",
29
+ avif: "image/avif",
30
+ bmp: "image/bmp",
31
+ ico: "image/x-icon",
32
+ tiff: "image/tiff",
33
+ tif: "image/tiff",
34
+ pdf: "application/pdf",
35
+ zip: "application/zip",
36
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
37
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
38
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
39
+ doc: "application/msword",
40
+ xls: "application/vnd.ms-excel",
41
+ ppt: "application/vnd.ms-powerpoint",
42
+ txt: "text/plain",
43
+ csv: "text/csv",
44
+ mp4: "video/mp4",
45
+ mp3: "audio/mpeg",
46
+ wav: "audio/wav",
47
+ dwg: "image/vnd.dwg",
48
+ }
49
+
50
+ const ZIP_TYPES = new Set([
51
+ "application/zip",
52
+ "application/x-zip-compressed",
53
+ "application/x-zip",
54
+ ])
55
+
56
+ function extToMime(filename: string): string | false {
57
+ const ext = filename.split(".").pop()?.toLowerCase() ?? ""
58
+ return EXT_TO_MIME[ext] ?? false
59
+ }
60
+
61
+ function mimeToExt(mime: string): string | false {
62
+ for (const [ext, m] of Object.entries(EXT_TO_MIME)) {
63
+ if (m === mime) return ext
64
+ }
65
+ return false
66
+ }
67
+
68
+ interface Props {
69
+ /** MIME types to accept, e.g. ["image/png","application/pdf"] */
70
+ accept?: string[]
71
+ /** Max file size in bytes (default 50 MB) */
72
+ maxSize?: number
73
+ /** Max number of files (default 10) */
74
+ maxFiles?: number
75
+ disabled?: boolean
76
+ /** Allow selecting multiple files */
77
+ multiple?: boolean
78
+ /** Already-uploaded files to show in the grid below the dropzone */
79
+ uploadedFiles?: FileDropzoneFile[]
80
+ /** Whether an upload is in flight */
81
+ isUploading?: boolean
82
+ /** Whether a ZIP extraction is in flight */
83
+ isExtracting?: boolean
84
+ /** Label shown in the dropzone (default: "Drop files or folders here") */
85
+ dropLabel?: string
86
+ /** Subtext shown below the label */
87
+ dropSubtext?: string
88
+ /** Called when the user selects or drops files (after validation) */
89
+ onFilesSelected?: (files: File[], errors: string[]) => void
90
+ }
91
+
92
+ let {
93
+ accept = [
94
+ "image/png",
95
+ "image/jpeg",
96
+ "application/pdf",
97
+ "application/zip",
98
+ "application/x-zip-compressed",
99
+ ],
100
+ maxSize = 50 * 1024 * 1024,
101
+ maxFiles = 10,
102
+ disabled = false,
103
+ multiple = true,
104
+ uploadedFiles = [],
105
+ isUploading = false,
106
+ isExtracting = false,
107
+ dropLabel = "Upload files",
108
+ dropSubtext,
109
+ onFilesSelected,
110
+ }: Props = $props()
111
+
112
+ let isDragOver = $state(false)
113
+ let fileInput = $state<HTMLInputElement>(undefined!)
114
+ let dropzoneRef = $state<HTMLElement>(undefined!)
115
+ let selectedFiles = $state<File[]>([])
116
+
117
+ // Human-readable accepted extensions for display
118
+ const acceptedExtensions = $derived(
119
+ accept
120
+ .map((type) => {
121
+ if (ZIP_TYPES.has(type)) return ".zip"
122
+ const ext = mimeToExt(type)
123
+ return ext ? `.${ext}` : type
124
+ })
125
+ .filter((v, i, a) => a.indexOf(v) === i) // dedupe
126
+ .join(", ")
127
+ )
128
+
129
+ function validateFile(file: File): string | null {
130
+ if (file.type && !accept.includes(file.type)) {
131
+ // Try to infer from extension for files where browser didn't set MIME
132
+ const inferred = extToMime(file.name)
133
+ if (!inferred || !accept.includes(inferred)) {
134
+ return `File type not supported. Accepted: ${acceptedExtensions}`
135
+ }
136
+ }
137
+ if (file.size > maxSize) {
138
+ const sizeMB = Math.round(maxSize / (1024 * 1024))
139
+ return `File too large (max ${sizeMB} MB)`
140
+ }
141
+ return null
142
+ }
143
+
144
+ function processFiles(files: FileList | File[]): { validFiles: File[]; errors: string[] } {
145
+ const fileArray = Array.from(files)
146
+ const validFiles: File[] = []
147
+ const errors: string[] = []
148
+
149
+ if (fileArray.length > maxFiles) {
150
+ errors.push(`Too many files. Maximum ${maxFiles} files allowed.`)
151
+ return { validFiles: [], errors }
152
+ }
153
+
154
+ for (const file of fileArray) {
155
+ const error = validateFile(file)
156
+ if (error) {
157
+ errors.push(`${file.name}: ${error}`)
158
+ } else {
159
+ validFiles.push(file)
160
+ }
161
+ }
162
+ return { validFiles, errors }
163
+ }
164
+
165
+ // Recursively read all files from a directory entry
166
+ async function readDirectoryEntries(entry: FileSystemDirectoryEntry): Promise<File[]> {
167
+ const files: File[] = []
168
+ const reader = entry.createReader()
169
+
170
+ const readBatch = (): Promise<FileSystemEntry[]> =>
171
+ new Promise((resolve, reject) => reader.readEntries(resolve, reject))
172
+
173
+ let batch: FileSystemEntry[]
174
+ do {
175
+ batch = await readBatch()
176
+ for (const child of batch) {
177
+ if (child.isFile) {
178
+ const file = await new Promise<File>((resolve, reject) =>
179
+ (child as FileSystemFileEntry).file(resolve, reject),
180
+ )
181
+ files.push(file)
182
+ } else if (child.isDirectory) {
183
+ const subFiles = await readDirectoryEntries(child as FileSystemDirectoryEntry)
184
+ files.push(...subFiles)
185
+ }
186
+ }
187
+ } while (batch.length > 0)
188
+
189
+ return files
190
+ }
191
+
192
+ // Collect files from DataTransfer items (handles folders)
193
+ async function collectDroppedFiles(dataTransfer: DataTransfer): Promise<File[]> {
194
+ const items = dataTransfer.items
195
+ if (!items || items.length === 0) {
196
+ return Array.from(dataTransfer.files)
197
+ }
198
+
199
+ const allFiles: File[] = []
200
+ const entries: FileSystemEntry[] = []
201
+
202
+ // Grab entries synchronously — they become invalid after await
203
+ for (let i = 0; i < items.length; i++) {
204
+ const entry = items[i].webkitGetAsEntry?.()
205
+ if (entry) entries.push(entry)
206
+ }
207
+
208
+ for (const entry of entries) {
209
+ if (entry.isFile) {
210
+ const file = await new Promise<File>((resolve, reject) =>
211
+ (entry as FileSystemFileEntry).file(resolve, reject),
212
+ )
213
+ allFiles.push(file)
214
+ } else if (entry.isDirectory) {
215
+ const dirFiles = await readDirectoryEntries(entry as FileSystemDirectoryEntry)
216
+ allFiles.push(...dirFiles)
217
+ }
218
+ }
219
+
220
+ return allFiles
221
+ }
222
+
223
+ function handleFileSelect(event: Event) {
224
+ const target = event.target as HTMLInputElement
225
+ if (target.files && target.files.length > 0) {
226
+ const { validFiles, errors } = processFiles(target.files)
227
+ selectedFiles = validFiles
228
+ onFilesSelected?.(validFiles, errors)
229
+ }
230
+ }
231
+
232
+ function handleDragEnter(event: DragEvent) {
233
+ event.preventDefault()
234
+ isDragOver = true
235
+ }
236
+
237
+ function handleDragLeave(event: DragEvent) {
238
+ event.preventDefault()
239
+ if (!dropzoneRef.contains(event.relatedTarget as Node)) {
240
+ isDragOver = false
241
+ }
242
+ }
243
+
244
+ function handleDragOver(event: DragEvent) {
245
+ event.preventDefault()
246
+ }
247
+
248
+ async function handleDrop(event: DragEvent) {
249
+ event.preventDefault()
250
+ isDragOver = false
251
+
252
+ if (disabled || !event.dataTransfer) return
253
+
254
+ const allFiles = await collectDroppedFiles(event.dataTransfer)
255
+ // Filter hidden / macOS artifact files
256
+ const filtered = allFiles.filter(
257
+ (f) => !f.name.startsWith(".") && !f.name.startsWith("__MACOSX"),
258
+ )
259
+
260
+ if (filtered.length > 0) {
261
+ const { validFiles, errors } = processFiles(filtered)
262
+ selectedFiles = validFiles
263
+ onFilesSelected?.(validFiles, errors)
264
+ }
265
+ }
266
+
267
+ function openFileDialog() {
268
+ if (!disabled) fileInput.click()
269
+ }
270
+
271
+ function formatFileSize(bytes: number): string {
272
+ if (bytes === 0) return "0 B"
273
+ const k = 1024
274
+ const sizes = ["B", "KB", "MB", "GB"]
275
+ const i = Math.floor(Math.log(bytes) / Math.log(k))
276
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i]
277
+ }
278
+
279
+ function fileIcon(file: File) {
280
+ if (file.type.startsWith("image/")) return "image"
281
+ if (file.type === "application/pdf") return "pdf"
282
+ if (ZIP_TYPES.has(file.type)) return "zip"
283
+ return "generic"
284
+ }
285
+
286
+ // Clear selected files when upload completes
287
+ $effect(() => {
288
+ if (!isUploading && uploadedFiles.length > 0) {
289
+ selectedFiles = []
290
+ }
291
+ })
292
+ </script>
293
+
294
+ <div class="w-full">
295
+ <!-- Hidden file input -->
296
+ <input
297
+ bind:this={fileInput}
298
+ type="file"
299
+ accept={accept.join(",")}
300
+ {multiple}
301
+ {disabled}
302
+ onchange={handleFileSelect}
303
+ class="hidden"
304
+ aria-hidden="true"
305
+ />
306
+
307
+ <!-- Dropzone -->
308
+ <div
309
+ bind:this={dropzoneRef}
310
+ class="relative border-2 border-dashed rounded-lg p-6 transition-all duration-200 cursor-pointer
311
+ {isDragOver
312
+ ? 'border-primary bg-primary/5 scale-[1.02]'
313
+ : disabled
314
+ ? 'border-base-300 bg-base-200 cursor-not-allowed'
315
+ : 'border-base-300 hover:border-primary hover:bg-primary/5'}"
316
+ onclick={openFileDialog}
317
+ ondragenter={handleDragEnter}
318
+ ondragleave={handleDragLeave}
319
+ ondragover={handleDragOver}
320
+ ondrop={handleDrop}
321
+ role="button"
322
+ tabindex="0"
323
+ aria-label={dropLabel}
324
+ onkeydown={(e) => {
325
+ if (e.key === "Enter" || e.key === " ") {
326
+ e.preventDefault()
327
+ openFileDialog()
328
+ }
329
+ }}
330
+ >
331
+ <div class="text-center">
332
+ <!-- Upload icon -->
333
+ <svg
334
+ class="mx-auto h-12 w-12 {disabled ? 'text-base-content/40' : 'text-base-content/50'}"
335
+ stroke="currentColor"
336
+ fill="none"
337
+ viewBox="0 0 48 48"
338
+ aria-hidden="true"
339
+ >
340
+ <path
341
+ d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02"
342
+ stroke-width="2"
343
+ stroke-linecap="round"
344
+ stroke-linejoin="round"
345
+ />
346
+ </svg>
347
+
348
+ <div class="mt-4">
349
+ <p class="text-lg font-medium {disabled ? 'text-base-content/40' : 'text-base-content'}">
350
+ {isDragOver ? "Drop files or folders here" : dropLabel}
351
+ </p>
352
+ <p class="mt-2 text-sm {disabled ? 'text-base-content/40' : 'text-base-content/50'}">
353
+ {#if !disabled}
354
+ {#if dropSubtext}
355
+ {dropSubtext}
356
+ {:else}
357
+ Drag and drop files, folders, or ZIP archives, or
358
+ <span class="font-medium text-primary underline">click to browse</span>
359
+ {/if}
360
+ {:else}
361
+ File upload is disabled
362
+ {/if}
363
+ </p>
364
+ </div>
365
+
366
+ {#if !disabled}
367
+ <div class="mt-4 text-xs text-base-content/50 space-y-1">
368
+ <p>Accepted: {acceptedExtensions}</p>
369
+ <p>Max size: {formatFileSize(maxSize)} &middot; Max files: {maxFiles}</p>
370
+ <p>You can drop a folder or ZIP archive</p>
371
+ </div>
372
+ {/if}
373
+ </div>
374
+
375
+ <!-- Drag overlay -->
376
+ {#if isDragOver}
377
+ <div
378
+ class="absolute inset-0 bg-primary/10 rounded-lg border-2 border-primary border-dashed flex items-center justify-center"
379
+ >
380
+ <div class="text-center">
381
+ <svg
382
+ class="mx-auto h-16 w-16 text-primary"
383
+ fill="none"
384
+ stroke="currentColor"
385
+ viewBox="0 0 24 24"
386
+ aria-hidden="true"
387
+ >
388
+ <path
389
+ stroke-linecap="round"
390
+ stroke-linejoin="round"
391
+ stroke-width="2"
392
+ d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"
393
+ />
394
+ </svg>
395
+ <p class="mt-2 text-lg font-medium text-primary">Drop files or folders here</p>
396
+ </div>
397
+ </div>
398
+ {/if}
399
+ </div>
400
+
401
+ <!-- Selected Files (before upload) -->
402
+ {#if selectedFiles.length > 0 && !isUploading && uploadedFiles.length === 0}
403
+ <div class="mt-4 space-y-2">
404
+ <h4 class="text-sm font-medium text-base-content/70">
405
+ Selected ({selectedFiles.length})
406
+ </h4>
407
+ <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3">
408
+ {#each selectedFiles as file}
409
+ <div class="flex flex-col items-center p-3 bg-base-200 rounded-lg border border-base-300">
410
+ <div class="w-12 h-12 bg-base-100 rounded border border-base-300 flex items-center justify-center mb-2">
411
+ {#if fileIcon(file) === "image"}
412
+ <svg class="h-6 w-6 text-info" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
413
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
414
+ </svg>
415
+ {:else if fileIcon(file) === "pdf"}
416
+ <svg class="h-6 w-6 text-error" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
417
+ <path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20M10.92,12.31C10.68,11.54 10.15,9.08 11.55,9.04C12.95,9 12.03,12.16 12.03,12.16C12.42,13.65 14.05,14.72 14.05,14.72C14.55,14.57 17.4,14.24 17,15.72C16.57,17.2 13.5,15.81 13.5,15.81C11.55,15.95 10.09,16.47 10.09,16.47C8.96,18.58 7.64,19.5 7.1,18.61C6.43,17.5 9.23,16.07 9.23,16.07C10.68,13.67 10.92,12.31 10.92,12.31Z" />
418
+ </svg>
419
+ {:else if fileIcon(file) === "zip"}
420
+ <svg class="h-6 w-6 text-warning" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
421
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />
422
+ </svg>
423
+ {:else}
424
+ <svg class="h-6 w-6 text-base-content/40" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
425
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
426
+ </svg>
427
+ {/if}
428
+ </div>
429
+ <span class="text-xs text-base-content/60 text-center font-medium truncate w-full" title={file.name}>
430
+ {file.name}
431
+ </span>
432
+ <span class="text-xs text-base-content/50 mt-1">{formatFileSize(file.size)}</span>
433
+ </div>
434
+ {/each}
435
+ </div>
436
+ </div>
437
+ {/if}
438
+
439
+ <!-- Upload / extraction progress -->
440
+ {#if isExtracting}
441
+ <div class="mt-4">
442
+ <div class="flex items-center justify-center p-6 bg-warning/10 rounded-lg border border-warning/30">
443
+ <div class="text-center">
444
+ <span class="loading loading-spinner loading-lg text-warning"></span>
445
+ <p class="mt-3 text-sm font-medium text-warning-content">Extracting ZIP file…</p>
446
+ <p class="text-xs text-warning-content/70">Unpacking and uploading files from archive</p>
447
+ </div>
448
+ </div>
449
+ </div>
450
+ {:else if isUploading}
451
+ <div class="mt-4">
452
+ <div class="flex items-center justify-center p-6 bg-info/10 rounded-lg border border-info/30">
453
+ <div class="text-center">
454
+ <span class="loading loading-spinner loading-lg text-primary"></span>
455
+ <p class="mt-3 text-sm font-medium text-info-content">Uploading files…</p>
456
+ <p class="text-xs text-info-content/70">Please wait while files are uploaded</p>
457
+ </div>
458
+ </div>
459
+ </div>
460
+ {/if}
461
+
462
+ <!-- Uploaded Files (after successful upload) -->
463
+ {#if uploadedFiles.length > 0}
464
+ <div class="mt-4 space-y-2">
465
+ <h4 class="text-sm font-medium text-base-content/70">
466
+ Uploaded ({uploadedFiles.length})
467
+ </h4>
468
+ <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3">
469
+ {#each uploadedFiles as file}
470
+ <div class="flex flex-col items-center p-3 bg-success/10 rounded-lg border border-success/30">
471
+ <FileThumbnail
472
+ name={file.name}
473
+ mimeType={file.mimeType}
474
+ url={file.url}
475
+ size="md"
476
+ />
477
+ <span class="text-xs text-base-content/60 text-center font-medium truncate w-full mt-2" title={file.name}>
478
+ {file.name}
479
+ </span>
480
+ <span class="text-xs text-success font-medium mt-1">✓ Uploaded</span>
481
+ </div>
482
+ {/each}
483
+ </div>
484
+ </div>
485
+ {/if}
486
+ </div>
487
+
488
+ <style>
489
+ div[role="button"]:focus {
490
+ outline: 2px solid var(--color-primary);
491
+ outline-offset: 2px;
492
+ }
493
+ </style>
@@ -39,9 +39,26 @@
39
39
  let uploadError = $state<string | null>(null)
40
40
  let searchQuery = $state("")
41
41
  let fileInput = $state<HTMLInputElement>(undefined!)
42
+ let dragOver = $state(false)
42
43
 
43
44
  const currentFiles = $derived(activeTab === "personal" ? personalFiles : teamFiles)
44
45
 
46
+ const IMAGE_EXTS = new Set(["jpg", "jpeg", "png", "gif", "webp", "svg", "avif", "bmp", "ico", "tiff", "tif"])
47
+ const PDF_EXTS = new Set(["pdf"])
48
+
49
+ const EXT_TO_MIME: Record<string, string> = {
50
+ jpg: "image/jpeg", jpeg: "image/jpeg", png: "image/png", gif: "image/gif",
51
+ webp: "image/webp", svg: "image/svg+xml", avif: "image/avif",
52
+ bmp: "image/bmp", ico: "image/x-icon", tiff: "image/tiff", tif: "image/tiff",
53
+ pdf: "application/pdf",
54
+ }
55
+
56
+ function getEffectiveMime(file: FilePickerFile): string {
57
+ if (file.metadata?.mimetype) return file.metadata.mimetype
58
+ const ext = file.name.split(".").pop()?.toLowerCase() ?? ""
59
+ return EXT_TO_MIME[ext] ?? ""
60
+ }
61
+
45
62
  const filteredFiles = $derived(() => {
46
63
  let files = currentFiles
47
64
  if (searchQuery.trim()) {
@@ -51,8 +68,8 @@
51
68
  if (accept) {
52
69
  const acceptTypes = accept.split(",").map((t) => t.trim().toLowerCase())
53
70
  files = files.filter((f) => {
54
- const mime = f.metadata?.mimetype || ""
55
- const ext = "." + f.name.split(".").pop()?.toLowerCase()
71
+ const mime = getEffectiveMime(f)
72
+ const ext = "." + (f.name.split(".").pop()?.toLowerCase() ?? "")
56
73
  return acceptTypes.some(
57
74
  (t) =>
58
75
  t === mime ||
@@ -121,7 +138,7 @@
121
138
  if (file) {
122
139
  selections.push({
123
140
  file,
124
- url: `${apiBase}/${encodeURIComponent(file.name)}/view?scope=${file.scope}`,
141
+ url: file.publicUrl ?? `${apiBase}/${encodeURIComponent(file.name)}/view?scope=${file.scope}`,
125
142
  downloadUrl: `${apiBase}/${encodeURIComponent(file.name)}/download?scope=${file.scope}`,
126
143
  })
127
144
  }
@@ -165,11 +182,17 @@
165
182
  }
166
183
 
167
184
  function isImage(file: FilePickerFile): boolean {
168
- return file.metadata?.mimetype?.startsWith("image/") ?? false
185
+ const mime = getEffectiveMime(file)
186
+ if (mime) return mime.startsWith("image/")
187
+ const ext = file.name.split(".").pop()?.toLowerCase() ?? ""
188
+ return IMAGE_EXTS.has(ext)
169
189
  }
170
190
 
171
191
  function isPdf(file: FilePickerFile): boolean {
172
- return file.metadata?.mimetype === "application/pdf"
192
+ const mime = getEffectiveMime(file)
193
+ if (mime) return mime === "application/pdf"
194
+ const ext = file.name.split(".").pop()?.toLowerCase() ?? ""
195
+ return PDF_EXTS.has(ext)
173
196
  }
174
197
 
175
198
  function getPreviewUrl(file: FilePickerFile): string {
@@ -238,6 +261,7 @@
238
261
  <div class="flex items-center gap-3 mb-4 shrink-0 flex-wrap">
239
262
  <div role="tablist" class="tabs tabs-boxed tabs-sm">
240
263
  <button
264
+ type="button"
241
265
  role="tab"
242
266
  class="tab {activeTab === 'personal' ? 'tab-active' : ''}"
243
267
  onclick={() => (activeTab = "personal")}
@@ -248,6 +272,7 @@
248
272
  {/if}
249
273
  </button>
250
274
  <button
275
+ type="button"
251
276
  role="tab"
252
277
  class="tab {activeTab === 'team' ? 'tab-active' : ''}"
253
278
  onclick={() => (activeTab = "team")}
@@ -275,6 +300,7 @@
275
300
  class="hidden"
276
301
  />
277
302
  <button
303
+ type="button"
278
304
  class="btn btn-sm btn-primary"
279
305
  onclick={() => fileInput?.click()}
280
306
  disabled={isUploading}
@@ -293,12 +319,35 @@
293
319
  {#if uploadError}
294
320
  <div class="alert alert-warning alert-sm mb-3 shrink-0">
295
321
  <span class="text-sm">{uploadError}</span>
296
- <button class="btn btn-xs btn-ghost" onclick={() => (uploadError = null)}>Dismiss</button>
322
+ <button type="button" class="btn btn-xs btn-ghost" onclick={() => (uploadError = null)}>Dismiss</button>
297
323
  </div>
298
324
  {/if}
299
325
 
300
326
  <!-- File grid -->
301
- <div class="flex-1 overflow-y-auto min-h-0">
327
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
328
+ <div
329
+ class="flex-1 overflow-y-auto min-h-0 relative"
330
+ ondragover={(e) => { e.preventDefault(); dragOver = true }}
331
+ ondragleave={(e) => { if (!e.currentTarget.contains(e.relatedTarget as Node)) dragOver = false }}
332
+ ondrop={(e) => {
333
+ e.preventDefault()
334
+ dragOver = false
335
+ if (e.dataTransfer?.files.length) {
336
+ const dt = new DataTransfer()
337
+ Array.from(e.dataTransfer.files).forEach(f => dt.items.add(f))
338
+ fileInput.files = dt.files
339
+ fileInput.dispatchEvent(new Event('change'))
340
+ }
341
+ }}
342
+ >
343
+ {#if dragOver && !loading}
344
+ <div class="absolute inset-0 z-10 flex flex-col items-center justify-center rounded-md border-2 border-dashed border-primary bg-primary/5 pointer-events-none">
345
+ <svg class="h-10 w-10 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
346
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" />
347
+ </svg>
348
+ <p class="mt-3 text-sm font-medium text-primary">Drop to upload</p>
349
+ </div>
350
+ {/if}
302
351
  {#if loading}
303
352
  <div class="flex items-center justify-center py-16">
304
353
  <span class="loading loading-spinner loading-lg text-primary"></span>
@@ -306,21 +355,40 @@
306
355
  {:else if error}
307
356
  <div class="text-center py-16">
308
357
  <p class="text-error text-sm">{error}</p>
309
- <button class="btn btn-sm btn-ghost mt-2" onclick={loadFiles}>Retry</button>
358
+ <button type="button" class="btn btn-sm btn-ghost mt-2" onclick={loadFiles}>Retry</button>
310
359
  </div>
311
360
  {:else if filteredFiles().length === 0}
312
- <div class="text-center py-16">
313
- <svg class="mx-auto h-10 w-10 text-base-content/20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
314
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
361
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
362
+ <div
363
+ class="flex flex-col items-center justify-center py-16 rounded-md border-2 border-dashed transition-colors duration-150 cursor-pointer
364
+ {dragOver ? 'border-primary bg-primary/5' : 'border-base-300 hover:border-base-content/20 hover:bg-base-200/40'}"
365
+ onclick={() => fileInput?.click()}
366
+ role="button"
367
+ tabindex="0"
368
+ onkeydown={(e) => e.key === 'Enter' && fileInput?.click()}
369
+ aria-label="Drop files here or click to upload"
370
+ >
371
+ <svg class="h-10 w-10 {dragOver ? 'text-primary' : 'text-base-content/20'} transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
372
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" />
315
373
  </svg>
316
- <p class="mt-3 text-sm text-base-content/50">
317
- {searchQuery ? "No files match your search" : "No files yet. Upload one above."}
374
+ <p class="mt-3 text-sm font-medium {dragOver ? 'text-primary' : 'text-base-content/50'}">
375
+ {#if dragOver}
376
+ Drop to upload
377
+ {:else if searchQuery}
378
+ No files match your search
379
+ {:else}
380
+ Drop a file here, or <span class="text-primary underline">browse</span>
381
+ {/if}
318
382
  </p>
383
+ {#if !searchQuery && !dragOver}
384
+ <p class="mt-1 text-xs text-base-content/30">{accept || "Any file type"}</p>
385
+ {/if}
319
386
  </div>
320
387
  {:else}
321
388
  <div class="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-3">
322
389
  {#each filteredFiles() as file (file.id)}
323
390
  <button
391
+ type="button"
324
392
  class="flex flex-col bg-base-100 border rounded-lg overflow-hidden text-left transition-all duration-150 hover:shadow-md
325
393
  {isSelected(file)
326
394
  ? 'border-primary ring-2 ring-primary/30'
@@ -393,8 +461,9 @@
393
461
  {/if}
394
462
  </span>
395
463
  <div class="flex gap-2">
396
- <button class="btn btn-sm btn-ghost" onclick={close}>Cancel</button>
464
+ <button type="button" class="btn btn-sm btn-ghost" onclick={close}>Cancel</button>
397
465
  <button
466
+ type="button"
398
467
  class="btn btn-sm btn-primary"
399
468
  disabled={selected.size === 0}
400
469
  onclick={confirmSelection}