{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "approval-mode-solid",
  "title": "Approval Mode (Solid)",
  "description": "A button showing how much the agent may do without asking, opening a menu of modes with a risky one marked.",
  "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/approval-mode.tsx",
      "content": "import {\n  APPROVAL_MODE_GROUP,\n  APPROVAL_MODE_LEARN_MORE,\n  type ApprovalModeContentState,\n  type ApprovalModeRow,\n  type ApprovalModeTriggerState,\n  approvalModePrimitive,\n  type MenuPartState,\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  KindMenuGroupLabel,\n  KindMenuItem,\n  KindMenuItemContent,\n  KindMenuItemIndicator,\n  KindMenuRadioGroup,\n  KindMenuRadioItem,\n  KindMenuSeparator,\n  menuProps,\n  menuTriggerProps,\n} from \"./internal/menu\";\n\nconst parts = createParts(approvalModePrimitive, { root: \"div\", trigger: \"span\", content: \"div\" });\n\nexport type ApprovalModeProps = Omit<ComponentProps<typeof parts.Root>, \"children\"> & {\n  children?: JSX.Element;\n};\n\n/**\n * A button showing the approval mode, named \"Approvals, <mode>\", that opens a menu of modes: radio items with a\n * description each, a risky one marked, and an optional Learn more link after them. Any `children` replace the\n * trigger and the content, inside UI SDK Menu.\n */\nexport function ApprovalMode(props: ApprovalModeProps) {\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 ApprovalModeRowsProps = Pick<ApprovalModeContentState, \"rows\">;\n\n/** The modes' radio items, a risky one marked \"Risky\". Choosing one closes the menu. */\nexport function ApprovalModeRows(props: ApprovalModeRowsProps) {\n  return (\n    <For each={props.rows} keyed={(row) => row.value}>\n      {(row) => (\n        <KindMenuRadioItem\n          value={row().value}\n          label={row().label}\n          closeOnSelect\n          data-danger={row().danger ? \"\" : undefined}\n        >\n          <KindMenuItemIndicator keepMounted>\n            <span data-menu-check=\"\" aria-hidden=\"true\" />\n          </KindMenuItemIndicator>\n          <KindMenuItemContent label={row().label} description={row().description} />\n          <Show when={row().danger}>\n            <span data-approval-mode-risk=\"\">Risky</span>\n          </Show>\n        </KindMenuRadioItem>\n      )}\n    </For>\n  );\n}\n\nfunction TriggerValue(props: { mode: ApprovalModeRow | undefined }) {\n  return (\n    <>\n      <span data-menu-trigger-icon=\"\" aria-hidden=\"true\" />\n      <Show when={props.mode}>{(mode) => <span data-approval-mode-value=\"\">{mode().label}</span>}</Show>\n      <Show when={props.mode?.danger}>\n        <span data-status-mark=\"\" data-status=\"warning\" aria-hidden=\"true\" />\n      </Show>\n    </>\n  );\n}\n\nexport type ApprovalModeTriggerProps = Omit<ComponentProps<typeof MenuTrigger>, \"children\"> & {\n  /** What the button shows, or a function of its state: a shield, the mode's label and a risky mode's mark. */\n  children?: JSX.Element | ((state: ApprovalModeTriggerState) => JSX.Element);\n};\n\n/** Opens the menu: UI SDK's `MenuTrigger`, named by the `label` and the mode. Props go to it. */\nexport function ApprovalModeTrigger(props: ApprovalModeTriggerProps) {\n  return (\n    <parts.Trigger>\n      {(trigger: ApprovalModeTriggerState) => (\n        // Hidden from agents, which use the Approval Mode's own actions.\n        <MenuTrigger {...menuTriggerProps(trigger)} data-agent-hidden=\"\" {...omit(props, \"children\")}>\n          {childrenOr(props.children, trigger, () => (\n            <TriggerValue mode={trigger.mode} />\n          ))}\n        </MenuTrigger>\n      )}\n    </parts.Trigger>\n  );\n}\n\nexport type ApprovalModeContentProps = Omit<ComponentProps<typeof KindMenuContent>, \"children\"> & {\n  /** What the radio group holds after its header, or a function of the content's state: the modes by default. */\n  children?: JSX.Element | ((state: ApprovalModeContentState) => JSX.Element);\n};\n\n/**\n * The menu: UI SDK's `MenuContent` holding one radio group, headed by the `label`, of the modes unless you pass\n * children, then a Learn more item (a link with `learnMoreHref`). Props go to the content.\n */\nexport function ApprovalModeContent(props: ApprovalModeContentProps) {\n  return (\n    <parts.Content>\n      {(state: ApprovalModeContentState) => (\n        <KindMenuContent align=\"start\" sideOffset={6} {...omit(props, \"children\")}>\n          <KindMenuRadioGroup name={APPROVAL_MODE_GROUP} value={state.value}>\n            <div data-approval-mode-header=\"\">\n              <KindMenuGroupLabel>{state.label}</KindMenuGroupLabel>\n            </div>\n            {childrenOr(props.children, state, () => (\n              <ApprovalModeRows rows={state.rows} />\n            ))}\n          </KindMenuRadioGroup>\n          <Show when={state.learnMore}>\n            <KindMenuSeparator data-approval-mode-learn-more=\"\" />\n            <KindMenuItem\n              value={APPROVAL_MODE_LEARN_MORE}\n              data-approval-mode-learn-more=\"\"\n              data-menu-inset=\"\"\n              // UI SDK reads `render` once, so the element follows `learnMoreHref` inside it.\n              render={(itemProps: JSX.HTMLAttributes<HTMLDivElement>) => (\n                <Show when={state.learnMoreHref} fallback={<div {...itemProps} />}>\n                  {(href) => (\n                    <a\n                      {...(itemProps as JSX.AnchorHTMLAttributes<HTMLAnchorElement> &\n                        JSX.HTMLAttributes<HTMLDivElement>)}\n                      href={href()}\n                    />\n                  )}\n                </Show>\n              )}\n            >\n              Learn more\n            </KindMenuItem>\n          </Show>\n        </KindMenuContent>\n      )}\n    </parts.Content>\n  );\n}\n\nconst DefaultParts = () => (\n  <>\n    <ApprovalModeTrigger />\n    <ApprovalModeContent />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/solid/approval-mode.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
