{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "item-slot",
  "title": "Item slot",
  "description": "A gear tile with a rarity spine, mod sockets, a count and an empty state. Set cipher to briefly split its edge on selection.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5",
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/item-slot.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Button as SdkButton } from \"@ui-sdk/react/button\"\nimport { Plus } from \"lucide-react\"\nimport { playCipherEdge } from \"@/registry/cyber/lib/cipher\"\nimport \"@/registry/cyber/ui/cyber/item-slot.css\"\n\ntype Rarity = \"common\" | \"rare\" | \"epic\" | \"legend\"\n\nconst rarityWord: Record<Rarity, string> = { common: \"common\", rare: \"rare\", epic: \"epic\", legend: \"legendary\" }\n\n// A gear slot: a square cut tile holding one item's artwork, with what's\n// known about it printed around the edges.\n//\n// - `label` names the item, or the slot when it's empty (\"Sidearm\"). The\n//   tile shows only artwork, so everything on it is spoken from the label:\n//   \"Kestrel KR-9 carbine, rare, 2 of 3 mods fitted, equipped\".\n// - `rarity` colors the spine down the leading edge.\n// - `mods`: up to four sockets, true for a fitted one. Solid pips are\n//   fitted, hollow ones are free.\n// - `count` prints a quantity; `isNew` flags it; `equipped` draws the\n//   stripe across the cut corner.\n// - `selected` presses it: the fill lights and brackets close on three\n//   corners.\n// - `cipher` briefly splits the frame and rarity spine when the slot becomes selected.\n// - `children` are the artwork, drawn in `currentColor`. With none, the\n//   slot is empty and shows a \"+\".\nfunction ItemSlot({\n  label,\n  rarity = \"common\",\n  count,\n  mods,\n  isNew,\n  equipped,\n  selected = false,\n  cipher = false,\n  size = \"md\",\n  children,\n  ...props\n}: Omit<React.ComponentProps<typeof SdkButton>, \"children\"> & {\n  label: string\n  rarity?: Rarity\n  count?: number\n  mods?: boolean[]\n  isNew?: boolean\n  equipped?: boolean\n  selected?: boolean\n  cipher?: boolean\n  size?: \"md\" | \"lg\"\n  children?: React.ReactNode\n}) {\n  const brackets = React.useRef<HTMLSpanElement>(null)\n  const wasSelected = React.useRef(selected)\n  React.useLayoutEffect(() => {\n    const justSelected = selected && !wasSelected.current\n    wasSelected.current = selected\n    if (!cipher || !justSelected) return\n    const tile = brackets.current?.closest<HTMLElement>('[data-kit=\"item-slot\"]')\n    if (tile) return playCipherEdge(tile)\n  }, [cipher, selected])\n\n  const empty = children == null || children === false\n  const sockets = mods?.slice(0, 4)\n  const spoken = empty\n    ? `${label}, empty`\n    : [\n        label,\n        rarityWord[rarity],\n        count != null && `quantity ${count}`,\n        sockets?.length && `${sockets.filter(Boolean).length} of ${sockets.length} mods fitted`,\n        equipped && \"equipped\",\n        isNew && \"new\",\n      ]\n        .filter(Boolean)\n        .join(\", \")\n\n  return (\n    <SdkButton\n      data-kit=\"item-slot\"\n      data-frame=\"br\"\n      data-press-flash=\"\"\n      data-cipher={cipher ? \"\" : undefined}\n      data-rarity={empty ? undefined : rarity}\n      data-empty={empty ? \"\" : undefined}\n      data-size={size}\n      aria-pressed={selected}\n      aria-label={spoken}\n      {...props}\n    >\n      {empty ? (\n        <Plus data-kit=\"item-slot-plus\" aria-hidden />\n      ) : (\n        <>\n          <span data-kit=\"item-slot-spine\" aria-hidden />\n          <span data-kit=\"item-slot-art\" aria-hidden>\n            {children}\n          </span>\n          {sockets && sockets.length > 0 && (\n            <span data-kit=\"item-slot-mods\" aria-hidden>\n              {sockets.map((fitted, index) => (\n                <span key={index} data-fitted={fitted ? \"\" : undefined} />\n              ))}\n            </span>\n          )}\n          {count != null && (\n            <span data-kit=\"item-slot-count\" aria-hidden>\n              {count > 99 ? \"99+\" : count}\n            </span>\n          )}\n          {isNew && (\n            <span data-kit=\"item-slot-new\" aria-hidden>\n              New\n            </span>\n          )}\n          {equipped && <span data-kit=\"item-slot-equipped\" aria-hidden />}\n        </>\n      )}\n      <span data-kit=\"item-slot-brackets\" ref={brackets} aria-hidden />\n    </SdkButton>\n  )\n}\n\nexport { ItemSlot }\nexport type { Rarity as ItemRarity }\n",
      "type": "registry:ui",
      "target": "@ui/item-slot.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/item-slot.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.ui {\n  /* A frame like any other control, so the state language is the usual\n     one: the line goes 70% to 100%, the fill 0 to 10 to 40. What's its own\n     is printed on top: the rarity spine, sockets, count, flags. */\n  [data-skin=\"cyber\"] [data-kit=\"item-slot\"] {\n    --frame-cut: 14px;\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n    /* A faint weave behind the artwork. */\n    --frame-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--cy-accent) 10%, transparent) 6px 7px);\n    --slot-size: 72px;\n    --slot-rarity: var(--cy-accent);\n\n    flex: none;\n    display: grid;\n    place-items: center;\n    width: var(--slot-size);\n    height: var(--slot-size);\n    padding: 0;\n    color: var(--cy-ink-hi);\n    cursor: pointer;\n    user-select: none;\n    transition:\n      background-color var(--cy-t-fast) linear,\n      border-color var(--cy-t-fast) linear;\n\n    &[data-size=\"lg\"] {\n      --slot-size: 96px;\n      --frame-cut: var(--cy-cut-lg);\n    }\n\n    &[data-rarity=\"rare\"] {\n      --slot-rarity: var(--cy-rare);\n    }\n    &[data-rarity=\"epic\"] {\n      --slot-rarity: var(--cy-epic);\n    }\n    &[data-rarity=\"legend\"] {\n      --slot-rarity: var(--cy-flag);\n    }\n\n    &[data-rarity] > [data-cipher-frame] > [data-frame]:not([data-cipher-edge]) {\n      border-inline-start: 5px solid var(--slot-rarity);\n    }\n\n    @media (hover: hover) {\n      &:hover:not(:disabled, [data-disabled]) {\n        --frame-line: var(--cy-line-hot);\n        --frame-fill: var(--cy-fill-hover);\n      }\n    }\n\n    &:is(:active, [aria-pressed=\"true\"]):not(:disabled, [data-disabled]) {\n      --frame-line: var(--cy-line-hot);\n      --frame-fill: var(--cy-fill-active);\n    }\n\n    /* Nothing in it: no weave, and the \"+\" in the resting ink. */\n    &[data-empty] {\n      --frame-image: none;\n      color: var(--cy-ink);\n    }\n\n    &:is(:disabled, [data-disabled]) {\n      --frame-line: var(--cy-line-deco);\n      --frame-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--cy-line-deco) 5px 6px);\n      --slot-rarity: var(--cy-line-ctl);\n      color: var(--cy-ink-mute);\n      cursor: not-allowed;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-plus\"] {\n    width: 20px;\n    height: 20px;\n  }\n\n  /* Over the frame's own edge, so the leading edge is the rarity color top\n     to bottom. */\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-spine\"] {\n    position: absolute;\n    inset-block: -1px;\n    inset-inline-start: -1px;\n    width: 5px;\n    background: var(--slot-rarity);\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-art\"] {\n    display: grid;\n    place-items: center;\n    width: 64%;\n    /* Clear of the spine. */\n    margin-inline-start: 4px;\n\n    & > svg {\n      display: block;\n      width: 100%;\n      height: auto;\n      fill: currentColor;\n    }\n  }\n\n  /* Sockets, two to a row. Fitted is solid, free is hollow: the shape says\n     it, the signal color only agrees. */\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-mods\"] {\n    position: absolute;\n    inset-block-start: 5px;\n    inset-inline-start: 9px;\n    display: grid;\n    grid-template-columns: repeat(2, 7px);\n    gap: 2px;\n\n    & > span {\n      width: 7px;\n      height: 7px;\n      border: 1px solid var(--cy-signal-dim);\n      background: var(--cy-panel);\n    }\n\n    & > [data-fitted] {\n      border-color: var(--cy-signal);\n      background: var(--cy-signal);\n    }\n\n    :is(:disabled, [data-disabled]) > & > span {\n      border-color: var(--cy-line-ctl);\n      background: none;\n    }\n    :is(:disabled, [data-disabled]) > & > [data-fitted] {\n      background: var(--cy-line-ctl);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-count\"] {\n    position: absolute;\n    inset-block-start: 4px;\n    inset-inline-end: 4px;\n    min-width: 18px;\n    padding: 2px 4px 1px;\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-xs);\n    font-weight: 600;\n    font-variant-numeric: tabular-nums;\n    line-height: 1.1;\n    text-align: center;\n    color: var(--cy-on-solid);\n    background: var(--cy-flag);\n    clip-path: polygon(0 0, 100% 0, 100% 100%, 4px 100%, 0 calc(100% - 4px));\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-new\"] {\n    position: absolute;\n    inset-block-end: 4px;\n    inset-inline-start: 9px;\n    padding: 1px 4px 0;\n    border: 1px solid var(--cy-flag);\n    font-size: var(--cy-text-xs);\n    font-weight: 700;\n    line-height: 1.1;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--cy-flag);\n    background: var(--cy-panel);\n  }\n\n  /* Equipped: a stripe lying along the cut corner, just inside it. */\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-equipped\"] {\n    position: absolute;\n    right: -1px;\n    bottom: -1px;\n    width: calc(var(--_cut) + 12px);\n    aspect-ratio: 1;\n    background: linear-gradient(135deg, transparent 58%, var(--cy-signal) 58% 68%, transparent 68%);\n  }\n\n  /* Selected: lock-on brackets on the three square corners. They sit a\n     little wide and invisible, and snap in when the slot is pressed. */\n  [data-skin=\"cyber\"] [data-kit=\"item-slot-brackets\"] {\n    --_b: 7px;\n\n    position: absolute;\n    inset: 2px;\n    color: var(--cy-signal);\n    background:\n      linear-gradient(currentColor, currentColor) left top / var(--_b) 2px,\n      linear-gradient(currentColor, currentColor) left top / 2px var(--_b),\n      linear-gradient(currentColor, currentColor) right top / var(--_b) 2px,\n      linear-gradient(currentColor, currentColor) right top / 2px var(--_b),\n      linear-gradient(currentColor, currentColor) left bottom / var(--_b) 2px,\n      linear-gradient(currentColor, currentColor) left bottom / 2px var(--_b);\n    background-repeat: no-repeat;\n    opacity: 0;\n    scale: 1.14;\n    pointer-events: none;\n    transition:\n      scale var(--cy-t) var(--cy-ease-snap),\n      opacity var(--cy-t-fast) linear;\n\n    [aria-pressed=\"true\"] > & {\n      opacity: 1;\n      scale: 1;\n    }\n  }\n\n  @media (forced-colors: active) {\n    [data-skin=\"cyber\"] [data-kit=\"item-slot\"][aria-pressed=\"true\"] {\n      border-color: Highlight;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/item-slot.css"
    }
  ],
  "type": "registry:ui"
}
