MCPcopy Create free account
hub / github.com/cosscom/coss / CommandMenu

Function CommandMenu

apps/ui/components/command-menu.tsx:48–243  ·  view source on GitHub ↗
({
  tree,
  navItems,
  ...props
}: ComponentProps<typeof CommandDialog> & {
  tree: typeof source.pageTree;
  navItems?: { href: string; label: string }[];
})

Source from the content-addressed store, hash-verified

46}
47
48export function CommandMenu({
49 tree,
50 navItems,
51 ...props
52}: ComponentProps<typeof CommandDialog> & {
53 tree: typeof source.pageTree;
54 navItems?: { href: string; label: string }[];
55}) {
56 const isMac = useIsMac();
57 const [config] = useConfig();
58 const { copyToClipboard } = useCopyToClipboard();
59 const [open, setOpen] = React.useState(false);
60 const [selectedType, setSelectedType] = React.useState<
61 "page" | "component" | null
62 >(null);
63 const [copyPayload, setCopyPayload] = React.useState("");
64 const packageManager = config.packageManager || "pnpm";
65
66 // Convert tree structure to grouped items
67 const groupedItems = React.useMemo<PageGroup[]>(() => {
68 const groups: PageGroup[] = [];
69
70 // Add nav items group
71 if (navItems && navItems.length > 0) {
72 groups.push({
73 items: navItems.map((item) => ({
74 isComponent: false,
75 keywords: ["nav", "navigation", item.label.toLowerCase()],
76 label: item.label,
77 url: item.href,
78 value: `Navigation ${item.label}`,
79 })),
80 value: "Pages",
81 });
82 }
83
84 // Add tree groups
85 tree.children.forEach((group) => {
86 if (group.type === "folder") {
87 const items: PageItem[] = [];
88 group.children.forEach((item) => {
89 if (item.type === "page") {
90 const isComponent = item.url.includes("/components/");
91 const itemName = item.name?.toString() || "";
92 items.push({
93 isComponent,
94 keywords: isComponent ? ["component"] : undefined,
95 label: itemName,
96 url: item.url,
97 value: itemName ? `${group.name} ${itemName}` : "",
98 });
99 }
100 });
101 if (items.length > 0) {
102 groups.push({
103 items,
104 value:
105 typeof group.name === "string" ? group.name : String(group.name),

Callers

nothing calls this directly

Calls 3

useIsMacFunction · 0.90
useConfigFunction · 0.90
useCopyToClipboardFunction · 0.90

Tested by

no test coverage detected