@constructive-io/ui 0.3.1 → 0.4.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/index.cjs +1112 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +396 -1
- package/dist/index.d.ts +396 -1
- package/dist/index.js +1093 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -7949,6 +7949,1097 @@ function OrgChart(props) {
|
|
|
7949
7949
|
return /* @__PURE__ */ jsxRuntime.jsx(react$1.ReactFlowProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OrgChartProvider, { editable: props.editable ?? true, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(OrgChartInner, { ...props }) }) }) });
|
|
7950
7950
|
}
|
|
7951
7951
|
|
|
7952
|
+
// src/components/storage/utils.ts
|
|
7953
|
+
function humanizeBytes(bytes) {
|
|
7954
|
+
if (bytes == null || Number.isNaN(bytes) || bytes < 0) return "\u2014";
|
|
7955
|
+
if (bytes === 0) return "0 B";
|
|
7956
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
7957
|
+
const exponent = Math.min(Math.floor(Math.log(Math.abs(bytes)) / Math.log(1024)), units.length - 1);
|
|
7958
|
+
const value = bytes / 1024 ** exponent;
|
|
7959
|
+
const formatted = exponent === 0 ? String(Math.round(value)) : value.toFixed(1);
|
|
7960
|
+
return `${formatted} ${units[exponent]}`;
|
|
7961
|
+
}
|
|
7962
|
+
function formatDate(iso) {
|
|
7963
|
+
if (!iso) return "\u2014";
|
|
7964
|
+
const date = new Date(iso);
|
|
7965
|
+
if (Number.isNaN(date.getTime())) return "\u2014";
|
|
7966
|
+
return date.toLocaleDateString(void 0, {
|
|
7967
|
+
year: "numeric",
|
|
7968
|
+
month: "short",
|
|
7969
|
+
day: "numeric"
|
|
7970
|
+
});
|
|
7971
|
+
}
|
|
7972
|
+
function formatDateTime(iso) {
|
|
7973
|
+
if (!iso) return "\u2014";
|
|
7974
|
+
const date = new Date(iso);
|
|
7975
|
+
if (Number.isNaN(date.getTime())) return "\u2014";
|
|
7976
|
+
return date.toLocaleString(void 0, {
|
|
7977
|
+
year: "numeric",
|
|
7978
|
+
month: "short",
|
|
7979
|
+
day: "numeric",
|
|
7980
|
+
hour: "numeric",
|
|
7981
|
+
minute: "2-digit"
|
|
7982
|
+
});
|
|
7983
|
+
}
|
|
7984
|
+
function shortMimeLabel(mimeType) {
|
|
7985
|
+
if (!mimeType) return "\u2014";
|
|
7986
|
+
const lower = mimeType.toLowerCase();
|
|
7987
|
+
const known = {
|
|
7988
|
+
"application/pdf": "PDF",
|
|
7989
|
+
"application/zip": "ZIP",
|
|
7990
|
+
"application/x-zip-compressed": "ZIP",
|
|
7991
|
+
"application/gzip": "GZIP",
|
|
7992
|
+
"application/x-tar": "TAR",
|
|
7993
|
+
"application/json": "JSON",
|
|
7994
|
+
"application/msword": "DOC",
|
|
7995
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "DOCX",
|
|
7996
|
+
"application/vnd.ms-excel": "XLS",
|
|
7997
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "XLSX",
|
|
7998
|
+
"application/vnd.ms-powerpoint": "PPT",
|
|
7999
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "PPTX",
|
|
8000
|
+
"text/csv": "CSV",
|
|
8001
|
+
"text/plain": "TXT",
|
|
8002
|
+
"text/markdown": "MD"
|
|
8003
|
+
};
|
|
8004
|
+
if (known[lower]) return known[lower];
|
|
8005
|
+
const subtype = lower.split("/")[1] ?? lower;
|
|
8006
|
+
const base = subtype.split("+")[0].replace(/^x-/, "");
|
|
8007
|
+
return base.toUpperCase();
|
|
8008
|
+
}
|
|
8009
|
+
function objectDisplayName(object) {
|
|
8010
|
+
return object.filename?.trim() || object.key;
|
|
8011
|
+
}
|
|
8012
|
+
function bucketDisplayName(bucket) {
|
|
8013
|
+
return bucket.key;
|
|
8014
|
+
}
|
|
8015
|
+
function resolveIcon(mimeType) {
|
|
8016
|
+
if (!mimeType) return lucideReact.FileIcon;
|
|
8017
|
+
const lower = mimeType.toLowerCase();
|
|
8018
|
+
if (lower.startsWith("image/")) return lucideReact.FileImageIcon;
|
|
8019
|
+
if (lower.startsWith("audio/")) return lucideReact.FileAudioIcon;
|
|
8020
|
+
if (lower.startsWith("video/")) return lucideReact.FileVideoIcon;
|
|
8021
|
+
if (lower === "application/pdf" || lower === "application/msword" || lower === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
|
|
8022
|
+
return lucideReact.FileTypeIcon;
|
|
8023
|
+
}
|
|
8024
|
+
if (lower === "text/csv" || lower === "application/vnd.ms-excel" || lower === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") {
|
|
8025
|
+
return lucideReact.FileSpreadsheetIcon;
|
|
8026
|
+
}
|
|
8027
|
+
if (lower === "application/zip" || lower === "application/x-zip-compressed" || lower === "application/gzip" || lower === "application/x-tar" || lower === "application/x-7z-compressed" || lower === "application/x-rar-compressed") {
|
|
8028
|
+
return lucideReact.FileArchiveIcon;
|
|
8029
|
+
}
|
|
8030
|
+
if (lower.startsWith("text/") || lower === "application/json") return lucideReact.FileTextIcon;
|
|
8031
|
+
return lucideReact.FileIcon;
|
|
8032
|
+
}
|
|
8033
|
+
function FileTypeIcon({ mimeType, className, ...props }) {
|
|
8034
|
+
const Icon = resolveIcon(mimeType);
|
|
8035
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { "aria-hidden": true, className: cn("size-4 shrink-0 text-muted-foreground", className), ...props });
|
|
8036
|
+
}
|
|
8037
|
+
var VISIBILITY_CONFIG = {
|
|
8038
|
+
public: { label: "Public", icon: lucideReact.GlobeIcon, variant: "secondary" },
|
|
8039
|
+
private: { label: "Private", icon: lucideReact.LockIcon, variant: "outline" },
|
|
8040
|
+
temp: { label: "Temp", icon: lucideReact.ClockIcon, variant: "warning" }
|
|
8041
|
+
};
|
|
8042
|
+
function VisibilityBadge({ visibility, size, className, hideIcon }) {
|
|
8043
|
+
const config = VISIBILITY_CONFIG[visibility];
|
|
8044
|
+
const Icon = config.icon;
|
|
8045
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Badge, { variant: config.variant, size, className: cn("gap-1", className), children: [
|
|
8046
|
+
!hideIcon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { "aria-hidden": true }),
|
|
8047
|
+
config.label
|
|
8048
|
+
] });
|
|
8049
|
+
}
|
|
8050
|
+
var STATUS_CONFIG = {
|
|
8051
|
+
requested: { label: "Requested", variant: "outline" },
|
|
8052
|
+
uploaded: { label: "Uploaded", variant: "secondary" },
|
|
8053
|
+
processed: { label: "Processed", variant: "success" }
|
|
8054
|
+
};
|
|
8055
|
+
function ObjectStatusBadge({ status, size, className }) {
|
|
8056
|
+
const config = STATUS_CONFIG[status];
|
|
8057
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: config.variant, size, className, children: config.label });
|
|
8058
|
+
}
|
|
8059
|
+
function BucketRailItem({ bucket, selected, onSelect }) {
|
|
8060
|
+
const unprovisioned = bucket.provisioned === false;
|
|
8061
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8062
|
+
"button",
|
|
8063
|
+
{
|
|
8064
|
+
type: "button",
|
|
8065
|
+
"aria-current": selected ? "true" : void 0,
|
|
8066
|
+
onClick: () => onSelect(bucket.id),
|
|
8067
|
+
className: cn(
|
|
8068
|
+
`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none transition-colors
|
|
8069
|
+
focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,
|
|
8070
|
+
selected ? "bg-accent text-accent-foreground" : "text-foreground hover:bg-muted/50"
|
|
8071
|
+
),
|
|
8072
|
+
children: [
|
|
8073
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
8074
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: bucketDisplayName(bucket) }),
|
|
8075
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
|
|
8076
|
+
/* @__PURE__ */ jsxRuntime.jsx(VisibilityBadge, { visibility: bucket.visibility, size: "sm" }),
|
|
8077
|
+
unprovisioned && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-[0.625rem] text-muted-foreground", children: "Not provisioned" })
|
|
8078
|
+
] })
|
|
8079
|
+
] }),
|
|
8080
|
+
bucket.objectCount != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: bucket.objectCount })
|
|
8081
|
+
]
|
|
8082
|
+
}
|
|
8083
|
+
);
|
|
8084
|
+
}
|
|
8085
|
+
function BucketRail({ buckets, selectedBucketId, onSelectBucket, onNewBucket, className }) {
|
|
8086
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex h-full min-h-0 flex-col", className), children: [
|
|
8087
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5 p-2", children: buckets.map((bucket) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8088
|
+
BucketRailItem,
|
|
8089
|
+
{
|
|
8090
|
+
bucket,
|
|
8091
|
+
selected: bucket.id === selectedBucketId,
|
|
8092
|
+
onSelect: onSelectBucket
|
|
8093
|
+
},
|
|
8094
|
+
bucket.id
|
|
8095
|
+
)) }) }),
|
|
8096
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
|
|
8097
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2", children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-start", onClick: onNewBucket, children: [
|
|
8098
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.PlusIcon, { "aria-hidden": true }),
|
|
8099
|
+
"New bucket"
|
|
8100
|
+
] }) })
|
|
8101
|
+
] });
|
|
8102
|
+
}
|
|
8103
|
+
function StorageBreadcrumb({ bucketKey, segments = [], onNavigate, className }) {
|
|
8104
|
+
const hasSegments = segments.length > 0;
|
|
8105
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Breadcrumb, { className: cn("min-w-0", className), children: /* @__PURE__ */ jsxRuntime.jsxs(BreadcrumbList, { className: "flex-nowrap", children: [
|
|
8106
|
+
/* @__PURE__ */ jsxRuntime.jsx(BreadcrumbItem, { className: "min-w-0", children: hasSegments ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8107
|
+
BreadcrumbLink,
|
|
8108
|
+
{
|
|
8109
|
+
className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5",
|
|
8110
|
+
onClick: () => onNavigate?.(null),
|
|
8111
|
+
children: [
|
|
8112
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.HardDriveIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
|
|
8113
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: bucketKey })
|
|
8114
|
+
]
|
|
8115
|
+
}
|
|
8116
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(BreadcrumbPage, { className: "inline-flex min-w-0 items-center gap-1.5", children: [
|
|
8117
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.HardDriveIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
|
|
8118
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: bucketKey })
|
|
8119
|
+
] }) }),
|
|
8120
|
+
segments.map((segment, index) => {
|
|
8121
|
+
const isLast = index === segments.length - 1;
|
|
8122
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(BreadcrumbItem, { className: "min-w-0", children: [
|
|
8123
|
+
/* @__PURE__ */ jsxRuntime.jsx(BreadcrumbSeparator, {}),
|
|
8124
|
+
isLast ? /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbPage, { className: "truncate", children: segment.label }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
8125
|
+
BreadcrumbLink,
|
|
8126
|
+
{
|
|
8127
|
+
className: "cursor-pointer truncate",
|
|
8128
|
+
onClick: () => onNavigate?.(segment.path),
|
|
8129
|
+
children: segment.label
|
|
8130
|
+
}
|
|
8131
|
+
)
|
|
8132
|
+
] }, segment.path);
|
|
8133
|
+
})
|
|
8134
|
+
] }) });
|
|
8135
|
+
}
|
|
8136
|
+
var SORT_COLUMNS = [
|
|
8137
|
+
{ value: "filename", label: "Name" },
|
|
8138
|
+
{ value: "size", label: "Size" },
|
|
8139
|
+
{ value: "createdAt", label: "Modified" },
|
|
8140
|
+
{ value: "mimeType", label: "Type" }
|
|
8141
|
+
];
|
|
8142
|
+
function ObjectToolbar({
|
|
8143
|
+
query,
|
|
8144
|
+
onQueryChange,
|
|
8145
|
+
sort,
|
|
8146
|
+
onSortChange,
|
|
8147
|
+
onUpload,
|
|
8148
|
+
selectedCount = 0,
|
|
8149
|
+
onBulkDelete,
|
|
8150
|
+
bulkDeleteProgress,
|
|
8151
|
+
onClearSelection,
|
|
8152
|
+
className
|
|
8153
|
+
}) {
|
|
8154
|
+
if (selectedCount > 0) {
|
|
8155
|
+
const isDeleting = bulkDeleteProgress != null && bulkDeleteProgress.done < bulkDeleteProgress.total;
|
|
8156
|
+
const failedCount = bulkDeleteProgress?.failed.length ?? 0;
|
|
8157
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex h-9 items-center justify-between gap-2 rounded-lg border bg-muted/40 px-2", className), children: [
|
|
8158
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2 text-sm font-medium tabular-nums", children: [
|
|
8159
|
+
selectedCount,
|
|
8160
|
+
" selected",
|
|
8161
|
+
failedCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-normal text-destructive", children: [
|
|
8162
|
+
failedCount,
|
|
8163
|
+
" failed"
|
|
8164
|
+
] })
|
|
8165
|
+
] }),
|
|
8166
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
8167
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "destructive-outline", size: "sm", onClick: onBulkDelete, disabled: isDeleting, children: [
|
|
8168
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2Icon, { "aria-hidden": true }),
|
|
8169
|
+
isDeleting ? `Deleting ${bulkDeleteProgress.done}/${bulkDeleteProgress.total}` : "Delete"
|
|
8170
|
+
] }),
|
|
8171
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", onClick: onClearSelection, disabled: isDeleting, children: [
|
|
8172
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { "aria-hidden": true }),
|
|
8173
|
+
"Clear"
|
|
8174
|
+
] })
|
|
8175
|
+
] })
|
|
8176
|
+
] });
|
|
8177
|
+
}
|
|
8178
|
+
const activeColumn = SORT_COLUMNS.find((column) => column.value === sort.column);
|
|
8179
|
+
const DirectionIcon = sort.direction === "asc" ? lucideReact.ArrowUpIcon : lucideReact.ArrowDownIcon;
|
|
8180
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2", className), children: [
|
|
8181
|
+
/* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { className: "max-w-xs flex-1", children: [
|
|
8182
|
+
/* @__PURE__ */ jsxRuntime.jsx(InputGroupAddon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SearchIcon, { "aria-hidden": true }) }),
|
|
8183
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8184
|
+
InputGroupInput,
|
|
8185
|
+
{
|
|
8186
|
+
type: "search",
|
|
8187
|
+
placeholder: "Search files",
|
|
8188
|
+
value: query,
|
|
8189
|
+
onChange: (event) => onQueryChange(event.target.value)
|
|
8190
|
+
}
|
|
8191
|
+
)
|
|
8192
|
+
] }),
|
|
8193
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
|
|
8194
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", children: [
|
|
8195
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpDownIcon, { "aria-hidden": true }),
|
|
8196
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-sm:sr-only", children: activeColumn?.label ?? "Sort" }),
|
|
8197
|
+
/* @__PURE__ */ jsxRuntime.jsx(DirectionIcon, { "aria-hidden": true, className: "opacity-70" })
|
|
8198
|
+
] }) }),
|
|
8199
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align: "end", className: "min-w-44", children: [
|
|
8200
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { children: "Sort by" }),
|
|
8201
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8202
|
+
DropdownMenuRadioGroup,
|
|
8203
|
+
{
|
|
8204
|
+
value: sort.column,
|
|
8205
|
+
onValueChange: (value) => onSortChange({ ...sort, column: value }),
|
|
8206
|
+
children: SORT_COLUMNS.map((column) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: column.value, children: column.label }, column.value))
|
|
8207
|
+
}
|
|
8208
|
+
),
|
|
8209
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
8210
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { children: "Direction" }),
|
|
8211
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8212
|
+
DropdownMenuRadioGroup,
|
|
8213
|
+
{
|
|
8214
|
+
value: sort.direction,
|
|
8215
|
+
onValueChange: (value) => onSortChange({ ...sort, direction: value }),
|
|
8216
|
+
children: [
|
|
8217
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "asc", children: "Ascending" }),
|
|
8218
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "desc", children: "Descending" })
|
|
8219
|
+
]
|
|
8220
|
+
}
|
|
8221
|
+
)
|
|
8222
|
+
] })
|
|
8223
|
+
] }),
|
|
8224
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { size: "sm", onClick: onUpload, children: [
|
|
8225
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.UploadIcon, { "aria-hidden": true }),
|
|
8226
|
+
"Upload"
|
|
8227
|
+
] })
|
|
8228
|
+
] });
|
|
8229
|
+
}
|
|
8230
|
+
function SortableHeader({ column, label, sort, onSortChange, className }) {
|
|
8231
|
+
const isActive = sort.column === column;
|
|
8232
|
+
const nextDirection = isActive && sort.direction === "asc" ? "desc" : "asc";
|
|
8233
|
+
const CaretIcon = sort.direction === "asc" ? lucideReact.ArrowUpIcon : lucideReact.ArrowDownIcon;
|
|
8234
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8235
|
+
"button",
|
|
8236
|
+
{
|
|
8237
|
+
type: "button",
|
|
8238
|
+
onClick: () => onSortChange({ column, direction: nextDirection }),
|
|
8239
|
+
"aria-label": `Sort by ${label}`,
|
|
8240
|
+
className: "-mx-1 inline-flex items-center gap-1 rounded px-1 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
8241
|
+
children: [
|
|
8242
|
+
label,
|
|
8243
|
+
isActive && /* @__PURE__ */ jsxRuntime.jsx(CaretIcon, { className: "size-3.5", "aria-hidden": true })
|
|
8244
|
+
]
|
|
8245
|
+
}
|
|
8246
|
+
) });
|
|
8247
|
+
}
|
|
8248
|
+
var COLUMN_COUNT = 6;
|
|
8249
|
+
function ObjectTable({
|
|
8250
|
+
objects,
|
|
8251
|
+
selectedIds,
|
|
8252
|
+
onSelectionChange,
|
|
8253
|
+
sort,
|
|
8254
|
+
onSortChange,
|
|
8255
|
+
onOpenObject,
|
|
8256
|
+
onDownload,
|
|
8257
|
+
onCopyLink,
|
|
8258
|
+
onRename,
|
|
8259
|
+
onDelete,
|
|
8260
|
+
isLoading,
|
|
8261
|
+
emptyLabel = "No files",
|
|
8262
|
+
className
|
|
8263
|
+
}) {
|
|
8264
|
+
if (isLoading) {
|
|
8265
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ObjectTableSkeleton, { className });
|
|
8266
|
+
}
|
|
8267
|
+
const selected = new Set(selectedIds);
|
|
8268
|
+
const allSelected = objects.length > 0 && selected.size === objects.length;
|
|
8269
|
+
const someSelected = selected.size > 0 && !allSelected;
|
|
8270
|
+
const toggleAll = (checked) => {
|
|
8271
|
+
onSelectionChange(checked ? objects.map((object) => object.id) : []);
|
|
8272
|
+
};
|
|
8273
|
+
const toggleOne = (objectId, checked) => {
|
|
8274
|
+
const next = new Set(selected);
|
|
8275
|
+
if (checked) next.add(objectId);
|
|
8276
|
+
else next.delete(objectId);
|
|
8277
|
+
onSelectionChange([...next]);
|
|
8278
|
+
};
|
|
8279
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Table, { className, children: [
|
|
8280
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
8281
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8282
|
+
Checkbox,
|
|
8283
|
+
{
|
|
8284
|
+
"aria-label": "Select all files",
|
|
8285
|
+
checked: allSelected,
|
|
8286
|
+
indeterminate: someSelected,
|
|
8287
|
+
onCheckedChange: (checked) => toggleAll(checked === true)
|
|
8288
|
+
}
|
|
8289
|
+
) }),
|
|
8290
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortableHeader, { column: "filename", label: "Name", sort, onSortChange }),
|
|
8291
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortableHeader, { column: "mimeType", label: "Type", sort, onSortChange }),
|
|
8292
|
+
/* @__PURE__ */ jsxRuntime.jsx(SortableHeader, { column: "size", label: "Size", sort, onSortChange, className: "text-right" }),
|
|
8293
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8294
|
+
SortableHeader,
|
|
8295
|
+
{
|
|
8296
|
+
column: "createdAt",
|
|
8297
|
+
label: "Modified",
|
|
8298
|
+
sort,
|
|
8299
|
+
onSortChange,
|
|
8300
|
+
className: "text-right"
|
|
8301
|
+
}
|
|
8302
|
+
),
|
|
8303
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-10" })
|
|
8304
|
+
] }) }),
|
|
8305
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: objects.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: COLUMN_COUNT, className: "h-24 text-center text-sm text-muted-foreground", children: emptyLabel }) }) : objects.map((object) => {
|
|
8306
|
+
const isSelected = selected.has(object.id);
|
|
8307
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8308
|
+
TableRow,
|
|
8309
|
+
{
|
|
8310
|
+
"data-state": isSelected ? "selected" : void 0,
|
|
8311
|
+
onClick: () => onOpenObject?.(object),
|
|
8312
|
+
className: "cursor-pointer",
|
|
8313
|
+
children: [
|
|
8314
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8315
|
+
Checkbox,
|
|
8316
|
+
{
|
|
8317
|
+
"aria-label": `Select ${objectDisplayName(object)}`,
|
|
8318
|
+
checked: isSelected,
|
|
8319
|
+
onCheckedChange: (checked) => toggleOne(object.id, checked === true)
|
|
8320
|
+
}
|
|
8321
|
+
) }),
|
|
8322
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "max-w-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8323
|
+
/* @__PURE__ */ jsxRuntime.jsx(FileTypeIcon, { mimeType: object.mimeType }),
|
|
8324
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: objectDisplayName(object) })
|
|
8325
|
+
] }) }),
|
|
8326
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-muted-foreground", children: shortMimeLabel(object.mimeType) }),
|
|
8327
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: humanizeBytes(object.size) }),
|
|
8328
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums text-muted-foreground", children: formatDate(object.createdAt) }),
|
|
8329
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
|
|
8330
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": `Actions for ${objectDisplayName(object)}`, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontalIcon, { "aria-hidden": true }) }) }),
|
|
8331
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align: "end", children: [
|
|
8332
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => onDownload?.(object), children: [
|
|
8333
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.DownloadIcon, { className: "size-4", "aria-hidden": true }),
|
|
8334
|
+
"Download"
|
|
8335
|
+
] }),
|
|
8336
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => onCopyLink?.(object), children: [
|
|
8337
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, { className: "size-4", "aria-hidden": true }),
|
|
8338
|
+
"Copy link"
|
|
8339
|
+
] }),
|
|
8340
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => onRename?.(object), children: [
|
|
8341
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.PencilIcon, { className: "size-4", "aria-hidden": true }),
|
|
8342
|
+
"Rename"
|
|
8343
|
+
] }),
|
|
8344
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
|
|
8345
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { variant: "destructive", onClick: () => onDelete?.(object), children: [
|
|
8346
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2Icon, { className: "size-4", "aria-hidden": true }),
|
|
8347
|
+
"Delete"
|
|
8348
|
+
] })
|
|
8349
|
+
] })
|
|
8350
|
+
] }) })
|
|
8351
|
+
]
|
|
8352
|
+
},
|
|
8353
|
+
object.id
|
|
8354
|
+
);
|
|
8355
|
+
}) })
|
|
8356
|
+
] });
|
|
8357
|
+
}
|
|
8358
|
+
function ObjectTableSkeleton({ rows = 6, className }) {
|
|
8359
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Table, { className, children: [
|
|
8360
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
8361
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-10" }),
|
|
8362
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Name" }),
|
|
8363
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Type" }),
|
|
8364
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-right", children: "Size" }),
|
|
8365
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-right", children: "Modified" }),
|
|
8366
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "w-10" })
|
|
8367
|
+
] }) }),
|
|
8368
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: Array.from({ length: rows }).map((_, index) => (
|
|
8369
|
+
// Skeleton rows are positional and static; index key is acceptable here.
|
|
8370
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "hover:bg-transparent", children: [
|
|
8371
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "size-4 rounded-[4px]" }) }),
|
|
8372
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8373
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "size-4" }),
|
|
8374
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-40" })
|
|
8375
|
+
] }) }),
|
|
8376
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-10" }) }),
|
|
8377
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-12" }) }),
|
|
8378
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "ml-auto h-4 w-20" }) }),
|
|
8379
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "size-4" }) })
|
|
8380
|
+
] }, index)
|
|
8381
|
+
)) })
|
|
8382
|
+
] });
|
|
8383
|
+
}
|
|
8384
|
+
function MetadataRow({ label, children }) {
|
|
8385
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[7rem_1fr] items-start gap-2 py-1.5", children: [
|
|
8386
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "text-sm text-muted-foreground", children: label }),
|
|
8387
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "min-w-0 text-sm", children })
|
|
8388
|
+
] });
|
|
8389
|
+
}
|
|
8390
|
+
function ObjectDetailBody({
|
|
8391
|
+
object,
|
|
8392
|
+
onDownload,
|
|
8393
|
+
onCopyLink,
|
|
8394
|
+
onRename,
|
|
8395
|
+
onDelete,
|
|
8396
|
+
isPreviewLoading
|
|
8397
|
+
}) {
|
|
8398
|
+
const displayName = objectDisplayName(object);
|
|
8399
|
+
const [isRenaming, setIsRenaming] = React19__namespace.useState(false);
|
|
8400
|
+
const [draftName, setDraftName] = React19__namespace.useState(displayName);
|
|
8401
|
+
const isImageType = object.mimeType.startsWith("image/");
|
|
8402
|
+
const isImage = isImageType && !!object.downloadUrl;
|
|
8403
|
+
const commitRename = () => {
|
|
8404
|
+
const trimmed = draftName.trim();
|
|
8405
|
+
if (trimmed && trimmed !== displayName) {
|
|
8406
|
+
onRename?.(object.id, trimmed);
|
|
8407
|
+
}
|
|
8408
|
+
setIsRenaming(false);
|
|
8409
|
+
};
|
|
8410
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8411
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SheetHeader, { className: "pb-3 text-left", children: [
|
|
8412
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { className: "truncate pr-8", children: displayName }),
|
|
8413
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetDescription, { className: "truncate font-mono text-xs", children: object.key })
|
|
8414
|
+
] }),
|
|
8415
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center rounded-lg border bg-muted/40 p-4", children: isImageType && isPreviewLoading ? /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "size-40 rounded-md" }) : isImage ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: object.downloadUrl ?? void 0, alt: displayName, className: "size-40 rounded-md object-cover" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-40 items-center justify-center rounded-md bg-background", children: /* @__PURE__ */ jsxRuntime.jsx(FileTypeIcon, { mimeType: object.mimeType, className: "size-16 text-muted-foreground" }) }) }),
|
|
8416
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-3", children: isRenaming ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8417
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8418
|
+
Input,
|
|
8419
|
+
{
|
|
8420
|
+
autoFocus: true,
|
|
8421
|
+
value: draftName,
|
|
8422
|
+
onChange: (event) => setDraftName(event.target.value),
|
|
8423
|
+
onKeyDown: (event) => {
|
|
8424
|
+
if (event.key === "Enter") commitRename();
|
|
8425
|
+
if (event.key === "Escape") setIsRenaming(false);
|
|
8426
|
+
},
|
|
8427
|
+
"aria-label": "New file name"
|
|
8428
|
+
}
|
|
8429
|
+
),
|
|
8430
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { size: "icon-sm", "aria-label": "Save name", onClick: commitRename, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { "aria-hidden": true }) }),
|
|
8431
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { size: "icon-sm", variant: "ghost", "aria-label": "Cancel rename", onClick: () => setIsRenaming(false), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { "aria-hidden": true }) })
|
|
8432
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", size: "sm", className: "w-full justify-start", onClick: () => setIsRenaming(true), children: [
|
|
8433
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.PencilIcon, { "aria-hidden": true }),
|
|
8434
|
+
"Rename"
|
|
8435
|
+
] }) }),
|
|
8436
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
|
|
8437
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "py-2", children: [
|
|
8438
|
+
/* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Filename", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate", children: object.filename ?? "\u2014" }) }),
|
|
8439
|
+
/* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Size", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums", children: humanizeBytes(object.size) }) }),
|
|
8440
|
+
/* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Type", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "break-all", children: object.mimeType }) }),
|
|
8441
|
+
/* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Modified", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums", children: formatDateTime(object.updatedAt ?? object.createdAt) }) }),
|
|
8442
|
+
/* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Key", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate font-mono text-xs", children: object.key }) }),
|
|
8443
|
+
/* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Visibility", children: /* @__PURE__ */ jsxRuntime.jsx(VisibilityBadge, { visibility: object.isPublic ? "public" : "private", size: "sm" }) }),
|
|
8444
|
+
object.status && /* @__PURE__ */ jsxRuntime.jsx(MetadataRow, { label: "Status", children: /* @__PURE__ */ jsxRuntime.jsx(ObjectStatusBadge, { status: object.status, size: "sm" }) })
|
|
8445
|
+
] }),
|
|
8446
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
|
|
8447
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 pt-4", children: [
|
|
8448
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: () => onDownload?.(object), children: [
|
|
8449
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.DownloadIcon, { "aria-hidden": true }),
|
|
8450
|
+
"Download"
|
|
8451
|
+
] }),
|
|
8452
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "outline", onClick: () => onCopyLink?.(object), children: [
|
|
8453
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, { "aria-hidden": true }),
|
|
8454
|
+
"Copy link"
|
|
8455
|
+
] }),
|
|
8456
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialog, { children: [
|
|
8457
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "destructive-outline", children: [
|
|
8458
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2Icon, { "aria-hidden": true }),
|
|
8459
|
+
"Delete"
|
|
8460
|
+
] }) }),
|
|
8461
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialogContent, { children: [
|
|
8462
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialogHeader, { children: [
|
|
8463
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogTitle, { children: "Delete this file?" }),
|
|
8464
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogDescription, { children: `"${displayName}" will be permanently removed. This action cannot be undone.` })
|
|
8465
|
+
] }),
|
|
8466
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialogFooter, { children: [
|
|
8467
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogCancel, { children: "Cancel" }),
|
|
8468
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8469
|
+
AlertDialogAction,
|
|
8470
|
+
{
|
|
8471
|
+
className: cn("bg-destructive text-destructive-foreground hover:bg-destructive/90"),
|
|
8472
|
+
onClick: () => onDelete?.(object.id),
|
|
8473
|
+
children: "Delete"
|
|
8474
|
+
}
|
|
8475
|
+
)
|
|
8476
|
+
] })
|
|
8477
|
+
] })
|
|
8478
|
+
] })
|
|
8479
|
+
] })
|
|
8480
|
+
] });
|
|
8481
|
+
}
|
|
8482
|
+
function ObjectDetailSheet({
|
|
8483
|
+
object,
|
|
8484
|
+
open,
|
|
8485
|
+
onOpenChange,
|
|
8486
|
+
onDownload,
|
|
8487
|
+
onCopyLink,
|
|
8488
|
+
onRename,
|
|
8489
|
+
onDelete,
|
|
8490
|
+
isPreviewLoading
|
|
8491
|
+
}) {
|
|
8492
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(SheetContent, { side: "right", className: "w-full gap-0 sm:max-w-md", children: object && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8493
|
+
ObjectDetailBody,
|
|
8494
|
+
{
|
|
8495
|
+
object,
|
|
8496
|
+
onDownload,
|
|
8497
|
+
onCopyLink,
|
|
8498
|
+
onRename,
|
|
8499
|
+
onDelete,
|
|
8500
|
+
isPreviewLoading
|
|
8501
|
+
},
|
|
8502
|
+
object.id
|
|
8503
|
+
) }) });
|
|
8504
|
+
}
|
|
8505
|
+
function UploadDropzone({ onFiles, uploads, onCancel, accept, maxSize, className }) {
|
|
8506
|
+
const inputRef = React19__namespace.useRef(null);
|
|
8507
|
+
const [isDragging, setIsDragging] = React19__namespace.useState(false);
|
|
8508
|
+
const handleDrop = (event) => {
|
|
8509
|
+
event.preventDefault();
|
|
8510
|
+
setIsDragging(false);
|
|
8511
|
+
if (event.dataTransfer.files.length > 0) {
|
|
8512
|
+
onFiles(event.dataTransfer.files);
|
|
8513
|
+
}
|
|
8514
|
+
};
|
|
8515
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-3", className), children: [
|
|
8516
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8517
|
+
"div",
|
|
8518
|
+
{
|
|
8519
|
+
onDragOver: (event) => {
|
|
8520
|
+
event.preventDefault();
|
|
8521
|
+
setIsDragging(true);
|
|
8522
|
+
},
|
|
8523
|
+
onDragLeave: () => setIsDragging(false),
|
|
8524
|
+
onDrop: handleDrop,
|
|
8525
|
+
className: cn(
|
|
8526
|
+
`flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed px-6 py-8 text-center
|
|
8527
|
+
transition-colors`,
|
|
8528
|
+
isDragging ? "border-primary bg-primary/5" : "border-input bg-muted/30"
|
|
8529
|
+
),
|
|
8530
|
+
children: [
|
|
8531
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.UploadCloudIcon, { className: "size-5", "aria-hidden": true }) }),
|
|
8532
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
8533
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-pretty text-sm font-medium", children: "Drag & drop files here" }),
|
|
8534
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
8535
|
+
"or browse",
|
|
8536
|
+
maxSize ? ` \u2014 up to ${humanizeBytes(maxSize)} each` : ""
|
|
8537
|
+
] })
|
|
8538
|
+
] }),
|
|
8539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => inputRef.current?.click(), children: "Browse files" }),
|
|
8540
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8541
|
+
"input",
|
|
8542
|
+
{
|
|
8543
|
+
ref: inputRef,
|
|
8544
|
+
type: "file",
|
|
8545
|
+
multiple: true,
|
|
8546
|
+
accept,
|
|
8547
|
+
className: "sr-only",
|
|
8548
|
+
onChange: (event) => {
|
|
8549
|
+
if (event.target.files && event.target.files.length > 0) {
|
|
8550
|
+
onFiles(event.target.files);
|
|
8551
|
+
}
|
|
8552
|
+
event.target.value = "";
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8555
|
+
)
|
|
8556
|
+
]
|
|
8557
|
+
}
|
|
8558
|
+
),
|
|
8559
|
+
uploads && uploads.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(UploadProgressList, { uploads, onCancel })
|
|
8560
|
+
] });
|
|
8561
|
+
}
|
|
8562
|
+
function UploadProgressList({ uploads, onCancel, className }) {
|
|
8563
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cn("flex flex-col gap-2", className), children: uploads.map((item) => {
|
|
8564
|
+
const isActive = item.status === "queued" || item.status === "uploading";
|
|
8565
|
+
const isError = item.status === "error";
|
|
8566
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8567
|
+
"li",
|
|
8568
|
+
{
|
|
8569
|
+
className: "flex items-center gap-3 rounded-lg border bg-background px-3 py-2",
|
|
8570
|
+
children: [
|
|
8571
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8572
|
+
FileTypeIcon,
|
|
8573
|
+
{
|
|
8574
|
+
mimeType: item.filename.includes(".") ? guessMimeFromName(item.filename) : "",
|
|
8575
|
+
className: cn(isError && "text-destructive")
|
|
8576
|
+
}
|
|
8577
|
+
),
|
|
8578
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
8579
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
8580
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium", children: item.filename }),
|
|
8581
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: humanizeBytes(item.size) })
|
|
8582
|
+
] }),
|
|
8583
|
+
isError ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1 text-xs text-destructive", children: [
|
|
8584
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircleIcon, { className: "size-3.5", "aria-hidden": true }),
|
|
8585
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: item.error ?? "Upload failed" })
|
|
8586
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
8587
|
+
Progress,
|
|
8588
|
+
{
|
|
8589
|
+
value: item.status === "done" ? 100 : item.progress,
|
|
8590
|
+
"aria-label": `${item.filename} ${item.progress}%`,
|
|
8591
|
+
className: "h-1.5"
|
|
8592
|
+
}
|
|
8593
|
+
)
|
|
8594
|
+
] }),
|
|
8595
|
+
isActive && onCancel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8596
|
+
Button,
|
|
8597
|
+
{
|
|
8598
|
+
size: "icon-sm",
|
|
8599
|
+
variant: "ghost",
|
|
8600
|
+
"aria-label": `Cancel upload of ${item.filename}`,
|
|
8601
|
+
onClick: () => onCancel(item.id),
|
|
8602
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { "aria-hidden": true })
|
|
8603
|
+
}
|
|
8604
|
+
)
|
|
8605
|
+
]
|
|
8606
|
+
},
|
|
8607
|
+
item.id
|
|
8608
|
+
);
|
|
8609
|
+
}) });
|
|
8610
|
+
}
|
|
8611
|
+
function guessMimeFromName(filename) {
|
|
8612
|
+
const ext = filename.split(".").pop()?.toLowerCase() ?? "";
|
|
8613
|
+
const map = {
|
|
8614
|
+
png: "image/png",
|
|
8615
|
+
jpg: "image/jpeg",
|
|
8616
|
+
jpeg: "image/jpeg",
|
|
8617
|
+
gif: "image/gif",
|
|
8618
|
+
webp: "image/webp",
|
|
8619
|
+
svg: "image/svg+xml",
|
|
8620
|
+
pdf: "application/pdf",
|
|
8621
|
+
zip: "application/zip",
|
|
8622
|
+
csv: "text/csv",
|
|
8623
|
+
txt: "text/plain",
|
|
8624
|
+
md: "text/markdown",
|
|
8625
|
+
doc: "application/msword",
|
|
8626
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
8627
|
+
xls: "application/vnd.ms-excel",
|
|
8628
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
8629
|
+
mp4: "video/mp4",
|
|
8630
|
+
mp3: "audio/mpeg"
|
|
8631
|
+
};
|
|
8632
|
+
return map[ext] ?? "";
|
|
8633
|
+
}
|
|
8634
|
+
var VISIBILITY_OPTIONS = [
|
|
8635
|
+
{ value: "public", label: "Public", hint: "Anyone with the link can read objects." },
|
|
8636
|
+
{ value: "private", label: "Private", hint: "Only authorized requests can read objects." },
|
|
8637
|
+
{ value: "temp", label: "Temp", hint: "Short-lived objects, cleaned up automatically." }
|
|
8638
|
+
];
|
|
8639
|
+
function toFormValue(initial) {
|
|
8640
|
+
return {
|
|
8641
|
+
key: initial?.key ?? "",
|
|
8642
|
+
visibility: initial?.visibility ?? "private",
|
|
8643
|
+
allowCustomKeys: initial?.allowCustomKeys ?? false,
|
|
8644
|
+
allowedMimeTypes: initial?.allowedMimeTypes ?? [],
|
|
8645
|
+
maxFileSize: initial?.maxFileSize ?? null,
|
|
8646
|
+
allowedOrigins: initial?.allowedOrigins ?? [],
|
|
8647
|
+
description: initial?.description ?? ""
|
|
8648
|
+
};
|
|
8649
|
+
}
|
|
8650
|
+
function BucketConfigForm({
|
|
8651
|
+
mode,
|
|
8652
|
+
initial,
|
|
8653
|
+
onSubmit,
|
|
8654
|
+
onCancel,
|
|
8655
|
+
onOpenChange,
|
|
8656
|
+
supportedFields
|
|
8657
|
+
}) {
|
|
8658
|
+
const [value, setValue] = React19__namespace.useState(() => toFormValue(initial));
|
|
8659
|
+
const supports = (field) => supportedFields?.[field] !== false;
|
|
8660
|
+
const keyMissing = mode === "create" && value.key.trim() === "";
|
|
8661
|
+
const handleSubmit = (event) => {
|
|
8662
|
+
event.preventDefault();
|
|
8663
|
+
if (keyMissing) return;
|
|
8664
|
+
onSubmit({ ...value, key: value.key.trim(), description: value.description.trim() });
|
|
8665
|
+
};
|
|
8666
|
+
const set = (field, fieldValue) => {
|
|
8667
|
+
setValue((prev) => ({ ...prev, [field]: fieldValue }));
|
|
8668
|
+
};
|
|
8669
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
8670
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SheetHeader, { className: "text-left", children: [
|
|
8671
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: mode === "create" ? "New bucket" : "Edit bucket" }),
|
|
8672
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetDescription, { children: mode === "create" ? "Configure a new storage bucket." : "Update this bucket\u2019s configuration." })
|
|
8673
|
+
] }),
|
|
8674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "-mx-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-4 py-2", children: [
|
|
8675
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
8676
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "bucket-key", children: "Key" }),
|
|
8677
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8678
|
+
Input,
|
|
8679
|
+
{
|
|
8680
|
+
id: "bucket-key",
|
|
8681
|
+
value: value.key,
|
|
8682
|
+
disabled: mode === "edit",
|
|
8683
|
+
placeholder: "my-bucket",
|
|
8684
|
+
"aria-invalid": keyMissing || void 0,
|
|
8685
|
+
onChange: (event) => set("key", event.target.value)
|
|
8686
|
+
}
|
|
8687
|
+
),
|
|
8688
|
+
mode === "edit" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "The key cannot be changed after creation." })
|
|
8689
|
+
] }),
|
|
8690
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
8691
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Visibility" }),
|
|
8692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8693
|
+
RadioGroup,
|
|
8694
|
+
{
|
|
8695
|
+
value: value.visibility,
|
|
8696
|
+
onValueChange: (next) => set("visibility", next),
|
|
8697
|
+
className: "gap-2",
|
|
8698
|
+
children: VISIBILITY_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8699
|
+
Label,
|
|
8700
|
+
{
|
|
8701
|
+
htmlFor: `visibility-${option.value}`,
|
|
8702
|
+
className: "flex cursor-pointer items-start gap-2.5 rounded-lg border p-3 font-normal has-[:checked]:border-primary/50 has-[:checked]:bg-primary/5",
|
|
8703
|
+
children: [
|
|
8704
|
+
/* @__PURE__ */ jsxRuntime.jsx(Radio, { id: `visibility-${option.value}`, value: option.value, className: "mt-0.5" }),
|
|
8705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col gap-0.5", children: [
|
|
8706
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: option.label }),
|
|
8707
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: option.hint })
|
|
8708
|
+
] })
|
|
8709
|
+
]
|
|
8710
|
+
},
|
|
8711
|
+
option.value
|
|
8712
|
+
))
|
|
8713
|
+
}
|
|
8714
|
+
)
|
|
8715
|
+
] }),
|
|
8716
|
+
supports("allowCustomKeys") && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8717
|
+
Label,
|
|
8718
|
+
{
|
|
8719
|
+
htmlFor: "allow-custom-keys",
|
|
8720
|
+
className: "flex cursor-pointer items-center justify-between gap-3 font-normal",
|
|
8721
|
+
children: [
|
|
8722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col gap-0.5", children: [
|
|
8723
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Allow custom keys" }),
|
|
8724
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-pretty text-xs text-muted-foreground", children: "Let clients choose object keys instead of generated ones." })
|
|
8725
|
+
] }),
|
|
8726
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8727
|
+
Switch,
|
|
8728
|
+
{
|
|
8729
|
+
id: "allow-custom-keys",
|
|
8730
|
+
checked: value.allowCustomKeys,
|
|
8731
|
+
onCheckedChange: (checked) => set("allowCustomKeys", checked)
|
|
8732
|
+
}
|
|
8733
|
+
)
|
|
8734
|
+
]
|
|
8735
|
+
}
|
|
8736
|
+
),
|
|
8737
|
+
supports("allowedMimeTypes") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
8738
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Allowed MIME types" }),
|
|
8739
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8740
|
+
ChipsInput,
|
|
8741
|
+
{
|
|
8742
|
+
value: value.allowedMimeTypes,
|
|
8743
|
+
onChange: (next) => set("allowedMimeTypes", next),
|
|
8744
|
+
placeholder: "image/png, application/pdf\u2026",
|
|
8745
|
+
ariaLabel: "Allowed MIME types"
|
|
8746
|
+
}
|
|
8747
|
+
),
|
|
8748
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Leave empty to allow any type." })
|
|
8749
|
+
] }),
|
|
8750
|
+
supports("maxFileSize") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
8751
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "max-file-size", children: "Max file size" }),
|
|
8752
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8753
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8754
|
+
Input,
|
|
8755
|
+
{
|
|
8756
|
+
id: "max-file-size",
|
|
8757
|
+
type: "number",
|
|
8758
|
+
min: 0,
|
|
8759
|
+
inputMode: "numeric",
|
|
8760
|
+
className: "max-w-40",
|
|
8761
|
+
value: value.maxFileSize ?? "",
|
|
8762
|
+
placeholder: "Unlimited",
|
|
8763
|
+
onChange: (event) => set("maxFileSize", event.target.value === "" ? null : Number(event.target.value))
|
|
8764
|
+
}
|
|
8765
|
+
),
|
|
8766
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "bytes" })
|
|
8767
|
+
] })
|
|
8768
|
+
] }),
|
|
8769
|
+
supports("allowedOrigins") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
8770
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Allowed origins (CORS)" }),
|
|
8771
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8772
|
+
ChipsInput,
|
|
8773
|
+
{
|
|
8774
|
+
value: value.allowedOrigins,
|
|
8775
|
+
onChange: (next) => set("allowedOrigins", next),
|
|
8776
|
+
placeholder: "https://example.com",
|
|
8777
|
+
ariaLabel: "Allowed origins"
|
|
8778
|
+
}
|
|
8779
|
+
)
|
|
8780
|
+
] }),
|
|
8781
|
+
supports("description") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
8782
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "bucket-description", children: "Description" }),
|
|
8783
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8784
|
+
Textarea,
|
|
8785
|
+
{
|
|
8786
|
+
id: "bucket-description",
|
|
8787
|
+
value: value.description,
|
|
8788
|
+
placeholder: "What is this bucket for?",
|
|
8789
|
+
onChange: (event) => set("description", event.target.value)
|
|
8790
|
+
}
|
|
8791
|
+
)
|
|
8792
|
+
] })
|
|
8793
|
+
] }),
|
|
8794
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SheetFooter, { className: "pt-3", children: [
|
|
8795
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8796
|
+
Button,
|
|
8797
|
+
{
|
|
8798
|
+
type: "button",
|
|
8799
|
+
variant: "outline",
|
|
8800
|
+
onClick: () => {
|
|
8801
|
+
onCancel?.();
|
|
8802
|
+
onOpenChange(false);
|
|
8803
|
+
},
|
|
8804
|
+
children: "Cancel"
|
|
8805
|
+
}
|
|
8806
|
+
),
|
|
8807
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", disabled: keyMissing, children: mode === "create" ? "Create bucket" : "Save changes" })
|
|
8808
|
+
] })
|
|
8809
|
+
] });
|
|
8810
|
+
}
|
|
8811
|
+
function BucketConfigSheet({
|
|
8812
|
+
mode,
|
|
8813
|
+
initial,
|
|
8814
|
+
open,
|
|
8815
|
+
onOpenChange,
|
|
8816
|
+
onSubmit,
|
|
8817
|
+
onCancel,
|
|
8818
|
+
supportedFields
|
|
8819
|
+
}) {
|
|
8820
|
+
const formKey = `${mode}:${initial?.id ?? "new"}:${open}`;
|
|
8821
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(SheetContent, { side: "right", className: "w-full sm:max-w-md", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8822
|
+
BucketConfigForm,
|
|
8823
|
+
{
|
|
8824
|
+
mode,
|
|
8825
|
+
initial,
|
|
8826
|
+
onSubmit,
|
|
8827
|
+
onCancel,
|
|
8828
|
+
onOpenChange,
|
|
8829
|
+
supportedFields
|
|
8830
|
+
},
|
|
8831
|
+
formKey
|
|
8832
|
+
) }) });
|
|
8833
|
+
}
|
|
8834
|
+
function ChipsInput({ value, onChange, placeholder, ariaLabel }) {
|
|
8835
|
+
const [draft, setDraft] = React19__namespace.useState("");
|
|
8836
|
+
const commit = () => {
|
|
8837
|
+
const token = draft.trim().replace(/,$/, "").trim();
|
|
8838
|
+
if (token && !value.includes(token)) {
|
|
8839
|
+
onChange([...value, token]);
|
|
8840
|
+
}
|
|
8841
|
+
setDraft("");
|
|
8842
|
+
};
|
|
8843
|
+
const removeAt = (index) => {
|
|
8844
|
+
onChange(value.filter((_, current) => current !== index));
|
|
8845
|
+
};
|
|
8846
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8847
|
+
"div",
|
|
8848
|
+
{
|
|
8849
|
+
className: cn(
|
|
8850
|
+
`flex min-h-9 flex-wrap items-center gap-1.5 rounded-lg border border-input bg-background px-2 py-1.5
|
|
8851
|
+
focus-within:border-primary/60 focus-within:ring-[3px] focus-within:ring-primary/35`
|
|
8852
|
+
),
|
|
8853
|
+
children: [
|
|
8854
|
+
value.map((chip, index) => /* @__PURE__ */ jsxRuntime.jsxs(Badge, { variant: "secondary", className: "gap-1 pr-1", children: [
|
|
8855
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: chip }),
|
|
8856
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8857
|
+
"button",
|
|
8858
|
+
{
|
|
8859
|
+
type: "button",
|
|
8860
|
+
"aria-label": `Remove ${chip}`,
|
|
8861
|
+
onClick: () => removeAt(index),
|
|
8862
|
+
className: "inline-flex size-3.5 items-center justify-center rounded-xs hover:bg-foreground/10",
|
|
8863
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { className: "size-3", "aria-hidden": true })
|
|
8864
|
+
}
|
|
8865
|
+
)
|
|
8866
|
+
] }, chip)),
|
|
8867
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8868
|
+
"input",
|
|
8869
|
+
{
|
|
8870
|
+
value: draft,
|
|
8871
|
+
onChange: (event) => setDraft(event.target.value),
|
|
8872
|
+
onKeyDown: (event) => {
|
|
8873
|
+
if (event.key === "Enter" || event.key === ",") {
|
|
8874
|
+
event.preventDefault();
|
|
8875
|
+
commit();
|
|
8876
|
+
} else if (event.key === "Backspace" && draft === "" && value.length > 0) {
|
|
8877
|
+
removeAt(value.length - 1);
|
|
8878
|
+
}
|
|
8879
|
+
},
|
|
8880
|
+
onBlur: commit,
|
|
8881
|
+
placeholder: value.length === 0 ? placeholder : void 0,
|
|
8882
|
+
"aria-label": ariaLabel,
|
|
8883
|
+
className: "min-w-24 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/72"
|
|
8884
|
+
}
|
|
8885
|
+
)
|
|
8886
|
+
]
|
|
8887
|
+
}
|
|
8888
|
+
);
|
|
8889
|
+
}
|
|
8890
|
+
var VARIANTS = {
|
|
8891
|
+
"no-buckets": {
|
|
8892
|
+
icon: lucideReact.HardDriveIcon,
|
|
8893
|
+
title: "No buckets yet",
|
|
8894
|
+
description: "Buckets organize your uploaded files. Create your first one to start storing objects.",
|
|
8895
|
+
actionLabel: "New bucket"
|
|
8896
|
+
},
|
|
8897
|
+
"not-provisioned": {
|
|
8898
|
+
icon: lucideReact.DatabaseIcon,
|
|
8899
|
+
title: "Storage not provisioned",
|
|
8900
|
+
description: "This database has buckets defined but storage has not been provisioned yet. Provision to enable uploads.",
|
|
8901
|
+
actionLabel: "Provision storage"
|
|
8902
|
+
},
|
|
8903
|
+
"empty-bucket": {
|
|
8904
|
+
icon: lucideReact.InboxIcon,
|
|
8905
|
+
title: "This bucket is empty",
|
|
8906
|
+
description: "Upload files to this bucket and they will appear here.",
|
|
8907
|
+
actionLabel: "Upload files"
|
|
8908
|
+
},
|
|
8909
|
+
"no-access": {
|
|
8910
|
+
icon: lucideReact.ShieldAlertIcon,
|
|
8911
|
+
title: "No access to storage",
|
|
8912
|
+
description: "You need to be an active member of this organization to view its storage. If you recently joined, an admin may still need to confirm your membership.",
|
|
8913
|
+
actionLabel: null,
|
|
8914
|
+
secondaryLabel: "Refresh"
|
|
8915
|
+
}
|
|
8916
|
+
};
|
|
8917
|
+
function StorageEmptyState({ variant, onAction, onSecondaryAction, className }) {
|
|
8918
|
+
const config = VARIANTS[variant];
|
|
8919
|
+
const Icon = config.icon;
|
|
8920
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8921
|
+
"div",
|
|
8922
|
+
{
|
|
8923
|
+
className: cn(
|
|
8924
|
+
"flex h-full w-full flex-col items-center justify-center gap-4 px-6 py-12 text-center",
|
|
8925
|
+
className
|
|
8926
|
+
),
|
|
8927
|
+
children: [
|
|
8928
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-6", "aria-hidden": true }) }),
|
|
8929
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex max-w-sm flex-col gap-1.5", children: [
|
|
8930
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-balance text-base font-semibold text-foreground", children: config.title }),
|
|
8931
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-pretty text-sm text-muted-foreground", children: config.description })
|
|
8932
|
+
] }),
|
|
8933
|
+
config.actionLabel && /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onAction, size: "sm", children: config.actionLabel }),
|
|
8934
|
+
variant === "no-access" && config.secondaryLabel && /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onSecondaryAction, size: "sm", variant: "outline", children: config.secondaryLabel })
|
|
8935
|
+
]
|
|
8936
|
+
}
|
|
8937
|
+
);
|
|
8938
|
+
}
|
|
8939
|
+
function StorageBrowser({
|
|
8940
|
+
buckets,
|
|
8941
|
+
selectedBucketId,
|
|
8942
|
+
onSelectBucket,
|
|
8943
|
+
onNewBucket,
|
|
8944
|
+
objects,
|
|
8945
|
+
selectedIds,
|
|
8946
|
+
onSelectionChange,
|
|
8947
|
+
sort,
|
|
8948
|
+
onSortChange,
|
|
8949
|
+
query,
|
|
8950
|
+
onQueryChange,
|
|
8951
|
+
segments,
|
|
8952
|
+
onNavigate,
|
|
8953
|
+
onOpenObject,
|
|
8954
|
+
onUpload,
|
|
8955
|
+
onBulkDelete,
|
|
8956
|
+
bulkDeleteProgress,
|
|
8957
|
+
onClearSelection,
|
|
8958
|
+
onDownload,
|
|
8959
|
+
onCopyLink,
|
|
8960
|
+
onRename,
|
|
8961
|
+
onDelete,
|
|
8962
|
+
isLoading,
|
|
8963
|
+
emptyLabel,
|
|
8964
|
+
emptyState,
|
|
8965
|
+
onEmptyStateAction,
|
|
8966
|
+
onEmptyStateSecondaryAction,
|
|
8967
|
+
className
|
|
8968
|
+
}) {
|
|
8969
|
+
const selectedBucket = buckets.find((bucket) => bucket.id === selectedBucketId) ?? null;
|
|
8970
|
+
const paneTakeover = emptyState === "no-buckets" || emptyState === "no-access" || emptyState === "not-provisioned";
|
|
8971
|
+
const showSelectBucketPrompt = !paneTakeover && !selectedBucket && buckets.length > 0;
|
|
8972
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex h-full min-h-0 overflow-hidden rounded-lg border bg-background", className), children: [
|
|
8973
|
+
/* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "flex w-64 shrink-0 flex-col border-r", children: [
|
|
8974
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-12 items-center px-3", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-sm font-semibold", children: "Buckets" }) }),
|
|
8975
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
|
|
8976
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8977
|
+
BucketRail,
|
|
8978
|
+
{
|
|
8979
|
+
buckets,
|
|
8980
|
+
selectedBucketId,
|
|
8981
|
+
onSelectBucket,
|
|
8982
|
+
onNewBucket,
|
|
8983
|
+
className: "min-h-0 flex-1"
|
|
8984
|
+
}
|
|
8985
|
+
)
|
|
8986
|
+
] }),
|
|
8987
|
+
/* @__PURE__ */ jsxRuntime.jsx("section", { className: "flex min-w-0 flex-1 flex-col", children: showSelectBucketPrompt ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col items-center justify-center px-6 py-12 text-center", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Select a bucket to view its files." }) }) : !selectedBucket || paneTakeover ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8988
|
+
StorageEmptyState,
|
|
8989
|
+
{
|
|
8990
|
+
variant: emptyState ?? "no-buckets",
|
|
8991
|
+
onAction: onEmptyStateAction ?? onNewBucket,
|
|
8992
|
+
onSecondaryAction: onEmptyStateSecondaryAction
|
|
8993
|
+
}
|
|
8994
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8995
|
+
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex min-h-12 items-center gap-2 px-4 py-2", children: [
|
|
8996
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "truncate text-sm font-semibold", children: bucketDisplayName(selectedBucket) }),
|
|
8997
|
+
/* @__PURE__ */ jsxRuntime.jsx(VisibilityBadge, { visibility: selectedBucket.visibility, size: "sm" }),
|
|
8998
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8999
|
+
ObjectToolbar,
|
|
9000
|
+
{
|
|
9001
|
+
query,
|
|
9002
|
+
onQueryChange,
|
|
9003
|
+
sort,
|
|
9004
|
+
onSortChange,
|
|
9005
|
+
onUpload,
|
|
9006
|
+
selectedCount: selectedIds.length,
|
|
9007
|
+
onBulkDelete: onBulkDelete ? () => onBulkDelete(selectedIds) : void 0,
|
|
9008
|
+
bulkDeleteProgress,
|
|
9009
|
+
onClearSelection
|
|
9010
|
+
}
|
|
9011
|
+
) })
|
|
9012
|
+
] }),
|
|
9013
|
+
(segments?.length ?? 0) > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9014
|
+
StorageBreadcrumb,
|
|
9015
|
+
{
|
|
9016
|
+
bucketKey: bucketDisplayName(selectedBucket),
|
|
9017
|
+
segments,
|
|
9018
|
+
onNavigate
|
|
9019
|
+
}
|
|
9020
|
+
) }),
|
|
9021
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
|
|
9022
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1 overflow-auto", children: emptyState === "empty-bucket" ? /* @__PURE__ */ jsxRuntime.jsx(StorageEmptyState, { variant: "empty-bucket", onAction: onEmptyStateAction ?? onUpload }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
9023
|
+
ObjectTable,
|
|
9024
|
+
{
|
|
9025
|
+
objects,
|
|
9026
|
+
selectedIds,
|
|
9027
|
+
onSelectionChange,
|
|
9028
|
+
sort,
|
|
9029
|
+
onSortChange,
|
|
9030
|
+
onOpenObject,
|
|
9031
|
+
onDownload,
|
|
9032
|
+
onCopyLink,
|
|
9033
|
+
onRename,
|
|
9034
|
+
onDelete,
|
|
9035
|
+
isLoading,
|
|
9036
|
+
emptyLabel
|
|
9037
|
+
}
|
|
9038
|
+
) })
|
|
9039
|
+
] }) })
|
|
9040
|
+
] });
|
|
9041
|
+
}
|
|
9042
|
+
|
|
7952
9043
|
exports.Alert = Alert;
|
|
7953
9044
|
exports.AlertDescription = AlertDescription;
|
|
7954
9045
|
exports.AlertDialog = AlertDialog;
|
|
@@ -7979,6 +9070,8 @@ exports.BreadcrumbLink = BreadcrumbLink;
|
|
|
7979
9070
|
exports.BreadcrumbList = BreadcrumbList;
|
|
7980
9071
|
exports.BreadcrumbPage = BreadcrumbPage;
|
|
7981
9072
|
exports.BreadcrumbSeparator = BreadcrumbSeparator;
|
|
9073
|
+
exports.BucketConfigSheet = BucketConfigSheet;
|
|
9074
|
+
exports.BucketRail = BucketRail;
|
|
7982
9075
|
exports.Button = Button;
|
|
7983
9076
|
exports.Calendar = Calendar;
|
|
7984
9077
|
exports.Card = Card;
|
|
@@ -8051,6 +9144,7 @@ exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
|
|
|
8051
9144
|
exports.DropdownMenuTrigger = DropdownMenuTrigger;
|
|
8052
9145
|
exports.Field = Field;
|
|
8053
9146
|
exports.FieldRow = FieldRow;
|
|
9147
|
+
exports.FileTypeIcon = FileTypeIcon;
|
|
8054
9148
|
exports.FlickeringGrid = FlickeringGrid;
|
|
8055
9149
|
exports.FlowZoomPanel = FlowZoomPanel;
|
|
8056
9150
|
exports.Form = Form;
|
|
@@ -8073,6 +9167,12 @@ exports.Label = Label;
|
|
|
8073
9167
|
exports.ModalPortalScope = ModalPortalScope;
|
|
8074
9168
|
exports.MotionGrid = MotionGrid;
|
|
8075
9169
|
exports.MultiSelect = MultiSelect;
|
|
9170
|
+
exports.OBJECT_TABLE_COLUMN_COUNT = COLUMN_COUNT;
|
|
9171
|
+
exports.ObjectDetailSheet = ObjectDetailSheet;
|
|
9172
|
+
exports.ObjectStatusBadge = ObjectStatusBadge;
|
|
9173
|
+
exports.ObjectTable = ObjectTable;
|
|
9174
|
+
exports.ObjectTableSkeleton = ObjectTableSkeleton;
|
|
9175
|
+
exports.ObjectToolbar = ObjectToolbar;
|
|
8076
9176
|
exports.OrgChart = OrgChart;
|
|
8077
9177
|
exports.PORTAL_ROOT_ID = PORTAL_ROOT_ID;
|
|
8078
9178
|
exports.PageHeader = PageHeader;
|
|
@@ -8159,6 +9259,9 @@ exports.StepperItem = StepperItem;
|
|
|
8159
9259
|
exports.StepperSeparator = StepperSeparator;
|
|
8160
9260
|
exports.StepperTitle = StepperTitle;
|
|
8161
9261
|
exports.StepperTrigger = StepperTrigger;
|
|
9262
|
+
exports.StorageBreadcrumb = StorageBreadcrumb;
|
|
9263
|
+
exports.StorageBrowser = StorageBrowser;
|
|
9264
|
+
exports.StorageEmptyState = StorageEmptyState;
|
|
8162
9265
|
exports.Switch = Switch;
|
|
8163
9266
|
exports.Table = Table;
|
|
8164
9267
|
exports.TableBody = TableBody;
|
|
@@ -8188,9 +9291,13 @@ exports.TooltipContent = TooltipContent;
|
|
|
8188
9291
|
exports.TooltipProvider = TooltipProvider;
|
|
8189
9292
|
exports.TooltipTrigger = TooltipTrigger;
|
|
8190
9293
|
exports.UnlinkButton = UnlinkButton;
|
|
9294
|
+
exports.UploadDropzone = UploadDropzone;
|
|
9295
|
+
exports.UploadProgressList = UploadProgressList;
|
|
9296
|
+
exports.VisibilityBadge = VisibilityBadge;
|
|
8191
9297
|
exports.alertVariants = alertVariants;
|
|
8192
9298
|
exports.backdropVariants = backdropVariants;
|
|
8193
9299
|
exports.badgeVariants = badgeVariants;
|
|
9300
|
+
exports.bucketDisplayName = bucketDisplayName;
|
|
8194
9301
|
exports.buttonVariants = buttonVariants;
|
|
8195
9302
|
exports.calculateResponsiveOffset = calculateResponsiveOffset;
|
|
8196
9303
|
exports.cardVariants = cardVariants;
|
|
@@ -8202,20 +9309,25 @@ exports.createReducedMotionVariants = createReducedMotionVariants;
|
|
|
8202
9309
|
exports.dockVariants = dockVariants;
|
|
8203
9310
|
exports.durations = durations;
|
|
8204
9311
|
exports.easings = easings;
|
|
9312
|
+
exports.formatDate = formatDate;
|
|
9313
|
+
exports.formatDateTime = formatDateTime;
|
|
8205
9314
|
exports.getCardOffset = getCardOffset;
|
|
8206
9315
|
exports.getCardZIndex = getCardZIndex;
|
|
8207
9316
|
exports.getCascadeOffset = getCascadeOffset;
|
|
8208
9317
|
exports.getResponsiveCardOffset = getResponsiveCardOffset;
|
|
8209
9318
|
exports.getSideBySideOffset = getSideBySideOffset;
|
|
8210
9319
|
exports.getVisibleCardIndices = getVisibleCardIndices;
|
|
9320
|
+
exports.humanizeBytes = humanizeBytes;
|
|
8211
9321
|
exports.isCardVisible = isCardVisible;
|
|
8212
9322
|
exports.mergeProps = mergeProps;
|
|
8213
9323
|
exports.normalizeWidth = normalizeWidth;
|
|
9324
|
+
exports.objectDisplayName = objectDisplayName;
|
|
8214
9325
|
exports.parseWidthToPixels = parseWidthToPixels;
|
|
8215
9326
|
exports.peekDragSpring = peekDragSpring;
|
|
8216
9327
|
exports.peekHoverSpring = peekHoverSpring;
|
|
8217
9328
|
exports.peekSlideSpring = peekSlideSpring;
|
|
8218
9329
|
exports.reducedMotionBackdropVariants = reducedMotionBackdropVariants;
|
|
9330
|
+
exports.shortMimeLabel = shortMimeLabel;
|
|
8219
9331
|
exports.showErrorToast = showErrorToast;
|
|
8220
9332
|
exports.showInfoToast = showInfoToast;
|
|
8221
9333
|
exports.showSuccessToast = showSuccessToast;
|