{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "context-bar-vue",
  "title": "Context Bar (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/context-bar.ts",
      "content": "import {\n  CONTEXT_BAR_FIRST_ITEM,\n  type ContextBarChipState,\n  type ContextBarListState,\n  type ContextBarOptions,\n  type ContextBarOverflowState,\n  contextBarPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type VNode } from \"vue\";\n\n// `@ui-sdk/vue`'s `createParts` hands the primitive an emitter for every callback, whether or not anything listens, so\n// `onRemove`, whose presence offers removal, is declared a function prop instead, which `@remove` binds.\nconst primitive = Object.defineProperty(\n  Object.assign((options: never) => contextBarPrimitive(options), contextBarPrimitive, {\n    options: { ...contextBarPrimitive.options, onRemove: \"action\" },\n  }),\n  \"name\",\n  { value: contextBarPrimitive.name },\n) as typeof contextBarPrimitive;\n\nconst parts = createParts(primitive, {\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\n/** A chip, whose `icon` is an image URL or a node such as an inline `svg`. */\nexport type ContextBarChipData = Omit<NonNullable<ContextBarOptions[\"chips\"]>[number], \"icon\"> & {\n  icon?: string | VNode;\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\nconst chipContent = ({ chip }: ContextBarChipState, remove: VNode) => {\n  const icon = chip?.icon as string | VNode | undefined;\n  return [\n    icon === undefined\n      ? null\n      : h(\"span\", { \"data-context-bar-icon\": \"\" }, [\n          typeof icon === \"string\" ? h(\"img\", { src: icon, alt: \"\" }) : icon,\n        ]),\n    h(\"span\", { \"data-context-bar-label\": \"\" }, chip?.label),\n    remove,\n  ];\n};\n\nconst chipPart = (name: string, part: Component, remove: Component) =>\n  defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(part, attrs, {\n          ...slots,\n          default:\n            slots.default ??\n            (({ state }: { state: ContextBarChipState }) =>\n              chipContent(state, h(remove, { value: attrs.value }))),\n        });\n    },\n  });\n\n/**\n * One chip in the bar: its icon, its label and a `ContextBarRemove`, unless you pass a slot. A new chip renders only\n * itself: the others keep their props.\n */\nexport const ContextBarChip = chipPart(\n  \"ContextBarChip\",\n  parts.Chip,\n  ContextBarRemove,\n) as unknown as typeof parts.Chip;\n\n/** One chip in the list of the rest, as `ContextBarChip` is in the bar, with a `ContextBarItemRemove`. */\nexport const ContextBarItem = chipPart(\n  \"ContextBarItem\",\n  parts.Item,\n  ContextBarItemRemove,\n) as unknown as typeof parts.Item;\n\nconst listPart = (name: string, part: Component, row: Component) =>\n  defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(part, attrs, {\n          ...slots,\n          default:\n            slots.default ??\n            (({ state }: { state: ContextBarListState }) =>\n              state.rows.map((entry) => h(row, { key: entry.item.id, value: entry.item.id }))),\n        });\n    },\n  });\n\n/** The row of chips, one Tab stop with arrow keys between them. Without a slot, a `ContextBarChip` per row. */\nexport const ContextBarList = listPart(\n  \"ContextBarList\",\n  parts.List,\n  ContextBarChip,\n) as unknown as typeof parts.List;\n\n/** The chips that don't fit, one Tab stop with arrow keys between them. Without a slot, a `ContextBarItem` per row. */\nexport const ContextBarOverflowList = listPart(\n  \"ContextBarOverflowList\",\n  parts.OverflowList,\n  ContextBarItem,\n) as unknown as typeof parts.OverflowList;\n\n/** The \"+N\" button, present while some chips don't fit, which opens the list of them. */\nexport const ContextBarOverflow = defineComponent({\n  name: \"ContextBarOverflow\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Overflow, attrs, {\n        ...slots,\n        default: slots.default ?? (({ state }: { state: ContextBarOverflowState }) => `+${state.count}`),\n      });\n  },\n}) as unknown as typeof parts.Overflow;\n\n/** Names the list of the chips that don't fit: the `label`. The styles keep it for assistive technology only. */\nexport const ContextBarTitle = defineComponent({\n  name: \"ContextBarTitle\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Title, attrs, {\n        ...slots,\n        default: slots.default ?? (({ state }: { state: { label: string } }) => state.label),\n      });\n  },\n}) as unknown as typeof parts.Title;\n\n/** The popover of the chips that don't fit, unless you pass a slot. Focus moves to the first. */\nexport const ContextBarContent = defineComponent({\n  name: \"ContextBarContent\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        parts.Content,\n        { initialFocus: CONTEXT_BAR_FIRST_ITEM, sideOffset: 6, align: \"end\", ...attrs },\n        {\n          default: slots.default ?? (() => [h(ContextBarTitle), h(ContextBarOverflowList)]),\n          // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n          render: (scope: {\n            props: Record<string, unknown>;\n            state: { presentation: string };\n            children: Component;\n          }) => {\n            const element = slots.render ? slots.render(scope) : h(\"div\", scope.props, [h(scope.children)]);\n            return [scope.state.presentation === \"sheet\" ? h(parts.Viewport, null, () => element) : element];\n          },\n        },\n      );\n  },\n}) as unknown as typeof parts.Content;\n\nconst DEFAULT_PARTS = () => [h(ContextBarList), h(ContextBarOverflow), h(ContextBarContent)];\n\n/**\n * A row of context chips: the ones that don't fit go behind a \"+N\" button whose popover lists them. With `@remove`,\n * Delete, Backspace or a chip's remove control removes it. A default slot replaces the list, the button and the popover.\n */\nexport const ContextBar = defineComponent({\n  name: \"ContextBar\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () => h(parts.Root, attrs, { ...slots, default: slots.default ?? DEFAULT_PARTS });\n  },\n}) as unknown as typeof parts.Root;\n",
      "type": "registry:ui",
      "target": "@ui/vue/context-bar.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
