{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "add-menu-vue",
  "title": "Add Menu (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-menu-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/add-menu.ts",
      "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 { MenuTrigger } from \"@ui-sdk/vue/menu\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { defineComponent, Fragment, h, type PropType, type SlotsType, type VNode } from \"vue\";\nimport {\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\n// `@ui-sdk/vue`'s `createParts` hands the primitive an emitter for every callback, whether or not anything listens, so\n// `onAction`, whose presence enables the items, is declared a function prop instead, which `@action` binds.\nconst primitive = Object.defineProperty(\n  Object.assign((options: never) => addMenuPrimitive(options), addMenuPrimitive, {\n    options: { ...addMenuPrimitive.options, onAction: \"action\" },\n  }),\n  \"name\",\n  { value: addMenuPrimitive.name },\n) as typeof addMenuPrimitive;\n\nconst parts = createParts(primitive, { root: \"div\", trigger: \"span\", content: \"div\" });\n\n/** An entry, whose `icon` is an image URL or a node such as an inline `svg`. */\nexport type AddMenuEntry = Omit<NonNullable<AddMenuOptions[\"items\"]>[number], \"icon\" | \"items\"> & {\n  icon?: string | VNode;\n  items?: AddMenuEntry[];\n};\n\nfunction row(row: AddMenuRow): VNode {\n  if (!row.sections)\n    return h(KindMenuItem, { key: row.id, value: row.id, label: row.label, disabled: row.disabled }, () =>\n      h(KindMenuItemContent, { icon: row.icon, label: row.label, description: row.description }),\n    );\n  const sections = row.sections;\n  return h(KindMenuSub, { key: row.id }, () => [\n    h(KindMenuSubTrigger, { disabled: row.disabled }, () => [\n      h(KindMenuItemContent, { icon: row.icon, label: row.label, description: row.description }),\n      h(\"span\", { \"data-menu-chevron\": \"\" }),\n    ]),\n    h(KindMenuSubContent, null, () => h(AddMenuRows, { sections })),\n  ]);\n}\n\n/** The rows of a level: each group under its label, separated, and a submenu for each entry with `items`. */\nexport const AddMenuRows = defineComponent({\n  name: \"AddMenuRows\",\n  props: { sections: { type: Array as PropType<AddMenuSection[]>, required: true } },\n  setup(props) {\n    return () =>\n      props.sections.map((section, index) => {\n        const rows = section.rows.map(row);\n        return h(Fragment, { key: section.label ?? \"\" }, [\n          index > 0 ? h(KindMenuSeparator) : null,\n          section.label === undefined\n            ? rows\n            : h(KindMenuGroup, null, () => [h(KindMenuGroupLabel, null, () => section.label), ...rows]),\n        ]);\n      });\n  },\n});\n\nconst plus = () => h(\"span\", { \"data-menu-trigger-icon\": \"\", \"aria-hidden\": \"true\" });\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label`, showing a plus unless you pass a slot. */\nexport const AddMenuTrigger = defineComponent({\n  name: \"AddMenuTrigger\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Trigger, null, {\n        default: ({ state }: { state: MenuTriggerState }) =>\n          // Hidden from agents, which use the Add Menu's own actions.\n          h(\n            MenuTrigger,\n            { ...menuTriggerProps(state), \"data-agent-hidden\": \"\", ...attrs },\n            { ...slots, default: slots.default ?? plus },\n          ),\n      });\n  },\n});\n\n/** The menu: UI SDK's `MenuContent` holding the rows unless you pass a slot, which gets the content's `{ state }`. Attributes go to it. */\nexport const AddMenuContent = defineComponent({\n  name: \"AddMenuContent\",\n  inheritAttrs: false,\n  slots: Object as SlotsType<{ default?: { state: AddMenuContentState }; render?: Record<string, unknown> }>,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Content, null, {\n        default: ({ state }: { state: AddMenuContentState }) =>\n          h(\n            KindMenuContent,\n            { align: \"start\", sideOffset: 6, ...attrs },\n            {\n              render: slots.render,\n              default: () =>\n                slots.default ? slots.default({ state }) : h(AddMenuRows, { sections: state.sections }),\n            },\n          ),\n      });\n  },\n});\n\nconst defaultParts = () => [h(AddMenuTrigger), h(AddMenuContent)];\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. A default slot replaces the trigger and the content, inside UI SDK Menu.\n */\nexport const AddMenu = defineComponent({\n  name: \"AddMenu\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        ...slots,\n        default: ({ state }: { state: MenuPartState }) =>\n          h(KindMenu, menuProps(state), { default: slots.default ?? defaultParts }),\n      });\n  },\n}) as unknown as typeof parts.Root;\n",
      "type": "registry:ui",
      "target": "@ui/vue/add-menu.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
