{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "add-menu",
  "title": "Add Menu",
  "description": "A plus button that opens a menu of what can be added, with icons, descriptions, groups and submenus.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-menu"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/add-menu.tsx",
      "content": "\"use client\";\n\nimport {\n  type AddMenuContentState,\n  type AddMenuOptions,\n  type AddMenuRow,\n  type AddMenuSection,\n  addMenuPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { MenuTrigger } from \"@ui-sdk/react/menu\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport { type ComponentProps, Fragment, type ReactElement, type ReactNode } from \"react\";\nimport {\n  KindMenu,\n  KindMenuContent,\n  KindMenuGroup,\n  KindMenuGroupLabel,\n  KindMenuItem,\n  KindMenuItemContent,\n  KindMenuSeparator,\n  KindMenuSub,\n  KindMenuSubContent,\n  KindMenuSubTrigger,\n} from \"./internal/menu\";\n\nconst parts = createParts(addMenuPrimitive, { root: \"div\", trigger: \"span\", content: \"div\" });\n\n/** An entry, whose `icon` is an image URL or an element such as an inline `svg`. */\nexport type AddMenuEntry = Omit<NonNullable<AddMenuOptions[\"items\"]>[number], \"icon\" | \"items\"> & {\n  icon?: string | ReactElement;\n  items?: AddMenuEntry[];\n};\n\nexport type AddMenuProps = Omit<ComponentProps<typeof parts.Root>, \"children\" | \"items\"> & {\n  items?: AddMenuEntry[];\n  children?: ReactNode;\n};\n\nfunction Row({ row }: { row: AddMenuRow }) {\n  if (!row.sections)\n    return (\n      <KindMenuItem value={row.id} label={row.label} disabled={row.disabled}>\n        <KindMenuItemContent icon={row.icon} label={row.label} description={row.description} />\n      </KindMenuItem>\n    );\n  return (\n    <KindMenuSub>\n      <KindMenuSubTrigger disabled={row.disabled}>\n        <KindMenuItemContent icon={row.icon} label={row.label} description={row.description} />\n        <span data-menu-chevron=\"\" />\n      </KindMenuSubTrigger>\n      <KindMenuSubContent>\n        <AddMenuRows sections={row.sections} />\n      </KindMenuSubContent>\n    </KindMenuSub>\n  );\n}\n\nexport type AddMenuRowsProps = { sections: AddMenuSection[] };\n\n/** The rows of a level: each group under its label, separated, and a submenu for each entry with `items`. */\nexport function AddMenuRows({ sections }: AddMenuRowsProps) {\n  return sections.map((section, index) => {\n    const rows = section.rows.map((row) => <Row key={row.id} row={row} />);\n    return (\n      <Fragment key={section.label ?? \"\"}>\n        {index > 0 ? <KindMenuSeparator /> : null}\n        {section.label === undefined ? (\n          rows\n        ) : (\n          <KindMenuGroup>\n            <KindMenuGroupLabel>{section.label}</KindMenuGroupLabel>\n            {rows}\n          </KindMenuGroup>\n        )}\n      </Fragment>\n    );\n  });\n}\n\n/**\n * An icon button named \"Add\" that opens a menu of what can be added: items with an icon and a description, grouped\n * under labels, and submenus. Any `children` replace the trigger and the content, inside UI SDK Menu.\n */\nexport function AddMenu({ children = DEFAULT_PARTS, ...props }: AddMenuProps) {\n  return <parts.Root {...props}>{(menu) => <KindMenu {...menu}>{children}</KindMenu>}</parts.Root>;\n}\n\nexport type AddMenuTriggerProps = ComponentProps<typeof MenuTrigger>;\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label`, showing a plus unless you pass children. */\nexport function AddMenuTrigger({ children = PLUS, ...props }: AddMenuTriggerProps) {\n  return (\n    <parts.Trigger>\n      {(trigger) => (\n        // Hidden from agents, which use the Add Menu's own actions.\n        <MenuTrigger {...trigger} data-agent-hidden=\"\" {...props}>\n          {children}\n        </MenuTrigger>\n      )}\n    </parts.Trigger>\n  );\n}\n\nexport type AddMenuContentProps = Omit<ComponentProps<typeof KindMenuContent>, \"children\"> & {\n  /** What the menu holds, or a function of its rows: the rows by default. */\n  children?: ReactNode | ((state: AddMenuContentState) => ReactNode);\n};\n\n/** The menu: UI SDK's `MenuContent` holding the rows unless you pass children. Props go to it. */\nexport function AddMenuContent({ children = DEFAULT_ROWS, ...props }: AddMenuContentProps) {\n  return (\n    <parts.Content>\n      {(state) => (\n        <KindMenuContent align=\"start\" sideOffset={6} {...props}>\n          {typeof children === \"function\" ? children(state) : children}\n        </KindMenuContent>\n      )}\n    </parts.Content>\n  );\n}\n\nconst DEFAULT_ROWS = ({ sections }: AddMenuContentState) => <AddMenuRows sections={sections} />;\n\n// Shared, so an update doesn't render the default parts' wrappers again.\nconst PLUS = <span data-menu-trigger-icon=\"\" aria-hidden=\"true\" />;\nconst DEFAULT_PARTS = (\n  <>\n    <AddMenuTrigger />\n    <AddMenuContent />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/add-menu.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
