{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "add-menu-solid",
  "title": "Add Menu (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-menu-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/add-menu.tsx",
      "content": "import {\n  type AddMenuContentState,\n  type AddMenuOptions,\n  type AddMenuRow,\n  type AddMenuSection,\n  addMenuPrimitive,\n  type MenuPartState,\n  type MenuTriggerState,\n} from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { MenuTrigger } from \"@ui-sdk/solid/menu\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, Show } from \"solid-js\";\nimport {\n  childrenOr,\n  KindMenu,\n  KindMenuContent,\n  KindMenuGroup,\n  KindMenuGroupLabel,\n  KindMenuItem,\n  KindMenuItemContent,\n  KindMenuSeparator,\n  KindMenuSub,\n  KindMenuSubContent,\n  KindMenuSubTrigger,\n  menuProps,\n  menuTriggerProps,\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 | JSX.Element | (() => JSX.Element);\n  items?: AddMenuEntry[];\n};\n\nexport type AddMenuProps = Omit<ComponentProps<typeof parts.Root>, \"children\" | \"items\"> & {\n  items?: AddMenuEntry[];\n  children?: JSX.Element;\n};\n\nfunction Row(props: { row: AddMenuRow }) {\n  return (\n    <Show\n      when={props.row.sections}\n      fallback={\n        <KindMenuItem value={props.row.id} label={props.row.label} disabled={props.row.disabled}>\n          <KindMenuItemContent\n            icon={props.row.icon}\n            label={props.row.label}\n            description={props.row.description}\n          />\n        </KindMenuItem>\n      }\n    >\n      {(sections) => (\n        <KindMenuSub>\n          <KindMenuSubTrigger disabled={props.row.disabled}>\n            <KindMenuItemContent\n              icon={props.row.icon}\n              label={props.row.label}\n              description={props.row.description}\n            />\n            <span data-menu-chevron=\"\" />\n          </KindMenuSubTrigger>\n          <KindMenuSubContent>\n            <AddMenuRows sections={sections()} />\n          </KindMenuSubContent>\n        </KindMenuSub>\n      )}\n    </Show>\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(props: AddMenuRowsProps) {\n  return (\n    <For each={props.sections} keyed={(section) => section.label ?? \"\"}>\n      {(section, index) => {\n        const rows = () => (\n          <For each={section().rows} keyed={(row) => row.id}>\n            {(row) => <Row row={row()} />}\n          </For>\n        );\n        return (\n          <>\n            <Show when={index() > 0}>\n              <KindMenuSeparator />\n            </Show>\n            <Show when={section().label !== undefined} fallback={rows()}>\n              <KindMenuGroup>\n                <KindMenuGroupLabel>{section().label}</KindMenuGroupLabel>\n                {rows()}\n              </KindMenuGroup>\n            </Show>\n          </>\n        );\n      }}\n    </For>\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(props: AddMenuProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {(menu: MenuPartState) => (\n        <KindMenu {...menuProps(menu)}>{props.children ?? <DefaultParts />}</KindMenu>\n      )}\n    </parts.Root>\n  );\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(props: AddMenuTriggerProps) {\n  return (\n    <parts.Trigger>\n      {(trigger: MenuTriggerState) => (\n        // Hidden from agents, which use the Add Menu's own actions.\n        <MenuTrigger {...menuTriggerProps(trigger)} data-agent-hidden=\"\" {...omit(props, \"children\")}>\n          {props.children ?? <span data-menu-trigger-icon=\"\" aria-hidden=\"true\" />}\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?: JSX.Element | ((state: AddMenuContentState) => JSX.Element);\n};\n\n/** The menu: UI SDK's `MenuContent` holding the rows unless you pass children. Props go to it. */\nexport function AddMenuContent(props: AddMenuContentProps) {\n  return (\n    <parts.Content>\n      {(state: AddMenuContentState) => (\n        <KindMenuContent align=\"start\" sideOffset={6} {...omit(props, \"children\")}>\n          {childrenOr(props.children, state, () => (\n            <AddMenuRows sections={state.sections} />\n          ))}\n        </KindMenuContent>\n      )}\n    </parts.Content>\n  );\n}\n\nconst DefaultParts = () => (\n  <>\n    <AddMenuTrigger />\n    <AddMenuContent />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/solid/add-menu.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
