@proveanything/smartlinks-utils-ui 1.13.0 → 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.
@@ -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
- if (!ref.current?.contains(e.target)) setOpen(false);
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
- return () => document.removeEventListener("mousedown", handler);
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 bottom-1.5 right-1.5" : "relative flex-shrink-0"
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 && /* @__PURE__ */ jsxs(
394
- "div",
395
- {
396
- className: "absolute bottom-full right-0 mb-1 z-20 min-w-[140px] rounded-md border border-border bg-popover text-popover-foreground shadow-md py-1",
397
- role: "menu",
398
- children: [
399
- onRename && /* @__PURE__ */ jsxs(
400
- "button",
401
- {
402
- type: "button",
403
- role: "menuitem",
404
- onClick: (e) => {
405
- e.stopPropagation();
406
- setOpen(false);
407
- onRename();
408
- },
409
- className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-accent",
410
- children: [
411
- /* @__PURE__ */ jsx(Pencil, { className: "w-3 h-3" }),
412
- " Rename"
413
- ]
414
- }
415
- ),
416
- onReplace && /* @__PURE__ */ jsxs(
417
- "button",
418
- {
419
- type: "button",
420
- role: "menuitem",
421
- onClick: (e) => {
422
- e.stopPropagation();
423
- setOpen(false);
424
- onReplace();
425
- },
426
- className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-accent",
427
- children: [
428
- /* @__PURE__ */ jsx(Upload, { className: "w-3 h-3" }),
429
- " Replace file"
430
- ]
431
- }
432
- ),
433
- onEditTags && /* @__PURE__ */ jsxs(
434
- "button",
435
- {
436
- type: "button",
437
- role: "menuitem",
438
- onClick: (e) => {
439
- e.stopPropagation();
440
- setOpen(false);
441
- onEditTags();
442
- },
443
- className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-accent",
444
- children: [
445
- /* @__PURE__ */ jsx(Tag, { className: "w-3 h-3" }),
446
- " Edit tags"
447
- ]
448
- }
449
- ),
450
- onDelete && /* @__PURE__ */ jsxs(
451
- "button",
452
- {
453
- type: "button",
454
- role: "menuitem",
455
- onClick: (e) => {
456
- e.stopPropagation();
457
- setOpen(false);
458
- onDelete();
459
- },
460
- className: "w-full flex items-center gap-2 px-2.5 py-1.5 text-xs text-destructive hover:bg-destructive/10",
461
- children: [
462
- /* @__PURE__ */ jsx(Trash2, { className: "w-3 h-3" }),
463
- " Delete"
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 right-2 w-5 h-5 rounded-full bg-primary flex items-center justify-center", children: /* @__PURE__ */ jsx(Check, { className: "w-3 h-3 text-primary-foreground" }) }),
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 ScopedAssetBrowser = ({ scope, accept, pageSize, viewMode, search, selectedIds, onToggleSelect, onDoubleClickSelect, onDelete, allowDelete, emptyText, listAppId, currentAppId, currentAppName, getAppName }) => {
2029
- const { assets, loading, error, refresh, remove, updateAsset, replaceFile } = useAssets({ scope, accept, pageSize, listAppId });
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) => {
@@ -2085,6 +2150,10 @@ var ScopedAssetBrowser = ({ scope, accept, pageSize, viewMode, search, selectedI
2085
2150
  const filteredAssets = useMemo(() => {
2086
2151
  const q = search.trim().toLowerCase();
2087
2152
  return assets.filter((a) => {
2153
+ if (requireProductId) {
2154
+ const pid = a.productId || a.metadata?.productId || (a.scope?.type === "product" ? a.scope?.productId : void 0);
2155
+ if (pid !== requireProductId) return false;
2156
+ }
2088
2157
  if (q) {
2089
2158
  const hit = (a.name || "").toLowerCase().includes(q) || (a.cleanName || "").toLowerCase().includes(q) || (a.mimeType || "").toLowerCase().includes(q) || (a.labels || []).some((l) => l.toLowerCase().includes(q));
2090
2159
  if (!hit) return false;
@@ -2097,7 +2166,7 @@ var ScopedAssetBrowser = ({ scope, accept, pageSize, viewMode, search, selectedI
2097
2166
  }
2098
2167
  return true;
2099
2168
  });
2100
- }, [assets, search, activeLabels]);
2169
+ }, [assets, search, activeLabels, requireProductId]);
2101
2170
  if (loading && assets.length === 0) {
2102
2171
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsx(Loader2, { className: "w-6 h-6 text-muted-foreground animate-spin" }) });
2103
2172
  }
@@ -2158,9 +2227,9 @@ var ScopedAssetBrowser = ({ scope, accept, pageSize, viewMode, search, selectedI
2158
2227
  onToggleSelect,
2159
2228
  onDoubleClickSelect,
2160
2229
  onDelete: allowDelete ? handleDeleteWithConfirm : void 0,
2161
- onRename: allowDelete ? handleRename : void 0,
2162
- onReplace: allowDelete ? handleReplace : void 0,
2163
- onEditTags: allowDelete ? handleEditTags : void 0,
2230
+ onRename: handleRename,
2231
+ onReplace: handleReplace,
2232
+ onEditTags: handleEditTags,
2164
2233
  allowDelete,
2165
2234
  currentAppId,
2166
2235
  currentAppName,
@@ -2246,13 +2315,55 @@ var AssetPickerContent = ({
2246
2315
  }
2247
2316
  return scope;
2248
2317
  }, [scope, productScope, scopeTab, hasProductScope]);
2249
- const { assets, upload, uploadFromUrl, uploadFromRemoteUrl, uploading, uploadProgress } = useAssets({
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({
2250
2351
  scope: activeScope,
2251
2352
  accept: acceptProp,
2252
2353
  pageSize,
2253
2354
  appId: uploadGlobal ? void 0 : appId,
2254
2355
  listAppId
2255
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]);
2256
2367
  const toSelection = useCallback((asset2) => ({
2257
2368
  id: asset2.id,
2258
2369
  url: asset2.url,
@@ -2289,34 +2400,46 @@ var AssetPickerContent = ({
2289
2400
  });
2290
2401
  }, [multiple, onSelect, onConfirm, toSelection]);
2291
2402
  const handleUploadFiles = useCallback(async (files) => {
2403
+ const targetScope = uploadScope;
2404
+ const sameAsActive = targetScope === activeScope;
2292
2405
  for (const file of files) {
2293
- const result = await upload(file);
2406
+ const result = await upload(file, void 0, sameAsActive ? void 0 : targetScope);
2294
2407
  if (result && !multiple) {
2295
2408
  setSelectedIds(/* @__PURE__ */ new Set([result.id]));
2296
2409
  onSelect?.(toSelection(result));
2297
2410
  }
2298
2411
  }
2299
2412
  setTab("browse");
2300
- }, [upload, multiple, onSelect, toSelection]);
2413
+ await reconcileAfterUpload(targetScope);
2414
+ }, [upload, multiple, onSelect, toSelection, uploadScope, activeScope, reconcileAfterUpload]);
2301
2415
  const handleUrlImport = useCallback(async (url, name) => {
2302
- const result = await uploadFromUrl(url, name);
2416
+ const targetScope = uploadScope;
2417
+ const sameAsActive = targetScope === activeScope;
2418
+ const result = await uploadFromUrl(url, name, sameAsActive ? void 0 : targetScope);
2303
2419
  if (result) {
2304
2420
  setTab("browse");
2305
2421
  if (!multiple) {
2306
2422
  setSelectedIds(/* @__PURE__ */ new Set([result.id]));
2307
2423
  onSelect?.(toSelection(result));
2308
2424
  }
2425
+ await reconcileAfterUpload(targetScope);
2309
2426
  }
2310
2427
  return result;
2311
- }, [uploadFromUrl, multiple, onSelect, toSelection]);
2428
+ }, [uploadFromUrl, multiple, onSelect, toSelection, uploadScope, activeScope, reconcileAfterUpload]);
2312
2429
  const handleRemoteIngest = useCallback(async (url, name) => {
2313
- const result = await uploadFromRemoteUrl(url, { name });
2430
+ const targetScope = uploadScope;
2431
+ const sameAsActive = targetScope === activeScope;
2432
+ const result = await uploadFromRemoteUrl(url, {
2433
+ name,
2434
+ ...sameAsActive ? {} : { scopeOverride: targetScope }
2435
+ });
2314
2436
  if (result && !multiple) {
2315
2437
  setSelectedIds(/* @__PURE__ */ new Set([result.id]));
2316
2438
  onSelect?.(toSelection(result));
2317
2439
  }
2440
+ if (result) await reconcileAfterUpload(targetScope);
2318
2441
  return result;
2319
- }, [uploadFromRemoteUrl, multiple, onSelect, toSelection]);
2442
+ }, [uploadFromRemoteUrl, multiple, onSelect, toSelection, uploadScope, activeScope, reconcileAfterUpload]);
2320
2443
  const handleDelete = useCallback(async (assetId) => {
2321
2444
  setSelectedIds((prev) => {
2322
2445
  const next = new Set(prev);
@@ -2501,13 +2624,29 @@ var AssetPickerContent = ({
2501
2624
  allowDelete,
2502
2625
  emptyText,
2503
2626
  listAppId,
2627
+ requireProductId: hasProductScope && scopeTab === "product" ? productScope.productId : void 0,
2504
2628
  currentAppId: appId,
2505
2629
  currentAppName: resolvedAppName,
2506
- getAppName
2630
+ getAppName,
2631
+ assets,
2632
+ loading: assetsLoading,
2633
+ error: assetsError,
2634
+ refresh: refreshAssets,
2635
+ remove,
2636
+ updateAsset,
2637
+ replaceFile
2507
2638
  },
2508
2639
  `${activeScope.type}-${activeScope.productId || ""}-${effectiveAccept || "all"}-${listAppId || "no-app-filter"}`
2509
2640
  ),
2510
2641
  tab === "upload" && /* @__PURE__ */ jsxs(Fragment, { children: [
2642
+ hasContext && /* @__PURE__ */ jsx(
2643
+ AttachToContextToggle,
2644
+ {
2645
+ checked: attachToContext,
2646
+ onChange: setAttachToContext,
2647
+ contextLabel
2648
+ }
2649
+ ),
2511
2650
  hasAppFilter && /* @__PURE__ */ jsx(
2512
2651
  GlobalUploadToggle,
2513
2652
  {
@@ -2529,6 +2668,14 @@ var AssetPickerContent = ({
2529
2668
  )
2530
2669
  ] }),
2531
2670
  tab === "url" && /* @__PURE__ */ jsxs(Fragment, { children: [
2671
+ hasContext && /* @__PURE__ */ jsx(
2672
+ AttachToContextToggle,
2673
+ {
2674
+ checked: attachToContext,
2675
+ onChange: setAttachToContext,
2676
+ contextLabel
2677
+ }
2678
+ ),
2532
2679
  hasAppFilter && /* @__PURE__ */ jsx(
2533
2680
  GlobalUploadToggle,
2534
2681
  {
@@ -2546,6 +2693,14 @@ var AssetPickerContent = ({
2546
2693
  )
2547
2694
  ] }),
2548
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
+ ),
2549
2704
  hasAppFilter && /* @__PURE__ */ jsx(
2550
2705
  GlobalUploadToggle,
2551
2706
  {
@@ -2564,6 +2719,14 @@ var AssetPickerContent = ({
2564
2719
  )
2565
2720
  ] }),
2566
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
+ ),
2567
2730
  hasAppFilter && /* @__PURE__ */ jsx(
2568
2731
  GlobalUploadToggle,
2569
2732
  {
@@ -2673,5 +2836,5 @@ var AssetPicker = (props) => {
2673
2836
  assertStylesLoaded();
2674
2837
 
2675
2838
  export { ASSET_MIME_FILTERS, AssetPicker, useAppRegistry, useAssets };
2676
- //# sourceMappingURL=chunk-PSVYUVZC.js.map
2677
- //# sourceMappingURL=chunk-PSVYUVZC.js.map
2839
+ //# sourceMappingURL=chunk-AWWWHHLL.js.map
2840
+ //# sourceMappingURL=chunk-AWWWHHLL.js.map