@bazza-ui/react 0.1.0-canary.10 → 0.1.0-canary.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/loaders/index.cjs","../../src/loaders/swr.tsx","../../src/loaders/tanstack-query.tsx","../../src/loaders/vanilla.tsx"],"names":["toError","error","toAsyncLoaderResultFromSWR","result","normalizedError","hasData","fetchStatus","isFetching","isInitialLoading","isRefetching","status","loadingPhase","createSWRStaticLoader","props","useSWR","loadStrategy","children","jsx","Fragment","createSWRQueryLoader","minQueryLength","initialQueryBehavior","initialQuery","belowMinBehavior","placeholderNodes","resolvedInitialQueryBehavior","query","enabled","isEnabled","createSWRLoaderComponent","useSWRFn","toAsyncLoaderResult","isPending","isSuccess","isError","isPaused","hasFetched","createStaticLoader","useQuery","createQueryLoader","createLoaderComponent","useQueryFn","normalizeError","getVanillaStatus","state","toVanillaAsyncLoaderResult","refetch","useAsyncState","fetcher","options","setState","fetcherRef","data","s","useAsyncQueryState","controller","createVanillaStaticLoader","createVanillaQueryLoader"],"mappings":"AAAA,geAA6B,+CC8HlB,SA9FFA,CAAAA,CAAQC,CAAAA,CAA8B,CAC7C,OAAIA,CAAAA,EAAS,IAAA,CACJ,IAAA,CAGLA,EAAAA,WAAiB,KAAA,CACZA,CAAAA,CAGF,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAK,CAAC,CAChC,CAKO,SAASC,CAAAA,CACdC,CAAAA,CACoD,CACpD,IAAMC,CAAAA,CAAkBJ,CAAAA,CAAQG,CAAAA,CAAO,KAAK,CAAA,CACtCE,CAAAA,CAAUF,CAAAA,CAAO,IAAA,GAAS,KAAA,CAAA,CAE1BG,CAAAA,CAAsCH,CAAAA,CAAO,QAAA,CAC/C,QAAA,CACAA,CAAAA,CAAO,YAAA,CACL,UAAA,CACA,MAAA,CAEAI,CAAAA,CAAaD,CAA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oBAAA,CAAsBK,CAAAA,CACtB,YAAA,CAAAH,CAAAA,CACA,YAAA,CAAAP,CAAAA,CACA,gBAAA,CAAAQ,CAAAA,CACA,gBAAA,CAAAC,CACF,CACF,CAAA,kWAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/loaders/index.cjs","sourcesContent":[null,"'use client'\n\nimport type * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/data-first/types.js'\n\n// ============================================================================\n// SWR Adapter\n// ============================================================================\n\n/**\n * SWR result shape (subset of SWRResponse).\n * This allows the adapter to work without requiring `swr` as a dependency.\n */\nexport interface SWRResult<TData, TError = Error> {\n data: TData | undefined\n error: TError | undefined\n isLoading?: boolean\n isValidating: boolean\n isPaused?: boolean\n mutate: (...args: unknown[]) => unknown\n}\n\nfunction toError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\n/**\n * Converts an SWR result to an AsyncLoaderResult.\n */\nexport function toAsyncLoaderResultFromSWR<TData, TError = Error>(\n result: SWRResult<TData, TError>,\n): AsyncLoaderResult<TData, SWRResult<TData, TError>> {\n const normalizedError = toError(result.error)\n const hasData = result.data !== undefined\n\n const fetchStatus: AsyncLoaderFetchStatus = result.isPaused\n ? 'paused'\n : result.isValidating\n ? 'fetching'\n : 'idle'\n\n const isFetching = fetchStatus === 'fetching'\n const isInitialLoading =\n result.isLoading ?? (isFetching && !hasData && normalizedError == null)\n const isRefetching = isFetching && !isInitialLoading\n\n const status: AsyncLoaderStatus = normalizedError\n ? 'error'\n : hasData\n ? 'success'\n : isInitialLoading || isFetching\n ? 'pending'\n : 'idle'\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: result.data,\n raw: result,\n source: 'swr',\n error: normalizedError,\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching,\n isInitialLoading,\n isRefetching,\n isPending: status === 'pending',\n isSuccess: status === 'success',\n isError: status === 'error',\n isPaused: fetchStatus === 'paused',\n hasData,\n hasFetched:\n hasData || normalizedError != null || isInitialLoading || isRefetching,\n refetch: () => result.mutate(),\n }\n}\n\n/**\n * Props for creating a static SWR loader component.\n */\nexport interface CreateSWRStaticLoaderProps {\n /** Hook that returns an SWR result. */\n useSWR: () => SWRResult<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration backed by SWR.\n */\nexport function createSWRStaticLoader(\n props: CreateSWRStaticLoaderProps,\n): StaticLoaderConfig {\n const { useSWR, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useSWR()\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query SWR loader component.\n */\nexport interface CreateSWRQueryLoaderProps {\n /**\n * Hook that returns an SWR result based on the search query.\n * `options.enabled` can be used to derive a `null` key and disable fetching.\n */\n useSWR: (\n query: string,\n options?: { enabled: boolean },\n ) => SWRResult<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query loader configuration backed by SWR.\n */\nexport function createSWRQueryLoader(\n props: CreateSWRQueryLoaderProps,\n): QueryLoaderConfig {\n const {\n useSWR,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useSWR(query, { enabled: isEnabled })\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n\n/**\n * Creates a loader component that wraps an SWR hook.\n */\nexport function createSWRLoaderComponent(\n useSWRFn: (query: string) => SWRResult<NodeDef[]>,\n): React.FC<LoaderComponentProps> {\n return function SWRLoader({ query, children }) {\n const result = useSWRFn(query)\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n}\n","'use client'\n\nimport type * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/data-first/types.js'\n\n// ============================================================================\n// TanStack Query Adapter\n// ============================================================================\n\n/**\n * TanStack Query result shape (subset of UseQueryResult).\n * This allows the adapter to work without requiring @tanstack/react-query as a dependency.\n */\nexport interface TanStackQueryResult<TData, TError = Error> {\n /** TanStack status (`pending` | `error` | `success`) */\n status?: 'pending' | 'error' | 'success'\n\n /** TanStack fetch status (`fetching` | `paused` | `idle`) */\n fetchStatus?: 'fetching' | 'paused' | 'idle'\n\n data: TData | undefined\n error: TError | null | undefined\n\n /** v5: true when first fetch is in-flight */\n isLoading?: boolean\n\n /** v5: true when status is pending */\n isPending?: boolean\n\n /** true when status is success */\n isSuccess?: boolean\n\n /** true when status is error */\n isError?: boolean\n\n /** true while any fetch is in-flight */\n isFetching?: boolean\n\n /** true while background refetch is in-flight */\n isRefetching?: boolean\n\n /** true when fetch is paused */\n isPaused?: boolean\n\n /** true once query has fetched at least once */\n isFetched?: boolean\n\n refetch: () => unknown\n}\n\nfunction toError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\n/**\n * Converts a TanStack Query result to an AsyncLoaderResult.\n * Use this to wrap your useQuery hook result.\n *\n * @example\n * ```tsx\n * function MyLoader({ query, children }) {\n * const result = useQuery({\n * queryKey: ['items', query],\n * queryFn: () => fetchItems(query),\n * })\n * return children(toAsyncLoaderResult(result))\n * }\n * ```\n */\nexport function toAsyncLoaderResult<TData, TError = Error>(\n result: TanStackQueryResult<TData, TError>,\n): AsyncLoaderResult<TData, TanStackQueryResult<TData, TError>> {\n const hasData = result.data !== undefined\n\n const fetchStatus: AsyncLoaderFetchStatus = result.fetchStatus\n ? result.fetchStatus\n : result.isPaused\n ? 'paused'\n : result.isFetching || result.isLoading\n ? 'fetching'\n : 'idle'\n\n const isFetching = fetchStatus === 'fetching'\n\n const status: AsyncLoaderStatus = result.status\n ? result.status\n : result.isError\n ? 'error'\n : result.isSuccess || hasData\n ? 'success'\n : result.isPending || result.isLoading || isFetching\n ? 'pending'\n : 'idle'\n\n const isPending = result.isPending ?? status === 'pending'\n const isSuccess = result.isSuccess ?? status === 'success'\n const isError = result.isError ?? status === 'error'\n const isInitialLoading = result.isLoading ?? (isPending && isFetching)\n const isRefetching = result.isRefetching ?? (isFetching && !isInitialLoading)\n const isPaused = result.isPaused ?? fetchStatus === 'paused'\n const hasFetched =\n result.isFetched ??\n (isSuccess || isError || isInitialLoading || isRefetching)\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: result.data,\n raw: result,\n source: 'tanstack-query',\n error: toError(result.error),\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching,\n isInitialLoading,\n isRefetching,\n isPending,\n isSuccess,\n isError,\n isPaused,\n hasData,\n hasFetched,\n refetch: result.refetch,\n }\n}\n\n/**\n * Props for creating a static loader component.\n */\nexport interface CreateStaticLoaderProps {\n /**\n * Hook that returns a TanStack Query result.\n * This hook will be called inside the loader component.\n */\n useQuery: () => TanStackQueryResult<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration for use with async menus.\n * The hook is called inside a component, so it follows React's rules of hooks.\n *\n * @example\n * ```tsx\n * const recentFilesLoader = createStaticLoader({\n * useQuery: () => useQuery({\n * queryKey: ['recent-files'],\n * queryFn: fetchRecentFiles,\n * staleTime: 5 * 60 * 1000,\n * }),\n * })\n *\n * // Use in submenu\n * {\n * kind: 'submenu',\n * value: 'Recent Files',\n * asyncNodes: {\n * ...recentFilesLoader,\n * loadStrategy: 'eager',\n * },\n * render: ...\n * }\n * ```\n */\nexport function createStaticLoader(\n props: CreateStaticLoaderProps,\n): StaticLoaderConfig {\n const { useQuery, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useQuery()\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query loader component.\n */\nexport interface CreateQueryLoaderProps {\n /**\n * Hook that returns a TanStack Query result based on the search query.\n * This hook will be called inside the loader component with the current query.\n */\n useQuery: (\n query: string,\n options?: { enabled: boolean },\n ) => TanStackQueryResult<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query loader configuration for use with async menus.\n * The loader will re-fetch when the search query changes.\n *\n * @example\n * ```tsx\n * const searchLoader = createQueryLoader({\n * useQuery: (query, options) => useQuery({\n * queryKey: ['search', query],\n * queryFn: () => searchItems(query),\n * enabled: options?.enabled,\n * }),\n * minQueryLength: 2,\n * })\n *\n * // Use in submenu\n * {\n * kind: 'submenu',\n * value: 'Search',\n * includeInDeepSearch: true,\n * asyncNodes: searchLoader,\n * render: ...\n * }\n * ```\n */\nexport function createQueryLoader(\n props: CreateQueryLoaderProps,\n): QueryLoaderConfig {\n const {\n useQuery,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useQuery(query, { enabled: isEnabled })\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n\n/**\n * Creates a loader component that wraps a TanStack Query hook.\n * This is a lower-level utility for custom loader implementations.\n *\n * @example\n * ```tsx\n * const MyLoader = createLoaderComponent((query) =>\n * useQuery({\n * queryKey: ['items', query],\n * queryFn: () => fetchItems(query),\n * })\n * )\n * ```\n */\nexport function createLoaderComponent(\n useQueryFn: (query: string) => TanStackQueryResult<NodeDef[]>,\n): React.FC<LoaderComponentProps> {\n return function TanStackLoader({ query, children }) {\n const result = useQueryFn(query)\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n}\n","'use client'\n\nimport * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/data-first/types.js'\n\n// ============================================================================\n// Vanilla Async Adapter (no external dependencies)\n// ============================================================================\n\ninterface VanillaAsyncInternalState<TData> {\n data: TData | undefined\n error: Error | null\n isFetching: boolean\n hasFetched: boolean\n}\n\nfunction normalizeError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\nfunction getVanillaStatus<TData>(\n state: VanillaAsyncInternalState<TData>,\n): AsyncLoaderStatus {\n if (state.error) {\n return 'error'\n }\n\n if (state.data !== undefined) {\n return 'success'\n }\n\n if (state.isFetching) {\n return 'pending'\n }\n\n return 'idle'\n}\n\nfunction toVanillaAsyncLoaderResult<TData>(\n state: VanillaAsyncInternalState<TData>,\n refetch: () => unknown,\n): AsyncLoaderResult<TData> {\n const status = getVanillaStatus(state)\n const fetchStatus: AsyncLoaderFetchStatus = state.isFetching\n ? 'fetching'\n : 'idle'\n\n const isInitialLoading = state.isFetching && !state.hasFetched\n const isRefetching = state.isFetching && state.hasFetched\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: state.data,\n source: 'vanilla',\n error: state.error,\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching: state.isFetching,\n isInitialLoading,\n isRefetching,\n isPending: status === 'pending',\n isSuccess: status === 'success',\n isError: status === 'error',\n isPaused: false,\n hasData: state.data !== undefined,\n hasFetched: state.hasFetched,\n refetch,\n }\n}\n\n/**\n * Internal hook for managing async state with plain promises.\n * Use this when you don't have TanStack Query or SWR.\n */\nfunction useAsyncState<T>(\n fetcher: () => Promise<T>,\n options?: { enabled?: boolean },\n): AsyncLoaderResult<T> {\n const { enabled = true } = options ?? {}\n const [state, setState] = React.useState<VanillaAsyncInternalState<T>>(\n () => ({\n data: undefined,\n error: null,\n isFetching: enabled,\n hasFetched: false,\n }),\n )\n\n const fetcherRef = React.useRef(fetcher)\n fetcherRef.current = fetcher\n\n const refetch = React.useCallback(() => {\n setState((s) => ({ ...s, isFetching: true, error: null }))\n fetcherRef\n .current()\n .then((data) => {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n })\n .catch((error) => {\n setState((s) => ({\n ...s,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n }))\n })\n }, [])\n\n React.useEffect(() => {\n if (enabled) {\n refetch()\n return\n }\n\n setState((s) => ({\n ...s,\n isFetching: false,\n }))\n }, [enabled, refetch])\n\n return React.useMemo(\n () => toVanillaAsyncLoaderResult(state, refetch),\n [state, refetch],\n )\n}\n\n/**\n * Internal hook for managing query-dependent async state with plain promises.\n * Unlike `useAsyncState`, this hook re-fetches whenever the query changes.\n * Aborts in-flight requests when a new query is issued or the component unmounts.\n */\nfunction useAsyncQueryState(\n fetcher: (\n query: string,\n options?: { signal?: AbortSignal },\n ) => Promise<NodeDef[]>,\n query: string,\n options?: { enabled?: boolean },\n): AsyncLoaderResult<NodeDef[]> {\n const { enabled = true } = options ?? {}\n const [state, setState] = React.useState<\n VanillaAsyncInternalState<NodeDef[]>\n >(() => ({\n data: undefined,\n error: null,\n isFetching: enabled,\n hasFetched: false,\n }))\n\n const fetcherRef = React.useRef(fetcher)\n fetcherRef.current = fetcher\n\n React.useEffect(() => {\n if (!enabled) {\n setState({\n data: undefined,\n error: null,\n isFetching: false,\n hasFetched: false,\n })\n return\n }\n\n const controller = new AbortController()\n\n setState({\n data: undefined,\n error: null,\n isFetching: true,\n hasFetched: false,\n })\n\n fetcherRef\n .current(query, { signal: controller.signal })\n .then((data) => {\n if (!controller.signal.aborted) {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n }\n })\n .catch((error) => {\n if (!controller.signal.aborted) {\n setState({\n data: undefined,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n })\n }\n })\n\n return () => {\n controller.abort()\n }\n }, [enabled, query])\n\n const refetch = React.useCallback(() => {\n // Trigger re-run by toggling a state-based effect isn't ideal here,\n // so we do a manual fetch that respects the current query/enabled state.\n setState((s) => ({\n ...s,\n isFetching: true,\n error: null,\n }))\n fetcherRef\n .current(query)\n .then((data) => {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n })\n .catch((error) => {\n setState((s) => ({\n ...s,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n }))\n })\n }, [query])\n\n return React.useMemo(\n () => toVanillaAsyncLoaderResult(state, refetch),\n [state, refetch],\n )\n}\n\n/**\n * Props for creating a static loader with vanilla fetch.\n */\nexport interface CreateVanillaStaticLoaderProps {\n /**\n * Async function that fetches the menu items.\n */\n fetcher: () => Promise<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration using plain fetch/promises.\n * No external data library required.\n *\n * @example\n * ```tsx\n * const recentFilesLoader = createVanillaStaticLoader({\n * fetcher: async () => {\n * const res = await fetch('/api/recent-files')\n * const data = await res.json()\n * return data.map(file => ({\n * kind: 'item',\n * value: file.name,\n * render: ...\n * }))\n * },\n * })\n * ```\n */\nexport function createVanillaStaticLoader(\n props: CreateVanillaStaticLoaderProps,\n): StaticLoaderConfig {\n const { fetcher, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useAsyncState(fetcher)\n return <>{children(result)}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query loader with vanilla fetch.\n */\nexport interface CreateVanillaQueryLoaderProps {\n /**\n * Async function that fetches menu items based on the search query.\n * Receives an optional `signal` that is aborted when a newer query is issued,\n * allowing you to cancel in-flight requests (e.g. pass it to `fetch()`).\n */\n fetcher: (\n query: string,\n options?: { signal?: AbortSignal },\n ) => Promise<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query loader configuration using plain fetch/promises.\n * No external data library required.\n *\n * @example\n * ```tsx\n * const searchLoader = createVanillaQueryLoader({\n * fetcher: async (query, options) => {\n * const res = await fetch(`/api/search?q=${encodeURIComponent(query)}`, {\n * signal: options?.signal, // aborts when a newer query is issued\n * })\n * const data = await res.json()\n * return data.map(item => ({\n * kind: 'item',\n * value: item.name,\n * render: ...\n * }))\n * },\n * minQueryLength: 2,\n * })\n * ```\n */\nexport function createVanillaQueryLoader(\n props: CreateVanillaQueryLoaderProps,\n): QueryLoaderConfig {\n const {\n fetcher,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useAsyncQueryState(fetcher, query, { enabled: isEnabled })\n return <>{children(result)}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/loaders/index.cjs","../../src/loaders/swr.tsx","../../src/loaders/tanstack-query.tsx","../../src/loaders/vanilla.tsx"],"names":["toError","error","toAsyncLoaderResultFromSWR","result","normalizedError","hasData","fetchStatus","isFetching","isInitialLoading","isRefetching","status","loadingPhase","createSWRStaticLoader","props","useSWR","loadStrategy","children","jsx","Fragment","createSWRQueryLoader","minQueryLength","initialQueryBehavior","initialQuery","belowMinBehavior","placeholderNodes","resolvedInitialQueryBehavior","query","enabled","isEnabled","createSWRLoaderComponent","useSWRFn","toAsyncLoaderResult","isPending","isSuccess","isError","isPaused","hasFetched","createStaticLoader","useQuery","createQueryLoader","createLoaderComponent","useQueryFn","normalizeError","getVanillaStatus","state","toVanillaAsyncLoaderResult","refetch","useAsyncState","fetcher","options","setState","fetcherRef","data","s","useAsyncQueryState","controller","createVanillaStaticLoader","createVanillaQueryLoader"],"mappings":"AAAA,geAA6B,+CC8HlB,SA9FFA,CAAAA,CAAQC,CAAAA,CAA8B,CAC7C,OAAIA,CAAAA,EAAS,IAAA,CACJ,IAAA,CAGLA,EAAAA,WAAiB,KAAA,CACZA,CAAAA,CAGF,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAK,CAAC,CAChC,CAKO,SAASC,CAAAA,CACdC,CAAAA,CACoD,CACpD,IAAMC,CAAAA,CAAkBJ,CAAAA,CAAQG,CAAAA,CAAO,KAAK,CAAA,CACtCE,CAAAA,CAAUF,CAAAA,CAAO,IAAA,GAAS,KAAA,CAAA,CAE1BG,CAAAA,CAAsCH,CAAAA,CAAO,QAAA,CAC/C,QAAA,CACAA,CAAAA,CAAO,YAAA,CACL,UAAA,CACA,MAAA,CAEAI,CAAAA,CAAaD,CAAAA,GAAgB,UAAA,CAC7BE,CAAAA,kBACJL,CAAAA,CAAO,SAAA,SAAA,CAAcI,CAAAA,EAAc,CAACF,CAAAA,EAAWD,CAAAA,EAAmB,IAAA,GAAA,CAC9DK,CAAAA,CAAeF,CAAAA,EAAc,CAACC,CAAAA,CAE9BE,CAAAA,CAA4BN,CAAAA,CAC9B,OAAA,CACAC,CAAAA,CACE,SAAA,CACAG,CAAAA,EAAoBD,CAAAA,CAClB,SAAA,CACA,MAAA,CAEFI,CAAAA,CAAwCH,CAAAA,CAC1C,SAAA,CACAC,CAAAA,CACE,YAAA,CACA,MAAA,CAEN,MAAO,CACL,IAAA,CAAMN,CAAAA,CAAO,IAAA,CACb,GAAA,CAAKA,CAAAA,CACL,MAAA,CAAQ,KAAA,CACR,KAAA,CAAOC,CAAAA,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AEEY,CAAAA,CACJJ,CAAAA,GAAyB,KAAA,CAAA,CACrBA,CAAAA,CACAC,CAAAA,GAAiB,KAAA,CAAA,CACf,CAAE,KAAA,CAAOA,CAAAA,CAAc,QAAA,CAAU,QAAS,CAAA,CAC1C,CAAE,KAAA,CAAO,EAAA,CAAI,QAAA,CAAU,QAAS,CAAA,CAcxC,MAAO,CACL,IAAA,CAAM,OAAA,CACN,MAAA,CAd6C,CAAC,CAC9C,KAAA,CAAAI,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,QAAA,CAAAX,CACF,CAAA,CAAA,EAAM,CACJ,IAAMY,CAAAA,kBACJD,CAAAA,SAAAA,CACCD,CAAAA,CAAM,MAAA,EAAUN,CAAAA,EAAkBK,CAAAA,GAAiC,CAAA,CAAA,GAAA,CAChEtB,CAAAA,CAASmD,CAAAA,CAAmBN,CAAAA,CAAStB,CAAAA,CAAO,CAAE,OAAA,CAASE,CAAU,CAAC,CAAA,CACxE,OAAOX,6BAAAA,oBAAAC,CAAA,CAAG,QAAA,CAAAF,CAAAA,CAASb,CAAM,CAAA,CAAE,CAC7B,CAAA,CAKE,cAAA,CAAAiB,CAAAA,CACA,oBAAA,CAAsBK,CAAAA,CACtB,YAAA,CAAAH,CAAAA,CACA,YAAA,CAAAP,CAAAA,CACA,gBAAA,CAAAQ,CAAAA,CACA,gBAAA,CAAAC,CACF,CACF,CAAA,kWAAA","file":"/home/runner/work/ui/ui/packages/react/dist/loaders/index.cjs","sourcesContent":[null,"'use client'\n\nimport type * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/data-first/types.js'\n\n// ============================================================================\n// SWR Adapter\n// ============================================================================\n\n/**\n * SWR result shape (subset of SWRResponse).\n * This allows the adapter to work without requiring `swr` as a dependency.\n */\nexport interface SWRResult<TData, TError = Error> {\n data: TData | undefined\n error: TError | undefined\n isLoading?: boolean\n isValidating: boolean\n isPaused?: boolean\n mutate: (...args: unknown[]) => unknown\n}\n\nfunction toError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\n/**\n * Converts an SWR result to an AsyncLoaderResult.\n */\nexport function toAsyncLoaderResultFromSWR<TData, TError = Error>(\n result: SWRResult<TData, TError>,\n): AsyncLoaderResult<TData, SWRResult<TData, TError>> {\n const normalizedError = toError(result.error)\n const hasData = result.data !== undefined\n\n const fetchStatus: AsyncLoaderFetchStatus = result.isPaused\n ? 'paused'\n : result.isValidating\n ? 'fetching'\n : 'idle'\n\n const isFetching = fetchStatus === 'fetching'\n const isInitialLoading =\n result.isLoading ?? (isFetching && !hasData && normalizedError == null)\n const isRefetching = isFetching && !isInitialLoading\n\n const status: AsyncLoaderStatus = normalizedError\n ? 'error'\n : hasData\n ? 'success'\n : isInitialLoading || isFetching\n ? 'pending'\n : 'idle'\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: result.data,\n raw: result,\n source: 'swr',\n error: normalizedError,\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching,\n isInitialLoading,\n isRefetching,\n isPending: status === 'pending',\n isSuccess: status === 'success',\n isError: status === 'error',\n isPaused: fetchStatus === 'paused',\n hasData,\n hasFetched:\n hasData || normalizedError != null || isInitialLoading || isRefetching,\n refetch: () => result.mutate(),\n }\n}\n\n/**\n * Props for creating a static SWR loader component.\n */\nexport interface CreateSWRStaticLoaderProps {\n /** Hook that returns an SWR result. */\n useSWR: () => SWRResult<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration backed by SWR.\n */\nexport function createSWRStaticLoader(\n props: CreateSWRStaticLoaderProps,\n): StaticLoaderConfig {\n const { useSWR, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useSWR()\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query SWR loader component.\n */\nexport interface CreateSWRQueryLoaderProps {\n /**\n * Hook that returns an SWR result based on the search query.\n * `options.enabled` can be used to derive a `null` key and disable fetching.\n */\n useSWR: (\n query: string,\n options?: { enabled: boolean },\n ) => SWRResult<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query loader configuration backed by SWR.\n */\nexport function createSWRQueryLoader(\n props: CreateSWRQueryLoaderProps,\n): QueryLoaderConfig {\n const {\n useSWR,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useSWR(query, { enabled: isEnabled })\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n\n/**\n * Creates a loader component that wraps an SWR hook.\n */\nexport function createSWRLoaderComponent(\n useSWRFn: (query: string) => SWRResult<NodeDef[]>,\n): React.FC<LoaderComponentProps> {\n return function SWRLoader({ query, children }) {\n const result = useSWRFn(query)\n return <>{children(toAsyncLoaderResultFromSWR(result))}</>\n }\n}\n","'use client'\n\nimport type * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/data-first/types.js'\n\n// ============================================================================\n// TanStack Query Adapter\n// ============================================================================\n\n/**\n * TanStack Query result shape (subset of UseQueryResult).\n * This allows the adapter to work without requiring @tanstack/react-query as a dependency.\n */\nexport interface TanStackQueryResult<TData, TError = Error> {\n /** TanStack status (`pending` | `error` | `success`) */\n status?: 'pending' | 'error' | 'success'\n\n /** TanStack fetch status (`fetching` | `paused` | `idle`) */\n fetchStatus?: 'fetching' | 'paused' | 'idle'\n\n data: TData | undefined\n error: TError | null | undefined\n\n /** v5: true when first fetch is in-flight */\n isLoading?: boolean\n\n /** v5: true when status is pending */\n isPending?: boolean\n\n /** true when status is success */\n isSuccess?: boolean\n\n /** true when status is error */\n isError?: boolean\n\n /** true while any fetch is in-flight */\n isFetching?: boolean\n\n /** true while background refetch is in-flight */\n isRefetching?: boolean\n\n /** true when fetch is paused */\n isPaused?: boolean\n\n /** true once query has fetched at least once */\n isFetched?: boolean\n\n refetch: () => unknown\n}\n\nfunction toError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\n/**\n * Converts a TanStack Query result to an AsyncLoaderResult.\n * Use this to wrap your useQuery hook result.\n *\n * @example\n * ```tsx\n * function MyLoader({ query, children }) {\n * const result = useQuery({\n * queryKey: ['items', query],\n * queryFn: () => fetchItems(query),\n * })\n * return children(toAsyncLoaderResult(result))\n * }\n * ```\n */\nexport function toAsyncLoaderResult<TData, TError = Error>(\n result: TanStackQueryResult<TData, TError>,\n): AsyncLoaderResult<TData, TanStackQueryResult<TData, TError>> {\n const hasData = result.data !== undefined\n\n const fetchStatus: AsyncLoaderFetchStatus = result.fetchStatus\n ? result.fetchStatus\n : result.isPaused\n ? 'paused'\n : result.isFetching || result.isLoading\n ? 'fetching'\n : 'idle'\n\n const isFetching = fetchStatus === 'fetching'\n\n const status: AsyncLoaderStatus = result.status\n ? result.status\n : result.isError\n ? 'error'\n : result.isSuccess || hasData\n ? 'success'\n : result.isPending || result.isLoading || isFetching\n ? 'pending'\n : 'idle'\n\n const isPending = result.isPending ?? status === 'pending'\n const isSuccess = result.isSuccess ?? status === 'success'\n const isError = result.isError ?? status === 'error'\n const isInitialLoading = result.isLoading ?? (isPending && isFetching)\n const isRefetching = result.isRefetching ?? (isFetching && !isInitialLoading)\n const isPaused = result.isPaused ?? fetchStatus === 'paused'\n const hasFetched =\n result.isFetched ??\n (isSuccess || isError || isInitialLoading || isRefetching)\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: result.data,\n raw: result,\n source: 'tanstack-query',\n error: toError(result.error),\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching,\n isInitialLoading,\n isRefetching,\n isPending,\n isSuccess,\n isError,\n isPaused,\n hasData,\n hasFetched,\n refetch: result.refetch,\n }\n}\n\n/**\n * Props for creating a static loader component.\n */\nexport interface CreateStaticLoaderProps {\n /**\n * Hook that returns a TanStack Query result.\n * This hook will be called inside the loader component.\n */\n useQuery: () => TanStackQueryResult<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration for use with async menus.\n * The hook is called inside a component, so it follows React's rules of hooks.\n *\n * @example\n * ```tsx\n * const recentFilesLoader = createStaticLoader({\n * useQuery: () => useQuery({\n * queryKey: ['recent-files'],\n * queryFn: fetchRecentFiles,\n * staleTime: 5 * 60 * 1000,\n * }),\n * })\n *\n * // Use in submenu\n * {\n * kind: 'submenu',\n * value: 'Recent Files',\n * asyncNodes: {\n * ...recentFilesLoader,\n * loadStrategy: 'eager',\n * },\n * render: ...\n * }\n * ```\n */\nexport function createStaticLoader(\n props: CreateStaticLoaderProps,\n): StaticLoaderConfig {\n const { useQuery, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useQuery()\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query loader component.\n */\nexport interface CreateQueryLoaderProps {\n /**\n * Hook that returns a TanStack Query result based on the search query.\n * This hook will be called inside the loader component with the current query.\n */\n useQuery: (\n query: string,\n options?: { enabled: boolean },\n ) => TanStackQueryResult<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query loader configuration for use with async menus.\n * The loader will re-fetch when the search query changes.\n *\n * @example\n * ```tsx\n * const searchLoader = createQueryLoader({\n * useQuery: (query, options) => useQuery({\n * queryKey: ['search', query],\n * queryFn: () => searchItems(query),\n * enabled: options?.enabled,\n * }),\n * minQueryLength: 2,\n * })\n *\n * // Use in submenu\n * {\n * kind: 'submenu',\n * value: 'Search',\n * includeInDeepSearch: true,\n * asyncNodes: searchLoader,\n * render: ...\n * }\n * ```\n */\nexport function createQueryLoader(\n props: CreateQueryLoaderProps,\n): QueryLoaderConfig {\n const {\n useQuery,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useQuery(query, { enabled: isEnabled })\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n\n/**\n * Creates a loader component that wraps a TanStack Query hook.\n * This is a lower-level utility for custom loader implementations.\n *\n * @example\n * ```tsx\n * const MyLoader = createLoaderComponent((query) =>\n * useQuery({\n * queryKey: ['items', query],\n * queryFn: () => fetchItems(query),\n * })\n * )\n * ```\n */\nexport function createLoaderComponent(\n useQueryFn: (query: string) => TanStackQueryResult<NodeDef[]>,\n): React.FC<LoaderComponentProps> {\n return function TanStackLoader({ query, children }) {\n const result = useQueryFn(query)\n return <>{children(toAsyncLoaderResult(result))}</>\n }\n}\n","'use client'\n\nimport * as React from 'react'\nimport type {\n AsyncLoaderFetchStatus,\n AsyncLoaderLoadingPhase,\n AsyncLoaderResult,\n AsyncLoaderStatus,\n InitialQueryBehavior,\n LoaderComponentProps,\n NodeDef,\n QueryLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/data-first/types.js'\n\n// ============================================================================\n// Vanilla Async Adapter (no external dependencies)\n// ============================================================================\n\ninterface VanillaAsyncInternalState<TData> {\n data: TData | undefined\n error: Error | null\n isFetching: boolean\n hasFetched: boolean\n}\n\nfunction normalizeError(error: unknown): Error | null {\n if (error == null) {\n return null\n }\n\n if (error instanceof Error) {\n return error\n }\n\n return new Error(String(error))\n}\n\nfunction getVanillaStatus<TData>(\n state: VanillaAsyncInternalState<TData>,\n): AsyncLoaderStatus {\n if (state.error) {\n return 'error'\n }\n\n if (state.data !== undefined) {\n return 'success'\n }\n\n if (state.isFetching) {\n return 'pending'\n }\n\n return 'idle'\n}\n\nfunction toVanillaAsyncLoaderResult<TData>(\n state: VanillaAsyncInternalState<TData>,\n refetch: () => unknown,\n): AsyncLoaderResult<TData> {\n const status = getVanillaStatus(state)\n const fetchStatus: AsyncLoaderFetchStatus = state.isFetching\n ? 'fetching'\n : 'idle'\n\n const isInitialLoading = state.isFetching && !state.hasFetched\n const isRefetching = state.isFetching && state.hasFetched\n\n const loadingPhase: AsyncLoaderLoadingPhase = isInitialLoading\n ? 'initial'\n : isRefetching\n ? 'background'\n : 'none'\n\n return {\n data: state.data,\n source: 'vanilla',\n error: state.error,\n status,\n fetchStatus,\n loadingPhase,\n isLoading: isInitialLoading,\n isFetching: state.isFetching,\n isInitialLoading,\n isRefetching,\n isPending: status === 'pending',\n isSuccess: status === 'success',\n isError: status === 'error',\n isPaused: false,\n hasData: state.data !== undefined,\n hasFetched: state.hasFetched,\n refetch,\n }\n}\n\n/**\n * Internal hook for managing async state with plain promises.\n * Use this when you don't have TanStack Query or SWR.\n */\nfunction useAsyncState<T>(\n fetcher: () => Promise<T>,\n options?: { enabled?: boolean },\n): AsyncLoaderResult<T> {\n const { enabled = true } = options ?? {}\n const [state, setState] = React.useState<VanillaAsyncInternalState<T>>(\n () => ({\n data: undefined,\n error: null,\n isFetching: enabled,\n hasFetched: false,\n }),\n )\n\n const fetcherRef = React.useRef(fetcher)\n fetcherRef.current = fetcher\n\n const refetch = React.useCallback(() => {\n setState((s) => ({ ...s, isFetching: true, error: null }))\n fetcherRef\n .current()\n .then((data) => {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n })\n .catch((error) => {\n setState((s) => ({\n ...s,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n }))\n })\n }, [])\n\n React.useEffect(() => {\n if (enabled) {\n refetch()\n return\n }\n\n setState((s) => ({\n ...s,\n isFetching: false,\n }))\n }, [enabled, refetch])\n\n return React.useMemo(\n () => toVanillaAsyncLoaderResult(state, refetch),\n [state, refetch],\n )\n}\n\n/**\n * Internal hook for managing query-dependent async state with plain promises.\n * Unlike `useAsyncState`, this hook re-fetches whenever the query changes.\n * Aborts in-flight requests when a new query is issued or the component unmounts.\n */\nfunction useAsyncQueryState(\n fetcher: (\n query: string,\n options?: { signal?: AbortSignal },\n ) => Promise<NodeDef[]>,\n query: string,\n options?: { enabled?: boolean },\n): AsyncLoaderResult<NodeDef[]> {\n const { enabled = true } = options ?? {}\n const [state, setState] = React.useState<\n VanillaAsyncInternalState<NodeDef[]>\n >(() => ({\n data: undefined,\n error: null,\n isFetching: enabled,\n hasFetched: false,\n }))\n\n const fetcherRef = React.useRef(fetcher)\n fetcherRef.current = fetcher\n\n React.useEffect(() => {\n if (!enabled) {\n setState({\n data: undefined,\n error: null,\n isFetching: false,\n hasFetched: false,\n })\n return\n }\n\n const controller = new AbortController()\n\n setState({\n data: undefined,\n error: null,\n isFetching: true,\n hasFetched: false,\n })\n\n fetcherRef\n .current(query, { signal: controller.signal })\n .then((data) => {\n if (!controller.signal.aborted) {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n }\n })\n .catch((error) => {\n if (!controller.signal.aborted) {\n setState({\n data: undefined,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n })\n }\n })\n\n return () => {\n controller.abort()\n }\n }, [enabled, query])\n\n const refetch = React.useCallback(() => {\n // Trigger re-run by toggling a state-based effect isn't ideal here,\n // so we do a manual fetch that respects the current query/enabled state.\n setState((s) => ({\n ...s,\n isFetching: true,\n error: null,\n }))\n fetcherRef\n .current(query)\n .then((data) => {\n setState({\n data,\n error: null,\n isFetching: false,\n hasFetched: true,\n })\n })\n .catch((error) => {\n setState((s) => ({\n ...s,\n error: normalizeError(error),\n isFetching: false,\n hasFetched: true,\n }))\n })\n }, [query])\n\n return React.useMemo(\n () => toVanillaAsyncLoaderResult(state, refetch),\n [state, refetch],\n )\n}\n\n/**\n * Props for creating a static loader with vanilla fetch.\n */\nexport interface CreateVanillaStaticLoaderProps {\n /**\n * Async function that fetches the menu items.\n */\n fetcher: () => Promise<NodeDef[]>\n\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens\n * - 'lazy': Load when submenu opens (default)\n */\n loadStrategy?: 'eager' | 'lazy'\n}\n\n/**\n * Creates a static loader configuration using plain fetch/promises.\n * No external data library required.\n *\n * @example\n * ```tsx\n * const recentFilesLoader = createVanillaStaticLoader({\n * fetcher: async () => {\n * const res = await fetch('/api/recent-files')\n * const data = await res.json()\n * return data.map(file => ({\n * kind: 'item',\n * value: file.name,\n * render: ...\n * }))\n * },\n * })\n * ```\n */\nexport function createVanillaStaticLoader(\n props: CreateVanillaStaticLoaderProps,\n): StaticLoaderConfig {\n const { fetcher, loadStrategy } = props\n\n const Loader: React.FC<LoaderComponentProps> = ({ children }) => {\n const result = useAsyncState(fetcher)\n return <>{children(result)}</>\n }\n\n return {\n type: 'static',\n Loader,\n loadStrategy,\n }\n}\n\n/**\n * Props for creating a query loader with vanilla fetch.\n */\nexport interface CreateVanillaQueryLoaderProps {\n /**\n * Async function that fetches menu items based on the search query.\n * Receives an optional `signal` that is aborted when a newer query is issued,\n * allowing you to cancel in-flight requests (e.g. pass it to `fetch()`).\n */\n fetcher: (\n query: string,\n options?: { signal?: AbortSignal },\n ) => Promise<NodeDef[]>\n /**\n * Minimum query length before fetching.\n * @default 1\n */\n minQueryLength?: number\n /**\n * Initial query behavior before user input reaches minQueryLength.\n * Defaults to fetching with an empty query.\n */\n initialQueryBehavior?: InitialQueryBehavior | false\n /**\n * @deprecated Use `initialQueryBehavior` instead.\n */\n initialQuery?: string\n /**\n * When to trigger the loader:\n * - 'eager': Load when root menu opens (good for deep search)\n * - 'lazy': Load when submenu opens (default)\n * @default 'lazy'\n */\n loadStrategy?: 'eager' | 'lazy'\n /**\n * What to show when query is below minQueryLength.\n * @default 'empty'\n */\n belowMinBehavior?: 'empty' | 'placeholder'\n /**\n * Placeholder nodes shown when query is below minQueryLength.\n */\n placeholderNodes?: NodeDef[]\n}\n\n/**\n * Creates a query loader configuration using plain fetch/promises.\n * No external data library required.\n *\n * @example\n * ```tsx\n * const searchLoader = createVanillaQueryLoader({\n * fetcher: async (query, options) => {\n * const res = await fetch(`/api/search?q=${encodeURIComponent(query)}`, {\n * signal: options?.signal, // aborts when a newer query is issued\n * })\n * const data = await res.json()\n * return data.map(item => ({\n * kind: 'item',\n * value: item.name,\n * render: ...\n * }))\n * },\n * minQueryLength: 2,\n * })\n * ```\n */\nexport function createVanillaQueryLoader(\n props: CreateVanillaQueryLoaderProps,\n): QueryLoaderConfig {\n const {\n fetcher,\n minQueryLength = 1,\n initialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior = 'empty',\n placeholderNodes,\n } = props\n\n const resolvedInitialQueryBehavior: InitialQueryBehavior | false =\n initialQueryBehavior !== undefined\n ? initialQueryBehavior\n : initialQuery !== undefined\n ? { value: initialQuery, loadWhen: 'needed' }\n : { value: '', loadWhen: 'needed' }\n\n const Loader: React.FC<LoaderComponentProps> = ({\n query,\n enabled,\n children,\n }) => {\n const isEnabled =\n enabled ??\n (query.length >= minQueryLength || resolvedInitialQueryBehavior !== false)\n const result = useAsyncQueryState(fetcher, query, { enabled: isEnabled })\n return <>{children(result)}</>\n }\n\n return {\n type: 'query',\n Loader,\n minQueryLength,\n initialQueryBehavior: resolvedInitialQueryBehavior,\n initialQuery,\n loadStrategy,\n belowMinBehavior,\n placeholderNodes,\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkSCDHQZFIcjs = require('../chunk-SCDHQZFI.cjs');var _chunk5T5B5SPRcjs = require('../chunk-5T5B5SPR.cjs');var _chunkW4ACKMIZcjs = require('../chunk-W4ACKMIZ.cjs');var _chunkXMZZ62VJcjs = require('../chunk-XMZZ62VJ.cjs');var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var Nt={};_chunkM4G6J7DPcjs.a.call(void 0, Nt,{Arrow:()=>_chunkW4ACKMIZcjs.s,Backdrop:()=>_chunkW4ACKMIZcjs.t,Empty:()=>_chunkW4ACKMIZcjs.U,Group:()=>_chunkW4ACKMIZcjs.pa,GroupLabel:()=>_chunkW4ACKMIZcjs.W,Icon:()=>_chunkW4ACKMIZcjs.T,Input:()=>_chunkW4ACKMIZcjs.V,Item:()=>ze,ItemIndicator:()=>Ge,ItemLabel:()=>Fe,List:()=>_chunkW4ACKMIZcjs.ba,Popup:()=>je,Portal:()=>_chunkW4ACKMIZcjs.K,Positioner:()=>Ye,Root:()=>Xe,ScrollDownArrow:()=>_chunkW4ACKMIZcjs.ea,ScrollUpArrow:()=>_chunkW4ACKMIZcjs.da,Separator:()=>_chunkW4ACKMIZcjs.sa,Surface:()=>$e,Trigger:()=>Ke,Value:()=>Je});var _userender = require('@base-ui/react/use-render');var _react = require('react'); var E = _interopRequireWildcard(_react); var Ie = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var Ae = _interopRequireWildcard(_react); var j = _interopRequireWildcard(_react); var ce = _interopRequireWildcard(_react); var Oe = _interopRequireWildcard(_react); var C = _interopRequireWildcard(_react); var I = _interopRequireWildcard(_react); var De = _interopRequireWildcard(_react); var G = _interopRequireWildcard(_react); var ae = _interopRequireWildcard(_react);var Le=Ie.createContext(null);function O(){let e=Ie.useContext(Le);if(!e)throw new Error("Select components must be used within a Select.Root");return e}function so(){return Ie.useContext(Le)}var $={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected",first:"data-first",last:"data-last",firstInGroup:"data-first-in-group",lastInGroup:"data-last-in-group"};var ke=Ce.createContext(null);function Te(){let e=Ce.useContext(ke);if(!e)throw new Error("Select.Item child components must be used within a Select.Item");return e}function uo(){return Ce.useContext(ke)}var _jsxruntime = require('react/jsx-runtime');var po={highlighted:e=>e?{[$.highlighted]:""}:null,disabled:e=>e?{[$.disabled]:""}:null,selected:e=>e?{[$.selected]:""}:null,first:e=>e?{[$.first]:""}:null,last:e=>e?{[$.last]:""}:null,firstInGroup:e=>e?{[$.firstInGroup]:""}:null,lastInGroup:e=>e?{[$.lastInGroup]:""}:null};function mo(e,n){let{value:t,textValue:l,keywords:s,disabled:r=!1,onSelect:c,forceMount:b=!1,render:o,className:a,style:P,onClick:d,onPointerDown:m,onPointerMove:R,children:u,...i}=e,p=O(),g=E.useMemo(()=>_chunkW4ACKMIZcjs.S.call(void 0, t,p.itemToStringValue),[t,p.itemToStringValue]),M=E.useId(),L=t===null?`select-clear-${M}`:void 0,h=E.useMemo(()=>_chunk5T5B5SPRcjs.e.call(void 0, p.items,g),[p.items,g]),V=_optionalChain([h, 'optionalAccess', _2 => _2.label]),w=E.useMemo(()=>_chunkW4ACKMIZcjs.R.call(void 0, t,p.itemToStringLabel),[t,p.itemToStringLabel]),v=E.useMemo(()=>{if(l!==void 0)return l;if(typeof V=="string")return V;if(w&&w!==g)return w},[l,V,w,g]),ee=E.useMemo(()=>_chunk5T5B5SPRcjs.g.call(void 0, s,[typeof V=="string"?V:w&&w!==g?w:void 0,..._nullishCoalesce(_optionalChain([h, 'optionalAccess', _3 => _3.keywords]), () => ([]))]),[s,V,w,g,h]),k=E.useRef(v),A=p.multiple?_chunk5T5B5SPRcjs.c.call(void 0, p.values,t,p.isItemEqualToValue):p.value!==""&&_chunk5T5B5SPRcjs.b.call(void 0, p.value,t,p.isItemEqualToValue),ie=!p.multiple,S=_chunkW4ACKMIZcjs.O.call(void 0, {id:L,value:g,keywords:ee,disabled:r,forceMount:b,closeOnClick:ie,children:u});E.useEffect(()=>{let T=()=>{if(!r){if(p.multiple)if(t==null)p.onValuesChange([]);else{let te=A?_chunk5T5B5SPRcjs.d.call(void 0, p.values,t,p.isItemEqualToValue):[...p.values,t];p.onValuesChange(te)}else p.onValueChange(t);_optionalChain([c, 'optionalCall', _4 => _4()])}};return S.registerSelect(T)},[r,p,t,A,c,S]),E.useEffect(()=>{let T=k.current;if(T)return p.registerItemText(g,T)},[g,p]),E.useEffect(()=>{!v&&typeof u=="string"&&(k.current=u,p.registerItemText(g,u))},[u,v,g,p]);let F=E.useMemo(()=>({highlighted:S.isHighlighted,disabled:r,selected:A,first:S.positional.first,last:S.positional.last,firstInGroup:S.positional.firstInGroup,lastInGroup:S.positional.lastInGroup}),[S.isHighlighted,r,A,S.positional]),J=E.useMemo(()=>({id:S.id,value:t,textValue:v,highlighted:S.isHighlighted,disabled:r,selected:A}),[S.id,t,v,S.isHighlighted,r,A]),B=E.useCallback(T=>{_optionalChain([d, 'optionalCall', _5 => _5(T)]),T.defaultPrevented||S.handlers.onClick(T)},[d,S.handlers]),W=E.useCallback(T=>{S.handlers.onPointerDown(T),_optionalChain([m, 'optionalCall', _6 => _6(T)])},[S.handlers,m]),_=E.useCallback(T=>{_optionalChain([R, 'optionalCall', _7 => _7(T)]),T.defaultPrevented||S.handlers.onPointerMove(T)},[R,S.handlers]),q=_userender.useRender.call(void 0, {render:o,ref:[S.ref,S.rowRef,n],state:F,stateAttributesMapping:po,props:{...i,[$.slot]:"",id:S.id,role:"option",tabIndex:-1,"aria-selected":A,"aria-disabled":r||void 0,className:a,style:P,onClick:B,onPointerMove:_,onPointerDown:W,children:u},enabled:S.isVisible,defaultTagName:"div"});return S.isVisible?_jsxruntime.jsx.call(void 0, ke.Provider,{value:J,children:q}):null}var ze=E.forwardRef(mo);var Me={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var So={selected:e=>e?{[Me.selected]:""}:null,highlighted:e=>e?{[Me.highlighted]:""}:null},Ge= exports.SelectItemIndicator =Ae.forwardRef(function(n,t){let{render:l,className:s,style:r,forceMount:c=!1,keepMounted:b=!1,children:o,...a}=n,P=Te(),d=P.selected,m=P.highlighted,R=Ae.useMemo(()=>({selected:d,highlighted:m}),[d,m]),u=c||b||d,i=typeof o=="function"?o(R):b&&!d?null:o,p=_userender.useRender.call(void 0, {render:l,ref:t,state:R,stateAttributesMapping:So,props:{...a,[Me.slot]:"","aria-hidden":!0,className:s,style:r,children:i},defaultTagName:"span"});return u?p:null});var Mt={slot:"bazzaui-select-item-label"};var Fe=j.forwardRef(function(n,t){let{render:l,className:s,style:r,children:c,...b}=n,o=O(),a=Te(),P=j.useRef(null),d=_chunkW4ACKMIZcjs.S.call(void 0, a.value,o.itemToStringValue),m=j.useMemo(()=>{if(c!==void 0)return c;let i=_chunk5T5B5SPRcjs.f.call(void 0, o.items,d);return i!==void 0?i:a.textValue!==void 0?a.textValue:d},[c,o.items,d,a.textValue]),R=j.useMemo(()=>({value:d,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[d,a.selected,a.highlighted,a.disabled]);j.useEffect(()=>{if(typeof m=="string")return o.registerItemText(d,m)},[m,o,d]);let u=j.useCallback(i=>{P.current=i,a.selected&&i&&(o.selectedItemTextRef.current=i),i&&!a.disabled&&(o.firstItemTextRef.current||(o.firstItemTextRef.current=i))},[a.selected,a.disabled,o]);return _userender.useRender.call(void 0, {render:l,ref:t,state:R,props:{...b,[Mt.slot]:"",ref:u,className:s,style:r,children:m},defaultTagName:"span"})});var Be=Oe.createContext(null);function Ve(){return Oe.useContext(Be)}var je=ce.forwardRef(function(n,t){let{className:l,render:s,...r}=n,c=Ve(),b=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _8 => _8.alignItemWithTriggerActive]), () => (!1)),o=_optionalChain([c, 'optionalAccess', _9 => _9.align]),a=ce.useCallback(m=>({...m,side:b?"none":m.side,alignItemWithTriggerActive:b}),[b]),P=ce.useMemo(()=>typeof l=="function"?m=>l(a(m)):l,[l,a]),d=ce.useMemo(()=>typeof s=="function"?(m,R)=>s(m,a(R)):s,[s,a]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.J,{ref:t,className:P,render:d,"data-align-item-with-trigger":b?"":void 0,...b?{"data-side":"none","data-align":o}:{},...r})});var _directioncontext = require('@base-ui/react/internals/direction-context');var _popover = require('@base-ui/react/popover');function pe(e,n,t){return e<n?n:e>t?t:e}function We(e){let n=e.getBoundingClientRect(),{offsetWidth:t,offsetHeight:l}=e,s=t>0?Math.round(n.width)/t:1,r=l>0?Math.round(n.height)/l:1;return(!Number.isFinite(s)||s===0)&&(s=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:s,y:r}}function Vt(e,n,t){return e/t[n]}function ve(e,n){let t=e.x/n.x,l=e.y/n.y,s=e.width/n.x,r=e.height/n.y;return{x:t,y:l,width:s,height:r,top:l,left:t,right:t+s,bottom:l+r}}var K=1;function ge(e,n){return Math.max(0,e-n)}var vt=5,yt=20,_e=10,Et=100;function wt(e){let{triggerRect:n,positionerRect:t,valueRect:l,textRect:s,scrollHeight:r,documentClientHeight:c,documentClientWidth:b,marginTop:o,marginBottom:a,minHeight:P,maxPopupHeight:d,borderBottom:m,direction:R}=e,u=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:o,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),i=c-o-a,p=b,g=n.height,M=i-n.bottom+g,L=R==="rtl"?n.right-t.width:n.left,h=0,V=null;if(s&&l){L=t.left+(R==="rtl"?l.right-s.right:l.left-s.left);let U=l.top-n.top+l.height/2;h=s.top-t.top+s.height/2-U,V=s.top+s.height/2}let w=M+h+a+m,v=Math.min(i,w),ee=i-o-a,k=w-v,A=p-vt,ie=pe(L,vt,A-t.width),S=ge(r,v),F=k>=S-K;if(F&&(v=Math.min(i,t.height)-(k-S)),n.top<yt||n.bottom>i-yt||Math.ceil(v)+K<Math.min(r,P))return u();let B=Math.max(P,v),W=a+m-o,_=0,q=k;if(F){let U=Math.max(0,i-w);_=t.height>=ee?0:Math.max(0,U+W),q=S}else q=Math.max(0,k-W);let T=null;if(V!=null){let U=t.top,Z=t.height,f=Z>0?(V-U)/Z*100:50;T=`50% ${pe(f,0,100)}%`}let te=B===i||v>=d;return{fallback:!1,left:ie,isTopPositioned:F,top:_,height:v,scrollTop:q,marginTop:o,marginBottom:a,reachedMaxHeight:te,transformOrigin:T}}function Ht(e){let{isTopPositioned:n,currentHeight:t,scrollTop:l,maxScrollTop:s,maxAvailableHeight:r}=e,c=n?s-l:l;if(c<=K){let d=pe(c,0,r-t),m=t+d;return{height:d>0?m:null,scroll:{kind:"set",value:n?s:0},reachedMaxHeight:r-m<=K}}let b=Math.min(t+c,r),o={kind:"none"},a=!1;if(r-b>K)o=n?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!n&&l<s){let d=t+c-r;o={kind:"clamp",value:l-(c-d)}}let P=Math.ceil(b);return{height:P,scroll:o,reachedMaxHeight:a||P>=r-K}}var qe={slot:"bazzaui-select-positioner"};var Ye=C.forwardRef(function(n,t){let{alignItemWithTrigger:l=!0,side:s="bottom",align:r="start",sideOffset:c=0,className:b,style:o,children:a,...P}=n,d=_chunkW4ACKMIZcjs.d.call(void 0, ),m=O(),R=_directioncontext.useDirection.call(void 0, )==="rtl"?"rtl":"ltr",u=d.store,i=u.useState("open"),p=u.useState("openMethod"),g=u.useState("hasInput"),[M,L]=C.useState(l),h=M&&p!=="touch"&&!g,[V,w]=C.useState(!1),[v,ee]=C.useState(null),k=C.useRef(null),A=C.useRef(null),ie=C.useRef(null),S=C.useRef(!1),F=C.useRef(!1),J=C.useCallback(()=>{let f=k.current,x=u.context.refs.popupRef.current;f&&(f.style.height=""),x&&(x.style.height="",x.style.removeProperty("--transform-origin")),S.current=!1,F.current=!1},[u]),B=C.useCallback(()=>{J(),L(l),w(!1),ee(null)},[l,J]);C.useEffect(()=>m.registerResetPositioningCallback(B),[m,B]);let W=C.useCallback(()=>{if(u.state.hasInput)return;let f=k.current,x=m.triggerRef.current,D=u.context.refs.popupRef.current,Y=u.context.refs.listRef.current;if(!f||!x||!D||!Y)return;let oe=m.selectedItemTextRef.current;if(!_optionalChain([oe, 'optionalAccess', _10 => _10.isConnected])){let N=m.firstItemTextRef.current;oe=_optionalChain([N, 'optionalAccess', _11 => _11.isConnected])?N:null}let se=m.valueRef.current,he=Io(D),H;try{let N=Ue(f),ne=f.ownerDocument,re=We(x),Q=N.getComputedStyle(f),me=N.getComputedStyle(D);H=wt({triggerRect:ve(x.getBoundingClientRect(),re),positionerRect:ve(f.getBoundingClientRect(),re),valueRect:se?ve(se.getBoundingClientRect(),re):null,textRect:oe?ve(oe.getBoundingClientRect(),re):null,scrollHeight:Y.scrollHeight,documentClientHeight:ne.documentElement.clientHeight,documentClientWidth:ne.documentElement.clientWidth,marginTop:Number.parseFloat(Q.marginTop)||_e,marginBottom:Number.parseFloat(Q.marginBottom)||_e,minHeight:Number.parseFloat(Q.minHeight)||Et,maxPopupHeight:Lt(me),borderBottom:Number.parseFloat(me.borderBottomWidth)||0,direction:R});let xe=(_nullishCoalesce(_optionalChain([N, 'access', _12 => _12.visualViewport, 'optionalAccess', _13 => _13.scale]), () => (1)))!==1&&Ro(N);if(H.fallback||xe){L(!1),w(!0);return}f.style.height=`${H.height}px`,D.style.height="100%",H.transformOrigin&&D.style.setProperty("--transform-origin",H.transformOrigin),Y.scrollTop=H.scrollTop,S.current=H.reachedMaxHeight,F.current=!0}finally{he()}ee({left:H.left,top:H.isTopPositioned?H.top:null,bottom:H.isTopPositioned?null:0,marginTop:H.marginTop,marginBottom:H.marginBottom}),w(!0)},[u,m,R]);C.useEffect(()=>{!i||!h||V||W()},[i,h,V,W]),C.useEffect(()=>{i&&!h&&J()},[i,h,J]),C.useEffect(()=>{if(!i||!h)return;let f=k.current,x=f?Ue(f):window,D=Y=>{u.setOpen(!1,_chunkXMZZ62VJcjs.a.none,Y)};return x.addEventListener("resize",D),()=>{x.removeEventListener("resize",D)}},[i,h,u]);let _=C.useCallback(f=>{let x=k.current,D=u.context.refs.popupRef.current;if(!x||!D||!F.current||S.current||!h)return;let Y=x.style.top==="0px",oe=x.style.bottom==="0px";if(!Y&&!oe)return;let se=Ue(x),he=x.ownerDocument,H=We(x),N=Vt(x.getBoundingClientRect().height,"y",H),ne=se.getComputedStyle(x),re=Number.parseFloat(ne.marginTop)||0,Q=Number.parseFloat(ne.marginBottom)||0,me=Lt(se.getComputedStyle(D)),xe=Math.min(he.documentElement.clientHeight-re-Q,me),le=Ht({isTopPositioned:Y,currentHeight:N,scrollTop:f.scrollTop,maxScrollTop:ge(f.scrollHeight,f.clientHeight),maxAvailableHeight:xe});switch(le.height!=null&&(x.style.height=`${le.height}px`),le.scroll.kind){case"set":f.scrollTop=le.scroll.value;break;case"max":{let X=ge(f.scrollHeight,f.clientHeight);Math.abs(f.scrollTop-X)>K&&(f.scrollTop=X);break}case"clamp":{let X=ge(f.scrollHeight,f.clientHeight),be=pe(le.scroll.value,0,X);Math.abs(f.scrollTop-be)>K&&(f.scrollTop=be);break}default:break}le.reachedMaxHeight&&(S.current=!0)},[u,h]);C.useEffect(()=>{if(!i||!h||!V)return;let f=u.context.refs.listRef.current;if(!f)return;let x=()=>_(f);return f.addEventListener("scroll",x,{passive:!0}),()=>{f.removeEventListener("scroll",x)}},[i,h,V,_,u]);let q=h?"none":s,T=C.useMemo(()=>({alignItemWithTriggerActive:h,side:q,align:r,scrollUpArrowRef:A,scrollDownArrowRef:ie,setAlignItemWithTriggerActive:L,resetPositioningState:B}),[h,q,r,B]),te=C.useCallback(f=>{k.current=f,typeof t=="function"?t(f):t&&(t.current=f)},[t]),U=i&&h&&!V,Z=h&&v?{position:"fixed",transform:"none",left:v.left,top:_nullishCoalesce(v.top, () => ("auto")),bottom:_nullishCoalesce(v.bottom, () => ("auto")),marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return _jsxruntime.jsx.call(void 0, Be.Provider,{value:T,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:te,side:h?void 0:s,align:h?void 0:r,sideOffset:h?0:c,disableAnchorTracking:h||void 0,className:b,style:{...o,...Z,...U?{visibility:"hidden"}:{}},...h?{"data-side":"none","data-align":r}:{},[qe.slot]:"",...P,children:a})})});function Ue(e){return _nullishCoalesce(_optionalChain([e, 'access', _14 => _14.ownerDocument, 'optionalAccess', _15 => _15.defaultView]), () => (window))}function Lt(e){let n=e.maxHeight||"";return n.endsWith("px")&&Number.parseFloat(n)||Number.POSITIVE_INFINITY}function Ro(e){let n=e.navigator;return n?/AppleWebKit/.test(n.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(n.userAgent):!1}var kt=[["transform","none"],["scale","1"],["translate","0 0"]];function Io(e){let{style:n}=e,t={};for(let[l,s]of kt)t[l]=n.getPropertyValue(l),n.setProperty(l,s,"important");return()=>{for(let[l]of kt){let s=t[l];s?n.setProperty(l,s):n.removeProperty(l)}}}function Xe(e){let{open:n,onOpenChange:t,onOpenChangeComplete:l,actionsRef:s,defaultOpen:r=!1,value:c,defaultValue:b,onValueChange:o,multiple:a=!1,values:P,defaultValues:d,onValuesChange:m,isItemEqualToValue:R=_chunk5T5B5SPRcjs.a,itemToStringLabel:u,itemToStringValue:i,name:p,form:g,required:M,disabled:L=!1,placeholder:h="Select...",items:V,modal:w=!0,closeOnOutsidePress:v="pointerdown",virtualized:ee=!1,virtualItems:k,onHighlightChange:A,debug:ie,children:S,...F}=e,J=I.useCallback((y,ue,Ee,Qt)=>_optionalChain([A, 'optionalCall', _16 => _16(y,Ee,Qt)]),[A]),B=I.useId(),W=I.useRef(null),_=I.useRef(null),q=I.useRef(null),T=I.useRef(null),te=I.useCallback(y=>{W.current=y},[]),U=I.useCallback(y=>{_.current=y},[]),Z=I.useRef(null),f=I.useCallback(y=>(Z.current=y,()=>{Z.current=null}),[]),{store:x,focusOwnerStore:D,openChainStore:Y,registerSurface:oe,closeAll:se,virtualization:he,handleOpenChange:H,disabled:N,setDisabled:ne,menuTreeResolver:re}=_chunkW4ACKMIZcjs.q.call(void 0, {onOpenChange:t,defaultOpen:r,virtualized:ee,items:k,onHighlightChange:J,closeOnOutsidePress:v,disabled:L}),Q=I.useRef(null);I.useImperativeHandle(s,()=>({close:()=>{_optionalChain([Q, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.close, 'call', _19 => _19()])},unmount:()=>{_optionalChain([Q, 'access', _20 => _20.current, 'optionalAccess', _21 => _21.unmount, 'call', _22 => _22()])},setDisabled:ne}),[ne]),x.useControlledProp("openProp",n);let me=x.useState("open"),[xe,le]=I.useState(b!==void 0?b:null),X=c!==void 0?c:xe,be=I.useCallback(y=>{c===void 0&&le(y),_optionalChain([o, 'optionalCall', _23 => _23(y)])},[c,o]),[Yt,Xt]=I.useState(_nullishCoalesce(d, () => ([]))),Pe=P!==void 0?P:Yt,Ze=I.useCallback(y=>{P===void 0&&Xt(y),_optionalChain([m, 'optionalCall', _24 => _24(y)])},[P,m]),Qe=I.useRef(new Map),et=I.useCallback((y,ue)=>(Qe.current.set(y,ue),()=>{}),[]),$t=I.useMemo(()=>({multiple:a,value:X,values:Pe,onValueChange:be,onValuesChange:Ze,isItemEqualToValue:R,itemToStringLabel:u,itemToStringValue:i,name:p,form:g,required:M,disabled:N,placeholder:h,items:V,itemTextRegistry:Qe.current,registerItemText:et,listId:B,triggerRef:W,valueRef:_,selectedItemTextRef:q,firstItemTextRef:T,setTriggerElement:te,setValueElement:U,registerResetPositioningCallback:f}),[a,X,Pe,be,Ze,R,u,i,p,g,M,N,h,V,et,B,te,U,f]),Kt=I.useMemo(()=>p?a?Pe.length>0?Pe.map((y,ue)=>{let Ee=_chunkW4ACKMIZcjs.S.call(void 0, y,i);return _jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:p,value:Ee,form:g,required:M&&ue===0},Ee)}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:p,value:"",form:g,required:M}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:p,value:X!=null?_chunkW4ACKMIZcjs.S.call(void 0, X,i):"",form:g,required:M}):null,[p,g,M,a,X,Pe,i]),Jt=I.useCallback((y,ue)=>{H(y,ue.reason,ue.event)},[H]),Zt=I.useCallback(y=>{!y&&x.context.clearSearchOnClose==="after-exit"&&(x.clearSearch(),x.setInputActive(!1)),y||(x.clearHighlight(),_optionalChain([Z, 'access', _25 => _25.current, 'optionalCall', _26 => _26()]),T.current=null),_optionalChain([l, 'optionalCall', _27 => _27(y)])},[x,l]);return _jsxruntime.jsx.call(void 0, Le.Provider,{value:$t,children:_jsxruntime.jsxs.call(void 0, _chunkW4ACKMIZcjs.N,{menuTreeResolver:re,store:x,focusOwnerStore:D,openChainStore:Y,disabled:N,depth:0,closeAll:se,registerSurface:oe,virtualization:he,menuType:"dropdown",closeOnOutsidePress:v,componentName:"select",debug:ie,children:[Kt,_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...F,open:me,onOpenChange:Jt,onOpenChangeComplete:Zt,modal:w,actionsRef:s?Q:void 0,children:S})]})})}var Ot={slot:"bazzaui-select-surface"};var $e=De.forwardRef(function(n,t){let{autoHighlightFirst:l,...s}=n,r=O(),c=Ve(),b=De.useMemo(()=>{let o=a=>_chunkW4ACKMIZcjs.Q.call(void 0, a)?!0:_chunkW4ACKMIZcjs.S.call(void 0, a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return o(a)}if(l!==void 0)return l;if(_optionalChain([c, 'optionalAccess', _28 => _28.alignItemWithTriggerActive])){let a=r.multiple?r.values[0]:r.value;return o(a)}return!0},[l,_optionalChain([c, 'optionalAccess', _29 => _29.alignItemWithTriggerActive]),r.multiple,r.value,r.values,r.itemToStringValue]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.fa,{ref:t,autoHighlightFirst:b,[Ot.slot]:"",...s})});var Se={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};var yo={open:e=>e?{[Se.open]:""}:null,disabled:e=>e?{[Se.disabled]:""}:null,placeholder:e=>e?{[Se.placeholder]:""}:null},Eo=G.forwardRef(function(n,t){let{render:l,children:s,disabled:r,className:c,style:b,triggerProps:o,triggerState:a,...P}=n,d=O(),m=_nullishCoalesce(r, () => (d.disabled)),R=d.multiple?d.values.length>0:!_chunkW4ACKMIZcjs.Q.call(void 0, d.value),u=G.useMemo(()=>({open:a.open,disabled:m,placeholder:!R}),[a.open,m,R]),i=G.useCallback(p=>{d.setTriggerElement(p)},[d]);return _userender.useRender.call(void 0, {render:l,ref:t,state:u,stateAttributesMapping:yo,props:{..._chunkSCDHQZFIcjs.a.call(void 0, o,{...P,className:c,style:b,children:s}),[Se.slot]:"",ref:i,role:"combobox","aria-haspopup":"listbox","aria-controls":d.listId},defaultTagName:"button"})}),Ke= exports.SelectTrigger =G.forwardRef(function(n,t){let{disabled:l,...s}=n,r=O(),c=_chunkW4ACKMIZcjs.d.call(void 0, ),{store:b,closeAll:o,closeOnOutsidePress:a}=c,P=(_nullishCoalesce(l, () => (r.disabled)))||c.disabled,d=b.useState("open"),m=G.useRef(null),R=G.useCallback(u=>{m.current=u,typeof t=="function"?t(u):t&&(t.current=u)},[t]);return G.useEffect(()=>{let u=m.current;if(!u||a!=="pointerdown")return;let i=p=>{d&&(o(_chunkXMZZ62VJcjs.a.triggerPress,p),u.addEventListener("click",g=>{g.stopPropagation(),g.preventDefault()},{once:!0,capture:!0}))};return u.addEventListener("pointerdown",i,!0),()=>{u.removeEventListener("pointerdown",i,!0)}},[d,o,a]),_jsxruntime.jsx.call(void 0, _popover.Popover.Trigger,{ref:R,disabled:P,render:(u,i)=>_jsxruntime.jsx.call(void 0, Eo,{...s,disabled:P,triggerProps:u,triggerState:i,ref:u.ref})})});var Ne={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var Ho={hasValue:e=>e?null:{[Ne.placeholder]:""},multiple:e=>e?{[Ne.multiple]:""}:null,getValueText:()=>null};function Lo(e,n){let{render:t,className:l,style:s,placeholder:r,children:c,...b}=e,o=O(),a=_nullishCoalesce(r, () => (o.placeholder)),P=ae.useMemo(()=>_chunk5T5B5SPRcjs.f.call(void 0, o.items,""),[o.items]),d=_nullishCoalesce(_nullishCoalesce(r, () => (P)), () => (a)),m=o.multiple?o.values.length>0:!_chunkW4ACKMIZcjs.Q.call(void 0, o.value),R=ae.useCallback(g=>{let M=_chunkW4ACKMIZcjs.S.call(void 0, g,o.itemToStringValue),L=o.itemTextRegistry.get(M);if(L!==void 0)return L;let h=_chunk5T5B5SPRcjs.f.call(void 0, o.items,M);if(h!==void 0)return h;let V=_chunkW4ACKMIZcjs.R.call(void 0, g,o.itemToStringLabel);if(V&&V!==M)return V},[o.itemTextRegistry,o.items,o.itemToStringLabel,o.itemToStringValue]),u=ae.useMemo(()=>({value:o.value,values:o.values,multiple:o.multiple,hasValue:m,placeholder:a,getValueText:R}),[o.value,o.values,o.multiple,m,a,R]),i;if(typeof c=="function")i=c(u);else if(c!==void 0)i=c;else if(!m)i=d;else if(o.multiple){let g=o.values.map(M=>{let L=R(M);return L!==void 0?L:_chunkW4ACKMIZcjs.R.call(void 0, M,o.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, M,o.itemToStringValue)}).filter(Boolean);i=g.length>2?`${g.length} selected`:g.join(", ")}else{let g=o.value;if(g!=null){let M=R(g);M!==void 0?i=M:i=_chunkW4ACKMIZcjs.R.call(void 0, g,o.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, g,o.itemToStringValue)}}let p=ae.useCallback(g=>{o.setValueElement(g)},[o]);return _userender.useRender.call(void 0, {render:t,ref:n,state:u,stateAttributesMapping:Ho,props:{...b,[Ne.slot]:"",ref:p,className:l,style:s,children:i},defaultTagName:"span"})}var Je=ae.forwardRef(Lo);var zt=(c=>(c.slot="bazzaui-select-arrow",c.open="data-open",c.closed="data-closed",c.side="data-side",c.align="data-align",c.uncentered="data-uncentered",c))(zt||{});var Gt=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Gt||{});var Ft=(n=>(n.slot="bazzaui-select-empty",n))(Ft||{});var Bt=(n=>(n.slot="bazzaui-select-group",n))(Bt||{});var jt=(n=>(n.slot="bazzaui-select-group-label",n))(jt||{});var ko={slot:"bazzaui-select-icon",open:"data-popup-open"};var Wt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(Wt||{});var _t=(t=>(t.slot="bazzaui-select-list",t.list="data-popup-menu-list",t))(_t||{});var qt=(n=>(n.alignItemWithTrigger="data-align-item-with-trigger",n))(qt||{});var Ao={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Ut=(n=>(n.slot="bazzaui-select-separator",n))(Ut||{});exports.Select = Nt; exports.SelectArrowDataAttributes = zt; exports.SelectBackdropDataAttributes = Gt; exports.SelectEmptyDataAttributes = Ft; exports.SelectGroupDataAttributes = Bt; exports.SelectGroupLabelDataAttributes = jt; exports.SelectIconDataAttributes = ko; exports.SelectInputDataAttributes = Wt; exports.SelectItem = ze; exports.SelectItemDataAttributes = $; exports.SelectItemIndicator = Ge; exports.SelectItemIndicatorDataAttributes = Me; exports.SelectItemLabel = Fe; exports.SelectListCssVars = _chunkW4ACKMIZcjs.aa; exports.SelectListDataAttributes = _t; exports.SelectPopup = je; exports.SelectPopupDataAttributes = qt; exports.SelectPositioner = Ye; exports.SelectPositionerCssVars = _chunkW4ACKMIZcjs.L; exports.SelectPositionerDataAttributes = qe; exports.SelectRoot = Xe; exports.SelectScrollArrowDataAttributes = Ao; exports.SelectSeparatorDataAttributes = Ut; exports.SelectStore = _chunkXMZZ62VJcjs.y; exports.SelectSurface = $e; exports.SelectTrigger = Ke; exports.SelectTriggerDataAttributes = Se; exports.SelectValue = Je; exports.commandScore = _chunkXMZZ62VJcjs.w; exports.defaultFilter = _chunkXMZZ62VJcjs.x; exports.useMaybeSelectContext = so; exports.useMaybeSelectItemContext = uo; exports.useMaybeSurfaceContext = _chunkXMZZ62VJcjs.q; exports.useSelectContext = O; exports.useSelectItemContext = Te; exports.useSelectPositionerContext = Ve; exports.useSurfaceContext = _chunkXMZZ62VJcjs.p;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkSCDHQZFIcjs = require('../chunk-SCDHQZFI.cjs');var _chunk5T5B5SPRcjs = require('../chunk-5T5B5SPR.cjs');var _chunkW4ACKMIZcjs = require('../chunk-W4ACKMIZ.cjs');var _chunkXMZZ62VJcjs = require('../chunk-XMZZ62VJ.cjs');var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var Nt={};_chunkM4G6J7DPcjs.a.call(void 0, Nt,{Arrow:()=>_chunkW4ACKMIZcjs.s,Backdrop:()=>_chunkW4ACKMIZcjs.t,Empty:()=>_chunkW4ACKMIZcjs.U,Group:()=>_chunkW4ACKMIZcjs.pa,GroupLabel:()=>_chunkW4ACKMIZcjs.W,Icon:()=>_chunkW4ACKMIZcjs.T,Input:()=>_chunkW4ACKMIZcjs.V,Item:()=>ze,ItemIndicator:()=>Ge,ItemLabel:()=>Fe,List:()=>_chunkW4ACKMIZcjs.ba,Popup:()=>je,Portal:()=>_chunkW4ACKMIZcjs.K,Positioner:()=>Ye,Root:()=>Xe,ScrollDownArrow:()=>_chunkW4ACKMIZcjs.ea,ScrollUpArrow:()=>_chunkW4ACKMIZcjs.da,Separator:()=>_chunkW4ACKMIZcjs.sa,Surface:()=>$e,Trigger:()=>Ke,Value:()=>Je});var _userender = require('@base-ui/react/use-render');var _react = require('react'); var E = _interopRequireWildcard(_react); var Ie = _interopRequireWildcard(_react); var Ce = _interopRequireWildcard(_react); var Ae = _interopRequireWildcard(_react); var j = _interopRequireWildcard(_react); var ce = _interopRequireWildcard(_react); var Oe = _interopRequireWildcard(_react); var T = _interopRequireWildcard(_react); var I = _interopRequireWildcard(_react); var De = _interopRequireWildcard(_react); var G = _interopRequireWildcard(_react); var ae = _interopRequireWildcard(_react);var Le=Ie.createContext(null);function O(){let e=Ie.useContext(Le);if(!e)throw new Error("Select components must be used within a Select.Root");return e}function so(){return Ie.useContext(Le)}var $={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected",first:"data-first",last:"data-last",firstInGroup:"data-first-in-group",lastInGroup:"data-last-in-group"};var ke=Ce.createContext(null);function Te(){let e=Ce.useContext(ke);if(!e)throw new Error("Select.Item child components must be used within a Select.Item");return e}function uo(){return Ce.useContext(ke)}var _jsxruntime = require('react/jsx-runtime');var po={highlighted:e=>e?{[$.highlighted]:""}:null,disabled:e=>e?{[$.disabled]:""}:null,selected:e=>e?{[$.selected]:""}:null,first:e=>e?{[$.first]:""}:null,last:e=>e?{[$.last]:""}:null,firstInGroup:e=>e?{[$.firstInGroup]:""}:null,lastInGroup:e=>e?{[$.lastInGroup]:""}:null};function mo(e,o){let{value:t,textValue:l,keywords:i,disabled:r=!1,onSelect:c,forceMount:b=!1,render:n,className:a,style:C,onClick:d,onPointerDown:m,onPointerMove:P,children:g,...s}=e,p=O(),u=E.useMemo(()=>_chunkW4ACKMIZcjs.S.call(void 0, t,p.itemToStringValue),[t,p.itemToStringValue]),R=E.useId(),w=t===null?`select-clear-${R}`:void 0,S=E.useMemo(()=>_chunk5T5B5SPRcjs.e.call(void 0, p.items,u),[p.items,u]),V=_optionalChain([S, 'optionalAccess', _2 => _2.label]),H=E.useMemo(()=>_chunkW4ACKMIZcjs.R.call(void 0, t,p.itemToStringLabel),[t,p.itemToStringLabel]),v=E.useMemo(()=>{if(l!==void 0)return l;if(typeof V=="string")return V;if(H&&H!==u)return H},[l,V,H,u]),ee=E.useMemo(()=>_chunk5T5B5SPRcjs.g.call(void 0, i,[typeof V=="string"?V:H&&H!==u?H:void 0,..._nullishCoalesce(_optionalChain([S, 'optionalAccess', _3 => _3.keywords]), () => ([]))]),[i,V,H,u,S]),k=E.useRef(v),A=p.multiple?_chunk5T5B5SPRcjs.c.call(void 0, p.values,t,p.isItemEqualToValue):p.value!==""&&_chunk5T5B5SPRcjs.b.call(void 0, p.value,t,p.isItemEqualToValue),ie=!p.multiple,h=_chunkW4ACKMIZcjs.O.call(void 0, {id:w,value:u,keywords:ee,disabled:r,forceMount:b,closeOnClick:ie,children:g});E.useEffect(()=>{let M=()=>{if(!r){if(p.multiple)if(t==null)p.onValuesChange([]);else{let te=A?_chunk5T5B5SPRcjs.d.call(void 0, p.values,t,p.isItemEqualToValue):[...p.values,t];p.onValuesChange(te)}else p.onValueChange(t);_optionalChain([c, 'optionalCall', _4 => _4()])}};return h.registerSelect(M)},[r,p,t,A,c,h]),E.useEffect(()=>{let M=k.current;if(M)return p.registerItemText(u,M)},[u,p]),E.useEffect(()=>{!v&&typeof g=="string"&&(k.current=g,p.registerItemText(u,g))},[g,v,u,p]);let F=E.useMemo(()=>({highlighted:h.isHighlighted,disabled:r,selected:A,first:h.positional.first,last:h.positional.last,firstInGroup:h.positional.firstInGroup,lastInGroup:h.positional.lastInGroup}),[h.isHighlighted,r,A,h.positional]),J=E.useMemo(()=>({id:h.id,value:t,textValue:v,highlighted:h.isHighlighted,disabled:r,selected:A}),[h.id,t,v,h.isHighlighted,r,A]),B=E.useCallback(M=>{_optionalChain([d, 'optionalCall', _5 => _5(M)]),M.defaultPrevented||h.handlers.onClick(M)},[d,h.handlers]),W=E.useCallback(M=>{h.handlers.onPointerDown(M),_optionalChain([m, 'optionalCall', _6 => _6(M)])},[h.handlers,m]),_=E.useCallback(M=>{_optionalChain([P, 'optionalCall', _7 => _7(M)]),M.defaultPrevented||h.handlers.onPointerMove(M)},[P,h.handlers]),q=_userender.useRender.call(void 0, {render:n,ref:[h.ref,h.rowRef,o],state:F,stateAttributesMapping:po,props:{...s,[$.slot]:"",id:h.id,role:"option",tabIndex:-1,"aria-selected":A,"aria-disabled":r||void 0,className:a,style:C,onClick:B,onPointerMove:_,onPointerDown:W,children:g},enabled:h.isVisible,defaultTagName:"div"});return h.isVisible?_jsxruntime.jsx.call(void 0, ke.Provider,{value:J,children:q}):null}var ze=E.forwardRef(mo);var Me={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var So={selected:e=>e?{[Me.selected]:""}:null,highlighted:e=>e?{[Me.highlighted]:""}:null},Ge= exports.SelectItemIndicator =Ae.forwardRef(function(o,t){let{render:l,className:i,style:r,forceMount:c=!1,keepMounted:b=!1,children:n,...a}=o,C=Te(),d=C.selected,m=C.highlighted,P=Ae.useMemo(()=>({selected:d,highlighted:m}),[d,m]),g=c||b||d,s=typeof n=="function"?n(P):b&&!d?null:n,p=_userender.useRender.call(void 0, {render:l,ref:t,state:P,stateAttributesMapping:So,props:{...a,[Me.slot]:"","aria-hidden":!0,className:i,style:r,children:s},defaultTagName:"span"});return g?p:null});var Mt={slot:"bazzaui-select-item-label"};var Fe=j.forwardRef(function(o,t){let{render:l,className:i,style:r,children:c,...b}=o,n=O(),a=Te(),C=j.useRef(null),d=_chunkW4ACKMIZcjs.S.call(void 0, a.value,n.itemToStringValue),m=j.useMemo(()=>{if(c!==void 0)return c;let s=_chunk5T5B5SPRcjs.f.call(void 0, n.items,d);return s!==void 0?s:a.textValue!==void 0?a.textValue:d},[c,n.items,d,a.textValue]),P=j.useMemo(()=>({value:d,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[d,a.selected,a.highlighted,a.disabled]);j.useEffect(()=>{if(typeof m=="string")return n.registerItemText(d,m)},[m,n,d]);let g=j.useCallback(s=>{C.current=s,a.selected&&s&&(n.selectedItemTextRef.current=s),s&&!a.disabled&&(n.firstItemTextRef.current||(n.firstItemTextRef.current=s))},[a.selected,a.disabled,n]);return _userender.useRender.call(void 0, {render:l,ref:t,state:P,props:{...b,[Mt.slot]:"",ref:g,className:i,style:r,children:m},defaultTagName:"span"})});var Be=Oe.createContext(null);function Ve(){return Oe.useContext(Be)}var je=ce.forwardRef(function(o,t){let{className:l,render:i,...r}=o,c=Ve(),b=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _8 => _8.alignItemWithTriggerActive]), () => (!1)),n=_optionalChain([c, 'optionalAccess', _9 => _9.align]),a=ce.useCallback(m=>({...m,side:b?"none":m.side,alignItemWithTriggerActive:b}),[b]),C=ce.useMemo(()=>typeof l=="function"?m=>l(a(m)):l,[l,a]),d=ce.useMemo(()=>typeof i=="function"?(m,P)=>i(m,a(P)):i,[i,a]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.J,{ref:t,className:C,render:d,"data-align-item-with-trigger":b?"":void 0,...b?{"data-side":"none","data-align":n}:{},...r})});var _directioncontext = require('@base-ui/react/internals/direction-context');var _popover = require('@base-ui/react/popover');function pe(e,o,t){return e<o?o:e>t?t:e}function We(e){let o=e.getBoundingClientRect(),{offsetWidth:t,offsetHeight:l}=e,i=t>0?Math.round(o.width)/t:1,r=l>0?Math.round(o.height)/l:1;return(!Number.isFinite(i)||i===0)&&(i=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:i,y:r}}function Vt(e,o,t){return e/t[o]}function ve(e,o){let t=e.x/o.x,l=e.y/o.y,i=e.width/o.x,r=e.height/o.y;return{x:t,y:l,width:i,height:r,top:l,left:t,right:t+i,bottom:l+r}}var K=1;function ge(e,o){return Math.max(0,e-o)}var vt=5,yt=20,_e=10,Et=100;function wt(e){let{triggerRect:o,positionerRect:t,valueRect:l,textRect:i,scrollHeight:r,documentClientHeight:c,documentClientWidth:b,marginTop:n,marginBottom:a,minHeight:C,maxPopupHeight:d,borderBottom:m,direction:P}=e,g=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:n,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),s=c-n-a,p=b,u=o.height,R=s-o.bottom+u,w=P==="rtl"?o.right-t.width:o.left,S=0,V=null;if(i&&l){w=t.left+(P==="rtl"?l.right-i.right:l.left-i.left);let U=l.top-o.top+l.height/2;S=i.top-t.top+i.height/2-U,V=i.top+i.height/2}let H=R+S+a+m,v=Math.min(s,H),ee=s-n-a,k=H-v,A=p-vt,ie=pe(w,vt,A-t.width),h=ge(r,v),F=k>=h-K;if(F&&(v=Math.min(s,t.height)-(k-h)),o.top<yt||o.bottom>s-yt||Math.ceil(v)+K<Math.min(r,C))return g();let B=Math.max(C,v),W=a+m-n,_=0,q=k;if(F){let U=Math.max(0,s-H);_=t.height>=ee?0:Math.max(0,U+W),q=h}else q=Math.max(0,k-W);let M=null;if(V!=null){let U=t.top,Z=t.height,f=Z>0?(V-U)/Z*100:50;M=`50% ${pe(f,0,100)}%`}let te=B===s||v>=d;return{fallback:!1,left:ie,isTopPositioned:F,top:_,height:v,scrollTop:q,marginTop:n,marginBottom:a,reachedMaxHeight:te,transformOrigin:M}}function Ht(e){let{isTopPositioned:o,currentHeight:t,scrollTop:l,maxScrollTop:i,maxAvailableHeight:r}=e,c=o?i-l:l;if(c<=K){let d=pe(c,0,r-t),m=t+d;return{height:d>0?m:null,scroll:{kind:"set",value:o?i:0},reachedMaxHeight:r-m<=K}}let b=Math.min(t+c,r),n={kind:"none"},a=!1;if(r-b>K)n=o?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!o&&l<i){let d=t+c-r;n={kind:"clamp",value:l-(c-d)}}let C=Math.ceil(b);return{height:C,scroll:n,reachedMaxHeight:a||C>=r-K}}var qe={slot:"bazzaui-select-positioner"};var Ye=T.forwardRef(function(o,t){let{alignItemWithTrigger:l=!0,side:i="bottom",align:r="start",sideOffset:c=0,className:b,style:n,children:a,...C}=o,d=_chunkW4ACKMIZcjs.d.call(void 0, ),m=O(),P=_directioncontext.useDirection.call(void 0, )==="rtl"?"rtl":"ltr",g=d.store,s=g.useState("open"),p=g.useState("openMethod"),u=g.useState("hasInput"),[R,w]=T.useState(l),S=R&&p!=="touch"&&!u,[V,H]=T.useState(!1),[v,ee]=T.useState(null),k=T.useRef(null),A=T.useRef(null),ie=T.useRef(null),h=T.useRef(!1),F=T.useRef(!1),J=T.useCallback(()=>{let f=k.current,x=g.context.refs.popupRef.current;f&&(f.style.height=""),x&&(x.style.height="",x.style.removeProperty("--transform-origin")),h.current=!1,F.current=!1},[g]),B=T.useCallback(()=>{J(),w(l),H(!1),ee(null)},[l,J]);T.useEffect(()=>m.registerResetPositioningCallback(B),[m,B]);let W=T.useCallback(()=>{if(g.state.hasInput)return;let f=k.current,x=m.triggerRef.current,D=g.context.refs.popupRef.current,Y=g.context.refs.listRef.current;if(!f||!x||!D||!Y)return;let oe=m.selectedItemTextRef.current;if(!_optionalChain([oe, 'optionalAccess', _10 => _10.isConnected])){let N=m.firstItemTextRef.current;oe=_optionalChain([N, 'optionalAccess', _11 => _11.isConnected])?N:null}let se=m.valueRef.current,he=Io(D),L;try{let N=Ue(f),ne=f.ownerDocument,re=We(x),Q=N.getComputedStyle(f),me=N.getComputedStyle(D);L=wt({triggerRect:ve(x.getBoundingClientRect(),re),positionerRect:ve(f.getBoundingClientRect(),re),valueRect:se?ve(se.getBoundingClientRect(),re):null,textRect:oe?ve(oe.getBoundingClientRect(),re):null,scrollHeight:Y.scrollHeight,documentClientHeight:ne.documentElement.clientHeight,documentClientWidth:ne.documentElement.clientWidth,marginTop:Number.parseFloat(Q.marginTop)||_e,marginBottom:Number.parseFloat(Q.marginBottom)||_e,minHeight:Number.parseFloat(Q.minHeight)||Et,maxPopupHeight:Lt(me),borderBottom:Number.parseFloat(me.borderBottomWidth)||0,direction:P});let xe=(_nullishCoalesce(_optionalChain([N, 'access', _12 => _12.visualViewport, 'optionalAccess', _13 => _13.scale]), () => (1)))!==1&&Ro(N);if(L.fallback||xe){w(!1),H(!0);return}f.style.height=`${L.height}px`,D.style.height="100%",L.transformOrigin&&D.style.setProperty("--transform-origin",L.transformOrigin),Y.scrollTop=L.scrollTop,h.current=L.reachedMaxHeight,F.current=!0}finally{he()}ee({left:L.left,top:L.isTopPositioned?L.top:null,bottom:L.isTopPositioned?null:0,marginTop:L.marginTop,marginBottom:L.marginBottom}),H(!0)},[g,m,P]);T.useEffect(()=>{!s||!S||V||W()},[s,S,V,W]),T.useEffect(()=>{s&&!S&&J()},[s,S,J]),T.useEffect(()=>{if(!s||!S)return;let f=k.current,x=f?Ue(f):window,D=Y=>{g.setOpen(!1,_chunkXMZZ62VJcjs.a.none,Y)};return x.addEventListener("resize",D),()=>{x.removeEventListener("resize",D)}},[s,S,g]);let _=T.useCallback(f=>{let x=k.current,D=g.context.refs.popupRef.current;if(!x||!D||!F.current||h.current||!S)return;let Y=x.style.top==="0px",oe=x.style.bottom==="0px";if(!Y&&!oe)return;let se=Ue(x),he=x.ownerDocument,L=We(x),N=Vt(x.getBoundingClientRect().height,"y",L),ne=se.getComputedStyle(x),re=Number.parseFloat(ne.marginTop)||0,Q=Number.parseFloat(ne.marginBottom)||0,me=Lt(se.getComputedStyle(D)),xe=Math.min(he.documentElement.clientHeight-re-Q,me),le=Ht({isTopPositioned:Y,currentHeight:N,scrollTop:f.scrollTop,maxScrollTop:ge(f.scrollHeight,f.clientHeight),maxAvailableHeight:xe});switch(le.height!=null&&(x.style.height=`${le.height}px`),le.scroll.kind){case"set":f.scrollTop=le.scroll.value;break;case"max":{let X=ge(f.scrollHeight,f.clientHeight);Math.abs(f.scrollTop-X)>K&&(f.scrollTop=X);break}case"clamp":{let X=ge(f.scrollHeight,f.clientHeight),be=pe(le.scroll.value,0,X);Math.abs(f.scrollTop-be)>K&&(f.scrollTop=be);break}default:break}le.reachedMaxHeight&&(h.current=!0)},[g,S]);T.useEffect(()=>{if(!s||!S||!V)return;let f=g.context.refs.listRef.current;if(!f)return;let x=()=>_(f);return f.addEventListener("scroll",x,{passive:!0}),()=>{f.removeEventListener("scroll",x)}},[s,S,V,_,g]);let q=S?"none":i,M=T.useMemo(()=>({alignItemWithTriggerActive:S,side:q,align:r,scrollUpArrowRef:A,scrollDownArrowRef:ie,setAlignItemWithTriggerActive:w,resetPositioningState:B}),[S,q,r,B]),te=T.useCallback(f=>{k.current=f,typeof t=="function"?t(f):t&&(t.current=f)},[t]),U=s&&S&&!V,Z=S&&v?{position:"fixed",transform:"none",left:v.left,top:_nullishCoalesce(v.top, () => ("auto")),bottom:_nullishCoalesce(v.bottom, () => ("auto")),marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return _jsxruntime.jsx.call(void 0, Be.Provider,{value:M,children:_jsxruntime.jsx.call(void 0, _popover.Popover.Positioner,{ref:te,side:S?void 0:i,align:S?void 0:r,sideOffset:S?0:c,disableAnchorTracking:S||void 0,className:b,style:{...n,...Z,...U?{visibility:"hidden"}:{}},...S?{"data-side":"none","data-align":r}:{},[qe.slot]:"",...C,children:a})})});function Ue(e){return _nullishCoalesce(_optionalChain([e, 'access', _14 => _14.ownerDocument, 'optionalAccess', _15 => _15.defaultView]), () => (window))}function Lt(e){let o=e.maxHeight||"";return o.endsWith("px")&&Number.parseFloat(o)||Number.POSITIVE_INFINITY}function Ro(e){let o=e.navigator;return o?/AppleWebKit/.test(o.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(o.userAgent):!1}var kt=[["transform","none"],["scale","1"],["translate","0 0"]];function Io(e){let{style:o}=e,t={};for(let[l,i]of kt)t[l]=o.getPropertyValue(l),o.setProperty(l,i,"important");return()=>{for(let[l]of kt){let i=t[l];i?o.setProperty(l,i):o.removeProperty(l)}}}function Xe(e){let{open:o,onOpenChange:t,onOpenChangeComplete:l,actionsRef:i,defaultOpen:r=!1,value:c,defaultValue:b,onValueChange:n,multiple:a=!1,values:C,defaultValues:d,onValuesChange:m,isItemEqualToValue:P=_chunk5T5B5SPRcjs.a,itemToStringLabel:g,itemToStringValue:s,name:p,form:u,required:R,disabled:w=!1,placeholder:S="Select...",items:V,modal:H=!0,closeOnOutsidePress:v="pointerdown",virtualized:ee=!1,virtualItems:k,onHighlightChange:A,debug:ie,children:h,...F}=e,J=I.useCallback((y,ue,Ee,Qt)=>_optionalChain([A, 'optionalCall', _16 => _16(y,Ee,Qt)]),[A]),B=I.useId(),W=I.useRef(null),_=I.useRef(null),q=I.useRef(null),M=I.useRef(null),te=I.useCallback(y=>{W.current=y},[]),U=I.useCallback(y=>{_.current=y},[]),Z=I.useRef(null),f=I.useCallback(y=>(Z.current=y,()=>{Z.current=null}),[]),{store:x,focusOwnerStore:D,openChainStore:Y,registerSurface:oe,closeAll:se,virtualization:he,handleOpenChange:L,disabled:N,setDisabled:ne,menuTreeResolver:re}=_chunkW4ACKMIZcjs.q.call(void 0, {onOpenChange:t,defaultOpen:r,virtualized:ee,items:k,onHighlightChange:J,closeOnOutsidePress:v,disabled:w}),Q=I.useRef(null);I.useImperativeHandle(i,()=>({close:()=>{_optionalChain([Q, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.close, 'call', _19 => _19()])},unmount:()=>{_optionalChain([Q, 'access', _20 => _20.current, 'optionalAccess', _21 => _21.unmount, 'call', _22 => _22()])},setDisabled:ne}),[ne]),x.useControlledProp("openProp",o);let me=x.useState("open"),[xe,le]=I.useState(b!==void 0?b:null),X=c!==void 0?c:xe,be=I.useCallback(y=>{c===void 0&&le(y),_optionalChain([n, 'optionalCall', _23 => _23(y)])},[c,n]),[Yt,Xt]=I.useState(_nullishCoalesce(d, () => ([]))),Pe=C!==void 0?C:Yt,Ze=I.useCallback(y=>{C===void 0&&Xt(y),_optionalChain([m, 'optionalCall', _24 => _24(y)])},[C,m]),Qe=I.useRef(new Map),et=I.useCallback((y,ue)=>(Qe.current.set(y,ue),()=>{}),[]),$t=I.useMemo(()=>({multiple:a,value:X,values:Pe,onValueChange:be,onValuesChange:Ze,isItemEqualToValue:P,itemToStringLabel:g,itemToStringValue:s,name:p,form:u,required:R,disabled:N,placeholder:S,items:V,itemTextRegistry:Qe.current,registerItemText:et,listId:B,triggerRef:W,valueRef:_,selectedItemTextRef:q,firstItemTextRef:M,setTriggerElement:te,setValueElement:U,registerResetPositioningCallback:f}),[a,X,Pe,be,Ze,P,g,s,p,u,R,N,S,V,et,B,te,U,f]),Kt=I.useMemo(()=>p?a?Pe.length>0?Pe.map((y,ue)=>{let Ee=_chunkW4ACKMIZcjs.S.call(void 0, y,s);return _jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:p,value:Ee,form:u,required:R&&ue===0},Ee)}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:p,value:"",form:u,required:R}):_jsxruntime.jsx.call(void 0, "input",{type:"hidden",name:p,value:X!=null?_chunkW4ACKMIZcjs.S.call(void 0, X,s):"",form:u,required:R}):null,[p,u,R,a,X,Pe,s]),Jt=I.useCallback((y,ue)=>{L(y,ue.reason,ue.event)},[L]),Zt=I.useCallback(y=>{!y&&x.context.clearSearchOnClose==="after-exit"&&(x.clearSearch(),x.setInputActive(!1)),y||(x.clearHighlight(),_optionalChain([Z, 'access', _25 => _25.current, 'optionalCall', _26 => _26()]),M.current=null),_optionalChain([l, 'optionalCall', _27 => _27(y)])},[x,l]);return _jsxruntime.jsx.call(void 0, Le.Provider,{value:$t,children:_jsxruntime.jsxs.call(void 0, _chunkW4ACKMIZcjs.N,{menuTreeResolver:re,store:x,focusOwnerStore:D,openChainStore:Y,disabled:N,depth:0,closeAll:se,registerSurface:oe,virtualization:he,menuType:"dropdown",closeOnOutsidePress:v,componentName:"select",debug:ie,children:[Kt,_jsxruntime.jsx.call(void 0, _popover.Popover.Root,{...F,open:me,onOpenChange:Jt,onOpenChangeComplete:Zt,modal:H,actionsRef:i?Q:void 0,children:h})]})})}var Ot={slot:"bazzaui-select-surface"};var $e=De.forwardRef(function(o,t){let{autoHighlightFirst:l,...i}=o,r=O(),c=Ve(),b=De.useMemo(()=>{let n=a=>_chunkW4ACKMIZcjs.Q.call(void 0, a)?!0:_chunkW4ACKMIZcjs.S.call(void 0, a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return n(a)}if(l!==void 0)return l;if(_optionalChain([c, 'optionalAccess', _28 => _28.alignItemWithTriggerActive])){let a=r.multiple?r.values[0]:r.value;return n(a)}return!0},[l,_optionalChain([c, 'optionalAccess', _29 => _29.alignItemWithTriggerActive]),r.multiple,r.value,r.values,r.itemToStringValue]);return _jsxruntime.jsx.call(void 0, _chunkW4ACKMIZcjs.fa,{ref:t,autoHighlightFirst:b,[Ot.slot]:"",...i})});var Se={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};var yo={open:e=>e?{[Se.open]:""}:null,disabled:e=>e?{[Se.disabled]:""}:null,placeholder:e=>e?{[Se.placeholder]:""}:null},Eo=G.forwardRef(function(o,t){let{render:l,children:i,disabled:r,className:c,style:b,triggerProps:n,triggerState:a,...C}=o,d=O(),m=_nullishCoalesce(r, () => (d.disabled)),P=d.multiple?d.values.length>0:!_chunkW4ACKMIZcjs.Q.call(void 0, d.value),g=G.useMemo(()=>({open:a.open,disabled:m,placeholder:!P}),[a.open,m,P]),s=G.useCallback(p=>{d.setTriggerElement(p)},[d]);return _userender.useRender.call(void 0, {render:l,ref:t,state:g,stateAttributesMapping:yo,props:{..._chunkSCDHQZFIcjs.a.call(void 0, n,{...C,className:c,style:b,children:i}),[Se.slot]:"",ref:s,role:"combobox","aria-haspopup":"listbox","aria-controls":d.listId},defaultTagName:"button"})}),Ke= exports.SelectTrigger =G.forwardRef(function(o,t){let{disabled:l,openOnHover:i,delay:r=100,closeDelay:c,...b}=o,n=O(),a=_chunkW4ACKMIZcjs.d.call(void 0, ),{store:C,closeAll:d,closeOnOutsidePress:m}=a,P=(_nullishCoalesce(l, () => (n.disabled)))||a.disabled,g=C.useState("open"),s=G.useRef(null),p=G.useCallback(u=>{s.current=u,typeof t=="function"?t(u):t&&(t.current=u)},[t]);return G.useEffect(()=>{let u=s.current;if(!u||m!=="pointerdown")return;let R=w=>{g&&(d(_chunkXMZZ62VJcjs.a.triggerPress,w),u.addEventListener("click",S=>{S.stopPropagation(),S.preventDefault()},{once:!0,capture:!0}))};return u.addEventListener("pointerdown",R,!0),()=>{u.removeEventListener("pointerdown",R,!0)}},[g,d,m]),_jsxruntime.jsx.call(void 0, _popover.Popover.Trigger,{ref:p,disabled:P,openOnHover:i,delay:r,closeDelay:c,render:(u,R)=>_jsxruntime.jsx.call(void 0, Eo,{...b,disabled:P,triggerProps:u,triggerState:R,ref:u.ref})})});var Ne={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var Ho={hasValue:e=>e?null:{[Ne.placeholder]:""},multiple:e=>e?{[Ne.multiple]:""}:null,getValueText:()=>null};function Lo(e,o){let{render:t,className:l,style:i,placeholder:r,children:c,...b}=e,n=O(),a=_nullishCoalesce(r, () => (n.placeholder)),C=ae.useMemo(()=>_chunk5T5B5SPRcjs.f.call(void 0, n.items,""),[n.items]),d=_nullishCoalesce(_nullishCoalesce(r, () => (C)), () => (a)),m=n.multiple?n.values.length>0:!_chunkW4ACKMIZcjs.Q.call(void 0, n.value),P=ae.useCallback(u=>{let R=_chunkW4ACKMIZcjs.S.call(void 0, u,n.itemToStringValue),w=n.itemTextRegistry.get(R);if(w!==void 0)return w;let S=_chunk5T5B5SPRcjs.f.call(void 0, n.items,R);if(S!==void 0)return S;let V=_chunkW4ACKMIZcjs.R.call(void 0, u,n.itemToStringLabel);if(V&&V!==R)return V},[n.itemTextRegistry,n.items,n.itemToStringLabel,n.itemToStringValue]),g=ae.useMemo(()=>({value:n.value,values:n.values,multiple:n.multiple,hasValue:m,placeholder:a,getValueText:P}),[n.value,n.values,n.multiple,m,a,P]),s;if(typeof c=="function")s=c(g);else if(c!==void 0)s=c;else if(!m)s=d;else if(n.multiple){let u=n.values.map(R=>{let w=P(R);return w!==void 0?w:_chunkW4ACKMIZcjs.R.call(void 0, R,n.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, R,n.itemToStringValue)}).filter(Boolean);s=u.length>2?`${u.length} selected`:u.join(", ")}else{let u=n.value;if(u!=null){let R=P(u);R!==void 0?s=R:s=_chunkW4ACKMIZcjs.R.call(void 0, u,n.itemToStringLabel)||_chunkW4ACKMIZcjs.S.call(void 0, u,n.itemToStringValue)}}let p=ae.useCallback(u=>{n.setValueElement(u)},[n]);return _userender.useRender.call(void 0, {render:t,ref:o,state:g,stateAttributesMapping:Ho,props:{...b,[Ne.slot]:"",ref:p,className:l,style:i,children:s},defaultTagName:"span"})}var Je=ae.forwardRef(Lo);var zt=(c=>(c.slot="bazzaui-select-arrow",c.open="data-open",c.closed="data-closed",c.side="data-side",c.align="data-align",c.uncentered="data-uncentered",c))(zt||{});var Gt=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Gt||{});var Ft=(o=>(o.slot="bazzaui-select-empty",o))(Ft||{});var Bt=(o=>(o.slot="bazzaui-select-group",o))(Bt||{});var jt=(o=>(o.slot="bazzaui-select-group-label",o))(jt||{});var ko={slot:"bazzaui-select-icon",open:"data-popup-open"};var Wt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(Wt||{});var _t=(t=>(t.slot="bazzaui-select-list",t.list="data-popup-menu-list",t))(_t||{});var qt=(o=>(o.alignItemWithTrigger="data-align-item-with-trigger",o))(qt||{});var Ao={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Ut=(o=>(o.slot="bazzaui-select-separator",o))(Ut||{});exports.Select = Nt; exports.SelectArrowDataAttributes = zt; exports.SelectBackdropDataAttributes = Gt; exports.SelectEmptyDataAttributes = Ft; exports.SelectGroupDataAttributes = Bt; exports.SelectGroupLabelDataAttributes = jt; exports.SelectIconDataAttributes = ko; exports.SelectInputDataAttributes = Wt; exports.SelectItem = ze; exports.SelectItemDataAttributes = $; exports.SelectItemIndicator = Ge; exports.SelectItemIndicatorDataAttributes = Me; exports.SelectItemLabel = Fe; exports.SelectListCssVars = _chunkW4ACKMIZcjs.aa; exports.SelectListDataAttributes = _t; exports.SelectPopup = je; exports.SelectPopupDataAttributes = qt; exports.SelectPositioner = Ye; exports.SelectPositionerCssVars = _chunkW4ACKMIZcjs.L; exports.SelectPositionerDataAttributes = qe; exports.SelectRoot = Xe; exports.SelectScrollArrowDataAttributes = Ao; exports.SelectSeparatorDataAttributes = Ut; exports.SelectStore = _chunkXMZZ62VJcjs.y; exports.SelectSurface = $e; exports.SelectTrigger = Ke; exports.SelectTriggerDataAttributes = Se; exports.SelectValue = Je; exports.commandScore = _chunkXMZZ62VJcjs.w; exports.defaultFilter = _chunkXMZZ62VJcjs.x; exports.useMaybeSelectContext = so; exports.useMaybeSelectItemContext = uo; exports.useMaybeSurfaceContext = _chunkXMZZ62VJcjs.q; exports.useSelectContext = O; exports.useSelectItemContext = Te; exports.useSelectPositionerContext = Ve; exports.useSurfaceContext = _chunkXMZZ62VJcjs.p;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/select/index.cjs","../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","SelectItemContext","useSelectItemContext","useMaybeSelectItemContext","stateAttributesMapping","value","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerM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U,IAAA,CAAO,CAAA,aAAA,EAAgBoB,CAAe,CAAA,CAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/select/index.cjs","sourcesContent":[null,"// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n first: (value: unknown) =>\n value ? { [SelectItemDataAttributes.first]: '' } : null,\n last: (value: unknown) =>\n value ? { [SelectItemDataAttributes.last]: '' } : null,\n firstInGroup: (value: unknown) =>\n value ? { [SelectItemDataAttributes.firstInGroup]: '' } : null,\n lastInGroup: (value: unknown) =>\n value ? { [SelectItemDataAttributes.lastInGroup]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n first: item.positional.first,\n last: item.positional.last,\n firstInGroup: item.positional.firstInGroup,\n lastInGroup: item.positional.lastInGroup,\n }),\n [item.isHighlighted, disabled, selected, item.positional],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, item.rowRef, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n /** Present when this row is the first visible list-level row (not inside a group). */\n first: 'data-first',\n /** Present when this row is the last visible list-level row (not inside a group). */\n last: 'data-last',\n /** Present when this row is the first visible row within its group. */\n firstInGroup: 'data-first-in-group',\n /** Present when this row is the last visible row within its group. */\n lastInGroup: 'data-last-in-group',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n"]}
1
+ {"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","SelectItemContext","useSelectItemContext","useMaybeSelectItemContext","stateAttributesMapping","value","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerMove","children","rest","selectContext","serializedValue","stringifyAsValue","generatedItemId","listboxId"],"mappings":"AAAA,4/BAA0C,yDAA2F,yDAAiO,yDAAmF,yDAA2C,ICApeA,EAAAA,CAAA,CAAA,CAAA,CAAAC,iCAAAA,EAAAD,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAE,mBAAAA,CAAA,QAAA,CAAA,CAAA,CAAA,EAAAC,mBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,mBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,UAAA,CAAA,CAAA,CAAA,EAAAC,mBAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,mBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,mBAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,aAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,SAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,MAAA,CAAA,CAAA,CAAA,EAAAC,mBAAAA,CAAA,UAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,eAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,aAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,SAAA,CAAA,CAAA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,CAGxC0B,CAAAA,CAAwB,CAAA,CAAA,OAAA,CAC5B,CAAA,CAAA,EAAMC,iCAAAA,CAAiBnB,CAAOiB,CAAAA,CAAc,iBAAiB,CAAA,CAC7D,CAACjB,CAAAA,CAAOiB,CAAAA,CAAc,iBAAiB,CACzC,CAAA,CAKMG,CAAAA,CAAwB,CAAA,CAAA,KAAA,CAAM,CAAA,CAC9BC,CAAAA,CACJrB,CAAAA,GAAU,IAAA,CAAO,CAAA,aAAA,EAAgBoB,CAAe,CAAA,CAAA","file":"/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","sourcesContent":[null,"// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n first: boolean\n last: boolean\n firstInGroup: boolean\n lastInGroup: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n first: (value: unknown) =>\n value ? { [SelectItemDataAttributes.first]: '' } : null,\n last: (value: unknown) =>\n value ? { [SelectItemDataAttributes.last]: '' } : null,\n firstInGroup: (value: unknown) =>\n value ? { [SelectItemDataAttributes.firstInGroup]: '' } : null,\n lastInGroup: (value: unknown) =>\n value ? { [SelectItemDataAttributes.lastInGroup]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n first: item.positional.first,\n last: item.positional.last,\n firstInGroup: item.positional.firstInGroup,\n lastInGroup: item.positional.lastInGroup,\n }),\n [item.isHighlighted, disabled, selected, item.positional],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, item.rowRef, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n /** Present when this row is the first visible list-level row (not inside a group). */\n first: 'data-first',\n /** Present when this row is the last visible list-level row (not inside a group). */\n last: 'data-last',\n /** Present when this row is the first visible row within its group. */\n firstInGroup: 'data-first-in-group',\n /** Present when this row is the last visible row within its group. */\n lastInGroup: 'data-last-in-group',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n"]}
@@ -10,7 +10,7 @@ import * as React from 'react';
10
10
  import { C as ComponentProps, a as ComponentRenderFn } from '../types-DT4FOOa2.cjs';
11
11
  import { PopoverPositionerProps, Popover, PopoverRootProps } from '@base-ui/react/popover';
12
12
  import { I as ItemEqualityComparer, a as Items } from '../items-B6HeFO_8.cjs';
13
- import { C as ChangeEventDetails, t as triggerPress, e as escapeKey, o as outsidePress, f as focusOut, i as itemPress, l as listNavigation, g as imperativeAction, n as none, G as GenericEventDetails, p as pointer, k as keyboard } from '../events-DPsuhBln.cjs';
13
+ import { C as ChangeEventDetails, t as triggerPress, a as triggerHover, e as escapeKey, o as outsidePress, f as focusOut, i as itemPress, l as listNavigation, g as imperativeAction, n as none, G as GenericEventDetails, p as pointer, k as keyboard } from '../events-DPsuhBln.cjs';
14
14
  export { S as SurfaceContextValue, u as useMaybeSurfaceContext, a as useSurfaceContext } from '../surface-context-DF-L-30G.cjs';
15
15
  export { c as commandScore, d as defaultFilter } from '../command-score-CTJ9NV6n.cjs';
16
16
  import '@base-ui/utils/store';
@@ -288,7 +288,7 @@ declare namespace SelectPositioner {
288
288
  /**
289
289
  * Reasons why the select's open state changed.
290
290
  */
291
- type SelectOpenChangeReason = typeof triggerPress | typeof escapeKey | typeof outsidePress | typeof focusOut | typeof itemPress | typeof listNavigation | typeof imperativeAction | typeof none;
291
+ type SelectOpenChangeReason = typeof triggerPress | typeof triggerHover | typeof escapeKey | typeof outsidePress | typeof focusOut | typeof itemPress | typeof listNavigation | typeof imperativeAction | typeof none;
292
292
  /**
293
293
  * Event details passed to the `onOpenChange` callback.
294
294
  */
@@ -577,10 +577,30 @@ interface SelectTriggerProps extends ComponentProps<'button', SelectTrigger.Stat
577
577
  * Whether the trigger is disabled.
578
578
  */
579
579
  disabled?: boolean;
580
+ /**
581
+ * Whether the select opens when hovering the trigger.
582
+ * @default false
583
+ */
584
+ openOnHover?: boolean;
585
+ /**
586
+ * Delay before opening on hover (in milliseconds).
587
+ * Only applies when `openOnHover` is true.
588
+ * @default 100
589
+ */
590
+ delay?: number;
591
+ /**
592
+ * Delay before closing when pointer leaves (in milliseconds).
593
+ * Only applies when `openOnHover` is true.
594
+ * @default 0
595
+ */
596
+ closeDelay?: number;
580
597
  }
581
598
  /**
582
599
  * A button that opens the select dropdown.
583
600
  * Renders a `<button>` element with combobox ARIA semantics.
601
+ *
602
+ * Supports `openOnHover` to open the select when hovering the trigger,
603
+ * with configurable `delay` and `closeDelay`.
584
604
  */
585
605
  declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectTrigger.Props, "ref"> & React.RefAttributes<HTMLButtonElement>>;
586
606
  declare namespace SelectTrigger {
@@ -10,7 +10,7 @@ import * as React from 'react';
10
10
  import { C as ComponentProps, a as ComponentRenderFn } from '../types-DT4FOOa2.js';
11
11
  import { PopoverPositionerProps, Popover, PopoverRootProps } from '@base-ui/react/popover';
12
12
  import { I as ItemEqualityComparer, a as Items } from '../items-B6HeFO_8.js';
13
- import { C as ChangeEventDetails, t as triggerPress, e as escapeKey, o as outsidePress, f as focusOut, i as itemPress, l as listNavigation, g as imperativeAction, n as none, G as GenericEventDetails, p as pointer, k as keyboard } from '../events-DOGItflK.js';
13
+ import { C as ChangeEventDetails, t as triggerPress, a as triggerHover, e as escapeKey, o as outsidePress, f as focusOut, i as itemPress, l as listNavigation, g as imperativeAction, n as none, G as GenericEventDetails, p as pointer, k as keyboard } from '../events-DOGItflK.js';
14
14
  export { S as SurfaceContextValue, u as useMaybeSurfaceContext, a as useSurfaceContext } from '../surface-context-ClmxshBW.js';
15
15
  export { c as commandScore, d as defaultFilter } from '../command-score-CTJ9NV6n.js';
16
16
  import '@base-ui/utils/store';
@@ -288,7 +288,7 @@ declare namespace SelectPositioner {
288
288
  /**
289
289
  * Reasons why the select's open state changed.
290
290
  */
291
- type SelectOpenChangeReason = typeof triggerPress | typeof escapeKey | typeof outsidePress | typeof focusOut | typeof itemPress | typeof listNavigation | typeof imperativeAction | typeof none;
291
+ type SelectOpenChangeReason = typeof triggerPress | typeof triggerHover | typeof escapeKey | typeof outsidePress | typeof focusOut | typeof itemPress | typeof listNavigation | typeof imperativeAction | typeof none;
292
292
  /**
293
293
  * Event details passed to the `onOpenChange` callback.
294
294
  */
@@ -577,10 +577,30 @@ interface SelectTriggerProps extends ComponentProps<'button', SelectTrigger.Stat
577
577
  * Whether the trigger is disabled.
578
578
  */
579
579
  disabled?: boolean;
580
+ /**
581
+ * Whether the select opens when hovering the trigger.
582
+ * @default false
583
+ */
584
+ openOnHover?: boolean;
585
+ /**
586
+ * Delay before opening on hover (in milliseconds).
587
+ * Only applies when `openOnHover` is true.
588
+ * @default 100
589
+ */
590
+ delay?: number;
591
+ /**
592
+ * Delay before closing when pointer leaves (in milliseconds).
593
+ * Only applies when `openOnHover` is true.
594
+ * @default 0
595
+ */
596
+ closeDelay?: number;
580
597
  }
581
598
  /**
582
599
  * A button that opens the select dropdown.
583
600
  * Renders a `<button>` element with combobox ARIA semantics.
601
+ *
602
+ * Supports `openOnHover` to open the select when hovering the trigger,
603
+ * with configurable `delay` and `closeDelay`.
584
604
  */
585
605
  declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectTrigger.Props, "ref"> & React.RefAttributes<HTMLButtonElement>>;
586
606
  declare namespace SelectTrigger {