{"version":3,"names":["createContext","useContext","NOOP","NOOP_TABS_ROOT_CONTEXT","value","undefined","onValueChange","orientation","tabActivationDirection","getTabElementBySelectedValue","getTabIdByPanelValue","getTabPanelIdByValue","registerMountedTabPanel","unregisterMountedTabPanel","setTabMap","present","TabsRootContext","useTabsRootContext","context","Error"],"sources":["tabs-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../internals/change-event-details\";\nimport type { CompositeMetadata } from \"../internals/composite/composite-context.ts\";\nimport type { Orientation } from \"../internals/types\";\n\n/**\n * The opaque identifier a consumer attaches to a `<Tabs.Tab>` + the matching\n * `<Tabs.Panel>`. `null` disables selection entirely (no panel visible).\n * Matches React Base UI's `TabsTab.Value` (which is also `any | null`).\n */\nexport type TabsTabValue = unknown;\n\n/**\n * Direction of the most recent activation. `\"none\"` on first render / when\n * the source or destination tab is missing from the live DOM map.\n */\nexport type TabsTabActivationDirection =\n\t| \"left\"\n\t| \"right\"\n\t| \"up\"\n\t| \"down\"\n\t| \"none\";\n\n/** Reason attached to `onValueChange` details. */\nexport type TabsRootChangeEventReason = typeof REASONS.none;\n\n/**\n * Change-event details passed to `onValueChange`. Extends the standard Base UI\n * details bag with `activationDirection` so consumers can drive directional\n * animations from their own handler.\n */\nexport type TabsRootChangeEventDetails = BaseUIChangeEventDetails<\n\tTabsRootChangeEventReason,\n\t{ activationDirection: TabsTabActivationDirection }\n>;\n\n/**\n * Metadata stored per `<Tabs.Tab>` in the composite map. `id` is the tab's\n * DOM id — used to wire `aria-labelledby` on the matching panel. `value` is\n * what the consumer passed via `props.value`.\n */\nexport interface TabsTabMetadata {\n\tdisabled: boolean;\n\tid: string | undefined;\n\tvalue: TabsTabValue;\n}\n\n/** Metadata stored per `<Tabs.Panel>` in the composite panel list. */\nexport interface TabsPanelMetadata {\n\tid?: string | undefined;\n\tvalue: TabsTabValue;\n}\n\n/**\n * State of `<Tabs.Root>` projected to `data-*` attrs + the `class` /\n * `style` / `render` callback surfaces.\n */\nexport interface TabsRootState {\n\t/** Layout orientation. */\n\torientation: Orientation;\n\t/** Activation direction of the most recent change. */\n\ttabActivationDirection: TabsTabActivationDirection;\n}\n\n/**\n * Context shared by every `<Tabs.*>` part. Accessors mirror React Base UI's\n * `TabsRootContext` but every slot that's reactive is exposed as an\n * `Accessor<T>` so descendants stay live without a memo ping-pong.\n */\nexport interface TabsRootContextValue {\n\t/** Currently selected tab value (`undefined` → defaultValue branch). */\n\tvalue: Accessor<TabsTabValue | undefined>;\n\t/**\n\t * Request a change. Fires the consumer's `onValueChange` first (with a\n\t * cancel-capable details bag) then — if not canceled — writes the\n\t * internal signal in the uncontrolled branch.\n\t */\n\tonValueChange: (\n\t\tnewValue: TabsTabValue,\n\t\teventDetails: TabsRootChangeEventDetails,\n\t) => void;\n\t/** Layout orientation (`\"horizontal\"` / `\"vertical\"`). */\n\torientation: Accessor<Orientation>;\n\t/** Activation direction accessor. */\n\ttabActivationDirection: Accessor<TabsTabActivationDirection>;\n\t/** Look up a tab element by value — powers the indicator's position math. */\n\tgetTabElementBySelectedValue: (\n\t\tselectedValue: TabsTabValue | undefined,\n\t) => HTMLElement | null;\n\t/** Panel `aria-labelledby` lookup — finds the tab id for a given panel value. */\n\tgetTabIdByPanelValue: (panelValue: TabsTabValue) => string | undefined;\n\t/** Tab `aria-controls` lookup — finds the panel id for a given tab value. */\n\tgetTabPanelIdByValue: (tabValue: TabsTabValue) => string | undefined;\n\t/**\n\t * Panels call this when they mount (or on `keepMounted` register) so the\n\t * root can answer `getTabPanelIdByValue(tabValue)` without walking DOM.\n\t */\n\tregisterMountedTabPanel: (panelValue: TabsTabValue, panelId: string) => void;\n\t/** Reverse of {@link registerMountedTabPanel}. */\n\tunregisterMountedTabPanel: (\n\t\tpanelValue: TabsTabValue,\n\t\tpanelId: string,\n\t) => void;\n\t/**\n\t * Exposed to `<Tabs.List>` so its `<CompositeList onMapChange>` forwards\n\t * the sorted tab map up to the root for aria-labelledby / activation-\n\t * direction lookups.\n\t */\n\tsetTabMap: (\n\t\tmap: Map<Element, CompositeMetadata<TabsTabMetadata> | null>,\n\t) => void;\n\t/** Marker — `true` when a real `<Tabs.Root>` provided this context. */\n\treadonly present: boolean;\n}\n\nconst NOOP = (): void => {};\n\nexport const NOOP_TABS_ROOT_CONTEXT: TabsRootContextValue = {\n\tvalue: () => undefined,\n\tonValueChange: NOOP,\n\torientation: () => \"horizontal\",\n\ttabActivationDirection: () => \"none\",\n\tgetTabElementBySelectedValue: () => null,\n\tgetTabIdByPanelValue: () => undefined,\n\tgetTabPanelIdByValue: () => undefined,\n\tregisterMountedTabPanel: NOOP,\n\tunregisterMountedTabPanel: NOOP,\n\tsetTabMap: NOOP,\n\tpresent: false,\n};\n\nexport const TabsRootContext = createContext<TabsRootContextValue>(\n\tNOOP_TABS_ROOT_CONTEXT,\n);\n\n/**\n * Read the `<Tabs.Root>` context. Throws when no root ancestor is present —\n * every tabs part requires a root.\n */\nexport function useTabsRootContext(): TabsRootContextValue {\n\tconst context = useContext(TabsRootContext);\n\tif (!context.present) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: TabsRootContext is missing. Tabs parts must be placed within <Tabs.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAQnE;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAQA;;AAGA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAOA;;AAMA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;;AA+CA,MAAMC,IAAI,GAAGA,CAAA,KAAY,CAAC,CAAC;AAE3B,OAAO,MAAMC,sBAA4C,GAAG;EAC3DC,KAAK,EAAEA,CAAA,KAAMC,SAAS;EACtBC,aAAa,EAAEJ,IAAI;EACnBK,WAAW,EAAEA,CAAA,KAAM,YAAY;EAC/BC,sBAAsB,EAAEA,CAAA,KAAM,MAAM;EACpCC,4BAA4B,EAAEA,CAAA,KAAM,IAAI;EACxCC,oBAAoB,EAAEA,CAAA,KAAML,SAAS;EACrCM,oBAAoB,EAAEA,CAAA,KAAMN,SAAS;EACrCO,uBAAuB,EAAEV,IAAI;EAC7BW,yBAAyB,EAAEX,IAAI;EAC/BY,SAAS,EAAEZ,IAAI;EACfa,OAAO,EAAE;AACV,CAAC;AAED,OAAO,MAAMC,eAAe,GAAGhB,aAAa,CAC3CG,sBACD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASc,kBAAkBA,CAAA,EAAyB;EAC1D,MAAMC,OAAO,GAAGjB,UAAU,CAACe,eAAe,CAAC;EAC3C,IAAI,CAACE,OAAO,CAACH,OAAO,EAAE;IACrB,MAAM,IAAII,KAAK,CACd,oFACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}