strata-react 1.0.6 → 1.0.7
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/README.md +1 -0
- package/dist/components/file-intake.d.ts +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +301 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/file-intake.d.ts +60 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type FileOutcome = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
size: number;
|
|
5
|
+
status: "processing";
|
|
6
|
+
} | {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
size: number;
|
|
10
|
+
status: "added";
|
|
11
|
+
} | {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
size: number;
|
|
15
|
+
status: "rejected";
|
|
16
|
+
reason: string;
|
|
17
|
+
} | {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
size: number;
|
|
21
|
+
status: "failed";
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
export type FileIntakeOptions = {
|
|
25
|
+
/** What is accepted, as the picker's `accept` list: extensions (`.gpx`), exact types (`audio/mpeg`) or families (`video/*`). */
|
|
26
|
+
accept: readonly string[];
|
|
27
|
+
/** The accepted kinds in words, used in the rejection reason and the drop hint: "a video, an audio file or a GPX track". */
|
|
28
|
+
acceptLabel: string;
|
|
29
|
+
/** More than one file at a time. Default true; with false, extra files in one drop are rejected by name. */
|
|
30
|
+
multiple?: boolean;
|
|
31
|
+
/** Largest size in bytes. Larger files are rejected with their size in the reason. */
|
|
32
|
+
maxBytes?: number;
|
|
33
|
+
/** Extra checks after the type check, for what a type cannot say. Return the reason in the product's words, or `null` to accept. */
|
|
34
|
+
check?: (file: File) => string | null | Promise<string | null>;
|
|
35
|
+
/** The app's own work on an accepted file. A throw marks it `failed` with the error's message and offers a retry. */
|
|
36
|
+
process?: (file: File, context: {
|
|
37
|
+
signal: AbortSignal;
|
|
38
|
+
}) => void | Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
export type FileIntake = {
|
|
41
|
+
/** One outcome per file offered, in the order offered, newest batch last. */
|
|
42
|
+
outcomes: readonly FileOutcome[];
|
|
43
|
+
/** Offers files (from the picker or a drop). Rejections appear as outcomes at once; accepted files are processed. */
|
|
44
|
+
add: (files: Iterable<File> | ArrayLike<File>) => void;
|
|
45
|
+
/** Runs `process` again for a failed file. */
|
|
46
|
+
retry: (id: string) => void;
|
|
47
|
+
/** Removes an outcome (and aborts its processing if still running). */
|
|
48
|
+
dismiss: (id: string) => void;
|
|
49
|
+
/** Removes every finished outcome (added, rejected and failed), leaving those still processing. */
|
|
50
|
+
clear: () => void;
|
|
51
|
+
/** Files still being processed. */
|
|
52
|
+
pending: number;
|
|
53
|
+
};
|
|
54
|
+
/** Whether a file matches one entry of an `accept` list: extension, exact type or `family/*`, ignoring case. */
|
|
55
|
+
export declare function matchesAccept(file: {
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
}, accept: readonly string[]): boolean;
|
|
59
|
+
/** Per-file outcomes for files picked or dropped: type and size checks with a named reason, the app's own `process` per file, retry and dismiss. */
|
|
60
|
+
export declare function useFileIntake(options: FileIntakeOptions): FileIntake;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strata-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "React + Tailwind v4 components that ship structure, behaviour, states and a token contract, and no look: each product brings a theme generated from its own subject.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|