npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@affino/popover-core

v1.0.0

Published

Headless popover controller powered by @affino/surface-core

Readme

@affino/popover-core

Headless popover controller built on top of @affino/surface-core. It keeps ARIA wiring, toggle semantics, and positioning helpers in sync with the rest of the Affino floating surfaces so adapters can stay tiny.

Highlights

  • Deterministic open / close orchestration with shared surface timers
  • Trigger + content prop helpers for instant ARIA wiring
  • Optional modal mode and escape / interact-outside guards
  • Arrow + positioning helpers that reuse computePosition()

Install

pnpm add @affino/popover-core
# or
yarn add @affino/popover-core
# or
npm install @affino/popover-core

Usage

import { PopoverCore } from "@affino/popover-core"

const popover = new PopoverCore({ id: "filters", closeOnEscape: true })

const triggerProps = popover.getTriggerProps()
const panelProps = popover.getContentProps({ role: "dialog" })

buttonEl.addEventListener("click", triggerProps.onClick!)
panelEl.addEventListener("keydown", panelProps.onKeyDown!)

popover.open()
  • Trigger props already expose aria-haspopup, aria-expanded, and aria-controls so DOM stays declarative.
  • Content props include role, aria-modal, and Escape handling.
  • Call popover.computePosition(anchorRect, panelRect) anytime layout shifts.
  • Use popover.getArrowProps({ anchorRect, popoverRect, position }) to align decorative arrows.

API

new PopoverCore(options?, callbacks?)

| Option | Type | Default | Description | | --- | --- | --- | --- | | id | string | auto | Stable identifier forwarded to trigger/content ids | | role | 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid' | dialog | Controls aria-haspopup + content role | | modal | boolean | false | Toggles aria-modal="true" and lets adapters apply scroll locking | | closeOnEscape | boolean | true | Close the surface when Escape fires from trigger or panel | | closeOnInteractOutside | boolean | true | Let adapters close when pointer / focus leaves the surface | | openDelay / closeDelay | number | 80 / 150 | Forwarded to the shared surface timers |

Callbacks mirror SurfaceCallbacks and add onInteractOutside(event) so analytics hooks can observe outside clicks before the controller closes.

Trigger helpers

const triggerProps = popover.getTriggerProps({ type: "button" })

Returns:

  • id, aria-haspopup, aria-controls, aria-expanded
  • onClick (toggles the surface)
  • onKeyDown (Space/Enter toggle, Escape closes)

Content helpers

const panelProps = popover.getContentProps({ role: "dialog", tabIndex: -1 })

Returns:

  • id, role, aria-modal, tabIndex, data-state
  • onKeyDown (Escape closes when enabled)

Arrow helper

const arrow = popover.getArrowProps({ anchorRect, popoverRect, position, options: { size: 12 } })

Just like tooltips, this helper outputs data-placement, data-align, and inline styles so CSS can stay declarative.

Adapter guidance

  • Pair with @affino/overlay-host to teleport panels into a managed stacking context.
  • Close on outside pointer / focus targets when popover.shouldCloseOnInteractOutside() returns true.
  • When popover.isModal() is true, lock scroll using createScrollLockController() from the overlay host package.
if (popover.shouldCloseOnInteractOutside() && !panel.contains(event.target)) {
  popover.interactOutside({ event, target: event.target })
}

The controller stays DOM-agnostic so it can power Vue, React, or vanilla adapters from the same package.