@foldkit/ui's anchor positioning as a Mount and a Behavior, and the top
layer around an anchored panel: the floating element is placed against the
button whose id is given, with placement, gap, offset, padding, portal and
flip handled by anchorSetup, which also releases on unmount. The Mount
writes top and left on the element itself, imperatively (and position
too under the fixed strategy); a Style on the same slot must leave those
alone, and data-placement is written by @foldkit/ui for styling.
portal defaults to true upstream: the element is relocated into a
portal root, so the runtime no longer patches it and a test sees it move.
The panel is given the custom properties of the region it was drawn in, as
it leaves it, so a region's density or compact step still reaches it.
Pass portal: false to keep the node where the view drew it. Positioning
without layout (jsdom's zero geometry) burns tens of seconds, portal or
not — drive the config, not the clock, in tests.
topLayer draws an upstream-anchored, in-place panel in the browser's top
layer instead: it shows the element as a manual popover around the wrapped
Mount's own acquire, and hides it when that Mount releases. Use it only
when the anchor keeps the panel in place (portal: false); moving a
relocated panel hides its popover again. The node stays where the runtime
drew it (no portal relocation), so no stacking context or ancestor
overflow can reach it, while the anchor positions it as before.
The panel carries popover="manual" in its view; light dismiss stays the
application's Messages. Wrapping keeps the wrapped Mount's name, args and
Messages, so Scene.Mount.resolve still matches it.
Where the anchor Mount is @foldkit/ui's own (Popover, Tooltip), the panel
cannot take a second Mount, so layer is an element around it that shows
in the top layer itself; and PlaceArrow points an arrow for an anchor
that computes none.
Wraps an anchor Mount that portals its panel (upstream's, which the
portal of its config does not say no to) so the panel keeps the custom
properties of the region it was drawn in: a region set compact, or a
density, reaches it as it would an in-place panel. Where the panel is not
relocated it does nothing. Wrapping keeps the wrapped Mount's name, args
and Messages, as topLayer does.
A box in the top layer, the viewport's width and no height, for a panel
whose anchor Mount is @foldkit/ui's: an element holds one Mount, so the
panel cannot also carry the one that shows it. Drawn around the panel, the
layer takes the panel out of every stacking context and ancestor
overflow, and the anchor places the panel inside it as on the page: the
layer is fixed at the viewport's corner, so its coordinates are the
viewport's, and as wide, so the panel's widths and 100% read as they
would. With no height it covers nothing a press could land on. Its look
is inline: the browser's popover border, padding and fill must not show
around a panel, whatever a theme does.
The layer box without its Mount, for a box whose own Mount shows it
(topLayer around one that sends Messages, which a Scene can resolve
where TopLayer sends none). style joins the box's inline style, since
a second h.Style on the element would replace it.
Places an arrow drawn as a panel's child against the middle of the
element whose id is given, for a panel whose anchor computes no arrow
(@foldkit/ui's Tooltip). It writes --arrow-x (above or below) or
--arrow-y (beside) on the arrow, the properties upstream's anchor writes
on a panel, and the other initial, so one rule styles both. It follows
the panel: the anchor writes the panel's style and data-placement on
every move, its first showing included, and each write places the arrow.
Draw an upstream-anchored, in-place panel in the browser's top layer: show
it as a manual popover, run the wrapped Mount's own acquire (which
positions it), and hide it once that Mount releases. Use it only when the
anchor keeps the panel in place (portal: false): upstream portal
relocation moves the element after the Mount acquires, and moving a shown
popover hides it again. The panel carries popover="manual" in its view.
Where the popover API or the attribute is missing the wrapper is a no-op
and the anchor positions in place.
The view sets inset: auto on the panel, since the anchor writes only
left and top over the browser's inset: 0. The browser's popover
border, padding and Canvas fill stay on an unstyled panel: any author
rule replaces them, as every recipe's panel does, where an inline reset
would beat the recipes.