Mixins / foldkit-mixins-ui

ContextMenu

namespace · packages/mixins-ui/src/contextMenu.ts:1

export * as ContextMenu from './contextMenu.js'

In the guides

Members

ContextMenu.Point

interface · packages/mixins-ui/src/contextMenu.ts:20

interface Point {
  readonly x: number
  readonly y: number
}

A context menu, shadcn's and Zag's: @foldkit/ui's Menu, opened where a right press landed instead of under a button, so its keys, typeahead, dismissal and rows stay the Menu's. target goes on the area that opens it: a right press records its point, and the contextmenu that follows (a right press, Shift+F10 or the ContextMenu key, the browser's own menu kept shut) opens the menu, update folding the Menu's own Opened Message (@foldkit/ui exports no open for it). toView draws the Menu with its button turned into that point, a mark of no size the Menu's own anchor places the rows against; with no point, a menu opened from the keyboard, the mark stands at the start of the area.

ContextMenu.target

function · packages/mixins-ui/src/contextMenu.ts:33

function target<Message>(
  options: TargetOptions<Message>,
  h: HtmlBuilder<Message>,
): ReadonlyArray<Attribute<Message>>

The attributes of the area a context menu opens in.

ContextMenu.TargetOptions

interface · packages/mixins-ui/src/contextMenu.ts:25

interface TargetOptions<Message> {
  readonly onPoint: (point: Point) => Message
  readonly onOpen: Message
}

ContextMenu.toView

function · packages/mixins-ui/src/contextMenu.ts:58

function toView<Message>(
  mixins: MixinList<Message>,
  context: ResolveContext<unknown, Message>,
  point: Option.Option<Point>,
): (render: MenuRenderInfo) => Html

The Menu's toView, its rows placed at point.