@putkoff/abstract-securefiles 0.0.18 → 0.0.21

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 (177) hide show
  1. package/dist/App/{secure_files.d.ts → SecureFiles.d.ts} +2 -2
  2. package/dist/App/index.d.ts +1 -1
  3. package/dist/FileHandlers/FileRow/imports.d.ts +2 -0
  4. package/dist/FileHandlers/FileRow/index.d.ts +1 -0
  5. package/dist/FileHandlers/FileRow/src/index.d.ts +1 -0
  6. package/dist/FileHandlers/FileRow/src/row_utils.d.ts +2 -0
  7. package/dist/FileHandlers/FileTable/imports.d.ts +4 -0
  8. package/dist/FileHandlers/FileTable/index.d.ts +1 -0
  9. package/dist/FileHandlers/FileTable/src/index.d.ts +1 -0
  10. package/dist/FileHandlers/FileTable/src/table_utils.d.ts +2 -0
  11. package/dist/FileHandlers/ShareModal/imports.d.ts +2 -0
  12. package/dist/FileHandlers/ShareModal/index.d.ts +1 -0
  13. package/dist/FileHandlers/ShareModal/src/index.d.ts +1 -0
  14. package/dist/FileHandlers/ShareModal/src/share_utils.d.ts +2 -0
  15. package/dist/FileHandlers/Upload/imports.d.ts +2 -0
  16. package/dist/FileHandlers/Upload/index.d.ts +1 -0
  17. package/dist/FileHandlers/Upload/src/index.d.ts +2 -0
  18. package/dist/FileHandlers/Upload/src/upload_utils.d.ts +2 -0
  19. package/dist/FileHandlers/imports.d.ts +4 -0
  20. package/dist/FileHandlers/index.d.ts +4 -0
  21. package/dist/UI/index.d.ts +19 -0
  22. package/dist/file_utils/imports.d.ts +2 -0
  23. package/dist/file_utils/index.d.ts +1 -0
  24. package/dist/file_utils/src/delete_utils/imports.d.ts +1 -0
  25. package/dist/file_utils/src/delete_utils/index.d.ts +1 -0
  26. package/dist/file_utils/src/delete_utils/src/delete_row.d.ts +2 -0
  27. package/dist/file_utils/src/delete_utils/src/delete_select.d.ts +1 -0
  28. package/dist/file_utils/src/delete_utils/src/delete_selected.d.ts +2 -0
  29. package/dist/file_utils/src/delete_utils/src/index.d.ts +3 -0
  30. package/dist/file_utils/src/download_utils/imports.d.ts +2 -0
  31. package/dist/file_utils/src/download_utils/index.d.ts +1 -0
  32. package/dist/file_utils/src/download_utils/src/direct_download.d.ts +3 -0
  33. package/dist/file_utils/src/download_utils/src/download_file.d.ts +2 -0
  34. package/dist/file_utils/src/download_utils/src/download_select.d.ts +2 -0
  35. package/dist/file_utils/src/download_utils/src/index.d.ts +5 -0
  36. package/dist/file_utils/src/download_utils/src/target_downloads.d.ts +4 -0
  37. package/dist/file_utils/src/download_utils/src/trigger_download.d.ts +2 -0
  38. package/dist/file_utils/src/imports.d.ts +2 -0
  39. package/dist/file_utils/src/index.d.ts +6 -0
  40. package/dist/file_utils/src/list_utils/imports.d.ts +2 -0
  41. package/dist/file_utils/src/list_utils/index.d.ts +1 -0
  42. package/dist/file_utils/src/list_utils/src/index.d.ts +1 -0
  43. package/dist/file_utils/src/list_utils/src/list_utils.d.ts +2 -0
  44. package/dist/file_utils/src/select_utils/index.d.ts +1 -0
  45. package/dist/file_utils/src/select_utils/src/index.d.ts +3 -0
  46. package/dist/file_utils/src/select_utils/src/init_select_all.d.ts +2 -0
  47. package/dist/file_utils/src/select_utils/src/sync_header_checkbox.d.ts +5 -0
  48. package/dist/file_utils/src/select_utils/src/toggle_checkboxes.d.ts +2 -0
  49. package/dist/file_utils/src/share_utils/imports.d.ts +2 -0
  50. package/dist/file_utils/src/share_utils/index.d.ts +1 -0
  51. package/dist/file_utils/src/share_utils/src/index.d.ts +1 -0
  52. package/dist/file_utils/src/share_utils/src/share_utils.d.ts +7 -0
  53. package/dist/file_utils/src/upload_utils/imports.d.ts +1 -0
  54. package/dist/file_utils/src/upload_utils/index.d.ts +1 -0
  55. package/dist/file_utils/src/upload_utils/src/index.d.ts +3 -0
  56. package/dist/file_utils/src/upload_utils/src/patch_file_settings.d.ts +2 -0
  57. package/dist/file_utils/src/upload_utils/src/upload_file.d.ts +2 -0
  58. package/dist/file_utils/src/upload_utils/src/upload_files.d.ts +5 -0
  59. package/dist/hooks/imports.d.ts +3 -0
  60. package/dist/hooks/index.d.ts +1 -0
  61. package/dist/hooks/useFiles/imports.d.ts +2 -0
  62. package/dist/hooks/useFiles/index.d.ts +1 -0
  63. package/dist/hooks/useFiles/src/deleteFile.d.ts +6 -0
  64. package/dist/hooks/useFiles/src/index.d.ts +6 -0
  65. package/dist/hooks/useFiles/src/load.d.ts +6 -0
  66. package/dist/hooks/useFiles/src/patchShareSettings.d.ts +7 -0
  67. package/dist/hooks/useFiles/src/toggleShare.d.ts +6 -0
  68. package/dist/hooks/useFiles/src/useFiles.d.ts +13 -0
  69. package/dist/hooks/useFiles/src/useSaveShareSettings.d.ts +3 -0
  70. package/dist/imports.d.ts +5 -0
  71. package/dist/index.cjs +928 -9
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.css +1 -1
  74. package/dist/index.d.ts +7 -1
  75. package/dist/index.js +882 -13
  76. package/dist/index.js.map +1 -1
  77. package/dist/styles/index.d.ts +1 -0
  78. package/dist/types/index.d.ts +1 -0
  79. package/dist/types/src/index.d.ts +1 -0
  80. package/dist/types/src/types.d.ts +75 -0
  81. package/package.json +4 -4
  82. package/src/App/{secure_files.tsx → SecureFiles.tsx} +4 -5
  83. package/src/App/index.ts +1 -1
  84. package/src/FileHandlers/FileRow/imports.ts +2 -0
  85. package/src/FileHandlers/FileRow/index.ts +1 -0
  86. package/src/FileHandlers/FileRow/src/index.ts +1 -0
  87. package/src/FileHandlers/FileRow/src/row_utils.tsx +143 -0
  88. package/src/FileHandlers/FileTable/imports.ts +16 -0
  89. package/src/FileHandlers/FileTable/index.ts +1 -0
  90. package/src/FileHandlers/FileTable/src/index.ts +1 -0
  91. package/src/FileHandlers/FileTable/src/table_utils.tsx +251 -0
  92. package/src/FileHandlers/ShareModal/imports.ts +2 -0
  93. package/src/FileHandlers/ShareModal/index.ts +1 -0
  94. package/src/FileHandlers/ShareModal/src/index.ts +1 -0
  95. package/src/FileHandlers/ShareModal/src/share_utils.tsx +158 -0
  96. package/src/FileHandlers/Upload/imports.ts +3 -0
  97. package/src/FileHandlers/Upload/index.ts +1 -0
  98. package/src/FileHandlers/Upload/src/index.ts +2 -0
  99. package/src/FileHandlers/Upload/src/upload_utils.tsx +267 -0
  100. package/src/FileHandlers/imports.ts +20 -0
  101. package/src/FileHandlers/index.ts +4 -0
  102. package/src/UI/index.tsx +113 -0
  103. package/src/custom.d.ts +7 -0
  104. package/src/file_utils/imports.ts +2 -0
  105. package/src/file_utils/index.ts +1 -0
  106. package/src/file_utils/src/delete_utils/imports.ts +1 -0
  107. package/src/file_utils/src/delete_utils/index.ts +1 -0
  108. package/src/file_utils/src/delete_utils/src/delete_row.ts +11 -0
  109. package/src/file_utils/src/delete_utils/src/delete_select.ts +9 -0
  110. package/src/file_utils/src/delete_utils/src/delete_selected.ts +15 -0
  111. package/src/file_utils/src/delete_utils/src/index.ts +3 -0
  112. package/src/file_utils/src/download_utils/imports.ts +3 -0
  113. package/src/file_utils/src/download_utils/index.ts +1 -0
  114. package/src/file_utils/src/download_utils/src/direct_download.ts +22 -0
  115. package/src/file_utils/src/download_utils/src/download_file.ts +24 -0
  116. package/src/file_utils/src/download_utils/src/download_select.ts +20 -0
  117. package/src/file_utils/src/download_utils/src/index.ts +5 -0
  118. package/src/file_utils/src/download_utils/src/target_downloads.ts +21 -0
  119. package/src/file_utils/src/download_utils/src/trigger_download.ts +14 -0
  120. package/src/file_utils/src/imports.ts +3 -0
  121. package/src/file_utils/src/index.ts +6 -0
  122. package/src/file_utils/src/list_utils/imports.ts +2 -0
  123. package/src/file_utils/src/list_utils/index.ts +1 -0
  124. package/src/file_utils/src/list_utils/src/index.ts +1 -0
  125. package/src/file_utils/src/list_utils/src/list_utils.ts +24 -0
  126. package/src/file_utils/src/select_utils/index.ts +1 -0
  127. package/src/file_utils/src/select_utils/src/index.ts +3 -0
  128. package/src/file_utils/src/select_utils/src/init_select_all.ts +37 -0
  129. package/src/file_utils/src/select_utils/src/sync_header_checkbox.ts +18 -0
  130. package/src/file_utils/src/select_utils/src/toggle_checkboxes.ts +11 -0
  131. package/src/file_utils/src/share_utils/imports.ts +2 -0
  132. package/src/file_utils/src/share_utils/index.ts +1 -0
  133. package/src/file_utils/src/share_utils/src/index.ts +1 -0
  134. package/src/file_utils/src/share_utils/src/share_utils.ts +29 -0
  135. package/src/file_utils/src/upload_utils/imports.ts +1 -0
  136. package/src/file_utils/src/upload_utils/index.ts +1 -0
  137. package/src/file_utils/src/upload_utils/src/index.ts +3 -0
  138. package/src/file_utils/src/upload_utils/src/patch_file_settings.ts +18 -0
  139. package/src/file_utils/src/upload_utils/src/upload_file.ts +28 -0
  140. package/src/file_utils/src/upload_utils/src/upload_files.ts +34 -0
  141. package/src/global.d.ts +1 -0
  142. package/src/hooks/imports.ts +3 -0
  143. package/src/hooks/index.ts +1 -0
  144. package/src/hooks/useFiles/imports.ts +3 -0
  145. package/src/hooks/useFiles/index.ts +1 -0
  146. package/src/hooks/useFiles/src/deleteFile.ts +22 -0
  147. package/src/hooks/useFiles/src/index.ts +6 -0
  148. package/src/hooks/useFiles/src/load.ts +52 -0
  149. package/src/hooks/useFiles/src/patchShareSettings.ts +37 -0
  150. package/src/hooks/useFiles/src/toggleShare.ts +28 -0
  151. package/src/hooks/useFiles/src/useFiles.ts +35 -0
  152. package/src/hooks/useFiles/src/useSaveShareSettings.ts +25 -0
  153. package/src/imports.ts +20 -0
  154. package/src/index.ts +7 -1
  155. package/src/styles/SecureFiles/index.css +10 -0
  156. package/src/styles/SecureFilesStyles.module.css +287 -0
  157. package/src/styles/index.ts +1 -0
  158. package/src/types/index.ts +1 -0
  159. package/src/types/src/index.ts +1 -0
  160. package/src/types/src/types.ts +88 -0
  161. package/src/App/index.d.ts +0 -1
  162. package/src/App/secure_files.d.ts +0 -4
  163. package/src/App/styles/index.css +0 -15
  164. package/src/index.d.ts +0 -1
  165. package/src/logs/abstract_flask.log +0 -0
  166. package/src/logs/clipit_logs.log +0 -10
  167. package/src/logs/fetch_utils.log +0 -0
  168. package/src/logs/pair_data.log +0 -0
  169. package/src/logs/query_utils.log +0 -0
  170. package/src/logs/routes_bp.log +0 -2
  171. /package/src/{App/styles → hooks/useFiles/src}/logs/clipit_logs.log +0 -0
  172. /package/src/{App/styles → hooks/useFiles/src}/logs/routes_bp.log +0 -0
  173. /package/src/{App/styles → styles/SecureFiles}/App.css +0 -0
  174. /package/{package.tmp.json → src/styles/SecureFiles/logs/clipit_logs.log} +0 -0
  175. /package/src/{logs/abstract_clipit.clipit.gui_frontend.drag_and_drop_component.imports.robust_readers.directory_reader.directory_reader.log → styles/SecureFiles/logs/routes_bp.log} +0 -0
  176. /package/src/{App/styles → styles/SecureFiles}/tailwind.css +0 -0
  177. /package/src/{App/styles → styles/SecureFiles}/window-manager.css +0 -0
@@ -0,0 +1,267 @@
1
+ import React, {
2
+ ChangeEvent,
3
+ useRef,
4
+ useState,
5
+ useCallback,
6
+ useEffect,
7
+ } from 'react';
8
+ import {
9
+ CloudArrowUpIcon,
10
+ Button,
11
+ uploadFiles,
12
+ useFiles,
13
+ currentUsername
14
+ } from './../imports';
15
+ import type { QueuedFile, UploadProps } from './../imports';
16
+
17
+ export default function Upload({ onUploaded }: UploadProps) {
18
+ const [queue, setQueue] = useState<QueuedFile[]>([]);
19
+ const [busy, setBusy] = useState(false);
20
+ const [message, setMessage] = useState<string | null>(null);
21
+ const [drag, setDrag] = useState(false);
22
+ const inputRef = useRef<HTMLInputElement>(null);
23
+ const [dirs, setDirs] = useState<string[]>([]);
24
+
25
+ // — existing files → directory list —
26
+ const { files, load } = useFiles();
27
+
28
+ useEffect(() => {
29
+ const dirSet = new Set<string>();
30
+ files.forEach(f => {
31
+ const parts = f.filepath.split('/');
32
+ if (parts.length > 1) {
33
+ parts.pop();
34
+ dirSet.add(parts.join('/') + '/');
35
+ }
36
+ });
37
+ setDirs(Array.from(dirSet).sort());
38
+ }, [files]);
39
+
40
+ // — directory selection state —
41
+ const [uploadDir, setUploadDir] = useState<string>('');
42
+ const [creatingNew, setCreatingNew] = useState(false);
43
+ const [newDirName, setNewDirName] = useState('');
44
+
45
+ // — queue logic —
46
+ const enqueue = useCallback((files: QueuedFile[]) => {
47
+ setQueue(prev => {
48
+ const map = new Map(prev.map(q => [`${q.file.name}-${q.file.size}`, q]));
49
+ files.forEach(q => map.set(`${q.file.name}-${q.file.size}`, q));
50
+ return Array.from(map.values());
51
+ });
52
+ }, []);
53
+
54
+ const extractFromDataTransfer = useCallback(
55
+ async (dt: DataTransfer): Promise<QueuedFile[]> => {
56
+ const out: QueuedFile[] = [];
57
+ const walk = async (entry: any, path = "") => {
58
+ if (!entry) return;
59
+ if (entry.isFile) {
60
+ const file: File = await new Promise(res => entry.file(res));
61
+ out.push({ file, relPath: path, progress: 0 });
62
+ } else if (entry.isDirectory) {
63
+ const reader = entry.createReader();
64
+ const entries: any[] = await new Promise(r => reader.readEntries(r));
65
+ await Promise.all(entries.map(e => walk(e, `${path}${entry.name}/`)));
66
+ }
67
+ };
68
+ await Promise.all(Array.from(dt.items).map(i => walk(i.webkitGetAsEntry())));
69
+ return out;
70
+ },
71
+ []
72
+ );
73
+
74
+ const handleSelect = (e: ChangeEvent<HTMLInputElement>) => {
75
+ const files = Array.from(e.target.files || []);
76
+ const queued: any = files.map(f => ({
77
+ file: f,
78
+ relPath: (f as any).webkitRelativePath.replace(/[^/]*$/, ""),
79
+ progress: 0,
80
+ }));
81
+ enqueue(queued);
82
+ e.target.value = "";
83
+ };
84
+
85
+ const handleDrop = async (e: React.DragEvent) => {
86
+ e.preventDefault();
87
+ const files = await extractFromDataTransfer(e.dataTransfer);
88
+ enqueue(files.length ? files : []);
89
+ setDrag(false);
90
+ };
91
+
92
+ const handleUploadAll = async () => {
93
+ if (!queue.length) {
94
+ setMessage("No files queued.");
95
+ return;
96
+ }
97
+ setBusy(true);
98
+ setMessage(null);
99
+ const targetDir = creatingNew
100
+ ? (newDirName.trim().replace(/^\/+|\/+$/g, "") + "/")
101
+ : uploadDir;
102
+ try {
103
+ for (const { file, relPath } of queue) {
104
+ await uploadFiles(file, targetDir + relPath);
105
+ setQueue(cur =>
106
+ cur.map(item =>
107
+ item.file === file ? { ...item, progress: 100 } : item
108
+ )
109
+ );
110
+ }
111
+ setQueue([]);
112
+ await onUploaded();
113
+ setMessage("Upload complete");
114
+ load();
115
+ } catch {
116
+ setMessage("Upload failed");
117
+ } finally {
118
+ setBusy(false);
119
+ }
120
+ };
121
+
122
+ // — directory selector handlers —
123
+ const handleDirChange = (e: ChangeEvent<HTMLSelectElement>) => {
124
+ const v = e.target.value;
125
+ if (v === "__new__") {
126
+ setCreatingNew(true);
127
+ setNewDirName("");
128
+ } else {
129
+ setCreatingNew(false);
130
+ setUploadDir(v);
131
+ }
132
+ };
133
+ const acceptNewDir = () => {
134
+ // normalize like before
135
+ const cleanName = newDirName.trim().replace(/^\/+|\/+$/g, '');
136
+ const normalized = `${uploadDir}${cleanName}/`;
137
+ // ① add it to our dirs list if it isn't there already
138
+ setDirs(prev => {
139
+ if (prev.includes(normalized)) return prev;
140
+ return [...prev, normalized].sort();
141
+ });
142
+
143
+ // ② select it & flip back to the <select>
144
+ setUploadDir(normalized);
145
+ setCreatingNew(false);
146
+ setNewDirName('');
147
+ };
148
+
149
+ return (
150
+ <div className="form-container max-w-2xl mx-auto">
151
+ {/* drop area */}
152
+ <div
153
+ className={`flex items-center border-2 border-dashed rounded-lg p-6 bg-white shadow-md space-x-4 transition-shadow duration-150
154
+ ${drag ? 'border-indigo-500 bg-indigo-50 shadow-lg' : 'border-gray-300 hover:shadow-lg'}`}
155
+ onClick={() => inputRef.current?.click()}
156
+ onDragEnter={e => { e.preventDefault(); setDrag(true); }}
157
+ onDragOver={e => e.preventDefault()}
158
+ onDragLeave={() => setDrag(false)}
159
+ onDrop={handleDrop}
160
+ role="region"
161
+ aria-label="File upload area"
162
+ >
163
+ <CloudArrowUpIcon
164
+ style={{ width: 300, height: 300 }}
165
+ className="text-gray-500 mb-3"
166
+ aria-hidden="true"
167
+ />
168
+ <div className="flex-1">
169
+ <p className="text-base font-semibold text-gray-700">
170
+ Drag & drop files or folders here
171
+ </p>
172
+ {queue.length > 0 && (
173
+ <p className="mt-1 text-sm text-gray-600">
174
+ {queue.length} item{queue.length > 1 && 's'} queued
175
+ </p>
176
+ )}
177
+ </div>
178
+ </div>
179
+
180
+ {/* hidden file input */}
181
+ <input
182
+ ref={inputRef}
183
+ type="file"
184
+ multiple
185
+ className="hidden"
186
+ {...({ webkitdirectory: true, directory: '' } as any)}
187
+ onChange={handleSelect}
188
+ />
189
+
190
+ {/* bottom controls */}
191
+ <div className="flex items-center justify-between mt-4">
192
+ {/* directory selector / new dir input */}
193
+ <div className="flex-1 mr-4">
194
+ {!creatingNew ? (
195
+ <select
196
+ value={uploadDir}
197
+ onChange={handleDirChange}
198
+ className="form-select w-full"
199
+ >
200
+ {dirs.map(d => (
201
+ <option key={d} value={d}>{d}</option>
202
+ ))}
203
+ <option value="__new__">+ Create new directory…</option>
204
+ </select>
205
+ ) : (
206
+ <div className="flex">
207
+ <input
208
+ type="text"
209
+ value={newDirName}
210
+ placeholder="new-folder-name"
211
+ onChange={e => setNewDirName(e.target.value)}
212
+ onBlur={acceptNewDir}
213
+ onKeyDown={e => e.key === 'Enter' && acceptNewDir()}
214
+ className="form-input flex-1"
215
+ />
216
+ <Button onClick={acceptNewDir} className="ml-2">
217
+ OK
218
+ </Button>
219
+ </div>
220
+ )}
221
+ </div>
222
+
223
+ {/* upload button */}
224
+ <Button
225
+ color="blue"
226
+ variant="primary"
227
+ onClick={handleUploadAll}
228
+ disabled={busy || !queue.length}
229
+ >
230
+ {busy ? 'Uploading…' : `Upload ${queue.length}`}
231
+ </Button>
232
+ </div>
233
+
234
+ {message && (
235
+ <p
236
+ className={`text-center text-sm ${message.includes('failed') ? 'text-red-600' : 'text-gray-600'
237
+ }`}
238
+ role="alert"
239
+ >
240
+ {message}
241
+ </p>
242
+ )}
243
+
244
+ {/* queued list */}
245
+ {queue.length > 0 && (
246
+ <div className="wm-container mt-4">
247
+ <h3 className="mb-2 text-sm font-semibold text-gray-700">Queued Files</h3>
248
+ <ul className="max-h-64 space-y-4 overflow-y-auto">
249
+ {queue.map(({ file, relPath, progress }) => (
250
+ <li key={`${file.name}-${file.size}`} className="space-y-1">
251
+ <div className="flex justify-between items-center">
252
+ <span className="truncate text-sm text-gray-800">
253
+ {relPath}{file.name}
254
+ </span>
255
+ <span className="text-xs text-gray-500">{progress}%</span>
256
+ </div>
257
+ <div className="w-full bg-gray-200 rounded-full h-2 overflow-hidden">
258
+ <div className="bg-indigo-600 h-2" style={{ width: `${progress}%` }} />
259
+ </div>
260
+ </li>
261
+ ))}
262
+ </ul>
263
+ </div>
264
+ )}
265
+ </div>
266
+ );
267
+ }
@@ -0,0 +1,20 @@
1
+ export type {QueuedFile, FileItem,FileTableProps,UploadProps,ShareModalProps,FileRowProps } from './../imports';
2
+ export {
3
+ CloudArrowUpIcon,
4
+ currentUsername,
5
+ fetchSharePatch,
6
+ Button,
7
+ Checkbox,
8
+ Input,
9
+ Spinner,
10
+ useEffect,
11
+ useRef,
12
+ useState,
13
+ useCallback,
14
+ ClipboardIcon,
15
+ createPortal,
16
+ secureFetchIt,
17
+
18
+ } from './../imports';
19
+ export {useFiles} from './../hooks'
20
+ export { downloadFile,uploadFiles} from './../file_utils'
@@ -0,0 +1,4 @@
1
+ export {FileRow} from './FileRow';
2
+ export {FileTable} from './FileTable';
3
+ export {ShareModal} from './ShareModal';
4
+ export {Upload} from './Upload';
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+
3
+ export type String = string | undefined | null;
4
+ export type Astring = any[] | string | undefined | null;
5
+ export type Trailing = React.ReactNode
6
+ export type ImportElem = {
7
+ reaxlEle:React.InputHTMLAttributes<HTMLInputElement>;
8
+ label?: String;
9
+ trailing?:Trailing;
10
+ className?: String;
11
+ classNames?:Astring;
12
+ }
13
+
14
+ // Utility to convert input to array
15
+ function ensure_list(obj: Astring | null | undefined): string[] {
16
+ if (Array.isArray(obj)) return obj.filter(Boolean);
17
+ if (typeof obj === 'string') return obj.split(' ').filter(Boolean);
18
+ return [];
19
+ }
20
+
21
+ // Get list and length safely
22
+ function getListAndLen(obj: Astring | null | undefined): { return_obj: string[]; ob_len: number } {
23
+ const return_obj = ensure_list(obj);
24
+ const ob_len = return_obj.length;
25
+ return { return_obj, ob_len };
26
+ }
27
+
28
+ // Combine class names with defaults
29
+ function combineClassNames(classNames: Astring = [], defaultClasses: Astring = ['form-group', 'form-label', 'flex', 'gap-2']): string[] {
30
+ const { return_obj: inputClasses } = getListAndLen(classNames);
31
+ const { return_obj: defaultClassList } = getListAndLen(defaultClasses);
32
+
33
+ // Combine and remove duplicates
34
+ const combined = [...new Set([...defaultClassList, ...inputClasses])];
35
+
36
+ console.log(`Combined classes (length: ${combined.length}): ${combined.join(' ')}`);
37
+ return combined;
38
+ }
39
+
40
+ export function Button({
41
+ children,
42
+ color = 'gray',
43
+ variant = 'default',
44
+ className = '',
45
+ ...rest
46
+ }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
47
+ color?: 'gray' | 'green' | 'blue';
48
+ variant?: 'default' | 'icon' | 'primary' | 'secondary';
49
+ className?: string;
50
+ }) {
51
+ const variantClasses = {
52
+ default: 'btn',
53
+ icon: 'btn-icon',
54
+ primary: 'btn-primary',
55
+ secondary: 'btn-secondary',
56
+ };
57
+
58
+ const colorClasses = {
59
+ gray: '',
60
+ green: variant === 'primary' ? 'btn-success' : 'btn-secondary',
61
+ blue: variant === 'primary' ? 'btn-primary' : 'btn-secondary',
62
+ };
63
+
64
+ const classes = combineClassNames([variantClasses[variant], colorClasses[color], className]);
65
+
66
+ return (
67
+ <button className={classes.join(' ')} {...rest}>
68
+ {children}
69
+ </button>
70
+ );
71
+ }
72
+
73
+ export function Checkbox({
74
+ label,
75
+ className = '',
76
+ classNames = [],
77
+ ...rest
78
+ }: ImportElem) {
79
+ const classes = combineClassNames(classNames, ['checkbox', 'wm-checkbox']);
80
+
81
+ return (
82
+ <label className={classes.join(' ')}>
83
+ <input type="checkbox" className="wm-checkbox" {...rest} />
84
+ {label && <span>{label}</span>}
85
+ </label>
86
+ );
87
+ }
88
+
89
+ export function Input({
90
+ label,
91
+ trailing,
92
+ className = '',
93
+ classNames = [],
94
+ ...rest
95
+ }: ImportElem) {
96
+ const classes = combineClassNames(classNames, ['form-group', 'flex', 'gap-2']);
97
+ const inputClasses = combineClassNames(className, ['form-input']);
98
+
99
+ return (
100
+ <label className={classes.join(' ')}>
101
+ {label && <span className="form-label">{label}</span>}
102
+ <div className="flex gap-2">
103
+ <input className={inputClasses.join(' ')} {...rest} />
104
+ {trailing}
105
+ </div>
106
+ </label>
107
+ );
108
+ }
109
+
110
+ export function Spinner() {
111
+ const classes = combineClassNames('animate-pulse');
112
+ return <p className={classes.join(' ')}>Loading…</p>;
113
+ }
@@ -0,0 +1,7 @@
1
+ // src/custom.d.ts
2
+ declare namespace NodeJS {
3
+ interface ProcessEnv {
4
+ readonly REACT_APP_API_BASE_URL: string;
5
+ // add more as needed...
6
+ }
7
+ }
@@ -0,0 +1,2 @@
1
+ export { fetchSharePatch, requireToken, alertit, fetchIt, stripPrefixes, make_path, secureFetchIt } from "./../imports";
2
+ export type { FileItem, ApiRow } from "./../types";
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1 @@
1
+ export { secureFetchIt,requireToken,alertit } from "./../imports";
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,11 @@
1
+
2
+ import {removeFile} from './delete_select'
3
+ import {alertit} from './../imports'
4
+ /** Given a checkbox inside a table-row → download that row’s file. */
5
+ export async function removeRow(cb: HTMLInputElement): Promise<void> {
6
+ const row = cb.closest("tr") as HTMLTableRowElement | null;
7
+ alertit(row)
8
+ if (row && row?.id) await removeFile(row);
9
+ }
10
+
11
+
@@ -0,0 +1,9 @@
1
+ import {requireToken,secureFetchIt} from './../imports';
2
+
3
+ export async function removeFile(item: any): Promise<void> {
4
+ const resp = await secureFetchIt( "remove", item, "POST", null, false,false,true) as any;
5
+ if (!resp || resp === false || resp?.result === false) {
6
+ throw new Error(`could not delete data: “${item.filename}”`);
7
+ }
8
+
9
+ }
@@ -0,0 +1,15 @@
1
+ import {removeFile} from './delete_select';
2
+
3
+
4
+ /** Bulk download: pass a NodeList or array of checkboxes. */
5
+ export async function removeSelected(checkboxes: Iterable<HTMLInputElement>): Promise<void> {
6
+ const list = Array.from(checkboxes);
7
+ if (!list.length) {
8
+ alert("No files selected.");
9
+ return;
10
+ }
11
+ for (const cb of list) {
12
+ alert(cb);
13
+ await removeFile(cb);
14
+ }
15
+ }
@@ -0,0 +1,3 @@
1
+ export * from './delete_select';
2
+ export * from './delete_selected';
3
+ export * from './delete_row';
@@ -0,0 +1,3 @@
1
+
2
+ export { secureFetchIt, requireToken } from './../imports'
3
+ export type { FileItem } from './../imports'
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,22 @@
1
+ import {triggerDownload} from './trigger_download';
2
+ import {FileItem} from './../imports';
3
+ /** Non-React “direct download” used by some old links (kept for parity) */
4
+ export async function directDownload(item: FileItem): Promise<void> {
5
+ const token = localStorage.getItem("token");
6
+ if (!token) throw new Error("No auth token found");
7
+
8
+ const res = await fetch("https://abstractendeavors.com/api/secure-files/secure-download/", {
9
+ method: "POST",
10
+ headers: {
11
+ Authorization: `Bearer ${token}`,
12
+ "Content-Type": "application/json",
13
+ Accept: "application/octet-stream",
14
+ },
15
+
16
+ body: JSON.stringify(item),
17
+ });
18
+
19
+ if (!res.ok) throw new Error(`Download failed: ${res.status}`);
20
+ const blob = await res.blob();
21
+ triggerDownload(blob, item.filename);
22
+ }
@@ -0,0 +1,24 @@
1
+ import { requireToken, secureFetchIt, FileItem } from './../imports';
2
+ import { triggerDownload } from './trigger_download';
3
+ export async function downloadFile(item: FileItem): Promise<void> {
4
+ const token = localStorage.getItem("token");
5
+ if (!token) throw new Error("No auth token found");
6
+
7
+ const res = await fetch("https://abstractendeavors.com/api/secure-files/secure-download/", {
8
+ method: "POST",
9
+ headers: {
10
+ Authorization: `Bearer ${token}`,
11
+ "Content-Type": "application/json",
12
+ // Don’t over-constrain Accept; let server pick proper content-type
13
+ // Accept: "application/octet-stream",
14
+ },
15
+ body: JSON.stringify(item),
16
+ });
17
+
18
+ if (!res.ok) throw new Error(`Download failed: ${res.status}`);
19
+
20
+ // Stream-friendly: if your triggerDownload revokes URL immediately, wait a tick
21
+ const blob = await res.blob();
22
+ const name = item.filename || "download";
23
+ triggerDownload(blob, name); // ensure this waits ~0-100ms before URL.revokeObjectURL
24
+ }
@@ -0,0 +1,20 @@
1
+ import {requireToken,secureFetchIt,FileItem} from './../imports';
2
+ import {triggerDownload} from './trigger_download';
3
+ export async function downloadSelect(item: FileItem): Promise<void> {
4
+ const token: string = requireToken();
5
+ const body = item
6
+ const headers = {
7
+ Authorization: `Bearer ${token}`,
8
+ Accept: "application/octet-stream",
9
+ "Content-Type": "application/json"
10
+ }
11
+ const blob = await secureFetchIt( "download", body, "POST", headers, true, true) as Blob;
12
+
13
+
14
+
15
+ if (!blob || blob.size === 0) {
16
+ throw new Error(`Received empty file data for “${item.filename}”`);
17
+ }
18
+
19
+ triggerDownload(blob, item.filename);
20
+ }
@@ -0,0 +1,5 @@
1
+ export * from './direct_download';
2
+ export * from './download_file';
3
+ export * from './download_select';
4
+ export * from './target_downloads';
5
+ export * from './trigger_download';
@@ -0,0 +1,21 @@
1
+ import {downloadSelect} from './download_select';
2
+ import type {FileItem} from './../imports'
3
+ /** Given a checkbox inside a table-row → download that row’s file. */
4
+ export async function downloadRow(cb: HTMLInputElement): Promise<void> {
5
+ const row = cb.closest("tr") as HTMLTableRowElement | null;
6
+ const filepath = cb.value;
7
+ const filename = row?.children[1]?.textContent?.trim() || "downloaded_file";
8
+ if (filepath) await downloadSelect({filepath,filename} as any);
9
+ }
10
+
11
+ /** Bulk download: pass a NodeList or array of checkboxes. */
12
+ export async function downloadSelected(checkboxes: Iterable<HTMLInputElement>): Promise<void> {
13
+ const list = Array.from(checkboxes);
14
+ if (!list.length) {
15
+ alert("No files selected.");
16
+ return;
17
+ }
18
+ for (const cb of list) {
19
+ await downloadRow(cb);
20
+ }
21
+ }
@@ -0,0 +1,14 @@
1
+ /** Helper function to trigger file download */
2
+ export function triggerDownload(blob: Blob, filename: string): void {
3
+ const url = URL.createObjectURL(blob);
4
+ const a = Object.assign(document.createElement("a"), {
5
+ href: url,
6
+ download: filename,
7
+ });
8
+ document.body.appendChild(a);
9
+ a.click();
10
+ a.remove();
11
+ URL.revokeObjectURL(url);
12
+
13
+ console.log(`✅ Successfully downloaded: ${filename}`);
14
+ }
@@ -0,0 +1,3 @@
1
+ export type { FileItem, ApiRow } from './../../types/src/types'
2
+ export { alertit, requireToken, secureFetchIt, fetchSharePatch } from './../imports'
3
+
@@ -0,0 +1,6 @@
1
+ export * from './download_utils';
2
+ export * from './select_utils';
3
+ export * from './upload_utils';
4
+ export * from './delete_utils';
5
+ export * from './list_utils';
6
+ export * from './share_utils';
@@ -0,0 +1,2 @@
1
+ export {secureFetchIt,fetchSharePatch} from './../imports';
2
+ export type { FileItem,ApiRow } from './../imports';
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1 @@
1
+ export * from './list_utils';
@@ -0,0 +1,24 @@
1
+ import { secureFetchIt } from './../imports';
2
+ import type { ApiRow, FileItem } from './../imports';
3
+ /** GET /secure-list */
4
+ export async function listFiles(setFiles: any = null): Promise<any> {
5
+ /** ← your request already returns the raw array */
6
+ const apiRows = await secureFetchIt("/list", null, "GET", null, false, true) as ApiRow[]
7
+
8
+ /** map API → UI ------------------------------------------------ */
9
+ const rows: FileItem[] = apiRows.map((r: ApiRow) => ({
10
+ id: r.id,
11
+ filename: r.filename,
12
+ uploader_id: r.uploader_id,
13
+ filepath: r.filepath,
14
+ created_at: r.created_at,
15
+ download_count: r.download_count,
16
+ download_limit: r.download_limit,
17
+ shareable: Boolean(r.shareable),
18
+ needsPassword: !!r.share_password,
19
+ share_password: r.share_password,
20
+ password_str: r.password_str,
21
+ }));
22
+
23
+ setFiles(rows);
24
+ }
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,3 @@
1
+ export * from './init_select_all';
2
+ export * from './sync_header_checkbox';
3
+ export * from './toggle_checkboxes';