{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toolbar",
  "title": "Toolbar",
  "description": "Buttons, toggles, groups, menus and a field in one row that Tab reaches once and the arrow keys move through. Each item is the Kino control it names, drawn and moving as it does alone.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/button-group.json",
    "https://kinoui.com/r/theme.json",
    "https://kinoui.com/r/flow.json",
    "https://kinoui.com/r/input.json",
    "https://kinoui.com/r/refs.json",
    "https://kinoui.com/r/separator.json",
    "https://kinoui.com/r/toggle.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/toolbar.tsx",
      "content": "'use client'\n\nimport { Button, buttonVariants } from '@/registry/components/kino/button'\nimport { ButtonGroup } from '@/registry/components/kino/button-group'\nimport { Input } from '@/registry/components/kino/input'\nimport { separatorVariants } from '@/registry/components/kino/separator'\nimport { ToggleVariantContext } from '@/registry/components/kino/toggle'\nimport { followFlow } from '@/registry/lib/flow'\nimport { mergeRefs } from '@/registry/lib/refs'\nimport {\n  Toolbar as ToolbarPrimitive,\n  ToolbarButton as ToolbarButtonPrimitive,\n  ToolbarGroup as ToolbarGroupPrimitive,\n  ToolbarInput as ToolbarInputPrimitive,\n  ToolbarLink as ToolbarLinkPrimitive,\n  ToolbarSeparator as ToolbarSeparatorPrimitive,\n} from '@ui-sdk/react/toolbar'\nimport type { VariantProps } from 'class-variance-authority'\nimport {\n  type ComponentProps,\n  createContext,\n  use,\n  useEffect,\n  useMemo,\n  useRef,\n} from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A row of Kino's own controls that Tab reaches once and the arrow keys move\n * through. Every item is the control it names, drawn and moving as it does\n * anywhere else: a Button, a Toggle, a Button group, a Toggle group, an Input.\n * A Toggle and a Toggle group join the toolbar on their own.\n */\n\ntype Orientation = 'horizontal' | 'vertical'\n\nconst OrientationContext = createContext<Orientation>('horizontal')\n\n// A Tooltip's hidden copy of its label, and what an open popup's trigger owns, aren't items.\nconst FLOW_ITEMS = ':not([aria-owns],[hidden])'\n\nfunction Toolbar({\n  ref,\n  className,\n  orientation = 'horizontal',\n  ...props\n}: Omit<ComponentProps<typeof ToolbarPrimitive>, 'className' | 'orientation'> & {\n  className?: string\n  orientation?: Orientation\n}) {\n  const rowRef = useRef<HTMLDivElement>(null)\n  const rowRefs = useMemo(() => mergeRefs(rowRef, ref), [ref])\n  // An item that changes width (a label, a spinner) moves the ones after it,\n  // and once the row wraps, onto another line: they glide there.\n  useEffect(() => {\n    if (!rowRef.current) return\n    return followFlow(rowRef.current, FLOW_ITEMS)\n  }, [])\n  return (\n    <OrientationContext value={orientation}>\n      {/* A toggle in the row is outline, as its buttons are. */}\n      <ToggleVariantContext value='outline'>\n        <ToolbarPrimitive\n          ref={rowRefs}\n          orientation={orientation}\n          className={cn(\n            // A row that runs out of room wraps, so no control is ever out of reach.\n            'relative isolate flex flex-wrap items-center gap-2 data-[orientation=vertical]:flex-col',\n            // Each item glides on `layout` (`followFlow`) and keeps its own\n            // press, in one shorthand; one removed fades where it was on `exit`.\n            '[&>*]:[transition:translate_var(--motion-layout-duration)_var(--motion-layout-easing),scale_var(--motion-press-duration)_var(--motion-press-easing),color_var(--motion-press-duration)_var(--motion-press-fade-easing),background-color_var(--motion-press-duration)_var(--motion-press-fade-easing),border-color_var(--motion-press-duration)_var(--motion-press-fade-easing),box-shadow_var(--motion-press-duration)_var(--motion-press-fade-easing)] [&>[data-flow=start]]:[transition:scale_var(--motion-press-duration)_var(--motion-press-easing),color_var(--motion-press-duration)_var(--motion-press-fade-easing),background-color_var(--motion-press-duration)_var(--motion-press-fade-easing),border-color_var(--motion-press-duration)_var(--motion-press-fade-easing),box-shadow_var(--motion-press-duration)_var(--motion-press-fade-easing)] motion-reduce:[&>*]:[transition:color_var(--motion-press-duration)_var(--motion-press-fade-easing),background-color_var(--motion-press-duration)_var(--motion-press-fade-easing),border-color_var(--motion-press-duration)_var(--motion-press-fade-easing),box-shadow_var(--motion-press-duration)_var(--motion-press-fade-easing)]',\n            '[&>[data-leaving]]:opacity-0 [&>[data-leaving]]:[transition:opacity_var(--motion-exit-duration)_var(--motion-exit-easing),translate_var(--motion-layout-duration)_var(--motion-layout-easing)]',\n            className,\n          )}\n          {...props}\n        />\n      </ToggleVariantContext>\n    </OrientationContext>\n  )\n}\n\nfunction ToolbarButton({\n  className,\n  variant = 'outline',\n  size = 'default',\n  loading,\n  disabled,\n  ...props\n}: Omit<ComponentProps<typeof ToolbarButtonPrimitive>, 'className' | 'render'> & {\n  className?: string\n} & VariantProps<typeof buttonVariants> & {\n    /** As a Button's: blocks presses at once, and shows the spinner once it lasts 200ms. */\n    loading?: boolean\n  }) {\n  return (\n    <ToolbarButtonPrimitive\n      // Loading blocks presses as disabled does, and the toolbar's button says so.\n      disabled={disabled || loading}\n      render={\n        <Button variant={variant} size={size} loading={loading} className={className} />\n      }\n      {...props}\n    />\n  )\n}\n\n/**\n * Joins its items as a Button group, slot included, so a Button inside sits\n * exactly as it does in one. It runs the way the toolbar does.\n */\nfunction ToolbarGroup(props: ComponentProps<typeof ToolbarGroupPrimitive>) {\n  const orientation = use(OrientationContext)\n  return (\n    <ToolbarGroupPrimitive\n      render={(groupProps) => <ButtonGroup {...groupProps} orientation={orientation} />}\n      {...props}\n    />\n  )\n}\n\n/** The Separator's line, across the toolbar's whole height (or width, when it runs down). */\nfunction ToolbarSeparator({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof ToolbarSeparatorPrimitive>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <ToolbarSeparatorPrimitive\n      // The toolbar decides the line's orientation: across a row, it runs down.\n      className={(state) =>\n        cn(\n          separatorVariants({ orientation: state.orientation }),\n          'self-stretch',\n          className,\n        )\n      }\n      {...props}\n    />\n  )\n}\n\n/** A link drawn as a Button. */\nfunction ToolbarLink({\n  className,\n  variant = 'outline',\n  size = 'default',\n  ...props\n}: Omit<ComponentProps<typeof ToolbarLinkPrimitive>, 'className'> & {\n  className?: string\n} & VariantProps<typeof buttonVariants>) {\n  return (\n    <ToolbarLinkPrimitive\n      className={cn(buttonVariants({ variant, size }), className)}\n      {...props}\n    />\n  )\n}\n\n/**\n * An Input whose text the arrow keys move through, leaving for the next item\n * once the caret is at that end. `className` goes to the box.\n */\nfunction ToolbarInput({\n  focusableWhenDisabled,\n  ...props\n}: Omit<ComponentProps<typeof Input>, 'render'> &\n  Pick<ComponentProps<typeof ToolbarInputPrimitive>, 'focusableWhenDisabled'>) {\n  return (\n    <Input\n      render={(inputProps) => (\n        <ToolbarInputPrimitive\n          {...inputProps}\n          focusableWhenDisabled={focusableWhenDisabled}\n        />\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Toolbar,\n  ToolbarButton,\n  ToolbarGroup,\n  ToolbarInput,\n  ToolbarLink,\n  ToolbarSeparator,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/toolbar.tsx"
    }
  ],
  "type": "registry:component"
}