@raster-app/react 0.1.0-rc.1 → 0.2.0-canary-846559b
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 +94 -79
- package/dist/context.js +4 -4
- package/dist/context.js.map +1 -1
- package/dist/picker-parts.d.ts +11 -2
- package/dist/picker-parts.js +88 -7
- package/dist/picker-parts.js.map +1 -1
- package/dist/raster-picker.d.ts +3 -2
- package/dist/raster-picker.js +16 -14
- package/dist/raster-picker.js.map +1 -1
- package/dist/styles.css +28 -15
- package/dist/use-asset-search.js +5 -3
- package/dist/use-asset-search.js.map +1 -1
- package/dist/use-asset-upload.d.ts +2 -2
- package/dist/use-asset-upload.js +3 -2
- package/dist/use-asset-upload.js.map +1 -1
- package/dist/use-assets.js +2 -2
- package/dist/use-assets.js.map +1 -1
- package/dist/use-libraries.js +2 -2
- package/dist/use-libraries.js.map +1 -1
- package/dist/use-organizations.js +2 -2
- package/dist/use-organizations.js.map +1 -1
- package/dist/use-promote-variant.d.ts +2 -2
- package/dist/use-promote-variant.js +3 -2
- package/dist/use-promote-variant.js.map +1 -1
- package/dist/use-session.js +5 -5
- package/dist/use-session.js.map +1 -1
- package/dist/use-sign-in.d.ts +1 -1
- package/dist/use-sign-in.js +4 -4
- package/dist/use-sign-in.js.map +1 -1
- package/package.json +7 -8
package/dist/raster-picker.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMutation } from '@tanstack/react-query';
|
|
3
3
|
import { useRef, useState } from 'react';
|
|
4
|
-
import { isReady, } from '@raster-app/sdk';
|
|
4
|
+
import { getAsset, isReady, } from '@raster-app/sdk';
|
|
5
5
|
import { useRasterClient } from './context.js';
|
|
6
6
|
import { Icon } from './icons.js';
|
|
7
|
-
import { Brand, Detail, Empty, ErrorCard, FilePicker, OrganizationSwitcher, PendingTile, Progress, Sentinel, Tile, } from './picker-parts.js';
|
|
7
|
+
import { Brand, Detail, Empty, ErrorCard, FilePicker, OrganizationSwitcher, PendingTile, Progress, Sentinel, Tile, TileGrid, } from './picker-parts.js';
|
|
8
8
|
import { SignIn } from './picker-sign-in.js';
|
|
9
9
|
import { useAssetSearch } from './use-asset-search.js';
|
|
10
10
|
import { useAssetUpload } from './use-asset-upload.js';
|
|
@@ -45,7 +45,7 @@ function Browser({ onPick, onError, }) {
|
|
|
45
45
|
const upload = useAssetUpload();
|
|
46
46
|
const promote = usePromoteVariant();
|
|
47
47
|
const read = useMutation({
|
|
48
|
-
mutationFn: (options) => client
|
|
48
|
+
mutationFn: (options) => getAsset(client, options),
|
|
49
49
|
});
|
|
50
50
|
const prefetchAssets = usePrefetchAssets();
|
|
51
51
|
const prefetchLibraries = usePrefetchLibraries();
|
|
@@ -69,9 +69,11 @@ function Browser({ onPick, onError, }) {
|
|
|
69
69
|
const shown = search.active ? search : library === null ? null : assets;
|
|
70
70
|
const items = search.active ? search.hits : assets.assets;
|
|
71
71
|
const hit = search.active ? (search.hits?.find((entry) => entry.id === focusId) ?? null) : null;
|
|
72
|
+
// Until a promote lands, the cached asset is still the previous default.
|
|
73
|
+
const busy = read.isPending || promote.state.status === 'promoting';
|
|
72
74
|
/** Hand the host the whole asset: a search hit or a variant carries less, so it is read first. */
|
|
73
75
|
function pick(item) {
|
|
74
|
-
if (organizationId === null)
|
|
76
|
+
if (organizationId === null || onPick === undefined)
|
|
75
77
|
return;
|
|
76
78
|
const loaded = assets.assets?.find((entry) => entry.id === item.id);
|
|
77
79
|
if (loaded) {
|
|
@@ -86,14 +88,14 @@ function Browser({ onPick, onError, }) {
|
|
|
86
88
|
}
|
|
87
89
|
/** Upload one file into the open library, or as a variant of `parentId`. */
|
|
88
90
|
async function send(file, parentId) {
|
|
89
|
-
|
|
91
|
+
// A second upload would cancel the one in flight.
|
|
92
|
+
if (organizationId === null || library === null || !writable || pending !== null)
|
|
90
93
|
return;
|
|
91
94
|
const preview = URL.createObjectURL(file);
|
|
92
95
|
setPending({ name: file.name, preview, parentId });
|
|
93
96
|
await upload.upload({ organizationId, libraryId: library.id, parentId, source: file });
|
|
94
97
|
URL.revokeObjectURL(preview);
|
|
95
|
-
|
|
96
|
-
setPending((current) => (current?.preview === preview ? null : current));
|
|
98
|
+
setPending(null);
|
|
97
99
|
}
|
|
98
100
|
/** The first press asks to confirm; the second promotes. */
|
|
99
101
|
function setDefault(variant) {
|
|
@@ -124,23 +126,23 @@ function Browser({ onPick, onError, }) {
|
|
|
124
126
|
if (versions) {
|
|
125
127
|
const focused = [opened, ...variants].find((entry) => entry.id === focusId) ?? opened;
|
|
126
128
|
heading = (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "rs-crumb", onClick: () => navigation.openAsset(null), children: library?.name }), _jsx("span", { className: "rs-muted", children: "/" }), _jsx("h1", { className: "rs-heading", children: opened.name }), _jsxs("span", { className: "rs-sidebar-count is-active", children: [variants.length + 1, " versions"] })] }));
|
|
127
|
-
content = (_jsxs(_Fragment, { children: [_jsx(Detail, { item: focused, busy:
|
|
129
|
+
content = (_jsxs(_Fragment, { children: [_jsx(Detail, { item: focused, busy: busy, onPick: onPick && (() => pick(focused)) }), _jsxs(TileGrid, { children: [_jsx(Tile, { asset: opened, selected: focused.id === opened.id, onOpen: () => setFocus({ scope, id: opened.id }), badge: _jsxs("span", { className: "rs-pill rs-tile-badge", children: [_jsx(Icon, { shape: "star", solid: true, width: 10.5 }), "Default"] }) }), variants.map((variant) => (_jsx(Tile, { asset: variant, selected: focused.id === variant.id, onOpen: () => setFocus({ scope, id: variant.id }), action: writable &&
|
|
128
130
|
isReady(variant) && (_jsxs("button", { type: "button", className: confirming === variant.id
|
|
129
131
|
? 'rs-pill rs-tile-action is-confirming'
|
|
130
132
|
: 'rs-pill rs-tile-action', disabled: promote.state.status === 'promoting', onClick: () => setDefault(variant), children: [_jsx(Icon, { shape: "star", width: 10.5 }), confirming === variant.id ? 'Confirm' : 'Set as default'] })) }, variant.id))), pendingTile] })] }));
|
|
131
133
|
}
|
|
132
134
|
else if (hit) {
|
|
133
135
|
heading = (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "rs-crumb", onClick: () => setFocus(null), children: "Search" }), _jsx("span", { className: "rs-muted", children: "/" }), _jsx("h1", { className: "rs-heading", children: hit.name })] }));
|
|
134
|
-
content = _jsx(Detail, { item: hit, busy:
|
|
136
|
+
content = _jsx(Detail, { item: hit, busy: busy, onPick: onPick && (() => pick(hit)) });
|
|
135
137
|
}
|
|
136
138
|
else if (shown === null ? organizations.isLoading || libraries.isLoading : items === null) {
|
|
137
139
|
content = shown?.error ? null : (_jsx("div", { className: "rs-center", children: _jsx("span", { className: "rs-spinner" }) }));
|
|
138
140
|
}
|
|
139
141
|
else if (shown !== null && items?.length === 0 && !pendingTile) {
|
|
140
|
-
content = search.active ? (_jsx(Empty, { glyph: "\u2205", title: "No results", text: `Nothing matches “${search.query}”.` })) : (_jsx(Empty, { glyph: "\u2205", title: "No assets", text: "This library is empty.", children: writable && library !== null && (_jsx(FilePicker, { className: "rs-button rs-button-primary rs-button-sm", disabled:
|
|
142
|
+
content = search.active ? (_jsx(Empty, { glyph: "\u2205", title: "No results", text: `Nothing matches “${search.query}”.` })) : (_jsx(Empty, { glyph: "\u2205", title: "No assets", text: "This library is empty.", children: writable && library !== null && (_jsx(FilePicker, { className: "rs-button rs-button-primary rs-button-sm", disabled: pending !== null, onFile: (file) => void send(file, null), children: "Upload files" })) }));
|
|
141
143
|
}
|
|
142
144
|
else if (shown !== null && items) {
|
|
143
|
-
content = (_jsxs(_Fragment, { children: [_jsxs(
|
|
145
|
+
content = (_jsxs(_Fragment, { children: [_jsxs(TileGrid, { children: [pendingTile, search.active
|
|
144
146
|
? search.hits?.map((entry) => (_jsx(Tile, { asset: entry, onOpen: () => setFocus({ scope, id: entry.id }) }, entry.id)))
|
|
145
147
|
: assets.assets?.map((asset) => {
|
|
146
148
|
const count = asset.variants?.filter(Boolean).length ?? 0;
|
|
@@ -160,12 +162,12 @@ function Browser({ onPick, onError, }) {
|
|
|
160
162
|
};
|
|
161
163
|
return (_jsxs("div", { className: open ? 'rs-library is-expanded' : 'rs-library', children: [_jsxs("button", { type: "button", className: "rs-sidebar-item rs-library-row", disabled: entry.access === null, onMouseEnter: warm, onFocus: warm, onClick: () => navigation.openLibrary(entry), children: [_jsx(Icon, { shape: "grid" }), _jsx("span", { className: "rs-library-name", children: entry.name }), _jsx("span", { className: open ? 'rs-sidebar-count is-active' : 'rs-sidebar-count', children: COUNT.format(entry.assetsCount ?? 0) })] }), _jsx("div", { className: open ? 'rs-library-menu is-expanded' : 'rs-library-menu', "aria-hidden": !open, children: _jsxs("div", { children: [_jsxs("button", { type: "button", tabIndex: open ? 0 : -1, className: open && !search.active && opened === null
|
|
162
164
|
? 'rs-sidebar-item is-active'
|
|
163
|
-
: 'rs-sidebar-item', onClick: toGrid, children: [_jsx(Icon, { shape: "circle" }), "All Assets"] }), _jsxs(FilePicker, { className: "rs-sidebar-item", disabled: !open || entry.access !== 'write', focusable: open, onFile: (file) => {
|
|
165
|
+
: 'rs-sidebar-item', onClick: toGrid, children: [_jsx(Icon, { shape: "circle" }), "All Assets"] }), _jsxs(FilePicker, { className: "rs-sidebar-item", disabled: !open || entry.access !== 'write' || pending !== null, focusable: open, onFile: (file) => {
|
|
164
166
|
toGrid();
|
|
165
167
|
void send(file, null);
|
|
166
168
|
}, children: [_jsx(Icon, { shape: "upload" }), "Upload"] })] }) })] }, entry.id));
|
|
167
169
|
})] }), _jsxs("div", { className: "rs-sidebar-footer", children: [_jsx("span", { className: "rs-sidebar-item rs-muted", children: session.isSignedIn ? (session.userName ?? 'Signed in') : 'API key' }), _jsx("button", { type: "button", className: "rs-sidebar-item", onClick: () => void session.signOut(), children: "Sign out" })] })] }), _jsxs("section", { className: "rs-main", "aria-label": "Assets", onDragEnter: (event) => {
|
|
168
|
-
if (!dropTarget || !event.dataTransfer.types.includes('Files'))
|
|
170
|
+
if (!dropTarget || pending !== null || !event.dataTransfer.types.includes('Files'))
|
|
169
171
|
return;
|
|
170
172
|
dragDepth.current += 1;
|
|
171
173
|
setDragging(true);
|
|
@@ -183,6 +185,6 @@ function Browser({ onPick, onError, }) {
|
|
|
183
185
|
const file = event.dataTransfer.files[0];
|
|
184
186
|
if (file && dropTarget)
|
|
185
187
|
void send(file, versions ? opened.id : null);
|
|
186
|
-
}, children: [_jsxs("header", { className: "rs-header", children: [heading, _jsx("span", { className: "rs-muted rs-small", children: status }), _jsx(Progress, { upload: upload.state, promote: promote.state }), _jsxs("div", { className: "rs-search", children: [_jsx(Icon, { shape: "search", width: 12.25 }), _jsx("input", { ref: searchInput, className: "rs-input", "aria-label": "Search Raster", placeholder: library === null ? 'Search every library…' : `Search ${library.name}…`, value: query, onChange: (event) => navigation.setQuery(event.target.value) }), query !== '' && (_jsx("button", { type: "button", className: "rs-icon-button", "aria-label": "Clear search", onClick: () => navigation.setQuery(''), children: _jsx(Icon, { shape: "x", width: 10.5 }) }))] }), versions && writable && (_jsxs(FilePicker, { className: "rs-button rs-button-sm", disabled:
|
|
188
|
+
}, children: [_jsxs("header", { className: "rs-header", children: [heading, _jsx("span", { className: "rs-muted rs-small", children: status }), _jsx(Progress, { upload: upload.state, promote: promote.state }), _jsxs("div", { className: "rs-search", children: [_jsx(Icon, { shape: "search", width: 12.25 }), _jsx("input", { ref: searchInput, className: "rs-input", "aria-label": "Search Raster", placeholder: library === null ? 'Search every library…' : `Search ${library.name}…`, value: query, onChange: (event) => navigation.setQuery(event.target.value) }), query !== '' && (_jsx("button", { type: "button", className: "rs-icon-button", "aria-label": "Clear search", onClick: () => navigation.setQuery(''), children: _jsx(Icon, { shape: "x", width: 10.5 }) }))] }), versions && writable && (_jsxs(FilePicker, { className: "rs-button rs-button-sm", disabled: pending !== null, onFile: (file) => void send(file, opened.id), children: [_jsx(Icon, { shape: "upload", width: 12.25 }), "Upload variant"] })), _jsx("button", { type: "button", className: "rs-button rs-button-sm", onClick: navigation.refresh, children: "Refresh" })] }), _jsxs("div", { className: "rs-content", children: [organizations.error && _jsx(ErrorCard, { error: organizations.error, onError: onError }), libraries.error && _jsx(ErrorCard, { error: libraries.error, onError: onError }), shown?.error && _jsx(ErrorCard, { error: shown.error, onError: onError }), read.error && _jsx(ErrorCard, { error: read.error, onError: onError }), upload.state.status === 'error' && (_jsx(ErrorCard, { error: upload.state.error, onError: onError })), promote.state.status === 'error' && (_jsx(ErrorCard, { error: promote.state.error, onError: onError })), content] }), _jsx("div", { className: dragging ? 'rs-drop is-active' : 'rs-drop' })] })] }));
|
|
187
189
|
}
|
|
188
190
|
//# sourceMappingURL=raster-picker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raster-picker.js","sourceRoot":"","sources":["../src/raster-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAkB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAKN,OAAO,GACP,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,QAAQ,EAER,QAAQ,EACR,IAAI,GACJ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EA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,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,EAClF,SAAS,CAAC,KAAK,IAAI,KAAC,SAAS,IAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,EAC1E,KAAK,EAAE,KAAK,IAAI,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,EACnE,IAAI,CAAC,KAAK,IAAI,KAAC,SAAS,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,EAChE,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,CACnC,KAAC,SAAS,IAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,CAC1D,EACA,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,CACpC,KAAC,SAAS,IAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,CAC3D,EACA,OAAO,IACH,EACN,cAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,GAAI,IACrD,IACR,CACH,CAAA;AACF,CAAC","sourcesContent":["import { useMutation } from '@tanstack/react-query'\nimport { type ReactNode, useRef, useState } from 'react'\n\nimport {\n\ttype Asset,\n\ttype AssetVariant,\n\ttype RasterApiError,\n\ttype SearchHit,\n\tisReady,\n} from '@raster-app/sdk'\n\nimport { useRasterClient } from './context.js'\nimport { Icon } from './icons.js'\nimport {\n\tBrand,\n\tDetail,\n\tEmpty,\n\tErrorCard,\n\tFilePicker,\n\tOrganizationSwitcher,\n\tPendingTile,\n\tProgress,\n\ttype ReportError,\n\tSentinel,\n\tTile,\n} from './picker-parts.js'\nimport { SignIn } from './picker-sign-in.js'\nimport { useAssetSearch } from './use-asset-search.js'\nimport { useAssetUpload } from './use-asset-upload.js'\nimport { useAssets, usePrefetchAssets } from './use-assets.js'\nimport { useLibraries, usePrefetchLibraries } from './use-libraries.js'\nimport { useRasterNavigation } from './use-navigation.js'\nimport { useOrganizations } from './use-organizations.js'\nimport { usePromoteVariant } from './use-promote-variant.js'\nimport { useSession } from './use-session.js'\n\nexport type RasterPickerProps = {\n\t/**\n\t * The picked asset, whole whether it came from a library, a search or an asset's versions, and\n\t * its organization. `getFullSizeUrl(asset)` is the image.\n\t */\n\tonPick: (asset: Asset, organizationId: string) => void\n\t/** Binds the device sign-in to this organization; any other grant fails. */\n\torganizationId?: string\n\t/** The consent the device sign-in asks for: `org` when `organizationId` is set, else `user`. */\n\tscope?: 'user' | 'org'\n\t/** Each failure the picker shows, once, for the host to log. */\n\tonError?: (error: RasterApiError) => void\n\t/** Follows the system's color scheme when unset. */\n\ttheme?: 'light' | 'dark'\n}\n\nconst COUNT = new Intl.NumberFormat('en-US', { notation: 'compact' })\n\n/** A file on its way in, which the grid shows until Raster has processed it. */\ntype Pending = { name: string; preview: string; parentId: string | null }\n\n/**\n * Raster's asset picker, drawn as Raster draws it (`@raster-app/react/styles.css`): sign-in, the\n * organization's libraries, search and uploads. A tile opens its asset large, to pick or open in\n * Raster, over its versions with the default to set. It fills its container, inside a\n * `RasterProvider`.\n */\nexport function RasterPicker({ onPick, organizationId, scope, onError, theme }: RasterPickerProps) {\n\tconst { credentials, isConfigured } = useSession()\n\n\tlet body = (\n\t\t<div className=\"rs-center\">\n\t\t\t<span className=\"rs-spinner\" />\n\t\t</div>\n\t)\n\tif (credentials !== undefined && !isConfigured) {\n\t\tbody = (\n\t\t\t<SignIn\n\t\t\t\torganizationId={organizationId}\n\t\t\t\tscope={scope ?? (organizationId === undefined ? 'user' : 'org')}\n\t\t\t\tonError={onError}\n\t\t\t/>\n\t\t)\n\t} else if (isConfigured) {\n\t\tbody = <Browser onPick={onPick} onError={onError} />\n\t}\n\treturn (\n\t\t<div className=\"rs rs-picker\" data-theme={theme}>\n\t\t\t{body}\n\t\t</div>\n\t)\n}\n\nfunction Browser({\n\tonPick,\n\tonError,\n}: {\n\tonPick: RasterPickerProps['onPick']\n\tonError: ReportError\n}) {\n\tconst client = useRasterClient()\n\tconst session = useSession()\n\tconst organizations = useOrganizations()\n\tconst navigation = useRasterNavigation({ organizations: organizations.data ?? null })\n\tconst { organizationId, library, query } = navigation\n\tconst organization = organizations.data?.find((entry) => entry.id === organizationId)\n\tconst libraries = useLibraries({ organizationId, organizationName: organization?.name ?? null })\n\tconst assets = useAssets({ organizationId, libraryId: library?.id ?? null })\n\tconst search = useAssetSearch(\n\t\torganizationId === null ? null : { organizationId, libraryId: library?.id ?? null },\n\t\tquery\n\t)\n\tconst upload = useAssetUpload()\n\tconst promote = usePromoteVariant()\n\tconst read = useMutation<Asset, RasterApiError, Parameters<typeof client.assets.get>[0]>({\n\t\tmutationFn: (options) => client.assets.get(options),\n\t})\n\tconst prefetchAssets = usePrefetchAssets()\n\tconst prefetchLibraries = usePrefetchLibraries()\n\tconst searchInput = useRef<HTMLInputElement>(null)\n\tconst [pending, setPending] = useState<Pending | null>(null)\n\tconst [confirming, setConfirming] = useState<string | null>(null)\n\tconst [dragging, setDragging] = useState(false)\n\tconst dragDepth = useRef(0)\n\t// The version shown large, or the search hit opened, for the scope it was chosen in.\n\tconst [focus, setFocus] = useState<{ scope: string; id: string } | null>(null)\n\tconst scope = [organizationId, library?.id, navigation.asset?.id, query].join('/')\n\tconst focusId = focus?.scope === scope ? focus.id : null\n\n\tconst access = libraries.data?.find((entry) => entry.id === library?.id)?.access ?? null\n\tconst writable = access === 'write'\n\t// The asset as the list last read it, which refetches after an upload or a promote.\n\tconst opened =\n\t\tnavigation.asset === null\n\t\t\t? null\n\t\t\t: (assets.assets?.find((entry) => entry.id === navigation.asset?.id) ?? navigation.asset)\n\tconst versions = !search.active && opened !== null\n\tconst variants = (opened?.variants ?? []).filter(\n\t\t(variant): variant is AssetVariant => variant !== null\n\t)\n\tconst shown = search.active ? search : library === null ? null : assets\n\tconst items = search.active ? search.hits : assets.assets\n\tconst hit = search.active ? (search.hits?.find((entry) => entry.id === focusId) ?? null) : null\n\n\t/** Hand the host the whole asset: a search hit or a variant carries less, so it is read first. */\n\tfunction pick(item: Asset | SearchHit | AssetVariant) {\n\t\tif (organizationId === null) return\n\t\tconst loaded = assets.assets?.find((entry) => entry.id === item.id)\n\t\tif (loaded) {\n\t\t\tonPick(loaded, organizationId)\n\t\t\treturn\n\t\t}\n\t\t// A variant lives in its original's library, which is the open one.\n\t\tconst libraryId = ('libraryId' in item ? item.libraryId : null) ?? library?.id\n\t\tif (!libraryId) return\n\t\tread.mutate(\n\t\t\t{ organizationId, libraryId, assetId: item.id },\n\t\t\t{ onSuccess: (asset) => onPick(asset, organizationId) }\n\t\t)\n\t}\n\n\t/** Upload one file into the open library, or as a variant of `parentId`. */\n\tasync function send(file: File, parentId: string | null) {\n\t\tif (organizationId === null || library === null || !writable) return\n\t\tconst preview = URL.createObjectURL(file)\n\t\tsetPending({ name: file.name, preview, parentId })\n\t\tawait upload.upload({ organizationId, libraryId: library.id, parentId, source: file })\n\t\tURL.revokeObjectURL(preview)\n\t\t// A later upload may have taken the placeholder over by now.\n\t\tsetPending((current) => (current?.preview === preview ? null : current))\n\t}\n\n\t/** The first press asks to confirm; the second promotes. */\n\tfunction setDefault(variant: AssetVariant) {\n\t\tif (confirming !== variant.id) {\n\t\t\tsetConfirming(variant.id)\n\t\t\treturn\n\t\t}\n\t\tsetConfirming(null)\n\t\tif (organizationId === null || library === null || opened === null) return\n\t\tvoid promote.promote({\n\t\t\torganizationId,\n\t\t\tlibraryId: library.id,\n\t\t\tassetId: opened.id,\n\t\t\tvariantId: variant.id,\n\t\t})\n\t}\n\n\tconst pendingTile = pending !== null &&\n\t\t!search.active &&\n\t\tpending.parentId === (opened?.id ?? null) && (\n\t\t\t<PendingTile\n\t\t\t\tname={pending.name}\n\t\t\t\tpreview={pending.preview}\n\t\t\t\tstatus={upload.state.status === 'uploading' ? 'Uploading' : 'Processing'}\n\t\t\t/>\n\t\t)\n\n\tlet status = ''\n\tif (search.active) status = search.isSearching ? 'Searching' : `${search.found} found`\n\telse if (library !== null && !versions) status = `${assets.assets?.length ?? 0} loaded`\n\n\tlet heading: ReactNode = (\n\t\t<>\n\t\t\t<h1 className=\"rs-heading\">{search.active ? 'Search' : (library?.name ?? 'Libraries')}</h1>\n\t\t\t{!search.active && library !== null && (\n\t\t\t\t<span className=\"rs-sidebar-count is-active\">{access ?? 'no access'}</span>\n\t\t\t)}\n\t\t</>\n\t)\n\tlet content: ReactNode = (\n\t\t<Empty glyph=\"grid\" title=\"Choose a library\" text=\"Or search every library.\" />\n\t)\n\tif (versions) {\n\t\tconst focused = [opened, ...variants].find((entry) => entry.id === focusId) ?? opened\n\t\theading = (\n\t\t\t<>\n\t\t\t\t<button type=\"button\" className=\"rs-crumb\" onClick={() => navigation.openAsset(null)}>\n\t\t\t\t\t{library?.name}\n\t\t\t\t</button>\n\t\t\t\t<span className=\"rs-muted\">/</span>\n\t\t\t\t<h1 className=\"rs-heading\">{opened.name}</h1>\n\t\t\t\t<span className=\"rs-sidebar-count is-active\">{variants.length + 1} versions</span>\n\t\t\t</>\n\t\t)\n\t\tcontent = (\n\t\t\t<>\n\t\t\t\t<Detail item={focused} busy={read.isPending} onPick={() => pick(focused)} />\n\t\t\t\t<div className=\"rs-grid\">\n\t\t\t\t\t<Tile\n\t\t\t\t\t\tasset={opened}\n\t\t\t\t\t\tselected={focused.id === opened.id}\n\t\t\t\t\t\tonOpen={() => setFocus({ scope, id: opened.id })}\n\t\t\t\t\t\tbadge={\n\t\t\t\t\t\t\t<span className=\"rs-pill rs-tile-badge\">\n\t\t\t\t\t\t\t\t<Icon shape=\"star\" solid width={10.5} />\n\t\t\t\t\t\t\t\tDefault\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t{variants.map((variant) => (\n\t\t\t\t\t\t<Tile\n\t\t\t\t\t\t\tkey={variant.id}\n\t\t\t\t\t\t\tasset={variant}\n\t\t\t\t\t\t\tselected={focused.id === variant.id}\n\t\t\t\t\t\t\tonOpen={() => setFocus({ scope, id: variant.id })}\n\t\t\t\t\t\t\taction={\n\t\t\t\t\t\t\t\twritable &&\n\t\t\t\t\t\t\t\tisReady(variant) && (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\tconfirming === variant.id\n\t\t\t\t\t\t\t\t\t\t\t\t? 'rs-pill rs-tile-action is-confirming'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'rs-pill rs-tile-action'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tdisabled={promote.state.status === 'promoting'}\n\t\t\t\t\t\t\t\t\t\tonClick={() => setDefault(variant)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Icon shape=\"star\" width={10.5} />\n\t\t\t\t\t\t\t\t\t\t{confirming === variant.id ? 'Confirm' : 'Set as default'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t\t{pendingTile}\n\t\t\t\t</div>\n\t\t\t</>\n\t\t)\n\t} else if (hit) {\n\t\theading = (\n\t\t\t<>\n\t\t\t\t<button type=\"button\" className=\"rs-crumb\" onClick={() => setFocus(null)}>\n\t\t\t\t\tSearch\n\t\t\t\t</button>\n\t\t\t\t<span className=\"rs-muted\">/</span>\n\t\t\t\t<h1 className=\"rs-heading\">{hit.name}</h1>\n\t\t\t</>\n\t\t)\n\t\tcontent = <Detail item={hit} busy={read.isPending} onPick={() => pick(hit)} />\n\t} else if (shown === null ? organizations.isLoading || libraries.isLoading : items === null) {\n\t\tcontent = shown?.error ? null : (\n\t\t\t<div className=\"rs-center\">\n\t\t\t\t<span className=\"rs-spinner\" />\n\t\t\t</div>\n\t\t)\n\t} else if (shown !== null && items?.length === 0 && !pendingTile) {\n\t\tcontent = search.active ? (\n\t\t\t<Empty glyph=\"∅\" title=\"No results\" text={`Nothing matches “${search.query}”.`} />\n\t\t) : (\n\t\t\t<Empty glyph=\"∅\" title=\"No assets\" text=\"This library is empty.\">\n\t\t\t\t{writable && library !== null && (\n\t\t\t\t\t<FilePicker\n\t\t\t\t\t\tclassName=\"rs-button rs-button-primary rs-button-sm\"\n\t\t\t\t\t\tdisabled={false}\n\t\t\t\t\t\tonFile={(file) => void send(file, null)}\n\t\t\t\t\t>\n\t\t\t\t\t\tUpload files\n\t\t\t\t\t</FilePicker>\n\t\t\t\t)}\n\t\t\t</Empty>\n\t\t)\n\t} else if (shown !== null && items) {\n\t\tcontent = (\n\t\t\t<>\n\t\t\t\t<div className=\"rs-grid\">\n\t\t\t\t\t{pendingTile}\n\t\t\t\t\t{search.active\n\t\t\t\t\t\t? search.hits?.map((entry) => (\n\t\t\t\t\t\t\t\t<Tile\n\t\t\t\t\t\t\t\t\tkey={entry.id}\n\t\t\t\t\t\t\t\t\tasset={entry}\n\t\t\t\t\t\t\t\t\tonOpen={() => setFocus({ scope, id: entry.id })}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t: assets.assets?.map((asset) => {\n\t\t\t\t\t\t\t\tconst count = asset.variants?.filter(Boolean).length ?? 0\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<Tile\n\t\t\t\t\t\t\t\t\t\tkey={asset.id}\n\t\t\t\t\t\t\t\t\t\tasset={asset}\n\t\t\t\t\t\t\t\t\t\tonOpen={() => {\n\t\t\t\t\t\t\t\t\t\t\tsetConfirming(null)\n\t\t\t\t\t\t\t\t\t\t\tnavigation.openAsset(asset)\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\tbadge={\n\t\t\t\t\t\t\t\t\t\t\tcount > 0 && (\n\t\t\t\t\t\t\t\t\t\t\t\t<span className=\"rs-pill rs-tile-badge\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Icon shape=\"layers\" width={10.5} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t{count + 1} versions\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t\t{shown.hasMore && (\n\t\t\t\t\t<div className=\"rs-center\">\n\t\t\t\t\t\t<Sentinel key={items.length} onVisible={shown.loadMore} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</>\n\t\t)\n\t}\n\n\tconst dropTarget = writable && library !== null && !search.active\n\n\treturn (\n\t\t<>\n\t\t\t<aside className=\"rs-sidebar\">\n\t\t\t\t<Brand />\n\t\t\t\t<OrganizationSwitcher\n\t\t\t\t\torganizations={organizations.data ?? []}\n\t\t\t\t\tcurrent={organization}\n\t\t\t\t\tonIntent={(entry) =>\n\t\t\t\t\t\tentry.id !== organizationId && prefetchLibraries(entry.id, entry.name)\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={navigation.selectOrganization}\n\t\t\t\t/>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclassName={search.active ? 'rs-sidebar-item is-active' : 'rs-sidebar-item'}\n\t\t\t\t\tonClick={() => searchInput.current?.focus()}\n\t\t\t\t>\n\t\t\t\t\t<Icon shape=\"search\" />\n\t\t\t\t\tSearch\n\t\t\t\t</button>\n\t\t\t\t<nav className=\"rs-scroll\">\n\t\t\t\t\t<h2 className=\"rs-sidebar-heading\">Libraries</h2>\n\t\t\t\t\t{libraries.data?.map((entry) => {\n\t\t\t\t\t\tconst open = entry.id === library?.id\n\t\t\t\t\t\tconst warm = () => organizationId !== null && prefetchAssets(organizationId, entry.id)\n\t\t\t\t\t\tconst toGrid = () => {\n\t\t\t\t\t\t\tnavigation.setQuery('')\n\t\t\t\t\t\t\tnavigation.openAsset(null)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div key={entry.id} className={open ? 'rs-library is-expanded' : 'rs-library'}>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tclassName=\"rs-sidebar-item rs-library-row\"\n\t\t\t\t\t\t\t\t\tdisabled={entry.access === null}\n\t\t\t\t\t\t\t\t\tonMouseEnter={warm}\n\t\t\t\t\t\t\t\t\tonFocus={warm}\n\t\t\t\t\t\t\t\t\tonClick={() => navigation.openLibrary(entry)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Icon shape=\"grid\" />\n\t\t\t\t\t\t\t\t\t<span className=\"rs-library-name\">{entry.name}</span>\n\t\t\t\t\t\t\t\t\t<span className={open ? 'rs-sidebar-count is-active' : 'rs-sidebar-count'}>\n\t\t\t\t\t\t\t\t\t\t{COUNT.format(entry.assetsCount ?? 0)}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={open ? 'rs-library-menu is-expanded' : 'rs-library-menu'}\n\t\t\t\t\t\t\t\t\taria-hidden={!open}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\ttabIndex={open ? 0 : -1}\n\t\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\t\topen && !search.active && opened === null\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'rs-sidebar-item is-active'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'rs-sidebar-item'\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonClick={toGrid}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Icon shape=\"circle\" />\n\t\t\t\t\t\t\t\t\t\t\tAll Assets\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t<FilePicker\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"rs-sidebar-item\"\n\t\t\t\t\t\t\t\t\t\t\tdisabled={!open || entry.access !== 'write'}\n\t\t\t\t\t\t\t\t\t\t\tfocusable={open}\n\t\t\t\t\t\t\t\t\t\t\tonFile={(file) => {\n\t\t\t\t\t\t\t\t\t\t\t\ttoGrid()\n\t\t\t\t\t\t\t\t\t\t\t\tvoid send(file, null)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Icon shape=\"upload\" />\n\t\t\t\t\t\t\t\t\t\t\tUpload\n\t\t\t\t\t\t\t\t\t\t</FilePicker>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</nav>\n\t\t\t\t<div className=\"rs-sidebar-footer\">\n\t\t\t\t\t<span className=\"rs-sidebar-item rs-muted\">\n\t\t\t\t\t\t{session.isSignedIn ? (session.userName ?? 'Signed in') : 'API key'}\n\t\t\t\t\t</span>\n\t\t\t\t\t<button type=\"button\" className=\"rs-sidebar-item\" onClick={() => void session.signOut()}>\n\t\t\t\t\t\tSign out\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</aside>\n\t\t\t<section\n\t\t\t\tclassName=\"rs-main\"\n\t\t\t\taria-label=\"Assets\"\n\t\t\t\tonDragEnter={(event) => {\n\t\t\t\t\tif (!dropTarget || !event.dataTransfer.types.includes('Files')) return\n\t\t\t\t\tdragDepth.current += 1\n\t\t\t\t\tsetDragging(true)\n\t\t\t\t}}\n\t\t\t\tonDragOver={(event) => {\n\t\t\t\t\tif (dropTarget) event.preventDefault()\n\t\t\t\t}}\n\t\t\t\tonDragLeave={() => {\n\t\t\t\t\tdragDepth.current = Math.max(0, dragDepth.current - 1)\n\t\t\t\t\tif (dragDepth.current === 0) setDragging(false)\n\t\t\t\t}}\n\t\t\t\tonDrop={(event) => {\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\tdragDepth.current = 0\n\t\t\t\t\tsetDragging(false)\n\t\t\t\t\tconst file = event.dataTransfer.files[0]\n\t\t\t\t\tif (file && dropTarget) void send(file, versions ? opened.id : null)\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<header className=\"rs-header\">\n\t\t\t\t\t{heading}\n\t\t\t\t\t<span className=\"rs-muted rs-small\">{status}</span>\n\t\t\t\t\t<Progress upload={upload.state} promote={promote.state} />\n\t\t\t\t\t<div className=\"rs-search\">\n\t\t\t\t\t\t<Icon shape=\"search\" width={12.25} />\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tref={searchInput}\n\t\t\t\t\t\t\tclassName=\"rs-input\"\n\t\t\t\t\t\t\taria-label=\"Search Raster\"\n\t\t\t\t\t\t\tplaceholder={library === null ? 'Search every library…' : `Search ${library.name}…`}\n\t\t\t\t\t\t\tvalue={query}\n\t\t\t\t\t\t\tonChange={(event) => navigation.setQuery(event.target.value)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{query !== '' && (\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tclassName=\"rs-icon-button\"\n\t\t\t\t\t\t\t\taria-label=\"Clear search\"\n\t\t\t\t\t\t\t\tonClick={() => navigation.setQuery('')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Icon shape=\"x\" width={10.5} />\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t\t{versions && writable && (\n\t\t\t\t\t\t<FilePicker\n\t\t\t\t\t\t\tclassName=\"rs-button rs-button-sm\"\n\t\t\t\t\t\t\tdisabled={false}\n\t\t\t\t\t\t\tonFile={(file) => void send(file, opened.id)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon shape=\"upload\" width={12.25} />\n\t\t\t\t\t\t\tUpload variant\n\t\t\t\t\t\t</FilePicker>\n\t\t\t\t\t)}\n\t\t\t\t\t<button type=\"button\" className=\"rs-button rs-button-sm\" onClick={navigation.refresh}>\n\t\t\t\t\t\tRefresh\n\t\t\t\t\t</button>\n\t\t\t\t</header>\n\t\t\t\t<div className=\"rs-content rs-scroll\">\n\t\t\t\t\t{organizations.error && <ErrorCard error={organizations.error} onError={onError} />}\n\t\t\t\t\t{libraries.error && <ErrorCard error={libraries.error} onError={onError} />}\n\t\t\t\t\t{shown?.error && <ErrorCard error={shown.error} onError={onError} />}\n\t\t\t\t\t{read.error && <ErrorCard error={read.error} onError={onError} />}\n\t\t\t\t\t{upload.state.status === 'error' && (\n\t\t\t\t\t\t<ErrorCard error={upload.state.error} onError={onError} />\n\t\t\t\t\t)}\n\t\t\t\t\t{promote.state.status === 'error' && (\n\t\t\t\t\t\t<ErrorCard error={promote.state.error} onError={onError} />\n\t\t\t\t\t)}\n\t\t\t\t\t{content}\n\t\t\t\t</div>\n\t\t\t\t<div className={dragging ? 'rs-drop is-active' : 'rs-drop'} />\n\t\t\t</section>\n\t\t</>\n\t)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"raster-picker.js","sourceRoot":"","sources":["../src/raster-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAkB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAKN,QAAQ,EACR,OAAO,GACP,MAAM,i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A,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,CACpC,KAAC,SAAS,IAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,CAC3D,EACA,OAAO,IACH,EACN,cAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,GAAI,IACrD,IACR,CACH,CAAA;AACF,CAAC","sourcesContent":["import { useMutation } from '@tanstack/react-query'\nimport { type ReactNode, useRef, useState } from 'react'\n\nimport {\n\ttype Asset,\n\ttype AssetVariant,\n\ttype RasterApiError,\n\ttype SearchHit,\n\tgetAsset,\n\tisReady,\n} from '@raster-app/sdk'\n\nimport { useRasterClient } from './context.js'\nimport { Icon } from './icons.js'\nimport {\n\tBrand,\n\tDetail,\n\tEmpty,\n\tErrorCard,\n\tFilePicker,\n\tOrganizationSwitcher,\n\tPendingTile,\n\tProgress,\n\ttype ReportError,\n\tSentinel,\n\tTile,\n\tTileGrid,\n} from './picker-parts.js'\nimport { SignIn } from './picker-sign-in.js'\nimport { useAssetSearch } from './use-asset-search.js'\nimport { useAssetUpload } from './use-asset-upload.js'\nimport { useAssets, usePrefetchAssets } from './use-assets.js'\nimport { useLibraries, usePrefetchLibraries } from './use-libraries.js'\nimport { useRasterNavigation } from './use-navigation.js'\nimport { useOrganizations } from './use-organizations.js'\nimport { usePromoteVariant } from './use-promote-variant.js'\nimport { useSession } from './use-session.js'\n\nexport type RasterPickerProps = {\n\t/**\n\t * The picked asset, whole whether it came from a library, a search or an asset's versions, and\n\t * its organization. `getFullSizeUrl(asset)` is the image. Without it, the picker only browses,\n\t * with no Pick asset button.\n\t */\n\tonPick?: (asset: Asset, organizationId: string) => void\n\t/** Binds the device sign-in to this organization; any other grant fails. */\n\torganizationId?: string\n\t/** The consent the device sign-in asks for: `org` when `organizationId` is set, else `user`. */\n\tscope?: 'user' | 'org'\n\t/** Each failure the picker shows, once, for the host to log. */\n\tonError?: (error: RasterApiError) => void\n\t/** Follows the system's color scheme when unset. */\n\ttheme?: 'light' | 'dark'\n}\n\nconst COUNT = new Intl.NumberFormat('en-US', { notation: 'compact' })\n\n/** A file on its way in, which the grid shows until Raster has processed it. */\ntype Pending = { name: string; preview: string; parentId: string | null }\n\n/**\n * Raster's asset picker, drawn as Raster draws it (`@raster-app/react/styles.css`): sign-in, the\n * organization's libraries, search and uploads. A tile opens its asset large, to pick or open in\n * Raster, over its versions with the default to set. It fills its container, inside a\n * `RasterProvider`.\n */\nexport function RasterPicker({ onPick, organizationId, scope, onError, theme }: RasterPickerProps) {\n\tconst { credentials, isConfigured } = useSession()\n\n\tlet body = (\n\t\t<div className=\"rs-center\">\n\t\t\t<span className=\"rs-spinner\" />\n\t\t</div>\n\t)\n\tif (credentials !== undefined && !isConfigured) {\n\t\tbody = (\n\t\t\t<SignIn\n\t\t\t\torganizationId={organizationId}\n\t\t\t\tscope={scope ?? (organizationId === undefined ? 'user' : 'org')}\n\t\t\t\tonError={onError}\n\t\t\t/>\n\t\t)\n\t} else if (isConfigured) {\n\t\tbody = <Browser onPick={onPick} onError={onError} />\n\t}\n\treturn (\n\t\t<div className=\"rs rs-picker\" data-theme={theme}>\n\t\t\t{body}\n\t\t</div>\n\t)\n}\n\nfunction Browser({\n\tonPick,\n\tonError,\n}: {\n\tonPick: RasterPickerProps['onPick']\n\tonError: ReportError\n}) {\n\tconst client = useRasterClient()\n\tconst session = useSession()\n\tconst organizations = useOrganizations()\n\tconst navigation = useRasterNavigation({ organizations: organizations.data ?? null })\n\tconst { organizationId, library, query } = navigation\n\tconst organization = organizations.data?.find((entry) => entry.id === organizationId)\n\tconst libraries = useLibraries({ organizationId, organizationName: organization?.name ?? null })\n\tconst assets = useAssets({ organizationId, libraryId: library?.id ?? null })\n\tconst search = useAssetSearch(\n\t\torganizationId === null ? null : { organizationId, libraryId: library?.id ?? null },\n\t\tquery\n\t)\n\tconst upload = useAssetUpload()\n\tconst promote = usePromoteVariant()\n\tconst read = useMutation<Asset, RasterApiError, Parameters<typeof getAsset>[1]>({\n\t\tmutationFn: (options) => getAsset(client, options),\n\t})\n\tconst prefetchAssets = usePrefetchAssets()\n\tconst prefetchLibraries = usePrefetchLibraries()\n\tconst searchInput = useRef<HTMLInputElement>(null)\n\tconst [pending, setPending] = useState<Pending | null>(null)\n\tconst [confirming, setConfirming] = useState<string | null>(null)\n\tconst [dragging, setDragging] = useState(false)\n\tconst dragDepth = useRef(0)\n\t// The version shown large, or the search hit opened, for the scope it was chosen in.\n\tconst [focus, setFocus] = useState<{ scope: string; id: string } | null>(null)\n\tconst scope = [organizationId, library?.id, navigation.asset?.id, query].join('/')\n\tconst focusId = focus?.scope === scope ? focus.id : null\n\n\tconst access = libraries.data?.find((entry) => entry.id === library?.id)?.access ?? null\n\tconst writable = access === 'write'\n\t// The asset as the list last read it, which refetches after an upload or a promote.\n\tconst opened =\n\t\tnavigation.asset === null\n\t\t\t? null\n\t\t\t: (assets.assets?.find((entry) => entry.id === navigation.asset?.id) ?? navigation.asset)\n\tconst versions = !search.active && opened !== null\n\tconst variants = (opened?.variants ?? []).filter(\n\t\t(variant): variant is AssetVariant => variant !== null\n\t)\n\tconst shown = search.active ? search : library === null ? null : assets\n\tconst items = search.active ? search.hits : assets.assets\n\tconst hit = search.active ? (search.hits?.find((entry) => entry.id === focusId) ?? null) : null\n\t// Until a promote lands, the cached asset is still the previous default.\n\tconst busy = read.isPending || promote.state.status === 'promoting'\n\n\t/** Hand the host the whole asset: a search hit or a variant carries less, so it is read first. */\n\tfunction pick(item: Asset | SearchHit | AssetVariant) {\n\t\tif (organizationId === null || onPick === undefined) return\n\t\tconst loaded = assets.assets?.find((entry) => entry.id === item.id)\n\t\tif (loaded) {\n\t\t\tonPick(loaded, organizationId)\n\t\t\treturn\n\t\t}\n\t\t// A variant lives in its original's library, which is the open one.\n\t\tconst libraryId = ('libraryId' in item ? item.libraryId : null) ?? library?.id\n\t\tif (!libraryId) return\n\t\tread.mutate(\n\t\t\t{ organizationId, libraryId, assetId: item.id },\n\t\t\t{ onSuccess: (asset) => onPick(asset, organizationId) }\n\t\t)\n\t}\n\n\t/** Upload one file into the open library, or as a variant of `parentId`. */\n\tasync function send(file: File, parentId: string | null) {\n\t\t// A second upload would cancel the one in flight.\n\t\tif (organizationId === null || library === null || !writable || pending !== null) return\n\t\tconst preview = URL.createObjectURL(file)\n\t\tsetPending({ name: file.name, preview, parentId })\n\t\tawait upload.upload({ organizationId, libraryId: library.id, parentId, source: file })\n\t\tURL.revokeObjectURL(preview)\n\t\tsetPending(null)\n\t}\n\n\t/** The first press asks to confirm; the second promotes. */\n\tfunction setDefault(variant: AssetVariant) {\n\t\tif (confirming !== variant.id) {\n\t\t\tsetConfirming(variant.id)\n\t\t\treturn\n\t\t}\n\t\tsetConfirming(null)\n\t\tif (organizationId === null || library === null || opened === null) return\n\t\tvoid promote.promote({\n\t\t\torganizationId,\n\t\t\tlibraryId: library.id,\n\t\t\tassetId: opened.id,\n\t\t\tvariantId: variant.id,\n\t\t})\n\t}\n\n\tconst pendingTile = pending !== null &&\n\t\t!search.active &&\n\t\tpending.parentId === (opened?.id ?? null) && (\n\t\t\t<PendingTile\n\t\t\t\tname={pending.name}\n\t\t\t\tpreview={pending.preview}\n\t\t\t\tstatus={upload.state.status === 'uploading' ? 'Uploading' : 'Processing'}\n\t\t\t/>\n\t\t)\n\n\tlet status = ''\n\tif (search.active) status = search.isSearching ? 'Searching' : `${search.found} found`\n\telse if (library !== null && !versions) status = `${assets.assets?.length ?? 0} loaded`\n\n\tlet heading: ReactNode = (\n\t\t<>\n\t\t\t<h1 className=\"rs-heading\">{search.active ? 'Search' : (library?.name ?? 'Libraries')}</h1>\n\t\t\t{!search.active && library !== null && (\n\t\t\t\t<span className=\"rs-sidebar-count is-active\">{access ?? 'no access'}</span>\n\t\t\t)}\n\t\t</>\n\t)\n\tlet content: ReactNode = (\n\t\t<Empty glyph=\"grid\" title=\"Choose a library\" text=\"Or search every library.\" />\n\t)\n\tif (versions) {\n\t\tconst focused = [opened, ...variants].find((entry) => entry.id === focusId) ?? opened\n\t\theading = (\n\t\t\t<>\n\t\t\t\t<button type=\"button\" className=\"rs-crumb\" onClick={() => navigation.openAsset(null)}>\n\t\t\t\t\t{library?.name}\n\t\t\t\t</button>\n\t\t\t\t<span className=\"rs-muted\">/</span>\n\t\t\t\t<h1 className=\"rs-heading\">{opened.name}</h1>\n\t\t\t\t<span className=\"rs-sidebar-count is-active\">{variants.length + 1} versions</span>\n\t\t\t</>\n\t\t)\n\t\tcontent = (\n\t\t\t<>\n\t\t\t\t<Detail item={focused} busy={busy} onPick={onPick && (() => pick(focused))} />\n\t\t\t\t<TileGrid>\n\t\t\t\t\t<Tile\n\t\t\t\t\t\tasset={opened}\n\t\t\t\t\t\tselected={focused.id === opened.id}\n\t\t\t\t\t\tonOpen={() => setFocus({ scope, id: opened.id })}\n\t\t\t\t\t\tbadge={\n\t\t\t\t\t\t\t<span className=\"rs-pill rs-tile-badge\">\n\t\t\t\t\t\t\t\t<Icon shape=\"star\" solid width={10.5} />\n\t\t\t\t\t\t\t\tDefault\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t{variants.map((variant) => (\n\t\t\t\t\t\t<Tile\n\t\t\t\t\t\t\tkey={variant.id}\n\t\t\t\t\t\t\tasset={variant}\n\t\t\t\t\t\t\tselected={focused.id === variant.id}\n\t\t\t\t\t\t\tonOpen={() => setFocus({ scope, id: variant.id })}\n\t\t\t\t\t\t\taction={\n\t\t\t\t\t\t\t\twritable &&\n\t\t\t\t\t\t\t\tisReady(variant) && (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\tconfirming === variant.id\n\t\t\t\t\t\t\t\t\t\t\t\t? 'rs-pill rs-tile-action is-confirming'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'rs-pill rs-tile-action'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tdisabled={promote.state.status === 'promoting'}\n\t\t\t\t\t\t\t\t\t\tonClick={() => setDefault(variant)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Icon shape=\"star\" width={10.5} />\n\t\t\t\t\t\t\t\t\t\t{confirming === variant.id ? 'Confirm' : 'Set as default'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t\t{pendingTile}\n\t\t\t\t</TileGrid>\n\t\t\t</>\n\t\t)\n\t} else if (hit) {\n\t\theading = (\n\t\t\t<>\n\t\t\t\t<button type=\"button\" className=\"rs-crumb\" onClick={() => setFocus(null)}>\n\t\t\t\t\tSearch\n\t\t\t\t</button>\n\t\t\t\t<span className=\"rs-muted\">/</span>\n\t\t\t\t<h1 className=\"rs-heading\">{hit.name}</h1>\n\t\t\t</>\n\t\t)\n\t\tcontent = <Detail item={hit} busy={busy} onPick={onPick && (() => pick(hit))} />\n\t} else if (shown === null ? organizations.isLoading || libraries.isLoading : items === null) {\n\t\tcontent = shown?.error ? null : (\n\t\t\t<div className=\"rs-center\">\n\t\t\t\t<span className=\"rs-spinner\" />\n\t\t\t</div>\n\t\t)\n\t} else if (shown !== null && items?.length === 0 && !pendingTile) {\n\t\tcontent = search.active ? (\n\t\t\t<Empty glyph=\"∅\" title=\"No results\" text={`Nothing matches “${search.query}”.`} />\n\t\t) : (\n\t\t\t<Empty glyph=\"∅\" title=\"No assets\" text=\"This library is empty.\">\n\t\t\t\t{writable && library !== null && (\n\t\t\t\t\t<FilePicker\n\t\t\t\t\t\tclassName=\"rs-button rs-button-primary rs-button-sm\"\n\t\t\t\t\t\tdisabled={pending !== null}\n\t\t\t\t\t\tonFile={(file) => void send(file, null)}\n\t\t\t\t\t>\n\t\t\t\t\t\tUpload files\n\t\t\t\t\t</FilePicker>\n\t\t\t\t)}\n\t\t\t</Empty>\n\t\t)\n\t} else if (shown !== null && items) {\n\t\tcontent = (\n\t\t\t<>\n\t\t\t\t<TileGrid>\n\t\t\t\t\t{pendingTile}\n\t\t\t\t\t{search.active\n\t\t\t\t\t\t? search.hits?.map((entry) => (\n\t\t\t\t\t\t\t\t<Tile\n\t\t\t\t\t\t\t\t\tkey={entry.id}\n\t\t\t\t\t\t\t\t\tasset={entry}\n\t\t\t\t\t\t\t\t\tonOpen={() => setFocus({ scope, id: entry.id })}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))\n\t\t\t\t\t\t: assets.assets?.map((asset) => {\n\t\t\t\t\t\t\t\tconst count = asset.variants?.filter(Boolean).length ?? 0\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<Tile\n\t\t\t\t\t\t\t\t\t\tkey={asset.id}\n\t\t\t\t\t\t\t\t\t\tasset={asset}\n\t\t\t\t\t\t\t\t\t\tonOpen={() => {\n\t\t\t\t\t\t\t\t\t\t\tsetConfirming(null)\n\t\t\t\t\t\t\t\t\t\t\tnavigation.openAsset(asset)\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\tbadge={\n\t\t\t\t\t\t\t\t\t\t\tcount > 0 && (\n\t\t\t\t\t\t\t\t\t\t\t\t<span className=\"rs-pill rs-tile-badge\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Icon shape=\"layers\" width={10.5} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t{count + 1} versions\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})}\n\t\t\t\t</TileGrid>\n\t\t\t\t{shown.hasMore && (\n\t\t\t\t\t<div className=\"rs-center\">\n\t\t\t\t\t\t<Sentinel key={items.length} onVisible={shown.loadMore} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</>\n\t\t)\n\t}\n\n\tconst dropTarget = writable && library !== null && !search.active\n\n\treturn (\n\t\t<>\n\t\t\t<aside className=\"rs-sidebar\">\n\t\t\t\t<Brand />\n\t\t\t\t<OrganizationSwitcher\n\t\t\t\t\torganizations={organizations.data ?? []}\n\t\t\t\t\tcurrent={organization}\n\t\t\t\t\tonIntent={(entry) =>\n\t\t\t\t\t\tentry.id !== organizationId && prefetchLibraries(entry.id, entry.name)\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={navigation.selectOrganization}\n\t\t\t\t/>\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclassName={search.active ? 'rs-sidebar-item is-active' : 'rs-sidebar-item'}\n\t\t\t\t\tonClick={() => searchInput.current?.focus()}\n\t\t\t\t>\n\t\t\t\t\t<Icon shape=\"search\" />\n\t\t\t\t\tSearch\n\t\t\t\t</button>\n\t\t\t\t<nav className=\"rs-scroll\">\n\t\t\t\t\t<h2 className=\"rs-sidebar-heading\">Libraries</h2>\n\t\t\t\t\t{libraries.data?.map((entry) => {\n\t\t\t\t\t\tconst open = entry.id === library?.id\n\t\t\t\t\t\tconst warm = () => organizationId !== null && prefetchAssets(organizationId, entry.id)\n\t\t\t\t\t\tconst toGrid = () => {\n\t\t\t\t\t\t\tnavigation.setQuery('')\n\t\t\t\t\t\t\tnavigation.openAsset(null)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div key={entry.id} className={open ? 'rs-library is-expanded' : 'rs-library'}>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tclassName=\"rs-sidebar-item rs-library-row\"\n\t\t\t\t\t\t\t\t\tdisabled={entry.access === null}\n\t\t\t\t\t\t\t\t\tonMouseEnter={warm}\n\t\t\t\t\t\t\t\t\tonFocus={warm}\n\t\t\t\t\t\t\t\t\tonClick={() => navigation.openLibrary(entry)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Icon shape=\"grid\" />\n\t\t\t\t\t\t\t\t\t<span className=\"rs-library-name\">{entry.name}</span>\n\t\t\t\t\t\t\t\t\t<span className={open ? 'rs-sidebar-count is-active' : 'rs-sidebar-count'}>\n\t\t\t\t\t\t\t\t\t\t{COUNT.format(entry.assetsCount ?? 0)}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={open ? 'rs-library-menu is-expanded' : 'rs-library-menu'}\n\t\t\t\t\t\t\t\t\taria-hidden={!open}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\ttabIndex={open ? 0 : -1}\n\t\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\t\topen && !search.active && opened === null\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'rs-sidebar-item is-active'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'rs-sidebar-item'\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonClick={toGrid}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Icon shape=\"circle\" />\n\t\t\t\t\t\t\t\t\t\t\tAll Assets\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t\t<FilePicker\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"rs-sidebar-item\"\n\t\t\t\t\t\t\t\t\t\t\tdisabled={!open || entry.access !== 'write' || pending !== null}\n\t\t\t\t\t\t\t\t\t\t\tfocusable={open}\n\t\t\t\t\t\t\t\t\t\t\tonFile={(file) => {\n\t\t\t\t\t\t\t\t\t\t\t\ttoGrid()\n\t\t\t\t\t\t\t\t\t\t\t\tvoid send(file, null)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<Icon shape=\"upload\" />\n\t\t\t\t\t\t\t\t\t\t\tUpload\n\t\t\t\t\t\t\t\t\t\t</FilePicker>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</nav>\n\t\t\t\t<div className=\"rs-sidebar-footer\">\n\t\t\t\t\t<span className=\"rs-sidebar-item rs-muted\">\n\t\t\t\t\t\t{session.isSignedIn ? (session.userName ?? 'Signed in') : 'API key'}\n\t\t\t\t\t</span>\n\t\t\t\t\t<button type=\"button\" className=\"rs-sidebar-item\" onClick={() => void session.signOut()}>\n\t\t\t\t\t\tSign out\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</aside>\n\t\t\t<section\n\t\t\t\tclassName=\"rs-main\"\n\t\t\t\taria-label=\"Assets\"\n\t\t\t\tonDragEnter={(event) => {\n\t\t\t\t\tif (!dropTarget || pending !== null || !event.dataTransfer.types.includes('Files')) return\n\t\t\t\t\tdragDepth.current += 1\n\t\t\t\t\tsetDragging(true)\n\t\t\t\t}}\n\t\t\t\tonDragOver={(event) => {\n\t\t\t\t\tif (dropTarget) event.preventDefault()\n\t\t\t\t}}\n\t\t\t\tonDragLeave={() => {\n\t\t\t\t\tdragDepth.current = Math.max(0, dragDepth.current - 1)\n\t\t\t\t\tif (dragDepth.current === 0) setDragging(false)\n\t\t\t\t}}\n\t\t\t\tonDrop={(event) => {\n\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\tdragDepth.current = 0\n\t\t\t\t\tsetDragging(false)\n\t\t\t\t\tconst file = event.dataTransfer.files[0]\n\t\t\t\t\tif (file && dropTarget) void send(file, versions ? opened.id : null)\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<header className=\"rs-header\">\n\t\t\t\t\t{heading}\n\t\t\t\t\t<span className=\"rs-muted rs-small\">{status}</span>\n\t\t\t\t\t<Progress upload={upload.state} promote={promote.state} />\n\t\t\t\t\t<div className=\"rs-search\">\n\t\t\t\t\t\t<Icon shape=\"search\" width={12.25} />\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tref={searchInput}\n\t\t\t\t\t\t\tclassName=\"rs-input\"\n\t\t\t\t\t\t\taria-label=\"Search Raster\"\n\t\t\t\t\t\t\tplaceholder={library === null ? 'Search every library…' : `Search ${library.name}…`}\n\t\t\t\t\t\t\tvalue={query}\n\t\t\t\t\t\t\tonChange={(event) => navigation.setQuery(event.target.value)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{query !== '' && (\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tclassName=\"rs-icon-button\"\n\t\t\t\t\t\t\t\taria-label=\"Clear search\"\n\t\t\t\t\t\t\t\tonClick={() => navigation.setQuery('')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Icon shape=\"x\" width={10.5} />\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t\t{versions && writable && (\n\t\t\t\t\t\t<FilePicker\n\t\t\t\t\t\t\tclassName=\"rs-button rs-button-sm\"\n\t\t\t\t\t\t\tdisabled={pending !== null}\n\t\t\t\t\t\t\tonFile={(file) => void send(file, opened.id)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Icon shape=\"upload\" width={12.25} />\n\t\t\t\t\t\t\tUpload variant\n\t\t\t\t\t\t</FilePicker>\n\t\t\t\t\t)}\n\t\t\t\t\t<button type=\"button\" className=\"rs-button rs-button-sm\" onClick={navigation.refresh}>\n\t\t\t\t\t\tRefresh\n\t\t\t\t\t</button>\n\t\t\t\t</header>\n\t\t\t\t<div className=\"rs-content\">\n\t\t\t\t\t{organizations.error && <ErrorCard error={organizations.error} onError={onError} />}\n\t\t\t\t\t{libraries.error && <ErrorCard error={libraries.error} onError={onError} />}\n\t\t\t\t\t{shown?.error && <ErrorCard error={shown.error} onError={onError} />}\n\t\t\t\t\t{read.error && <ErrorCard error={read.error} onError={onError} />}\n\t\t\t\t\t{upload.state.status === 'error' && (\n\t\t\t\t\t\t<ErrorCard error={upload.state.error} onError={onError} />\n\t\t\t\t\t)}\n\t\t\t\t\t{promote.state.status === 'error' && (\n\t\t\t\t\t\t<ErrorCard error={promote.state.error} onError={onError} />\n\t\t\t\t\t)}\n\t\t\t\t\t{content}\n\t\t\t\t</div>\n\t\t\t\t<div className={dragging ? 'rs-drop is-active' : 'rs-drop'} />\n\t\t\t</section>\n\t\t</>\n\t)\n}\n"]}
|
package/dist/styles.css
CHANGED
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
.rs-picker > .rs-sidebar {
|
|
105
|
-
width:
|
|
105
|
+
width: 266px;
|
|
106
106
|
flex-shrink: 0;
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
flex-shrink: 0;
|
|
120
120
|
align-items: center;
|
|
121
121
|
gap: 10.5px;
|
|
122
|
-
padding: 10.5px 10.5px 0
|
|
122
|
+
padding: 10.5px 10.5px 0 30px;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/* The title and search give way first, so no button's label is cut. */
|
|
@@ -127,10 +127,16 @@
|
|
|
127
127
|
flex-shrink: 0;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/*
|
|
131
|
+
* Positioned, so a grid's `offsetTop` counts from the top of the scroll. Its scrollbar is the
|
|
132
|
+
* system's, as Raster's grid has, so it takes none of the grid's width.
|
|
133
|
+
*/
|
|
130
134
|
.rs-content {
|
|
135
|
+
position: relative;
|
|
131
136
|
flex: 1;
|
|
132
137
|
min-height: 0;
|
|
133
|
-
|
|
138
|
+
overflow-y: auto;
|
|
139
|
+
padding: 30px;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
.rs-content > * + * {
|
|
@@ -622,10 +628,20 @@
|
|
|
622
628
|
|
|
623
629
|
/* ---- asset tiles ---- */
|
|
624
630
|
|
|
631
|
+
/* A row of tiles, with its columns from `gridColumns`, placed where the scroll puts it. */
|
|
625
632
|
.rs-grid {
|
|
626
633
|
display: grid;
|
|
627
|
-
|
|
628
|
-
|
|
634
|
+
gap: 30px;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.rs-tile-grid {
|
|
638
|
+
position: relative;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.rs-tile-grid > .rs-grid {
|
|
642
|
+
position: absolute;
|
|
643
|
+
right: 0;
|
|
644
|
+
left: 0;
|
|
629
645
|
}
|
|
630
646
|
|
|
631
647
|
.rs-asset-thumb {
|
|
@@ -635,7 +651,7 @@
|
|
|
635
651
|
flex-direction: column;
|
|
636
652
|
justify-content: space-between;
|
|
637
653
|
width: 100%;
|
|
638
|
-
height:
|
|
654
|
+
height: 210px;
|
|
639
655
|
overflow: hidden;
|
|
640
656
|
padding: 0;
|
|
641
657
|
border: 0;
|
|
@@ -667,16 +683,15 @@
|
|
|
667
683
|
opacity: 0.6;
|
|
668
684
|
}
|
|
669
685
|
|
|
686
|
+
/* The blurhash is blurred already, so it is stretched over the tile with no filter to composite. */
|
|
670
687
|
.rs-thumb-blur {
|
|
671
688
|
position: absolute;
|
|
672
|
-
inset:
|
|
689
|
+
inset: 0;
|
|
673
690
|
z-index: 10;
|
|
674
|
-
width:
|
|
675
|
-
height:
|
|
691
|
+
width: 100%;
|
|
692
|
+
height: 100%;
|
|
676
693
|
object-fit: cover;
|
|
677
|
-
filter: blur(40px);
|
|
678
694
|
opacity: 0.75;
|
|
679
|
-
transform: translateZ(0);
|
|
680
695
|
}
|
|
681
696
|
|
|
682
697
|
.rs-thumb-preview {
|
|
@@ -706,11 +721,9 @@
|
|
|
706
721
|
flex-direction: column;
|
|
707
722
|
justify-content: center;
|
|
708
723
|
flex-shrink: 0;
|
|
709
|
-
height:
|
|
724
|
+
height: 54px;
|
|
710
725
|
padding: 7px 10.5px;
|
|
711
726
|
background: var(--rs-thumb-meta);
|
|
712
|
-
-webkit-backdrop-filter: blur(12px);
|
|
713
|
-
backdrop-filter: blur(12px);
|
|
714
727
|
}
|
|
715
728
|
|
|
716
729
|
.rs-thumb-title {
|
|
@@ -800,7 +813,7 @@
|
|
|
800
813
|
/* The transparency checkerboard, behind a format that carries alpha. */
|
|
801
814
|
.rs-transparent {
|
|
802
815
|
position: absolute;
|
|
803
|
-
inset: 0 0
|
|
816
|
+
inset: 0 0 54px 0;
|
|
804
817
|
z-index: 10;
|
|
805
818
|
background-color: var(--rs-thumb-bg);
|
|
806
819
|
}
|
package/dist/use-asset-search.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { skipToken, useInfiniteQuery, } from '@tanstack/react-query';
|
|
2
2
|
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { SEARCH_PAGE_SIZE, } from '@raster-app/sdk';
|
|
3
|
+
import { SEARCH_PAGE_SIZE, searchAssets, } from '@raster-app/sdk';
|
|
4
4
|
import { useRasterClient } from './context.js';
|
|
5
5
|
import { rasterKeys } from './query-keys.js';
|
|
6
6
|
import { useCredentialIdentity } from './use-session.js';
|
|
@@ -32,7 +32,7 @@ export function useAssetSearch(scope, rawQuery) {
|
|
|
32
32
|
],
|
|
33
33
|
queryFn: scope === null
|
|
34
34
|
? skipToken
|
|
35
|
-
: ({ pageParam, signal }) => client
|
|
35
|
+
: ({ pageParam, signal }) => searchAssets(client, {
|
|
36
36
|
organizationId: scope.organizationId,
|
|
37
37
|
libraryIds: scope.libraryId === null ? undefined : [scope.libraryId],
|
|
38
38
|
query: debouncedQuery,
|
|
@@ -65,9 +65,11 @@ export function useAssetSearch(scope, rawQuery) {
|
|
|
65
65
|
void fetchNextPage({ cancelRefetch: false });
|
|
66
66
|
}, [hasMore, fetchNextPage]);
|
|
67
67
|
useEffect(() => {
|
|
68
|
+
if (query === debouncedQuery)
|
|
69
|
+
return;
|
|
68
70
|
const timer = setTimeout(() => setDebouncedQuery(query), SEARCH_DEBOUNCE_MS);
|
|
69
71
|
return () => clearTimeout(timer);
|
|
70
|
-
}, [query]);
|
|
72
|
+
}, [query, debouncedQuery]);
|
|
71
73
|
return {
|
|
72
74
|
active,
|
|
73
75
|
query,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-asset-search.js","sourceRoot":"","sources":["../src/use-asset-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EACT,gBAAgB,GAChB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,
|
|
1
|
+
{"version":3,"file":"use-asset-search.js","sourceRoot":"","sources":["../src/use-asset-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EACT,gBAAgB,GAChB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAIN,gBAAgB,EAChB,YAAY,GACZ,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,sFAAsF;AACtF,MAAM,kBAAkB,GAAG,GAAG,CAAA;AA2B9B,SAAS,SAAS,CAAC,IAAgC;IAClD,OAAO;QACN,6EAA6E;QAC7E,IAAI,EAAE,KAAK,CAAC,IAAI,CACf,IAAI,GAAG,CAAC,IA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KAAK,aAAa,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1D,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAA;IAE5B,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,KAAK,KAAK,cAAc;YAAE,OAAM;QACpC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,CAAA;QAC5E,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;IAE3B,OAAO;QACN,MAAM;QACN,KAAK;QACL,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,IAAI;QACzB,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;QACxB,WAAW;QACX,OAAO;QACP,QAAQ;QACR,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;KAC5B,CAAA;AACF,CAAC","sourcesContent":["import {\n\ttype InfiniteData,\n\ttype QueryKey,\n\tskipToken,\n\tuseInfiniteQuery,\n} from '@tanstack/react-query'\nimport { useCallback, useEffect, useState } from 'react'\n\nimport {\n\ttype RasterApiError,\n\ttype SearchHit,\n\ttype SearchResult,\n\tSEARCH_PAGE_SIZE,\n\tsearchAssets,\n} from '@raster-app/sdk'\n\nimport { useRasterClient } from './context.js'\nimport { rasterKeys } from './query-keys.js'\nimport { useCredentialIdentity } from './use-session.js'\n\n/** How long typing must pause before a query is sent, so a word costs one request. */\nconst SEARCH_DEBOUNCE_MS = 300\n\n/** Where a search looks: one organization, optionally narrowed to one of its libraries. */\nexport type SearchScope = {\n\torganizationId: string\n\t/** Null searches every library in the organization. */\n\tlibraryId: string | null\n}\n\nexport type AssetSearch = {\n\t/** Whether there is a query to show results for — views swap to results on this. */\n\tactive: boolean\n\t/** The trimmed query the results are (or will be) for. */\n\tquery: string\n\t/** Null until the first page has landed. */\n\thits: Array<SearchHit> | null\n\t/** Total matches in scope, from the index — not just those loaded so far. */\n\tfound: number\n\tisSearching: boolean\n\thasMore: boolean\n\t/** Fetch the next page. A no-op while one is already in flight, at the end, or after a failure. */\n\tloadMore: () => void\n\terror: RasterApiError | null\n}\n\ntype Results = Pick<SearchResult, 'hits' | 'found'>\n\nfunction toResults(data: InfiniteData<SearchResult>): Results {\n\treturn {\n\t\t// The index can shift between pages; a hit already shown is not shown twice.\n\t\thits: Array.from(\n\t\t\tnew Map(data.pages.flatMap((page) => page.hits).map((hit) => [hit.id, hit])).values()\n\t\t),\n\t\tfound: data.pages[data.pages.length - 1]?.found ?? 0,\n\t}\n}\n\n/**\n * Full-text search over Raster, as a header search box drives it. The previous results stay\n * on screen while the next query runs, since a grid that blanks on every keystroke makes\n * typing feel destructive. A null scope switches the search off.\n */\nexport function useAssetSearch(scope: SearchScope | null, rawQuery: string): AssetSearch {\n\tconst client = useRasterClient()\n\n\tconst identity = useCredentialIdentity()\n\n\tconst [debouncedQuery, setDebouncedQuery] = useState('')\n\n\tconst query = rawQuery.trim()\n\tconst active = scope !== null && query !== ''\n\n\tconst { data, error, isFetching, isError, hasNextPage, fetchNextPage } = useInfiniteQuery<\n\t\tSearchResult,\n\t\tRasterApiError,\n\t\tResults,\n\t\tQueryKey,\n\t\tnumber\n\t>({\n\t\tqueryKey: [\n\t\t\t...rasterKeys.search(identity, scope?.organizationId ?? null),\n\t\t\tscope?.libraryId ?? null,\n\t\t\tdebouncedQuery,\n\t\t],\n\t\tqueryFn:\n\t\t\tscope === null\n\t\t\t\t? skipToken\n\t\t\t\t: ({ pageParam, signal }) =>\n\t\t\t\t\t\tsearchAssets(client, {\n\t\t\t\t\t\t\torganizationId: scope.organizationId,\n\t\t\t\t\t\t\tlibraryIds: scope.libraryId === null ? undefined : [scope.libraryId],\n\t\t\t\t\t\t\tquery: debouncedQuery,\n\t\t\t\t\t\t\tpage: pageParam,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t}),\n\t\tinitialPageParam: 1,\n\t\tgetNextPageParam: (lastPage, pages) =>\n\t\t\tlastPage.hits.length === SEARCH_PAGE_SIZE && pages.length * SEARCH_PAGE_SIZE < lastPage.found\n\t\t\t\t? pages.length + 1\n\t\t\t\t: undefined,\n\t\tselect: toResults,\n\t\t// `keepPreviousData` within one sign-in's search of one organization. The observer holds\n\t\t// the last account's results after their cache is dropped, and a hit names its library but\n\t\t// not its organization, so one shown under another organization would be acted on there.\n\t\tplaceholderData: (previous, previousQuery) => {\n\t\t\tconst [, signIn, , organizationId] = previousQuery?.queryKey ?? []\n\t\t\treturn signIn === identity && organizationId === scope?.organizationId ? previous : undefined\n\t\t},\n\t\t// A blank `q` returns recent assets rather than matches.\n\t\tenabled: identity !== null && active && debouncedQuery !== '',\n\t})\n\n\tconst shown = active ? data : undefined\n\t// Up from the keystroke rather than from when the request goes out, so the spinner confirms\n\t// the typing was noticed.\n\tconst isSearching = active && (query !== debouncedQuery || isFetching)\n\t// A failure also stops paging, rather than let an observer retry it on every scroll.\n\tconst hasMore = active && hasNextPage && !isError\n\n\tconst loadMore = useCallback(() => {\n\t\tif (hasMore) void fetchNextPage({ cancelRefetch: false })\n\t}, [hasMore, fetchNextPage])\n\n\tuseEffect(() => {\n\t\tif (query === debouncedQuery) return\n\t\tconst timer = setTimeout(() => setDebouncedQuery(query), SEARCH_DEBOUNCE_MS)\n\t\treturn () => clearTimeout(timer)\n\t}, [query, debouncedQuery])\n\n\treturn {\n\t\tactive,\n\t\tquery,\n\t\thits: shown?.hits ?? null,\n\t\tfound: shown?.found ?? 0,\n\t\tisSearching,\n\t\thasMore,\n\t\tloadMore,\n\t\terror: active ? error : null,\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Asset, type RasterApiError, type UploadSource, type UploadedAsset } from '@raster-app/sdk';
|
|
2
2
|
export type UploadState = {
|
|
3
3
|
status: 'idle';
|
|
4
4
|
} | {
|
|
@@ -33,7 +33,7 @@ type UploadOptions = {
|
|
|
33
33
|
export type AssetUpload = {
|
|
34
34
|
state: UploadState;
|
|
35
35
|
/**
|
|
36
|
-
* Upload a file, then wait until Raster has processed it (`
|
|
36
|
+
* Upload a file, then wait until Raster has processed it (`waitUntilProcessed`).
|
|
37
37
|
*
|
|
38
38
|
* Resolves with the finished asset. Null leaves the rest to `state`: still processing when
|
|
39
39
|
* the wait gave up, which is not a failure, just "not yet" — or failed, or cancelled.
|
package/dist/use-asset-upload.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { uploadAsset, waitUntilProcessed, } from '@raster-app/sdk';
|
|
3
4
|
import { useRasterClient } from './context.js';
|
|
4
5
|
import { rasterKeys } from './query-keys.js';
|
|
5
6
|
import { useCredentialIdentity } from './use-session.js';
|
|
@@ -18,11 +19,11 @@ export function useAssetUpload() {
|
|
|
18
19
|
const identity = useCredentialIdentity();
|
|
19
20
|
const mutation = useMutation({
|
|
20
21
|
mutationFn: async ({ signal, ...options }) => {
|
|
21
|
-
const uploaded = await client
|
|
22
|
+
const uploaded = await uploadAsset(client, { ...options, signal });
|
|
22
23
|
// An upload superseded by now must not show as the one processing.
|
|
23
24
|
if (!signal.aborted)
|
|
24
25
|
setUploaded(uploaded);
|
|
25
|
-
const asset = await
|
|
26
|
+
const asset = await waitUntilProcessed(client, {
|
|
26
27
|
organizationId: options.organizationId,
|
|
27
28
|
libraryId: options.libraryId,
|
|
28
29
|
assetId: uploaded.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-asset-upload.js","sourceRoot":"","sources":["../src/use-asset-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3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aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;IAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AACxC,CAAC","sourcesContent":["import { type UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n\ttype Asset,\n\ttype RasterApiError,\n\ttype UploadSource,\n\ttype UploadedAsset,\n\tuploadAsset,\n\twaitUntilProcessed,\n} from '@raster-app/sdk'\n\nimport { useRasterClient } from './context.js'\nimport { rasterKeys } from './query-keys.js'\nimport { useCredentialIdentity } from './use-session.js'\n\nexport type UploadState =\n\t| { status: 'idle' }\n\t| { status: 'uploading' }\n\t/** Raster has the file and is still processing it. */\n\t| { status: 'processing'; asset: UploadedAsset }\n\t/** Processed. For a variant, `asset` is its parent, whose `variants` now carry it. */\n\t| { status: 'done'; asset: Asset }\n\t/** Raster has the file, but was still processing it when the wait gave up. */\n\t| { status: 'timed-out'; asset: UploadedAsset }\n\t| { status: 'error'; error: RasterApiError }\n\ntype UploadOptions = {\n\torganizationId: string\n\tlibraryId: string\n\t/** Attach as a variant of this asset; omit for a new top-level asset. */\n\tparentId?: string | null\n\tsource: UploadSource\n\tfilename?: string\n}\n\ntype UploadOutcome = Extract<UploadState, { status: 'done' | 'timed-out' }>\n\ntype UploadVariables = UploadOptions & { signal: AbortSignal }\n\ntype UploadMutation = UseMutationResult<UploadOutcome, RasterApiError, UploadVariables>\n\nexport type AssetUpload = {\n\tstate: UploadState\n\t/**\n\t * Upload a file, then wait until Raster has processed it (`waitUntilProcessed`).\n\t *\n\t * Resolves with the finished asset. Null leaves the rest to `state`: still processing when\n\t * the wait gave up, which is not a failure, just \"not yet\" — or failed, or cancelled.\n\t */\n\tupload: (options: UploadOptions) => Promise<Asset | null>\n\tcancel: () => void\n\treset: () => void\n}\n\nfunction uploadState(mutation: UploadMutation, uploaded: UploadedAsset | null): UploadState {\n\tif (mutation.isSuccess) return mutation.data\n\tif (mutation.isError) return { status: 'error', error: mutation.error }\n\tif (mutation.isIdle) return { status: 'idle' }\n\treturn uploaded === null ? { status: 'uploading' } : { status: 'processing', asset: uploaded }\n}\n\nexport function useAssetUpload(): AssetUpload {\n\tconst client = useRasterClient()\n\tconst queryClient = useQueryClient()\n\n\tconst identity = useCredentialIdentity()\n\tconst mutation = useMutation<UploadOutcome, RasterApiError, UploadVariables>({\n\t\tmutationFn: async ({ signal, ...options }) => {\n\t\t\tconst uploaded = await uploadAsset(client, { ...options, signal })\n\t\t\t// An upload superseded by now must not show as the one processing.\n\t\t\tif (!signal.aborted) setUploaded(uploaded)\n\t\t\tconst asset = await waitUntilProcessed(client, {\n\t\t\t\torganizationId: options.organizationId,\n\t\t\t\tlibraryId: options.libraryId,\n\t\t\t\tassetId: uploaded.id,\n\t\t\t\tparentId: uploaded.parentId,\n\t\t\t\tsignal,\n\t\t\t})\n\t\t\treturn asset === null ? { status: 'timed-out', asset: uploaded } : { status: 'done', asset }\n\t\t},\n\t\t// Whatever failed, Raster may have the file by now.\n\t\tonSettled: (_outcome, _error, { organizationId, libraryId }) => {\n\t\t\tvoid queryClient.invalidateQueries({\n\t\t\t\tqueryKey: rasterKeys.libraries(identity, organizationId),\n\t\t\t})\n\t\t\tvoid queryClient.invalidateQueries({\n\t\t\t\tqueryKey: rasterKeys.assets(identity, organizationId, libraryId),\n\t\t\t})\n\t\t\tvoid queryClient.invalidateQueries({ queryKey: rasterKeys.search(identity, organizationId) })\n\t\t},\n\t})\n\n\tconst [uploaded, setUploaded] = useState<UploadedAsset | null>(null)\n\n\tconst controllerRef = useRef<AbortController | null>(null)\n\n\tconst { mutateAsync, reset: resetMutation } = mutation\n\tconst state = uploadState(mutation, uploaded)\n\n\tconst upload = useCallback<AssetUpload['upload']>(\n\t\tasync (options) => {\n\t\t\tcontrollerRef.current?.abort()\n\t\t\tconst controller = new AbortController()\n\t\t\tcontrollerRef.current = controller\n\t\t\tsetUploaded(null)\n\t\t\ttry {\n\t\t\t\tconst outcome = await mutateAsync({ ...options, signal: controller.signal })\n\t\t\t\treturn outcome.status === 'done' ? outcome.asset : null\n\t\t\t} catch {\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\t\t[mutateAsync]\n\t)\n\n\tconst reset = useCallback(() => {\n\t\tresetMutation()\n\t\tsetUploaded(null)\n\t}, [resetMutation])\n\n\tconst cancel = useCallback(() => {\n\t\tcontrollerRef.current?.abort()\n\t\treset()\n\t}, [reset])\n\n\tuseEffect(() => () => controllerRef.current?.abort(), [])\n\n\treturn { state, upload, cancel, reset }\n}\n"]}
|
package/dist/use-assets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { skipToken, useInfiniteQuery, useQueryClient, } from '@tanstack/react-query';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { ASSETS_PAGE_SIZE, } from '@raster-app/sdk';
|
|
3
|
+
import { ASSETS_PAGE_SIZE, listAssets, } from '@raster-app/sdk';
|
|
4
4
|
import { useRasterClient } from './context.js';
|
|
5
5
|
import { rasterKeys } from './query-keys.js';
|
|
6
6
|
import { useCredentialIdentity } from './use-session.js';
|
|
@@ -11,7 +11,7 @@ function toAssets(data) {
|
|
|
11
11
|
/** One page of a library, as the grid reads it and a hover warms it. */
|
|
12
12
|
function listPage(client, organizationId, libraryId) {
|
|
13
13
|
// `signal` aborts a page nobody wants any more, which would otherwise hold the connection pool.
|
|
14
|
-
return ({ pageParam, signal }) => client
|
|
14
|
+
return ({ pageParam, signal }) => listAssets(client, { organizationId, libraryId, page: pageParam, signal });
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Warm a library's first page, as a hover does before the click that opens it. A library already
|
package/dist/use-assets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-assets.js","sourceRoot":"","sources":["../src/use-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,SAAS,EACT,g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C,CAAC,CAAC,SAAS;QACpE,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,QAAQ,KAAK,IAAI,IAAI,cAAc,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI;KAC3E,CAAC,CAAA;IAEF,0FAA0F;IAC1F,MAAM,OAAO,GAAG,WAAW,IAAI,CAAC,OAAO,CAAA;IAEvC,gGAAgG;IAChG,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QACjC,IAAI,OAAO;YAAE,KAAK,aAAa,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1D,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAA;IAE5B,OAAO,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;AACjF,CAAC","sourcesContent":["import {\n\ttype InfiniteData,\n\ttype QueryFunctionContext,\n\ttype QueryKey,\n\tskipToken,\n\tuseInfiniteQuery,\n\tuseQueryClient,\n} from '@tanstack/react-query'\nimport { useCallback } from 'react'\n\nimport {\n\ttype Asset,\n\ttype RasterApiError,\n\ttype RasterClient,\n\tASSETS_PAGE_SIZE,\n\tlistAssets,\n} from '@raster-app/sdk'\n\nimport { useRasterClient } from './context.js'\nimport { rasterKeys } from './query-keys.js'\nimport { useCredentialIdentity } from './use-session.js'\n\nexport type AssetsResource = {\n\t/** Null until the first page lands. */\n\tassets: Array<Asset> | null\n\tisLoading: boolean\n\terror: RasterApiError | null\n\thasMore: boolean\n\t/** Fetch the next page. A no-op while one is already in flight, at the end, or after a failure. */\n\tloadMore: () => void\n}\n\n/** A library can change between pages; an asset already shown is not shown twice. */\nfunction toAssets(data: InfiniteData<Array<Asset>>): Array<Asset> {\n\treturn Array.from(new Map(data.pages.flat().map((asset) => [asset.id, asset])).values())\n}\n\n/** One page of a library, as the grid reads it and a hover warms it. */\nfunction listPage(client: RasterClient, organizationId: string, libraryId: string) {\n\t// `signal` aborts a page nobody wants any more, which would otherwise hold the connection pool.\n\treturn ({ pageParam, signal }: QueryFunctionContext<QueryKey, number>) =>\n\t\tlistAssets(client, { organizationId, libraryId, page: pageParam, signal })\n}\n\n/**\n * Warm a library's first page, as a hover does before the click that opens it. A library already\n * cached is left alone: its grid paints on the click and refreshes itself.\n */\nexport function usePrefetchAssets(): (organizationId: string, libraryId: string) => void {\n\tconst client = useRasterClient()\n\tconst queryClient = useQueryClient()\n\tconst identity = useCredentialIdentity()\n\n\treturn useCallback(\n\t\t(organizationId, libraryId) => {\n\t\t\tconst queryKey = rasterKeys.assets(identity, organizationId, libraryId)\n\t\t\tif (identity === null || queryClient.getQueryData(queryKey) !== undefined) return\n\t\t\tvoid queryClient.prefetchInfiniteQuery({\n\t\t\t\tqueryKey,\n\t\t\t\tqueryFn: listPage(client, organizationId, libraryId),\n\t\t\t\tinitialPageParam: 1,\n\t\t\t})\n\t\t},\n\t\t[client, queryClient, identity]\n\t)\n}\n\n/**\n * A library's assets, paged.\n *\n * Pass a null `libraryId` before a library is open; the hook then sits idle.\n */\nexport function useAssets(options: {\n\torganizationId: string | null\n\tlibraryId: string | null\n}): AssetsResource {\n\tconst { organizationId, libraryId } = options\n\n\tconst client = useRasterClient()\n\n\tconst identity = useCredentialIdentity()\n\tconst { data, error, isFetching, isError, hasNextPage, fetchNextPage } = useInfiniteQuery<\n\t\tArray<Asset>,\n\t\tRasterApiError,\n\t\tArray<Asset>,\n\t\tQueryKey,\n\t\tnumber\n\t>({\n\t\tqueryKey: rasterKeys.assets(identity, organizationId, libraryId),\n\t\tqueryFn:\n\t\t\torganizationId === null || libraryId === null\n\t\t\t\t? skipToken\n\t\t\t\t: listPage(client, organizationId, libraryId),\n\t\tinitialPageParam: 1,\n\t\tgetNextPageParam: (lastPage, pages) =>\n\t\t\tlastPage.length === ASSETS_PAGE_SIZE ? pages.length + 1 : undefined,\n\t\tselect: toAssets,\n\t\tenabled: identity !== null && organizationId !== null && libraryId !== null,\n\t})\n\n\t// A failure also stops paging, rather than let a scroll observer retry it on every frame.\n\tconst hasMore = hasNextPage && !isError\n\n\t// Without `cancelRefetch: false`, a call while a page is in flight would abort it to ask again.\n\tconst loadMore = useCallback(() => {\n\t\tif (hasMore) void fetchNextPage({ cancelRefetch: false })\n\t}, [hasMore, fetchNextPage])\n\n\treturn { assets: data ?? null, isLoading: isFetching, error, hasMore, loadMore }\n}\n"]}
|