{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "context-menu",
  "title": "Context menu",
  "description": "An area that opens a menu on right-click, a long press, or the keyboard.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json",
    "https://www.cyberspec.dev/r/menu.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/context-menu.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Menu as SdkMenu, MenuContextTrigger } from \"@ui-sdk/react/menu\"\nimport { MenuPopup, type MenuEntry } from \"@/registry/cyber/ui/menu\"\nimport \"@/registry/cyber/ui/cyber/context-menu.css\"\n\n// An area with a menu of its own: right-click it, press and hold on a touch\n// screen, or focus it and press Shift+F10 (or the menu key).\n//\n// - `label` names the area, since it's a tab stop.\n// - `items` is the menu, as data (see MenuEntry in menu.tsx).\n// - `children` replace the printed instructions with your own content. Keep\n//   the three ways in somewhere on the screen if you do.\n//\n// A reticle marks the point the menu was opened from, for as long as it's\n// open. Opened from the keyboard there's no such point, and no reticle.\nfunction ContextMenu({\n  label,\n  items,\n  children,\n  ...props\n}: Omit<React.ComponentProps<typeof SdkMenu>, \"children\" | \"items\"> & {\n  label: string\n  items: MenuEntry[]\n  children?: React.ReactNode\n}) {\n  // Where the pointer last went down, measured from the area's corner. A\n  // press (rather than the contextmenu event) covers a long press on iOS,\n  // which sends no contextmenu. It's written straight to the element: it's\n  // decoration, and not worth a render on every press.\n  const mark = (event: React.PointerEvent<HTMLDivElement>) => {\n    const area = event.currentTarget\n    const box = area.getBoundingClientRect()\n    area.style.setProperty(\"--at-x\", `${event.clientX - box.left}px`)\n    area.style.setProperty(\"--at-y\", `${event.clientY - box.top}px`)\n    area.toggleAttribute(\"data-pointed\", true)\n  }\n  const unmark = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    event.currentTarget.toggleAttribute(\"data-pointed\", false)\n  }\n  return (\n    <SdkMenu {...props}>\n      <MenuContextTrigger\n        data-kit=\"context-menu\"\n        data-frame=\"tl br\"\n        tabIndex={0}\n        role=\"group\"\n        aria-label={label}\n        onPointerDown={mark}\n        onKeyDown={unmark}\n      >\n        {children ?? (\n          <>\n            <span data-kit=\"context-menu-prompt\" data-pointer=\"fine\">\n              Right-click, or press and hold\n            </span>\n            <span data-kit=\"context-menu-prompt\" data-pointer=\"coarse\">\n              Press and hold\n            </span>\n            <span data-kit=\"context-menu-keys\">\n              or focus and press\n              {/* The two keys stay on one line: they're pressed together. */}\n              <span data-kit=\"context-menu-combo\">\n                <kbd data-kit=\"context-menu-key\" data-frame=\"br\">\n                  Shift\n                </kbd>\n                <kbd data-kit=\"context-menu-key\" data-frame=\"br\">\n                  F10\n                </kbd>\n              </span>\n            </span>\n          </>\n        )}\n        <span data-kit=\"context-menu-reticle\" aria-hidden />\n        <span data-micro aria-hidden>\n          CTX // SECONDARY INPUT\n        </span>\n      </MenuContextTrigger>\n      <MenuPopup items={items} />\n    </SdkMenu>\n  )\n}\n\nexport { ContextMenu }\n",
      "type": "registry:ui",
      "target": "@ui/context-menu.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/context-menu.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.ui {\n  /* The area: a control, so its idle edge is the 70% line. Faint hatching\n     says the whole surface answers, not just the words on it. */\n  [data-skin=\"cyber\"] [data-kit=\"context-menu\"] {\n    --frame-cut: var(--cy-cut);\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel-a);\n    --frame-image: repeating-linear-gradient(\n      135deg,\n      transparent 0 7px,\n      color-mix(in srgb, var(--cy-accent) 9%, transparent) 7px 8px\n    );\n\n    display: grid;\n    place-content: center;\n    justify-items: center;\n    gap: 4px;\n    width: 100%;\n    min-height: 132px;\n    padding: 20px 16px 22px;\n    overflow: hidden;\n    text-align: center;\n    cursor: context-menu;\n    /* A long press opens the menu, so it shouldn't also select the words or\n       call up the system's own sheet. */\n    user-select: none;\n    -webkit-touch-callout: none;\n    transition:\n      background-color var(--cy-t-fast) linear,\n      border-color var(--cy-t-fast) linear;\n\n    @media (hover: hover) {\n      &:hover {\n        --frame-line: var(--cy-line-hot);\n        --frame-fill: var(--cy-fill-hover);\n      }\n    }\n\n    /* Its menu is open. */\n    &:not([data-closed]) {\n      --frame-line: var(--cy-line-hot);\n      --frame-fill: var(--cy-fill-hover);\n    }\n\n    &[data-disabled] {\n      --frame-line: var(--cy-line-deco);\n      color: var(--cy-ink-mute);\n      cursor: not-allowed;\n    }\n\n    /* The print sits in the corner the frame doesn't cut. */\n    & > [data-micro] {\n      position: absolute;\n      inset-block-end: 6px;\n      inset-inline-start: 10px;\n    }\n  }\n\n  /* How to open it, said for the pointer in use. */\n  [data-skin=\"cyber\"] [data-kit=\"context-menu-prompt\"] {\n    font-size: var(--cy-text-md);\n    font-weight: 600;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--cy-ink);\n\n    &[data-pointer=\"coarse\"] {\n      display: none;\n    }\n\n    @media (pointer: coarse) {\n      &[data-pointer=\"fine\"] {\n        display: none;\n      }\n      &[data-pointer=\"coarse\"] {\n        display: inline;\n      }\n    }\n  }\n\n  /* The way in from the keyboard, with its keys as caps. */\n  [data-skin=\"cyber\"] [data-kit=\"context-menu-keys\"] {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    justify-content: center;\n    gap: 4px 5px;\n    font-size: var(--cy-text-sm);\n    color: var(--cy-ink-mute);\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"context-menu-combo\"] {\n    display: inline-flex;\n    gap: 5px;\n  }\n\n  /* A key cap: a small frame, with what's printed on it in the signal\n     color, like any value. */\n  [data-skin=\"cyber\"] [data-kit=\"context-menu-key\"] {\n    --frame-cut: 4px;\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n\n    min-width: 20px;\n    padding: 2px 5px 1px;\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-xs);\n    line-height: 1.2;\n    text-align: center;\n    color: var(--cy-signal);\n  }\n\n  /* The reticle: a cross and a box at the point the menu was opened from,\n     shown while it's open. The point is measured from the area's left\n     edge, in either reading direction. Opened from the keyboard there is\n     no point, so there's no reticle. */\n  [data-skin=\"cyber\"] [data-kit=\"context-menu-reticle\"] {\n    position: absolute;\n    top: var(--at-y, 50%);\n    left: var(--at-x, 50%);\n    width: 21px;\n    height: 21px;\n    margin: -10.5px;\n    border: 1px solid var(--cy-signal);\n    background:\n      linear-gradient(var(--cy-signal), var(--cy-signal)) center / 1px 9px no-repeat,\n      linear-gradient(var(--cy-signal), var(--cy-signal)) center / 9px 1px no-repeat;\n    opacity: 0;\n    pointer-events: none;\n\n    [data-pointed]:not([data-closed]) > & {\n      opacity: 1;\n      animation: var(--cy-fx-flicker) 2400ms linear infinite;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/context-menu.css"
    }
  ],
  "type": "registry:ui"
}
