{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "question-solid",
  "title": "Question (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-radio-solid",
    "@kind-ui/internal-checkbox-solid",
    "@kind-ui/internal-textarea-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/question.tsx",
      "content": "import { type QuestionChoicesState, type QuestionTextState, questionPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, Match, omit, Show, Switch } from \"solid-js\";\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\ntype Single = Extract<QuestionChoicesState, { kind: \"single\" }>;\ntype Multiple = Extract<QuestionChoicesState, { kind: \"multiple\" }>;\n\nexport type QuestionProps = ComponentProps<typeof parts.Root>;\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. Any `children` replace the default parts.\n */\nexport function Question(props: QuestionProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: { questions: { id: string }[] }) => (\n          <>\n            <For each={state.questions} keyed={(question) => question.id}>\n              {(question) => <QuestionItem value={question().id} />}\n            </For>\n            <QuestionActions>\n              <QuestionSubmit />\n              <QuestionSkip />\n              <QuestionStatus />\n              <QuestionError />\n            </QuestionActions>\n            <QuestionSummary />\n          </>\n        ))}\n    </parts.Root>\n  );\n}\n\nexport const QuestionActions = parts.Actions;\nexport const QuestionStatusIcon = parts.StatusIcon;\nexport const QuestionSummaryIcon = parts.SummaryIcon;\n\nexport type QuestionItemProps = ComponentProps<typeof parts.Item>;\n\n/** The question whose `id` is `value`. Without children, it shows its prompt and its choices or text box. */\nexport function QuestionItem(props: QuestionItemProps) {\n  return (\n    <parts.Item {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <QuestionPrompt />\n          <QuestionChoices />\n          <QuestionText />\n        </>\n      )}\n    </parts.Item>\n  );\n}\n\nexport type QuestionPromptProps = ComponentProps<typeof parts.Prompt>;\n\n/** The question's prompt, marked \"Required\" when it is, unless you pass children. */\nexport function QuestionPrompt(props: QuestionPromptProps) {\n  return (\n    <parts.Prompt {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: { prompt: string; required: boolean }) => (\n          <>\n            {state.prompt}\n            <Show when={state.required}>\n              {\" \"}\n              <span data-question-required=\"\">Required</span>\n            </Show>\n          </>\n        ))}\n    </parts.Prompt>\n  );\n}\n\nexport type QuestionChoicesProps = ComponentProps<typeof parts.Choices>;\n\n/** A radio group for a single choice or a checkbox group for a multiple one, unless you pass children. */\nexport function QuestionChoices(props: QuestionChoicesProps) {\n  return (\n    <parts.Choices {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: Partial<QuestionChoicesState>) => {\n          const options = () => (\n            <For each={state.options} keyed={(option) => option.value}>\n              {(option) => (\n                // biome-ignore lint/a11y/noLabelWithoutControl: the label wraps UI SDK's radio or checkbox, which it names.\n                <label data-question-option=\"\">\n                  <Show\n                    when={state.kind === \"single\"}\n                    fallback={\n                      <KindCheckbox value={option().value}>\n                        <KindCheckboxIndicator>\n                          <Check />\n                        </KindCheckboxIndicator>\n                      </KindCheckbox>\n                    }\n                  >\n                    <KindRadio value={option().value}>\n                      <KindRadioIndicator />\n                    </KindRadio>\n                  </Show>\n                  <span data-question-option-text=\"\">\n                    <span>{option().label}</span>\n                    <Show when={option().description}>\n                      <span data-question-option-description=\"\">{option().description}</span>\n                    </Show>\n                  </span>\n                </label>\n              )}\n            </For>\n          );\n          return (\n            <Switch>\n              <Match when={state.kind === \"single\"}>\n                <KindRadioGroup\n                  aria-labelledby={(state as Single).labelledBy}\n                  controller={(state as Single).controller}\n                  defaultValue={(state as Single).defaultValue}\n                  readOnly={(state as Single).readOnly}\n                >\n                  {options()}\n                </KindRadioGroup>\n              </Match>\n              <Match when={state.kind === \"multiple\"}>\n                <KindCheckboxGroup\n                  controller={(state as Multiple).controller}\n                  defaultValue={(state as Multiple).defaultValue}\n                  readOnly={(state as Multiple).readOnly}\n                >\n                  {options()}\n                </KindCheckboxGroup>\n              </Match>\n            </Switch>\n          );\n        })}\n    </parts.Choices>\n  );\n}\n\nexport type QuestionTextProps = ComponentProps<typeof parts.Text>;\n\n/** A text box for a text question, unless you pass children. Enter adds a line; it never submits. */\nexport function QuestionText(props: QuestionTextProps) {\n  return (\n    <parts.Text {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: Partial<QuestionTextState>) => (\n          <Show when={state.controller}>\n            <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          </Show>\n        ))}\n    </parts.Text>\n  );\n}\n\nexport type QuestionSubmitProps = ComponentProps<typeof parts.Submit>;\n\n/** Calls `onSubmit`. Reads the `submitLabel` unless you pass children. Rendered only while `onSubmit` is set. */\nexport function QuestionSubmit(props: QuestionSubmitProps) {\n  return <parts.Submit {...omit(props, \"children\")}>{props.children ?? withPendingMark}</parts.Submit>;\n}\n\nexport type QuestionSkipProps = ComponentProps<typeof parts.Skip>;\n\n/** Calls `onSkip`. Reads the `skipLabel` unless you pass children. Rendered only while `onSkip` is set. */\nexport function QuestionSkip(props: QuestionSkipProps) {\n  return <parts.Skip {...omit(props, \"children\")}>{props.children ?? withPendingMark}</parts.Skip>;\n}\n\nexport type QuestionStatusProps = ComponentProps<typeof parts.Status>;\n\n/**\n * \"Sending answers\" or \"Skipping\" while the host has them, unless you pass children. The pressed button holds the\n * running mark, so the words stand alone.\n */\nexport function QuestionStatus(props: QuestionStatusProps) {\n  return (\n    <parts.Status {...omit(props, \"children\")}>\n      {props.children ?? ((state: { label: string }) => state.label)}\n    </parts.Status>\n  );\n}\n\nexport type QuestionErrorProps = ComponentProps<typeof parts.Error>;\n\n/** \"Answers not sent. Try again.\" after a submission fails, unless you pass children. */\nexport function QuestionError(props: QuestionErrorProps) {\n  return (\n    <parts.Error {...omit(props, \"children\")}>{props.children ?? \"Answers not sent. Try again.\"}</parts.Error>\n  );\n}\n\nexport type QuestionSummaryProps = ComponentProps<typeof parts.Summary>;\n\n/** \"Answered\" with each question and its answer, or \"Skipped\", unless you pass children. */\nexport function QuestionSummary(props: QuestionSummaryProps) {\n  return (\n    <parts.Summary {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <span data-question-outcome=\"\">\n              <QuestionSummaryIcon />\n              {state.outcome}\n            </span>\n            <Show when={state.items.length > 0}>\n              <dl>\n                <For each={state.items} keyed={(item) => item.id}>\n                  {(item) => (\n                    <div>\n                      <dt>{item().prompt}</dt>\n                      <dd data-empty={item().answer === undefined ? \"\" : undefined}>\n                        {item().answer ?? \"No answer\"}\n                      </dd>\n                    </div>\n                  )}\n                </For>\n              </dl>\n            </Show>\n          </>\n        ))}\n    </parts.Summary>\n  );\n}\n\n// The mark shows only while the button's call is pending (controls.css).\nconst withPendingMark = (state: { label: string }): JSX.Element => (\n  <>\n    <span data-kind-pending-mark=\"\" data-status-mark=\"\" data-status=\"running\" aria-hidden=\"true\" />\n    {state.label}\n  </>\n);\n\n// Lucide's check, as the status mark draws it.\nfunction Check() {\n  return (\n    <svg\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      <path d=\"M20 6 9 17l-5-5\" />\n    </svg>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/question.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
