@burdenoff/microfe-files 2026.1110.2 → 2026.1111.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/dist/files/components/ActionMenu.d.ts +6 -0
- package/dist/files/components/ActionMenu.js +2 -1
- package/dist/files/components/ActionMenu.js.map +1 -1
- package/dist/files/components/ContextMenu.d.ts +6 -0
- package/dist/files/components/ContextMenu.js +2 -0
- package/dist/files/components/ContextMenu.js.map +1 -1
- package/dist/files/components/FileBrowser.d.ts +8 -2
- package/dist/files/components/FileBrowser.js +214 -180
- package/dist/files/components/FileBrowser.js.map +1 -1
- package/dist/files/components/FileCard.d.ts +5 -0
- package/dist/files/components/FileCard.js +98 -94
- package/dist/files/components/FileCard.js.map +1 -1
- package/dist/files/components/FileListItem.d.ts +5 -0
- package/dist/files/components/FileListItem.js +88 -87
- package/dist/files/components/FileListItem.js.map +1 -1
- package/dist/files/components/FilePreviewModal.d.ts +6 -1
- package/dist/files/components/FilePreviewModal.js +30 -29
- package/dist/files/components/FilePreviewModal.js.map +1 -1
- package/dist/files/components/FolderCard.d.ts +5 -0
- package/dist/files/components/FolderCard.js +108 -104
- package/dist/files/components/FolderCard.js.map +1 -1
- package/dist/files/components/ShareDialog.d.ts +12 -5
- package/dist/files/components/ShareDialog.js +348 -188
- package/dist/files/components/ShareDialog.js.map +1 -1
- package/dist/files/components/UploadQueue.js +1 -1
- package/dist/files/components/contextMenuItems.d.ts +32 -0
- package/dist/files/components/contextMenuItems.js +6 -2
- package/dist/files/components/contextMenuItems.js.map +1 -1
- package/dist/files/hooks/useShareDialogPermission.d.ts +45 -0
- package/dist/files/hooks/useShareDialogPermission.js +31 -0
- package/dist/files/hooks/useShareDialogPermission.js.map +1 -0
- package/dist/files/hooks/useSharePermissions.d.ts +26 -0
- package/dist/files/hooks/useSharePermissions.js +81 -0
- package/dist/files/hooks/useSharePermissions.js.map +1 -0
- package/dist/files/pages/BrowserPage.js +340 -336
- package/dist/files/pages/BrowserPage.js.map +1 -1
- package/dist/files/utils/sharePermission.d.ts +140 -0
- package/dist/files/utils/sharePermission.js +77 -0
- package/dist/files/utils/sharePermission.js.map +1 -0
- package/dist/generated/wspace-operations.d.ts +20 -0
- package/dist/generated/wspace-operations.js +141 -1
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/translations/en.d.ts +16 -0
- package/dist/translations/en.js +16 -0
- package/dist/translations/en.js.map +1 -1
- package/package.json +1 -1
|
@@ -44,8 +44,8 @@ function _(e) {
|
|
|
44
44
|
sh: "bash"
|
|
45
45
|
}[e.split(".").pop()?.toLowerCase() || ""] || "text";
|
|
46
46
|
}
|
|
47
|
-
function v({ file: v, onClose: y, onDownload: b, onShare: x,
|
|
48
|
-
let { t:
|
|
47
|
+
function v({ file: v, onClose: y, onDownload: b, onShare: x, shareDeniedReason: S, onStar: C, onDelete: w, customActions: T }) {
|
|
48
|
+
let { t: E } = h(), D = g(v.mimeType, v.name), O = v.downloadUrl || v.url;
|
|
49
49
|
return s(() => {
|
|
50
50
|
let e = (e) => {
|
|
51
51
|
e.key === "Escape" && y();
|
|
@@ -70,7 +70,7 @@ function v({ file: v, onClose: y, onDownload: b, onShare: x, onStar: S, onDelete
|
|
|
70
70
|
}), /* @__PURE__ */ m("div", {
|
|
71
71
|
className: "flex items-center gap-2",
|
|
72
72
|
children: [
|
|
73
|
-
|
|
73
|
+
T?.map((e) => /* @__PURE__ */ m("button", {
|
|
74
74
|
type: "button",
|
|
75
75
|
onClick: e.onClick,
|
|
76
76
|
className: "flex items-center gap-1.5 px-3 py-2 text-sm font-medium text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200",
|
|
@@ -81,40 +81,41 @@ function v({ file: v, onClose: y, onDownload: b, onShare: x, onStar: S, onDelete
|
|
|
81
81
|
type: "button",
|
|
82
82
|
onClick: b,
|
|
83
83
|
className: "p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200",
|
|
84
|
-
title: e(
|
|
85
|
-
"aria-label": e(
|
|
84
|
+
title: e(E, "files.common.actions.download", "Download"),
|
|
85
|
+
"aria-label": e(E, "files.preview.downloadFile", "Download file"),
|
|
86
86
|
children: /* @__PURE__ */ p(c, { className: "size-5" })
|
|
87
87
|
}),
|
|
88
88
|
x && /* @__PURE__ */ p("button", {
|
|
89
89
|
type: "button",
|
|
90
90
|
onClick: x,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
"data-share-denied": S !== void 0 || void 0,
|
|
92
|
+
className: `p-2 rounded-lg transition-colors duration-200 hover:bg-action-ghost-bg-hover ${S === void 0 ? "text-text-secondary hover:text-text-primary" : "text-text-tertiary"}`,
|
|
93
|
+
title: S ?? e(E, "files.common.actions.share", "Share"),
|
|
94
|
+
"aria-label": e(E, "files.preview.shareFile", "Share file"),
|
|
94
95
|
children: /* @__PURE__ */ p(l, { className: "size-5" })
|
|
95
96
|
}),
|
|
96
|
-
|
|
97
|
+
C && /* @__PURE__ */ p("button", {
|
|
97
98
|
type: "button",
|
|
98
|
-
onClick:
|
|
99
|
+
onClick: C,
|
|
99
100
|
className: "p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200",
|
|
100
|
-
title: v.starred ? e(
|
|
101
|
-
"aria-label": v.starred ? e(
|
|
101
|
+
title: v.starred ? e(E, "files.preview.removeStar", "Remove star") : e(E, "files.preview.addStar", "Add star"),
|
|
102
|
+
"aria-label": v.starred ? e(E, "files.preview.removeStar", "Remove star") : e(E, "files.preview.addStar", "Add star"),
|
|
102
103
|
children: /* @__PURE__ */ p(u, { className: `size-5 ${v.starred ? "fill-status-warning-text text-status-warning-text" : ""}` })
|
|
103
104
|
}),
|
|
104
|
-
|
|
105
|
+
w && /* @__PURE__ */ p("button", {
|
|
105
106
|
type: "button",
|
|
106
|
-
onClick:
|
|
107
|
+
onClick: w,
|
|
107
108
|
className: "p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200",
|
|
108
|
-
title: e(
|
|
109
|
-
"aria-label": e(
|
|
109
|
+
title: e(E, "files.common.actions.delete", "Delete"),
|
|
110
|
+
"aria-label": e(E, "files.preview.deleteFile", "Delete file"),
|
|
110
111
|
children: /* @__PURE__ */ p(d, { className: "size-5" })
|
|
111
112
|
}),
|
|
112
113
|
/* @__PURE__ */ p("button", {
|
|
113
114
|
type: "button",
|
|
114
115
|
onClick: y,
|
|
115
116
|
className: "p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200 ml-2",
|
|
116
|
-
title: e(
|
|
117
|
-
"aria-label": e(
|
|
117
|
+
title: e(E, "files.common.actions.close", "Close"),
|
|
118
|
+
"aria-label": e(E, "files.preview.close", "Close preview"),
|
|
118
119
|
children: /* @__PURE__ */ p(f, { className: "size-5" })
|
|
119
120
|
})
|
|
120
121
|
]
|
|
@@ -122,36 +123,36 @@ function v({ file: v, onClose: y, onDownload: b, onShare: x, onStar: S, onDelete
|
|
|
122
123
|
}), /* @__PURE__ */ p("div", {
|
|
123
124
|
className: "flex-1 overflow-hidden",
|
|
124
125
|
children: (() => {
|
|
125
|
-
if (!
|
|
126
|
+
if (!O) return /* @__PURE__ */ p("div", {
|
|
126
127
|
role: "status",
|
|
127
128
|
className: "p-8 text-text-secondary",
|
|
128
|
-
children: e(
|
|
129
|
+
children: e(E, "files.file.errors.downloadUrlUnavailable", "Download URL is unavailable")
|
|
129
130
|
});
|
|
130
|
-
switch (
|
|
131
|
+
switch (D) {
|
|
131
132
|
case "image": return /* @__PURE__ */ p(t, {
|
|
132
133
|
file: v,
|
|
133
|
-
url:
|
|
134
|
+
url: O
|
|
134
135
|
});
|
|
135
136
|
case "pdf": return /* @__PURE__ */ p(n, {
|
|
136
137
|
file: v,
|
|
137
|
-
url:
|
|
138
|
+
url: O
|
|
138
139
|
});
|
|
139
140
|
case "video": return /* @__PURE__ */ p(r, {
|
|
140
141
|
file: v,
|
|
141
|
-
url:
|
|
142
|
+
url: O
|
|
142
143
|
});
|
|
143
144
|
case "audio": return /* @__PURE__ */ p(i, {
|
|
144
145
|
file: v,
|
|
145
|
-
url:
|
|
146
|
+
url: O
|
|
146
147
|
});
|
|
147
148
|
case "code": return /* @__PURE__ */ p(a, {
|
|
148
149
|
file: v,
|
|
149
|
-
url:
|
|
150
|
+
url: O,
|
|
150
151
|
language: _(v.name)
|
|
151
152
|
});
|
|
152
153
|
case "text": return /* @__PURE__ */ p(o, {
|
|
153
154
|
file: v,
|
|
154
|
-
url:
|
|
155
|
+
url: O
|
|
155
156
|
});
|
|
156
157
|
default: return /* @__PURE__ */ p("div", {
|
|
157
158
|
className: "flex flex-col items-center justify-center h-full bg-bg-canvas p-8",
|
|
@@ -160,7 +161,7 @@ function v({ file: v, onClose: y, onDownload: b, onShare: x, onStar: S, onDelete
|
|
|
160
161
|
children: [
|
|
161
162
|
/* @__PURE__ */ p("p", {
|
|
162
163
|
className: "text-text-secondary mb-4",
|
|
163
|
-
children: e(
|
|
164
|
+
children: e(E, "files.preview.notAvailable", "Preview not available for this file type.")
|
|
164
165
|
}),
|
|
165
166
|
/* @__PURE__ */ p("p", {
|
|
166
167
|
className: "text-sm text-text-tertiary mb-6",
|
|
@@ -170,7 +171,7 @@ function v({ file: v, onClose: y, onDownload: b, onShare: x, onStar: S, onDelete
|
|
|
170
171
|
type: "button",
|
|
171
172
|
onClick: b,
|
|
172
173
|
className: "px-4 py-2 bg-action-primary-bg text-text-inverse rounded-lg hover:bg-action-primary-bg-hover transition-colors duration-200",
|
|
173
|
-
children: e(
|
|
174
|
+
children: e(E, "files.preview.downloadFile", "Download File")
|
|
174
175
|
})
|
|
175
176
|
]
|
|
176
177
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreviewModal.js","names":["getFilePreviewType","mimeType","codeExtensions","ext","filename","detectLanguage","FilePreviewModal","useI18n","previewType","file","url","useEffect","handleEscape","event","onClose","customActions","action","onDownload","tWithFallback","t","Download","onShare","Share2","onStar","Star","onDelete","Trash2","X","ImageViewer","PDFViewer","VideoPlayer","AudioPlayer","CodeViewer","TextViewer"],"sources":["../../../src/files/components/FilePreviewModal.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { X, Download, Share2, Star, Trash2 } from \"lucide-react\";\nimport { useI18n } from \"@burdenoff/fe-libs/shared/providers/shell/I18nProvider\";\nimport type { FileItem } from \"../types\";\nimport { tWithFallback } from \"../utils/i18n\";\nimport { ImageViewer } from \"./viewers/ImageViewer\";\nimport { PDFViewer } from \"./viewers/PDFViewer\";\nimport { VideoPlayer } from \"./viewers/VideoPlayer\";\nimport { AudioPlayer } from \"./viewers/AudioPlayer\";\nimport { CodeViewer } from \"./viewers/CodeViewer\";\nimport { TextViewer } from \"./viewers/TextViewer\";\n\ninterface FilePreviewModalProps {\n file: FileItem;\n onClose: () => void;\n onDownload: () => void;\n onShare?: () => void;\n onStar?: () => void;\n onDelete?: () => void;\n customActions?: Array<{\n label: string;\n icon: React.ReactNode;\n onClick: () => void;\n }>;\n}\n\ntype PreviewType =\n \"image\" | \"pdf\" | \"video\" | \"audio\" | \"code\" | \"text\" | \"unsupported\";\n\nfunction getFilePreviewType(mimeType: string, filename: string): PreviewType {\n // Image files\n if (mimeType.startsWith(\"image/\")) {\n return \"image\";\n }\n\n // PDF files\n if (mimeType === \"application/pdf\") {\n return \"pdf\";\n }\n\n // Video files\n if (mimeType.startsWith(\"video/\")) {\n return \"video\";\n }\n\n // Audio files\n if (mimeType.startsWith(\"audio/\")) {\n return \"audio\";\n }\n\n // Code files (by extension)\n const codeExtensions = [\n \"js\",\n \"jsx\",\n \"ts\",\n \"tsx\",\n \"py\",\n \"java\",\n \"cpp\",\n \"c\",\n \"cs\",\n \"rb\",\n \"go\",\n \"rs\",\n \"php\",\n \"html\",\n \"css\",\n \"scss\",\n \"json\",\n \"yaml\",\n \"yml\",\n \"xml\",\n \"sql\",\n \"sh\",\n \"bash\",\n \"vue\",\n \"swift\",\n \"kt\",\n \"r\",\n \"dart\",\n \"lua\",\n ];\n const ext = filename.split(\".\").pop()?.toLowerCase();\n if (ext && codeExtensions.includes(ext)) {\n return \"code\";\n }\n\n // Text files\n if (\n mimeType.startsWith(\"text/\") ||\n mimeType === \"application/json\" ||\n mimeType === \"application/xml\"\n ) {\n return \"text\";\n }\n\n return \"unsupported\";\n}\n\nfunction detectLanguage(filename: string): string {\n const ext = filename.split(\".\").pop()?.toLowerCase();\n const languageMap: Record<string, string> = {\n js: \"javascript\",\n jsx: \"jsx\",\n ts: \"typescript\",\n tsx: \"tsx\",\n py: \"python\",\n java: \"java\",\n cpp: \"cpp\",\n c: \"c\",\n cs: \"csharp\",\n rb: \"ruby\",\n go: \"go\",\n rs: \"rust\",\n php: \"php\",\n html: \"html\",\n css: \"css\",\n json: \"json\",\n md: \"markdown\",\n yaml: \"yaml\",\n yml: \"yaml\",\n xml: \"xml\",\n sql: \"sql\",\n sh: \"bash\",\n };\n return languageMap[ext || \"\"] || \"text\";\n}\n\nexport function FilePreviewModal({\n file,\n onClose,\n onDownload,\n onShare,\n onStar,\n onDelete,\n customActions,\n}: FilePreviewModalProps) {\n const { t } = useI18n();\n const previewType = getFilePreviewType(file.mimeType, file.name);\n const url = file.downloadUrl || file.url;\n\n useEffect(() => {\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n onClose();\n }\n };\n\n document.addEventListener(\"keydown\", handleEscape);\n return () => document.removeEventListener(\"keydown\", handleEscape);\n }, [onClose]);\n\n const renderPreview = () => {\n if (!url)\n return (\n <div role=\"status\" className=\"p-8 text-text-secondary\">\n {tWithFallback(\n t,\n \"files.file.errors.downloadUrlUnavailable\",\n \"Download URL is unavailable\",\n )}\n </div>\n );\n switch (previewType) {\n case \"image\":\n return <ImageViewer file={file} url={url} />;\n case \"pdf\":\n return <PDFViewer file={file} url={url} />;\n case \"video\":\n return <VideoPlayer file={file} url={url} />;\n case \"audio\":\n return <AudioPlayer file={file} url={url} />;\n case \"code\":\n return (\n <CodeViewer\n file={file}\n url={url}\n language={detectLanguage(file.name)}\n />\n );\n case \"text\":\n return <TextViewer file={file} url={url} />;\n default:\n return (\n <div className=\"flex flex-col items-center justify-center h-full bg-bg-canvas p-8\">\n <div className=\"bg-bg-surface p-8 rounded-lg text-center max-w-md\">\n <p className=\"text-text-secondary mb-4\">\n {tWithFallback(\n t,\n \"files.preview.notAvailable\",\n \"Preview not available for this file type.\",\n )}\n </p>\n <p className=\"text-sm text-text-tertiary mb-6\">{file.mimeType}</p>\n <button\n type=\"button\"\n onClick={onDownload}\n className=\"px-4 py-2 bg-action-primary-bg text-text-inverse rounded-lg hover:bg-action-primary-bg-hover transition-colors duration-200\"\n >\n {tWithFallback(\n t,\n \"files.preview.downloadFile\",\n \"Download File\",\n )}\n </button>\n </div>\n </div>\n );\n }\n };\n\n return (\n <div\n className=\"fixed inset-0 bg-bg-overlay flex flex-col z-[100] animate-in fade-in duration-200\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={`Preview ${file.name}`}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-6 py-4 bg-bg-elevated/90 backdrop-blur-sm border-b border-border-default\">\n <div className=\"flex items-center gap-4 flex-1 min-w-0\">\n <h2 className=\"text-base font-medium text-text-primary truncate\">\n {file.name}\n </h2>\n <span className=\"text-sm text-text-secondary flex-shrink-0\">\n {(file.size / 1024 / 1024).toFixed(2)} MB\n </span>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {/* Custom Actions */}\n {customActions?.map((action) => (\n <button\n type=\"button\"\n key={action.label}\n onClick={action.onClick}\n className=\"flex items-center gap-1.5 px-3 py-2 text-sm font-medium text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={action.label}\n >\n {action.icon}\n <span>{action.label}</span>\n </button>\n ))}\n\n {/* Standard Actions */}\n <button\n type=\"button\"\n onClick={onDownload}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={tWithFallback(\n t,\n \"files.common.actions.download\",\n \"Download\",\n )}\n aria-label={tWithFallback(\n t,\n \"files.preview.downloadFile\",\n \"Download file\",\n )}\n >\n <Download className=\"size-5\" />\n </button>\n {onShare && (\n <button\n type=\"button\"\n onClick={onShare}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={tWithFallback(t, \"files.common.actions.share\", \"Share\")}\n aria-label={tWithFallback(\n t,\n \"files.preview.shareFile\",\n \"Share file\",\n )}\n >\n <Share2 className=\"size-5\" />\n </button>\n )}\n {onStar && (\n <button\n type=\"button\"\n onClick={onStar}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={\n file.starred\n ? tWithFallback(t, \"files.preview.removeStar\", \"Remove star\")\n : tWithFallback(t, \"files.preview.addStar\", \"Add star\")\n }\n aria-label={\n file.starred\n ? tWithFallback(t, \"files.preview.removeStar\", \"Remove star\")\n : tWithFallback(t, \"files.preview.addStar\", \"Add star\")\n }\n >\n <Star\n className={`size-5 ${\n file.starred\n ? \"fill-status-warning-text text-status-warning-text\"\n : \"\"\n }`}\n />\n </button>\n )}\n {onDelete && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={tWithFallback(t, \"files.common.actions.delete\", \"Delete\")}\n aria-label={tWithFallback(\n t,\n \"files.preview.deleteFile\",\n \"Delete file\",\n )}\n >\n <Trash2 className=\"size-5\" />\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200 ml-2\"\n title={tWithFallback(t, \"files.common.actions.close\", \"Close\")}\n aria-label={tWithFallback(\n t,\n \"files.preview.close\",\n \"Close preview\",\n )}\n >\n <X className=\"size-5\" />\n </button>\n </div>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 overflow-hidden\">{renderPreview()}</div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAASA,EAAmB,GAAkB,GAA+B;CAE3E,IAAIC,EAAS,WAAW,QAAQ,GAC9B,OAAO;CAIT,IAAIA,MAAa,mBACf,OAAO;CAIT,IAAIA,EAAS,WAAW,QAAQ,GAC9B,OAAO;CAIT,IAAIA,EAAS,WAAW,QAAQ,GAC9B,OAAO;CAIT,IAAMC,IAAiB,2IA8BvB,GACMC,IAAMC,EAAS,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,YAAY;CAcnD,OAbID,KAAOD,EAAe,SAASC,CAAG,IAC7B,SAKPF,EAAS,WAAW,OAAO,KAC3BA,MAAa,sBACbA,MAAa,oBAEN,SAGF;AACT;AAEA,SAASI,EAAe,GAA0B;CA0BhD,OAAO;EAvBL,IAAI;EACJ,KAAK;EACL,IAAI;EACJ,KAAK;EACL,IAAI;EACJ,MAAM;EACN,KAAK;EACL,GAAG;EACH,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,KAAK;EACL,MAAM;EACN,KAAK;EACL,MAAM;EACN,IAAI;EACJ,MAAM;EACN,KAAK;EACL,KAAK;EACL,KAAK;EACL,IAAI;CAEC,EAzBKD,EAAS,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,YAAY,KAyBzB,OAAO;AACnC;AAEA,SAAgBE,EAAiB,EAC/B,SACA,YACA,eACA,YACA,WACA,aACA,oBACwB;CACxB,IAAM,EAAE,SAAMC,EAAQ,GAChBC,IAAcR,EAAmBS,EAAK,UAAUA,EAAK,IAAI,GACzDC,IAAMD,EAAK,eAAeA,EAAK;CAwErC,OAtEAE,QAAgB;EACd,IAAMC,KAAgB,MAAyB;GAC7C,AAAIC,EAAM,QAAQ,YAChBC,EAAQ;EAEZ;EAGA,OADA,SAA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AAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,kBAAC,KAAD;SAAG,WAAU;SACV,UAAAf,EACCC,GACA,8BACA,2CACF;QACC,CAAA;QACH,kBAAC,KAAD;SAAG,WAAU;SAAmC,UAAAV,EAAK;QAAY,CAAA;QACjE,kBAAC,UAAD;SACE,MAAK;SACL,SAASQ;SACT,WAAU;SAET,UAAAC,EACCC,GACA,8BACA,eACF;QACM,CAAA;OACL;;KACF,CAAA;IAEX;GACF,EA6H6C,CAAc;EAAO,CAAA,CAC3D;;AAET"}
|
|
1
|
+
{"version":3,"file":"FilePreviewModal.js","names":["getFilePreviewType","mimeType","codeExtensions","ext","filename","detectLanguage","FilePreviewModal","useI18n","previewType","file","url","useEffect","handleEscape","event","onClose","customActions","action","onDownload","tWithFallback","t","Download","onShare","shareDeniedReason","Share2","onStar","Star","onDelete","Trash2","X","ImageViewer","PDFViewer","VideoPlayer","AudioPlayer","CodeViewer","TextViewer"],"sources":["../../../src/files/components/FilePreviewModal.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { X, Download, Share2, Star, Trash2 } from \"lucide-react\";\nimport { useI18n } from \"@burdenoff/fe-libs/shared/providers/shell/I18nProvider\";\nimport type { FileItem } from \"../types\";\nimport { tWithFallback } from \"../utils/i18n\";\nimport { ImageViewer } from \"./viewers/ImageViewer\";\nimport { PDFViewer } from \"./viewers/PDFViewer\";\nimport { VideoPlayer } from \"./viewers/VideoPlayer\";\nimport { AudioPlayer } from \"./viewers/AudioPlayer\";\nimport { CodeViewer } from \"./viewers/CodeViewer\";\nimport { TextViewer } from \"./viewers/TextViewer\";\n\ninterface FilePreviewModalProps {\n file: FileItem;\n onClose: () => void;\n onDownload: () => void;\n onShare?: () => void;\n /**\n * When set, Share is marked denied with this explanation (BOFF-10039). It\n * still opens the share dialog, which shows the denied state.\n */\n shareDeniedReason?: string;\n onStar?: () => void;\n onDelete?: () => void;\n customActions?: Array<{\n label: string;\n icon: React.ReactNode;\n onClick: () => void;\n }>;\n}\n\ntype PreviewType =\n \"image\" | \"pdf\" | \"video\" | \"audio\" | \"code\" | \"text\" | \"unsupported\";\n\nfunction getFilePreviewType(mimeType: string, filename: string): PreviewType {\n // Image files\n if (mimeType.startsWith(\"image/\")) {\n return \"image\";\n }\n\n // PDF files\n if (mimeType === \"application/pdf\") {\n return \"pdf\";\n }\n\n // Video files\n if (mimeType.startsWith(\"video/\")) {\n return \"video\";\n }\n\n // Audio files\n if (mimeType.startsWith(\"audio/\")) {\n return \"audio\";\n }\n\n // Code files (by extension)\n const codeExtensions = [\n \"js\",\n \"jsx\",\n \"ts\",\n \"tsx\",\n \"py\",\n \"java\",\n \"cpp\",\n \"c\",\n \"cs\",\n \"rb\",\n \"go\",\n \"rs\",\n \"php\",\n \"html\",\n \"css\",\n \"scss\",\n \"json\",\n \"yaml\",\n \"yml\",\n \"xml\",\n \"sql\",\n \"sh\",\n \"bash\",\n \"vue\",\n \"swift\",\n \"kt\",\n \"r\",\n \"dart\",\n \"lua\",\n ];\n const ext = filename.split(\".\").pop()?.toLowerCase();\n if (ext && codeExtensions.includes(ext)) {\n return \"code\";\n }\n\n // Text files\n if (\n mimeType.startsWith(\"text/\") ||\n mimeType === \"application/json\" ||\n mimeType === \"application/xml\"\n ) {\n return \"text\";\n }\n\n return \"unsupported\";\n}\n\nfunction detectLanguage(filename: string): string {\n const ext = filename.split(\".\").pop()?.toLowerCase();\n const languageMap: Record<string, string> = {\n js: \"javascript\",\n jsx: \"jsx\",\n ts: \"typescript\",\n tsx: \"tsx\",\n py: \"python\",\n java: \"java\",\n cpp: \"cpp\",\n c: \"c\",\n cs: \"csharp\",\n rb: \"ruby\",\n go: \"go\",\n rs: \"rust\",\n php: \"php\",\n html: \"html\",\n css: \"css\",\n json: \"json\",\n md: \"markdown\",\n yaml: \"yaml\",\n yml: \"yaml\",\n xml: \"xml\",\n sql: \"sql\",\n sh: \"bash\",\n };\n return languageMap[ext || \"\"] || \"text\";\n}\n\nexport function FilePreviewModal({\n file,\n onClose,\n onDownload,\n onShare,\n shareDeniedReason,\n onStar,\n onDelete,\n customActions,\n}: FilePreviewModalProps) {\n const { t } = useI18n();\n const previewType = getFilePreviewType(file.mimeType, file.name);\n const url = file.downloadUrl || file.url;\n\n useEffect(() => {\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n onClose();\n }\n };\n\n document.addEventListener(\"keydown\", handleEscape);\n return () => document.removeEventListener(\"keydown\", handleEscape);\n }, [onClose]);\n\n const renderPreview = () => {\n if (!url)\n return (\n <div role=\"status\" className=\"p-8 text-text-secondary\">\n {tWithFallback(\n t,\n \"files.file.errors.downloadUrlUnavailable\",\n \"Download URL is unavailable\",\n )}\n </div>\n );\n switch (previewType) {\n case \"image\":\n return <ImageViewer file={file} url={url} />;\n case \"pdf\":\n return <PDFViewer file={file} url={url} />;\n case \"video\":\n return <VideoPlayer file={file} url={url} />;\n case \"audio\":\n return <AudioPlayer file={file} url={url} />;\n case \"code\":\n return (\n <CodeViewer\n file={file}\n url={url}\n language={detectLanguage(file.name)}\n />\n );\n case \"text\":\n return <TextViewer file={file} url={url} />;\n default:\n return (\n <div className=\"flex flex-col items-center justify-center h-full bg-bg-canvas p-8\">\n <div className=\"bg-bg-surface p-8 rounded-lg text-center max-w-md\">\n <p className=\"text-text-secondary mb-4\">\n {tWithFallback(\n t,\n \"files.preview.notAvailable\",\n \"Preview not available for this file type.\",\n )}\n </p>\n <p className=\"text-sm text-text-tertiary mb-6\">{file.mimeType}</p>\n <button\n type=\"button\"\n onClick={onDownload}\n className=\"px-4 py-2 bg-action-primary-bg text-text-inverse rounded-lg hover:bg-action-primary-bg-hover transition-colors duration-200\"\n >\n {tWithFallback(\n t,\n \"files.preview.downloadFile\",\n \"Download File\",\n )}\n </button>\n </div>\n </div>\n );\n }\n };\n\n return (\n <div\n className=\"fixed inset-0 bg-bg-overlay flex flex-col z-[100] animate-in fade-in duration-200\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={`Preview ${file.name}`}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-6 py-4 bg-bg-elevated/90 backdrop-blur-sm border-b border-border-default\">\n <div className=\"flex items-center gap-4 flex-1 min-w-0\">\n <h2 className=\"text-base font-medium text-text-primary truncate\">\n {file.name}\n </h2>\n <span className=\"text-sm text-text-secondary flex-shrink-0\">\n {(file.size / 1024 / 1024).toFixed(2)} MB\n </span>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {/* Custom Actions */}\n {customActions?.map((action) => (\n <button\n type=\"button\"\n key={action.label}\n onClick={action.onClick}\n className=\"flex items-center gap-1.5 px-3 py-2 text-sm font-medium text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={action.label}\n >\n {action.icon}\n <span>{action.label}</span>\n </button>\n ))}\n\n {/* Standard Actions */}\n <button\n type=\"button\"\n onClick={onDownload}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={tWithFallback(\n t,\n \"files.common.actions.download\",\n \"Download\",\n )}\n aria-label={tWithFallback(\n t,\n \"files.preview.downloadFile\",\n \"Download file\",\n )}\n >\n <Download className=\"size-5\" />\n </button>\n {onShare && (\n <button\n type=\"button\"\n // A denied Share still opens the share dialog, which explains\n // the denial (a tooltip alone never reaches touch users).\n onClick={onShare}\n data-share-denied={shareDeniedReason !== undefined || undefined}\n className={`p-2 rounded-lg transition-colors duration-200 hover:bg-action-ghost-bg-hover ${\n shareDeniedReason !== undefined\n ? \"text-text-tertiary\"\n : \"text-text-secondary hover:text-text-primary\"\n }`}\n title={\n shareDeniedReason ??\n tWithFallback(t, \"files.common.actions.share\", \"Share\")\n }\n aria-label={tWithFallback(\n t,\n \"files.preview.shareFile\",\n \"Share file\",\n )}\n >\n <Share2 className=\"size-5\" />\n </button>\n )}\n {onStar && (\n <button\n type=\"button\"\n onClick={onStar}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={\n file.starred\n ? tWithFallback(t, \"files.preview.removeStar\", \"Remove star\")\n : tWithFallback(t, \"files.preview.addStar\", \"Add star\")\n }\n aria-label={\n file.starred\n ? tWithFallback(t, \"files.preview.removeStar\", \"Remove star\")\n : tWithFallback(t, \"files.preview.addStar\", \"Add star\")\n }\n >\n <Star\n className={`size-5 ${\n file.starred\n ? \"fill-status-warning-text text-status-warning-text\"\n : \"\"\n }`}\n />\n </button>\n )}\n {onDelete && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200\"\n title={tWithFallback(t, \"files.common.actions.delete\", \"Delete\")}\n aria-label={tWithFallback(\n t,\n \"files.preview.deleteFile\",\n \"Delete file\",\n )}\n >\n <Trash2 className=\"size-5\" />\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"p-2 text-text-secondary hover:text-text-primary hover:bg-action-ghost-bg-hover rounded-lg transition-colors duration-200 ml-2\"\n title={tWithFallback(t, \"files.common.actions.close\", \"Close\")}\n aria-label={tWithFallback(\n t,\n \"files.preview.close\",\n \"Close preview\",\n )}\n >\n <X className=\"size-5\" />\n </button>\n </div>\n </div>\n\n {/* Content */}\n <div className=\"flex-1 overflow-hidden\">{renderPreview()}</div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAASA,EAAmB,GAAkB,GAA+B;CAE3E,IAAIC,EAAS,WAAW,QAAQ,GAC9B,OAAO;CAIT,IAAIA,MAAa,mBACf,OAAO;CAIT,IAAIA,EAAS,WAAW,QAAQ,GAC9B,OAAO;CAIT,IAAIA,EAAS,WAAW,QAAQ,GAC9B,OAAO;CAIT,IAAMC,IAAiB,2IA8BvB,GACMC,IAAMC,EAAS,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,YAAY;CAcnD,OAbID,KAAOD,EAAe,SAASC,CAAG,IAC7B,SAKPF,EAAS,WA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MACV,OAAOI,EAAcC,GAAG,8BAA8B,OAAO;MAC7D,cAAYD,EACVC,GACA,uBACA,eACF;MAEA,UAAA,kBAACS,GAAD,EAAG,WAAU,SAAU,CAAA;KACjB,CAAA;IACL;GACF,CAAA,CAAA;EAGL,CAAA,GAAA,kBAAC,OAAD;GAAK,WAAU;GAA0B,iBAhMjB;IAC1B,IAAI,CAAClB,GACH,OACE,kBAAC,OAAD;KAAK,MAAK;KAAS,WAAU;KAC1B,UAAAQ,EACCC,GACA,4CACA,6BACF;IACG,CAAA;IAET,QAAQX,GAAR;KACE,KAAK,SACH,OAAO,kBAACqB,GAAD;MAAmB;MAAW;KAAM,CAAA;KAC7C,KAAK,OACH,OAAO,kBAACC,GAAD;MAAiB;MAAW;KAAM,CAAA;KAC3C,KAAK,SACH,OAAO,kBAACC,GAAD;MAAmB;MAAW;KAAM,CAAA;KAC7C,KAAK,SACH,OAAO,kBAACC,GAAD;MAAmB;MAAW;KAAM,CAAA;KAC7C,KAAK,QACH,OACE,kBAACC,GAAD;MACQ;MACD;MACL,UAAU5B,EAAeI,EAAK,IAAI;KACnC,CAAA;KAEL,KAAK,QACH,OAAO,kBAACyB,GAAD;MAAkB;MAAW;KAAM,CAAA;KAC5C,SACE,OACE,kBAAC,OAAD;MAAK,WAAU;MACb,UAAA,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,kBAAC,KAAD;SAAG,WAAU;SACV,UAAAhB,EACCC,GACA,8BACA,2CACF;QACC,CAAA;QACH,kBAAC,KAAD;SAAG,WAAU;SAAmC,UAAAV,EAAK;QAAY,CAAA;QACjE,kBAAC,UAAD;SACE,MAAK;SACL,SAASQ;SACT,WAAU;SAET,UAAAC,EACCC,GACA,8BACA,eACF;QACM,CAAA;OACL;;KACF,CAAA;IAEX;GACF,EAuI6C,CAAc;EAAO,CAAA,CAC3D;;AAET"}
|
|
@@ -10,6 +10,11 @@ interface FolderCardProps {
|
|
|
10
10
|
onSelect?: (folderId: string) => void;
|
|
11
11
|
onOpen?: (folder: FolderItem) => void;
|
|
12
12
|
onShare?: (folder: FolderItem) => void;
|
|
13
|
+
/**
|
|
14
|
+
* When set, Share is marked denied with this explanation (BOFF-10039). It
|
|
15
|
+
* still opens the share dialog, which shows the denied state.
|
|
16
|
+
*/
|
|
17
|
+
shareDeniedReason?: string;
|
|
13
18
|
onDelete?: (folder: FolderItem) => void;
|
|
14
19
|
onRestore?: (folder: FolderItem) => void;
|
|
15
20
|
onRename?: (folder: FolderItem) => void;
|
|
@@ -1,81 +1,84 @@
|
|
|
1
1
|
import { formatFileDate as e } from "../utils/index.js";
|
|
2
2
|
import { useFilesStore as t } from "../store/filesStore.js";
|
|
3
3
|
import { ActionMenu as n } from "./ActionMenu.js";
|
|
4
|
-
import { canDropOnFolder as
|
|
5
|
-
import { tWithFallback as
|
|
6
|
-
import { useMemo as
|
|
7
|
-
import { Activity as
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import { useI18n as
|
|
10
|
-
import { GlassCard as
|
|
4
|
+
import { canDropOnFolder as ee, getDragOperation as r } from "../hooks/useDragDrop.js";
|
|
5
|
+
import { tWithFallback as i } from "../utils/i18n.js";
|
|
6
|
+
import { useMemo as te, useState as a } from "react";
|
|
7
|
+
import { Activity as o, ChevronRight as s, Edit as c, Folder as l, FolderInput as ne, FolderOpen as u, Info as d, RotateCcw as f, Share2 as p, Star as m, Trash2 as h } from "lucide-react";
|
|
8
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
9
|
+
import { useI18n as y } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
10
|
+
import { GlassCard as b } from "@burdenoff/fe-libs/ui";
|
|
11
11
|
// src/files/components/FolderCard.tsx
|
|
12
|
-
var
|
|
13
|
-
let { t: V } =
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
e.stopPropagation(),
|
|
12
|
+
var x = ({ folder: x, isSelected: S = !1, isDragging: C = !1, isDropTarget: w = !1, draggedItem: T = null, onSelect: E, onOpen: D, onShare: O, shareDeniedReason: k, onDelete: A, onRestore: j, onRename: M, onFavorite: N, onCopy: re, onMove: P, onInfo: F, onActivity: I, onDragStart: L, onDragEnd: R, onDrop: z, onContextMenu: B }) => {
|
|
13
|
+
let { t: V } = y(), [H, U] = a(!1), [W, G] = a(!1), { toggleFolderSelection: K } = t(), ie = ee(T, x), q = w && ie, J = x.filesCount ?? 0, Y = x.subfoldersCount ?? 0, X = J + Y, Z = () => {
|
|
14
|
+
D && D(x);
|
|
15
|
+
}, ae = (e) => {
|
|
16
|
+
e.stopPropagation(), E ? E(x.id) : K(x.id);
|
|
17
17
|
}, Q = (e, t) => {
|
|
18
18
|
e.stopPropagation(), t();
|
|
19
|
-
},
|
|
20
|
-
e.dataTransfer.effectAllowed = "copyMove", e.dataTransfer.setData("application/x-file-id",
|
|
21
|
-
let t =
|
|
22
|
-
e.dataTransfer.setData("application/x-drag-operation", t), L?.(
|
|
19
|
+
}, oe = (e) => {
|
|
20
|
+
e.dataTransfer.effectAllowed = "copyMove", e.dataTransfer.setData("application/x-file-id", x.id), e.dataTransfer.setData("application/x-file-type", "folder");
|
|
21
|
+
let t = r(e);
|
|
22
|
+
e.dataTransfer.setData("application/x-drag-operation", t), L?.(x, t);
|
|
23
23
|
}, $ = () => {
|
|
24
24
|
R?.();
|
|
25
|
-
}, oe = (e) => {
|
|
26
|
-
q && (e.preventDefault(), e.dataTransfer.dropEffect = E?.operation === "copy" ? "copy" : "move");
|
|
27
25
|
}, se = (e) => {
|
|
26
|
+
q && (e.preventDefault(), e.dataTransfer.dropEffect = T?.operation === "copy" ? "copy" : "move");
|
|
27
|
+
}, ce = (e) => {
|
|
28
28
|
q && e.preventDefault();
|
|
29
|
-
},
|
|
30
|
-
e.preventDefault(), q && z?.(
|
|
31
|
-
},
|
|
32
|
-
e.preventDefault(), e.stopPropagation(), B?.(
|
|
33
|
-
},
|
|
34
|
-
...
|
|
35
|
-
label:
|
|
36
|
-
icon: /* @__PURE__ */
|
|
37
|
-
onClick: () =>
|
|
29
|
+
}, le = () => {}, ue = (e) => {
|
|
30
|
+
e.preventDefault(), q && z?.(x);
|
|
31
|
+
}, de = (e) => {
|
|
32
|
+
e.preventDefault(), e.stopPropagation(), B?.(x, e.clientX, e.clientY);
|
|
33
|
+
}, fe = H ? u : l, pe = te(() => [
|
|
34
|
+
...O ? [{
|
|
35
|
+
label: i(V, "files.card.share", "Share"),
|
|
36
|
+
icon: /* @__PURE__ */ _(p, { className: "size-4" }),
|
|
37
|
+
onClick: () => O(x),
|
|
38
|
+
denied: k !== void 0,
|
|
39
|
+
title: k
|
|
38
40
|
}] : [],
|
|
39
41
|
...P ? [{
|
|
40
|
-
label:
|
|
41
|
-
icon: /* @__PURE__ */
|
|
42
|
-
onClick: () => P(
|
|
42
|
+
label: i(V, "files.card.moveTo", "Move to"),
|
|
43
|
+
icon: /* @__PURE__ */ _(ne, { className: "size-4" }),
|
|
44
|
+
onClick: () => P(x)
|
|
43
45
|
}] : [],
|
|
44
46
|
...M ? [{
|
|
45
|
-
label:
|
|
46
|
-
icon: /* @__PURE__ */
|
|
47
|
-
onClick: () => M(
|
|
47
|
+
label: i(V, "files.card.rename", "Rename"),
|
|
48
|
+
icon: /* @__PURE__ */ _(c, { className: "size-4" }),
|
|
49
|
+
onClick: () => M(x),
|
|
48
50
|
divider: !0
|
|
49
51
|
}] : [],
|
|
50
52
|
...N ? [{
|
|
51
|
-
label:
|
|
52
|
-
icon: /* @__PURE__ */
|
|
53
|
-
onClick: () => N(
|
|
53
|
+
label: x.starred ? i(V, "files.card.removeFromStarred", "Remove from starred") : i(V, "files.card.addToStarred", "Add to starred"),
|
|
54
|
+
icon: /* @__PURE__ */ _(m, { className: "size-4" }),
|
|
55
|
+
onClick: () => N(x)
|
|
54
56
|
}] : [],
|
|
55
57
|
...F ? [{
|
|
56
|
-
label:
|
|
57
|
-
icon: /* @__PURE__ */
|
|
58
|
-
onClick: () => F(
|
|
58
|
+
label: i(V, "files.card.details", "Details"),
|
|
59
|
+
icon: /* @__PURE__ */ _(d, { className: "size-4" }),
|
|
60
|
+
onClick: () => F(x)
|
|
59
61
|
}] : [],
|
|
60
62
|
...I ? [{
|
|
61
|
-
label:
|
|
62
|
-
icon: /* @__PURE__ */
|
|
63
|
-
onClick: () => I(
|
|
63
|
+
label: i(V, "files.card.activity", "Activity"),
|
|
64
|
+
icon: /* @__PURE__ */ _(o, { className: "size-4" }),
|
|
65
|
+
onClick: () => I(x)
|
|
64
66
|
}] : [],
|
|
65
67
|
...A ? [{
|
|
66
|
-
label:
|
|
67
|
-
icon: /* @__PURE__ */
|
|
68
|
-
onClick: () => A(
|
|
68
|
+
label: i(V, "files.card.delete", "Delete"),
|
|
69
|
+
icon: /* @__PURE__ */ _(h, { className: "size-4" }),
|
|
70
|
+
onClick: () => A(x),
|
|
69
71
|
variant: "danger",
|
|
70
72
|
divider: !0
|
|
71
73
|
}] : [],
|
|
72
74
|
...j ? [{
|
|
73
|
-
label:
|
|
74
|
-
icon: /* @__PURE__ */
|
|
75
|
-
onClick: () => j(
|
|
75
|
+
label: i(V, "files.card.restore", "Restore"),
|
|
76
|
+
icon: /* @__PURE__ */ _(f, { className: "size-4" }),
|
|
77
|
+
onClick: () => j(x)
|
|
76
78
|
}] : []
|
|
77
79
|
], [
|
|
78
|
-
|
|
80
|
+
x,
|
|
81
|
+
O,
|
|
79
82
|
k,
|
|
80
83
|
P,
|
|
81
84
|
M,
|
|
@@ -86,11 +89,11 @@ var S = ({ folder: S, isSelected: C = !1, isDragging: w = !1, isDropTarget: T =
|
|
|
86
89
|
j,
|
|
87
90
|
V
|
|
88
91
|
]);
|
|
89
|
-
return /* @__PURE__ */
|
|
92
|
+
return /* @__PURE__ */ _(b, {
|
|
90
93
|
treatment: "insight",
|
|
91
|
-
className: `group cursor-pointer focus-within:shadow-elevation-2 ${
|
|
94
|
+
className: `group cursor-pointer focus-within:shadow-elevation-2 ${C ? "opacity-50" : ""} ${q ? "border-action-primary-bg ring-2 ring-action-primary-bg ring-offset-2" : S ? "border-action-primary-bg bg-bg-accent" : "border-border-seam"}`,
|
|
92
95
|
onClick: Z,
|
|
93
|
-
onContextMenu:
|
|
96
|
+
onContextMenu: de,
|
|
94
97
|
onMouseEnter: () => U(!0),
|
|
95
98
|
onMouseLeave: () => {
|
|
96
99
|
W || U(!1);
|
|
@@ -103,98 +106,99 @@ var S = ({ folder: S, isSelected: C = !1, isDragging: w = !1, isDropTarget: T =
|
|
|
103
106
|
e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), Z());
|
|
104
107
|
},
|
|
105
108
|
draggable: !!L,
|
|
106
|
-
onDragStart:
|
|
109
|
+
onDragStart: oe,
|
|
107
110
|
onDragEnd: $,
|
|
108
|
-
onDragOver:
|
|
109
|
-
onDragEnter:
|
|
110
|
-
onDragLeave:
|
|
111
|
-
onDrop:
|
|
111
|
+
onDragOver: se,
|
|
112
|
+
onDragEnter: ce,
|
|
113
|
+
onDragLeave: le,
|
|
114
|
+
onDrop: ue,
|
|
112
115
|
role: "button",
|
|
113
116
|
tabIndex: 0,
|
|
114
|
-
"aria-label": `${
|
|
115
|
-
children: /* @__PURE__ */
|
|
117
|
+
"aria-label": `${i(V, "files.browser.openFolder", "Open folder")} ${x.name}`,
|
|
118
|
+
children: /* @__PURE__ */ v("div", {
|
|
116
119
|
className: "flex items-center gap-3 p-3",
|
|
117
120
|
children: [
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
className: `flex-shrink-0 transition-opacity ${
|
|
121
|
+
/* @__PURE__ */ _("div", {
|
|
122
|
+
className: `flex-shrink-0 transition-opacity ${S ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,
|
|
120
123
|
onClick: (e) => e.stopPropagation(),
|
|
121
|
-
children: /* @__PURE__ */
|
|
124
|
+
children: /* @__PURE__ */ _("input", {
|
|
122
125
|
type: "checkbox",
|
|
123
|
-
checked:
|
|
124
|
-
onChange:
|
|
126
|
+
checked: S,
|
|
127
|
+
onChange: ae,
|
|
125
128
|
className: "size-4 rounded border-border-default bg-bg-surface text-action-primary-bg focus:ring-2 focus:ring-action-primary-bg focus:ring-offset-2",
|
|
126
|
-
"aria-label": `Select ${
|
|
129
|
+
"aria-label": `Select ${x.name}`
|
|
127
130
|
})
|
|
128
131
|
}),
|
|
129
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ _("div", {
|
|
130
133
|
className: "flex-shrink-0 flex items-center justify-center size-10 rounded-lg bg-action-primary-bg/10",
|
|
131
|
-
children: /* @__PURE__ */
|
|
134
|
+
children: /* @__PURE__ */ _(fe, { className: "size-5 text-action-primary-bg" })
|
|
132
135
|
}),
|
|
133
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ v("div", {
|
|
134
137
|
className: "flex-1 min-w-0 pr-1",
|
|
135
|
-
children: [/* @__PURE__ */
|
|
138
|
+
children: [/* @__PURE__ */ v("div", {
|
|
136
139
|
className: "flex items-center gap-1.5",
|
|
137
|
-
children: [/* @__PURE__ */
|
|
140
|
+
children: [/* @__PURE__ */ _("span", {
|
|
138
141
|
className: "text-sm font-medium text-text-primary truncate",
|
|
139
|
-
children:
|
|
140
|
-
}),
|
|
141
|
-
}), /* @__PURE__ */
|
|
142
|
+
children: x.name
|
|
143
|
+
}), x.starred && /* @__PURE__ */ _(m, { className: "size-3 flex-shrink-0 fill-status-warning-text text-status-warning-text" })]
|
|
144
|
+
}), /* @__PURE__ */ v("div", {
|
|
142
145
|
className: "flex items-center gap-1 mt-0.5 text-xs text-text-secondary",
|
|
143
146
|
children: [
|
|
144
|
-
Y > 0 && /* @__PURE__ */
|
|
147
|
+
Y > 0 && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v("span", { children: [
|
|
145
148
|
Y,
|
|
146
149
|
" ",
|
|
147
|
-
Y === 1 ?
|
|
148
|
-
] }), J > 0 && /* @__PURE__ */
|
|
150
|
+
Y === 1 ? i(V, "files.folder.subfolder", "folder") : i(V, "files.folder.subfolders", "folders")
|
|
151
|
+
] }), J > 0 && /* @__PURE__ */ _("span", {
|
|
149
152
|
className: "text-border-subtle",
|
|
150
153
|
children: "·"
|
|
151
154
|
})] }),
|
|
152
|
-
J > 0 && /* @__PURE__ */
|
|
155
|
+
J > 0 && /* @__PURE__ */ v("span", { children: [
|
|
153
156
|
J,
|
|
154
157
|
" ",
|
|
155
|
-
J === 1 ?
|
|
158
|
+
J === 1 ? i(V, "files.folder.file", "file") : i(V, "files.folder.files", "files")
|
|
156
159
|
] }),
|
|
157
|
-
X === 0 && /* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */
|
|
160
|
+
X === 0 && /* @__PURE__ */ _("span", { children: i(V, "files.folder.empty", "Empty") }),
|
|
161
|
+
/* @__PURE__ */ _("span", {
|
|
159
162
|
className: "text-border-subtle",
|
|
160
163
|
children: "·"
|
|
161
164
|
}),
|
|
162
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ _("span", {
|
|
163
166
|
className: "truncate",
|
|
164
|
-
children: e(
|
|
167
|
+
children: e(x.updatedAt)
|
|
165
168
|
})
|
|
166
169
|
]
|
|
167
170
|
})]
|
|
168
171
|
}),
|
|
169
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ v("div", {
|
|
170
173
|
className: "flex-shrink-0 flex items-center gap-1",
|
|
171
174
|
children: [
|
|
172
|
-
H && j && /* @__PURE__ */
|
|
175
|
+
H && j && /* @__PURE__ */ _("button", {
|
|
173
176
|
type: "button",
|
|
174
|
-
onClick: (e) => Q(e, () => j(
|
|
177
|
+
onClick: (e) => Q(e, () => j(x)),
|
|
175
178
|
className: "p-1.5 hover:bg-status-success-bg-subtle rounded transition-colors",
|
|
176
|
-
"aria-label":
|
|
177
|
-
title:
|
|
178
|
-
children: /* @__PURE__ */
|
|
179
|
+
"aria-label": i(V, "files.card.restore", "Restore"),
|
|
180
|
+
title: i(V, "files.card.restore", "Restore"),
|
|
181
|
+
children: /* @__PURE__ */ _(f, { className: "size-4 text-status-success-text" })
|
|
179
182
|
}),
|
|
180
|
-
H &&
|
|
181
|
-
onClick: (e) => Q(e, () =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
H && O && /* @__PURE__ */ _("button", {
|
|
184
|
+
onClick: (e) => Q(e, () => O(x)),
|
|
185
|
+
"data-share-denied": k !== void 0 || void 0,
|
|
186
|
+
className: `p-1.5 rounded transition-colors hover:bg-action-ghost-bg-hover ${k === void 0 ? "" : "opacity-50"}`,
|
|
187
|
+
"aria-label": i(V, "files.card.share", "Share"),
|
|
188
|
+
title: k ?? i(V, "files.card.share", "Share"),
|
|
189
|
+
children: /* @__PURE__ */ _(p, { className: "size-4 text-text-secondary" })
|
|
186
190
|
}),
|
|
187
|
-
H && M && /* @__PURE__ */
|
|
188
|
-
onClick: (e) => Q(e, () => M(
|
|
191
|
+
H && M && /* @__PURE__ */ _("button", {
|
|
192
|
+
onClick: (e) => Q(e, () => M(x)),
|
|
189
193
|
className: "p-1.5 hover:bg-action-ghost-bg-hover rounded transition-colors",
|
|
190
|
-
"aria-label":
|
|
191
|
-
title:
|
|
192
|
-
children: /* @__PURE__ */
|
|
194
|
+
"aria-label": i(V, "files.card.rename", "Rename"),
|
|
195
|
+
title: i(V, "files.card.rename", "Rename"),
|
|
196
|
+
children: /* @__PURE__ */ _(c, { className: "size-4 text-text-secondary" })
|
|
193
197
|
}),
|
|
194
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ _("div", {
|
|
195
199
|
onClick: (e) => e.stopPropagation(),
|
|
196
|
-
children: /* @__PURE__ */
|
|
197
|
-
items:
|
|
200
|
+
children: /* @__PURE__ */ _(n, {
|
|
201
|
+
items: pe,
|
|
198
202
|
align: "right",
|
|
199
203
|
triggerClassName: !H && !W ? "opacity-0 group-hover:opacity-100" : "",
|
|
200
204
|
isOpen: W,
|
|
@@ -205,11 +209,11 @@ var S = ({ folder: S, isSelected: C = !1, isDragging: w = !1, isDropTarget: T =
|
|
|
205
209
|
})
|
|
206
210
|
]
|
|
207
211
|
}),
|
|
208
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ _(s, { className: "flex-shrink-0 size-4 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity" })
|
|
209
213
|
]
|
|
210
214
|
})
|
|
211
215
|
});
|
|
212
216
|
};
|
|
213
|
-
export {
|
|
217
|
+
export { x as FolderCard };
|
|
214
218
|
|
|
215
219
|
//# sourceMappingURL=FolderCard.js.map
|