import type { BlokkliIcon } from '#blokkli-build/icons'; import type { ThemeColorName } from '../../../global/types/theme.js'; import type { AddAction } from '../types/actions.js'; type PluginAddFunction = () => T | T[] | undefined; type AddActionFunction = PluginAddFunction; export type ItemDropdownAction = { id: string; label: string; description?: string; enabled?: boolean; icon?: BlokkliIcon; bundle?: string; weight?: number; group: string; variant?: string; callback: () => void; }; type ItemDropdownActionFunction = PluginAddFunction; export type MenuButtonPlugin = { id: string; title: string; description: string; icon?: BlokkliIcon; type?: 'success' | 'danger' | 'yellow'; weight?: number; secondary?: boolean; disabled?: boolean; callback: () => void; }; type MenuButtonFunction = PluginAddFunction; export type HighlightItem = { id?: string; uuid?: string; element?: HTMLElement; color: ThemeColorName; icon: BlokkliIcon; label: string; description?: string; onClick: () => void; }; type HighlightFunction = PluginAddFunction; export type ViewOption = { id: string; label: string; description: string; icon: BlokkliIcon; keyCode?: string; tourText?: string; weight?: number; }; type ViewOptionFunction = PluginAddFunction; type PluginFunctionMap = { addAction: AddActionFunction; itemDropdownAction: ItemDropdownActionFunction; menuButton: MenuButtonFunction; highlight: HighlightFunction; viewOption: ViewOptionFunction; }; type PluginDataMap = { addAction: AddAction; itemDropdownAction: ItemDropdownAction; menuButton: MenuButtonPlugin; highlight: HighlightItem; viewOption: ViewOption; }; export type PluginProvider = { /** * Register a plugin provider function. * * The function will be called when plugins of this type are requested. * It can return a single plugin, an array of plugins, or undefined. * * @param type - The plugin type ('addAction', 'itemDropdownAction', 'menuButton') * @param fn - Function that returns plugin(s) * * @example * ```ts * plugin.add('addAction', () => ({ * id: 'custom-add', * label: 'Add Custom', * bundles: ['text'], * callback: () => console.log('add'), * })) * ``` */ add(type: T, fn: PluginFunctionMap[T]): void; /** * Unregister a plugin provider function. * * Removes a previously registered function so it no longer provides plugins. * * @param type - The plugin type * @param fn - The function to remove (must be the same reference used in add) */ remove(type: T, fn: PluginFunctionMap[T]): void; /** * Get all plugins from all registered providers. * * Calls all registered provider functions for this type, flattens the results, * and filters out undefined values. * * @param type - The plugin type to retrieve * @returns Array of all available plugins of this type */ get(type: T): PluginDataMap[T][]; }; export default function (): PluginProvider; export {};