{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "feedback-vue",
  "title": "Feedback (Vue)",
  "description": "Thumbs up and down for a response, with an optional comment written in a popover.",
  "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/feedback.ts",
      "content": "import {\n  type FeedbackCommentTextState,\n  type FeedbackThumbsState,\n  feedbackPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { Toggle, ToggleGroup, ToggleIcon } from \"@ui-sdk/vue/toggle\";\nimport { type Component, defineComponent, h, type Slots } from \"vue\";\nimport { KindTextarea } from \"./internal/textarea\";\n\nconst parts = createParts(feedbackPrimitive, {\n  root: \"div\",\n  thumbs: \"div\",\n  comment: \"button\",\n  thanks: \"span\",\n  content: \"div\",\n  title: \"h2\",\n  \"comment-text\": \"div\",\n  \"comment-send\": \"button\",\n  \"comment-status\": \"span\",\n  \"comment-status-icon\": \"span\",\n  \"comment-error\": \"span\",\n});\n\n// A part whose default slot falls back to `fallback` when the caller fills none.\nfunction withDefault<C extends Component>(part: C, name: string, fallback: (scope: never) => unknown): C {\n  const Part = defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () => h(part, attrs, { ...slots, default: slots.default ?? fallback } as Slots);\n    },\n  });\n  return Part as unknown as C;\n}\n\n/** \"Good response\": a Toggle whose value is `\"up\"`. */\nexport const FeedbackUp = defineComponent({\n  name: \"FeedbackUp\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        Toggle,\n        {\n          value: \"up\",\n          \"aria-label\": \"Good response\",\n          \"data-kind-icon-button\": \"\",\n          \"data-kind-size\": \"sm\",\n          ...attrs,\n        },\n        { ...slots, default: slots.default ?? (() => h(ToggleIcon, { \"data-feedback-icon\": \"up\" })) },\n      );\n  },\n}) as unknown as typeof Toggle;\n\n/** \"Bad response\": a Toggle whose value is `\"down\"`. */\nexport const FeedbackDown = defineComponent({\n  name: \"FeedbackDown\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        Toggle,\n        {\n          value: \"down\",\n          \"aria-label\": \"Bad response\",\n          \"data-kind-icon-button\": \"\",\n          \"data-kind-size\": \"sm\",\n          ...attrs,\n        },\n        { ...slots, default: slots.default ?? (() => h(ToggleIcon, { \"data-feedback-icon\": \"down\" })) },\n      );\n  },\n}) as unknown as typeof Toggle;\n\n/** UI SDK's Toggle group, holding the thumbs unless you fill its slot. One Tab stop, with arrow keys between. */\nexport const FeedbackThumbs = defineComponent({\n  name: \"FeedbackThumbs\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Thumbs, attrs, {\n        ...slots,\n        default: ({ state }: { state: FeedbackThumbsState }) =>\n          // Hidden from agents, which use the Feedback's own `rate`.\n          h(\n            ToggleGroup,\n            {\n              controller: state.controller,\n              defaultValue: state.defaultValue,\n              \"aria-label\": state[\"aria-label\"],\n              \"data-agent-hidden\": \"\",\n            },\n            () => slots.default?.() ?? [h(FeedbackUp), h(FeedbackDown)],\n          ),\n      });\n  },\n}) as unknown as typeof parts.Thumbs;\n\n/** \"Add a comment\", unless you fill its slot. Opens the comment box. Rendered once there's a rating and `onComment`. */\nexport const FeedbackComment = withDefault(parts.Comment, \"FeedbackComment\", () => \"Add a comment\");\n\n/** \"Thanks for your feedback\", unless you fill its slot. Rendered while `commentSent` is set. */\nexport const FeedbackThanks = withDefault(parts.Thanks, \"FeedbackThanks\", () => \"Thanks for your feedback\");\n\n/** \"Add a comment\", unless you fill its slot. Names the comment box; the styles keep it for assistive technology only. */\nexport const FeedbackTitle = withDefault(parts.Title, \"FeedbackTitle\", () => \"Add a comment\");\n\n/**\n * UI SDK's Textarea, unless you fill its slot, which gets its props as `state` (`<textarea v-bind=\"state\">`), its\n * placeholder keyed on the rating.\n */\nexport const FeedbackCommentText = defineComponent({\n  name: \"FeedbackCommentText\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.CommentText, attrs, {\n        ...slots,\n        default: ({ state }: { state: FeedbackCommentTextState }) => {\n          // The slot's state is a proxy that tracks each key read and lists none, so it's copied key by key for a\n          // slot that binds it with `v-bind`.\n          const props: FeedbackCommentTextState = {\n            controller: state.controller,\n            defaultValue: state.defaultValue,\n            readOnly: state.readOnly,\n            placeholder: state.placeholder,\n            \"aria-label\": state[\"aria-label\"],\n          };\n          return slots.default ? slots.default({ state: props }) : h(KindTextarea, { ...props, rows: 3 });\n        },\n      });\n  },\n}) as unknown as typeof parts.CommentText;\n\n/** Sends the comment through `onComment`. Reads \"Send\" unless you fill its slot. */\nexport const FeedbackCommentSend = withDefault(parts.CommentSend, \"FeedbackCommentSend\", () => \"Send\");\n\nexport const FeedbackCommentStatusIcon = parts.CommentStatusIcon;\n\n/** A running mark and \"Sending\" while `onComment` is pending, unless you fill its slot. */\nexport const FeedbackCommentStatus = withDefault(parts.CommentStatus, \"FeedbackCommentStatus\", () => [\n  h(FeedbackCommentStatusIcon),\n  \"Sending\",\n]);\n\n/** \"Comment not sent. Try again.\" after `onComment` rejects, unless you fill its slot. */\nexport const FeedbackCommentError = withDefault(\n  parts.CommentError,\n  \"FeedbackCommentError\",\n  () => \"Comment not sent. Try again.\",\n);\n\n/** The comment box: a title, the text, Send and its error, unless you fill its slot. */\nexport const FeedbackContent = withDefault(parts.Content, \"FeedbackContent\", () => [\n  h(FeedbackTitle),\n  h(FeedbackCommentText),\n  h(\"div\", { \"data-feedback-actions\": \"\" }, [\n    h(FeedbackCommentStatus),\n    h(FeedbackCommentError),\n    h(FeedbackCommentSend),\n  ]),\n]);\n\n/**\n * Thumbs up and down for a response, then \"Add a comment\" while `onComment` is set, which opens a box to write one.\n * Anything in its default slot replaces the default parts.\n */\nexport const Feedback = withDefault(parts.Root, \"Feedback\", () => [\n  h(FeedbackThumbs),\n  h(FeedbackComment),\n  h(FeedbackThanks),\n  h(FeedbackContent),\n]);\n",
      "type": "registry:ui",
      "target": "@ui/vue/feedback.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
