@muhgholy/next-drive 4.23.11 → 4.23.14

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,5 +1,5 @@
1
1
  import type { TDriveUploadState } from '../../types/client';
2
- export declare const useUpload: (apiEndpoint: string, activeAccountId: string | null, withCredentials?: boolean, onUploadComplete?: (item: unknown) => void, unauthenticated?: boolean) => {
2
+ export declare const useUpload: (apiEndpoint: string, activeAccountId: string | null, withCredentials?: boolean, onUploadComplete?: (item: unknown) => void) => {
3
3
  uploads: TDriveUploadState[];
4
4
  uploadFiles: (files: File[], folderId: string | null) => Promise<void>;
5
5
  cancelUpload: (id: string) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-upload.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYxD,eAAO,MAAM,SAAS,GAAI,aAAa,MAAM,EAAE,iBAAiB,MAAM,GAAG,IAAI,EAAE,kBAAiB,OAAe,EAAE,mBAAmB,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,kBAAiB,OAAe;;yBAmK3I,IAAI,EAAE,YAAY,MAAM,GAAG,IAAI;uBAuB9D,MAAM;;CA+CxB,CAAC"}
1
+ {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/use-upload.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYxD,eAAO,MAAM,SAAS,GAAI,aAAa,MAAM,EAAE,iBAAiB,MAAM,GAAG,IAAI,EAAE,kBAAiB,OAAe,EAAE,mBAAmB,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI;;yBAkKzG,IAAI,EAAE,YAAY,MAAM,GAAG,IAAI;uBAuB9D,MAAM;;CA+CxB,CAAC"}
@@ -322,7 +322,7 @@ var getChunkSize = (fileSize) => {
322
322
  if (fileSize < 1024 * 1024 * 1024) return 8 * 1024 * 1024;
323
323
  return 16 * 1024 * 1024;
324
324
  };
325
- var useUpload = (apiEndpoint, activeAccountId, withCredentials = false, onUploadComplete, unauthenticated = false) => {
325
+ var useUpload = (apiEndpoint, activeAccountId, withCredentials = false, onUploadComplete) => {
326
326
  const [uploads, setUploads] = React3.useState([]);
327
327
  const abortControllers = React3.useRef(/* @__PURE__ */ new Map());
328
328
  const filesRef = React3.useRef(/* @__PURE__ */ new Map());
@@ -406,7 +406,6 @@ var useUpload = (apiEndpoint, activeAccountId, withCredentials = false, onUpload
406
406
  formData.append("fileType", file.type);
407
407
  formData.append("folderId", folderId || "root");
408
408
  if (driveId) formData.append("driveId", driveId);
409
- if (unauthenticated) formData.append("unauthenticated", "true");
410
409
  let attempts = 0;
411
410
  let success = false;
412
411
  while (!success && attempts < 3 && !controller.signal.aborted) {
@@ -3156,7 +3155,7 @@ var DriveFileChooser = (props) => {
3156
3155
  onChange(uploaded);
3157
3156
  }
3158
3157
  }, [multiple, onChange]);
3159
- const { uploads, uploadFiles } = useUpload(apiEndpoint, activeAccountId, withCredentials, handleUploaded, unauthenticatedMode);
3158
+ const { uploads, uploadFiles } = useUpload(apiEndpoint, activeAccountId, withCredentials, handleUploaded);
3160
3159
  const openPicker = React3.useCallback(() => {
3161
3160
  if (unauthenticatedMode) fileInputRef.current?.click();
3162
3161
  else setIsOpen(true);
@@ -3194,7 +3193,7 @@ var DriveFileChooser = (props) => {
3194
3193
  }, [multiple, value, onChange]);
3195
3194
  const hasSelection = value && (Array.isArray(value) ? value.length > 0 : true);
3196
3195
  const displayFiles = React3.useMemo(() => !value ? [] : Array.isArray(value) ? value : [value], [value]);
3197
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkHQTC3554_cjs.cn("nd:w-full", className), children: [
3196
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkHQTC3554_cjs.cn("nd:w-full nd:min-w-0", className), children: [
3198
3197
  !hasSelection ? /* @__PURE__ */ jsxRuntime.jsxs(
3199
3198
  Button,
3200
3199
  {
@@ -3220,7 +3219,7 @@ var DriveFileChooser = (props) => {
3220
3219
  ) : (
3221
3220
  /* Selected Files Display */
3222
3221
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkHQTC3554_cjs.cn("nd:rounded-lg nd:border", error ? "nd:border-destructive" : "nd:border-border", disabled && "nd:opacity-50"), children: [
3223
- !multiple && displayFiles[0] && displayFiles[0].file && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex nd:items-center nd:gap-3 nd:p-2.5", children: [
3222
+ !multiple && displayFiles[0] && displayFiles[0].file && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex nd:items-center nd:gap-3 nd:p-2.5 nd:min-w-0", children: [
3224
3223
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nd:size-12 nd:rounded-lg nd:overflow-hidden nd:bg-muted/30 nd:flex nd:items-center nd:justify-center nd:shrink-0", children: displayFiles[0].file.mime?.startsWith("image/") ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: createUrl(displayFiles[0]), alt: displayFiles[0].file.name || "", className: "nd:size-full nd:object-cover" }) : chunkHQTC3554_cjs.getFileIcon(displayFiles[0].file.mime || "", false, "nd:size-6 nd:text-muted-foreground") }),
3225
3224
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex-1 nd:min-w-0", children: [
3226
3225
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "nd:text-sm nd:font-medium nd:truncate", children: displayFiles[0].file.name || "Unknown" }),
@@ -3247,7 +3246,7 @@ var DriveFileChooser = (props) => {
3247
3246
  !disabled && /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "nd:h-7 nd:text-xs nd:text-muted-foreground", onClick: () => onChange([]), children: "Clear" })
3248
3247
  ] })
3249
3248
  ] }),
3250
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nd:max-h-40 nd:overflow-y-auto nd:divide-y nd:divide-border/50", children: displayFiles.filter((file) => file?.file).map((file) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex nd:items-center nd:gap-2.5 nd:px-3 nd:py-2 nd:hover:bg-muted/20", children: [
3249
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nd:max-h-40 nd:overflow-y-auto nd:divide-y nd:divide-border/50", children: displayFiles.filter((file) => file?.file).map((file) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex nd:items-center nd:gap-2.5 nd:px-3 nd:py-2 nd:hover:bg-muted/20 nd:min-w-0", children: [
3251
3250
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nd:size-8 nd:rounded nd:overflow-hidden nd:bg-muted/30 nd:flex nd:items-center nd:justify-center nd:shrink-0", children: file.file.mime?.startsWith("image/") ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: createUrl(file), alt: file.file.name || "", className: "nd:size-full nd:object-cover" }) : chunkHQTC3554_cjs.getFileIcon(file.file.mime || "", false, "nd:size-4 nd:text-muted-foreground") }),
3252
3251
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex-1 nd:min-w-0", children: [
3253
3252
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "nd:text-sm nd:truncate", children: file.file.name || "Unknown" }),
@@ -3264,9 +3263,9 @@ var DriveFileChooser = (props) => {
3264
3263
  error && helperText && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "nd:text-xs nd:text-destructive nd:mt-1.5", children: helperText }),
3265
3264
  unauthenticatedMode && /* @__PURE__ */ jsxRuntime.jsx("input", { ref: fileInputRef, type: "file", accept, multiple, className: "nd:hidden", onChange: handleFilePick }),
3266
3265
  activeUploads.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nd:mt-2 nd:space-y-2", children: activeUploads.map((u) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:rounded-lg nd:border nd:px-3 nd:py-2", children: [
3267
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex nd:items-center nd:gap-2", children: [
3266
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nd:flex nd:items-center nd:gap-2 nd:min-w-0", children: [
3268
3267
  u.status === "error" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "nd:size-4 nd:text-destructive nd:shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "nd:size-4 nd:animate-spin nd:text-muted-foreground nd:shrink-0" }),
3269
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nd:text-sm nd:truncate nd:flex-1", children: u.name }),
3268
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nd:text-sm nd:truncate nd:flex-1 nd:min-w-0", children: u.name }),
3270
3269
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nd:text-xs nd:text-muted-foreground nd:shrink-0", children: u.status === "error" ? "Failed" : `${Math.round(u.currentChunk / Math.max(1, u.totalChunks) * 100)}%` })
3271
3270
  ] }),
3272
3271
  u.status !== "error" && /* @__PURE__ */ jsxRuntime.jsx(Progress, { value: Math.round(u.currentChunk / Math.max(1, u.totalChunks) * 100), className: "nd:mt-1.5" }),