{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "confirmation-vue",
  "title": "Confirmation (Vue)",
  "description": "Approve or deny an agent's request, with an optional reason, then the recorded outcome.",
  "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-textarea-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/confirmation.ts",
      "content": "import {\n  type ConfirmationReasonState,\n  codeSpans,\n  confirmationPrimitive,\n  WORDS,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type Slot, type VNodeChild } from \"vue\";\nimport { KindTextarea } from \"./internal/textarea\";\n\nconst parts = createParts(confirmationPrimitive, {\n  root: \"div\",\n  title: \"div\",\n  meta: \"span\",\n  risk: \"div\",\n  \"risk-icon\": \"span\",\n  reason: \"div\",\n  choices: \"div\",\n  approve: \"button\",\n  always: \"button\",\n  deny: \"button\",\n  cancel: \"button\",\n  error: \"span\",\n  detail: \"div\",\n  outcome: \"div\",\n  \"outcome-icon\": \"span\",\n});\n\n// A part whose default slot falls back to `fallback`, as React's default `children` do.\nconst withDefault = <State, Part extends Component = Component>(\n  part: Part,\n  name: string,\n  fallback: (scope: { state: State }) => VNodeChild,\n): Part =>\n  defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () => h(part as Component, attrs, { ...slots, default: slots.default ?? (fallback as Slot) });\n    },\n  }) as unknown as Part;\n\n/** Text with its backticks as `code`. */\nexport const withCode = (text: string) =>\n  codeSpans(text).map((piece, index) => (index % 2 ? h(\"code\", piece) : piece));\n\n// The mark shows only while the button's call is pending (controls.css).\nconst withPendingMark = ({ state }: { state: { label: string } }) => [\n  h(\"span\", {\n    \"data-kind-pending-mark\": \"\",\n    \"data-status-mark\": \"\",\n    \"data-status\": \"running\",\n    \"aria-hidden\": \"true\",\n  }),\n  ...withCode(state.label),\n];\n\nexport const ConfirmationChoices = parts.Choices;\nexport const ConfirmationOutcomeIcon = parts.OutcomeIcon;\nexport const ConfirmationRiskIcon = parts.RiskIcon;\n\n/** The `label`, unless you fill the slot. Rendered only while `label` is set, and hidden inside a Tool. */\nexport const ConfirmationTitle = withDefault<{ label: string }>(\n  parts.Title,\n  \"ConfirmationTitle\",\n  ({ state }) => withCode(state.label),\n);\n\n/** \"Sending decision\", else the deadline (\"Decide in 4 min\", then \"Expired\"), unless you fill the slot. */\nexport const ConfirmationMeta = withDefault<{ text: string }>(\n  parts.Meta,\n  \"ConfirmationMeta\",\n  ({ state }) => state.text,\n);\n\n/** The `riskText` after a warning mark, unless you fill the slot. Rendered only while `riskText` is set. */\nexport const ConfirmationRisk = withDefault<{ text: string }>(parts.Risk, \"ConfirmationRisk\", ({ state }) => [\n  h(ConfirmationRiskIcon),\n  h(\"span\", withCode(state.text)),\n]);\n\n/**\n * A box for the reason Deny sends, unless you fill the slot. Rendered with the `reason` option, once a person's Deny\n * opens it.\n */\nexport const ConfirmationReason = withDefault<ConfirmationReasonState>(\n  parts.Reason,\n  \"ConfirmationReason\",\n  ({ state }) =>\n    h(KindTextarea, {\n      controller: state.controller,\n      readOnly: state.readOnly,\n      \"aria-label\": \"Reason for denying\",\n      placeholder: \"Add a reason (optional)\",\n      rows: 2,\n    }),\n);\n\n/** Calls `onApprove`. Reads the `approveLabel` unless you fill the slot. Rendered only while `onApprove` is set. */\nexport const ConfirmationApprove = withDefault(parts.Approve, \"ConfirmationApprove\", withPendingMark);\n\n/**\n * Calls `onAlwaysAllow`, which approves and asks the host to remember. Reads the `alwaysLabel` and `alwaysTarget`\n * unless you fill the slot. Rendered only while `onAlwaysAllow` is set and `risk` isn't `\"danger\"`.\n */\nexport const ConfirmationAlways = withDefault(parts.Always, \"ConfirmationAlways\", withPendingMark);\n\n/**\n * Calls `onDeny`. With `reason`, a person's first press opens the reason box instead. Reads the `denyLabel` unless\n * you fill the slot. Rendered only while `onDeny` is set.\n */\nexport const ConfirmationDeny = withDefault(parts.Deny, \"ConfirmationDeny\", withPendingMark);\n\n/** Closes the reason box without deciding. Reads \"Cancel\" unless you fill the slot. Rendered while the box is open. */\nexport const ConfirmationCancel = withDefault(parts.Cancel, \"ConfirmationCancel\", () => \"Cancel\");\n\n/** \"Decision not sent. Try again.\" while the host reports `submit-failed`, unless you fill the slot. */\nexport const ConfirmationError = withDefault(parts.Error, \"ConfirmationError\", () => WORDS.notSentRetry);\n\n/** The `alwaysDetail`, unless you fill the slot. Rendered under the choices while Always allow shows. */\nexport const ConfirmationDetail = withDefault<{ text: string }>(\n  parts.Detail,\n  \"ConfirmationDetail\",\n  ({ state }) => withCode(state.text),\n);\n\n/** Where the request stands, like \"Approved\", with the denial's reason, unless you fill the slot. */\nexport const ConfirmationOutcome = withDefault<{ label: string; reason: string | undefined }>(\n  parts.Outcome,\n  \"ConfirmationOutcome\",\n  ({ state }) => [\n    h(ConfirmationOutcomeIcon),\n    h(\"span\", { \"data-confirmation-label\": \"\" }, withCode(state.label)),\n    \" \",\n    state.reason ? h(\"span\", { \"data-confirmation-reason\": \"\" }, state.reason) : null,\n  ],\n);\n\nconst defaultParts = () => [\n  h(ConfirmationTitle),\n  h(ConfirmationMeta),\n  h(ConfirmationRisk),\n  h(ConfirmationReason),\n  h(ConfirmationChoices, null, () => [\n    h(ConfirmationCancel),\n    h(ConfirmationDeny),\n    h(ConfirmationAlways),\n    h(ConfirmationApprove),\n    h(ConfirmationError),\n  ]),\n  h(ConfirmationDetail),\n  h(ConfirmationOutcome),\n];\n\n/**\n * Asks a person to approve or deny a request, then shows what was decided. Only the choices the host supplies\n * (`onDeny`, `onAlwaysAllow`, `onApprove`) render, in that order. A default slot replaces the default parts.\n */\nexport const Confirmation = withDefault(parts.Root, \"Confirmation\", defaultParts);\n",
      "type": "registry:ui",
      "target": "@ui/vue/confirmation.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
