{"version":3,"names":["createContext","useContext","SelectRootContext","useSelectRootContext","optional","context","Error"],"sources":["select-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 { FloatingRootStore } from \"../internals/floating-ui/components/floating-root-store\";\nimport type { UseInteractionsReturn } from \"../internals/floating-ui/hooks/use-interactions\";\nimport type { MutableRef } from \"../internals/floating-ui/types\";\nimport type { InteractionType } from \"../internals/popups/use-open-interaction-type\";\nimport type { TransitionStatus } from \"../internals/use-transition-status/use-transition-status\";\nimport type { ItemsInput } from \"./utils/resolve-value-label\";\n\n/**\n * Selection guard mirroring React's `selectionRef`. React uses it to gate\n * an accidental mousedown-drag-commit on items: after a mousedown on the\n * trigger, an unselected item's mouseup is blocked for 200ms, and a\n * currently-selected item's mouseup is blocked for 400ms.\n */\nexport interface SelectSelectionGuard {\n\tallowSelectedMouseUp: boolean;\n\tallowUnselectedMouseUp: boolean;\n}\n\n/**\n * Change-reason union for `Select.Root`. Mirrors Base UI React 1:1 —\n * every reason emitted from `setOpen` / `setValue` in the ported paths.\n */\nexport type SelectRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.windowResize\n\t| typeof REASONS.itemPress\n\t| typeof REASONS.focusOut\n\t| typeof REASONS.listNavigation\n\t| typeof REASONS.cancelOpen\n\t| typeof REASONS.none;\n\nexport type SelectRootChangeEventDetails =\n\tBaseUIChangeEventDetails<SelectRootChangeEventReason>;\n\nexport type SelectValue = unknown;\n\n/**\n * Shared state / handles surfaced through the Select root context. Every\n * reactive field is exposed as an `Accessor<T>` so consumers don't need to\n * wrap reads in `untrack` / `createMemo`.\n */\nexport interface SelectRootContextValue {\n\t/** Reactive open state. */\n\topen: Accessor<boolean>;\n\t/** Whether the popup subtree is currently mounted (open OR animating out). */\n\tmounted: Accessor<boolean>;\n\t/** Enter/exit transition phase, or undefined when settled. */\n\ttransitionStatus: Accessor<TransitionStatus>;\n\t/** Whether the open popup should trap focus + scroll-lock + backdrop-cutout. */\n\tmodal: Accessor<boolean>;\n\t/** Whether the select allows multiple values. */\n\tmultiple: Accessor<boolean>;\n\t/** Whether the select is disabled (field or own prop). */\n\tdisabled: Accessor<boolean>;\n\t/** Whether the select is read-only. */\n\treadOnly: Accessor<boolean>;\n\t/** Whether the select requires a value for submission. */\n\trequired: Accessor<boolean>;\n\t/** Field name (own `name` or inherited from `<Field>`). */\n\tname: Accessor<string | undefined>;\n\t/** Autogenerated or explicit root id. */\n\tid: Accessor<string | undefined>;\n\t/** Field-level label id (wired via LabelableProvider). */\n\tlabelId: Accessor<string | undefined>;\n\tsetLabelId: (id: string | undefined) => void;\n\n\t/** The current selection value — scalar or array-of-values for `multiple`. */\n\tvalue: Accessor<SelectValue>;\n\t/** The highlighted item index (used for listbox navigation). */\n\tactiveIndex: Accessor<number | null>;\n\tsetActiveIndex: (index: number | null) => void;\n\t/** The currently-selected item index (distinct from activeIndex). */\n\tselectedIndex: Accessor<number | null>;\n\tsetSelectedIndex: (index: number | null) => void;\n\n\t/** Whether mouse hovers highlight list items. */\n\thighlightItemOnHover: Accessor<boolean>;\n\t/** Custom value comparer (defaults to `Object.is`). */\n\tisItemEqualToValue: Accessor<(a: SelectValue, b: SelectValue) => boolean>;\n\t/** Trigger-to-label formatter for object values. */\n\titemToStringLabel: Accessor<((value: SelectValue) => string) | undefined>;\n\t/** Trigger-to-form-value formatter for object values. */\n\titemToStringValue: Accessor<((value: SelectValue) => string) | undefined>;\n\t/** Optional items registry for trigger label resolution / group support. */\n\titems: Accessor<ItemsInput<SelectValue>>;\n\n\t/**\n\t * Imperative setOpen. Respects `details.cancel()` for uncontrolled open.\n\t */\n\tsetOpen: (next: boolean, details: SelectRootChangeEventDetails) => void;\n\t/**\n\t * Imperative setValue. Respects `details.cancel()` and forwards\n\t * `onValueChange` before the internal write.\n\t */\n\tsetValue: (next: SelectValue, details: SelectRootChangeEventDetails) => void;\n\n\t/** Floating-UI root context for interaction hooks and positioning. */\n\tfloatingRootContext: FloatingRootStore;\n\t/** Interaction prop-getter bundle (click + dismiss + listnav + typeahead). */\n\tinteractions: UseInteractionsReturn;\n\n\t/** Trigger element slot (positioner reads this for anchor). */\n\ttriggerElement: Accessor<HTMLElement | null>;\n\tsetTriggerElement: (element: HTMLElement | null) => void;\n\t/** Popup element ref (filled by `<Select.Popup>`). */\n\tpopupRef: MutableRef<HTMLElement | null>;\n\t/** List element ref — set by `<Select.List>` when used. */\n\tlistElement: Accessor<HTMLElement | null>;\n\tsetListElement: (element: HTMLElement | null) => void;\n\t/** Value element ref (trigger's `<Select.Value>`). */\n\tvalueRef: MutableRef<HTMLElement | null>;\n\t/** The text ref of the selected item (used for popup alignment math). */\n\tselectedItemTextRef: MutableRef<HTMLElement | null>;\n\n\t/** Parallel listRef + labelsRef + valuesRef used by listnav / typeahead / equality. */\n\tlistRef: MutableRef<Array<HTMLElement | null>>;\n\tlabelsRef: MutableRef<Array<string | null>>;\n\t// biome-ignore lint/suspicious/noExplicitAny: values registry indexes by position.\n\tvaluesRef: MutableRef<Array<any>>;\n\t/** Whether typeahead is currently active (suppresses space → click). */\n\ttypingRef: MutableRef<boolean>;\n\n\t/** Consumer callback — called after open/close transitions settle. */\n\tonOpenChangeComplete?: ((open: boolean) => void) | undefined;\n\n\t/** Read by positioner's composite-list reconciliation. */\n\t// biome-ignore lint/suspicious/noExplicitAny: values registry indexes by position.\n\tinitialValueRef: MutableRef<any>;\n\n\t/**\n\t * Interaction type that opened the popup (`'mouse' | 'keyboard' | 'touch' |\n\t * 'pen' | ''`) — used by popup geometry and scroll arrows to differentiate\n\t * touch opens from pointer/keyboard opens. `null` while closed.\n\t */\n\topenMethod: Accessor<InteractionType | null>;\n\n\t/** Whether the popup's up-scroll arrow should render (trigger-aligned only). */\n\tscrollUpArrowVisible: Accessor<boolean>;\n\tsetScrollUpArrowVisible: (next: boolean) => void;\n\t/** Whether the popup's down-scroll arrow should render (trigger-aligned only). */\n\tscrollDownArrowVisible: Accessor<boolean>;\n\tsetScrollDownArrowVisible: (next: boolean) => void;\n\t/** Count of mounted scroll arrows. When any arrow is mounted we skip the\n\t *  bottom popup/list padding used by React's `scroll-arrow` layout. */\n\tscrollArrowsMountedCountRef: MutableRef<number>;\n\t/**\n\t * Imperative \"recompute scroll arrow visibility now\" — filled by the\n\t * popup when its geometry effect binds; called from items / positioner /\n\t * scroll arrows. Always safe to invoke; delegates through an internal\n\t * ref so the popup can swap its callback.\n\t */\n\thandleScrollArrowVisibility: () => void;\n\t/**\n\t * Backing ref for {@link handleScrollArrowVisibility}. The popup writes\n\t * its geometry callback here during `<Select.Popup>`'s setup phase.\n\t */\n\thandleScrollArrowVisibilityRef: MutableRef<() => void>;\n\t/**\n\t * Live callback-invoked variant of the popup's scroll handler —\n\t * overwritten by the popup's trigger-aligned geometry effect when the\n\t * popup measures initial placement. A no-op otherwise.\n\t */\n\tscrollHandlerRef: MutableRef<(scroller: HTMLElement) => void>;\n\t/** Tracks whether the most recent interaction was keyboard-driven. */\n\tkeyboardActiveRef: MutableRef<boolean>;\n\n\t/** Selection-window guard — see {@link SelectSelectionGuard}. */\n\tselectionRef: MutableRef<SelectSelectionGuard>;\n}\n\nexport const SelectRootContext = createContext<SelectRootContextValue | null>(\n\tnull,\n);\n\nexport function useSelectRootContext(): SelectRootContextValue;\nexport function useSelectRootContext(\n\toptional: true,\n): SelectRootContextValue | null;\nexport function useSelectRootContext(\n\toptional?: boolean,\n): SelectRootContextValue | null {\n\tconst context = useContext(SelectRootContext);\n\tif (context == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: SelectRootContext is missing. Select parts must be placed within <Select.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAYnE;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;;AAkIA,OAAO,MAAMC,iBAAiB,GAAGF,aAAa,CAC7C,IACD,CAAC;AAMD,OAAO,SAASG,oBAAoBA,CACnCC,QAAkB,EACc;EAChC,MAAMC,OAAO,GAAGJ,UAAU,CAACC,iBAAiB,CAAC;EAC7C,IAAIG,OAAO,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IACjC,MAAM,IAAIE,KAAK,CACd,0FACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}