@bazza-ui/react 0.1.0-canary.2 → 0.1.0-canary.4
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.
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/chunk-BGJJC6GX.cjs.map +1 -1
- package/dist/chunk-FWWOE2SW.cjs.map +1 -1
- package/dist/chunk-JSPKF52O.cjs.map +1 -1
- package/dist/chunk-M4G6J7DP.cjs.map +1 -1
- package/dist/combobox/index.cjs.map +1 -1
- package/dist/context-menu/index.cjs.map +1 -1
- package/dist/dropdown-menu/index.cjs.map +1 -1
- package/dist/internal/listbox/index.cjs.map +1 -1
- package/dist/internal/popup-menu/index.cjs.map +1 -1
- package/dist/select/index.cjs.map +1 -1
- package/dist/video-player/index.cjs +3 -0
- package/dist/video-player/index.cjs.map +1 -0
- package/dist/video-player/index.d.cts +1383 -0
- package/dist/video-player/index.d.ts +1383 -0
- package/dist/video-player/index.js +3 -0
- package/dist/video-player/index.js.map +1 -0
- package/package.json +8 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/adapters/index.cjs","../../src/adapters/swr.tsx","../../src/adapters/tanstack-query.tsx","../../src/adapters/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","createVanillaStaticLo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,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/adapters/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 QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/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-dependent 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-dependent loader configuration backed by SWR.\n */\nexport function createSWRQueryLoader(\n props: CreateSWRQueryLoaderProps,\n): QueryDependentLoaderConfig {\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 QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/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-dependent 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-dependent 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): QueryDependentLoaderConfig {\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 QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/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-dependent 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-dependent 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): QueryDependentLoaderConfig {\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":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/adapters/index.cjs","../../src/adapters/swr.tsx","../../src/adapters/tanstack-query.tsx","../../src/adapters/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,QAA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AAG,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":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/adapters/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 QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/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-dependent 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-dependent loader configuration backed by SWR.\n */\nexport function createSWRQueryLoader(\n props: CreateSWRQueryLoaderProps,\n): QueryDependentLoaderConfig {\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 QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/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-dependent 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-dependent 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): QueryDependentLoaderConfig {\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 QueryDependentLoaderConfig,\n StaticLoaderConfig,\n} from '../internal/popup-menu/deep-search/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-dependent 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-dependent 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): QueryDependentLoaderConfig {\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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/item-equality.ts"],"names":["defaultItemEquality","item","value","compareItemEquality","comparer","itemIncludes","collection","removeItem"],"mappings":"AAaO,6EAAMA,CAAAA,CAA4C,CAACC,CAAAA,CAAMC,CAAAA,CAAAA,EAC9D,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAMhB,SAASC,CAAAA,CACdF,CAAAA,CACAC,CAAAA,CACAE,CAAAA,CACS,CAET,OAAIH,CAAAA,EAAQ,IAAA,EAAQC,CAAAA,EAAS,IAAA,CACpB,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAEvBE,CAAAA,CAASH,CAAAA,CAAMC,CAAK,CAC7B,CAKO,SAASG,CAAAA,CACdC,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,MAAI,CAACE,CAAAA,EAAcA,CAAAA,CAAW,MAAA,GAAW,CAAA,CAChC,CAAA,CAAA,CAEFA,CAAAA,CAAW,IAAA,CAAML,CAAAA,EAClBA,CAAAA,GAAS,KAAA,CAAA,CACJ,CAAA,CAAA,CAEFE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACjD,CACH,CA0BO,SAASG,CAAAA,CACdD,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,OAAOE,CAAAA,CAAW,MAAA,CACfL,CAAAA,EAAS,CAACE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACtD,CACF,CAAA,2DAAA","file":"/
|
|
1
|
+
{"version":3,"sources":["../src/utils/item-equality.ts"],"names":["defaultItemEquality","item","value","compareItemEquality","comparer","itemIncludes","collection","removeItem"],"mappings":"AAaO,6EAAMA,CAAAA,CAA4C,CAACC,CAAAA,CAAMC,CAAAA,CAAAA,EAC9D,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAMhB,SAASC,CAAAA,CACdF,CAAAA,CACAC,CAAAA,CACAE,CAAAA,CACS,CAET,OAAIH,CAAAA,EAAQ,IAAA,EAAQC,CAAAA,EAAS,IAAA,CACpB,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAMC,CAAK,CAAA,CAEvBE,CAAAA,CAASH,CAAAA,CAAMC,CAAK,CAC7B,CAKO,SAASG,CAAAA,CACdC,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,MAAI,CAACE,CAAAA,EAAcA,CAAAA,CAAW,MAAA,GAAW,CAAA,CAChC,CAAA,CAAA,CAEFA,CAAAA,CAAW,IAAA,CAAML,CAAAA,EAClBA,CAAAA,GAAS,KAAA,CAAA,CACJ,CAAA,CAAA,CAEFE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACjD,CACH,CA0BO,SAASG,CAAAA,CACdD,CAAAA,CACAJ,CAAAA,CACAE,CAAAA,CACS,CACT,OAAOE,CAAAA,CAAW,MAAA,CACfL,CAAAA,EAAS,CAACE,CAAAA,CAAoBF,CAAAA,CAAMC,CAAAA,CAAOE,CAAQ,CACtD,CACF,CAAA,2DAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-BGJJC6GX.cjs","sourcesContent":["/**\n * Type for custom item equality comparison functions.\n * Used to compare object values in Select and Combobox components.\n */\nexport type ItemEqualityComparer<Value = unknown> = (\n itemValue: Value,\n value: Value,\n) => boolean\n\n/**\n * Default equality comparer using Object.is.\n * Handles primitives and object reference equality.\n */\nexport const defaultItemEquality: ItemEqualityComparer = (item, value) =>\n Object.is(item, value)\n\n/**\n * Compare two items for equality using a custom comparer.\n * Handles null/undefined values separately using Object.is.\n */\nexport function compareItemEquality<Value>(\n item: Value,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n // Handle null/undefined with Object.is for consistent behavior\n if (item == null || value == null) {\n return Object.is(item, value)\n }\n return comparer(item, value)\n}\n\n/**\n * Check if a collection includes a specific value using custom equality.\n */\nexport function itemIncludes<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): boolean {\n if (!collection || collection.length === 0) {\n return false\n }\n return collection.some((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Find the index of a value in a collection using custom equality.\n * Returns -1 if not found.\n */\nexport function findItemIndex<Value>(\n collection: readonly Value[] | undefined | null,\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): number {\n if (!collection || collection.length === 0) {\n return -1\n }\n return collection.findIndex((item) => {\n if (item === undefined) {\n return false\n }\n return compareItemEquality(item, value, comparer)\n })\n}\n\n/**\n * Remove a value from a collection using custom equality.\n * Returns a new array without the matching item.\n */\nexport function removeItem<Value>(\n collection: readonly Value[],\n value: Value,\n comparer: ItemEqualityComparer<Value>,\n): Value[] {\n return collection.filter(\n (item) => !compareItemEquality(item, value, comparer),\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/chunk-FWWOE2SW.cjs","../src/internal/listbox/contexts/group-context.ts","../src/internal/listbox/contexts/item-context.ts","../src/internal/listbox/contexts/listbox-context.ts","../src/internal/listbox/contexts/row-width-context.ts","../src/internal/listbox/contexts/surface-context.ts","../src/internal/listbox/hooks/use-listbox-item.ts","../src/internal/listbox/utils/normalize.ts"],"names":["GroupContext","useGroupContext","ItemContext","useItemContext","context","useMaybeItemContext","ListboxContext","useListboxContext","useMaybeListboxContext","RowWidthContext","useRowWidthContext","useMaybeRowWidthContext","SurfaceContext","useSurfaceContext","useMaybeSurfaceContext","normalizeValue","value","slugify","useListboxItem","params","idProp","valueProp","keywords","disabled","forceMount","shortcut","forceOrder","forceScore","isSubmenuTrigger","onSelect","closeOnClick","onAfterSelect","children","aimGuard","store","groupContext","depth","ref","inferredValue","setInferredValue","textContent","registrationId","generatedDomId","domId"],"mappings":"AAAA,2/BAAyC,uWCElB,IAUjBA,EAAAA,CAAqB,CAAA,CAAA,aAAA,CAAwC,IAAI,CAAA,CAEhE,SAASC,CAAAA,CAAAA,CAA4C,CAC1D,OAAa,CAAA,CAAA,UAAA,CAAWD,EAAY,CACtC,CCdA,IAiBME,CAAAA,CAAoB,CAAA,CAAA,aAAA,CAAuC,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AAA,CAAAmC,CAAM,CAAA,CAAI7B,CAAAA,CAAkB,CAAA,CAE9B8B,CAAAA,CAAY,CAAA,CAAA,MAAA,CAAuB,IAAI,CAAA,CAGvC,CAACC,CAAAA,CAAeC,CAAgB,CAAA,CAAU,CAAA,CAAA,QAAA,CAAiB,EAAE,CAAA,CAE7D,CAAA,CAAA,eAAA,CAAgB,CAAA,CAAA,EAAM,CAC1B,EAAA,CAAInB,CAAAA,GAAW,KAAA,CAAA,EAAaC,CAAAA,GAAc,KAAA,CAAA,EAAagB,CAAAA,CAAI,OAAA,CAAS,CAClE,IAAMG,CAAAA,kCAAcH,CAAAA,qBAAI,OAAA,qBAAQ,WAAA,6BAAa,IAAA,mBAAK,GAAA,SAAK,IAAA,CACvDE,CAAAA,CAAiBC,CAAW,CAC9B,CACF,CAAA,CAAG,CAACpB,CAAAA,CAAQC,CAAAA,CAAWW,CAAQ,CAAC,CAAA,CAKhC,IAAMS,CAAAA,kBAAiBrB,CAAAA,SAAAA,CAAWL,CAAAA,CAAeM,CAAS,CAAA,EAAKiB,CAAAA,GAAAA,CAKzDI,CAAAA,CAAuB,CAAA,CAAA,KAAA,CAAM,CAAA,CAC7BC,CAAAA,kBAAQvB,CAAAA,SAAU,CAAA,KAAA,EAAQsB,CAAc,CAAA,GAAA","file":"/home/runner/work/ui/ui/packages/react/dist/chunk-FWWOE2SW.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Group Context (for items to know their parent group)\n// ============================================================================\n\nexport interface GroupContextValue {\n groupId: string\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null)\n\nexport function useGroupContext(): GroupContextValue | null {\n return React.useContext(GroupContext)\n}\n\nexport { GroupContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Item Context (for child components like indicators to access item state)\n// ============================================================================\n\nexport interface ItemContextValue {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Keyboard shortcut for this item */\n shortcut?: string\n}\n\nconst ItemContext = React.createContext<ItemContextValue | null>(null)\n\nexport function useItemContext(): ItemContextValue {\n const context = React.useContext(ItemContext)\n if (!context) {\n throw new Error('Item child components must be used within an Item')\n }\n return context\n}\n\nexport function useMaybeItemContext(): ItemContextValue | null {\n return React.useContext(ItemContext)\n}\n\nexport { ItemContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { HighlightChangeEventDetails } from '../../popup-menu/events.js'\nimport type { ListboxStore, VirtualItem } from '../store/ListboxStore.js'\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\nexport interface ListboxContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: () => void\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n}\n\nconst ListboxContext = React.createContext<ListboxContextValue | null>(null)\n\nexport function useListboxContext(): ListboxContextValue {\n const context = React.useContext(ListboxContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Listbox provider')\n }\n return context\n}\n\nexport function useMaybeListboxContext(): ListboxContextValue | null {\n return React.useContext(ListboxContext)\n}\n\nexport { ListboxContext }\n","'use client'\n\nimport * as React from 'react'\n\n/**\n * Context value for row width measurement.\n * Provided by List when `measureRowWidth` is enabled.\n */\nexport interface RowWidthContextValue {\n /**\n * Queue a row element for width measurement.\n * Call this when a row mounts or becomes visible.\n *\n * @param element - The DOM element to measure\n * @param id - Unique identifier for this row (used to avoid re-measuring)\n */\n queueMeasurement: (element: HTMLElement, id: string) => void\n}\n\n/**\n * Context for row width measurement.\n * Items use this to self-register for measurement.\n */\nexport const RowWidthContext = React.createContext<RowWidthContextValue | null>(\n null,\n)\n\nif (process.env.NODE_ENV !== 'production') {\n RowWidthContext.displayName = 'RowWidthContext'\n}\n\n/**\n * Hook to get the row width context.\n * Throws an error if used outside of a List with `measureRowWidth` enabled.\n */\nexport function useRowWidthContext(): RowWidthContextValue {\n const context = React.useContext(RowWidthContext)\n if (!context) {\n throw new Error(\n 'useRowWidthContext must be used within a List with measureRowWidth enabled',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally get the row width context.\n * Returns null if not within a List with `measureRowWidth` enabled.\n * This is the preferred hook for items that should work both with and without measurement.\n */\nexport function useMaybeRowWidthContext(): RowWidthContextValue | null {\n return React.useContext(RowWidthContext)\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ListboxStore } from '../store/ListboxStore.js'\n\n// Re-export types from the store for convenience\nexport type {\n FilterFn,\n ItemRegistration,\n} from '../store/ListboxStore.js'\n\n// ============================================================================\n// Surface Context\n// ============================================================================\n\nexport interface SurfaceContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Unique identifier for this surface */\n surfaceId: string\n}\n\nconst SurfaceContext = React.createContext<SurfaceContextValue | null>(null)\n\nexport function useSurfaceContext(): SurfaceContextValue {\n const context = React.useContext(SurfaceContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Surface provider')\n }\n return context\n}\n\nexport function useMaybeSurfaceContext(): SurfaceContextValue | null {\n return React.useContext(SurfaceContext)\n}\n\nexport { SurfaceContext }\n","'use client'\n\nimport * as React from 'react'\nimport { useGroupContext } from '../contexts/group-context.js'\nimport type { ItemContextValue } from '../contexts/item-context.js'\nimport { useListboxContext } from '../contexts/listbox-context.js'\nimport { useMaybeRowWidthContext } from '../contexts/row-width-context.js'\nimport { useSurfaceContext } from '../contexts/surface-context.js'\nimport { normalizeValue } from '../utils/normalize.js'\n\n/**\n * Aim guard refs for submenu navigation.\n * Optional - only needed for popup menus with submenus.\n */\nexport interface AimGuardRefs {\n /** Whether aim guard is currently active */\n aimGuardActiveRef: React.RefObject<boolean>\n /** The depth at which aim guard is active (null when not guarding) */\n guardedDepthRef: React.RefObject<number | null>\n}\n\n/**\n * Parameters for the useListboxItem hook.\n */\nexport interface UseListboxItemParams {\n /**\n * Explicit unique identifier for this item in the store.\n * Takes highest priority for item registration.\n * Used by data-first APIs to ensure consistent IDs.\n */\n id?: string\n\n /**\n * Unique value for this item used as identifier and for filtering.\n * If not provided, will be inferred from textContent.\n * Used for registration when `id` is not provided.\n */\n value?: 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 * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Keyboard shortcut to trigger this item.\n * When the menu is focused and the user presses this key, the item will be selected.\n * Should be a single character (e.g., \"1\", \"a\", etc.).\n */\n shortcut?: string\n\n /**\n * Forces this row's relative order during score-based sorting.\n * Lower values appear earlier.\n * @default 0\n */\n forceOrder?: number\n\n /**\n * Overrides this row's computed fuzzy-match score.\n * Useful for pinning or manually ranking rows in score-based views.\n */\n forceScore?: number\n\n /**\n * Whether this item is a submenu trigger (for store registration).\n * @default false\n */\n isSubmenuTrigger?: boolean\n\n /**\n * Callback when this item is selected (via click or Enter key).\n * For simple items, pass this directly. For checkbox/radio items,\n * use registerSelect() to register a dynamic handler.\n */\n onSelect?: () => void\n\n /**\n * Whether selecting this item should close the menu.\n * @default true\n */\n closeOnClick?: boolean\n\n /**\n * Callback invoked after selection occurs (via click).\n * Called with the item's ID. The consumer handles any\n * post-selection behavior like closing menus.\n */\n onAfterSelect?: (itemId: string) => void\n\n /**\n * Children (used for text content inference when value is not provided).\n */\n children?: React.ReactNode\n\n /**\n * Optional aim guard refs for popup menu navigation.\n * When provided, pointer move events will respect the aim guard.\n */\n aimGuard?: AimGuardRefs\n}\n\n/**\n * Return value from the useListboxItem hook.\n */\nexport interface UseListboxItemReturn {\n /** Unique ID for this item (DOM ID for aria-activedescendant) */\n id: string\n\n /**\n * Store identifier for this item.\n * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.\n * This is the `value` prop (or inferred from textContent).\n */\n storeId: string\n\n /** Ref to attach to the item element */\n ref: React.RefObject<HTMLDivElement | null>\n\n /** Whether item is currently highlighted */\n isHighlighted: boolean\n\n /** Whether item should be rendered (passes filter) */\n isVisible: boolean\n\n /** Context value to provide to children via ItemContext.Provider */\n contextValue: ItemContextValue\n\n /**\n * Event handlers to spread on the element.\n * These handle click, pointer move, and pointer down events.\n */\n handlers: {\n onClick: React.MouseEventHandler<HTMLDivElement>\n onPointerMove: React.PointerEventHandler<HTMLDivElement>\n onPointerDown: React.PointerEventHandler<HTMLDivElement>\n }\n\n /**\n * Register a custom onSelect handler.\n * This is useful for checkbox/radio items where the select behavior\n * needs to be customized (e.g., toggle checked state).\n * Returns an unregister function.\n */\n registerSelect: (handler: (() => void) | undefined) => () => void\n}\n\n/**\n * Hook that provides all shared logic for navigatable/highlightable listbox items.\n *\n * This hook handles:\n * - Item registration with the listbox store\n * - Highlight state management (keyboard and pointer)\n * - Filter/search visibility\n * - Scroll into view on keyboard navigation\n * - Click, pointer move, and pointer down event handlers\n * - Optional aim guard integration (for submenu navigation)\n *\n * @example\n * ```tsx\n * function CustomItem(props) {\n * const item = useListboxItem({\n * value: props.value,\n * disabled: props.disabled,\n * onSelect: props.onSelect,\n * })\n *\n * if (!item.isVisible) return null\n *\n * return (\n * <ItemContext.Provider value={item.contextValue}>\n * <div\n * ref={item.ref}\n * {...item.handlers}\n * data-highlighted={item.isHighlighted || undefined}\n * >\n * {props.children}\n * </div>\n * </ItemContext.Provider>\n * )\n * }\n * ```\n */\nexport function useListboxItem(\n params: UseListboxItemParams,\n): UseListboxItemReturn {\n const {\n id: idProp,\n value: valueProp,\n keywords,\n disabled = false,\n forceMount = false,\n shortcut,\n forceOrder,\n forceScore,\n isSubmenuTrigger = false,\n onSelect,\n closeOnClick = true,\n onAfterSelect,\n children,\n aimGuard,\n } = params\n\n const { store } = useSurfaceContext()\n const groupContext = useGroupContext()\n const { depth } = useListboxContext()\n\n const ref = React.useRef<HTMLDivElement>(null)\n\n // Infer value from textContent if not provided\n const [inferredValue, setInferredValue] = React.useState<string>('')\n\n React.useLayoutEffect(() => {\n if (idProp === undefined && valueProp === undefined && ref.current) {\n const textContent = ref.current.textContent?.trim() ?? ''\n setInferredValue(textContent)\n }\n }, [idProp, valueProp, children])\n\n // Registration ID priority: id prop > value prop > textContent inference\n // This ensures data-first APIs can provide explicit IDs that match their internal tracking\n // Note: valueProp is normalized (trimmed) to match cmdk's behavior\n const registrationId = idProp ?? (normalizeValue(valueProp) || inferredValue)\n\n // Generate a stable ID for DOM id attribute (aria-activedescendant, etc.)\n // When id prop is provided (data-first APIs), use it directly for DOM ID\n // This ensures aria-activedescendant works correctly with composite IDs\n const generatedDomId = React.useId()\n const domId = idProp ?? `item-${generatedDomId}`\n\n // Stabilize keywords to prevent infinite loops when passed as inline arrays\n // We use JSON.stringify to compare by value rather than reference\n // Keywords are also normalized (trimmed) to match cmdk's behavior\n const normalizedKeywords = keywords\n ?.map((k) => normalizeValue(k))\n .filter(Boolean)\n const keywordsKey = normalizedKeywords\n ? JSON.stringify(normalizedKeywords)\n : undefined\n\n // Register item with store (using registrationId as the unique identifier)\n React.useEffect(() => {\n if (!registrationId && !forceMount) return\n\n const unregister = store.registerItem(registrationId, {\n value: registrationId,\n keywords: normalizedKeywords,\n groupId: groupContext?.groupId,\n disabled,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n })\n\n return unregister\n // eslint-disable-next-line react-hooks/exhaustive-deps -- keywordsKey is a stable representation of keywords\n }, [\n registrationId,\n keywordsKey,\n groupContext?.groupId,\n disabled,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n store,\n forceMount,\n ])\n\n // Register DOM ref with store for scroll behavior\n React.useEffect(() => {\n if (!registrationId) return\n return store.registerItemRef(registrationId, ref)\n }, [registrationId, store])\n\n // Register for row width measurement if enabled\n const rowWidthContext = useMaybeRowWidthContext()\n\n React.useLayoutEffect(() => {\n if (rowWidthContext && ref.current && registrationId) {\n rowWidthContext.queueMeasurement(ref.current, registrationId)\n }\n }, [rowWidthContext, registrationId])\n\n // Register onSelect handler if provided directly\n React.useEffect(() => {\n if (!onSelect || !registrationId) return\n return store.registerItemSelect(registrationId, onSelect)\n }, [registrationId, onSelect, store])\n\n // Use selectors to get derived state (using registrationId as identifier)\n const normalizedSearch = store.useState('normalizedSearch')\n const isHighlighted = store.useState('isHighlighted', registrationId)\n const score = store.useState('getItemScore', registrationId)\n\n // Check if filtering is disabled (consumer handles filtering externally)\n const filterDisabled = store.isFilterDisabled()\n\n // Determine visibility based on filter score\n // When filterDisabled, consumer handles filtering so all items are visible\n const hasSearch = normalizedSearch.length > 0\n const isVisible = forceMount || filterDisabled || !hasSearch || score > 0\n\n // Note: Scroll behavior is now handled by the store's setHighlightedId method.\n // It uses the registered DOM refs to call scrollIntoView when the element exists,\n // or falls back to onHighlightChange for virtualizer sync.\n\n // Event handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n event.preventDefault()\n\n // Call the registered onSelect handler via store\n const registeredHandler = store.context.itemSelects.get(registrationId)\n registeredHandler?.()\n\n // Notify consumer that selection occurred (for closing menus, etc.)\n onAfterSelect?.(registrationId)\n },\n [disabled, store, registrationId, onAfterSelect],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n // Don't highlight if aim guard is active at this depth (user is moving toward submenu)\n // Only block highlighting in the same menu where the trigger is located\n if (aimGuard) {\n const { aimGuardActiveRef, guardedDepthRef } = aimGuard\n if (aimGuardActiveRef.current && guardedDepthRef.current === depth)\n return\n }\n\n // Check if pointer has actually moved - prevents phantom highlights when\n // content shifts under a stationary pointer (e.g., search results changing)\n if (!store.shouldAllowPointerHighlight(event.clientX, event.clientY)) {\n return\n }\n\n // Highlight on hover (using registrationId as identifier)\n store.setHighlightedId(registrationId)\n },\n [disabled, aimGuard, depth, store, registrationId],\n )\n\n // Context value for child components\n const contextValue: ItemContextValue = React.useMemo(\n () => ({\n id: domId,\n highlighted: isHighlighted,\n disabled,\n shortcut,\n }),\n [domId, isHighlighted, disabled, shortcut],\n )\n\n // Register a custom select handler (for checkbox/radio items)\n const registerSelect = React.useCallback(\n (handler: (() => void) | undefined) => {\n if (!registrationId) return () => {}\n return store.registerItemSelect(registrationId, handler)\n },\n [store, registrationId],\n )\n\n const handlers = React.useMemo(\n () => ({\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n }),\n [handleClick, handlePointerMove, handlePointerDown],\n )\n\n return {\n id: domId,\n storeId: registrationId,\n ref,\n isHighlighted,\n isVisible,\n contextValue,\n handlers,\n registerSelect,\n }\n}\n","/**\n * Normalizes a value string for use in filtering and identification.\n * Trims leading/trailing whitespace to match cmdk's behavior.\n *\n * @param value - The value to normalize\n * @returns The trimmed value, or empty string if value is nullish\n */\nexport function normalizeValue(value: string | undefined | null): string {\n return value?.trim() ?? ''\n}\n\n/**\n * Converts a value string to a URL-safe slug for use in IDs.\n * - Trims whitespace\n * - Converts to lowercase\n * - Replaces spaces with hyphens\n * - Removes non-alphanumeric characters (except hyphens)\n * - Collapses multiple hyphens into one\n * - Removes leading/trailing hyphens\n *\n * @example\n * slugify(\"User Settings\") // \"user-settings\"\n * slugify(\" Hello World! \") // \"hello-world\"\n * slugify(\"Café & Co.\") // \"caf-co\"\n *\n * @param value - The value to slugify\n * @returns The slugified value, or empty string if value is nullish\n */\nexport function slugify(value: string | undefined | null): string {\n if (!value) return ''\n\n return (\n value\n .trim()\n .toLowerCase()\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove non-alphanumeric characters (except hyphens)\n .replace(/[^a-z0-9-]/g, '')\n // Collapse multiple hyphens into one\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n )\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-FWWOE2SW.cjs","../src/internal/listbox/contexts/group-context.ts","../src/internal/listbox/contexts/item-context.ts","../src/internal/listbox/contexts/listbox-context.ts","../src/internal/listbox/contexts/row-width-context.ts","../src/internal/listbox/contexts/surface-context.ts","../src/internal/listbox/hooks/use-listbox-item.ts","../src/internal/listbox/utils/normalize.ts"],"names":["GroupContext","useGroupContext","ItemContext","useItemContext","context","useMaybeItemContext","ListboxContext","useListboxContext","useMaybeListboxContext","RowWidthContext","useRowWidthContext","useMaybeRowWidthContext","SurfaceContext","useSurfaceContext","useMaybeSurfaceContext","normalizeValue","value","slugify","useListboxItem","params","idProp","valueProp","keywords","disabled","forceMount","shortcut","forceOrder","forceScore","isSubmenuTrigger","onSelect","closeOnClick","onAfterSelect","children","aimGuard","store","groupContext","depth","ref","inferredValue","setInferredValue","textContent","registrationId","generatedDomId","domId"],"mappings":"AAAA,2/BAAyC,uWCElB,IAUjBA,EAAAA,CAAqB,CAAA,CAAA,aAAA,CAAwC,IAAI,CAAA,CAEhE,SAASC,CAAAA,CAAAA,CAA4C,CAC1D,OAAa,CAAA,CAAA,UAAA,CAAWD,EAAY,CACtC,CCdA,IAiBME,CAAAA,CAAoB,CAAA,CAAA,aAAA,CAAuC,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AAA,CAAAmC,CAAM,CAAA,CAAI7B,CAAAA,CAAkB,CAAA,CAE9B8B,CAAAA,CAAY,CAAA,CAAA,MAAA,CAAuB,IAAI,CAAA,CAGvC,CAACC,CAAAA,CAAeC,CAAgB,CAAA,CAAU,CAAA,CAAA,QAAA,CAAiB,EAAE,CAAA,CAE7D,CAAA,CAAA,eAAA,CAAgB,CAAA,CAAA,EAAM,CAC1B,EAAA,CAAInB,CAAAA,GAAW,KAAA,CAAA,EAAaC,CAAAA,GAAc,KAAA,CAAA,EAAagB,CAAAA,CAAI,OAAA,CAAS,CAClE,IAAMG,CAAAA,kCAAcH,CAAAA,qBAAI,OAAA,qBAAQ,WAAA,6BAAa,IAAA,mBAAK,GAAA,SAAK,IAAA,CACvDE,CAAAA,CAAiBC,CAAW,CAC9B,CACF,CAAA,CAAG,CAACpB,CAAAA,CAAQC,CAAAA,CAAWW,CAAQ,CAAC,CAAA,CAKhC,IAAMS,CAAAA,kBAAiBrB,CAAAA,SAAAA,CAAWL,CAAAA,CAAeM,CAAS,CAAA,EAAKiB,CAAAA,GAAAA,CAKzDI,CAAAA,CAAuB,CAAA,CAAA,KAAA,CAAM,CAAA,CAC7BC,CAAAA,kBAAQvB,CAAAA,SAAU,CAAA,KAAA,EAAQsB,CAAc,CAAA,GAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-FWWOE2SW.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Group Context (for items to know their parent group)\n// ============================================================================\n\nexport interface GroupContextValue {\n groupId: string\n}\n\nconst GroupContext = React.createContext<GroupContextValue | null>(null)\n\nexport function useGroupContext(): GroupContextValue | null {\n return React.useContext(GroupContext)\n}\n\nexport { GroupContext }\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Item Context (for child components like indicators to access item state)\n// ============================================================================\n\nexport interface ItemContextValue {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Keyboard shortcut for this item */\n shortcut?: string\n}\n\nconst ItemContext = React.createContext<ItemContextValue | null>(null)\n\nexport function useItemContext(): ItemContextValue {\n const context = React.useContext(ItemContext)\n if (!context) {\n throw new Error('Item child components must be used within an Item')\n }\n return context\n}\n\nexport function useMaybeItemContext(): ItemContextValue | null {\n return React.useContext(ItemContext)\n}\n\nexport { ItemContext }\n","'use client'\n\nimport * as React from 'react'\nimport type { HighlightChangeEventDetails } from '../../popup-menu/events.js'\nimport type { ListboxStore, VirtualItem } from '../store/ListboxStore.js'\n\n/**\n * Virtualization configuration passed from Root/Submenu to Surface.\n */\nexport interface VirtualizationConfig {\n /** Whether virtualization mode is enabled */\n virtualized: boolean\n /** Pre-registered items for virtualization */\n items: VirtualItem[]\n /**\n * Callback when highlighted item changes (for scroll sync).\n * The third parameter contains event details including the reason for the change.\n */\n onHighlightChange?: (\n id: string | null,\n index: number,\n eventDetails: HighlightChangeEventDetails,\n ) => void\n}\n\nexport interface ListboxContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Nesting depth: 0 = root menu, 1+ = submenu */\n depth: number\n /** Close the entire menu tree (deepest submenu to root, sequentially) */\n closeAll: () => void\n /** Register a surface (submenu) for closeAll tracking. Returns unregister function. */\n registerSurface: (\n depth: number,\n setOpen: (open: boolean) => void,\n ) => () => void\n /** Virtualization configuration (if enabled) */\n virtualization?: VirtualizationConfig\n}\n\nconst ListboxContext = React.createContext<ListboxContextValue | null>(null)\n\nexport function useListboxContext(): ListboxContextValue {\n const context = React.useContext(ListboxContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Listbox provider')\n }\n return context\n}\n\nexport function useMaybeListboxContext(): ListboxContextValue | null {\n return React.useContext(ListboxContext)\n}\n\nexport { ListboxContext }\n","'use client'\n\nimport * as React from 'react'\n\n/**\n * Context value for row width measurement.\n * Provided by List when `measureRowWidth` is enabled.\n */\nexport interface RowWidthContextValue {\n /**\n * Queue a row element for width measurement.\n * Call this when a row mounts or becomes visible.\n *\n * @param element - The DOM element to measure\n * @param id - Unique identifier for this row (used to avoid re-measuring)\n */\n queueMeasurement: (element: HTMLElement, id: string) => void\n}\n\n/**\n * Context for row width measurement.\n * Items use this to self-register for measurement.\n */\nexport const RowWidthContext = React.createContext<RowWidthContextValue | null>(\n null,\n)\n\nif (process.env.NODE_ENV !== 'production') {\n RowWidthContext.displayName = 'RowWidthContext'\n}\n\n/**\n * Hook to get the row width context.\n * Throws an error if used outside of a List with `measureRowWidth` enabled.\n */\nexport function useRowWidthContext(): RowWidthContextValue {\n const context = React.useContext(RowWidthContext)\n if (!context) {\n throw new Error(\n 'useRowWidthContext must be used within a List with measureRowWidth enabled',\n )\n }\n return context\n}\n\n/**\n * Hook to optionally get the row width context.\n * Returns null if not within a List with `measureRowWidth` enabled.\n * This is the preferred hook for items that should work both with and without measurement.\n */\nexport function useMaybeRowWidthContext(): RowWidthContextValue | null {\n return React.useContext(RowWidthContext)\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ListboxStore } from '../store/ListboxStore.js'\n\n// Re-export types from the store for convenience\nexport type {\n FilterFn,\n ItemRegistration,\n} from '../store/ListboxStore.js'\n\n// ============================================================================\n// Surface Context\n// ============================================================================\n\nexport interface SurfaceContextValue {\n /** The Listbox store instance */\n store: ListboxStore\n /** Unique identifier for this surface */\n surfaceId: string\n}\n\nconst SurfaceContext = React.createContext<SurfaceContextValue | null>(null)\n\nexport function useSurfaceContext(): SurfaceContextValue {\n const context = React.useContext(SurfaceContext)\n if (!context) {\n throw new Error('Listbox components must be used within a Surface provider')\n }\n return context\n}\n\nexport function useMaybeSurfaceContext(): SurfaceContextValue | null {\n return React.useContext(SurfaceContext)\n}\n\nexport { SurfaceContext }\n","'use client'\n\nimport * as React from 'react'\nimport { useGroupContext } from '../contexts/group-context.js'\nimport type { ItemContextValue } from '../contexts/item-context.js'\nimport { useListboxContext } from '../contexts/listbox-context.js'\nimport { useMaybeRowWidthContext } from '../contexts/row-width-context.js'\nimport { useSurfaceContext } from '../contexts/surface-context.js'\nimport { normalizeValue } from '../utils/normalize.js'\n\n/**\n * Aim guard refs for submenu navigation.\n * Optional - only needed for popup menus with submenus.\n */\nexport interface AimGuardRefs {\n /** Whether aim guard is currently active */\n aimGuardActiveRef: React.RefObject<boolean>\n /** The depth at which aim guard is active (null when not guarding) */\n guardedDepthRef: React.RefObject<number | null>\n}\n\n/**\n * Parameters for the useListboxItem hook.\n */\nexport interface UseListboxItemParams {\n /**\n * Explicit unique identifier for this item in the store.\n * Takes highest priority for item registration.\n * Used by data-first APIs to ensure consistent IDs.\n */\n id?: string\n\n /**\n * Unique value for this item used as identifier and for filtering.\n * If not provided, will be inferred from textContent.\n * Used for registration when `id` is not provided.\n */\n value?: 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 * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n\n /**\n * Keyboard shortcut to trigger this item.\n * When the menu is focused and the user presses this key, the item will be selected.\n * Should be a single character (e.g., \"1\", \"a\", etc.).\n */\n shortcut?: string\n\n /**\n * Forces this row's relative order during score-based sorting.\n * Lower values appear earlier.\n * @default 0\n */\n forceOrder?: number\n\n /**\n * Overrides this row's computed fuzzy-match score.\n * Useful for pinning or manually ranking rows in score-based views.\n */\n forceScore?: number\n\n /**\n * Whether this item is a submenu trigger (for store registration).\n * @default false\n */\n isSubmenuTrigger?: boolean\n\n /**\n * Callback when this item is selected (via click or Enter key).\n * For simple items, pass this directly. For checkbox/radio items,\n * use registerSelect() to register a dynamic handler.\n */\n onSelect?: () => void\n\n /**\n * Whether selecting this item should close the menu.\n * @default true\n */\n closeOnClick?: boolean\n\n /**\n * Callback invoked after selection occurs (via click).\n * Called with the item's ID. The consumer handles any\n * post-selection behavior like closing menus.\n */\n onAfterSelect?: (itemId: string) => void\n\n /**\n * Children (used for text content inference when value is not provided).\n */\n children?: React.ReactNode\n\n /**\n * Optional aim guard refs for popup menu navigation.\n * When provided, pointer move events will respect the aim guard.\n */\n aimGuard?: AimGuardRefs\n}\n\n/**\n * Return value from the useListboxItem hook.\n */\nexport interface UseListboxItemReturn {\n /** Unique ID for this item (DOM ID for aria-activedescendant) */\n id: string\n\n /**\n * Store identifier for this item.\n * Use this when calling store methods like setHighlightedId, registerSubmenuOpen, etc.\n * This is the `value` prop (or inferred from textContent).\n */\n storeId: string\n\n /** Ref to attach to the item element */\n ref: React.RefObject<HTMLDivElement | null>\n\n /** Whether item is currently highlighted */\n isHighlighted: boolean\n\n /** Whether item should be rendered (passes filter) */\n isVisible: boolean\n\n /** Context value to provide to children via ItemContext.Provider */\n contextValue: ItemContextValue\n\n /**\n * Event handlers to spread on the element.\n * These handle click, pointer move, and pointer down events.\n */\n handlers: {\n onClick: React.MouseEventHandler<HTMLDivElement>\n onPointerMove: React.PointerEventHandler<HTMLDivElement>\n onPointerDown: React.PointerEventHandler<HTMLDivElement>\n }\n\n /**\n * Register a custom onSelect handler.\n * This is useful for checkbox/radio items where the select behavior\n * needs to be customized (e.g., toggle checked state).\n * Returns an unregister function.\n */\n registerSelect: (handler: (() => void) | undefined) => () => void\n}\n\n/**\n * Hook that provides all shared logic for navigatable/highlightable listbox items.\n *\n * This hook handles:\n * - Item registration with the listbox store\n * - Highlight state management (keyboard and pointer)\n * - Filter/search visibility\n * - Scroll into view on keyboard navigation\n * - Click, pointer move, and pointer down event handlers\n * - Optional aim guard integration (for submenu navigation)\n *\n * @example\n * ```tsx\n * function CustomItem(props) {\n * const item = useListboxItem({\n * value: props.value,\n * disabled: props.disabled,\n * onSelect: props.onSelect,\n * })\n *\n * if (!item.isVisible) return null\n *\n * return (\n * <ItemContext.Provider value={item.contextValue}>\n * <div\n * ref={item.ref}\n * {...item.handlers}\n * data-highlighted={item.isHighlighted || undefined}\n * >\n * {props.children}\n * </div>\n * </ItemContext.Provider>\n * )\n * }\n * ```\n */\nexport function useListboxItem(\n params: UseListboxItemParams,\n): UseListboxItemReturn {\n const {\n id: idProp,\n value: valueProp,\n keywords,\n disabled = false,\n forceMount = false,\n shortcut,\n forceOrder,\n forceScore,\n isSubmenuTrigger = false,\n onSelect,\n closeOnClick = true,\n onAfterSelect,\n children,\n aimGuard,\n } = params\n\n const { store } = useSurfaceContext()\n const groupContext = useGroupContext()\n const { depth } = useListboxContext()\n\n const ref = React.useRef<HTMLDivElement>(null)\n\n // Infer value from textContent if not provided\n const [inferredValue, setInferredValue] = React.useState<string>('')\n\n React.useLayoutEffect(() => {\n if (idProp === undefined && valueProp === undefined && ref.current) {\n const textContent = ref.current.textContent?.trim() ?? ''\n setInferredValue(textContent)\n }\n }, [idProp, valueProp, children])\n\n // Registration ID priority: id prop > value prop > textContent inference\n // This ensures data-first APIs can provide explicit IDs that match their internal tracking\n // Note: valueProp is normalized (trimmed) to match cmdk's behavior\n const registrationId = idProp ?? (normalizeValue(valueProp) || inferredValue)\n\n // Generate a stable ID for DOM id attribute (aria-activedescendant, etc.)\n // When id prop is provided (data-first APIs), use it directly for DOM ID\n // This ensures aria-activedescendant works correctly with composite IDs\n const generatedDomId = React.useId()\n const domId = idProp ?? `item-${generatedDomId}`\n\n // Stabilize keywords to prevent infinite loops when passed as inline arrays\n // We use JSON.stringify to compare by value rather than reference\n // Keywords are also normalized (trimmed) to match cmdk's behavior\n const normalizedKeywords = keywords\n ?.map((k) => normalizeValue(k))\n .filter(Boolean)\n const keywordsKey = normalizedKeywords\n ? JSON.stringify(normalizedKeywords)\n : undefined\n\n // Register item with store (using registrationId as the unique identifier)\n React.useEffect(() => {\n if (!registrationId && !forceMount) return\n\n const unregister = store.registerItem(registrationId, {\n value: registrationId,\n keywords: normalizedKeywords,\n groupId: groupContext?.groupId,\n disabled,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n })\n\n return unregister\n // eslint-disable-next-line react-hooks/exhaustive-deps -- keywordsKey is a stable representation of keywords\n }, [\n registrationId,\n keywordsKey,\n groupContext?.groupId,\n disabled,\n isSubmenuTrigger,\n shortcut,\n forceOrder,\n forceScore,\n closeOnClick,\n store,\n forceMount,\n ])\n\n // Register DOM ref with store for scroll behavior\n React.useEffect(() => {\n if (!registrationId) return\n return store.registerItemRef(registrationId, ref)\n }, [registrationId, store])\n\n // Register for row width measurement if enabled\n const rowWidthContext = useMaybeRowWidthContext()\n\n React.useLayoutEffect(() => {\n if (rowWidthContext && ref.current && registrationId) {\n rowWidthContext.queueMeasurement(ref.current, registrationId)\n }\n }, [rowWidthContext, registrationId])\n\n // Register onSelect handler if provided directly\n React.useEffect(() => {\n if (!onSelect || !registrationId) return\n return store.registerItemSelect(registrationId, onSelect)\n }, [registrationId, onSelect, store])\n\n // Use selectors to get derived state (using registrationId as identifier)\n const normalizedSearch = store.useState('normalizedSearch')\n const isHighlighted = store.useState('isHighlighted', registrationId)\n const score = store.useState('getItemScore', registrationId)\n\n // Check if filtering is disabled (consumer handles filtering externally)\n const filterDisabled = store.isFilterDisabled()\n\n // Determine visibility based on filter score\n // When filterDisabled, consumer handles filtering so all items are visible\n const hasSearch = normalizedSearch.length > 0\n const isVisible = forceMount || filterDisabled || !hasSearch || score > 0\n\n // Note: Scroll behavior is now handled by the store's setHighlightedId method.\n // It uses the registered DOM refs to call scrollIntoView when the element exists,\n // or falls back to onHighlightChange for virtualizer sync.\n\n // Event handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n event.preventDefault()\n\n // Call the registered onSelect handler via store\n const registeredHandler = store.context.itemSelects.get(registrationId)\n registeredHandler?.()\n\n // Notify consumer that selection occurred (for closing menus, etc.)\n onAfterSelect?.(registrationId)\n },\n [disabled, store, registrationId, onAfterSelect],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return\n if (disabled) return\n if (!registrationId) return\n\n // Don't highlight if aim guard is active at this depth (user is moving toward submenu)\n // Only block highlighting in the same menu where the trigger is located\n if (aimGuard) {\n const { aimGuardActiveRef, guardedDepthRef } = aimGuard\n if (aimGuardActiveRef.current && guardedDepthRef.current === depth)\n return\n }\n\n // Check if pointer has actually moved - prevents phantom highlights when\n // content shifts under a stationary pointer (e.g., search results changing)\n if (!store.shouldAllowPointerHighlight(event.clientX, event.clientY)) {\n return\n }\n\n // Highlight on hover (using registrationId as identifier)\n store.setHighlightedId(registrationId)\n },\n [disabled, aimGuard, depth, store, registrationId],\n )\n\n // Context value for child components\n const contextValue: ItemContextValue = React.useMemo(\n () => ({\n id: domId,\n highlighted: isHighlighted,\n disabled,\n shortcut,\n }),\n [domId, isHighlighted, disabled, shortcut],\n )\n\n // Register a custom select handler (for checkbox/radio items)\n const registerSelect = React.useCallback(\n (handler: (() => void) | undefined) => {\n if (!registrationId) return () => {}\n return store.registerItemSelect(registrationId, handler)\n },\n [store, registrationId],\n )\n\n const handlers = React.useMemo(\n () => ({\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n }),\n [handleClick, handlePointerMove, handlePointerDown],\n )\n\n return {\n id: domId,\n storeId: registrationId,\n ref,\n isHighlighted,\n isVisible,\n contextValue,\n handlers,\n registerSelect,\n }\n}\n","/**\n * Normalizes a value string for use in filtering and identification.\n * Trims leading/trailing whitespace to match cmdk's behavior.\n *\n * @param value - The value to normalize\n * @returns The trimmed value, or empty string if value is nullish\n */\nexport function normalizeValue(value: string | undefined | null): string {\n return value?.trim() ?? ''\n}\n\n/**\n * Converts a value string to a URL-safe slug for use in IDs.\n * - Trims whitespace\n * - Converts to lowercase\n * - Replaces spaces with hyphens\n * - Removes non-alphanumeric characters (except hyphens)\n * - Collapses multiple hyphens into one\n * - Removes leading/trailing hyphens\n *\n * @example\n * slugify(\"User Settings\") // \"user-settings\"\n * slugify(\" Hello World! \") // \"hello-world\"\n * slugify(\"Café & Co.\") // \"caf-co\"\n *\n * @param value - The value to slugify\n * @returns The slugified value, or empty string if value is nullish\n */\nexport function slugify(value: string | undefined | null): string {\n if (!value) return ''\n\n return (\n value\n .trim()\n .toLowerCase()\n // Replace spaces with hyphens\n .replace(/\\s+/g, '-')\n // Remove non-alphanumeric characters (except hyphens)\n .replace(/[^a-z0-9-]/g, '')\n // Collapse multiple hyphens into one\n .replace(/-+/g, '-')\n // Remove leading/trailing hyphens\n .replace(/^-|-$/g, '')\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-JSPKF52O.cjs","../src/internal/popup-menu/contexts/component-name-context.ts"],"names":["ComponentNameContext","useComponentName","context","useMaybeComponentName","getSlotAttribute","componentName","partName"],"mappings":"AAAA,2/BAAyL,iyECElK,IAYVA,EAAAA,CAA6B,EAAA,CAAA,aAAA,CACxC,IACF,CAAA,CAMO,SAASC,EAAAA,CAAAA,CAAkC,CAChD,IAAMC,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWF,EAAoB,CAAA,CACrD,EAAA,CAAIE,CAAAA,GAAY,IAAA,CACd,MAAM,IAAI,KAAA,CACR,sEACF,CAAA,CAEF,OAAOA,CACT,CAMO,SAASC,CAAAA,CAAAA,CAA8C,CAC5D,OAAa,EAAA,CAAA,UAAA,CAAWH,EAAoB,CAC9C,CAQO,SAASI,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACoB,CACpB,EAAA,CAAKD,CAAAA,CACL,MAAO,CAAA,QAAA,EAAWA,CAAa,CAAA,CAAA,EAAIC,CAAQ,CAAA,CAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-JSPKF52O.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\n\n/**\n * Component name used for generating bazzaui-* slot attributes.\n * E.g., 'dropdown-menu', 'context-menu', 'select', 'combobox'\n */\nexport type ComponentName =\n | 'dropdown-menu'\n | 'context-menu'\n | 'select'\n | 'combobox'\n\nexport const ComponentNameContext = React.createContext<ComponentName | null>(\n null,\n)\n\n/**\n * Returns the component name from context.\n * Throws if used outside of a component that provides the context.\n */\nexport function useComponentName(): ComponentName {\n const context = React.useContext(ComponentNameContext)\n if (context === null) {\n throw new Error(\n 'useComponentName must be used within a ComponentNameContext.Provider',\n )\n }\n return context\n}\n\n/**\n * Returns the component name from context, or null if not available.\n * Useful for internal components that may be used outside the popup-menu context.\n */\nexport function useMaybeComponentName(): ComponentName | null {\n return React.useContext(ComponentNameContext)\n}\n\n/**\n * Helper to generate a bazzaui slot attribute value.\n * @param componentName The component name (e.g., 'dropdown-menu')\n * @param partName The part name (e.g., 'trigger', 'item')\n * @returns The slot attribute value (e.g., 'bazzaui-dropdown-menu-trigger')\n */\nexport function getSlotAttribute(\n componentName: ComponentName | null,\n partName: string,\n): string | undefined {\n if (!componentName) return undefined\n return `bazzaui-${componentName}-${partName}`\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-M4G6J7DP.cjs"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/chunk-M4G6J7DP.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/combobox/index.cjs","../../src/combobox/index.parts.ts","../../src/combobox/clear/clear.tsx","../../src/combobox/clear/clear.data-attrs.ts","../../src/combobox/contexts/combobox-positioner-context.ts","../../src/combobox/input/input.tsx","../../src/combobox/input-wrapper/input-wrapper-context.ts","../../src/combobox/input/input.data-attrs.ts","../../src/combobox/input/use-combobox-display-value.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","ComboboxClear","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","ComboboxInput","ComboboxInputWrapper","ComboboxItem","ComboboxItemIndicator","ComboboxItemLabel","PopupMenuList","PopupMenuPopup","PopupMenuPortal","ComboboxPositioner","ComboboxRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","ComboboxSurface","useComboboxPositionerContext","ComboboxClearDataAttributes","props","forwardedRef","keepMounted","disabledProp","render","className","style","onClick","rest","comboboxContext","useComboboxContext","disabled","hasValue","handleClick","event","handlePointerDown","state","element","useRender","ComboboxPositionerContext","ComboboxInputWrapperContext","useIsInsideInputWrapper","ComboboxInputDataAttributes","resolveLabelFromItems","items","value","label","i","useComboboxDisplayValue","params","open","getValueText","serializedValue","stringifyAsValue","registryText","itemsLabel","resolvedLabel","resolveLabel","selectedLabel","texts","v","text"],"mappings":"AAAA,4/BAAkE,yDAAgQ,yDAAkF,yDAA2C,ICA/bA,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,EAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,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AAA,CAAA,CAAkBA,CAAAA,CAG7BJ,kCAAAA,CAAaG,CAAG/B,CAAAA,CAAgB,iBAAiB,CAAA,EACjDwB,kCAAAA,CAAiBO,CAAG/B,CAAAA,CAAgB,iBAAiB,CAEzD,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA,CACjB,OAAI8B,CAAAA,CAAM,MAAA,EAAU,CAAA,CACXA,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAA,CAEjB,CAAA,EAAA","file":"/home/runner/work/ui/ui/packages/react/dist/combobox/index.cjs","sourcesContent":[null,"// ============================================================================\n// Combobox Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Combobox-specific\n// Root, Input, 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 // Icon\n PopupMenuIcon as Icon,\n PopupMenuList as List,\n PopupMenuPopup as Popup,\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 { ComboboxClear as Clear } from './clear/clear.js'\nexport { useComboboxPositionerContext } from './contexts/combobox-positioner-context.js'\nexport { ComboboxInput as Input } from './input/input.js'\nexport { ComboboxInputWrapper as InputWrapper } from './input-wrapper/input-wrapper.js'\nexport { ComboboxItem as Item } from './item/item.js'\nexport { ComboboxItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { ComboboxItemLabel as ItemLabel } from './item-label/item-label.js'\nexport { ComboboxPositioner as Positioner } from './positioner/positioner.js'\n// Combobox-specific components\nexport { ComboboxRoot as Root } from './root/root.js'\nexport { ComboboxSurface as Surface } from './surface/surface.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useComboboxContext } from '../contexts/combobox-context.js'\nimport { ComboboxClearDataAttributes } from './clear.data-attrs.js'\n\nexport { ComboboxClearDataAttributes }\n\nexport interface ComboboxClearState extends Record<string, unknown> {\n /**\n * Whether the combobox has a value (clear button is actionable).\n */\n hasValue: boolean\n /**\n * Whether the combobox is disabled.\n */\n disabled: boolean\n}\n\nexport interface ComboboxClearProps\n extends ComponentProps<'button', ComboboxClear.State> {\n /**\n * Whether to render the button even when there's no value to clear.\n * @default false\n */\n keepMounted?: boolean\n}\n\n/**\n * A button that clears the selected value(s) when clicked.\n * Renders a `<button>` element.\n */\nexport const ComboboxClear = React.forwardRef<\n HTMLButtonElement,\n ComboboxClear.Props\n>(function ComboboxClear(props, forwardedRef) {\n const {\n keepMounted = false,\n disabled: disabledProp,\n render,\n className,\n style,\n onClick,\n ...rest\n } = props\n\n const comboboxContext = useComboboxContext()\n\n const disabled = disabledProp ?? comboboxContext.disabled\n\n const hasValue = comboboxContext.multiple\n ? comboboxContext.values.length > 0\n : comboboxContext.value !== ''\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n\n if (comboboxContext.multiple) {\n comboboxContext.onValuesChange([])\n } else {\n comboboxContext.onValueChange('')\n }\n\n // Also clear the input value\n comboboxContext.onInputValueChange('')\n },\n [onClick, comboboxContext],\n )\n\n // Prevent pointer down from stealing focus from the input\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLButtonElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const state: ComboboxClear.State = React.useMemo(\n () => ({\n hasValue,\n disabled,\n }),\n [hasValue, disabled],\n )\n\n const element = useRender({\n render,\n ref: forwardedRef,\n state,\n props: {\n ...rest,\n [ComboboxClearDataAttributes.slot]: '',\n type: 'button',\n tabIndex: -1, // Not tabbable - use keyboard shortcuts instead\n 'aria-label': 'Clear selection',\n disabled: disabled || !hasValue,\n className,\n style,\n onClick: handleClick,\n onPointerDown: handlePointerDown,\n },\n enabled: keepMounted || hasValue,\n defaultTagName: 'button',\n })\n\n // Don't render if no value and not keepMounted\n if (!keepMounted && !hasValue) {\n return null\n }\n\n return element\n})\n\nexport namespace ComboboxClear {\n export type State = ComboboxClearState\n export interface Props extends ComboboxClearProps {}\n}\n","/**\n * Data attributes for ComboboxClear component.\n */\nexport const ComboboxClearDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-combobox-clear'}\n */\n slot: 'bazzaui-combobox-clear',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Types\n// ============================================================================\n\n// Types matching Base UI's positioning types\nexport type Side = 'top' | 'bottom' | 'left' | 'right'\nexport type Align = 'start' | 'center' | 'end'\n\n/**\n * Layout mode for the combobox popup.\n * - `'floating'` - Standard dropdown positioning below/above the input\n * - `'input-embedded'` - Popup wraps around the input (macOS-style)\n */\nexport type ComboboxLayout = 'floating' | 'input-embedded'\n\n/**\n * Context value for Combobox Positioner.\n * Provides alignment state for coordinating positioning behavior.\n */\nexport interface ComboboxPositionerContextValue {\n /**\n * The layout mode being used.\n * - `'floating'` - Standard dropdown positioning\n * - `'input-embedded'` - Popup wraps around the input\n */\n layout: ComboboxLayout\n\n /**\n * The side of the popup relative to the input.\n */\n side: Side\n\n /**\n * The alignment of the popup.\n */\n align: Align\n\n /**\n * Height of the input element in pixels.\n * Use this to add appropriate padding to the popup.\n */\n inputHeight: number\n}\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst ComboboxPositionerContext =\n React.createContext<ComboboxPositionerContextValue | null>(null)\n\n/**\n * Hook to access the Combobox Positioner context.\n * Returns null if used outside a ComboboxPositioner.\n */\nexport function useComboboxPositionerContext(): ComboboxPositionerContextValue | null {\n return React.useContext(ComboboxPositionerContext)\n}\n\nexport { ComboboxPositionerContext }\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { useFocusOwner } from '../../internal/popup-menu/contexts/focus-owner-context.js'\nimport { usePopupMenuContext } from '../../internal/popup-menu/contexts/popup-menu-context.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useComboboxContext } from '../contexts/combobox-context.js'\nimport { useIsInsideInputWrapper } from '../input-wrapper/input-wrapper-context.js'\nimport { ComboboxInputDataAttributes } from './input.data-attrs.js'\nimport { useComboboxDisplayValue } from './use-combobox-display-value.js'\nimport { useComboboxInputBehavior } from './use-combobox-input-behavior.js'\n\nexport { ComboboxInputDataAttributes }\n\nexport interface ComboboxInputState extends Record<string, unknown> {\n /**\n * Whether the combobox popup is open.\n */\n open: boolean\n /**\n * Whether the input is disabled.\n */\n disabled: boolean\n /**\n * Whether the input currently shows placeholder (no value selected).\n */\n placeholder: boolean\n}\n\n/**\n * Cursor behavior when the combobox popup opens.\n * - `'none'` - Don't move the cursor (cursor appears where clicked)\n * - `'end'` - Move cursor to the end of the input\n * - `'select-all'` - Move cursor to the end and select all text\n */\nexport type ComboboxInputCursorBehavior = 'none' | 'end' | 'select-all'\n\nexport interface ComboboxInputProps\n extends Omit<\n ComponentProps<'input', ComboboxInput.State>,\n 'value' | 'onChange' | 'type'\n > {\n /**\n * Placeholder text shown when no value is selected and input is empty.\n * Overrides the placeholder set on Combobox.Root.\n */\n placeholder?: string\n\n /**\n * Cursor behavior when the combobox popup opens.\n * - `'none'` - Don't move the cursor (cursor appears where clicked)\n * - `'end'` - Move cursor to the end of the input\n * - `'select-all'` - Move cursor to the end and select all text\n *\n * @default 'none'\n */\n cursorBehavior?: ComboboxInputCursorBehavior\n}\n\n/**\n * An input that acts as both the trigger and search field for the combobox.\n * Renders an `<input>` element with combobox ARIA semantics.\n */\nexport const ComboboxInput = React.forwardRef<\n HTMLInputElement,\n ComboboxInput.Props\n>(function ComboboxInput(props, forwardedRef) {\n const {\n placeholder: placeholderProp,\n disabled: disabledProp,\n cursorBehavior = 'none',\n render,\n className,\n style,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n ...rest\n } = props\n\n const comboboxContext = useComboboxContext()\n const popupMenuContext = usePopupMenuContext()\n const focusOwnerStore = useFocusOwner()\n const isInsideInputWrapper = useIsInsideInputWrapper()\n\n const disabled =\n (disabledProp ?? comboboxContext.disabled) || popupMenuContext.disabled\n const placeholder = placeholderProp ?? comboboxContext.placeholder\n\n // Get open state\n const open = popupMenuContext.store.useState('open')\n\n // Use display value hook\n const { hasValue, displayValue, getValueText } = useComboboxDisplayValue({\n comboboxContext,\n open,\n })\n\n // Use input behavior hook\n const { handleChange, handleFocus, handleBlur, handleClick, handleKeyDown } =\n useComboboxInputBehavior({\n comboboxContext,\n store: popupMenuContext.store,\n focusOwnerStore,\n open,\n disabled,\n cursorBehavior,\n hasValue,\n getValueText,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n })\n\n // Build data attributes\n const dataAttrs: Record<string, string> = {\n [ComboboxInputDataAttributes.slot]: '',\n }\n if (open) {\n dataAttrs[ComboboxInputDataAttributes.open] = ''\n } else {\n dataAttrs[ComboboxInputDataAttributes.closed] = ''\n }\n if (disabled) {\n dataAttrs[ComboboxInputDataAttributes.disabled] = ''\n }\n if (!hasValue) {\n dataAttrs[ComboboxInputDataAttributes.placeholder] = ''\n }\n // Add input-embedded data attribute when layout is input-embedded\n if (comboboxContext.layout === 'input-embedded') {\n dataAttrs['data-input-embedded'] = ''\n }\n\n // Register input element for positioning\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n comboboxContext.setInputElement(node)\n if (typeof forwardedRef === 'function') {\n forwardedRef(node)\n } else if (forwardedRef) {\n forwardedRef.current = node\n }\n },\n [forwardedRef, comboboxContext],\n )\n\n const state: ComboboxInput.State = React.useMemo(\n () => ({\n open,\n disabled,\n placeholder: !hasValue,\n }),\n [open, disabled, hasValue],\n )\n\n // When input-embedded layout, apply styles to position input above the popup\n // Skip z-index if inside an InputWrapper (the wrapper handles z-index)\n const inputEmbeddedStyles: React.CSSProperties | undefined =\n comboboxContext.layout === 'input-embedded' && !isInsideInputWrapper\n ? { position: 'relative', zIndex: 1 }\n : undefined\n\n const element = useRender({\n render,\n ref: mergedRef,\n state,\n props: {\n ...rest,\n ...dataAttrs,\n type: 'text',\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': open,\n 'aria-controls': comboboxContext.listId,\n 'aria-haspopup': 'listbox',\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: false,\n disabled,\n placeholder: !hasValue ? placeholder : undefined,\n className,\n style: { ...inputEmbeddedStyles, ...style },\n value: displayValue,\n onChange: handleChange,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n },\n defaultTagName: 'input',\n })\n\n return element\n})\n\nexport namespace ComboboxInput {\n export interface Props extends ComboboxInputProps {}\n export type State = ComboboxInputState\n}\n","import * as React from 'react'\n\n/**\n * Context to indicate that children are inside an InputWrapper.\n * When true, Input should not apply its own z-index styles for input-embedded layout.\n */\nexport const ComboboxInputWrapperContext = React.createContext<boolean>(false)\n\n/**\n * Hook to check if component is inside a ComboboxInputWrapper.\n */\nexport function useIsInsideInputWrapper(): boolean {\n return React.useContext(ComboboxInputWrapperContext)\n}\n","/**\n * Data attributes for ComboboxInput component.\n */\nexport const ComboboxInputDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-combobox-input'}\n */\n slot: 'bazzaui-combobox-input',\n /** Present when the combobox popup is open. */\n open: 'data-open',\n /** Present when the combobox popup is closed. */\n closed: 'data-closed',\n /** Present when the input is disabled. */\n disabled: 'data-disabled',\n /** Present when no value is selected (showing placeholder). */\n placeholder: 'data-placeholder',\n} as const\n","'use client'\n\nimport * as React from 'react'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComboboxContextValue } from '../contexts/combobox-context.js'\n\n/**\n * Helper to resolve label from items prop\n */\nfunction resolveLabelFromItems(\n items:\n | Record<string, React.ReactNode>\n | Array<{ value: string; label: React.ReactNode }>\n | undefined,\n value: string,\n): string | undefined {\n if (!items) return undefined\n\n if (Array.isArray(items)) {\n const item = items.find((i) => i.value === value)\n const label = item?.label\n return typeof label === 'string' ? label : undefined\n }\n\n const label = items[value]\n return typeof label === 'string' ? label : undefined\n}\n\nexport interface UseComboboxDisplayValueParams<Value = unknown> {\n comboboxContext: ComboboxContextValue<Value>\n open: boolean\n}\n\nexport interface UseComboboxDisplayValueReturn<Value = unknown> {\n /** Whether a value is selected */\n hasValue: boolean\n /** The value to display in the input */\n displayValue: string\n /** The label of the selected value(s) */\n selectedLabel: string\n /** Get the display text for a value */\n getValueText: (value: Value) => string | undefined\n}\n\n/**\n * Hook to compute the display value for the combobox input.\n *\n * Handles:\n * - Determining if a value is selected (single or multi-select)\n * - Computing the display label for selected values\n * - Switching between selected label (closed) and input value (open)\n */\nexport function useComboboxDisplayValue<Value = unknown>(\n params: UseComboboxDisplayValueParams<Value>,\n): UseComboboxDisplayValueReturn<Value> {\n const { comboboxContext, open } = params\n\n // Determine if showing placeholder (no value selected)\n const hasValue = comboboxContext.multiple\n ? comboboxContext.values.length > 0\n : comboboxContext.value != null\n\n // Get the display text for selected value\n const getValueText = React.useCallback(\n (value: Value): string | undefined => {\n // Serialize for registry lookup\n const serializedValue = stringifyAsValue(\n value,\n comboboxContext.itemToStringValue,\n )\n\n // First try the registry (populated when items mount)\n const registryText = comboboxContext.itemTextRegistry.get(serializedValue)\n if (registryText !== undefined) {\n return registryText\n }\n\n // Fall back to the items prop (for initial render before popup opens)\n const itemsLabel = resolveLabelFromItems(\n comboboxContext.items,\n serializedValue,\n )\n if (itemsLabel !== undefined) {\n return itemsLabel\n }\n\n // Fall back to itemToStringLabel for object values\n const resolvedLabel = resolveLabel(\n value,\n comboboxContext.itemToStringLabel,\n )\n // Only return if it's different from the serialized value (meaning we got a real label)\n if (resolvedLabel && resolvedLabel !== serializedValue) {\n return resolvedLabel\n }\n\n return undefined\n },\n [\n comboboxContext.itemTextRegistry,\n comboboxContext.items,\n comboboxContext.itemToStringLabel,\n comboboxContext.itemToStringValue,\n ],\n )\n\n // Get the label for the selected value (used when closed or just opened)\n const selectedLabel = React.useMemo(() => {\n if (!hasValue) {\n return ''\n }\n if (comboboxContext.multiple) {\n // For multi-select, show comma-separated values or count\n const texts = comboboxContext.values\n .map((v) => {\n const text = getValueText(v)\n if (text !== undefined) return text\n // Fall back to resolved label or serialized value\n return (\n resolveLabel(v, comboboxContext.itemToStringLabel) ||\n stringifyAsValue(v, comboboxContext.itemToStringValue)\n )\n })\n .filter(Boolean)\n if (texts.length <= 2) {\n return texts.join(', ')\n }\n return `${texts.length} selected`\n }\n // Single-select: show the value's text\n const value = comboboxContext.value\n if (value == null) return ''\n\n const text = getValueText(value)\n if (text !== undefined) return text\n // Fall back to resolved label or serialized value\n return (\n resolveLabel(value, comboboxContext.itemToStringLabel) ||\n stringifyAsValue(value, comboboxContext.itemToStringValue)\n )\n }, [\n hasValue,\n comboboxContext.multiple,\n comboboxContext.value,\n comboboxContext.values,\n comboboxContext.itemToStringLabel,\n comboboxContext.itemToStringValue,\n getValueText,\n ])\n\n // Determine the display value for the input\n // When closed: show selected value's text\n // When open: show the search/filter text (inputValue)\n const displayValue = React.useMemo(() => {\n if (!open) {\n // When closed, show the selected value's label\n return selectedLabel\n }\n // When open, use the input value for filtering\n return comboboxContext.inputValue\n }, [open, selectedLabel, comboboxContext.inputValue])\n\n return {\n hasValue,\n displayValue,\n selectedLabel,\n getValueText,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/combobox/index.cjs","../../src/combobox/index.parts.ts","../../src/combobox/clear/clear.tsx","../../src/combobox/clear/clear.data-attrs.ts","../../src/combobox/contexts/combobox-positioner-context.ts","../../src/combobox/input/input.tsx","../../src/combobox/input-wrapper/input-wrapper-context.ts","../../src/combobox/input/input.data-attrs.ts","../../src/combobox/input/use-combobox-display-value.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","ComboboxClear","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","ComboboxInput","ComboboxInputWrapper","ComboboxItem","ComboboxItemIndicator","ComboboxItemLabel","PopupMenuList","PopupMenuPopup","PopupMenuPortal","ComboboxPositioner","ComboboxRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","ComboboxSurface","useComboboxPositionerContext","ComboboxClearDataAttributes","props","forwardedRef","keepMounted","disabledProp","render","className","style","onClick","rest","comboboxContext","useComboboxContext","disabled","hasValue","handleClick","event","handlePointerDown","state","element","useRender","ComboboxPositionerContext","ComboboxInputWrapperContext","useIsInsideInputWrapper","ComboboxInputDataAttributes","resolveLabelFromItems","items","value","label","i","useComboboxDisplayValue","params","open","getValueText","serializedValue","stringifyAsValue","registryText","itemsLabel","resolvedLabel","resolveLabel","selectedLabel","texts","v","text"],"mappings":"AAAA,4/BAAkE,yDAAgQ,yDAAkF,yDAA2C,ICA/bA,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,EAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,UAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,YAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,aAAA,CAAA,C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,CACXA,CAAAA,CAAM,IAAA,CAAK,IAAI,CAAA,CAEjB,CAAA,EAAA","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/combobox/index.cjs","sourcesContent":[null,"// ============================================================================\n// Combobox Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Combobox-specific\n// Root, Input, 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 // Icon\n PopupMenuIcon as Icon,\n PopupMenuList as List,\n PopupMenuPopup as Popup,\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 { ComboboxClear as Clear } from './clear/clear.js'\nexport { useComboboxPositionerContext } from './contexts/combobox-positioner-context.js'\nexport { ComboboxInput as Input } from './input/input.js'\nexport { ComboboxInputWrapper as InputWrapper } from './input-wrapper/input-wrapper.js'\nexport { ComboboxItem as Item } from './item/item.js'\nexport { ComboboxItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { ComboboxItemLabel as ItemLabel } from './item-label/item-label.js'\nexport { ComboboxPositioner as Positioner } from './positioner/positioner.js'\n// Combobox-specific components\nexport { ComboboxRoot as Root } from './root/root.js'\nexport { ComboboxSurface as Surface } from './surface/surface.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useComboboxContext } from '../contexts/combobox-context.js'\nimport { ComboboxClearDataAttributes } from './clear.data-attrs.js'\n\nexport { ComboboxClearDataAttributes }\n\nexport interface ComboboxClearState extends Record<string, unknown> {\n /**\n * Whether the combobox has a value (clear button is actionable).\n */\n hasValue: boolean\n /**\n * Whether the combobox is disabled.\n */\n disabled: boolean\n}\n\nexport interface ComboboxClearProps\n extends ComponentProps<'button', ComboboxClear.State> {\n /**\n * Whether to render the button even when there's no value to clear.\n * @default false\n */\n keepMounted?: boolean\n}\n\n/**\n * A button that clears the selected value(s) when clicked.\n * Renders a `<button>` element.\n */\nexport const ComboboxClear = React.forwardRef<\n HTMLButtonElement,\n ComboboxClear.Props\n>(function ComboboxClear(props, forwardedRef) {\n const {\n keepMounted = false,\n disabled: disabledProp,\n render,\n className,\n style,\n onClick,\n ...rest\n } = props\n\n const comboboxContext = useComboboxContext()\n\n const disabled = disabledProp ?? comboboxContext.disabled\n\n const hasValue = comboboxContext.multiple\n ? comboboxContext.values.length > 0\n : comboboxContext.value !== ''\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented) return\n\n if (comboboxContext.multiple) {\n comboboxContext.onValuesChange([])\n } else {\n comboboxContext.onValueChange('')\n }\n\n // Also clear the input value\n comboboxContext.onInputValueChange('')\n },\n [onClick, comboboxContext],\n )\n\n // Prevent pointer down from stealing focus from the input\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLButtonElement>) => {\n event.preventDefault()\n },\n [],\n )\n\n const state: ComboboxClear.State = React.useMemo(\n () => ({\n hasValue,\n disabled,\n }),\n [hasValue, disabled],\n )\n\n const element = useRender({\n render,\n ref: forwardedRef,\n state,\n props: {\n ...rest,\n [ComboboxClearDataAttributes.slot]: '',\n type: 'button',\n tabIndex: -1, // Not tabbable - use keyboard shortcuts instead\n 'aria-label': 'Clear selection',\n disabled: disabled || !hasValue,\n className,\n style,\n onClick: handleClick,\n onPointerDown: handlePointerDown,\n },\n enabled: keepMounted || hasValue,\n defaultTagName: 'button',\n })\n\n // Don't render if no value and not keepMounted\n if (!keepMounted && !hasValue) {\n return null\n }\n\n return element\n})\n\nexport namespace ComboboxClear {\n export type State = ComboboxClearState\n export interface Props extends ComboboxClearProps {}\n}\n","/**\n * Data attributes for ComboboxClear component.\n */\nexport const ComboboxClearDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-combobox-clear'}\n */\n slot: 'bazzaui-combobox-clear',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Types\n// ============================================================================\n\n// Types matching Base UI's positioning types\nexport type Side = 'top' | 'bottom' | 'left' | 'right'\nexport type Align = 'start' | 'center' | 'end'\n\n/**\n * Layout mode for the combobox popup.\n * - `'floating'` - Standard dropdown positioning below/above the input\n * - `'input-embedded'` - Popup wraps around the input (macOS-style)\n */\nexport type ComboboxLayout = 'floating' | 'input-embedded'\n\n/**\n * Context value for Combobox Positioner.\n * Provides alignment state for coordinating positioning behavior.\n */\nexport interface ComboboxPositionerContextValue {\n /**\n * The layout mode being used.\n * - `'floating'` - Standard dropdown positioning\n * - `'input-embedded'` - Popup wraps around the input\n */\n layout: ComboboxLayout\n\n /**\n * The side of the popup relative to the input.\n */\n side: Side\n\n /**\n * The alignment of the popup.\n */\n align: Align\n\n /**\n * Height of the input element in pixels.\n * Use this to add appropriate padding to the popup.\n */\n inputHeight: number\n}\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst ComboboxPositionerContext =\n React.createContext<ComboboxPositionerContextValue | null>(null)\n\n/**\n * Hook to access the Combobox Positioner context.\n * Returns null if used outside a ComboboxPositioner.\n */\nexport function useComboboxPositionerContext(): ComboboxPositionerContextValue | null {\n return React.useContext(ComboboxPositionerContext)\n}\n\nexport { ComboboxPositionerContext }\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { useFocusOwner } from '../../internal/popup-menu/contexts/focus-owner-context.js'\nimport { usePopupMenuContext } from '../../internal/popup-menu/contexts/popup-menu-context.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useComboboxContext } from '../contexts/combobox-context.js'\nimport { useIsInsideInputWrapper } from '../input-wrapper/input-wrapper-context.js'\nimport { ComboboxInputDataAttributes } from './input.data-attrs.js'\nimport { useComboboxDisplayValue } from './use-combobox-display-value.js'\nimport { useComboboxInputBehavior } from './use-combobox-input-behavior.js'\n\nexport { ComboboxInputDataAttributes }\n\nexport interface ComboboxInputState extends Record<string, unknown> {\n /**\n * Whether the combobox popup is open.\n */\n open: boolean\n /**\n * Whether the input is disabled.\n */\n disabled: boolean\n /**\n * Whether the input currently shows placeholder (no value selected).\n */\n placeholder: boolean\n}\n\n/**\n * Cursor behavior when the combobox popup opens.\n * - `'none'` - Don't move the cursor (cursor appears where clicked)\n * - `'end'` - Move cursor to the end of the input\n * - `'select-all'` - Move cursor to the end and select all text\n */\nexport type ComboboxInputCursorBehavior = 'none' | 'end' | 'select-all'\n\nexport interface ComboboxInputProps\n extends Omit<\n ComponentProps<'input', ComboboxInput.State>,\n 'value' | 'onChange' | 'type'\n > {\n /**\n * Placeholder text shown when no value is selected and input is empty.\n * Overrides the placeholder set on Combobox.Root.\n */\n placeholder?: string\n\n /**\n * Cursor behavior when the combobox popup opens.\n * - `'none'` - Don't move the cursor (cursor appears where clicked)\n * - `'end'` - Move cursor to the end of the input\n * - `'select-all'` - Move cursor to the end and select all text\n *\n * @default 'none'\n */\n cursorBehavior?: ComboboxInputCursorBehavior\n}\n\n/**\n * An input that acts as both the trigger and search field for the combobox.\n * Renders an `<input>` element with combobox ARIA semantics.\n */\nexport const ComboboxInput = React.forwardRef<\n HTMLInputElement,\n ComboboxInput.Props\n>(function ComboboxInput(props, forwardedRef) {\n const {\n placeholder: placeholderProp,\n disabled: disabledProp,\n cursorBehavior = 'none',\n render,\n className,\n style,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n ...rest\n } = props\n\n const comboboxContext = useComboboxContext()\n const popupMenuContext = usePopupMenuContext()\n const focusOwnerStore = useFocusOwner()\n const isInsideInputWrapper = useIsInsideInputWrapper()\n\n const disabled =\n (disabledProp ?? comboboxContext.disabled) || popupMenuContext.disabled\n const placeholder = placeholderProp ?? comboboxContext.placeholder\n\n // Get open state\n const open = popupMenuContext.store.useState('open')\n\n // Use display value hook\n const { hasValue, displayValue, getValueText } = useComboboxDisplayValue({\n comboboxContext,\n open,\n })\n\n // Use input behavior hook\n const { handleChange, handleFocus, handleBlur, handleClick, handleKeyDown } =\n useComboboxInputBehavior({\n comboboxContext,\n store: popupMenuContext.store,\n focusOwnerStore,\n open,\n disabled,\n cursorBehavior,\n hasValue,\n getValueText,\n onFocus,\n onBlur,\n onClick,\n onKeyDown,\n })\n\n // Build data attributes\n const dataAttrs: Record<string, string> = {\n [ComboboxInputDataAttributes.slot]: '',\n }\n if (open) {\n dataAttrs[ComboboxInputDataAttributes.open] = ''\n } else {\n dataAttrs[ComboboxInputDataAttributes.closed] = ''\n }\n if (disabled) {\n dataAttrs[ComboboxInputDataAttributes.disabled] = ''\n }\n if (!hasValue) {\n dataAttrs[ComboboxInputDataAttributes.placeholder] = ''\n }\n // Add input-embedded data attribute when layout is input-embedded\n if (comboboxContext.layout === 'input-embedded') {\n dataAttrs['data-input-embedded'] = ''\n }\n\n // Register input element for positioning\n const mergedRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n comboboxContext.setInputElement(node)\n if (typeof forwardedRef === 'function') {\n forwardedRef(node)\n } else if (forwardedRef) {\n forwardedRef.current = node\n }\n },\n [forwardedRef, comboboxContext],\n )\n\n const state: ComboboxInput.State = React.useMemo(\n () => ({\n open,\n disabled,\n placeholder: !hasValue,\n }),\n [open, disabled, hasValue],\n )\n\n // When input-embedded layout, apply styles to position input above the popup\n // Skip z-index if inside an InputWrapper (the wrapper handles z-index)\n const inputEmbeddedStyles: React.CSSProperties | undefined =\n comboboxContext.layout === 'input-embedded' && !isInsideInputWrapper\n ? { position: 'relative', zIndex: 1 }\n : undefined\n\n const element = useRender({\n render,\n ref: mergedRef,\n state,\n props: {\n ...rest,\n ...dataAttrs,\n type: 'text',\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': open,\n 'aria-controls': comboboxContext.listId,\n 'aria-haspopup': 'listbox',\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: false,\n disabled,\n placeholder: !hasValue ? placeholder : undefined,\n className,\n style: { ...inputEmbeddedStyles, ...style },\n value: displayValue,\n onChange: handleChange,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n },\n defaultTagName: 'input',\n })\n\n return element\n})\n\nexport namespace ComboboxInput {\n export interface Props extends ComboboxInputProps {}\n export type State = ComboboxInputState\n}\n","import * as React from 'react'\n\n/**\n * Context to indicate that children are inside an InputWrapper.\n * When true, Input should not apply its own z-index styles for input-embedded layout.\n */\nexport const ComboboxInputWrapperContext = React.createContext<boolean>(false)\n\n/**\n * Hook to check if component is inside a ComboboxInputWrapper.\n */\nexport function useIsInsideInputWrapper(): boolean {\n return React.useContext(ComboboxInputWrapperContext)\n}\n","/**\n * Data attributes for ComboboxInput component.\n */\nexport const ComboboxInputDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-combobox-input'}\n */\n slot: 'bazzaui-combobox-input',\n /** Present when the combobox popup is open. */\n open: 'data-open',\n /** Present when the combobox popup is closed. */\n closed: 'data-closed',\n /** Present when the input is disabled. */\n disabled: 'data-disabled',\n /** Present when no value is selected (showing placeholder). */\n placeholder: 'data-placeholder',\n} as const\n","'use client'\n\nimport * as React from 'react'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComboboxContextValue } from '../contexts/combobox-context.js'\n\n/**\n * Helper to resolve label from items prop\n */\nfunction resolveLabelFromItems(\n items:\n | Record<string, React.ReactNode>\n | Array<{ value: string; label: React.ReactNode }>\n | undefined,\n value: string,\n): string | undefined {\n if (!items) return undefined\n\n if (Array.isArray(items)) {\n const item = items.find((i) => i.value === value)\n const label = item?.label\n return typeof label === 'string' ? label : undefined\n }\n\n const label = items[value]\n return typeof label === 'string' ? label : undefined\n}\n\nexport interface UseComboboxDisplayValueParams<Value = unknown> {\n comboboxContext: ComboboxContextValue<Value>\n open: boolean\n}\n\nexport interface UseComboboxDisplayValueReturn<Value = unknown> {\n /** Whether a value is selected */\n hasValue: boolean\n /** The value to display in the input */\n displayValue: string\n /** The label of the selected value(s) */\n selectedLabel: string\n /** Get the display text for a value */\n getValueText: (value: Value) => string | undefined\n}\n\n/**\n * Hook to compute the display value for the combobox input.\n *\n * Handles:\n * - Determining if a value is selected (single or multi-select)\n * - Computing the display label for selected values\n * - Switching between selected label (closed) and input value (open)\n */\nexport function useComboboxDisplayValue<Value = unknown>(\n params: UseComboboxDisplayValueParams<Value>,\n): UseComboboxDisplayValueReturn<Value> {\n const { comboboxContext, open } = params\n\n // Determine if showing placeholder (no value selected)\n const hasValue = comboboxContext.multiple\n ? comboboxContext.values.length > 0\n : comboboxContext.value != null\n\n // Get the display text for selected value\n const getValueText = React.useCallback(\n (value: Value): string | undefined => {\n // Serialize for registry lookup\n const serializedValue = stringifyAsValue(\n value,\n comboboxContext.itemToStringValue,\n )\n\n // First try the registry (populated when items mount)\n const registryText = comboboxContext.itemTextRegistry.get(serializedValue)\n if (registryText !== undefined) {\n return registryText\n }\n\n // Fall back to the items prop (for initial render before popup opens)\n const itemsLabel = resolveLabelFromItems(\n comboboxContext.items,\n serializedValue,\n )\n if (itemsLabel !== undefined) {\n return itemsLabel\n }\n\n // Fall back to itemToStringLabel for object values\n const resolvedLabel = resolveLabel(\n value,\n comboboxContext.itemToStringLabel,\n )\n // Only return if it's different from the serialized value (meaning we got a real label)\n if (resolvedLabel && resolvedLabel !== serializedValue) {\n return resolvedLabel\n }\n\n return undefined\n },\n [\n comboboxContext.itemTextRegistry,\n comboboxContext.items,\n comboboxContext.itemToStringLabel,\n comboboxContext.itemToStringValue,\n ],\n )\n\n // Get the label for the selected value (used when closed or just opened)\n const selectedLabel = React.useMemo(() => {\n if (!hasValue) {\n return ''\n }\n if (comboboxContext.multiple) {\n // For multi-select, show comma-separated values or count\n const texts = comboboxContext.values\n .map((v) => {\n const text = getValueText(v)\n if (text !== undefined) return text\n // Fall back to resolved label or serialized value\n return (\n resolveLabel(v, comboboxContext.itemToStringLabel) ||\n stringifyAsValue(v, comboboxContext.itemToStringValue)\n )\n })\n .filter(Boolean)\n if (texts.length <= 2) {\n return texts.join(', ')\n }\n return `${texts.length} selected`\n }\n // Single-select: show the value's text\n const value = comboboxContext.value\n if (value == null) return ''\n\n const text = getValueText(value)\n if (text !== undefined) return text\n // Fall back to resolved label or serialized value\n return (\n resolveLabel(value, comboboxContext.itemToStringLabel) ||\n stringifyAsValue(value, comboboxContext.itemToStringValue)\n )\n }, [\n hasValue,\n comboboxContext.multiple,\n comboboxContext.value,\n comboboxContext.values,\n comboboxContext.itemToStringLabel,\n comboboxContext.itemToStringValue,\n getValueText,\n ])\n\n // Determine the display value for the input\n // When closed: show selected value's text\n // When open: show the search/filter text (inputValue)\n const displayValue = React.useMemo(() => {\n if (!open) {\n // When closed, show the selected value's label\n return selectedLabel\n }\n // When open, use the input value for filtering\n return comboboxContext.inputValue\n }, [open, selectedLabel, comboboxContext.inputValue])\n\n return {\n hasValue,\n displayValue,\n selectedLabel,\n getValueText,\n }\n}\n"]}
|