@yuhuanowo/yunui 0.2.15 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/adapters.js +1 -1
- package/dist/ai.js +13 -9
- package/dist/ai.js.map +1 -1
- package/dist/chat.d.ts +133 -0
- package/dist/chat.js +268 -0
- package/dist/chat.js.map +1 -0
- package/dist/{chunk-U2LNRVMI.js → chunk-3RT24MSH.js} +4 -3
- package/dist/chunk-3RT24MSH.js.map +1 -0
- package/dist/chunk-5E3O6ANF.js +1154 -0
- package/dist/chunk-5E3O6ANF.js.map +1 -0
- package/dist/{chunk-6MZN3GOP.js → chunk-5TOGZTAO.js} +218 -835
- package/dist/chunk-5TOGZTAO.js.map +1 -0
- package/dist/chunk-AV5TGEJS.js +54 -0
- package/dist/chunk-AV5TGEJS.js.map +1 -0
- package/dist/{chunk-LLNTUA5K.js → chunk-GSPJ5YI6.js} +15 -56
- package/dist/chunk-GSPJ5YI6.js.map +1 -0
- package/dist/chunk-QEIBYOG2.js +188 -0
- package/dist/chunk-QEIBYOG2.js.map +1 -0
- package/dist/{chunk-N53PNMPJ.js → chunk-UYYG4XDW.js} +3 -3
- package/dist/{chunk-N53PNMPJ.js.map → chunk-UYYG4XDW.js.map} +1 -1
- package/dist/content.d.ts +144 -0
- package/dist/content.js +890 -0
- package/dist/content.js.map +1 -0
- package/dist/index.d.ts +183 -5
- package/dist/index.js +5 -3
- package/dist/patterns.d.ts +87 -1
- package/dist/patterns.js +446 -8
- package/dist/patterns.js.map +1 -1
- package/package.json +77 -5
- package/styles/content.css +129 -0
- package/styles/yunui.css +24 -4
- package/dist/chunk-6MZN3GOP.js.map +0 -1
- package/dist/chunk-LLNTUA5K.js.map +0 -1
- package/dist/chunk-U2LNRVMI.js.map +0 -1
package/dist/patterns.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { copyToClipboard } from './chunk-
|
|
4
|
-
export { Footer } from './chunk-
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
2
|
+
import './chunk-5E3O6ANF.js';
|
|
3
|
+
import { copyToClipboard } from './chunk-UYYG4XDW.js';
|
|
4
|
+
export { Footer } from './chunk-UYYG4XDW.js';
|
|
5
|
+
import './chunk-GSPJ5YI6.js';
|
|
6
|
+
import { ImageLightbox } from './chunk-QEIBYOG2.js';
|
|
7
|
+
import { Button, Card, Badge, Avatar, AvatarImage, AvatarFallback, IconButton, Spinner } from './chunk-5TOGZTAO.js';
|
|
8
|
+
import { cn } from './chunk-AV5TGEJS.js';
|
|
9
|
+
import { useYunUI } from './chunk-3RT24MSH.js';
|
|
7
10
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
9
|
-
import { AlertCircle, RefreshCw, Check, Copy, Plus, FileText, ExternalLink, Calendar, Clock, User, ChevronLeft, ChevronRight, PanelLeftClose, X, ArrowUpRight, ArrowDownRight, GraduationCap, ArrowRight, Award, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Brain, Eye, Code, MessageSquare, XCircle, Zap, CheckCircle, FileCode, EyeOff, Sparkles, Globe, Loader2, LogOut, Bell, Trash2, Camera, Info, CheckCircle2, AlertTriangle } from 'lucide-react';
|
|
11
|
+
import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|
12
|
+
import { AlertCircle, RefreshCw, Check, Copy, Plus, FileText, ExternalLink, Calendar, Clock, User, ChevronLeft, ChevronRight, PanelLeftClose, X, ArrowUpRight, ArrowDownRight, GraduationCap, ArrowRight, Award, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Brain, Eye, Code, MessageSquare, XCircle, Zap, CheckCircle, FileCode, EyeOff, Sparkles, Globe, Loader2, LogOut, Pause, Play, Download, Grid, List, Bell, Trash2, Camera, Info, CheckCircle2, AlertTriangle } from 'lucide-react';
|
|
10
13
|
|
|
11
14
|
function BackgroundEffects() {
|
|
12
15
|
return /* @__PURE__ */ jsx("div", { className: "absolute inset-0 -z-10 h-full w-full pointer-events-none select-none overflow-hidden bg-(--bg-base)", children: /* @__PURE__ */ jsx(
|
|
@@ -1158,6 +1161,441 @@ function MetricBar({ icon, label, value, percentage, color, className }) {
|
|
|
1158
1161
|
] })
|
|
1159
1162
|
] });
|
|
1160
1163
|
}
|
|
1164
|
+
var fmtTime = (s) => {
|
|
1165
|
+
if (!Number.isFinite(s) || s < 0) return "0:00";
|
|
1166
|
+
const m = Math.floor(s / 60);
|
|
1167
|
+
const sec = Math.floor(s % 60);
|
|
1168
|
+
return `${m}:${sec.toString().padStart(2, "0")}`;
|
|
1169
|
+
};
|
|
1170
|
+
function AudioPlayer({ src, title, downloadName, autoPlay = false, labels, className }) {
|
|
1171
|
+
const audioRef = useRef(null);
|
|
1172
|
+
const [playing, setPlaying] = useState(false);
|
|
1173
|
+
const [current, setCurrent] = useState(0);
|
|
1174
|
+
const [duration, setDuration] = useState(0);
|
|
1175
|
+
useEffect(() => {
|
|
1176
|
+
setPlaying(false);
|
|
1177
|
+
setCurrent(0);
|
|
1178
|
+
setDuration(0);
|
|
1179
|
+
}, [src]);
|
|
1180
|
+
const toggle = () => {
|
|
1181
|
+
const el = audioRef.current;
|
|
1182
|
+
if (!el) return;
|
|
1183
|
+
if (el.paused) {
|
|
1184
|
+
void el.play();
|
|
1185
|
+
} else {
|
|
1186
|
+
el.pause();
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
const seek = (e) => {
|
|
1190
|
+
const el = audioRef.current;
|
|
1191
|
+
if (!el) return;
|
|
1192
|
+
const t = Number(e.target.value);
|
|
1193
|
+
el.currentTime = t;
|
|
1194
|
+
setCurrent(t);
|
|
1195
|
+
};
|
|
1196
|
+
const pct = duration > 0 ? current / duration * 100 : 0;
|
|
1197
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2 rounded-xl border border-border bg-card p-3", className), children: [
|
|
1198
|
+
title && /* @__PURE__ */ jsx("div", { className: "truncate text-sm font-medium", children: title }),
|
|
1199
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1200
|
+
/* @__PURE__ */ jsx(
|
|
1201
|
+
"button",
|
|
1202
|
+
{
|
|
1203
|
+
type: "button",
|
|
1204
|
+
onClick: toggle,
|
|
1205
|
+
"aria-label": playing ? labels?.pause ?? "Pause" : labels?.play ?? "Play",
|
|
1206
|
+
className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent text-accent-foreground transition-opacity hover:opacity-90",
|
|
1207
|
+
children: playing ? /* @__PURE__ */ jsx(Pause, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Play, { className: "h-4 w-4 translate-x-px" })
|
|
1208
|
+
}
|
|
1209
|
+
),
|
|
1210
|
+
/* @__PURE__ */ jsx(
|
|
1211
|
+
"input",
|
|
1212
|
+
{
|
|
1213
|
+
type: "range",
|
|
1214
|
+
min: 0,
|
|
1215
|
+
max: duration || 0,
|
|
1216
|
+
step: "any",
|
|
1217
|
+
value: current,
|
|
1218
|
+
onChange: seek,
|
|
1219
|
+
"aria-label": labels?.seek ?? "Seek",
|
|
1220
|
+
className: "h-1.5 flex-1 cursor-pointer appearance-none rounded-full bg-muted accent-[var(--color-accent)]",
|
|
1221
|
+
style: {
|
|
1222
|
+
background: `linear-gradient(to right, var(--color-accent) ${pct}%, var(--color-muted) ${pct}%)`
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
),
|
|
1226
|
+
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: [
|
|
1227
|
+
fmtTime(current),
|
|
1228
|
+
" / ",
|
|
1229
|
+
fmtTime(duration)
|
|
1230
|
+
] }),
|
|
1231
|
+
downloadName && /* @__PURE__ */ jsx(
|
|
1232
|
+
"a",
|
|
1233
|
+
{
|
|
1234
|
+
href: src,
|
|
1235
|
+
download: downloadName,
|
|
1236
|
+
"aria-label": labels?.download ?? "Download audio",
|
|
1237
|
+
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
1238
|
+
children: /* @__PURE__ */ jsx(Download, { className: "h-4 w-4" })
|
|
1239
|
+
}
|
|
1240
|
+
)
|
|
1241
|
+
] }),
|
|
1242
|
+
/* @__PURE__ */ jsx(
|
|
1243
|
+
"audio",
|
|
1244
|
+
{
|
|
1245
|
+
ref: audioRef,
|
|
1246
|
+
src,
|
|
1247
|
+
autoPlay,
|
|
1248
|
+
onPlay: () => setPlaying(true),
|
|
1249
|
+
onPause: () => setPlaying(false),
|
|
1250
|
+
onTimeUpdate: (e) => setCurrent(e.currentTarget.currentTime),
|
|
1251
|
+
onLoadedMetadata: (e) => setDuration(e.currentTarget.duration),
|
|
1252
|
+
onEnded: () => setPlaying(false),
|
|
1253
|
+
className: "hidden"
|
|
1254
|
+
}
|
|
1255
|
+
)
|
|
1256
|
+
] });
|
|
1257
|
+
}
|
|
1258
|
+
var DEFAULT_LABELS = {
|
|
1259
|
+
starting: "Starting\u2026",
|
|
1260
|
+
processing: "Processing\u2026",
|
|
1261
|
+
failed: "Generation failed",
|
|
1262
|
+
expired: "Media expired",
|
|
1263
|
+
download: "Download",
|
|
1264
|
+
delete: "Delete",
|
|
1265
|
+
gridView: "Grid view",
|
|
1266
|
+
listView: "List view"
|
|
1267
|
+
};
|
|
1268
|
+
function isUrlExpired(url) {
|
|
1269
|
+
try {
|
|
1270
|
+
const expires = new URL(url).searchParams.get("Expires");
|
|
1271
|
+
if (expires) {
|
|
1272
|
+
const ts = parseInt(expires, 10);
|
|
1273
|
+
return Date.now() / 1e3 > ts - 60;
|
|
1274
|
+
}
|
|
1275
|
+
} catch {
|
|
1276
|
+
return true;
|
|
1277
|
+
}
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1280
|
+
function MediaBody({
|
|
1281
|
+
item,
|
|
1282
|
+
labels
|
|
1283
|
+
}) {
|
|
1284
|
+
const [loading, setLoading] = useState(true);
|
|
1285
|
+
const [loadFailed, setLoadFailed] = useState(false);
|
|
1286
|
+
const kind = item.kind ?? "image";
|
|
1287
|
+
const status = item.status ?? "completed";
|
|
1288
|
+
const isExpired = useMemo(() => {
|
|
1289
|
+
if (!item.url || item.url.startsWith("data:") || item.url.startsWith("blob:")) return false;
|
|
1290
|
+
return isUrlExpired(item.url);
|
|
1291
|
+
}, [item.url]);
|
|
1292
|
+
const isProcessing = status === "pending" || status === "processing";
|
|
1293
|
+
const showError = isExpired || loadFailed || status === "failed";
|
|
1294
|
+
if (isProcessing) {
|
|
1295
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center gap-2 bg-muted", children: [
|
|
1296
|
+
/* @__PURE__ */ jsx(Spinner, { size: "lg" }),
|
|
1297
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: status === "pending" ? labels.starting : labels.processing }),
|
|
1298
|
+
item.progress !== void 0 && item.progress > 0 && /* @__PURE__ */ jsx("div", { className: "mt-1 h-1.5 w-24 overflow-hidden rounded-full bg-muted-foreground/20", children: /* @__PURE__ */ jsx(
|
|
1299
|
+
"div",
|
|
1300
|
+
{
|
|
1301
|
+
className: "h-full bg-primary transition-all duration-300",
|
|
1302
|
+
style: { width: `${Math.min(item.progress, 95)}%` }
|
|
1303
|
+
}
|
|
1304
|
+
) })
|
|
1305
|
+
] });
|
|
1306
|
+
}
|
|
1307
|
+
if (showError) {
|
|
1308
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center gap-1 bg-muted px-3 text-center", children: [
|
|
1309
|
+
/* @__PURE__ */ jsx(AlertCircle, { size: 22, className: "text-error" }),
|
|
1310
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-error", children: status === "failed" ? labels.failed : labels.expired }),
|
|
1311
|
+
item.error && /* @__PURE__ */ jsx("span", { className: "mt-0.5 max-w-[85%] truncate text-xs text-error/70", children: item.error })
|
|
1312
|
+
] });
|
|
1313
|
+
}
|
|
1314
|
+
if (kind === "audio") {
|
|
1315
|
+
return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center bg-muted/40 px-3", children: /* @__PURE__ */ jsx(AudioPlayer, { src: item.url, className: "w-full" }) });
|
|
1316
|
+
}
|
|
1317
|
+
if (kind === "video") {
|
|
1318
|
+
return (
|
|
1319
|
+
// eslint-disable-next-line jsx-a11y/media-has-caption
|
|
1320
|
+
/* @__PURE__ */ jsx(
|
|
1321
|
+
"video",
|
|
1322
|
+
{
|
|
1323
|
+
src: item.url,
|
|
1324
|
+
controls: true,
|
|
1325
|
+
className: "h-full w-full bg-black object-contain",
|
|
1326
|
+
onLoadedData: () => setLoading(false),
|
|
1327
|
+
onError: () => {
|
|
1328
|
+
setLoading(false);
|
|
1329
|
+
setLoadFailed(true);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
)
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1335
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1336
|
+
loading && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 animate-pulse bg-muted" }),
|
|
1337
|
+
/* @__PURE__ */ jsx(
|
|
1338
|
+
"img",
|
|
1339
|
+
{
|
|
1340
|
+
src: item.url,
|
|
1341
|
+
alt: typeof item.prompt === "string" ? item.prompt : "",
|
|
1342
|
+
className: cn("h-full w-full object-cover", loading && "opacity-0"),
|
|
1343
|
+
onLoad: () => setLoading(false),
|
|
1344
|
+
onError: () => {
|
|
1345
|
+
setLoading(false);
|
|
1346
|
+
setLoadFailed(true);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
)
|
|
1350
|
+
] });
|
|
1351
|
+
}
|
|
1352
|
+
function MediaCard({
|
|
1353
|
+
item,
|
|
1354
|
+
index,
|
|
1355
|
+
view,
|
|
1356
|
+
onDownload,
|
|
1357
|
+
onDelete,
|
|
1358
|
+
onPreview,
|
|
1359
|
+
labels
|
|
1360
|
+
}) {
|
|
1361
|
+
const status = item.status ?? "completed";
|
|
1362
|
+
const kind = item.kind ?? "image";
|
|
1363
|
+
const isProcessing = status === "pending" || status === "processing";
|
|
1364
|
+
const isDone = status === "completed";
|
|
1365
|
+
const canPreview = Boolean(onPreview) && isDone && kind === "image";
|
|
1366
|
+
const modelShort = item.model?.split("/").pop();
|
|
1367
|
+
const caption = /* @__PURE__ */ jsxs("div", { className: cn(view === "list" ? "min-w-0 flex-1" : "p-3"), children: [
|
|
1368
|
+
item.prompt !== void 0 && /* @__PURE__ */ jsx("div", { className: "line-clamp-2 text-sm", children: item.prompt }),
|
|
1369
|
+
(modelShort || item.meta) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
1370
|
+
modelShort && /* @__PURE__ */ jsx("span", { className: "truncate", children: modelShort }),
|
|
1371
|
+
modelShort && item.meta && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "\u2022" }),
|
|
1372
|
+
item.meta
|
|
1373
|
+
] })
|
|
1374
|
+
] });
|
|
1375
|
+
const overlayBtn = "flex h-9 w-9 items-center justify-center rounded-full bg-card text-foreground shadow-md ring-1 ring-border backdrop-blur transition hover:scale-105 disabled:pointer-events-none disabled:opacity-40";
|
|
1376
|
+
const actions = (onDownload || onDelete) && (view === "grid" ? /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex items-center justify-center gap-2.5 bg-foreground/0 opacity-0 transition-all group-hover:bg-foreground/30 group-hover:opacity-100", children: [
|
|
1377
|
+
onDownload && /* @__PURE__ */ jsx(
|
|
1378
|
+
"button",
|
|
1379
|
+
{
|
|
1380
|
+
type: "button",
|
|
1381
|
+
className: overlayBtn,
|
|
1382
|
+
disabled: !isDone,
|
|
1383
|
+
"aria-label": labels.download,
|
|
1384
|
+
onClick: (e) => {
|
|
1385
|
+
e.stopPropagation();
|
|
1386
|
+
onDownload(item);
|
|
1387
|
+
},
|
|
1388
|
+
children: /* @__PURE__ */ jsx(Download, { size: 18 })
|
|
1389
|
+
}
|
|
1390
|
+
),
|
|
1391
|
+
onDelete && /* @__PURE__ */ jsx(
|
|
1392
|
+
"button",
|
|
1393
|
+
{
|
|
1394
|
+
type: "button",
|
|
1395
|
+
className: cn(overlayBtn, "text-error"),
|
|
1396
|
+
"aria-label": labels.delete,
|
|
1397
|
+
onClick: (e) => {
|
|
1398
|
+
e.stopPropagation();
|
|
1399
|
+
onDelete(item);
|
|
1400
|
+
},
|
|
1401
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 18 })
|
|
1402
|
+
}
|
|
1403
|
+
)
|
|
1404
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
1405
|
+
onDownload && /* @__PURE__ */ jsx(
|
|
1406
|
+
Button,
|
|
1407
|
+
{
|
|
1408
|
+
size: "icon",
|
|
1409
|
+
variant: "ghost",
|
|
1410
|
+
disabled: !isDone,
|
|
1411
|
+
"aria-label": labels.download,
|
|
1412
|
+
onClick: (e) => {
|
|
1413
|
+
e.stopPropagation();
|
|
1414
|
+
onDownload(item);
|
|
1415
|
+
},
|
|
1416
|
+
children: /* @__PURE__ */ jsx(Download, { size: 16 })
|
|
1417
|
+
}
|
|
1418
|
+
),
|
|
1419
|
+
onDelete && /* @__PURE__ */ jsx(
|
|
1420
|
+
Button,
|
|
1421
|
+
{
|
|
1422
|
+
size: "icon",
|
|
1423
|
+
variant: "ghost",
|
|
1424
|
+
"aria-label": labels.delete,
|
|
1425
|
+
onClick: (e) => {
|
|
1426
|
+
e.stopPropagation();
|
|
1427
|
+
onDelete(item);
|
|
1428
|
+
},
|
|
1429
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 16, className: "text-error" })
|
|
1430
|
+
}
|
|
1431
|
+
)
|
|
1432
|
+
] }));
|
|
1433
|
+
if (kind === "audio") {
|
|
1434
|
+
const showError = status === "failed";
|
|
1435
|
+
return /* @__PURE__ */ jsxs("div", { className: "card space-y-2.5 p-3", children: [
|
|
1436
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
1437
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1438
|
+
item.prompt !== void 0 && /* @__PURE__ */ jsx("div", { className: "line-clamp-2 text-sm", children: item.prompt }),
|
|
1439
|
+
(modelShort || item.meta) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
1440
|
+
modelShort && /* @__PURE__ */ jsx("span", { className: "truncate", children: modelShort }),
|
|
1441
|
+
modelShort && item.meta && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "\u2022" }),
|
|
1442
|
+
item.meta
|
|
1443
|
+
] })
|
|
1444
|
+
] }),
|
|
1445
|
+
(onDownload || onDelete) && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
1446
|
+
onDownload && /* @__PURE__ */ jsx(
|
|
1447
|
+
Button,
|
|
1448
|
+
{
|
|
1449
|
+
size: "icon",
|
|
1450
|
+
variant: "ghost",
|
|
1451
|
+
disabled: !isDone,
|
|
1452
|
+
"aria-label": labels.download,
|
|
1453
|
+
onClick: () => onDownload(item),
|
|
1454
|
+
children: /* @__PURE__ */ jsx(Download, { size: 16 })
|
|
1455
|
+
}
|
|
1456
|
+
),
|
|
1457
|
+
onDelete && /* @__PURE__ */ jsx(
|
|
1458
|
+
Button,
|
|
1459
|
+
{
|
|
1460
|
+
size: "icon",
|
|
1461
|
+
variant: "ghost",
|
|
1462
|
+
"aria-label": labels.delete,
|
|
1463
|
+
onClick: () => onDelete(item),
|
|
1464
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 16, className: "text-error" })
|
|
1465
|
+
}
|
|
1466
|
+
)
|
|
1467
|
+
] })
|
|
1468
|
+
] }),
|
|
1469
|
+
isProcessing ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 py-2 text-xs text-muted-foreground", children: [
|
|
1470
|
+
/* @__PURE__ */ jsx(Spinner, { size: "sm" }),
|
|
1471
|
+
" ",
|
|
1472
|
+
status === "pending" ? labels.starting : labels.processing
|
|
1473
|
+
] }) : showError ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 py-2 text-xs text-error", children: [
|
|
1474
|
+
/* @__PURE__ */ jsx(AlertCircle, { size: 14 }),
|
|
1475
|
+
" ",
|
|
1476
|
+
labels.failed,
|
|
1477
|
+
item.error ? `: ${item.error}` : ""
|
|
1478
|
+
] }) : /* @__PURE__ */ jsx(AudioPlayer, { src: item.url, className: "w-full" })
|
|
1479
|
+
] });
|
|
1480
|
+
}
|
|
1481
|
+
if (view === "list") {
|
|
1482
|
+
return /* @__PURE__ */ jsxs("div", { className: "card flex items-center gap-3 p-3", children: [
|
|
1483
|
+
/* @__PURE__ */ jsx("div", { className: "relative h-16 w-16 shrink-0 overflow-hidden rounded-md bg-muted", children: /* @__PURE__ */ jsx(MediaBody, { item, labels }) }),
|
|
1484
|
+
caption,
|
|
1485
|
+
actions
|
|
1486
|
+
] });
|
|
1487
|
+
}
|
|
1488
|
+
return /* @__PURE__ */ jsxs(
|
|
1489
|
+
"div",
|
|
1490
|
+
{
|
|
1491
|
+
className: cn(
|
|
1492
|
+
"card group animate-enter overflow-hidden",
|
|
1493
|
+
canPreview && "cursor-pointer"
|
|
1494
|
+
),
|
|
1495
|
+
style: { animationDelay: `${Math.min(index, 10) * 50}ms` },
|
|
1496
|
+
onClick: () => canPreview && onPreview?.(item),
|
|
1497
|
+
children: [
|
|
1498
|
+
/* @__PURE__ */ jsxs("div", { className: "relative aspect-square", children: [
|
|
1499
|
+
/* @__PURE__ */ jsx(MediaBody, { item, labels }),
|
|
1500
|
+
!isProcessing && actions
|
|
1501
|
+
] }),
|
|
1502
|
+
caption
|
|
1503
|
+
]
|
|
1504
|
+
}
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
function MediaGallery({
|
|
1508
|
+
items,
|
|
1509
|
+
viewMode,
|
|
1510
|
+
onViewModeChange,
|
|
1511
|
+
onDownload,
|
|
1512
|
+
onDelete,
|
|
1513
|
+
onPreview,
|
|
1514
|
+
title,
|
|
1515
|
+
empty,
|
|
1516
|
+
labels,
|
|
1517
|
+
className
|
|
1518
|
+
}) {
|
|
1519
|
+
const [internalView, setInternalView] = useState("grid");
|
|
1520
|
+
const view = viewMode ?? internalView;
|
|
1521
|
+
const setView = onViewModeChange ?? setInternalView;
|
|
1522
|
+
const showToggle = Boolean(onViewModeChange) || items.length > 0;
|
|
1523
|
+
const l = { ...DEFAULT_LABELS, ...labels };
|
|
1524
|
+
const [lightbox, setLightbox] = useState(null);
|
|
1525
|
+
const handlePreview = (item) => {
|
|
1526
|
+
if (onPreview) onPreview(item);
|
|
1527
|
+
else setLightbox(item);
|
|
1528
|
+
};
|
|
1529
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
1530
|
+
/* @__PURE__ */ jsx(
|
|
1531
|
+
ImageLightbox,
|
|
1532
|
+
{
|
|
1533
|
+
src: lightbox?.url,
|
|
1534
|
+
alt: typeof lightbox?.prompt === "string" ? lightbox.prompt : "",
|
|
1535
|
+
isOpen: lightbox !== null,
|
|
1536
|
+
onClose: () => setLightbox(null)
|
|
1537
|
+
}
|
|
1538
|
+
),
|
|
1539
|
+
(title || showToggle) && /* @__PURE__ */ jsxs("div", { className: "mb-4 flex items-center justify-between gap-3", children: [
|
|
1540
|
+
title ? /* @__PURE__ */ jsx("h2", { className: "heading-md", children: title }) : /* @__PURE__ */ jsx("span", {}),
|
|
1541
|
+
showToggle && /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
1542
|
+
/* @__PURE__ */ jsx(
|
|
1543
|
+
"button",
|
|
1544
|
+
{
|
|
1545
|
+
type: "button",
|
|
1546
|
+
onClick: () => setView("grid"),
|
|
1547
|
+
"aria-label": l.gridView,
|
|
1548
|
+
"aria-pressed": view === "grid",
|
|
1549
|
+
className: cn(
|
|
1550
|
+
"rounded-lg p-2 transition-colors",
|
|
1551
|
+
view === "grid" ? "bg-muted" : "hover:bg-muted/50"
|
|
1552
|
+
),
|
|
1553
|
+
children: /* @__PURE__ */ jsx(Grid, { size: 16 })
|
|
1554
|
+
}
|
|
1555
|
+
),
|
|
1556
|
+
/* @__PURE__ */ jsx(
|
|
1557
|
+
"button",
|
|
1558
|
+
{
|
|
1559
|
+
type: "button",
|
|
1560
|
+
onClick: () => setView("list"),
|
|
1561
|
+
"aria-label": l.listView,
|
|
1562
|
+
"aria-pressed": view === "list",
|
|
1563
|
+
className: cn(
|
|
1564
|
+
"rounded-lg p-2 transition-colors",
|
|
1565
|
+
view === "list" ? "bg-muted" : "hover:bg-muted/50"
|
|
1566
|
+
),
|
|
1567
|
+
children: /* @__PURE__ */ jsx(List, { size: 16 })
|
|
1568
|
+
}
|
|
1569
|
+
)
|
|
1570
|
+
] })
|
|
1571
|
+
] }),
|
|
1572
|
+
items.length === 0 ? empty ?? null : view === "grid" ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4", children: items.map((item, i) => /* @__PURE__ */ jsx(
|
|
1573
|
+
MediaCard,
|
|
1574
|
+
{
|
|
1575
|
+
item,
|
|
1576
|
+
index: i,
|
|
1577
|
+
view: "grid",
|
|
1578
|
+
onDownload,
|
|
1579
|
+
onDelete,
|
|
1580
|
+
onPreview: handlePreview,
|
|
1581
|
+
labels: l
|
|
1582
|
+
},
|
|
1583
|
+
item.id
|
|
1584
|
+
)) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: items.map((item, i) => /* @__PURE__ */ jsx(
|
|
1585
|
+
MediaCard,
|
|
1586
|
+
{
|
|
1587
|
+
item,
|
|
1588
|
+
index: i,
|
|
1589
|
+
view: "list",
|
|
1590
|
+
onDownload,
|
|
1591
|
+
onDelete,
|
|
1592
|
+
onPreview: handlePreview,
|
|
1593
|
+
labels: l
|
|
1594
|
+
},
|
|
1595
|
+
item.id
|
|
1596
|
+
)) })
|
|
1597
|
+
] });
|
|
1598
|
+
}
|
|
1161
1599
|
var TONES2 = {
|
|
1162
1600
|
info: {
|
|
1163
1601
|
bg: "bg-linear-to-r from-blue-500/10 via-blue-500/5 to-blue-500/10",
|
|
@@ -1453,6 +1891,6 @@ function AvatarUploader({
|
|
|
1453
1891
|
);
|
|
1454
1892
|
}
|
|
1455
1893
|
|
|
1456
|
-
export { AccountLockedCard, ActiveBadge, AvatarUploader, BackgroundEffects, Banner, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, DeprecatedBadge, ErrorBoundary, FAQ, FeatureLockedState, FellowBadge, FellowsBanner, LLMCopyButton, LinkRow, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, NotificationBell, NotificationItem, NotificationPanel, PageEmptyState, PageErrorState, PageHeader, PageLayout, PageLoadingState, SessionItem, SettingRow, Sidebar, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
|
|
1894
|
+
export { AccountLockedCard, ActiveBadge, AudioPlayer, AvatarUploader, BackgroundEffects, Banner, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, DeprecatedBadge, ErrorBoundary, FAQ, FeatureLockedState, FellowBadge, FellowsBanner, LLMCopyButton, LinkRow, MediaEmptyState, MediaErrorState, MediaGallery, MediaLoadingState, MediaPageHeader, MetricBar, NotificationBell, NotificationItem, NotificationPanel, PageEmptyState, PageErrorState, PageHeader, PageLayout, PageLoadingState, SessionItem, SettingRow, Sidebar, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
|
|
1457
1895
|
//# sourceMappingURL=patterns.js.map
|
|
1458
1896
|
//# sourceMappingURL=patterns.js.map
|