@pylonsync/client 0.11.1 → 0.11.4

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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { type ReactNode } from "react";
3
- import { type UploadedFile } from "@pylonsync/react";
3
+ import { type FileVisibility, type UploadedFile } from "@pylonsync/react";
4
4
  export interface FileUploadProps {
5
5
  /** Called once for each successfully uploaded file. */
6
6
  onUploaded?: (file: UploadedFile, source: File) => void;
@@ -12,6 +12,11 @@ export interface FileUploadProps {
12
12
  multiple?: boolean;
13
13
  /** Max file size in bytes — files exceeding this are rejected client-side. */
14
14
  maxSizeBytes?: number;
15
+ /**
16
+ * Who can read the uploaded files. "private" (default): the uploader
17
+ * only. "public": anyone, for content every visitor sees.
18
+ */
19
+ visibility?: FileVisibility;
15
20
  /** Override the headline. */
16
21
  label?: ReactNode;
17
22
  /** Override the helper text. */
@@ -25,13 +30,12 @@ export interface FileUploadResult {
25
30
  error?: string;
26
31
  }
27
32
  /**
28
- * Drop-in drag-and-drop file picker. Streams each file to
29
- * `/api/files/upload` via the existing `uploadFile` helper, surfaces
30
- * per-file progress + errors, and emits `onUploaded` as each file
31
- * lands.
33
+ * Drop-in drag-and-drop file picker. Uploads each file with `uploadFile`
34
+ * (init, PUT, confirm), shows per-file progress and errors, and emits
35
+ * `onUploaded` as each file lands.
32
36
  *
33
37
  * Pure UI shell — no provider configuration of its own. Pylon's file
34
38
  * router handles where bytes actually go (local disk for self-host,
35
39
  * Stack0 / S3 for cloud).
36
40
  */
37
- export declare function FileUpload({ onUploaded, onComplete, accept, multiple, maxSizeBytes, label, helperText, className, }: FileUploadProps): React.JSX.Element;
41
+ export declare function FileUpload({ onUploaded, onComplete, accept, multiple, maxSizeBytes, visibility, label, helperText, className, }: FileUploadProps): React.JSX.Element;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.11.1",
6
+ "version": "0.11.4",
7
7
  "type": "module",
8
8
  "main": "src/index.ts",
9
9
  "types": "./dist/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "prepack": "bun run build"
21
21
  },
22
22
  "dependencies": {
23
- "@pylonsync/react": "0.11.1",
24
- "@pylonsync/sync": "0.11.1",
23
+ "@pylonsync/react": "0.11.4",
24
+ "@pylonsync/sync": "0.11.4",
25
25
  "clsx": "^2.1.1"
26
26
  },
27
27
  "peerDependencies": {
@@ -9,7 +9,7 @@ import {
9
9
  useRef,
10
10
  useState,
11
11
  } from "react";
12
- import { uploadFile, type UploadedFile } from "@pylonsync/react";
12
+ import { uploadFile, type FileVisibility, type UploadedFile } from "@pylonsync/react";
13
13
  import { cn } from "../lib/cn";
14
14
 
15
15
  export interface FileUploadProps {
@@ -23,6 +23,11 @@ export interface FileUploadProps {
23
23
  multiple?: boolean;
24
24
  /** Max file size in bytes — files exceeding this are rejected client-side. */
25
25
  maxSizeBytes?: number;
26
+ /**
27
+ * Who can read the uploaded files. "private" (default): the uploader
28
+ * only. "public": anyone, for content every visitor sees.
29
+ */
30
+ visibility?: FileVisibility;
26
31
  /** Override the headline. */
27
32
  label?: ReactNode;
28
33
  /** Override the helper text. */
@@ -38,10 +43,9 @@ export interface FileUploadResult {
38
43
  }
39
44
 
40
45
  /**
41
- * Drop-in drag-and-drop file picker. Streams each file to
42
- * `/api/files/upload` via the existing `uploadFile` helper, surfaces
43
- * per-file progress + errors, and emits `onUploaded` as each file
44
- * lands.
46
+ * Drop-in drag-and-drop file picker. Uploads each file with `uploadFile`
47
+ * (init, PUT, confirm), shows per-file progress and errors, and emits
48
+ * `onUploaded` as each file lands.
45
49
  *
46
50
  * Pure UI shell — no provider configuration of its own. Pylon's file
47
51
  * router handles where bytes actually go (local disk for self-host,
@@ -53,6 +57,7 @@ export function FileUpload({
53
57
  accept,
54
58
  multiple,
55
59
  maxSizeBytes,
60
+ visibility,
56
61
  label = "Drop files to upload",
57
62
  helperText = "or click to browse",
58
63
  className,
@@ -81,7 +86,7 @@ export function FileUpload({
81
86
  initial.map(async (entry) => {
82
87
  if (entry.status === "error") return entry;
83
88
  try {
84
- const uploaded = await uploadFile(entry.file);
89
+ const uploaded = await uploadFile(entry.file, { visibility });
85
90
  onUploaded?.(uploaded, entry.file);
86
91
  return { ...entry, uploaded } satisfies FileUploadResult;
87
92
  } catch (err) {
@@ -105,7 +110,7 @@ export function FileUpload({
105
110
  });
106
111
  onComplete?.(settled);
107
112
  },
108
- [maxSizeBytes, onComplete, onUploaded],
113
+ [maxSizeBytes, onComplete, onUploaded, visibility],
109
114
  );
110
115
 
111
116
  function onDrop(e: DragEvent<HTMLDivElement>) {