{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "thread-list-solid",
  "title": "Thread List (Solid)",
  "description": "Threads grouped by date, or runs by Needs you, Running and Done, with one menu to rename, pin, share, archive and delete.",
  "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-menu-solid",
    "@kind-ui/internal-alert-dialog-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/thread-list.tsx",
      "content": "import {\n  type MenuPartState,\n  type ThreadListDialogState,\n  type ThreadListGridState,\n  type ThreadListLinkState,\n  type ThreadListMenuContentState,\n  type ThreadListState,\n  type ThreadListSummaryState,\n  type ThreadListTimeState,\n  threadListPrimitive,\n} 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 {\n  KindAlertDialog,\n  KindAlertDialogBackdrop,\n  KindAlertDialogContent,\n  KindAlertDialogDescription,\n  KindAlertDialogTitle,\n} from \"./internal/alert-dialog\";\nimport { KindMenu, KindMenuContent, KindMenuItem, menuProps } from \"./internal/menu\";\n\nconst parts = createParts(threadListPrimitive, {\n  root: \"nav\",\n  new: \"button\",\n  viewport: \"div\",\n  grid: \"div\",\n  heading: \"div\",\n  \"heading-cell\": \"div\",\n  row: \"div\",\n  \"link-cell\": \"div\",\n  link: \"a\",\n  status: \"span\",\n  unread: \"span\",\n  summary: \"span\",\n  time: \"span\",\n  editor: \"input\",\n  \"more-cell\": \"div\",\n  more: \"button\",\n  unarchive: \"button\",\n  \"fold-row\": \"div\",\n  \"fold-cell\": \"div\",\n  fold: \"button\",\n  empty: \"p\",\n  menu: \"div\",\n  \"menu-content\": \"div\",\n  dialog: \"div\",\n  \"dialog-error\": \"span\",\n  \"dialog-cancel\": \"button\",\n  \"dialog-delete\": \"button\",\n  end: \"div\",\n  retry: \"button\",\n});\n\nexport type ThreadListProps = ComponentProps<typeof parts.Root>;\n\n/**\n * The threads as a navigation grid, grouped by pinned, the host's groups and date, or by what each run needs from the\n * person with `groupBy=\"status\"`, with New chat above and one menu of Rename, Pin, Share, Archive and Delete for every\n * row. Any `children` replace the default parts.\n */\nexport function ThreadList(props: ThreadListProps) {\n  return <parts.Root {...omit(props, \"children\")}>{props.children ?? <DefaultParts />}</parts.Root>;\n}\n\nexport type ThreadListNewProps = ComponentProps<typeof parts.New>;\n\n/** Calls `onNew`. Reads \"New chat\" unless you pass children. Rendered only while `onNew` is set. */\nexport function ThreadListNew(props: ThreadListNewProps) {\n  return (\n    <parts.New {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <span data-thread-list-icon=\"new\" aria-hidden=\"true\" />\n          New chat\n        </>\n      )}\n    </parts.New>\n  );\n}\n\nexport type ThreadListEmptyProps = ComponentProps<typeof parts.Empty>;\n\n/** \"Nothing is waiting on you.\" when grouped by status with nothing waiting or running, unless you pass children. */\nexport function ThreadListEmpty(props: ThreadListEmptyProps) {\n  return (\n    <parts.Empty {...omit(props, \"children\")}>\n      {props.children ?? ((state: { text: string }) => state.text)}\n    </parts.Empty>\n  );\n}\n\n/** Scrolls the rows, of which it renders only those in view. Holds a `ThreadListGrid` and a `ThreadListEnd`. */\nexport const ThreadListViewport = parts.Viewport;\n\nexport type ThreadListGridProps = ComponentProps<typeof parts.Grid>;\n\n/** A `ThreadListHeading`, `ThreadListRow` or `ThreadListFold` for each row in view, unless you pass children. */\nexport function ThreadListGrid(props: ThreadListGridProps) {\n  return (\n    <parts.Grid {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: ThreadListGridState) => (\n          // Keyed by row key, so a row keeps its element as it scrolls or moves.\n          <For each={state.visible} keyed={(item) => item.key}>\n            {(item) => (\n              <Switch fallback={<ThreadListRow value={item().key} />}>\n                <Match when={state.rows[item().index]?.type === \"heading\"}>\n                  <ThreadListHeading value={item().key} />\n                </Match>\n                <Match when={state.rows[item().index]?.type === \"fold\"}>\n                  <ThreadListFold value={item().key} />\n                </Match>\n              </Switch>\n            )}\n          </For>\n        ))}\n    </parts.Grid>\n  );\n}\n\nexport type ThreadListHeadingProps = ComponentProps<typeof parts.Heading>;\n\n/** A group's heading, by its row key, with its count when grouped by status. */\nexport function ThreadListHeading(props: ThreadListHeadingProps) {\n  return (\n    <parts.Heading {...props}>\n      <parts.HeadingCell value={props.value}>\n        {(state: { label: string; count: string }) => (\n          <>\n            {state.label}\n            <Show when={state.count}>\n              {\" \"}\n              <span data-thread-list-count=\"\">{state.count}</span>\n            </Show>\n          </>\n        )}\n      </parts.HeadingCell>\n    </parts.Heading>\n  );\n}\n\nexport type ThreadListFoldProps = ComponentProps<typeof parts.FoldRow>;\n\n/** The row after \"Done\"'s threads: \"12 more done\", which shows a page more, then \"Show less\". */\nexport function ThreadListFold(props: ThreadListFoldProps) {\n  return (\n    <parts.FoldRow {...props}>\n      <parts.FoldCell value={props.value}>\n        <parts.Fold value={props.value}>\n          {(state: { label: string }) => (\n            <>\n              <span data-thread-list-icon=\"fold\" aria-hidden=\"true\" />\n              {state.label}\n            </>\n          )}\n        </parts.Fold>\n      </parts.FoldCell>\n    </parts.FoldRow>\n  );\n}\n\nexport type ThreadListRowProps = Omit<ComponentProps<typeof parts.Row>, \"children\"> & {\n  /** What the link shows, a function of its `{ value, title }`. */\n  children?: (state: ThreadListLinkState) => JSX.Element;\n};\n\n/**\n * A thread's row, by its id: its link, which also opens the row's menu on a right-click or Shift+F10, how long ago it\n * changed, and its More button, or Unarchive in the archived view, which takes the time's place on hover and focus.\n */\nexport function ThreadListRow(props: ThreadListRowProps) {\n  return (\n    <parts.Row {...omit(props, \"children\")}>\n      <parts.LinkCell value={props.value}>\n        <ThreadListLink value={props.value}>{props.children}</ThreadListLink>\n        <parts.Editor value={props.value} type=\"text\" />\n        <parts.Time value={props.value}>{(state: ThreadListTimeState) => state.label}</parts.Time>\n      </parts.LinkCell>\n      <parts.MoreCell value={props.value}>\n        <parts.More value={props.value} data-kind-icon-button=\"\" data-kind-size=\"sm\">\n          <span data-thread-list-icon=\"more\" aria-hidden=\"true\" />\n        </parts.More>\n        <parts.Unarchive value={props.value}>{(state: { label: string }) => state.label}</parts.Unarchive>\n      </parts.MoreCell>\n    </parts.Row>\n  );\n}\n\nexport type ThreadListLinkProps = ComponentProps<typeof parts.Link>;\n\n/** A thread's link: its title and its one mark, then its second line, unless you pass children. */\nexport function ThreadListLink(props: ThreadListLinkProps) {\n  return (\n    <parts.Link {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: ThreadListLinkState) => (\n          <>\n            <span data-thread-list-title=\"\">{state.title}</span>\n            <parts.Status value={state.value} />\n            <parts.Unread value={state.value} />\n            <parts.Summary value={state.value}>\n              {(summary: ThreadListSummaryState) => (\n                <>\n                  {summary.lead}\n                  {summary.lead && summary.pieces.length > 0 ? \" · \" : \"\"}\n                  <For each={summary.pieces} keyed={false}>\n                    {(piece, index) => (index % 2 ? <code>{piece()}</code> : <>{piece()}</>)}\n                  </For>\n                </>\n              )}\n            </parts.Summary>\n          </>\n        ))}\n    </parts.Link>\n  );\n}\n\nexport type ThreadListMenuProps = { children?: JSX.Element };\n\n/** UI SDK Menu, shared by every row, holding a `ThreadListMenuContent` unless you pass children. */\nexport function ThreadListMenu(props: ThreadListMenuProps) {\n  return (\n    <parts.Menu>\n      {(menu: MenuPartState) => (\n        <KindMenu {...menuProps(menu)}>{props.children ?? <ThreadListMenuContent />}</KindMenu>\n      )}\n    </parts.Menu>\n  );\n}\n\nexport type ThreadListMenuContentProps = Omit<ComponentProps<typeof KindMenuContent>, \"children\"> & {\n  /** The menu's items, a function of its thread and actions: a menu item for each action by default. */\n  children?: (state: ThreadListMenuContentState) => JSX.Element;\n};\n\n/** UI SDK's `MenuContent` with Rename, Pin or Unpin, Share and Delete, each while its callback is set. */\nexport function ThreadListMenuContent(props: ThreadListMenuContentProps) {\n  return (\n    <parts.MenuContent>\n      {(state: ThreadListMenuContentState) => (\n        // Hidden from agents, which use the Thread List's own actions. Kept mounted, so Menu never shows up beside it.\n        <KindMenuContent\n          align=\"end\"\n          sideOffset={4}\n          finalFocus={state.finalFocus}\n          keepMounted\n          data-agent-hidden=\"\"\n          {...omit(props, \"children\")}\n        >\n          {props.children?.(state) ?? (\n            <For each={state.actions} keyed={(action) => action.value}>\n              {(action) => (\n                <KindMenuItem\n                  value={action().value}\n                  data-destructive={action().value === \"delete\" ? \"\" : undefined}\n                >\n                  <span data-thread-list-icon={action().value} aria-hidden=\"true\" />\n                  {action().label}\n                </KindMenuItem>\n              )}\n            </For>\n          )}\n        </KindMenuContent>\n      )}\n    </parts.MenuContent>\n  );\n}\n\nexport type ThreadListDialogProps = { children?: JSX.Element };\n\n/**\n * The Alert Dialog Delete opens: \"Delete chat?\", the thread's title, and Cancel and Delete, unless you pass children\n * for the answers. Rendered only while `onDelete` is set and `confirmDelete` is on.\n */\nexport function ThreadListDialog(props: ThreadListDialogProps) {\n  return (\n    <parts.Dialog>\n      {(state: ThreadListDialogState) => (\n        <KindAlertDialog controller={state.controller} dismissible={state.dismissible}>\n          <KindAlertDialogBackdrop />\n          <KindAlertDialogContent initialFocus={state.initialFocus} finalFocus={state.finalFocus}>\n            <KindAlertDialogTitle>{state.title}</KindAlertDialogTitle>\n            <KindAlertDialogDescription>{state.description}</KindAlertDialogDescription>\n            {props.children ?? <DefaultAnswers />}\n          </KindAlertDialogContent>\n        </KindAlertDialog>\n      )}\n    </parts.Dialog>\n  );\n}\n\nexport type ThreadListDialogErrorProps = ComponentProps<typeof parts.DialogError>;\n\n/** \"Couldn't delete. Try again.\" after a delete fails, unless you pass children. */\nexport function ThreadListDialogError(props: ThreadListDialogErrorProps) {\n  return (\n    <parts.DialogError {...omit(props, \"children\")}>\n      {props.children ?? \"Couldn't delete. Try again.\"}\n    </parts.DialogError>\n  );\n}\n\nexport type ThreadListDialogCancelProps = ComponentProps<typeof parts.DialogCancel>;\n\n/** Closes the dialog. Reads \"Cancel\" unless you pass children. */\nexport function ThreadListDialogCancel(props: ThreadListDialogCancelProps) {\n  return <parts.DialogCancel {...omit(props, \"children\")}>{props.children ?? \"Cancel\"}</parts.DialogCancel>;\n}\n\nexport type ThreadListDialogDeleteProps = ComponentProps<typeof parts.DialogDelete>;\n\n/** Calls `onDelete`. Reads \"Delete\" unless you pass children. */\nexport function ThreadListDialogDelete(props: ThreadListDialogDeleteProps) {\n  return <parts.DialogDelete {...omit(props, \"children\")}>{props.children ?? \"Delete\"}</parts.DialogDelete>;\n}\n\nexport type ThreadListEndProps = ComponentProps<typeof parts.End>;\n\n/** After the rows while loading more: \"Loading more chats\", or \"Couldn't load more chats\" and Retry. */\nexport function ThreadListEnd(props: ThreadListEndProps) {\n  return (\n    <parts.End {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: { status: ThreadListState[\"loadStatus\"] }) => (\n          <Show\n            when={state.status === \"loading\"}\n            fallback={\n              <>\n                Couldn't load more chats\n                <ThreadListRetry />\n              </>\n            }\n          >\n            <span aria-hidden=\"true\" data-status-mark=\"\" data-status=\"running\" />\n            Loading more chats\n          </Show>\n        ))}\n    </parts.End>\n  );\n}\n\nexport type ThreadListRetryProps = ComponentProps<typeof parts.Retry>;\n\n/** Calls `onLoadMore` again. Reads \"Retry\" unless you pass children. */\nexport function ThreadListRetry(props: ThreadListRetryProps) {\n  return <parts.Retry {...omit(props, \"children\")}>{props.children ?? \"Retry\"}</parts.Retry>;\n}\n\nfunction DefaultAnswers() {\n  return (\n    <div data-thread-list-answers=\"\">\n      <ThreadListDialogError />\n      <ThreadListDialogCancel />\n      <ThreadListDialogDelete />\n    </div>\n  );\n}\n\nfunction DefaultParts() {\n  return (\n    <>\n      <ThreadListNew />\n      <ThreadListEmpty />\n      <ThreadListViewport>\n        <ThreadListGrid />\n        <ThreadListEnd />\n      </ThreadListViewport>\n      <ThreadListMenu />\n      <ThreadListDialog />\n    </>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/thread-list.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
