{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-menu-solid",
  "title": "Settings Menu (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-menu-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/settings-menu.tsx",
      "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 type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { MenuItemIndicator, MenuTrigger } from \"@ui-sdk/solid/menu\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, Match, omit, Show, Switch } from \"solid-js\";\nimport {\n  childrenOr,\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 | JSX.Element | (() => JSX.Element);\n\n/**\n * A setting, whose `icon` and options' `icon`s are image URLs, elements such as an inline `svg`, or functions returning\n * one, which draw a new copy wherever the icon shows.\n */\nexport type SettingsMenuSetting =\n  | (Extract<Entry, { type: \"toggle\" }> & { icon?: Icon })\n  | (Omit<Choice, \"options\"> & { icon?: Icon; options: (Choice[\"options\"][number] & { icon?: Icon })[] });\n\nexport type SettingsMenuProps = Omit<ComponentProps<typeof parts.Root>, \"children\" | \"settings\"> & {\n  settings?: SettingsMenuSetting[];\n  children?: JSX.Element;\n};\n\ntype ToggleRow = Extract<SettingsMenuRow, { type: \"toggle\" }>;\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(props: { row: ChoiceRow }) {\n  const radios = (options: () => ChoiceRow[\"groups\"][number][\"options\"]) => (\n    <For each={options()} keyed={(option) => option.value}>\n      {(option) => (\n        <KindMenuRadioItem\n          value={option().value}\n          label={option().label}\n          disabled={option().disabled ?? false}\n        >\n          <KindMenuItemIndicator keepMounted>\n            <span data-menu-check=\"\" aria-hidden=\"true\" />\n          </KindMenuItemIndicator>\n          <KindMenuItemContent\n            icon={option().icon}\n            label={option().label}\n            meta={option().meta}\n            metaLabel={option().metaLabel}\n          />\n        </KindMenuRadioItem>\n      )}\n    </For>\n  );\n  return (\n    <>\n      <KindMenuRadioGroup name={props.row.id} value={props.row.value ?? null}>\n        {/* By position: an inline row's own label can match a host group's. */}\n        <For each={props.row.groups} keyed={false}>\n          {(group) => (\n            // A labelled group sits inside the one radio group, which UI SDK keys by the setting's `id`.\n            <Show when={group().label !== undefined} fallback={radios(() => group().options)}>\n              <KindMenuGroup>\n                <KindMenuGroupLabel>{group().label}</KindMenuGroupLabel>\n                {radios(() => group().options)}\n              </KindMenuGroup>\n            </Show>\n          )}\n        </For>\n      </KindMenuRadioGroup>\n      <Show when={props.row.actions.length && !props.row.inline}>\n        <KindMenuSeparator />\n      </Show>\n      <For each={props.row.actions} keyed={(action) => action.value}>\n        {(action) => (\n          <KindMenuItem\n            value={action().value}\n            label={action().label}\n            data-menu-inset={props.row.inline ? \"\" : undefined}\n          >\n            <KindMenuItemContent icon={action().icon} label={action().label} />\n          </KindMenuItem>\n        )}\n      </For>\n      <Show when={props.row.note}>\n        <KindMenuSeparator />\n        {/* Each row's name says its cost in words, so the note is for the eye. */}\n        <span data-menu-note=\"\" aria-hidden=\"true\">\n          {props.row.note}\n        </span>\n      </Show>\n    </>\n  );\n}\n\nfunction Row(props: { row: SettingsMenuRow }) {\n  const toggle = () => props.row as ToggleRow;\n  const choice = () => props.row as ChoiceRow;\n  return (\n    <Switch>\n      <Match when={props.row.type === \"toggle\"}>\n        <KindMenuCheckboxItem value={toggle().id} label={toggle().label} checked={toggle().checked}>\n          <KindMenuItemContent\n            icon={toggle().icon}\n            label={toggle().label}\n            description={toggle().description}\n          />\n          <MenuItemIndicator keepMounted data-menu-switch=\"\" aria-hidden=\"true\">\n            <span data-menu-switch-thumb=\"\" />\n          </MenuItemIndicator>\n        </KindMenuCheckboxItem>\n      </Match>\n      <Match when={choice().inline}>\n        <Choices row={choice()} />\n      </Match>\n      <Match when>\n        <KindMenuSub>\n          <KindMenuSubTrigger>\n            <KindMenuItemContent icon={choice().icon} label={choice().label} />\n            <span data-settings-menu-value=\"\">\n              <For each={choice().options} keyed={(option) => option.value}>\n                {(option) => (\n                  <span data-current={option().value === choice().value ? \"\" : undefined}>\n                    {option().label}\n                  </span>\n                )}\n              </For>\n            </span>\n            <span data-menu-chevron=\"\" />\n          </KindMenuSubTrigger>\n          <KindMenuSubContent>\n            <Choices row={choice()} />\n          </KindMenuSubContent>\n        </KindMenuSub>\n      </Match>\n    </Switch>\n  );\n}\n\nexport type SettingsMenuRowsProps = { rows: SettingsMenuRow[] };\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 function SettingsMenuRows(props: SettingsMenuRowsProps) {\n  return (\n    <For each={props.rows} keyed={(row) => row.id}>\n      {(row, index) => (\n        <>\n          <Row row={row()} />\n          <Show\n            when={row().type === \"choice\" && (row() as ChoiceRow).inline && index() < props.rows.length - 1}\n          >\n            <KindMenuSeparator />\n          </Show>\n        </>\n      )}\n    </For>\n  );\n}\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. Any `children` replace the trigger and the content,\n * inside UI SDK Menu.\n */\nexport function SettingsMenu(props: SettingsMenuProps) {\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 SettingsMenuTriggerProps = ComponentProps<typeof MenuTrigger>;\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label`, showing a settings icon unless you pass children. */\nexport function SettingsMenuTrigger(props: SettingsMenuTriggerProps) {\n  return (\n    <parts.Trigger>\n      {(trigger: MenuTriggerState) => (\n        // Hidden from agents, which use the Settings 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 SettingsMenuContentProps = 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: SettingsMenuContentState) => JSX.Element);\n};\n\n/** The menu: UI SDK's `MenuContent` holding the rows unless you pass children. Props go to it. */\nexport function SettingsMenuContent(props: SettingsMenuContentProps) {\n  return (\n    <parts.Content>\n      {(state: SettingsMenuContentState) => (\n        <KindMenuContent align=\"start\" sideOffset={6} {...omit(props, \"children\")}>\n          {childrenOr(props.children, state, () => (\n            <SettingsMenuRows rows={state.rows} />\n          ))}\n        </KindMenuContent>\n      )}\n    </parts.Content>\n  );\n}\n\nconst DefaultParts = () => (\n  <>\n    <SettingsMenuTrigger />\n    <SettingsMenuContent />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/solid/settings-menu.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
