@proveanything/smartlinks-utils-ui 1.13.1 → 1.13.2
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/{chunk-HKL24TFC.js → chunk-AWWWHHLL.js} +261 -103
- package/dist/chunk-AWWWHHLL.js.map +1 -0
- package/dist/components/AssetPicker/index.css +2 -16
- package/dist/components/AssetPicker/index.css.map +1 -1
- package/dist/components/AssetPicker/index.d.ts +1 -1
- package/dist/components/AssetPicker/index.js +1 -1
- package/dist/components/ConditionsEditor/index.css +2 -16
- package/dist/components/ConditionsEditor/index.css.map +1 -1
- package/dist/components/FontPicker/index.css +2 -16
- package/dist/components/FontPicker/index.css.map +1 -1
- package/dist/components/IconPicker/index.css +2 -16
- package/dist/components/IconPicker/index.css.map +1 -1
- package/dist/components/LinkPicker/index.css +2 -16
- package/dist/components/LinkPicker/index.css.map +1 -1
- package/dist/components/RecordsAdmin/index.css +2 -16
- package/dist/components/RecordsAdmin/index.css.map +1 -1
- package/dist/index.css +2 -16
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{useAssets-tRkW00zx.d.ts → useAssets-Cs0OJs-x.d.ts} +6 -2
- package/package.json +1 -1
- package/dist/chunk-HKL24TFC.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { assertStylesLoaded } from './chunk-OLYC54YT.js';
|
|
2
2
|
import { cn } from './chunk-L7FQ52F5.js';
|
|
3
|
-
import React7, { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
3
|
+
import React7, { useState, useRef, useEffect, useCallback, useMemo, useLayoutEffect } from 'react';
|
|
4
4
|
import * as SL from '@proveanything/smartlinks';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
5
6
|
import { Filter, Search, LayoutGrid, List, X, Loader2, AlertCircle, Tag, ImageOff, Wand2, Maximize2, Clipboard, Pencil, Check, Upload, Link, MicOff, Mic, ChevronDown, ChevronRight, Sparkles, Image as Image$1, Plus, FileIcon, Film, Music, FileText, AppWindow, MoreVertical, Trash2 } from 'lucide-react';
|
|
6
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
8
|
|
|
@@ -55,13 +56,13 @@ function useAssets({ scope, accept, pageSize, appId, listAppId }) {
|
|
|
55
56
|
useEffect(() => {
|
|
56
57
|
fetchAssets();
|
|
57
58
|
}, [fetchAssets]);
|
|
58
|
-
const upload = useCallback(async (file, onProgress) => {
|
|
59
|
+
const upload = useCallback(async (file, onProgress, scopeOverride) => {
|
|
59
60
|
setUploading(true);
|
|
60
61
|
setUploadProgress(0);
|
|
61
62
|
try {
|
|
62
63
|
const result = await SL.asset.upload({
|
|
63
64
|
file,
|
|
64
|
-
scope,
|
|
65
|
+
scope: scopeOverride || scope,
|
|
65
66
|
name: file.name,
|
|
66
67
|
admin: true,
|
|
67
68
|
...appId ? { appId } : {},
|
|
@@ -70,7 +71,7 @@ function useAssets({ scope, accept, pageSize, appId, listAppId }) {
|
|
|
70
71
|
onProgress?.(pct);
|
|
71
72
|
}
|
|
72
73
|
});
|
|
73
|
-
if (mountedRef.current) {
|
|
74
|
+
if (mountedRef.current && !scopeOverride) {
|
|
74
75
|
setAssets((prev) => [result, ...prev]);
|
|
75
76
|
}
|
|
76
77
|
return result;
|
|
@@ -84,7 +85,7 @@ function useAssets({ scope, accept, pageSize, appId, listAppId }) {
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
}, [scope, appId]);
|
|
87
|
-
const uploadFromUrl = useCallback(async (url, name) => {
|
|
88
|
+
const uploadFromUrl = useCallback(async (url, name, scopeOverride) => {
|
|
88
89
|
setUploading(true);
|
|
89
90
|
setUploadProgress(0);
|
|
90
91
|
try {
|
|
@@ -93,7 +94,7 @@ function useAssets({ scope, accept, pageSize, appId, listAppId }) {
|
|
|
93
94
|
const blob = await response.blob();
|
|
94
95
|
const fileName = name || url.split("/").pop()?.split("?")[0] || "imported-file";
|
|
95
96
|
const file = new File([blob], fileName, { type: blob.type });
|
|
96
|
-
return await upload(file);
|
|
97
|
+
return await upload(file, void 0, scopeOverride);
|
|
97
98
|
} catch (err) {
|
|
98
99
|
if (mountedRef.current) setError(err?.message || "URL import failed");
|
|
99
100
|
return null;
|
|
@@ -110,12 +111,12 @@ function useAssets({ scope, accept, pageSize, appId, listAppId }) {
|
|
|
110
111
|
try {
|
|
111
112
|
const result = await SL.asset.uploadFromUrl({
|
|
112
113
|
url,
|
|
113
|
-
scope,
|
|
114
|
+
scope: opts?.scopeOverride || scope,
|
|
114
115
|
metadata: { name: opts?.name, ...opts?.metadata || {} },
|
|
115
116
|
...appId ? { appId } : {},
|
|
116
117
|
admin: true
|
|
117
118
|
});
|
|
118
|
-
if (mountedRef.current) {
|
|
119
|
+
if (mountedRef.current && !opts?.scopeOverride) {
|
|
119
120
|
setAssets((prev) => [result, ...prev]);
|
|
120
121
|
}
|
|
121
122
|
return result;
|
|
@@ -352,13 +353,54 @@ var AppBadge = ({ appId, appName, size = "sm" }) => {
|
|
|
352
353
|
var CardMenu = ({ onRename, onReplace, onEditTags, onDelete, position = "absolute" }) => {
|
|
353
354
|
const [open, setOpen] = useState(false);
|
|
354
355
|
const ref = useRef(null);
|
|
356
|
+
const btnRef = useRef(null);
|
|
357
|
+
const menuRef = useRef(null);
|
|
358
|
+
const [pos, setPos] = useState(null);
|
|
355
359
|
useEffect(() => {
|
|
356
360
|
if (!open) return;
|
|
357
361
|
const handler = (e) => {
|
|
358
|
-
|
|
362
|
+
const t = e.target;
|
|
363
|
+
if (ref.current?.contains(t)) return;
|
|
364
|
+
if (menuRef.current?.contains(t)) return;
|
|
365
|
+
setOpen(false);
|
|
366
|
+
};
|
|
367
|
+
const onKey = (e) => {
|
|
368
|
+
if (e.key === "Escape") setOpen(false);
|
|
359
369
|
};
|
|
360
370
|
document.addEventListener("mousedown", handler);
|
|
361
|
-
|
|
371
|
+
document.addEventListener("keydown", onKey);
|
|
372
|
+
return () => {
|
|
373
|
+
document.removeEventListener("mousedown", handler);
|
|
374
|
+
document.removeEventListener("keydown", onKey);
|
|
375
|
+
};
|
|
376
|
+
}, [open]);
|
|
377
|
+
useLayoutEffect(() => {
|
|
378
|
+
if (!open) {
|
|
379
|
+
setPos(null);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const update = () => {
|
|
383
|
+
const el = btnRef.current;
|
|
384
|
+
if (!el) return;
|
|
385
|
+
const r = el.getBoundingClientRect();
|
|
386
|
+
const menuW = menuRef.current?.offsetWidth ?? 160;
|
|
387
|
+
const menuH = menuRef.current?.offsetHeight ?? 160;
|
|
388
|
+
const margin = 8;
|
|
389
|
+
let left = Math.min(window.innerWidth - menuW - margin, r.right - menuW);
|
|
390
|
+
left = Math.max(margin, left);
|
|
391
|
+
let top = r.bottom + 4;
|
|
392
|
+
if (top + menuH > window.innerHeight - margin) {
|
|
393
|
+
top = Math.max(margin, r.top - menuH - 4);
|
|
394
|
+
}
|
|
395
|
+
setPos({ top, left });
|
|
396
|
+
};
|
|
397
|
+
update();
|
|
398
|
+
window.addEventListener("resize", update);
|
|
399
|
+
window.addEventListener("scroll", update, true);
|
|
400
|
+
return () => {
|
|
401
|
+
window.removeEventListener("resize", update);
|
|
402
|
+
window.removeEventListener("scroll", update, true);
|
|
403
|
+
};
|
|
362
404
|
}, [open]);
|
|
363
405
|
if (!onRename && !onReplace && !onEditTags && !onDelete) return null;
|
|
364
406
|
return /* @__PURE__ */ jsxs(
|
|
@@ -366,7 +408,7 @@ var CardMenu = ({ onRename, onReplace, onEditTags, onDelete, position = "absolut
|
|
|
366
408
|
{
|
|
367
409
|
ref,
|
|
368
410
|
className: cn(
|
|
369
|
-
position === "absolute" ? "absolute
|
|
411
|
+
position === "absolute" ? "absolute top-1.5 right-1.5 z-10" : "relative flex-shrink-0"
|
|
370
412
|
),
|
|
371
413
|
onClick: (e) => e.stopPropagation(),
|
|
372
414
|
onDoubleClick: (e) => e.stopPropagation(),
|
|
@@ -374,6 +416,7 @@ var CardMenu = ({ onRename, onReplace, onEditTags, onDelete, position = "absolut
|
|
|
374
416
|
/* @__PURE__ */ jsx(
|
|
375
417
|
"button",
|
|
376
418
|
{
|
|
419
|
+
ref: btnRef,
|
|
377
420
|
type: "button",
|
|
378
421
|
onClick: (e) => {
|
|
379
422
|
e.stopPropagation();
|
|
@@ -381,91 +424,96 @@ var CardMenu = ({ onRename, onReplace, onEditTags, onDelete, position = "absolut
|
|
|
381
424
|
},
|
|
382
425
|
className: cn(
|
|
383
426
|
"w-6 h-6 rounded-full flex items-center justify-center transition-all",
|
|
384
|
-
"bg-background/90 border border-border text-foreground hover:bg-background shadow-sm"
|
|
385
|
-
position === "absolute" && "opacity-0 group-hover:opacity-100",
|
|
386
|
-
open && "opacity-100"
|
|
427
|
+
"bg-background/90 border border-border text-foreground hover:bg-background shadow-sm"
|
|
387
428
|
),
|
|
388
429
|
title: "Asset actions",
|
|
389
430
|
"aria-label": "Asset actions",
|
|
390
431
|
children: /* @__PURE__ */ jsx(MoreVertical, { className: "w-3 h-3" })
|
|
391
432
|
}
|
|
392
433
|
),
|
|
393
|
-
open &&
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
434
|
+
open && typeof document !== "undefined" && createPortal(
|
|
435
|
+
/* @__PURE__ */ jsxs(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
ref: menuRef,
|
|
439
|
+
className: "fixed z-[1000] min-w-[160px] rounded-md border border-border bg-popover text-popover-foreground shadow-lg py-1",
|
|
440
|
+
style: pos ? { top: pos.top, left: pos.left } : { visibility: "hidden", top: 0, left: 0 },
|
|
441
|
+
role: "menu",
|
|
442
|
+
onClick: (e) => e.stopPropagation(),
|
|
443
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
444
|
+
children: [
|
|
445
|
+
onRename && /* @__PURE__ */ jsxs(
|
|
446
|
+
"button",
|
|
447
|
+
{
|
|
448
|
+
type: "button",
|
|
449
|
+
role: "menuitem",
|
|
450
|
+
onClick: (e) => {
|
|
451
|
+
e.stopPropagation();
|
|
452
|
+
setOpen(false);
|
|
453
|
+
onRename();
|
|
454
|
+
},
|
|
455
|
+
className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-accent",
|
|
456
|
+
children: [
|
|
457
|
+
/* @__PURE__ */ jsx(Pencil, { className: "w-3 h-3" }),
|
|
458
|
+
" Rename"
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
),
|
|
462
|
+
onReplace && /* @__PURE__ */ jsxs(
|
|
463
|
+
"button",
|
|
464
|
+
{
|
|
465
|
+
type: "button",
|
|
466
|
+
role: "menuitem",
|
|
467
|
+
onClick: (e) => {
|
|
468
|
+
e.stopPropagation();
|
|
469
|
+
setOpen(false);
|
|
470
|
+
onReplace();
|
|
471
|
+
},
|
|
472
|
+
className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-accent",
|
|
473
|
+
children: [
|
|
474
|
+
/* @__PURE__ */ jsx(Upload, { className: "w-3 h-3" }),
|
|
475
|
+
" Replace file"
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
onEditTags && /* @__PURE__ */ jsxs(
|
|
480
|
+
"button",
|
|
481
|
+
{
|
|
482
|
+
type: "button",
|
|
483
|
+
role: "menuitem",
|
|
484
|
+
onClick: (e) => {
|
|
485
|
+
e.stopPropagation();
|
|
486
|
+
setOpen(false);
|
|
487
|
+
onEditTags();
|
|
488
|
+
},
|
|
489
|
+
className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-accent",
|
|
490
|
+
children: [
|
|
491
|
+
/* @__PURE__ */ jsx(Tag, { className: "w-3 h-3" }),
|
|
492
|
+
" Edit tags"
|
|
493
|
+
]
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
onDelete && /* @__PURE__ */ jsxs(
|
|
497
|
+
"button",
|
|
498
|
+
{
|
|
499
|
+
type: "button",
|
|
500
|
+
role: "menuitem",
|
|
501
|
+
onClick: (e) => {
|
|
502
|
+
e.stopPropagation();
|
|
503
|
+
setOpen(false);
|
|
504
|
+
onDelete();
|
|
505
|
+
},
|
|
506
|
+
className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs text-destructive hover:bg-destructive/10",
|
|
507
|
+
children: [
|
|
508
|
+
/* @__PURE__ */ jsx(Trash2, { className: "w-3 h-3" }),
|
|
509
|
+
" Delete"
|
|
510
|
+
]
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
]
|
|
514
|
+
}
|
|
515
|
+
),
|
|
516
|
+
document.body
|
|
469
517
|
)
|
|
470
518
|
]
|
|
471
519
|
}
|
|
@@ -545,7 +593,7 @@ var AssetGridItem = ({ asset: asset2, selected, onToggle, onDoubleClick, onDelet
|
|
|
545
593
|
] })
|
|
546
594
|
] })
|
|
547
595
|
] }),
|
|
548
|
-
selected && /* @__PURE__ */ jsx("div", { className: "absolute top-2
|
|
596
|
+
selected && /* @__PURE__ */ jsx("div", { className: "absolute top-2 left-2 w-5 h-5 rounded-full bg-primary flex items-center justify-center z-10", children: /* @__PURE__ */ jsx(Check, { className: "w-3 h-3 text-primary-foreground" }) }),
|
|
549
597
|
/* @__PURE__ */ jsx(
|
|
550
598
|
CardMenu,
|
|
551
599
|
{
|
|
@@ -2025,8 +2073,25 @@ var GlobalUploadToggle = ({ checked, onChange, appName }) => /* @__PURE__ */ jsx
|
|
|
2025
2073
|
/* @__PURE__ */ jsx("span", { className: "block", children: checked ? `Asset will be available to every app in this collection.` : `Asset will be tagged to ${appName}. Tick to share with every app in the collection instead.` })
|
|
2026
2074
|
] })
|
|
2027
2075
|
] });
|
|
2028
|
-
var
|
|
2029
|
-
|
|
2076
|
+
var AttachToContextToggle = ({ checked, onChange, contextLabel }) => /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-2 text-xs text-muted-foreground cursor-pointer select-none p-2 rounded-md border border-border bg-muted/30", children: [
|
|
2077
|
+
/* @__PURE__ */ jsx(
|
|
2078
|
+
"input",
|
|
2079
|
+
{
|
|
2080
|
+
type: "checkbox",
|
|
2081
|
+
checked,
|
|
2082
|
+
onChange: (e) => onChange(e.target.checked),
|
|
2083
|
+
className: "mt-0.5 cursor-pointer"
|
|
2084
|
+
}
|
|
2085
|
+
),
|
|
2086
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
2087
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium text-foreground", children: [
|
|
2088
|
+
"Attach to ",
|
|
2089
|
+
contextLabel
|
|
2090
|
+
] }),
|
|
2091
|
+
/* @__PURE__ */ jsx("span", { className: "block", children: checked ? `Asset will be tagged to ${contextLabel}.` : `Asset will be added to the collection (available everywhere). Tick to attach it to ${contextLabel} instead.` })
|
|
2092
|
+
] })
|
|
2093
|
+
] });
|
|
2094
|
+
var ScopedAssetBrowser = ({ scope: _scope, accept: _accept, pageSize: _pageSize, viewMode, search, selectedIds, onToggleSelect, onDoubleClickSelect, onDelete, allowDelete, emptyText, listAppId: _listAppId, requireProductId, currentAppId, currentAppName, getAppName, assets, loading, error, refresh, remove, updateAsset, replaceFile }) => {
|
|
2030
2095
|
const replaceInputRef = React7.useRef(null);
|
|
2031
2096
|
const replaceTargetRef = React7.useRef(null);
|
|
2032
2097
|
const handleRename = useCallback(async (asset2) => {
|
|
@@ -2250,13 +2315,55 @@ var AssetPickerContent = ({
|
|
|
2250
2315
|
}
|
|
2251
2316
|
return scope;
|
|
2252
2317
|
}, [scope, productScope, scopeTab, hasProductScope]);
|
|
2253
|
-
const
|
|
2318
|
+
const collectionScope = useMemo(() => {
|
|
2319
|
+
const cId = scope.collectionId;
|
|
2320
|
+
return cId ? { type: "collection", collectionId: cId } : null;
|
|
2321
|
+
}, [scope]);
|
|
2322
|
+
const contextScope = useMemo(() => {
|
|
2323
|
+
if (scope.type === "proof") return scope;
|
|
2324
|
+
if (scope.type === "product") return scope;
|
|
2325
|
+
if (productScope) {
|
|
2326
|
+
return { type: "product", collectionId: productScope.collectionId, productId: productScope.productId };
|
|
2327
|
+
}
|
|
2328
|
+
return null;
|
|
2329
|
+
}, [scope, productScope]);
|
|
2330
|
+
const contextLabel = contextScope?.type === "proof" ? "this proof" : "this product";
|
|
2331
|
+
const hasContext = !!contextScope && !!collectionScope;
|
|
2332
|
+
const [attachToContext, setAttachToContext] = useState(true);
|
|
2333
|
+
const uploadScope = useMemo(() => {
|
|
2334
|
+
if (hasContext) return attachToContext ? contextScope : collectionScope;
|
|
2335
|
+
return activeScope;
|
|
2336
|
+
}, [hasContext, attachToContext, contextScope, collectionScope, activeScope]);
|
|
2337
|
+
const {
|
|
2338
|
+
assets,
|
|
2339
|
+
loading: assetsLoading,
|
|
2340
|
+
error: assetsError,
|
|
2341
|
+
refresh: refreshAssets,
|
|
2342
|
+
upload,
|
|
2343
|
+
uploadFromUrl,
|
|
2344
|
+
uploadFromRemoteUrl,
|
|
2345
|
+
remove,
|
|
2346
|
+
updateAsset,
|
|
2347
|
+
replaceFile,
|
|
2348
|
+
uploading,
|
|
2349
|
+
uploadProgress
|
|
2350
|
+
} = useAssets({
|
|
2254
2351
|
scope: activeScope,
|
|
2255
2352
|
accept: acceptProp,
|
|
2256
2353
|
pageSize,
|
|
2257
2354
|
appId: uploadGlobal ? void 0 : appId,
|
|
2258
2355
|
listAppId
|
|
2259
2356
|
});
|
|
2357
|
+
const reconcileAfterUpload = useCallback(async (uploadedScope) => {
|
|
2358
|
+
if (hasProductScope) {
|
|
2359
|
+
const desiredTab = uploadedScope.type === "product" ? "product" : "collection";
|
|
2360
|
+
if (desiredTab !== scopeTab) {
|
|
2361
|
+
setScopeTab(desiredTab);
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
await refreshAssets();
|
|
2366
|
+
}, [hasProductScope, scopeTab, refreshAssets]);
|
|
2260
2367
|
const toSelection = useCallback((asset2) => ({
|
|
2261
2368
|
id: asset2.id,
|
|
2262
2369
|
url: asset2.url,
|
|
@@ -2293,34 +2400,46 @@ var AssetPickerContent = ({
|
|
|
2293
2400
|
});
|
|
2294
2401
|
}, [multiple, onSelect, onConfirm, toSelection]);
|
|
2295
2402
|
const handleUploadFiles = useCallback(async (files) => {
|
|
2403
|
+
const targetScope = uploadScope;
|
|
2404
|
+
const sameAsActive = targetScope === activeScope;
|
|
2296
2405
|
for (const file of files) {
|
|
2297
|
-
const result = await upload(file);
|
|
2406
|
+
const result = await upload(file, void 0, sameAsActive ? void 0 : targetScope);
|
|
2298
2407
|
if (result && !multiple) {
|
|
2299
2408
|
setSelectedIds(/* @__PURE__ */ new Set([result.id]));
|
|
2300
2409
|
onSelect?.(toSelection(result));
|
|
2301
2410
|
}
|
|
2302
2411
|
}
|
|
2303
2412
|
setTab("browse");
|
|
2304
|
-
|
|
2413
|
+
await reconcileAfterUpload(targetScope);
|
|
2414
|
+
}, [upload, multiple, onSelect, toSelection, uploadScope, activeScope, reconcileAfterUpload]);
|
|
2305
2415
|
const handleUrlImport = useCallback(async (url, name) => {
|
|
2306
|
-
const
|
|
2416
|
+
const targetScope = uploadScope;
|
|
2417
|
+
const sameAsActive = targetScope === activeScope;
|
|
2418
|
+
const result = await uploadFromUrl(url, name, sameAsActive ? void 0 : targetScope);
|
|
2307
2419
|
if (result) {
|
|
2308
2420
|
setTab("browse");
|
|
2309
2421
|
if (!multiple) {
|
|
2310
2422
|
setSelectedIds(/* @__PURE__ */ new Set([result.id]));
|
|
2311
2423
|
onSelect?.(toSelection(result));
|
|
2312
2424
|
}
|
|
2425
|
+
await reconcileAfterUpload(targetScope);
|
|
2313
2426
|
}
|
|
2314
2427
|
return result;
|
|
2315
|
-
}, [uploadFromUrl, multiple, onSelect, toSelection]);
|
|
2428
|
+
}, [uploadFromUrl, multiple, onSelect, toSelection, uploadScope, activeScope, reconcileAfterUpload]);
|
|
2316
2429
|
const handleRemoteIngest = useCallback(async (url, name) => {
|
|
2317
|
-
const
|
|
2430
|
+
const targetScope = uploadScope;
|
|
2431
|
+
const sameAsActive = targetScope === activeScope;
|
|
2432
|
+
const result = await uploadFromRemoteUrl(url, {
|
|
2433
|
+
name,
|
|
2434
|
+
...sameAsActive ? {} : { scopeOverride: targetScope }
|
|
2435
|
+
});
|
|
2318
2436
|
if (result && !multiple) {
|
|
2319
2437
|
setSelectedIds(/* @__PURE__ */ new Set([result.id]));
|
|
2320
2438
|
onSelect?.(toSelection(result));
|
|
2321
2439
|
}
|
|
2440
|
+
if (result) await reconcileAfterUpload(targetScope);
|
|
2322
2441
|
return result;
|
|
2323
|
-
}, [uploadFromRemoteUrl, multiple, onSelect, toSelection]);
|
|
2442
|
+
}, [uploadFromRemoteUrl, multiple, onSelect, toSelection, uploadScope, activeScope, reconcileAfterUpload]);
|
|
2324
2443
|
const handleDelete = useCallback(async (assetId) => {
|
|
2325
2444
|
setSelectedIds((prev) => {
|
|
2326
2445
|
const next = new Set(prev);
|
|
@@ -2508,11 +2627,26 @@ var AssetPickerContent = ({
|
|
|
2508
2627
|
requireProductId: hasProductScope && scopeTab === "product" ? productScope.productId : void 0,
|
|
2509
2628
|
currentAppId: appId,
|
|
2510
2629
|
currentAppName: resolvedAppName,
|
|
2511
|
-
getAppName
|
|
2630
|
+
getAppName,
|
|
2631
|
+
assets,
|
|
2632
|
+
loading: assetsLoading,
|
|
2633
|
+
error: assetsError,
|
|
2634
|
+
refresh: refreshAssets,
|
|
2635
|
+
remove,
|
|
2636
|
+
updateAsset,
|
|
2637
|
+
replaceFile
|
|
2512
2638
|
},
|
|
2513
2639
|
`${activeScope.type}-${activeScope.productId || ""}-${effectiveAccept || "all"}-${listAppId || "no-app-filter"}`
|
|
2514
2640
|
),
|
|
2515
2641
|
tab === "upload" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2642
|
+
hasContext && /* @__PURE__ */ jsx(
|
|
2643
|
+
AttachToContextToggle,
|
|
2644
|
+
{
|
|
2645
|
+
checked: attachToContext,
|
|
2646
|
+
onChange: setAttachToContext,
|
|
2647
|
+
contextLabel
|
|
2648
|
+
}
|
|
2649
|
+
),
|
|
2516
2650
|
hasAppFilter && /* @__PURE__ */ jsx(
|
|
2517
2651
|
GlobalUploadToggle,
|
|
2518
2652
|
{
|
|
@@ -2534,6 +2668,14 @@ var AssetPickerContent = ({
|
|
|
2534
2668
|
)
|
|
2535
2669
|
] }),
|
|
2536
2670
|
tab === "url" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2671
|
+
hasContext && /* @__PURE__ */ jsx(
|
|
2672
|
+
AttachToContextToggle,
|
|
2673
|
+
{
|
|
2674
|
+
checked: attachToContext,
|
|
2675
|
+
onChange: setAttachToContext,
|
|
2676
|
+
contextLabel
|
|
2677
|
+
}
|
|
2678
|
+
),
|
|
2537
2679
|
hasAppFilter && /* @__PURE__ */ jsx(
|
|
2538
2680
|
GlobalUploadToggle,
|
|
2539
2681
|
{
|
|
@@ -2551,6 +2693,14 @@ var AssetPickerContent = ({
|
|
|
2551
2693
|
)
|
|
2552
2694
|
] }),
|
|
2553
2695
|
tab === "ai" && aiEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2696
|
+
hasContext && /* @__PURE__ */ jsx(
|
|
2697
|
+
AttachToContextToggle,
|
|
2698
|
+
{
|
|
2699
|
+
checked: attachToContext,
|
|
2700
|
+
onChange: setAttachToContext,
|
|
2701
|
+
contextLabel
|
|
2702
|
+
}
|
|
2703
|
+
),
|
|
2554
2704
|
hasAppFilter && /* @__PURE__ */ jsx(
|
|
2555
2705
|
GlobalUploadToggle,
|
|
2556
2706
|
{
|
|
@@ -2569,6 +2719,14 @@ var AssetPickerContent = ({
|
|
|
2569
2719
|
)
|
|
2570
2720
|
] }),
|
|
2571
2721
|
tab === "stock" && stockEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2722
|
+
hasContext && /* @__PURE__ */ jsx(
|
|
2723
|
+
AttachToContextToggle,
|
|
2724
|
+
{
|
|
2725
|
+
checked: attachToContext,
|
|
2726
|
+
onChange: setAttachToContext,
|
|
2727
|
+
contextLabel
|
|
2728
|
+
}
|
|
2729
|
+
),
|
|
2572
2730
|
hasAppFilter && /* @__PURE__ */ jsx(
|
|
2573
2731
|
GlobalUploadToggle,
|
|
2574
2732
|
{
|
|
@@ -2678,5 +2836,5 @@ var AssetPicker = (props) => {
|
|
|
2678
2836
|
assertStylesLoaded();
|
|
2679
2837
|
|
|
2680
2838
|
export { ASSET_MIME_FILTERS, AssetPicker, useAppRegistry, useAssets };
|
|
2681
|
-
//# sourceMappingURL=chunk-
|
|
2682
|
-
//# sourceMappingURL=chunk-
|
|
2839
|
+
//# sourceMappingURL=chunk-AWWWHHLL.js.map
|
|
2840
|
+
//# sourceMappingURL=chunk-AWWWHHLL.js.map
|