Appearance
useSearchLibraryItems Composable ​
File Information ​
- Path:
app/composables/core/components/search/useSearchLibraryItems.ts - Purpose: Open, share, download and analytics logic for collage and folder search results rendered by
SearchLibraryItems - Type: Core Composable (Search Component)
Overview ​
Exports the SearchLibraryType type ('collages' | 'folders') and the useSearchLibraryItems(props) composable.
- Open:
open(item)tracks the click, logs aviewedactivity (collagewithcollection_id, orfolderwithcategory_id,environment: 'dealer'), resolvesbrand_name-collage-idorbrand_name-folders-idand opens it in a new tab. - Grid card clicks:
onCardClick(item, event)only records the search-result click; it ignores clicks inside.optionIcon,.menu-list,.v-checkboxor.search-matches. - Analytics source:
'overlay'whenflag === 'search-bar', otherwise'search-page', passed totrackSearchResultClickfromuseAmplitudeSearchTracking. - Count label: collages show
Empty CollageorN Asset(s); folders showEmpty FolderorN Subfolder(s), N Asset(s)(numbers formatted withen-USlocale). - Share:
shareCollage(item)opens the share dialog only whenitem.assets_count > 0;shareFolder(item)always opens it with the folder as the single item. - Download:
downloadFolder(item)callsdownloadStore.downloadMultipleFiles({ files: [], folders: [id], download_name: item.folder_name }), tracks a folderdownloadedactivity, and keeps the id in a downloading set until thedownload-all-foldermitt event fires (or the request fails).
Parameters ​
| Name | Type | Description |
|---|---|---|
props.type | SearchLibraryType | Result type |
props.items | any[] | Result entries |
props.flag | 'search-bar' | 'results-page' | Mount location |
props.matchColumn | boolean | null (optional) | Overrides hasMatchColumn when not null/undefined |
Return Type ​
| Key | Description |
|---|---|
open(item) | Track and open the collage/folder in a new tab |
onCardClick(item, event) | Track a grid card click on its open area |
itemName(item) | item.name || item.collection_name for collages, item.folder_name for folders |
countLabel(item) | Count text described above |
formatDateUnix | Re-exported from useHelpers() |
hasMatchColumn | props.matchColumn ?? items.some(item => itemSearchMatches(item).length > 0): the caller's value wins; otherwise true when any item has matches beyond its name |
shareDialog, shareCollageItem, shareCollage | Collage share dialog state |
shareFolderItems, shareFolder, shareFolderTitle, shareFolderDescription | Folder share dialog state |
isDownloading(item), downloadFolder(item) | Folder download state and action |
Usage ​
typescript
const { open, itemName, countLabel, downloadFolder } = useSearchLibraryItems(props)