import type { ComputedRef, Ref } from 'vue' import type { RouteLocationRaw } from 'vue-router' import type { Option as OverflowMenuOption } from '#ui/components/base/OverflowMenu.vue' import { createContext } from '#ui/providers/create-context' import type { ContentCardTableItem, ContentItem, ContentModpackCardCategory, ContentModpackCardProject, ContentModpackCardVersion, ContentOwner, } from '../types' export interface ContentModpackData { project: ContentModpackCardProject projectLink?: string | RouteLocationRaw version?: ContentModpackCardVersion versionLink?: string | RouteLocationRaw owner?: ContentOwner categories: ContentModpackCardCategory[] hasUpdate: boolean disabled?: boolean disabledText?: string } export type { UploadState } from '@modrinth/api-client' export interface ContentManagerContext { // Data items: Ref | ComputedRef loading: Ref error: Ref // Modpack modpack: Ref | ComputedRef isPackLocked: Ref | ComputedRef // Guards isBusy: Ref | ComputedRef busyMessage?: Ref | ComputedRef disableAddContent?: Ref | ComputedRef disableAddContentTooltip?: string // Labelling contentTypeLabel: Ref | ComputedRef // Core actions toggleEnabled: (item: ContentItem) => Promise deleteItem: (item: ContentItem) => Promise refresh: () => Promise browse: () => void uploadFiles: () => void // Bulk actions (optional — when provided, used instead of one-by-one loops) bulkDeleteItems?: (items: ContentItem[]) => Promise bulkEnableItems?: (items: ContentItem[]) => Promise bulkDisableItems?: (items: ContentItem[]) => Promise // Update support (optional per-platform) hasUpdateSupport: boolean updateItem?: (id: string) => void bulkUpdateItem?: (item: ContentItem) => Promise bulkUpdateItems?: (items: ContentItem[]) => Promise // Modpack actions (optional) updateModpack?: () => void viewModpackContent?: () => void unlinkModpack?: () => void openSettings?: () => void // Switch version (optional) switchVersion?: (item: ContentItem) => void // Per-item overflow menu (optional) getOverflowOptions?: (item: ContentItem) => OverflowMenuOption[] // Share support (optional — when undefined, share button becomes hidden entirely) shareItems?: (items: ContentItem[], format: 'names' | 'file-names' | 'urls' | 'markdown') => void // Upload progress (optional) uploadState?: Ref | ComputedRef // Bulk operation guard — set by layout, checked by providers to suppress refreshes isBulkOperating?: Ref // Deletion context (controls modal variant) deletionContext?: 'instance' | 'server' // One-time content hint (optional — shows tooltip on modpack content button) showContentHint?: Ref dismissContentHint?: () => void // Table item mapping (link generation differs per platform) mapToTableItem: (item: ContentItem) => ContentCardTableItem // Filter persistence key — when set, selected filters are saved/restored via sessionStorage filterPersistKey?: string } export const [injectContentManager, provideContentManager] = createContext( 'ContentPageLayout', 'contentManagerContext', )