@kahitsan/ksui 0.29.0 → 0.29.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.
- package/package.json +1 -1
- package/src/index.ts +5 -0
- package/src/utils/pending-file.ts +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kahitsan/ksui",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "ksui is a standalone set of SolidJS UI components for KahitSan/Hilinga and any SolidJS app. Published to the public npm registry and consumed as a normal dependency. Ships source under a `solid` export condition so the consumer's vite-plugin-solid compiles it with only solid-js externalized; it depends on nothing but solid-js + lucide-solid and injects its own CSS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -197,6 +197,11 @@ export { attachmentUrl, isResolvableAttachment } from "./utils/attachments";
|
|
|
197
197
|
|
|
198
198
|
export { createObjectUrlResource } from "./utils/object-url-resource";
|
|
199
199
|
export type { ObjectUrlOptions } from "./utils/object-url-resource";
|
|
200
|
+
export {
|
|
201
|
+
createPendingFile,
|
|
202
|
+
revokePendingFile,
|
|
203
|
+
} from "./utils/pending-file";
|
|
204
|
+
export type { PendingFile } from "./utils/pending-file";
|
|
200
205
|
|
|
201
206
|
export { useAccountsIndex, resolveAccount, resolveAccountName } from "./utils/accounts-index";
|
|
202
207
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Pre-upload pending file state — a file the user has picked or pasted but not
|
|
2
|
+
// yet uploaded. The two plugins that support attachment upload (transactions,
|
|
3
|
+
// timesheets/payroll) both defined this locally; extracted here so they share
|
|
4
|
+
// one canonical type + helpers and avoid drift.
|
|
5
|
+
|
|
6
|
+
/** A file the user picked or pasted but hasn't been uploaded yet. */
|
|
7
|
+
export interface PendingFile {
|
|
8
|
+
id: string;
|
|
9
|
+
file: File;
|
|
10
|
+
previewUrl: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let _counter = 0;
|
|
14
|
+
|
|
15
|
+
/** Wrap a picked/pasted File into a PendingFile with a stable id and optional
|
|
16
|
+
* image preview URL. Must be called from the client (browser) — relies on
|
|
17
|
+
* URL.createObjectURL. */
|
|
18
|
+
export function createPendingFile(file: File): PendingFile {
|
|
19
|
+
const isImage = file.type.startsWith("image/");
|
|
20
|
+
return {
|
|
21
|
+
id: `pf-${++_counter}-${Date.now()}`,
|
|
22
|
+
file,
|
|
23
|
+
previewUrl: isImage ? URL.createObjectURL(file) : null,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Release the object URL held by a pending file. Call when the file is removed
|
|
28
|
+
* from the list or after upload completes. */
|
|
29
|
+
export function revokePendingFile(pf: PendingFile): void {
|
|
30
|
+
if (pf.previewUrl) URL.revokeObjectURL(pf.previewUrl);
|
|
31
|
+
}
|