{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-menu-vue",
  "title": "Settings Menu (Vue)",
  "description": "An icon button that opens a menu of settings: toggles drawn as switches, and choices in submenus showing their value.",
  "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/settings-menu.ts",
      "content": "import {\n  type MenuPartState,\n  type MenuTriggerState,\n  type SettingsMenuContentState,\n  type SettingsMenuOptions,\n  type SettingsMenuRow,\n  settingsMenuPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { MenuItemIndicator, 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  KindMenuCheckboxItem,\n  KindMenuContent,\n  KindMenuGroup,\n  KindMenuGroupLabel,\n  KindMenuItem,\n  KindMenuItemContent,\n  KindMenuItemIndicator,\n  KindMenuRadioGroup,\n  KindMenuRadioItem,\n  KindMenuSeparator,\n  KindMenuSub,\n  KindMenuSubContent,\n  KindMenuSubTrigger,\n  menuProps,\n  menuTriggerProps,\n} from \"./internal/menu\";\n\nconst parts = createParts(settingsMenuPrimitive, { root: \"div\", trigger: \"span\", content: \"div\" });\n\ntype Entry = NonNullable<SettingsMenuOptions[\"settings\"]>[number];\ntype Choice = Extract<Entry, { type: \"choice\" }>;\ntype Icon = string | VNode;\n\n/** A setting, whose `icon` and options' `icon`s are image URLs or nodes such as an inline `svg`. */\nexport type SettingsMenuSetting =\n  | (Extract<Entry, { type: \"toggle\" }> & { icon?: Icon })\n  | (Omit<Choice, \"options\"> & { icon?: Icon; options: (Choice[\"options\"][number] & { icon?: Icon })[] });\n\ntype ChoiceRow = Extract<SettingsMenuRow, { type: \"choice\" }>;\n\n/** A choice's options in one radio group, under their group labels, then its actions. */\nfunction choices(row: ChoiceRow) {\n  return [\n    h(KindMenuRadioGroup, { name: row.id, value: row.value ?? null }, () =>\n      row.groups.map((group, index) => {\n        const radios = group.options.map((option) =>\n          h(\n            KindMenuRadioItem,\n            {\n              key: option.value,\n              value: option.value,\n              label: option.label,\n              disabled: option.disabled ?? false,\n            },\n            () => [\n              h(KindMenuItemIndicator, { keepMounted: true }, () =>\n                h(\"span\", { \"data-menu-check\": \"\", \"aria-hidden\": \"true\" }),\n              ),\n              h(KindMenuItemContent, {\n                icon: option.icon,\n                label: option.label,\n                meta: option.meta,\n                metaLabel: option.metaLabel,\n              }),\n            ],\n          ),\n        );\n        // A labelled group sits inside the one radio group, which UI SDK keys by the setting's `id`.\n        return group.label === undefined\n          ? radios\n          : // By position: an inline row's own label can match a host group's.\n            h(KindMenuGroup, { key: index }, () => [\n              h(KindMenuGroupLabel, null, () => group.label),\n              ...radios,\n            ]);\n      }),\n    ),\n    row.actions.length && !row.inline ? h(KindMenuSeparator) : null,\n    ...row.actions.map((action) =>\n      h(\n        KindMenuItem,\n        {\n          key: action.value,\n          value: action.value,\n          label: action.label,\n          \"data-menu-inset\": row.inline ? \"\" : undefined,\n        },\n        () => h(KindMenuItemContent, { icon: action.icon, label: action.label }),\n      ),\n    ),\n    // Each row's name says its cost in words, so the note is for the eye.\n    ...(row.note\n      ? [h(KindMenuSeparator), h(\"span\", { \"data-menu-note\": \"\", \"aria-hidden\": \"true\" }, row.note)]\n      : []),\n  ];\n}\n\nfunction rowNodes(row: SettingsMenuRow) {\n  if (row.type === \"toggle\")\n    return h(KindMenuCheckboxItem, { value: row.id, label: row.label, checked: row.checked }, () => [\n      h(KindMenuItemContent, { icon: row.icon, label: row.label, description: row.description }),\n      h(MenuItemIndicator, { keepMounted: true, \"data-menu-switch\": \"\", \"aria-hidden\": \"true\" }, () =>\n        h(\"span\", { \"data-menu-switch-thumb\": \"\" }),\n      ),\n    ]);\n  if (row.inline) return choices(row);\n  return h(KindMenuSub, null, () => [\n    h(KindMenuSubTrigger, null, () => [\n      h(KindMenuItemContent, { icon: row.icon, label: row.label }),\n      h(\n        \"span\",\n        { \"data-settings-menu-value\": \"\" },\n        row.options.map((option) =>\n          h(\n            \"span\",\n            { key: option.value, \"data-current\": option.value === row.value ? \"\" : undefined },\n            option.label,\n          ),\n        ),\n      ),\n      h(\"span\", { \"data-menu-chevron\": \"\" }),\n    ]),\n    h(KindMenuSubContent, null, () => choices(row)),\n  ]);\n}\n\n/**\n * The rows: a switch for each toggle, and for each choice a submenu showing its value, or while `inline` a section of\n * the menu, holding its options under their group labels and any actions after them. A separator follows an inline\n * section. Model Control draws its rows with it too.\n */\nexport const SettingsMenuRows = defineComponent({\n  name: \"SettingsMenuRows\",\n  props: { rows: { type: Array as PropType<SettingsMenuRow[]>, required: true } },\n  setup(props) {\n    return () =>\n      props.rows.map((row, index) =>\n        h(Fragment, { key: row.id }, [\n          rowNodes(row),\n          row.type === \"choice\" && row.inline && index < props.rows.length - 1 ? h(KindMenuSeparator) : null,\n        ]),\n      );\n  },\n});\n\nconst icon = () => h(\"span\", { \"data-menu-trigger-icon\": \"\", \"aria-hidden\": \"true\" });\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label`, showing a settings icon unless you pass a slot. */\nexport const SettingsMenuTrigger = defineComponent({\n  name: \"SettingsMenuTrigger\",\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 Settings Menu's own actions.\n          h(\n            MenuTrigger,\n            { ...menuTriggerProps(state), \"data-agent-hidden\": \"\", ...attrs },\n            {\n              ...slots,\n              default: slots.default ?? icon,\n            },\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 SettingsMenuContent = defineComponent({\n  name: \"SettingsMenuContent\",\n  inheritAttrs: false,\n  slots: Object as SlotsType<{\n    default?: { state: SettingsMenuContentState };\n    render?: Record<string, unknown>;\n  }>,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Content, null, {\n        default: ({ state }: { state: SettingsMenuContentState }) =>\n          h(\n            KindMenuContent,\n            { align: \"start\", sideOffset: 6, ...attrs },\n            {\n              render: slots.render,\n              default: () =>\n                slots.default ? slots.default({ state }) : h(SettingsMenuRows, { rows: state.rows }),\n            },\n          ),\n      });\n  },\n});\n\nconst defaultParts = () => [h(SettingsMenuTrigger), h(SettingsMenuContent)];\n\n/**\n * An icon button named \"Settings\" that opens a menu of settings: toggles drawn as switches, which keep the menu open,\n * and choices, each a submenu of options showing the current one. A default slot replaces the trigger and the\n * content, inside UI SDK Menu.\n */\nexport const SettingsMenu = defineComponent({\n  name: \"SettingsMenu\",\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/settings-menu.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
