@kolkrabbi/kol-component 0.256.0 → 0.257.0
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/package.json
CHANGED
|
@@ -337,6 +337,7 @@ export function MediaLibraryProvider({
|
|
|
337
337
|
|
|
338
338
|
const value = useMemo(() => {
|
|
339
339
|
const annotated = objects.map((o) => ({ ...o, kind: kindOf(o) }))
|
|
340
|
+
const storageOf = new Map(objects.filter((o) => o.storageKey).map((o) => [o.key, o.storageKey]))
|
|
340
341
|
const scoped = prefix ? annotated.filter((o) => o.key.startsWith(prefix)) : annotated
|
|
341
342
|
const folders = foldersUnder(scoped, prefix)
|
|
342
343
|
/* level = the direct children; flat = every object under the prefix */
|
|
@@ -415,7 +416,9 @@ export function MediaLibraryProvider({
|
|
|
415
416
|
bucket,
|
|
416
417
|
buckets,
|
|
417
418
|
setBucket,
|
|
418
|
-
|
|
419
|
+
/* a PATH resolves to the row's `storageKey` — the object never moves, rename and move edit
|
|
420
|
+
* the row (MediaLibraryUrlOnStorageKey, kol-website 2026-10-13); no `storageKey`, the path */
|
|
421
|
+
mediaUrl: client?.mediaUrl ? (key) => client.mediaUrl(storageOf.get(key) ?? key, bucket ?? undefined) : (key) => key,
|
|
419
422
|
proxied: client?.proxied ?? ((url) => url),
|
|
420
423
|
}
|
|
421
424
|
}, [objects, prefix, flat, sort, search, kinds, paging, pageSize, loading, error, accept, client, bucket, buckets])
|
|
@@ -1081,7 +1084,7 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
|
|
|
1081
1084
|
const [file, setFile] = useState(null)
|
|
1082
1085
|
const ok = !!file && acceptsKind(accept)({ ...file, kind: kindOf(file) })
|
|
1083
1086
|
const use = () => {
|
|
1084
|
-
onSelect?.(client.mediaUrl(file.key, bucket ?? undefined), { contentType: file.contentType, kind: kindOf(file) })
|
|
1087
|
+
onSelect?.(client.mediaUrl(file.storageKey ?? file.key, bucket ?? undefined), { contentType: file.contentType, kind: kindOf(file) })
|
|
1085
1088
|
onClose?.()
|
|
1086
1089
|
}
|
|
1087
1090
|
return (
|
|
@@ -244,7 +244,10 @@ function useBucketLibrary({ client, bucket, defaults, settings: controlled, onSe
|
|
|
244
244
|
const folderInfo = loaded.folders ?? {}
|
|
245
245
|
const setFolderInfo = (fn) => setLoaded((prev) => ({ ...prev, folders: fn(prev.folders ?? {}) }))
|
|
246
246
|
const error = ready ? loaded.error : null
|
|
247
|
-
|
|
247
|
+
/* a PATH resolves to the row's `storageKey` — the object never moves, rename and move edit the
|
|
248
|
+
* row (MediaLibraryUrlOnStorageKey, kol-website 2026-10-13); no `storageKey`, the path */
|
|
249
|
+
const storageOf = useMemo(() => new Map(objects.filter((o) => o.storageKey).map((o) => [o.key, o.storageKey])), [objects])
|
|
250
|
+
const mediaUrl = (key) => client?.mediaUrl?.(storageOf.get(key) ?? key, bucketId ?? undefined) ?? key
|
|
248
251
|
const downloadUrl = (key) => client?.downloadUrl?.(key, bucketId ?? undefined) ?? mediaUrl(key)
|
|
249
252
|
const writable = !!bucketMeta.writable && !!(client?.deleteObject || client?.renameObject)
|
|
250
253
|
/* A CLIENT WITH NO `mediaUrl` HAS NO URLS (kol-fxr 2026-10-08: a stored preset is not a fetchable
|