Mixins / foldkit-mixins-ui

HoverIntent

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

export * as HoverIntent from './hoverIntent.js'

Members

HoverIntent.anchor

function · packages/mixins-ui/src/hoverIntent.ts:39

function anchor(config?: AnchorConfig): AnchorConfig

A hover card's placement, the default of anchored: below its trigger and centred on it, 8px off, kept 8px inside the viewport, flipping and shifting rather than leave it. config overrides any of it.

HoverIntent.HoverIntentContext

interface · packages/mixins-ui/src/hoverIntent.ts:53

interface HoverIntentContext<Input, Message> extends ResolveContext<
  Input,
  Message
> {
  readonly anchored?: {
    readonly id: string
    readonly anchor?: AnchorConfig
  }
}

HoverIntent.HoverIntentSlots

const · packages/mixins-ui/src/hoverIntent.ts:22

const HoverIntentSlots: Slots.Contract<{
  readonly trigger: Slot.UnnamedSlot<
    Capability.Capability<
      'Interactive',
      readonly [Capability.Capability<'Base', readonly []>]
    >,
    readonly [
      Event.EventToken<'hover'>,
      Event.EventToken<'focus'>,
      Event.EventToken<'blur'>,
    ],
    readonly Slot.AttributeName[],
    readonly Slot.RequirementName[],
    boolean
  >
  readonly panel: Slot.UnnamedSlot<
    Capability.Capability<
      'Container',
      readonly [
        Capability.Capability<
          'Interactive',
          readonly [Capability.Capability<'Base', readonly []>]
        >,
      ]
    >,
    readonly [
      Event.EventToken<'hover'>,
      Event.EventToken<'focus'>,
      Event.EventToken<'blur'>,
    ],
    readonly Slot.AttributeName[],
    readonly Slot.RequirementName[],
    boolean
  >
  readonly arrow: Slot.UnnamedSlot<
    Capability.Capability<
      'Container',
      readonly [
        Capability.Capability<
          'Interactive',
          readonly [Capability.Capability<'Base', readonly []>]
        >,
      ]
    >,
    readonly Slot.EventName[],
    readonly Slot.AttributeName[],
    readonly Slot.RequirementName[],
    boolean
  >
}>

HoverIntent is a Submodel: open and close delays with intent, for a hover card or a menu that should not flicker. Both bundles are ChildAttribute groups: trigger owns the pointer and focus entry points, panel owns its own so moving into the panel keeps it open. resolve preserves each group by identity.

Upstream's HoverIntent places nothing. Given anchored, resolve places the panel against the trigger itself, as a hover card does: the panel shows in the browser's top layer and the anchor positions it there, and arrow, drawn as the panel's child, points at the trigger. The trigger then carries aria-expanded, and aria-describedby the panel while it is open. Escape closes the card from the trigger or the panel while either has focus.

HoverIntent.panelId

function · packages/mixins-ui/src/hoverIntent.ts:51

function panelId(id: string): string

The panel's id when anchored names id: what the open trigger's aria-describedby points at.

HoverIntent.resolve

function · packages/mixins-ui/src/hoverIntent.ts:66

function resolve<Input, Message>(
  render: RenderInfo,
  mixins: MixinList<Message>,
  context: HoverIntentContext<Input, Message>,
): ResolvedHoverIntent<Message>

Resolves the hover-intent render groups; isVisible passes through unchanged.

HoverIntent.ResolvedHoverIntent

type · packages/mixins-ui/src/hoverIntent.ts:63

type ResolvedHoverIntent<Message> = Resolved<
  RenderInfo,
  typeof HoverIntentSlots,
  Message
>

The hover intent's bundles with the attached Mixins applied.

HoverIntent.toView

function · packages/mixins-ui/src/hoverIntent.ts:103

function toView<Message>(
  mixins: MixinList<Message>,
  context: HoverIntentContext<unknown, Message>,
  draw: (resolved: ResolvedHoverIntent<Message>) => Html,
): (render: RenderInfo) => Html

The hover intent's toView: draw receives its bundles with mixins applied.

HoverIntent.triggerId

function · packages/mixins-ui/src/hoverIntent.ts:48

function triggerId(id: string): string

The trigger's id when anchored names id, for focusTriggerSelector or a label.