{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "test-results-vue",
  "title": "Test Results (Vue)",
  "description": "A test run's pass, fail and skip counts over a filterable tree of suites, each failure open to its stack trace.",
  "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/stack-trace-vue",
    "@kind-ui/internal-tree-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/test-results.ts",
      "content": "import {\n  type TestResultsCountState,\n  type TestResultsFailureState,\n  type TestResultsRow,\n  type TestResultsTreeState,\n  testResultsPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport type { TreeItemData } from \"@ui-sdk/vue/tree\";\nimport { type Component, defineComponent, h, type PropType, type Slots } from \"vue\";\nimport {\n  KindTree,\n  KindTreeGroup,\n  KindTreeItem,\n  KindTreeItemIndicator,\n  KindTreeItemLabel,\n} from \"./internal/tree\";\nimport { StackTrace } from \"./stack-trace\";\n\nconst parts = createParts(testResultsPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  icon: \"span\",\n  title: \"span\",\n  meta: \"span\",\n  content: \"div\",\n  filter: \"div\",\n  count: \"button\",\n  tree: \"div\",\n  item: \"span\",\n  \"item-status\": \"span\",\n  failure: \"div\",\n  empty: \"p\",\n});\n\n// Lucide \"chevron-right\", see THIRD_PARTY_NOTICES.md.\nconst chevron = () =>\n  h(\n    \"svg\",\n    {\n      viewBox: \"0 0 24 24\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"2\",\n      \"aria-hidden\": \"true\",\n    },\n    [h(\"path\", { d: \"m9 18 6-6-6-6\", \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" })],\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\nexport const TestResultsTrigger = parts.Trigger;\nexport const TestResultsIcon = parts.Icon;\nexport const TestResultsContent = parts.Content;\n\n/** The `label`, else \"Tests\", unless you fill its slot. */\nexport const TestResultsTitle = withDefault(\n  parts.Title,\n  \"TestResultsTitle\",\n  ({ state }: { state: { title: string } }) => state.title,\n);\n\n/** The run's duration, unless you fill its slot. */\nexport const TestResultsMeta = withDefault(\n  parts.Meta,\n  \"TestResultsMeta\",\n  ({ state }: { state: { duration: string } }) => state.duration,\n);\n\n/**\n * A toggle button for the tests with its `value` (`\"pass\"`, `\"fail\"` or `\"skip\"`): pressing it shows only those, and\n * pressing it again shows every test. \"3 passed\", unless you fill its slot.\n */\nexport const TestResultsCount = withDefault(\n  parts.Count,\n  \"TestResultsCount\",\n  ({ state }: { state: TestResultsCountState }) => state.text,\n);\n\n/** Holds the counts beside the trigger: a `TestResultsCount` for passed, failed and skipped, unless you fill its slot. */\nexport const TestResultsFilter = withDefault(parts.Filter, \"TestResultsFilter\", () => [\n  h(TestResultsCount, { value: \"pass\" }),\n  h(TestResultsCount, { value: \"fail\" }),\n  h(TestResultsCount, { value: \"skip\" }),\n]);\n\n/** A row's status mark, read as its status and duration, like \"failed, 12 ms\". */\nexport const TestResultsItemStatus = parts.ItemStatus;\n\n/**\n * A row's name and its status mark, unless you fill its slot. Its `value` is the suite's id or the test's\n * `suiteId/testId`. The duration is drawn after them.\n */\nexport const TestResultsItem = withDefault(\n  parts.Item,\n  \"TestResultsItem\",\n  ({ state }: { state: TestResultsRow }) => [\n    h(\"span\", { \"data-test-results-name\": \"\" }, state.name),\n    \" \",\n    h(TestResultsItemStatus),\n  ],\n);\n\n/** A failed test's message and stack trace, as a Stack Trace, unless you fill its slot. Its `value` is the test's. */\nexport const TestResultsFailure = withDefault(\n  parts.Failure,\n  \"TestResultsFailure\",\n  ({ state }: { state: TestResultsFailureState }) =>\n    h(StackTrace, {\n      message: state.message || undefined,\n      stack: state.stack,\n      autoOpen: \"never\",\n      motion: state.motion,\n    }),\n);\n\n// Every row has an indicator, a passed or skipped test's an empty spacer that lines its name up with the others. It's\n// hidden from agents, which hides UI SDK's Tree from them while the rows stay the Test Results'. A row is its own\n// component, so it renders again only when core gives its suite a new item, as React's memoized row does.\nconst Row: Component<{ item: TreeItemData }> = defineComponent({\n  name: \"TestResultsRow\",\n  props: { item: { type: Object as PropType<TreeItemData>, required: true } },\n  setup(props) {\n    return () => {\n      const { item } = props;\n      return h(KindTreeItem, { value: item.value }, () => [\n        h(KindTreeItemLabel, null, () => [\n          h(KindTreeItemIndicator, { \"data-agent-hidden\": \"\" }, item.children ? chevron : undefined),\n          h(TestResultsItem, { value: item.value }),\n        ]),\n        item.children\n          ? h(KindTreeGroup, null, () =>\n              item.children?.length\n                ? h(TestResultsRows, { items: item.children })\n                : h(TestResultsFailure, { value: item.value }),\n            )\n          : null,\n      ]);\n    };\n  },\n});\n\n/** A Tree row for each item: a suite holds its tests, and a failed test its `TestResultsFailure`. */\nexport const TestResultsRows: Component<{ items: TreeItemData[] }> = defineComponent({\n  name: \"TestResultsRows\",\n  props: { items: { type: Array as PropType<TreeItemData[]>, required: true } },\n  setup(props) {\n    return () => props.items.map((item) => h(Row, { key: item.value, item }));\n  },\n});\n\n/** The suites and tests as a UI SDK Tree, with a row for each, unless you fill its slot. */\nexport const TestResultsTree = withDefault(\n  parts.Tree,\n  \"TestResultsTree\",\n  ({ state }: { state: TestResultsTreeState }) =>\n    // The slot's state is a proxy that lists no keys, so the Tree's props are read one by one.\n    h(\n      KindTree,\n      {\n        controller: state.controller,\n        items: state.items,\n        defaultExpanded: state.defaultExpanded,\n        \"aria-label\": state[\"aria-label\"],\n        mode: state.mode,\n        hiddenUntilFound: state.hiddenUntilFound,\n      },\n      () => h(TestResultsRows, { items: state.items }),\n    ),\n);\n\n/** What shows when the filter lets no test through, like \"No failed tests\", unless you fill its slot. */\nexport const TestResultsEmpty = withDefault(\n  parts.Empty,\n  \"TestResultsEmpty\",\n  ({ state }: { state: { text: string } }) => state.text,\n);\n\n/**\n * A test run as a step: its duration in the header, its counts beside it, which filter the tests when pressed, over a\n * tree of suites and tests in which a failed test opens to its message and stack trace. A default slot replaces the\n * default parts.\n */\nexport const TestResults = withDefault(parts.Root, \"TestResults\", () => [\n  h(TestResultsTrigger, null, () => [h(TestResultsIcon), h(TestResultsTitle), h(TestResultsMeta)]),\n  h(TestResultsFilter),\n  h(TestResultsContent, null, () =>\n    h(\"div\", { \"data-test-results-panel\": \"\" }, [h(TestResultsTree), h(TestResultsEmpty)]),\n  ),\n]);\n",
      "type": "registry:ui",
      "target": "@ui/vue/test-results.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
