{"version":3,"names":["resolve","input","undefined","usePositioner","options","getStyle","base","styles","inert","pointerEvents","transitionStatus","transition","getHidden","hidden","style","props","role"],"sources":["use-positioner.ts"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\n/**\n * Port of Base UI React's `usePositioner`\n * (`packages/react/src/utils/usePositioner.tsx`).\n *\n * React's version calls `useRenderElement` internally and returns a JSX\n * element; the Solid port is more idiomatic as a helper that returns a\n * composable prop bag which consumers feed into `renderElement` themselves.\n * This keeps the compound positioners (popover, tooltip, menu, select, …)\n * in control of their context providers, `<Show>` gating, and portal\n * placement, without having to unwrap anything from this hook.\n *\n * ## React → Solid deviations\n *\n * - Returns a `UsePositionerReturn` object of accessors instead of a JSX\n *   element. Consumers spread `.props` into their `renderElement` call and\n *   apply `.style` reactively via a getter.\n * - The `inert` / `hidden` flags collapse into the returned style /\n *   HTML-props bag, matching how the React source sets them.\n * - `transitionStatus` is accepted as an accessor; when it is `\"starting\"`\n *   we emit `transition: none` to disable the initial mount transition\n *   (mirrors React's `getDisabledMountTransitionStyles`).\n */\n\nimport type { Accessor } from \"solid-js\";\nimport type { TransitionStatus } from \"../use-transition-status/use-transition-status\";\n\nexport interface UsePositionerOptions {\n\t/**\n\t * Reactive accessor for the positioner's base style. Typically sourced\n\t * from `useAnchorPositioning(...).positionerStyles`.\n\t */\n\tstyles: Accessor<JSX.CSSProperties>;\n\t/**\n\t * Current transition status. Used to toggle off transitions during the\n\t * initial mount frame so enter animations don't play on first paint.\n\t */\n\ttransitionStatus: Accessor<TransitionStatus>;\n\t/**\n\t * Whether the positioner DOM node should render with the `hidden`\n\t * attribute. Set to `true` while the popup is closed but `keepMounted`\n\t * keeps it in the tree.\n\t */\n\thidden?: Accessor<boolean> | boolean | undefined;\n\t/**\n\t * When true, disables pointer events on the positioner. Used by modal\n\t * popups while the backdrop animates out.\n\t */\n\tinert?: Accessor<boolean> | boolean | undefined;\n}\n\nexport interface UsePositionerReturn {\n\t/**\n\t * Resolved style to apply to the positioner element. Always returns a\n\t * fresh object so Solid's JSX binding picks up property changes.\n\t */\n\treadonly style: JSX.CSSProperties;\n\t/**\n\t * Resolved `hidden` flag. Feed directly into `hidden={...}`.\n\t */\n\treadonly hidden: boolean | undefined;\n\t/**\n\t * Standard HTML props bag for the positioner outer element:\n\t * `{ role: 'presentation', hidden, style }`. Consumers pass this into\n\t * their `renderElement(...)` call's `props` array.\n\t */\n\treadonly props: JSX.HTMLAttributes<HTMLDivElement>;\n}\n\nfunction resolve<T>(input: T | Accessor<T> | undefined): T | undefined {\n\tif (input === undefined) return undefined;\n\treturn typeof input === \"function\" ? (input as Accessor<T>)() : input;\n}\n\n/**\n * Produce the shared prop bag + style for a popup positioner element. This\n * hook owns the common role/hidden/style/inert-aware shape that every Base\n * UI popup positioner renders; consumers layer their component-specific\n * props on top via `renderElement`'s `props` array.\n *\n * Safe to call outside of a tracking context — the returned object exposes\n * getters, so reactive reads only happen at access time (e.g. inside a\n * `renderElement` props-array entry).\n */\nexport function usePositioner(\n\toptions: UsePositionerOptions,\n): UsePositionerReturn {\n\tconst getStyle = (): JSX.CSSProperties => {\n\t\tconst base: JSX.CSSProperties = { ...options.styles() };\n\t\tif (resolve(options.inert)) {\n\t\t\t(base as JSX.CSSProperties & { pointerEvents?: string }).pointerEvents =\n\t\t\t\t\"none\";\n\t\t}\n\t\tif (options.transitionStatus() === \"starting\") {\n\t\t\t// Disables the initial mount transition to avoid a visual \"pop\" when\n\t\t\t// the element paints for the first time. Matches React's\n\t\t\t// `getDisabledMountTransitionStyles`.\n\t\t\t(base as JSX.CSSProperties & { transition?: string }).transition = \"none\";\n\t\t}\n\t\treturn base;\n\t};\n\n\tconst getHidden = (): boolean | undefined =>\n\t\tresolve(options.hidden) || undefined;\n\n\treturn {\n\t\tget style() {\n\t\t\treturn getStyle();\n\t\t},\n\t\tget hidden() {\n\t\t\treturn getHidden();\n\t\t},\n\t\tget props() {\n\t\t\treturn {\n\t\t\t\trole: \"presentation\",\n\t\t\t\thidden: getHidden(),\n\t\t\t\tget style(): JSX.CSSProperties {\n\t\t\t\t\treturn getStyle();\n\t\t\t\t},\n\t\t\t} as JSX.HTMLAttributes<HTMLDivElement>;\n\t\t},\n\t};\n}\n"],"mappings":"AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+CA,SAASA,OAAOA,CAAIC,KAAkC,EAAiB;EACtE,IAAIA,KAAK,KAAKC,SAAS,EAAE,OAAOA,SAAS;EACzC,OAAO,OAAOD,KAAK,KAAK,UAAU,GAAIA,KAAK,CAAiB,CAAC,GAAGA,KAAK;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,aAAaA,CAC5BC,OAA6B,EACP;EACtB,MAAMC,QAAQ,GAAGA,CAAA,KAAyB;IACzC,MAAMC,IAAuB,GAAG;MAAE,GAAGF,OAAO,CAACG,MAAM,CAAC;IAAE,CAAC;IACvD,IAAIP,OAAO,CAACI,OAAO,CAACI,KAAK,CAAC,EAAE;MAC1BF,IAAI,CAAoDG,aAAa,GACrE,MAAM;IACR;IACA,IAAIL,OAAO,CAACM,gBAAgB,CAAC,CAAC,KAAK,UAAU,EAAE;MAC9C;MACA;MACA;MACCJ,IAAI,CAAiDK,UAAU,GAAG,MAAM;IAC1E;IACA,OAAOL,IAAI;EACZ,CAAC;EAED,MAAMM,SAAS,GAAGA,CAAA,KACjBZ,OAAO,CAACI,OAAO,CAACS,MAAM,CAAC,IAAIX,SAAS;EAErC,OAAO;IACN,IAAIY,KAAKA,CAAA,EAAG;MACX,OAAOT,QAAQ,CAAC,CAAC;IAClB,CAAC;IACD,IAAIQ,MAAMA,CAAA,EAAG;MACZ,OAAOD,SAAS,CAAC,CAAC;IACnB,CAAC;IACD,IAAIG,KAAKA,CAAA,EAAG;MACX,OAAO;QACNC,IAAI,EAAE,cAAc;QACpBH,MAAM,EAAED,SAAS,CAAC,CAAC;QACnB,IAAIE,KAAKA,CAAA,EAAsB;UAC9B,OAAOT,QAAQ,CAAC,CAAC;QAClB;MACD,CAAC;IACF;EACD,CAAC;AACF","ignoreList":[]}