{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "components-breadcrumb",
  "type": "registry:component",
  "title": "Breadcrumb",
  "description": "The trail to the current page, with a collapsing middle",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-icons.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/components/src/breadcrumb.tsx",
      "target": "@ui/gpuixui/components/breadcrumb.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport { Icon } from \"../icons/index.js\";\nimport {\n  BREADCRUMB_ELLIPSIS,\n  BREADCRUMB_ITEM,\n  BREADCRUMB_LINK,\n  BREADCRUMB_LIST,\n  BREADCRUMB_PAGE,\n  BREADCRUMB_ROOT,\n  BREADCRUMB_SEPARATOR,\n  cn,\n} from \"../tw/index.js\";\nimport * as Arr from \"effect/Array\";\nimport {\n  Children,\n  createContext,\n  Fragment,\n  isValidElement,\n  useContext,\n  type ReactNode,\n} from \"react\";\nimport { collapse, type Crumb } from \"./breadcrumb/logic.js\";\nimport { activationHandlers } from \"./internal/key.js\";\nimport {\n  assertParts,\n  type PartChildren,\n  type PartComponent,\n  type PartsContract,\n} from \"./internal/parts.js\";\nimport { recipeStyle } from \"./internal/recipe.js\";\nimport { keyboardRing, useTheme } from \"./internal/theme.js\";\n\ninterface BreadcrumbContextValue {\n  readonly maxItems: number | undefined;\n  readonly separator: ReactNode;\n}\n\nconst BreadcrumbContext = createContext<BreadcrumbContextValue | undefined>(\n  undefined,\n);\n\nconst useBreadcrumbContext = (): BreadcrumbContextValue => {\n  const value = useContext(BreadcrumbContext);\n  if (value === undefined) {\n    throw new Error(\"Breadcrumb parts must be used inside Breadcrumb\");\n  }\n  return value;\n};\n\nexport interface BreadcrumbProps extends Omit<Props, \"children\"> {\n  readonly maxItems?: number;\n\n  readonly separator?: ReactNode;\n\n  readonly className?: string;\n  readonly children?: PartChildren;\n}\n\nexport const Breadcrumb = ({\n  maxItems,\n  separator,\n  className,\n  children,\n  style,\n  ...rest\n}: BreadcrumbProps) => {\n  const theme = useTheme();\n  const context: BreadcrumbContextValue = { maxItems, separator };\n  assertParts(breadcrumbRoot, children);\n\n  return (\n    <BreadcrumbContext.Provider value={context}>\n      <div\n        role=\"navigation\"\n        aria-label=\"Breadcrumb\"\n        {...rest}\n        style={mergeStyles(\n          recipeStyle(cn(BREADCRUMB_ROOT, className), theme),\n          style,\n        )}\n      >\n        {children}\n      </div>\n    </BreadcrumbContext.Provider>\n  );\n};\n\ninterface Entry {\n  readonly element: ReactNode;\n  readonly separator: ReactNode;\n}\n\nconst entries = (\n  children: ReactNode,\n  fallback: ReactNode,\n): ReadonlyArray<Entry> => {\n  const collected: Array<{ element: ReactNode; separator: ReactNode }> = [];\n  let pending: ReactNode = fallback;\n\n  Arr.forEach(Children.toArray(children), (child) => {\n    if (isValidElement(child) && child.type === BreadcrumbSeparator) {\n      pending = child;\n      return;\n    }\n    collected.push({ element: child, separator: pending });\n    pending = fallback;\n  });\n\n  return collected;\n};\n\nconst Ellipsis = () => {\n  const theme = useTheme();\n  return (\n    <div style={recipeStyle(BREADCRUMB_ELLIPSIS, theme)}>\n      <Icon\n        name=\"ellipsis\"\n        size=\"xs\"\n        color={theme.colors.mutedForeground}\n        label=\"More\"\n      />\n    </div>\n  );\n};\n\nexport interface BreadcrumbListProps extends Omit<Props, \"children\"> {\n  readonly className?: string;\n  readonly children?: PartChildren;\n}\n\nexport const BreadcrumbList = ({\n  className,\n  style,\n  children,\n  ...rest\n}: BreadcrumbListProps) => {\n  const theme = useTheme();\n  const { maxItems, separator } = useBreadcrumbContext();\n  const fallback = separator ?? <BreadcrumbSeparator />;\n  const parsed = entries(children, fallback);\n  assertParts(breadcrumbList, children);\n  const crumbs: ReadonlyArray<Crumb<Entry>> =\n    maxItems === undefined\n      ? Arr.map(parsed, (item) => ({ kind: \"item\", item }))\n      : collapse(parsed, maxItems);\n\n  return (\n    <div\n      role=\"list\"\n      {...rest}\n      style={mergeStyles(\n        recipeStyle(cn(BREADCRUMB_LIST, className), theme),\n        style,\n      )}\n    >\n      {Arr.map(crumbs, (crumb, index) => {\n        const item = crumb.kind === \"item\" ? crumb.item : undefined;\n        return (\n          <Fragment key={index}>\n            {index === 0\n              ? null\n              : item === undefined\n                ? fallback\n                : item.separator}\n            {item === undefined ? <Ellipsis /> : item.element}\n          </Fragment>\n        );\n      })}\n    </div>\n  );\n};\n\nexport interface BreadcrumbItemProps extends Omit<Props, \"children\"> {\n  readonly className?: string;\n  readonly children?: PartChildren;\n}\n\nexport const BreadcrumbItem = ({\n  className,\n  children,\n  style,\n  ...rest\n}: BreadcrumbItemProps) => {\n  const theme = useTheme();\n  assertParts(breadcrumbItem, children);\n  return (\n    <div\n      role=\"listitem\"\n      {...rest}\n      style={mergeStyles(\n        recipeStyle(cn(BREADCRUMB_ITEM, className), theme),\n        style,\n      )}\n    >\n      {children}\n    </div>\n  );\n};\n\nexport interface BreadcrumbLinkProps extends Props {\n  readonly onSelect?: () => void;\n\n  readonly current?: boolean;\n\n  readonly className?: string;\n}\n\nexport const BreadcrumbLink = ({\n  onSelect,\n  current = false,\n  onClick,\n  onKeyDown,\n  onKeyUp,\n  onFocus,\n  onBlur,\n  className,\n  style,\n  ...rest\n}: BreadcrumbLinkProps) => {\n  const theme = useTheme();\n\n  if (current) {\n    return <BreadcrumbPage {...rest} className={className} style={style} />;\n  }\n\n  return (\n    <div\n      role=\"link\"\n      {...rest}\n      tabIndex={0}\n      onClick={(event) => {\n        onClick?.(event);\n        onSelect?.();\n      }}\n      {...activationHandlers(() => onSelect?.(), { onKeyDown, onKeyUp })}\n      onFocus={(event) => onFocus?.(event)}\n      onBlur={(event) => onBlur?.(event)}\n      style={mergeStyles(\n        mergeStyles(recipeStyle(cn(BREADCRUMB_LINK, className), theme), {\n          hover: { color: theme.colors.foreground },\n          ...keyboardRing(theme),\n        }),\n        style,\n      )}\n    />\n  );\n};\n\nexport interface BreadcrumbPageProps extends Props {\n  readonly className?: string;\n}\n\nexport const BreadcrumbPage = ({\n  className,\n  style,\n  ...rest\n}: BreadcrumbPageProps) => {\n  const theme = useTheme();\n  return (\n    <text\n      {...rest}\n      aria-selected\n      style={mergeStyles(\n        recipeStyle(cn(BREADCRUMB_PAGE, className), theme),\n        style,\n      )}\n    />\n  );\n};\n\nexport interface BreadcrumbSeparatorProps extends Props {\n  readonly className?: string;\n}\n\nexport const BreadcrumbSeparator = ({\n  className,\n  style,\n  ...rest\n}: BreadcrumbSeparatorProps) => {\n  const theme = useTheme();\n  return (\n    <text\n      role=\"presentation\"\n      {...rest}\n      style={mergeStyles(\n        recipeStyle(cn(BREADCRUMB_SEPARATOR, className), theme),\n        style,\n      )}\n    >\n      /\n    </text>\n  );\n};\n\nconst breadcrumbParts: ReadonlyArray<PartComponent> = [\n  Breadcrumb,\n  BreadcrumbList,\n  BreadcrumbItem,\n  BreadcrumbLink,\n  BreadcrumbPage,\n  BreadcrumbSeparator,\n];\n\nconst breadcrumbRoot: PartsContract = {\n  parent: \"Breadcrumb\",\n  family: breadcrumbParts,\n  accepts: [BreadcrumbList],\n  hint: \"Put BreadcrumbList directly inside Breadcrumb.\",\n};\n\nconst breadcrumbList: PartsContract = {\n  parent: \"BreadcrumbList\",\n  family: breadcrumbParts,\n  accepts: [BreadcrumbItem, BreadcrumbSeparator],\n  hint: \"Put BreadcrumbItem and BreadcrumbSeparator directly inside BreadcrumbList.\",\n};\n\nconst breadcrumbItem: PartsContract = {\n  parent: \"BreadcrumbItem\",\n  family: breadcrumbParts,\n  accepts: [BreadcrumbLink, BreadcrumbPage],\n  hint: \"Put BreadcrumbLink or BreadcrumbPage directly inside BreadcrumbItem.\",\n};\n\nexport const breadcrumbMeta = {\n  name: \"Breadcrumbs\",\n  tier: 2,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"no aria-current in 0.11.0; the current page publishes aria-selected, the stand-in Pagination/Stepper/Timeline use\",\n    \"maxItems reads direct children, so a custom wrapper element is counted as one entry\",\n  ],\n  docs: \"docs/breadcrumb.mdx\",\n  example: \"examples/breadcrumb.example.tsx\",\n  testFile: \"src/behaviour/breadcrumb.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/components/src/breadcrumb/logic.ts",
      "target": "@ui/gpuixui/components/breadcrumb/logic.ts",
      "type": "registry:lib",
      "content": "import * as Arr from \"effect/Array\";\n\nexport type Crumb<A> =\n  | { readonly kind: \"item\"; readonly item: A }\n  | { readonly kind: \"ellipsis\" };\n\nexport const crumb = <A>(item: A): Crumb<A> => ({ kind: \"item\", item });\n\nconst ELLIPSIS: Crumb<never> = { kind: \"ellipsis\" };\n\nconst minimum = 3;\n\nexport const collapse = <A>(\n  items: ReadonlyArray<A>,\n  requested: number,\n): ReadonlyArray<Crumb<A>> => {\n  const maxItems = Number.isNaN(requested) ? minimum : requested;\n  const budget = Math.max(minimum, Math.trunc(maxItems));\n  if (Arr.length(items) <= budget) return Arr.map(items, crumb);\n  return [\n    ...Arr.map(Arr.take(items, 1), crumb),\n    ELLIPSIS,\n    ...Arr.map(Arr.takeRight(items, budget - 2), crumb),\n  ];\n};\n"
    },
    {
      "path": "packages/components/src/internal/key.ts",
      "target": "@ui/gpuixui/components/internal/key.ts",
      "type": "registry:lib",
      "content": "import type { EventPayload, KeyEvent, Props } from \"@gpuix/react\";\nimport * as Option from \"effect/Option\";\n\nexport type KeyPhase = \"down\" | \"up\";\n\nexport const isActivation = (event: EventPayload, phase: KeyPhase): boolean => {\n  if (event.isHeld === true) return false;\n  if (event.key === \"enter\") return phase === \"down\";\n  return event.key === \"space\" && phase === \"up\";\n};\n\nexport const swallowsDefault = (\n  event: EventPayload,\n  phase: KeyPhase,\n): boolean => event.key === \"space\" && phase === \"down\";\n\nexport const activationHandlers = (\n  activate: (event: KeyEvent) => void,\n  observe: Pick<Props, \"onKeyDown\" | \"onKeyUp\"> = {},\n): Pick<Props, \"onKeyDown\" | \"onKeyUp\"> => ({\n  onKeyDown: (event: KeyEvent) => {\n    if (swallowsDefault(event, \"down\")) event.preventDefault();\n    if (isActivation(event, \"down\")) activate(event);\n    observe.onKeyDown?.(event);\n  },\n  onKeyUp: (event: KeyEvent) => {\n    if (isActivation(event, \"up\")) activate(event);\n    observe.onKeyUp?.(event);\n  },\n});\n\nexport const isEnter = (event: EventPayload): boolean => event.key === \"enter\";\n\nexport const isDown = (event: EventPayload): boolean =>\n  event.key === \"down\" || (event.key === \"n\" && event.modifiers?.ctrl === true);\n\nexport const isUp = (event: EventPayload): boolean =>\n  event.key === \"up\" || (event.key === \"p\" && event.modifiers?.ctrl === true);\n\nexport const isRight = (event: EventPayload): boolean => event.key === \"right\";\n\nexport const isLeft = (event: EventPayload): boolean => event.key === \"left\";\n\nexport const isFirst = (event: EventPayload): boolean => event.key === \"home\";\n\nexport const isLast = (event: EventPayload): boolean => event.key === \"end\";\n\nexport const isPageUp = (event: EventPayload): boolean =>\n  event.key === \"pageup\";\n\nexport const isPageDown = (event: EventPayload): boolean =>\n  event.key === \"pagedown\";\n\nexport const isDismiss = (event: EventPayload): boolean =>\n  event.key === \"escape\";\n\nexport const isTab = (event: EventPayload): boolean => event.key === \"tab\";\n\nexport const isSelectAll = (event: EventPayload): boolean =>\n  event.key === \"a\" &&\n  (event.modifiers?.cmd === true || event.modifiers?.ctrl === true);\n\nexport const isMenuKey = (event: EventPayload): boolean =>\n  (event.key === \"f10\" && event.modifiers?.shift === true) ||\n  event.key === \"contextmenu\";\n\nexport const axisDirection = (\n  event: EventPayload,\n  orientation: \"horizontal\" | \"vertical\",\n): Option.Option<1 | -1> => {\n  if (event.key === \"right\") return Option.some(1);\n  if (event.key === \"left\") return Option.some(-1);\n  if (orientation === \"vertical\") {\n    if (isDown(event)) return Option.some(1);\n    if (isUp(event)) return Option.some(-1);\n  }\n  return Option.none();\n};\n"
    },
    {
      "path": "packages/components/src/internal/parts.ts",
      "target": "@ui/gpuixui/components/internal/parts.ts",
      "type": "registry:lib",
      "content": "import * as Arr from \"effect/Array\";\nimport * as P from \"effect/Predicate\";\nimport {\n  Children,\n  Fragment,\n  isValidElement,\n  type ReactElement,\n  type ReactNode,\n} from \"react\";\n\nexport type PartComponent = (props: never) => ReactNode;\n\nexport type PartChildren =\n  | ReactElement<unknown>\n  | boolean\n  | null\n  | undefined\n  | ReadonlyArray<PartChildren>;\n\nexport interface PartsContract {\n  readonly parent: string;\n\n  readonly family: ReadonlyArray<PartComponent>;\n\n  readonly accepts: ReadonlyArray<PartComponent>;\n\n  readonly hint?: string;\n}\n\nconst componentName = (type: unknown): string =>\n  P.isString(type)\n    ? type\n    : P.isFunction(type)\n      ? type.name || \"anonymous\"\n      : \"element\";\n\nconst fragmentChildren = (element: ReactElement<unknown>): ReactNode =>\n  hasChildren(element.props) ? element.props.children : undefined;\n\nconst hasChildren = (\n  value: unknown,\n): value is { readonly children?: ReactNode } =>\n  P.isObject(value) && \"children\" in value;\n\nconst leaves = (children: ReactNode): ReadonlyArray<unknown> =>\n  Arr.flatMap(Children.toArray(children), (child) =>\n    isValidElement<unknown>(child) && child.type === Fragment\n      ? leaves(fragmentChildren(child))\n      : [child],\n  );\n\nexport const assertParts = (\n  contract: PartsContract,\n  children: ReactNode,\n): void => {\n  Arr.forEach(leaves(children), (leaf) => {\n    if (!isValidElement(leaf)) return;\n    if (Arr.some(contract.accepts, (part) => part === leaf.type)) return;\n    if (!Arr.some(contract.family, (part) => part === leaf.type)) return;\n\n    throw new Error(\n      `${componentName(leaf.type)} cannot be used inside ${contract.parent}.` +\n        (contract.hint === undefined ? \"\" : ` ${contract.hint}`),\n    );\n  });\n};\n"
    },
    {
      "path": "packages/components/src/internal/recipe.ts",
      "target": "@ui/gpuixui/components/internal/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { createRecipeCache } from \"../../tw/index.js\";\nimport type { Theme } from \"./theme.js\";\n\nexport const recipeStyle: (recipe: string, theme: Theme) => StyleDesc =\n  createRecipeCache(512);\n"
    },
    {
      "path": "packages/components/src/internal/theme.ts",
      "target": "@ui/gpuixui/components/internal/theme.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport * as Schema from \"effect/Schema\";\nimport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  brandTextOn,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  pointerWash,\n  selectionOn,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n  type BoxShadow,\n  type ElevationLevel,\n  type FindHighlightSource,\n  type NativeTextFill,\n  type PlatformName,\n  type PointerWashSurface,\n  type StatusTone,\n  type SyntaxColors,\n  type SyntaxRole,\n  type TextRole,\n  type Theme,\n  type ThemeColors,\n} from \"../../tokens/index.js\";\n\nexport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n};\nexport type {\n  BoxShadow,\n  ElevationLevel,\n  FindHighlightSource,\n  NativeTextFill,\n  PlatformName,\n  StatusTone,\n  SyntaxColors,\n  SyntaxRole,\n  TextRole,\n  Theme,\n};\nexport { ThemeProvider, useTheme } from \"../../tokens/react.js\";\n\nexport const keyboardRing = (theme: Theme, invalid = false): StyleDesc =>\n  controlFocusRing(theme, { invalid }) ?? {};\n\nexport interface ControlRingState {\n  readonly disabled?: boolean;\n\n  readonly invalid?: boolean;\n}\n\nexport const controlRing = (\n  theme: Theme,\n  state: ControlRingState = {},\n): StyleDesc => controlFocusRing(theme, state) ?? {};\n\nexport const pressWash = (theme: Theme, replaced: PointerWashSurface): string =>\n  pointerWash(theme, \"active\", replaced) ?? theme.colors.active;\n\nexport const selectionWash = (theme: Theme): StyleDesc => ({\n  selectionColor: theme.colors.selection,\n});\n\nexport const keepContent: StyleDesc = { keyboardFocusDim: false };\n\nexport const disabledFade = (\n  disabled: boolean,\n): { readonly opacity: number } | undefined =>\n  disabled ? { opacity: disabledOpacity } : undefined;\n\nconst Tones = Schema.Literals([\"info\", \"success\", \"warning\", \"danger\"]);\n\nexport type Tone = typeof Tones.Type;\n\nexport const toneOf = (value: unknown): Tone =>\n  Schema.is(Tones)(value) ? value : \"info\";\n\nexport interface ToneStyle {\n  readonly fg: string;\n  readonly bg: string;\n  readonly border: string;\n}\n\nconst TOKEN_TONE: Readonly<Record<Tone, StatusTone>> = {\n  info: \"info\",\n  success: \"success\",\n  warning: \"warning\",\n  danger: \"destructive\",\n};\n\nexport const tone = (theme: Theme, value: Tone): ToneStyle => {\n  const { background, border, foreground } = statusTone(\n    theme,\n    TOKEN_TONE[value],\n  );\n  return { bg: background, border, fg: foreground };\n};\n\nconst softRoles: Readonly<Record<Tone, keyof ThemeColors>> = {\n  info: \"infoSoft\",\n  success: \"successSoft\",\n  warning: \"warningSoft\",\n  danger: \"destructiveSoft\",\n};\n\nexport const messageLink = (theme: Theme, value: Tone): string =>\n  brandTextOn(theme, softRoles[value]);\n\nexport const messageSelection = (theme: Theme, value: Tone): string =>\n  selectionOn(theme, softRoles[value]);\n\nexport const toneSurface = (theme: Theme, value: Tone): StyleDesc => {\n  const { bg, border, fg } = tone(theme, value);\n  return {\n    backgroundColor: bg,\n    color: fg,\n    borderWidth: theme.borderWidth.thin,\n    borderColor: border,\n  };\n};\n"
    }
  ],
  "docs": "[Breadcrumb](https://gpuixui.sudokw.com/components/breadcrumb) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/components/breadcrumb",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}