{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "question-vue",
  "title": "Question (Vue)",
  "description": "Single choice, multiple choice and free text questions in one form, then the recorded answers.",
  "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-radio-vue",
    "@kind-ui/internal-checkbox-vue",
    "@kind-ui/internal-textarea-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/question.ts",
      "content": "import type { Question as QuestionData } from \"@kind-ui/agent-ui\";\nimport {\n  type QuestionChoicesState,\n  type QuestionSummaryItem,\n  type QuestionTextState,\n  questionPrimitive,\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 { KindCheckbox, KindCheckboxGroup, KindCheckboxIndicator } from \"./internal/checkbox\";\nimport { KindRadio, KindRadioGroup, KindRadioIndicator } from \"./internal/radio\";\nimport { KindTextarea } from \"./internal/textarea\";\n\nconst parts = createParts(questionPrimitive, {\n  root: \"form\",\n  item: \"fieldset\",\n  prompt: \"legend\",\n  choices: \"div\",\n  text: \"div\",\n  actions: \"div\",\n  submit: \"button\",\n  skip: \"button\",\n  status: \"span\",\n  \"status-icon\": \"span\",\n  error: \"span\",\n  summary: \"div\",\n  \"summary-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// 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  state.label,\n];\n\n// Lucide's check, as the status mark draws it.\nconst check = () =>\n  h(\n    \"svg\",\n    {\n      viewBox: \"0 0 24 24\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"3.5\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [h(\"path\", { d: \"M20 6 9 17l-5-5\" })],\n  );\n\nexport const QuestionActions = parts.Actions;\nexport const QuestionStatusIcon = parts.StatusIcon;\nexport const QuestionSummaryIcon = parts.SummaryIcon;\n\n/** The question's prompt, marked \"Required\" when it is, unless you fill the slot. */\nexport const QuestionPrompt = withDefault<{ prompt: string; required: boolean }>(\n  parts.Prompt,\n  \"QuestionPrompt\",\n  ({ state }) => [\n    state.prompt,\n    state.required ? [\" \", h(\"span\", { \"data-question-required\": \"\" }, \"Required\")] : null,\n  ],\n);\n\n/** A radio group for a single choice or a checkbox group for a multiple one, unless you fill the slot. */\nexport const QuestionChoices = withDefault<QuestionChoicesState | { kind?: undefined }>(\n  parts.Choices,\n  \"QuestionChoices\",\n  ({ state }) => {\n    // The slot's state proxy answers reads but not `in`.\n    if (!state.kind) return null;\n    const options = () =>\n      state.options.map((option) =>\n        h(\"label\", { key: option.value, \"data-question-option\": \"\" }, [\n          state.kind === \"single\"\n            ? h(KindRadio, { value: option.value }, () => h(KindRadioIndicator))\n            : h(KindCheckbox, { value: option.value }, () => h(KindCheckboxIndicator, null, check)),\n          h(\"span\", { \"data-question-option-text\": \"\" }, [\n            h(\"span\", option.label),\n            option.description\n              ? h(\"span\", { \"data-question-option-description\": \"\" }, option.description)\n              : null,\n          ]),\n        ]),\n      );\n    return state.kind === \"single\"\n      ? h(\n          KindRadioGroup,\n          {\n            \"aria-labelledby\": state.labelledBy,\n            controller: state.controller,\n            defaultValue: state.defaultValue,\n            readOnly: state.readOnly,\n          },\n          options,\n        )\n      : h(\n          KindCheckboxGroup,\n          { controller: state.controller, defaultValue: state.defaultValue, readOnly: state.readOnly },\n          options,\n        );\n  },\n);\n\n/** A text box for a text question, unless you fill the slot. Enter adds a line; it never submits. */\nexport const QuestionText = withDefault<QuestionTextState | { controller?: undefined }>(\n  parts.Text,\n  \"QuestionText\",\n  ({ state }) =>\n    state.controller\n      ? h(KindTextarea, {\n          controller: state.controller,\n          defaultValue: state.defaultValue,\n          readOnly: state.readOnly,\n          placeholder: state.placeholder,\n          \"aria-label\": state.label,\n          rows: 3,\n        })\n      : null,\n);\n\n/** Calls `onSubmit`. Reads the `submitLabel` unless you fill the slot. Rendered only while `onSubmit` is set. */\nexport const QuestionSubmit = withDefault(parts.Submit, \"QuestionSubmit\", withPendingMark);\n\n/** Calls `onSkip`. Reads the `skipLabel` unless you fill the slot. Rendered only while `onSkip` is set. */\nexport const QuestionSkip = withDefault(parts.Skip, \"QuestionSkip\", withPendingMark);\n\n/**\n * \"Sending answers\" or \"Skipping\" while the host has them, unless you fill the slot. The pressed button holds the\n * running mark, so the words stand alone.\n */\nexport const QuestionStatus = withDefault<{ label: string }>(\n  parts.Status,\n  \"QuestionStatus\",\n  ({ state }) => state.label,\n);\n\n/** \"Answers not sent. Try again.\" after a submission fails, unless you fill the slot. */\nexport const QuestionError = withDefault(parts.Error, \"QuestionError\", () => \"Answers not sent. Try again.\");\n\n/** \"Answered\" with each question and its answer, or \"Skipped\", unless you fill the slot. */\nexport const QuestionSummary = withDefault<{ outcome: string; items: QuestionSummaryItem[] }>(\n  parts.Summary,\n  \"QuestionSummary\",\n  ({ state }) => [\n    h(\"span\", { \"data-question-outcome\": \"\" }, [h(QuestionSummaryIcon), state.outcome]),\n    state.items.length > 0\n      ? h(\n          \"dl\",\n          state.items.map((item) =>\n            h(\"div\", { key: item.id }, [\n              h(\"dt\", item.prompt),\n              h(\n                \"dd\",\n                { \"data-empty\": item.answer === undefined ? \"\" : undefined },\n                item.answer ?? \"No answer\",\n              ),\n            ]),\n          ),\n        )\n      : null,\n  ],\n);\n\nconst itemParts = () => [h(QuestionPrompt), h(QuestionChoices), h(QuestionText)];\n\n/** The question whose `id` is `value`. Without a default slot, it shows its prompt and its choices or text box. */\nexport const QuestionItem = withDefault(parts.Item, \"QuestionItem\", itemParts);\n\nconst defaultParts = ({ state }: { state: { questions: QuestionData[] } }) => [\n  ...state.questions.map((question) => h(QuestionItem, { key: question.id, value: question.id })),\n  h(QuestionActions, null, () => [h(QuestionSubmit), h(QuestionSkip), h(QuestionStatus), h(QuestionError)]),\n  h(QuestionSummary),\n];\n\n/**\n * One question or several in one form, each a fieldset, with Submit and Skip, then the recorded answers in the form's\n * place. A default slot replaces the default parts.\n */\nexport const Question = withDefault(parts.Root, \"Question\", defaultParts);\n",
      "type": "registry:ui",
      "target": "@ui/vue/question.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
