{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "context-bar-svelte",
  "title": "Context Bar (Svelte)",
  "description": "A row of removable context chips, the ones that don't fit behind a +N button that lists them.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/svelte@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ChipContent.svelte",
      "content": "<!-- A chip's icon and label, and its remove control. -->\n<script lang=\"ts\">\n  import type { ContextBarChipState } from \"@kind-ui/agent-ui/core\";\n  import type { Snippet } from \"svelte\";\n\n  let { chip, remove }: { chip: ContextBarChipState[\"chip\"]; remove: Snippet } = $props();\n  const icon = $derived(chip?.icon as string | Snippet | undefined);\n</script>\n\n{#if icon !== undefined}<span data-context-bar-icon=\"\"\n    >{#if typeof icon === \"string\"}<img src={icon} alt=\"\" />{:else}{@render icon()}{/if}</span\n  >{/if}<span data-context-bar-label=\"\">{chip?.label}</span>{@render remove()}\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ChipContent.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBar.svelte",
      "content": "<!--\n  A row of context chips: the ones that don't fit go behind a \"+N\" button whose popover lists them. With `onRemove`,\n  Delete, Backspace or a chip's remove control removes it. Any `children` replace the list, the button and the popover.\n-->\n<script lang=\"ts\">\n  import type { ComponentProps } from \"svelte\";\n  import ContextBarContent from \"./ContextBarContent.svelte\";\n  import ContextBarList from \"./ContextBarList.svelte\";\n  import ContextBarOverflow from \"./ContextBarOverflow.svelte\";\n  import type { ContextBarChipData } from \"./index\";\n  import { parts } from \"./parts\";\n\n  type RootProps = ComponentProps<typeof parts.Root>;\n  type Props = { [K in keyof RootProps as K extends \"chips\" ? never : K]: RootProps[K] } & {\n    chips?: readonly ContextBarChipData[];\n    children?: RootProps[\"children\"];\n  };\n\n  let { open = $bindable(), children: content, ...props }: Props = $props();\n</script>\n\n<parts.Root bind:open {...props}>\n  {#snippet children(state: Parameters<NonNullable<RootProps[\"children\"]>>[0])}\n    {#if content}{@render content(state)}{:else}<ContextBarList /><ContextBarOverflow /><ContextBarContent />{/if}\n  {/snippet}\n</parts.Root>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBar.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarChip.svelte",
      "content": "<!-- One chip in the bar: its icon, its label and a `ContextBarRemove`, unless you pass children. -->\n<script lang=\"ts\">\n  import type { ContextBarChipState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import ChipContent from \"./ChipContent.svelte\";\n  import { parts } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.Chip> & { children?: Snippet<[ContextBarChipState]> };\n\n  let { value, children: content, ...props }: Props = $props();\n</script>\n\n<parts.Chip {value} {...props}>\n  {#snippet children(state: ContextBarChipState)}\n    {#if content}{@render content(state)}{:else}\n      <ChipContent chip={state.chip}>\n        {#snippet remove()}<parts.Remove {value} />{/snippet}\n      </ChipContent>\n    {/if}\n  {/snippet}\n</parts.Chip>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarChip.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarContent.svelte",
      "content": "<!-- The popover of the chips that don't fit, unless you pass children. Focus moves to the first. -->\n<script lang=\"ts\">\n  import { CONTEXT_BAR_FIRST_ITEM } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps } from \"svelte\";\n  import ContextBarOverflowList from \"./ContextBarOverflowList.svelte\";\n  import ContextBarTitle from \"./ContextBarTitle.svelte\";\n  import { parts } from \"./parts\";\n\n  type ContentProps = ComponentProps<typeof parts.Content>;\n  type Props = ContentProps;\n\n  let { children: content, render: own, ...props }: Props = $props();\n</script>\n\n<parts.Content initialFocus={CONTEXT_BAR_FIRST_ITEM} sideOffset={6} align=\"end\" {...props}>\n  <!-- A sheet sits in a full-screen viewport, which renders only while the content presents as one. -->\n  {#snippet render(handed: Parameters<NonNullable<ContentProps[\"render\"]>>[0])}\n    {#if handed.state.presentation === \"sheet\"}\n      <parts.Viewport>{@render element(handed)}</parts.Viewport>\n    {:else}\n      {@render element(handed)}\n    {/if}\n  {/snippet}\n  {#snippet children(state: Parameters<NonNullable<ContentProps[\"children\"]>>[0])}\n    {#if content}{@render content(state)}{:else}<ContextBarTitle /><ContextBarOverflowList />{/if}\n  {/snippet}\n</parts.Content>\n\n{#snippet element(handed: Parameters<NonNullable<ContentProps[\"render\"]>>[0])}\n  {#if own}{@render own(handed)}{:else}<div {...handed.props}>{@render handed.children?.(handed.state)}</div>{/if}\n{/snippet}\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarContent.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarItem.svelte",
      "content": "<!-- One chip in the list of the rest, as `ContextBarChip` is in the bar, with a `ContextBarItemRemove`. -->\n<script lang=\"ts\">\n  import type { ContextBarChipState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import ChipContent from \"./ChipContent.svelte\";\n  import { parts } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.Item> & { children?: Snippet<[ContextBarChipState]> };\n\n  let { value, children: content, ...props }: Props = $props();\n</script>\n\n<parts.Item {value} {...props}>\n  {#snippet children(state: ContextBarChipState)}\n    {#if content}{@render content(state)}{:else}\n      <ChipContent chip={state.chip}>\n        {#snippet remove()}<parts.ItemRemove {value} />{/snippet}\n      </ChipContent>\n    {/if}\n  {/snippet}\n</parts.Item>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarItem.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarList.svelte",
      "content": "<!-- The row of chips, one Tab stop with arrow keys between them. Without children, a `ContextBarChip` per row. -->\n<script lang=\"ts\">\n  import type { ContextBarListState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import ContextBarChip from \"./ContextBarChip.svelte\";\n  import { parts } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.List> & { children?: Snippet<[ContextBarListState]> };\n\n  let { children: content, ...props }: Props = $props();\n</script>\n\n<parts.List {...props}>\n  {#snippet children(state: ContextBarListState)}\n    {#if content}{@render content(state)}{:else}\n      {#each state.rows as row (row.item.id)}<ContextBarChip value={row.item.id} />{/each}\n    {/if}\n  {/snippet}\n</parts.List>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarList.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarOverflow.svelte",
      "content": "<!-- The \"+N\" button, present while some chips don't fit, which opens the list of them. -->\n<script lang=\"ts\">\n  import type { ContextBarOverflowState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import { parts } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.Overflow> & { children?: Snippet<[ContextBarOverflowState]> };\n\n  let { children: content, ...props }: Props = $props();\n</script>\n\n<parts.Overflow {...props}>\n  {#snippet children(state: ContextBarOverflowState)}\n    {#if content}{@render content(state)}{:else}+{state.count}{/if}\n  {/snippet}\n</parts.Overflow>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarOverflow.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarOverflowList.svelte",
      "content": "<!-- The chips that don't fit, one Tab stop with arrow keys between them. Without children, a `ContextBarItem` per row. -->\n<script lang=\"ts\">\n  import type { ContextBarListState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import ContextBarItem from \"./ContextBarItem.svelte\";\n  import { parts } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.OverflowList> & { children?: Snippet<[ContextBarListState]> };\n\n  let { children: content, ...props }: Props = $props();\n</script>\n\n<parts.OverflowList {...props}>\n  {#snippet children(state: ContextBarListState)}\n    {#if content}{@render content(state)}{:else}\n      {#each state.rows as row (row.item.id)}<ContextBarItem value={row.item.id} />{/each}\n    {/if}\n  {/snippet}\n</parts.OverflowList>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarOverflowList.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/ContextBarTitle.svelte",
      "content": "<!-- Names the list of the chips that don't fit: the `label`. The styles keep it for assistive technology only. -->\n<script lang=\"ts\">\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import { parts } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.Title> & { children?: Snippet<[{ label: string }]> };\n\n  let { children: content, ...props }: Props = $props();\n</script>\n\n<parts.Title {...props}>\n  {#snippet children(state: { label: string })}\n    {#if content}{@render content(state)}{:else}{state.label}{/if}\n  {/snippet}\n</parts.Title>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/ContextBarTitle.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/index.ts",
      "content": "import type { ContextBarOptions } from \"@kind-ui/agent-ui/core\";\nimport type { Snippet } from \"svelte\";\nimport { parts } from \"./parts\";\n\n/** A chip, whose `icon` is an image URL or a snippet such as an inline `svg`. */\nexport type ContextBarChipData = Omit<NonNullable<ContextBarOptions[\"chips\"]>[number], \"icon\"> & {\n  icon?: string | Snippet;\n};\n\n/** A chip's remove control in the bar, for the pointer: hidden from assistive technology, which uses Delete. */\nexport const ContextBarRemove = parts.Remove;\n/** A chip's remove control in the list of the rest, as `ContextBarRemove` is in the bar. */\nexport const ContextBarItemRemove = parts.ItemRemove;\n\nexport { default as ContextBar } from \"./ContextBar.svelte\";\nexport { default as ContextBarChip } from \"./ContextBarChip.svelte\";\nexport { default as ContextBarContent } from \"./ContextBarContent.svelte\";\nexport { default as ContextBarItem } from \"./ContextBarItem.svelte\";\nexport { default as ContextBarList } from \"./ContextBarList.svelte\";\nexport { default as ContextBarOverflow } from \"./ContextBarOverflow.svelte\";\nexport { default as ContextBarOverflowList } from \"./ContextBarOverflowList.svelte\";\nexport { default as ContextBarTitle } from \"./ContextBarTitle.svelte\";\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/index.ts"
    },
    {
      "path": "packages/agent-ui/src/svelte/context-bar/parts.ts",
      "content": "import { contextBarPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/svelte/primitive\";\n\nexport const parts = createParts(contextBarPrimitive, {\n  root: \"div\",\n  list: \"ul\",\n  chip: \"li\",\n  remove: \"span\",\n  \"item-remove\": \"span\",\n  overflow: \"button\",\n  content: \"div\",\n  viewport: \"div\",\n  title: \"h2\",\n  \"overflow-list\": \"ul\",\n  item: \"li\",\n});\n",
      "type": "registry:ui",
      "target": "@ui/svelte/context-bar/parts.ts"
    }
  ],
  "meta": {
    "layer": "svelte"
  },
  "type": "registry:ui"
}
