import type { PropsLike } from "./merge-props-n.js"; /** * Accessor-or-value. Consumers may pass plain values or Solid accessors for * any reactive gate; readers resolve at call time so the returned handlers * see the latest state without recreating the primitive. */ type MaybeAccessor = T | (() => T); export interface UseMixedToggleClickHandlerParameters { /** * Whether the mixed toggle click handler is enabled. * @default true */ enabled?: MaybeAccessor | undefined; /** * Which action the `mousedown` event performs on the popup — `"open"` means * the popup opens on mousedown (so the follow-up click must not close it), * `"close"` means the popup closes on mousedown (so the follow-up click * must not re-open it). */ mouseDownAction: MaybeAccessor<"open" | "close">; /** * Current open state of the popup. Read at event-time — pass a signal * accessor to track updates. */ open: MaybeAccessor; } /** * Port of Base UI React's `useMixedToggleClickHandler` * (`packages/react/src/utils/useMixedToggleClickHandler.ts`). * * Produces a pair of `onMouseDown` / `onClick` handlers that fix the * "mousedown opens, click closes" (or "mousedown closes, click opens") * race that occurs when a popup trigger is toggled by different events: * the mousedown flips the popup state, and the ensuing click — fired by * the same user gesture — would otherwise immediately flip it back. * * The fix is to record, on mousedown, that a subsequent click should be * ignored; the one-shot `click` listener installed on the owner document * clears the latch at the end of the event loop so unrelated future * clicks still work. * * Solid 2 notes: * * - Unlike React's `useMemo` gate on `enabled`, the Solid port reads * `enabled` at event time. That keeps the primitive's return value * identity stable (`mergePropsN` doesn't care about identity, but * callers that capture the handlers once don't need to rewire on * toggle) and avoids a stale-closure hazard during a transition. * - `mouseDownAction` and `open` are likewise read at event time so the * primitive can be called once during setup rather than inside an * effect. * - The returned shape is `PropsLike` so consumers feed it directly into * `mergePropsN`. The right-most handler can call `preventBaseUIHandler()` * to short-circuit chained consumer handlers — matching the React * source, which uses `event.preventBaseUIHandler()` for the same * purpose. */ export declare function useMixedToggleClickHandler(params: UseMixedToggleClickHandlerParameters): PropsLike; export {}; //# sourceMappingURL=use-mixed-toggle-click-handler.d.ts.map