/** * Stage 4.1 port of Base UI React's `useInteractions` hook. * * React source: * `base-ui/packages/react/src/floating-ui-react/hooks/useInteractions.ts`. * * Merges the prop bags produced by individual interaction hooks (`useHover`, * `useFocus`, `useClick`, `useDismiss`, `useListNavigation`, `useRole`, ...) * into three prop-getters (`getReferenceProps`, `getFloatingProps`, * `getItemProps`) plus a fourth `getTriggerProps` that Base UI's fork adds * for separate trigger/reference handling. * * ### React → Solid deviations * * 1. React memoises each getter with `useCallback` keyed on per-element * `propsList` slices so the identity is stable across renders. Solid * components don't re-run their bodies, so the returned getters are * plain functions — identity is stable for the lifetime of the call * site already. * * 2. React's hand-rolled `mergeProps` loop duplicates the merge semantics * that `mergePropsN` (`src/internals/merge-props-n.ts`) already * implements for the rest of the Solid port: event handlers chain * instead of overwriting, `class` / `style` compose, right-most * non-`undefined` wins for scalars. The port delegates to * `mergePropsN` instead of reimplementing. One consequence: the * `preventBaseUIHandler()` chain-short-circuit that `mergePropsN` * arms on the event is automatically honored here too (React's * source has no equivalent — it returns the first non-undefined * result from the handler array, which is a different contract). * * 3. React's `for…in` enumeration of source objects in `mergeProps` * walks prototype-inherited keys; Solid's `mergePropsN` walks * `Object.keys` only. Hook-produced bags are plain objects in both * ports, so the distinction doesn't matter in practice. * * 4. React uses `React.HTMLProps` for the user-prop parameter * type. The Solid port accepts `ElementPropsBag` from `../types`, * which is `JSX.HTMLAttributes & Record` — * the same loose bag already used for inter-hook prop passing. */ import { type PropsLike } from "../../merge-props-n.js"; import type { ElementProps, ElementPropsBag, ExtendedUserProps } from "../types.js"; export type { ExtendedUserProps }; export interface UseInteractionsReturn { getReferenceProps: (userProps?: ElementPropsBag) => PropsLike; getFloatingProps: (userProps?: ElementPropsBag) => PropsLike; getItemProps: (userProps?: Omit & ExtendedUserProps) => PropsLike; getTriggerProps: (userProps?: ElementPropsBag) => PropsLike; } type InteractionEntry = ElementProps | false | null | undefined; /** * Merges an array of interaction-hook prop bags into the four prop-getters * consumed by Base UI's floating surfaces. Each getter runs `mergePropsN` * at call time, so event-handler chaining and `preventBaseUIHandler` work * consistently with the rest of the Solid internals. */ export declare function useInteractions(propsList?: Array): UseInteractionsReturn; //# sourceMappingURL=use-interactions.d.ts.map