mirror of
https://github.com/johndoe6345789/AutoMetabuilder.git
synced 2026-04-24 13:54:59 +00:00
- Created custom hooks: useWorkflowGraph, useWorkflowPlugins, usePluginSearch, useTabNavigation - Decomposed canvas logic into: useCanvasNodes, useCanvasEdges, useCanvasDragDrop - Built atomic node components: NodeHeader, NodeBody, NodePorts - Created canvas UI components: CanvasInfoPanel, CanvasHintPanel - Split builder into: LoadingState, ErrorState, WorkflowBuilderHeader, WorkflowBuilderTabs, WorkflowBuilderContent - Added React Flow for n8n-style visual canvas with drag-and-drop - All components now under 100 LOC following PROMPT.md guidelines Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
20 lines
772 B
TypeScript
20 lines
772 B
TypeScript
import { useMemo, useState } from "react";
|
|
import { WorkflowPluginMap } from "../lib/types";
|
|
|
|
export function usePluginSearch(plugins: WorkflowPluginMap, t: (key: string, fallback?: string) => string) {
|
|
const [search, setSearch] = useState("");
|
|
|
|
const filteredPlugins = useMemo(() => {
|
|
const query = search.trim().toLowerCase();
|
|
return Object.entries(plugins).filter(([id, plugin]) => {
|
|
const label = plugin.label ? t(plugin.label, id) : id;
|
|
const category = plugin.category || "";
|
|
const tags = (plugin.tags || []).join(" ");
|
|
const searchText = `${id} ${label} ${category} ${tags}`.toLowerCase();
|
|
return !query || searchText.includes(query);
|
|
});
|
|
}, [plugins, search, t]);
|
|
|
|
return { search, setSearch, filteredPlugins };
|
|
}
|