@bazza-ui/react 0.1.0-canary.7 → 0.1.0-canary.8
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/chunk-23NDAOAL.js +2 -0
- package/dist/chunk-23NDAOAL.js.map +1 -0
- package/dist/chunk-IT372NHF.js +2 -0
- package/dist/chunk-IT372NHF.js.map +1 -0
- package/dist/chunk-KRMKZEK4.cjs +2 -0
- package/dist/{chunk-URLK26NV.cjs.map → chunk-KRMKZEK4.cjs.map} +1 -1
- package/dist/chunk-SCDHQZFI.cjs +2 -0
- package/dist/chunk-SCDHQZFI.cjs.map +1 -0
- package/dist/combobox/index.cjs +1 -1
- package/dist/combobox/index.cjs.map +1 -1
- package/dist/combobox/index.js +1 -1
- package/dist/combobox/index.js.map +1 -1
- package/dist/{context-Dhm4Zi3l.d.ts → context-ChPa-nD4.d.ts} +6 -0
- package/dist/{context-Drjy6Y10.d.cts → context-HN6UavqL.d.cts} +6 -0
- package/dist/context-menu/index.cjs +1 -1
- package/dist/context-menu/index.d.cts +2 -2
- package/dist/context-menu/index.d.ts +2 -2
- package/dist/context-menu/index.js +1 -1
- package/dist/dropdown-menu/index.cjs +1 -1
- package/dist/dropdown-menu/index.cjs.map +1 -1
- package/dist/dropdown-menu/index.d.cts +2 -2
- package/dist/dropdown-menu/index.d.ts +2 -2
- package/dist/dropdown-menu/index.js +1 -1
- package/dist/dropdown-menu/index.js.map +1 -1
- package/dist/internal/popup-menu/index.cjs +1 -1
- package/dist/internal/popup-menu/index.d.cts +2 -2
- package/dist/internal/popup-menu/index.d.ts +2 -2
- package/dist/internal/popup-menu/index.js +1 -1
- package/dist/select/index.cjs +1 -1
- package/dist/select/index.cjs.map +1 -1
- package/dist/select/index.js +1 -1
- package/dist/select/index.js.map +1 -1
- package/dist/video-player/index.cjs +2 -2
- package/dist/video-player/index.cjs.map +1 -1
- package/dist/video-player/index.js +2 -2
- package/dist/video-player/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2D2HREBK.js +0 -2
- package/dist/chunk-2D2HREBK.js.map +0 -1
- package/dist/chunk-URLK26NV.cjs +0 -2
|
@@ -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","useComboboxDisplayValue","params","open","isValueEmpty","getValueText","value","serializedValue","stringifyAsValue","registryText","itemsLabel","resolveLabelFromItems","resolvedLabel","resolveLabel","selectedLabel","texts","v","text"],"mappings":"AAAA,4/BAA0F,yDAA2Q,yDAAmF,yDAA2C,ICAneA,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,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IoB,CAAe,CAAA,CACzE,EAAA,CAAIE,CAAAA,GAAiB,KAAA,CAAA,CACnB,OAAOA,CAAAA,CAKT,IAAMC,CAAAA,CAAaC,iCAAAA,CACjBxB,CAAgB,KAAA,CAChBoB,CACF,CAAA,CACA,EAAA,CAAI,OAAOG,CAAAA,EAAe,QAAA,CACxB,OAAOA,CAAAA,CAIT,IAAME,CAAAA,CAAgBC,kCAAAA,CACpBP,CACAnB,CAAAA,CAAgB,iBAClB,CAAA,CAEA,EAAA,CAAIyB,CAAAA,EAAiBA,CAAAA,GAAkBL,CAAAA,CACrC,OAAOK,CAIX,CAAA,CACA,CACEzB,CAAAA,CAAgB,gBAAA,CAChBA,CAAAA,CAAgB,KAAA,CAChBA,CAAAA,CAAgB,iBAAA,CAChBA,CAAAA,CAAgB,iBAClB,CACF,CAAA,CAGM2B,CAAAA,CAAsB,EAAA,CAAA,OAAA,CAAQ,CAAA,CAAA,EAAM,CACxC,EAAA,CAAI,CAACxB,CAAAA,CACH,MAAO,EAAA,CAET,EAAA,CAAIH,CAAAA,CAAgB,QAAA,CAAU,CAE5B,IAAM4B,CAAAA,CAAQ5B,CAAAA,CAAgB,MAAA,CAC3B,GAAA,CAAK6B,CAAAA,EAAM,CACV,IAAMC,CAAAA,CAAOZ,CAAAA,CAAaW,CAAC,CAAA,CAC3B,OAAIC,CAAAA,GAAS,KAAA,CAAA,CAAkBA,CAAAA,CAG7BJ,kCAAAA,CAAaG,CAAG7B,CAAAA,CAAgB,iBAAiB,CAAA,EACjDqB,kCAAAA,CAAiBQ,CAAG7B,CAAAA,CAAgB,iBAAiB,CAEzD,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA,CACjB,OAAI4B,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 { resolveLabelFromItems } from '../../utils/items.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\n // A `null` item's label (looked up under the empty-string key) acts as the\n // placeholder, taking precedence over the Root placeholder but not an\n // explicit `placeholder` prop on the input.\n const nullItemLabel = resolveLabelFromItems(comboboxContext.items, '')\n const placeholder =\n placeholderProp ??\n (typeof nullItemLabel === 'string' ? nullItemLabel : undefined) ??\n 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 { resolveLabelFromItems } from '../../utils/items.js'\nimport {\n isValueEmpty,\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComboboxContextValue } from '../contexts/combobox-context.js'\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 : !isValueEmpty(comboboxContext.value)\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 // The input can only display strings, so ignore non-string labels here.\n const itemsLabel = resolveLabelFromItems(\n comboboxContext.items,\n serializedValue,\n )\n if (typeof itemsLabel === 'string') {\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 // Empty-string values are already handled by the `!hasValue` guard above;\n // this null check also narrows `Value | null` down to `Value`.\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":["/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","onPointerDown","rest","comboboxContext","useComboboxContext","disabled","hasValue","handleClick","event","handlePointerDown","state","element","useRender","ComboboxPositionerContext","ComboboxInputWrapperContext","useIsInsideInputWrapper","ComboboxInputDataAttributes","useComboboxDisplayValue","params","open","isValueEmpty","getValueText","value","serializedValue","stringifyAsValue","registryText","itemsLabel","resolveLabelFromItems","resolvedLabel","resolveLabel","selectedLabel","texts","v","text"],"mappings":"AAAA,4/BAA0F,yDAA2Q,yDAAmF,yDAA2C,ICAneA,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,CAAA,CAAA,EAAAC,EAAAA,CAAA,SAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,MAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,UAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAA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AAA,CAAQ,CAAA,CAAA,EAAM,CACxC,EAAA,CAAI,CAACxB,CAAAA,CACH,MAAO,EAAA,CAET,EAAA,CAAIH,CAAAA,CAAgB,QAAA,CAAU,CAE5B,IAAM4B,CAAAA,CAAQ5B,CAAAA,CAAgB,MAAA,CAC3B,GAAA,CAAK6B,CAAAA,EAAM,CACV,IAAMC,CAAAA,CAAOZ,CAAAA,CAAaW,CAAC,CAAA,CAC3B,OAAIC,CAAAA,GAAS,KAAA,CAAA,CAAkBA,CAAAA,CAG7BJ,kCAAAA,CAAaG,CAAG7B,CAAAA,CAAgB,iBAAiB,CAAA,EACjDqB,kCAAAA,CAAiBQ,CAAG7B,CAAAA,CAAgB,iBAAiB,CAEzD,CAAC,CAAA,CACA,MAAA,CAAO,OAAO,CAAA,CACjB,OAAI4B,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 onPointerDown,\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 onPointerDown?.(event)\n },\n [onPointerDown],\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 { resolveLabelFromItems } from '../../utils/items.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\n // A `null` item's label (looked up under the empty-string key) acts as the\n // placeholder, taking precedence over the Root placeholder but not an\n // explicit `placeholder` prop on the input.\n const nullItemLabel = resolveLabelFromItems(comboboxContext.items, '')\n const placeholder =\n placeholderProp ??\n (typeof nullItemLabel === 'string' ? nullItemLabel : undefined) ??\n 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 { resolveLabelFromItems } from '../../utils/items.js'\nimport {\n isValueEmpty,\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComboboxContextValue } from '../contexts/combobox-context.js'\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 : !isValueEmpty(comboboxContext.value)\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 // The input can only display strings, so ignore non-string labels here.\n const itemsLabel = resolveLabelFromItems(\n comboboxContext.items,\n serializedValue,\n )\n if (typeof itemsLabel === 'string') {\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 // Empty-string values are already handled by the `!hasValue` guard above;\n // this null check also narrows `Value | null` down to `Value`.\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"]}
|
package/dist/combobox/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as yo,b as vo,c as Vo,d as Mo,e as Eo,f as te,g as Lo}from"../chunk-KO3DXT3Y.js";import{Ab as So,L as ro,La as uo,Ma as io,N as ao,Na as xt,P as so,Qa as po,R as lo,Ra as mo,S as D,Sa as co,T as dt,Ua as bo,Va as N,Wa as F,Xa as xo,Ya as Co,_a as Ct,ab as fo,eb as go,f as no,fb as ho,gb as Po,l as ce,yb as Io,zb as Ro}from"../chunk-2D2HREBK.js";import{a as oe,p as it,q as pt,w as mt,x as ct,y as bt}from"../chunk-ZPRKUVIC.js";import{a as ut}from"../chunk-4C666HHU.js";var Fo={};ut(Fo,{Arrow:()=>ao,Backdrop:()=>so,Clear:()=>ve,Empty:()=>Co,Group:()=>Io,GroupLabel:()=>Ro,Icon:()=>xo,Input:()=>Ee,InputWrapper:()=>Le,Item:()=>we,ItemIndicator:()=>Te,ItemLabel:()=>ke,List:()=>fo,Popup:()=>uo,Portal:()=>io,Positioner:()=>He,Root:()=>Oe,ScrollDownArrow:()=>ho,ScrollUpArrow:()=>go,Separator:()=>So,Surface:()=>De,useComboboxPositionerContext:()=>Ve});import{useRender as ft}from"@base-ui/react/use-render";import*as X from"react";var wo={slot:"bazzaui-combobox-clear"};var ve=X.forwardRef(function(e,t){let{keepMounted:p=!1,disabled:s,render:r,className:m,style:d,onClick:o,...l}=e,u=D(),C=s??u.disabled,b=u.multiple?u.values.length>0:u.value!=="",R=X.useCallback(P=>{o?.(P),!P.defaultPrevented&&(u.multiple?u.onValuesChange([]):u.onValueChange(""),u.onInputValueChange(""))},[o,u]),a=X.useCallback(P=>{P.preventDefault()},[]),f=X.useMemo(()=>({hasValue:b,disabled:C}),[b,C]),c=ft({render:r,ref:t,state:f,props:{...l,[wo.slot]:"",type:"button",tabIndex:-1,"aria-label":"Clear selection",disabled:C||!b,className:m,style:d,onClick:R,onPointerDown:a},enabled:p||b,defaultTagName:"button"});return!p&&!b?null:c});import*as be from"react";var de=be.createContext(null);function Ve(){return be.useContext(de)}import{useRender as gt}from"@base-ui/react/use-render";import*as ne from"react";import*as xe from"react";var Me=xe.createContext(!1);function To(){return xe.useContext(Me)}var Q={slot:"bazzaui-combobox-input",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import*as le from"react";function ko(I){let{comboboxContext:e,open:t}=I,p=e.multiple?e.values.length>0:!bo(e.value),s=le.useCallback(d=>{let o=F(d,e.itemToStringValue),l=e.itemTextRegistry.get(o);if(l!==void 0)return l;let u=te(e.items,o);if(typeof u=="string")return u;let C=N(d,e.itemToStringLabel);if(C&&C!==o)return C},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),r=le.useMemo(()=>{if(!p)return"";if(e.multiple){let l=e.values.map(u=>{let C=s(u);return C!==void 0?C:N(u,e.itemToStringLabel)||F(u,e.itemToStringValue)}).filter(Boolean);return l.length<=2?l.join(", "):`${l.length} selected`}let d=e.value;if(d==null)return"";let o=s(d);return o!==void 0?o:N(d,e.itemToStringLabel)||F(d,e.itemToStringValue)},[p,e.multiple,e.value,e.values,e.itemToStringLabel,e.itemToStringValue,s]),m=le.useMemo(()=>t?e.inputValue:r,[t,r,e.inputValue]);return{hasValue:p,displayValue:m,selectedLabel:r,getValueText:s}}import*as k from"react";function Ho(I){let{comboboxContext:e,store:t,focusOwnerStore:p,open:s,disabled:r,cursorBehavior:m,hasValue:d,getValueText:o,onFocus:l,onBlur:u,onClick:C,onKeyDown:b}=I,R=k.useRef(!1),a=k.useRef(!1),f=k.useRef(!1),c=k.useRef(null),P=k.useRef(null),y=k.useRef(null);k.useEffect(()=>{if(!s)return;let n=x=>{let i=e.inputRef.current,M=e.inputWrapperRef.current,S=document.getElementById(e.listId),O=x.target,W=i?.contains(O),z=M?.contains(O),_=S?.contains(O);!W&&!z&&!_&&(y.current=x)};return document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("pointerdown",n,!0),y.current=null}},[s,e.inputRef,e.inputWrapperRef,e.listId]),k.useLayoutEffect(()=>{let n=e.inputRef.current;if(n&&s&&P.current){let{start:x,end:i}=P.current,M=n.selectionStart,S=n.value.length;M===S&&x!==S&&n.setSelectionRange(x,i),P.current=null}});let L=k.useRef(s);k.useLayoutEffect(()=>{if(s&&!L.current){if(R.current){R.current=!1,L.current=s;return}if(f.current){f.current=!1,a.current=!1,c.current=null,L.current=s;return}if(a.current&&m==="none"){let x=e.inputRef.current,i=c.current;x&&i!==null&&requestAnimationFrame(()=>{let M=x.value.length,S=Math.min(i,M);x.setSelectionRange(S,S)}),a.current=!1,c.current=null,L.current=s;return}d&&e.multiple&&e.onInputValueChange("");let n=e.inputRef.current;if(n){let x=n.value.length;m==="select-all"&&x>0?requestAnimationFrame(()=>{n.setSelectionRange(0,n.value.length)}):m==="end"&&x>0&&requestAnimationFrame(()=>{n.setSelectionRange(n.value.length,n.value.length)})}}L.current=s},[s,e,d,m]);let w=k.useCallback(n=>{let x=n.target,i=x.value,M=x.selectionStart,S=x.selectionEnd;M!==null&&S!==null&&(P.current={start:M,end:S}),e.onInputValueChange(i),e.setFilterActive(),t.setSearch(i),t.state.open||(R.current=!0,e.openCombobox())},[e,t]),T=k.useCallback(n=>{if(l?.(n),n.defaultPrevented)return;let x=t.state.open;if(x&&(f.current=!0),e.openOnFocus&&!r&&!x){if(d&&!e.multiple){let i=o(e.value)??N(e.value,e.itemToStringLabel);e.onInputValueChange(i)}e.openCombobox()}},[l,e,r,t,d,o]),V=k.useCallback(n=>{u?.(n),!n.defaultPrevented&&requestAnimationFrame(()=>{let x=document.activeElement,M=document.getElementById(e.listId)?.contains(x),S=x===e.inputRef.current;if(!M&&!S){f.current=!1;let O=y.current,W=O?oe.outsidePress:oe.focusOut;y.current=null,e.closeCombobox(W,O??void 0)}})},[u,e]),A=k.useCallback(n=>{if(C?.(n),n.defaultPrevented)return;let x=t.state.open;if(!r&&!x){let i=n.target;if(m==="none"){let M=i.selectionStart;c.current=M,a.current=!0}if(d&&!e.multiple){let M=o(e.value)??N(e.value,e.itemToStringLabel);e.onInputValueChange(M)}e.openCombobox()}else x&&(f.current=!0)},[C,e,r,t,m,d,o]),q=k.useCallback(n=>{if(b?.(n),!n.defaultPrevented){if(s&&n.key==="Escape"){n.preventDefault(),e.closeCombobox(oe.escapeKey);return}if(!s&&(n.key==="ArrowDown"||n.key==="ArrowUp"||n.key==="Enter")){if(n.preventDefault(),d&&!e.multiple){let x=o(e.value)??N(e.value,e.itemToStringLabel);e.onInputValueChange(x)}e.openCombobox();return}}},[s,e,b,d,o]),{handleKeyDown:j}=co({store:t,surfaceId:"combobox-input",focusOwnerStore:p,depth:0,submenuContext:null,subpageContext:null,enabled:s,enableTypeToSearch:!1,onKeyDown:q,closeAll:e.closeCombobox,skipFocusOwnerCheck:!0});return{handleChange:w,handleFocus:T,handleBlur:V,handleClick:A,handleKeyDown:j,selectionRef:P}}var Ee=ne.forwardRef(function(e,t){let{placeholder:p,disabled:s,cursorBehavior:r="none",render:m,className:d,style:o,onFocus:l,onBlur:u,onClick:C,onKeyDown:b,...R}=e,a=D(),f=ce(),c=no(),P=To(),y=(s??a.disabled)||f.disabled,L=te(a.items,""),w=p??(typeof L=="string"?L:void 0)??a.placeholder,T=f.store.useState("open"),{hasValue:V,displayValue:A,getValueText:q}=ko({comboboxContext:a,open:T}),{handleChange:j,handleFocus:n,handleBlur:x,handleClick:i,handleKeyDown:M}=Ho({comboboxContext:a,store:f.store,focusOwnerStore:c,open:T,disabled:y,cursorBehavior:r,hasValue:V,getValueText:q,onFocus:l,onBlur:u,onClick:C,onKeyDown:b}),S={[Q.slot]:""};T?S[Q.open]="":S[Q.closed]="",y&&(S[Q.disabled]=""),V||(S[Q.placeholder]=""),a.layout==="input-embedded"&&(S["data-input-embedded"]="");let O=ne.useCallback(v=>{a.setInputElement(v),typeof t=="function"?t(v):t&&(t.current=v)},[t,a]),W=ne.useMemo(()=>({open:T,disabled:y,placeholder:!V}),[T,y,V]),z=a.layout==="input-embedded"&&!P?{position:"relative",zIndex:1}:void 0;return gt({render:m,ref:O,state:W,props:{...R,...S,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":T,"aria-controls":a.listId,"aria-haspopup":"listbox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:y,placeholder:V?void 0:w,className:d,style:{...z,...o},value:A,onChange:j,onFocus:n,onBlur:x,onClick:i,onKeyDown:M},defaultTagName:"input"})});import{useRender as ht}from"@base-ui/react/use-render";import*as re from"react";var Ce={slot:"bazzaui-combobox-input-wrapper",open:"data-open"};import{jsx as It}from"react/jsx-runtime";var Pt={open:I=>I?{[Ce.open]:""}:null},Le=re.forwardRef(function(e,t){let{render:p,className:s,style:r,children:m,...d}=e,{store:o}=ce(),l=D(),u=o.useState("open"),C=re.useMemo(()=>({open:u}),[u]),b=l.layout==="input-embedded"?{position:"relative",zIndex:1}:{position:"relative"},R=re.useCallback(f=>{l.setInputWrapperElement(f),typeof t=="function"?t(f):t&&(t.current=f)},[t,l]),a=ht({render:p,ref:R,state:C,stateAttributesMapping:Pt,props:{...d,[Ce.slot]:"",className:s,style:{...b,...r},children:m},defaultTagName:"div"});return It(Me.Provider,{value:!0,children:a})});import{useRender as St}from"@base-ui/react/use-render";import*as E from"react";var ae={slot:"bazzaui-combobox-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};import*as ue from"react";var fe=ue.createContext(null);function ie(){let I=ue.useContext(fe);if(!I)throw new Error("ComboboxItem child components must be used within a Combobox.Item");return I}function Rt(){return ue.useContext(fe)}import{jsx as Vt}from"react/jsx-runtime";var yt={highlighted:I=>I?{[ae.highlighted]:""}:null,disabled:I=>I?{[ae.disabled]:""}:null,selected:I=>I?{[ae.selected]:""}:null};function vt(I,e){let{value:t,textValue:p,keywords:s,disabled:r=!1,onSelect:m,forceMount:d=!1,render:o,className:l,style:u,onClick:C,onPointerDown:b,onPointerMove:R,children:a,...f}=I,c=D(),P=E.useMemo(()=>F(t,c.itemToStringValue),[t,c.itemToStringValue]),y=E.useId(),L=t===null?`combobox-clear-${y}`:void 0,w=E.useMemo(()=>Eo(c.items,P),[c.items,P]),T=w?.label,V=E.useMemo(()=>N(t,c.itemToStringLabel),[t,c.itemToStringLabel]),A=E.useMemo(()=>{if(p!==void 0)return p;if(typeof T=="string")return T;if(V&&V!==P)return V},[p,T,V,P]),q=E.useMemo(()=>Lo(s,[typeof T=="string"?T:V&&V!==P?V:void 0,...w?.keywords??[]]),[s,T,V,P,w]),j=E.useRef(A),n=c.multiple?Vo(c.values,t,c.isItemEqualToValue):c.value!==""&&vo(c.value,t,c.isItemEqualToValue),x=c.closeOnSelect,i=mo({id:L,value:P,keywords:q,disabled:r,forceMount:d,closeOnClick:x,children:a});E.useEffect(()=>{let v=()=>{if(!r){if(c.multiple)if(t==null)c.onValuesChange([]);else{let ee=n?Mo(c.values,t,c.isItemEqualToValue):[...c.values,t];c.onValuesChange(ee)}else c.onValueChange(t);m?.()}};return i.registerSelect(v)},[r,c,t,n,m,i]),E.useEffect(()=>{let v=j.current;if(v)return c.registerItemText(P,v)},[P,c]),E.useEffect(()=>{!A&&typeof a=="string"&&(j.current=a,c.registerItemText(P,a))},[a,A,P,c]);let M=E.useMemo(()=>({highlighted:i.isHighlighted,disabled:r,selected:n}),[i.isHighlighted,r,n]),S=E.useMemo(()=>({id:i.id,value:t,textValue:A,highlighted:i.isHighlighted,disabled:r,selected:n}),[i.id,t,A,i.isHighlighted,r,n]),O=E.useCallback(v=>{C?.(v),v.defaultPrevented||i.handlers.onClick(v)},[C,i.handlers]),W=E.useCallback(v=>{i.handlers.onPointerDown(v),b?.(v)},[i.handlers,b]),z=E.useCallback(v=>{R?.(v),v.defaultPrevented||i.handlers.onPointerMove(v)},[R,i.handlers]),_=St({render:o,ref:[i.ref,e],state:M,stateAttributesMapping:yt,props:{...f,[ae.slot]:"",id:i.id,role:"option",tabIndex:-1,"aria-selected":n,"aria-disabled":r||void 0,className:l,style:u,onClick:O,onPointerMove:z,onPointerDown:W,children:a},enabled:i.isVisible,defaultTagName:"div"});return i.isVisible?Vt(fe.Provider,{value:S,children:_}):null}var we=E.forwardRef(vt);import{useRender as Mt}from"@base-ui/react/use-render";import*as he from"react";var ge={slot:"bazzaui-combobox-item-indicator",selected:"data-selected"};var Et={selected:I=>I?{[ge.selected]:""}:null},Te=he.forwardRef(function(e,t){let{keepMounted:p=!1,render:s,className:r,style:m,...d}=e,o=ie(),l=he.useMemo(()=>({selected:o.selected}),[o.selected]),u=Mt({render:s,ref:t,state:l,stateAttributesMapping:Et,props:{...d,[ge.slot]:"","aria-hidden":!0,className:r,style:m},enabled:p||o.selected,defaultTagName:"span"});return!p&&!o.selected?null:u});import{useRender as Lt}from"@base-ui/react/use-render";import*as Y from"react";var Oo={slot:"bazzaui-combobox-item-label"};var ke=Y.forwardRef(function(e,t){let{render:p,className:s,style:r,children:m,...d}=e,o=D(),l=ie(),u=F(l.value,o.itemToStringValue),C=Y.useMemo(()=>{if(m!==void 0)return m;let R=te(o.items,u);return R!==void 0?R:l.textValue!==void 0?l.textValue:u},[m,o.items,u,l.textValue]),b=Y.useMemo(()=>({value:u,selected:l.selected,highlighted:l.highlighted,disabled:l.disabled}),[u,l.selected,l.highlighted,l.disabled]);return Y.useEffect(()=>{if(typeof C=="string")return o.registerItemText(u,C)},[C,o,u]),Lt({render:p,ref:t,state:b,props:{...d,[Oo.slot]:"",className:s,style:r,children:C},defaultTagName:"span"})});import{Popover as Do}from"@base-ui/react/popover";import*as U from"react";var Pe={slot:"bazzaui-combobox-positioner"};import{jsx as pe}from"react/jsx-runtime";function wt(I,e,t,p){let s=t+p*2;if(I==="top"){let d=-(e+p),o=e+p;return{width:s,marginBottom:d,paddingTop:p,paddingLeft:p,paddingRight:p,paddingBottom:o}}let r=-(e+p),m=e+p;return{width:s,marginTop:r,paddingTop:m,paddingLeft:p,paddingRight:p,paddingBottom:p}}var He=U.forwardRef(function(e,t){let{layout:p,popupPadding:s=8,side:r="bottom",align:m,sideOffset:d=4,anchor:o,className:l,style:u,children:C,...b}=e,R=D(),a=p??R.layout,f=a==="input-embedded",c=o??R.inputWrapperRef.current?R.inputWrapperRef:R.inputRef,P=f?0:d,y=f?"center":m??"start",{inputHeight:L,inputWidth:w}=R,T=w+s*2,V={...u,...f?{zIndex:0}:{}};if(f)return pe(Do.Positioner,{ref:t,side:r,align:y,sideOffset:P,anchor:c,className:l,style:V,"data-input-embedded":"",[Pe.slot]:"",...b,render:(n,x)=>{let i=x.side,M={layout:a,side:i,align:x.align,inputHeight:R.inputHeight},S={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`,"--combobox-popup-padding":`${s}px`,"--combobox-popup-width":`${T}px`},O=wt(i,L,w,s),W=U.Children.map(C,z=>U.isValidElement(z)?U.cloneElement(z,{style:{...O,...z.props.style},"data-side":i}):z);return pe(de.Provider,{value:M,children:pe("div",{...n,style:{...n.style,...S},"data-side":i,children:W})})}});let A={layout:a,side:r,align:y,inputHeight:R.inputHeight},q={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`},j={...V,...q};return pe(de.Provider,{value:A,children:pe(Do.Positioner,{ref:t,side:r,align:y,sideOffset:P,anchor:c,className:l,style:j,[Pe.slot]:"",...b,children:C})})});import{Popover as Tt}from"@base-ui/react/popover";import*as h from"react";import{jsx as me,jsxs as kt}from"react/jsx-runtime";function Oe(I){let{open:e,onOpenChange:t,actionsRef:p,defaultOpen:s=!1,value:r,defaultValue:m,onValueChange:d,multiple:o=!1,values:l,defaultValues:u,onValuesChange:C,isItemEqualToValue:b=yo,itemToStringLabel:R,itemToStringValue:a,inputValue:f,defaultInputValue:c="",onInputValueChange:P,name:y,form:L,required:w,disabled:T=!1,placeholder:V="Search...",items:A,modal:q=!1,closeOnSelect:j,openOnFocus:n=!0,virtualized:x=!1,virtualItems:i,onHighlightChange:M,layout:S="floating",onOpenChangeComplete:O,debug:W,children:z,..._}=I,v=h.useId(),ee=h.useRef(null),Ie=h.useRef(null),[Ae,Fe]=h.useState(0),[ze,Be]=h.useState(0),We=h.useCallback(g=>{if(ee.current=g,g&&!Ie.current){let H=g.getBoundingClientRect();Fe(H.height),Be(H.width)}},[]),je=h.useCallback(g=>{if(Ie.current=g,g){let H=g.getBoundingClientRect();Fe(H.height),Be(H.width)}},[]),{store:B,focusOwnerStore:Go,openChainStore:$o,registerSurface:Jo,closeAll:Xo,virtualization:Qo,handleOpenChange:Ne,disabled:G,setDisabled:qe}=ro({onOpenChange:t,defaultOpen:s,virtualized:x,items:i,onHighlightChange:M,disabled:T}),Re=h.useRef(null);h.useImperativeHandle(p,()=>({close:()=>{Re.current?.close()},unmount:()=>{Re.current?.unmount()},setDisabled:qe}),[qe]),B.useControlledProp("openProp",e);let Yo=B.useState("open"),Ke=h.useCallback((g,H,K)=>{G&&H!==oe.imperativeAction||!g&&ee.current&&document.activeElement===ee.current||Ne(g,H,K)},[Ne,G]),Zo=h.useCallback(g=>{!g&&B.context.clearSearchOnClose==="after-exit"&&(B.clearSearch(),B.setInputActive(!1)),g||B.clearHighlight(),O?.(g)},[B,O]),_o=h.useCallback((g,H)=>{Ke(g,H.reason,H.event)},[Ke]),[et,ot]=h.useState(m!==void 0?m:null),$=r!==void 0?r:et,Ue=h.useCallback(g=>{r===void 0&&ot(g),d?.(g)},[r,d]),[tt,nt]=h.useState(u??[]),se=l!==void 0?l:tt,Ge=h.useCallback(g=>{l===void 0&&nt(g),C?.(g)},[l,C]),[Se,rt]=h.useState(c),$e=f!==void 0?f:Se,Je=h.useCallback(g=>{f===void 0&&rt(g),P?.(g)},[f,P]),Xe=h.useRef(new Map),Qe=h.useCallback((g,H)=>(Xe.current.set(g,H),()=>{}),[]),Ye=j??!o,ye=h.useRef({type:"active"}),[,at]=h.useState({type:"active"}),J=h.useCallback(g=>{ye.current=g,at(g)},[]),Ze=ye.current,_e=h.useCallback(()=>{J({type:"active"})},[J]),eo=h.useCallback(()=>{G||(!o&&$!=null?J({type:"showAll"}):J({type:"active"}),B.setOpen(!0))},[G,B,o,$,J]),oo=h.useCallback((g,H)=>{let K=ye.current,to=K.type==="active"?Se:K.type==="showAll"?"":K.search;J({type:"frozen",search:to}),B.setOpen(!1,g,H)},[B,J,Se]),st=h.useMemo(()=>({multiple:o,value:$,values:se,onValueChange:Ue,onValuesChange:Ge,isItemEqualToValue:b,itemToStringLabel:R,itemToStringValue:a,inputValue:$e,onInputValueChange:Je,name:y,form:L,required:w,disabled:G,placeholder:V,items:A,itemTextRegistry:Xe.current,registerItemText:Qe,listId:v,inputRef:ee,setInputElement:We,inputWrapperRef:Ie,setInputWrapperElement:je,closeOnSelect:Ye,openOnFocus:n,openCombobox:eo,closeCombobox:oo,filterMode:Ze,setFilterActive:_e,inputHeight:Ae,inputWidth:ze,layout:S}),[o,$,se,Ue,Ge,b,R,a,$e,Je,y,L,w,G,V,A,Qe,v,We,je,Ye,n,eo,oo,Ze,_e,Ae,ze,S]),lt=h.useMemo(()=>y?o?se.length>0?se.map((g,H)=>{let K=F(g,a);return me("input",{type:"hidden",name:y,value:K,form:L,required:w&&H===0},K)}):me("input",{type:"hidden",name:y,value:"",form:L,required:w}):me("input",{type:"hidden",name:y,value:$!=null?F($,a):"",form:L,required:w}):null,[y,L,w,o,$,se,a]);return me(lo.Provider,{value:st,children:kt(po,{store:B,focusOwnerStore:Go,openChainStore:$o,disabled:G,depth:0,closeAll:Xo,registerSurface:Jo,virtualization:Qo,menuType:"dropdown",componentName:"combobox",debug:W,children:[lt,me(Tt.Root,{..._,open:Yo,onOpenChange:_o,onOpenChangeComplete:Zo,modal:q,actionsRef:p?Re:void 0,children:z})]})})}import*as Z from"react";var Ao={slot:"bazzaui-combobox-surface"};import{jsx as Ht}from"react/jsx-runtime";var De=Z.forwardRef(function(e,t){let{autoHighlightFirst:p,search:s,onSearchChange:r,onPointerMove:m,...d}=e,o=D(),l=Z.useCallback(a=>{m?.(a);let f=o.inputRef.current;f&&document.activeElement!==f&&f.focus()},[m,o.inputRef]),u=Z.useMemo(()=>{let a=p??!0;if(a==="selected"){let f=o.multiple?o.values[0]:o.value;return f!=null?F(f,o.itemToStringValue):!0}return a},[p,o.multiple,o.value,o.values,o.itemToStringValue]),{filterMode:C}=o,b=s??(C.type==="active"?o.inputValue:C.type==="showAll"?"":C.search),R=Z.useCallback(a=>{o.onInputValueChange(a),r?.(a)},[o,r]);return Ht(Po,{ref:t,autoHighlightFirst:u,search:b,onSearchChange:R,onPointerMove:l,skipAutoFocus:!0,[Ao.slot]:"",...d})});var zo=(m=>(m.slot="bazzaui-combobox-arrow",m.open="data-open",m.closed="data-closed",m.side="data-side",m.align="data-align",m.uncentered="data-uncentered",m))(zo||{});var Bo=(r=>(r.slot="bazzaui-combobox-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Bo||{});var Wo=(e=>(e.slot="bazzaui-combobox-empty",e))(Wo||{});var jo=(e=>(e.slot="bazzaui-combobox-group",e))(jo||{});var No=(e=>(e.slot="bazzaui-combobox-group-label",e))(No||{});var Ot={slot:"bazzaui-combobox-icon",open:"data-popup-open"};var qo=(t=>(t.slot="bazzaui-combobox-list",t.list="data-popup-menu-list",t))(qo||{});var Ko=(b=>(b.slot="bazzaui-combobox-popup",b.open="data-open",b.closed="data-closed",b.side="data-side",b.align="data-align",b.startingStyle="data-starting-style",b.endingStyle="data-ending-style",b.instant="data-instant",b.focused="data-focused",b.hasOpenSubmenu="data-has-open-submenu",b.submenu="data-submenu",b.navigating="data-navigating",b))(Ko||{});var Dt={slotUp:"bazzaui-combobox-scroll-up-arrow",slotDown:"bazzaui-combobox-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Uo=(e=>(e.slot="bazzaui-combobox-separator",e))(Uo||{});export{Fo as Combobox,zo as ComboboxArrowDataAttributes,Bo as ComboboxBackdropDataAttributes,ve as ComboboxClear,Wo as ComboboxEmptyDataAttributes,jo as ComboboxGroupDataAttributes,No as ComboboxGroupLabelDataAttributes,Ot as ComboboxIconDataAttributes,Ee as ComboboxInput,Q as ComboboxInputDataAttributes,Le as ComboboxInputWrapper,Ce as ComboboxInputWrapperDataAttributes,we as ComboboxItem,ae as ComboboxItemDataAttributes,Te as ComboboxItemIndicator,ge as ComboboxItemIndicatorDataAttributes,ke as ComboboxItemLabel,Ct as ComboboxListCssVars,qo as ComboboxListDataAttributes,Ko as ComboboxPopupDataAttributes,He as ComboboxPositioner,xt as ComboboxPositionerCssVars,Pe as ComboboxPositionerDataAttributes,Oe as ComboboxRoot,Dt as ComboboxScrollArrowDataAttributes,Uo as ComboboxSeparatorDataAttributes,bt as ComboboxStore,De as ComboboxSurface,mt as commandScore,ct as defaultFilter,D as useComboboxContext,ie as useComboboxItemContext,Ve as useComboboxPositionerContext,dt as useMaybeComboboxContext,Rt as useMaybeComboboxItemContext,pt as useMaybeSurfaceContext,it as useSurfaceContext};
|
|
1
|
+
import{a as yo,b as vo,c as Vo,d as Mo,e as Eo,f as te,g as Lo}from"../chunk-KO3DXT3Y.js";import{Ab as So,L as ro,La as uo,Ma as io,N as ao,Na as xt,P as so,Qa as po,R as lo,Ra as mo,S as D,Sa as co,T as dt,Ua as bo,Va as N,Wa as F,Xa as xo,Ya as Co,_a as Ct,ab as fo,eb as go,f as no,fb as ho,gb as Po,l as ce,yb as Io,zb as Ro}from"../chunk-23NDAOAL.js";import{a as oe,p as it,q as pt,w as mt,x as ct,y as bt}from"../chunk-ZPRKUVIC.js";import{a as ut}from"../chunk-4C666HHU.js";var Fo={};ut(Fo,{Arrow:()=>ao,Backdrop:()=>so,Clear:()=>ve,Empty:()=>Co,Group:()=>Io,GroupLabel:()=>Ro,Icon:()=>xo,Input:()=>Ee,InputWrapper:()=>Le,Item:()=>we,ItemIndicator:()=>Te,ItemLabel:()=>ke,List:()=>fo,Popup:()=>uo,Portal:()=>io,Positioner:()=>He,Root:()=>Oe,ScrollDownArrow:()=>ho,ScrollUpArrow:()=>go,Separator:()=>So,Surface:()=>De,useComboboxPositionerContext:()=>Ve});import{useRender as ft}from"@base-ui/react/use-render";import*as X from"react";var wo={slot:"bazzaui-combobox-clear"};var ve=X.forwardRef(function(e,t){let{keepMounted:i=!1,disabled:s,render:r,className:m,style:b,onClick:o,onPointerDown:l,...C}=e,p=D(),d=s??p.disabled,P=p.multiple?p.values.length>0:p.value!=="",a=X.useCallback(I=>{o?.(I),!I.defaultPrevented&&(p.multiple?p.onValuesChange([]):p.onValueChange(""),p.onInputValueChange(""))},[o,p]),f=X.useCallback(I=>{I.preventDefault(),l?.(I)},[l]),c=X.useMemo(()=>({hasValue:P,disabled:d}),[P,d]),S=ft({render:r,ref:t,state:c,props:{...C,[wo.slot]:"",type:"button",tabIndex:-1,"aria-label":"Clear selection",disabled:d||!P,className:m,style:b,onClick:a,onPointerDown:f},enabled:i||P,defaultTagName:"button"});return!i&&!P?null:S});import*as be from"react";var de=be.createContext(null);function Ve(){return be.useContext(de)}import{useRender as gt}from"@base-ui/react/use-render";import*as ne from"react";import*as xe from"react";var Me=xe.createContext(!1);function To(){return xe.useContext(Me)}var Q={slot:"bazzaui-combobox-input",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import*as le from"react";function ko(R){let{comboboxContext:e,open:t}=R,i=e.multiple?e.values.length>0:!bo(e.value),s=le.useCallback(b=>{let o=F(b,e.itemToStringValue),l=e.itemTextRegistry.get(o);if(l!==void 0)return l;let C=te(e.items,o);if(typeof C=="string")return C;let p=N(b,e.itemToStringLabel);if(p&&p!==o)return p},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),r=le.useMemo(()=>{if(!i)return"";if(e.multiple){let l=e.values.map(C=>{let p=s(C);return p!==void 0?p:N(C,e.itemToStringLabel)||F(C,e.itemToStringValue)}).filter(Boolean);return l.length<=2?l.join(", "):`${l.length} selected`}let b=e.value;if(b==null)return"";let o=s(b);return o!==void 0?o:N(b,e.itemToStringLabel)||F(b,e.itemToStringValue)},[i,e.multiple,e.value,e.values,e.itemToStringLabel,e.itemToStringValue,s]),m=le.useMemo(()=>t?e.inputValue:r,[t,r,e.inputValue]);return{hasValue:i,displayValue:m,selectedLabel:r,getValueText:s}}import*as k from"react";function Ho(R){let{comboboxContext:e,store:t,focusOwnerStore:i,open:s,disabled:r,cursorBehavior:m,hasValue:b,getValueText:o,onFocus:l,onBlur:C,onClick:p,onKeyDown:d}=R,P=k.useRef(!1),a=k.useRef(!1),f=k.useRef(!1),c=k.useRef(null),S=k.useRef(null),I=k.useRef(null);k.useEffect(()=>{if(!s)return;let n=x=>{let u=e.inputRef.current,M=e.inputWrapperRef.current,y=document.getElementById(e.listId),O=x.target,W=u?.contains(O),z=M?.contains(O),_=y?.contains(O);!W&&!z&&!_&&(I.current=x)};return document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("pointerdown",n,!0),I.current=null}},[s,e.inputRef,e.inputWrapperRef,e.listId]),k.useLayoutEffect(()=>{let n=e.inputRef.current;if(n&&s&&S.current){let{start:x,end:u}=S.current,M=n.selectionStart,y=n.value.length;M===y&&x!==y&&n.setSelectionRange(x,u),S.current=null}});let L=k.useRef(s);k.useLayoutEffect(()=>{if(s&&!L.current){if(P.current){P.current=!1,L.current=s;return}if(f.current){f.current=!1,a.current=!1,c.current=null,L.current=s;return}if(a.current&&m==="none"){let x=e.inputRef.current,u=c.current;x&&u!==null&&requestAnimationFrame(()=>{let M=x.value.length,y=Math.min(u,M);x.setSelectionRange(y,y)}),a.current=!1,c.current=null,L.current=s;return}b&&e.multiple&&e.onInputValueChange("");let n=e.inputRef.current;if(n){let x=n.value.length;m==="select-all"&&x>0?requestAnimationFrame(()=>{n.setSelectionRange(0,n.value.length)}):m==="end"&&x>0&&requestAnimationFrame(()=>{n.setSelectionRange(n.value.length,n.value.length)})}}L.current=s},[s,e,b,m]);let w=k.useCallback(n=>{let x=n.target,u=x.value,M=x.selectionStart,y=x.selectionEnd;M!==null&&y!==null&&(S.current={start:M,end:y}),e.onInputValueChange(u),e.setFilterActive(),t.setSearch(u),t.state.open||(P.current=!0,e.openCombobox())},[e,t]),T=k.useCallback(n=>{if(l?.(n),n.defaultPrevented)return;let x=t.state.open;if(x&&(f.current=!0),e.openOnFocus&&!r&&!x){if(b&&!e.multiple){let u=o(e.value)??N(e.value,e.itemToStringLabel);e.onInputValueChange(u)}e.openCombobox()}},[l,e,r,t,b,o]),V=k.useCallback(n=>{C?.(n),!n.defaultPrevented&&requestAnimationFrame(()=>{let x=document.activeElement,M=document.getElementById(e.listId)?.contains(x),y=x===e.inputRef.current;if(!M&&!y){f.current=!1;let O=I.current,W=O?oe.outsidePress:oe.focusOut;I.current=null,e.closeCombobox(W,O??void 0)}})},[C,e]),A=k.useCallback(n=>{if(p?.(n),n.defaultPrevented)return;let x=t.state.open;if(!r&&!x){let u=n.target;if(m==="none"){let M=u.selectionStart;c.current=M,a.current=!0}if(b&&!e.multiple){let M=o(e.value)??N(e.value,e.itemToStringLabel);e.onInputValueChange(M)}e.openCombobox()}else x&&(f.current=!0)},[p,e,r,t,m,b,o]),q=k.useCallback(n=>{if(d?.(n),!n.defaultPrevented){if(s&&n.key==="Escape"){n.preventDefault(),e.closeCombobox(oe.escapeKey);return}if(!s&&(n.key==="ArrowDown"||n.key==="ArrowUp"||n.key==="Enter")){if(n.preventDefault(),b&&!e.multiple){let x=o(e.value)??N(e.value,e.itemToStringLabel);e.onInputValueChange(x)}e.openCombobox();return}}},[s,e,d,b,o]),{handleKeyDown:j}=co({store:t,surfaceId:"combobox-input",focusOwnerStore:i,depth:0,submenuContext:null,subpageContext:null,enabled:s,enableTypeToSearch:!1,onKeyDown:q,closeAll:e.closeCombobox,skipFocusOwnerCheck:!0});return{handleChange:w,handleFocus:T,handleBlur:V,handleClick:A,handleKeyDown:j,selectionRef:S}}var Ee=ne.forwardRef(function(e,t){let{placeholder:i,disabled:s,cursorBehavior:r="none",render:m,className:b,style:o,onFocus:l,onBlur:C,onClick:p,onKeyDown:d,...P}=e,a=D(),f=ce(),c=no(),S=To(),I=(s??a.disabled)||f.disabled,L=te(a.items,""),w=i??(typeof L=="string"?L:void 0)??a.placeholder,T=f.store.useState("open"),{hasValue:V,displayValue:A,getValueText:q}=ko({comboboxContext:a,open:T}),{handleChange:j,handleFocus:n,handleBlur:x,handleClick:u,handleKeyDown:M}=Ho({comboboxContext:a,store:f.store,focusOwnerStore:c,open:T,disabled:I,cursorBehavior:r,hasValue:V,getValueText:q,onFocus:l,onBlur:C,onClick:p,onKeyDown:d}),y={[Q.slot]:""};T?y[Q.open]="":y[Q.closed]="",I&&(y[Q.disabled]=""),V||(y[Q.placeholder]=""),a.layout==="input-embedded"&&(y["data-input-embedded"]="");let O=ne.useCallback(v=>{a.setInputElement(v),typeof t=="function"?t(v):t&&(t.current=v)},[t,a]),W=ne.useMemo(()=>({open:T,disabled:I,placeholder:!V}),[T,I,V]),z=a.layout==="input-embedded"&&!S?{position:"relative",zIndex:1}:void 0;return gt({render:m,ref:O,state:W,props:{...P,...y,type:"text",role:"combobox","aria-autocomplete":"list","aria-expanded":T,"aria-controls":a.listId,"aria-haspopup":"listbox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:I,placeholder:V?void 0:w,className:b,style:{...z,...o},value:A,onChange:j,onFocus:n,onBlur:x,onClick:u,onKeyDown:M},defaultTagName:"input"})});import{useRender as ht}from"@base-ui/react/use-render";import*as re from"react";var Ce={slot:"bazzaui-combobox-input-wrapper",open:"data-open"};import{jsx as It}from"react/jsx-runtime";var Pt={open:R=>R?{[Ce.open]:""}:null},Le=re.forwardRef(function(e,t){let{render:i,className:s,style:r,children:m,...b}=e,{store:o}=ce(),l=D(),C=o.useState("open"),p=re.useMemo(()=>({open:C}),[C]),d=l.layout==="input-embedded"?{position:"relative",zIndex:1}:{position:"relative"},P=re.useCallback(f=>{l.setInputWrapperElement(f),typeof t=="function"?t(f):t&&(t.current=f)},[t,l]),a=ht({render:i,ref:P,state:p,stateAttributesMapping:Pt,props:{...b,[Ce.slot]:"",className:s,style:{...d,...r},children:m},defaultTagName:"div"});return It(Me.Provider,{value:!0,children:a})});import{useRender as St}from"@base-ui/react/use-render";import*as E from"react";var ae={slot:"bazzaui-combobox-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};import*as ue from"react";var fe=ue.createContext(null);function ie(){let R=ue.useContext(fe);if(!R)throw new Error("ComboboxItem child components must be used within a Combobox.Item");return R}function Rt(){return ue.useContext(fe)}import{jsx as Vt}from"react/jsx-runtime";var yt={highlighted:R=>R?{[ae.highlighted]:""}:null,disabled:R=>R?{[ae.disabled]:""}:null,selected:R=>R?{[ae.selected]:""}:null};function vt(R,e){let{value:t,textValue:i,keywords:s,disabled:r=!1,onSelect:m,forceMount:b=!1,render:o,className:l,style:C,onClick:p,onPointerDown:d,onPointerMove:P,children:a,...f}=R,c=D(),S=E.useMemo(()=>F(t,c.itemToStringValue),[t,c.itemToStringValue]),I=E.useId(),L=t===null?`combobox-clear-${I}`:void 0,w=E.useMemo(()=>Eo(c.items,S),[c.items,S]),T=w?.label,V=E.useMemo(()=>N(t,c.itemToStringLabel),[t,c.itemToStringLabel]),A=E.useMemo(()=>{if(i!==void 0)return i;if(typeof T=="string")return T;if(V&&V!==S)return V},[i,T,V,S]),q=E.useMemo(()=>Lo(s,[typeof T=="string"?T:V&&V!==S?V:void 0,...w?.keywords??[]]),[s,T,V,S,w]),j=E.useRef(A),n=c.multiple?Vo(c.values,t,c.isItemEqualToValue):c.value!==""&&vo(c.value,t,c.isItemEqualToValue),x=c.closeOnSelect,u=mo({id:L,value:S,keywords:q,disabled:r,forceMount:b,closeOnClick:x,children:a});E.useEffect(()=>{let v=()=>{if(!r){if(c.multiple)if(t==null)c.onValuesChange([]);else{let ee=n?Mo(c.values,t,c.isItemEqualToValue):[...c.values,t];c.onValuesChange(ee)}else c.onValueChange(t);m?.()}};return u.registerSelect(v)},[r,c,t,n,m,u]),E.useEffect(()=>{let v=j.current;if(v)return c.registerItemText(S,v)},[S,c]),E.useEffect(()=>{!A&&typeof a=="string"&&(j.current=a,c.registerItemText(S,a))},[a,A,S,c]);let M=E.useMemo(()=>({highlighted:u.isHighlighted,disabled:r,selected:n}),[u.isHighlighted,r,n]),y=E.useMemo(()=>({id:u.id,value:t,textValue:A,highlighted:u.isHighlighted,disabled:r,selected:n}),[u.id,t,A,u.isHighlighted,r,n]),O=E.useCallback(v=>{p?.(v),v.defaultPrevented||u.handlers.onClick(v)},[p,u.handlers]),W=E.useCallback(v=>{u.handlers.onPointerDown(v),d?.(v)},[u.handlers,d]),z=E.useCallback(v=>{P?.(v),v.defaultPrevented||u.handlers.onPointerMove(v)},[P,u.handlers]),_=St({render:o,ref:[u.ref,e],state:M,stateAttributesMapping:yt,props:{...f,[ae.slot]:"",id:u.id,role:"option",tabIndex:-1,"aria-selected":n,"aria-disabled":r||void 0,className:l,style:C,onClick:O,onPointerMove:z,onPointerDown:W,children:a},enabled:u.isVisible,defaultTagName:"div"});return u.isVisible?Vt(fe.Provider,{value:y,children:_}):null}var we=E.forwardRef(vt);import{useRender as Mt}from"@base-ui/react/use-render";import*as he from"react";var ge={slot:"bazzaui-combobox-item-indicator",selected:"data-selected"};var Et={selected:R=>R?{[ge.selected]:""}:null},Te=he.forwardRef(function(e,t){let{keepMounted:i=!1,render:s,className:r,style:m,...b}=e,o=ie(),l=he.useMemo(()=>({selected:o.selected}),[o.selected]),C=Mt({render:s,ref:t,state:l,stateAttributesMapping:Et,props:{...b,[ge.slot]:"","aria-hidden":!0,className:r,style:m},enabled:i||o.selected,defaultTagName:"span"});return!i&&!o.selected?null:C});import{useRender as Lt}from"@base-ui/react/use-render";import*as Y from"react";var Oo={slot:"bazzaui-combobox-item-label"};var ke=Y.forwardRef(function(e,t){let{render:i,className:s,style:r,children:m,...b}=e,o=D(),l=ie(),C=F(l.value,o.itemToStringValue),p=Y.useMemo(()=>{if(m!==void 0)return m;let P=te(o.items,C);return P!==void 0?P:l.textValue!==void 0?l.textValue:C},[m,o.items,C,l.textValue]),d=Y.useMemo(()=>({value:C,selected:l.selected,highlighted:l.highlighted,disabled:l.disabled}),[C,l.selected,l.highlighted,l.disabled]);return Y.useEffect(()=>{if(typeof p=="string")return o.registerItemText(C,p)},[p,o,C]),Lt({render:i,ref:t,state:d,props:{...b,[Oo.slot]:"",className:s,style:r,children:p},defaultTagName:"span"})});import{Popover as Do}from"@base-ui/react/popover";import*as U from"react";var Pe={slot:"bazzaui-combobox-positioner"};import{jsx as pe}from"react/jsx-runtime";function wt(R,e,t,i){let s=t+i*2;if(R==="top"){let b=-(e+i),o=e+i;return{width:s,marginBottom:b,paddingTop:i,paddingLeft:i,paddingRight:i,paddingBottom:o}}let r=-(e+i),m=e+i;return{width:s,marginTop:r,paddingTop:m,paddingLeft:i,paddingRight:i,paddingBottom:i}}var He=U.forwardRef(function(e,t){let{layout:i,popupPadding:s=8,side:r="bottom",align:m,sideOffset:b=4,anchor:o,className:l,style:C,children:p,...d}=e,P=D(),a=i??P.layout,f=a==="input-embedded",c=o??P.inputWrapperRef.current?P.inputWrapperRef:P.inputRef,S=f?0:b,I=f?"center":m??"start",{inputHeight:L,inputWidth:w}=P,T=w+s*2,V={...C,...f?{zIndex:0}:{}};if(f)return pe(Do.Positioner,{ref:t,side:r,align:I,sideOffset:S,anchor:c,className:l,style:V,"data-input-embedded":"",[Pe.slot]:"",...d,render:(n,x)=>{let u=x.side,M={layout:a,side:u,align:x.align,inputHeight:P.inputHeight},y={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`,"--combobox-popup-padding":`${s}px`,"--combobox-popup-width":`${T}px`},O=wt(u,L,w,s),W=U.Children.map(p,z=>U.isValidElement(z)?U.cloneElement(z,{style:{...O,...z.props.style},"data-side":u}):z);return pe(de.Provider,{value:M,children:pe("div",{...n,style:{...n.style,...y},"data-side":u,children:W})})}});let A={layout:a,side:r,align:I,inputHeight:P.inputHeight},q={"--combobox-input-height":`${L}px`,"--combobox-input-width":`${w}px`},j={...V,...q};return pe(de.Provider,{value:A,children:pe(Do.Positioner,{ref:t,side:r,align:I,sideOffset:S,anchor:c,className:l,style:j,[Pe.slot]:"",...d,children:p})})});import{Popover as Tt}from"@base-ui/react/popover";import*as h from"react";import{jsx as me,jsxs as kt}from"react/jsx-runtime";function Oe(R){let{open:e,onOpenChange:t,actionsRef:i,defaultOpen:s=!1,value:r,defaultValue:m,onValueChange:b,multiple:o=!1,values:l,defaultValues:C,onValuesChange:p,isItemEqualToValue:d=yo,itemToStringLabel:P,itemToStringValue:a,inputValue:f,defaultInputValue:c="",onInputValueChange:S,name:I,form:L,required:w,disabled:T=!1,placeholder:V="Search...",items:A,modal:q=!1,closeOnSelect:j,openOnFocus:n=!0,virtualized:x=!1,virtualItems:u,onHighlightChange:M,layout:y="floating",onOpenChangeComplete:O,debug:W,children:z,..._}=R,v=h.useId(),ee=h.useRef(null),Ie=h.useRef(null),[Ae,Fe]=h.useState(0),[ze,Be]=h.useState(0),We=h.useCallback(g=>{if(ee.current=g,g&&!Ie.current){let H=g.getBoundingClientRect();Fe(H.height),Be(H.width)}},[]),je=h.useCallback(g=>{if(Ie.current=g,g){let H=g.getBoundingClientRect();Fe(H.height),Be(H.width)}},[]),{store:B,focusOwnerStore:Go,openChainStore:$o,registerSurface:Jo,closeAll:Xo,virtualization:Qo,handleOpenChange:Ne,disabled:G,setDisabled:qe}=ro({onOpenChange:t,defaultOpen:s,virtualized:x,items:u,onHighlightChange:M,disabled:T}),Re=h.useRef(null);h.useImperativeHandle(i,()=>({close:()=>{Re.current?.close()},unmount:()=>{Re.current?.unmount()},setDisabled:qe}),[qe]),B.useControlledProp("openProp",e);let Yo=B.useState("open"),Ke=h.useCallback((g,H,K)=>{G&&H!==oe.imperativeAction||!g&&ee.current&&document.activeElement===ee.current||Ne(g,H,K)},[Ne,G]),Zo=h.useCallback(g=>{!g&&B.context.clearSearchOnClose==="after-exit"&&(B.clearSearch(),B.setInputActive(!1)),g||B.clearHighlight(),O?.(g)},[B,O]),_o=h.useCallback((g,H)=>{Ke(g,H.reason,H.event)},[Ke]),[et,ot]=h.useState(m!==void 0?m:null),$=r!==void 0?r:et,Ue=h.useCallback(g=>{r===void 0&&ot(g),b?.(g)},[r,b]),[tt,nt]=h.useState(C??[]),se=l!==void 0?l:tt,Ge=h.useCallback(g=>{l===void 0&&nt(g),p?.(g)},[l,p]),[Se,rt]=h.useState(c),$e=f!==void 0?f:Se,Je=h.useCallback(g=>{f===void 0&&rt(g),S?.(g)},[f,S]),Xe=h.useRef(new Map),Qe=h.useCallback((g,H)=>(Xe.current.set(g,H),()=>{}),[]),Ye=j??!o,ye=h.useRef({type:"active"}),[,at]=h.useState({type:"active"}),J=h.useCallback(g=>{ye.current=g,at(g)},[]),Ze=ye.current,_e=h.useCallback(()=>{J({type:"active"})},[J]),eo=h.useCallback(()=>{G||(!o&&$!=null?J({type:"showAll"}):J({type:"active"}),B.setOpen(!0))},[G,B,o,$,J]),oo=h.useCallback((g,H)=>{let K=ye.current,to=K.type==="active"?Se:K.type==="showAll"?"":K.search;J({type:"frozen",search:to}),B.setOpen(!1,g,H)},[B,J,Se]),st=h.useMemo(()=>({multiple:o,value:$,values:se,onValueChange:Ue,onValuesChange:Ge,isItemEqualToValue:d,itemToStringLabel:P,itemToStringValue:a,inputValue:$e,onInputValueChange:Je,name:I,form:L,required:w,disabled:G,placeholder:V,items:A,itemTextRegistry:Xe.current,registerItemText:Qe,listId:v,inputRef:ee,setInputElement:We,inputWrapperRef:Ie,setInputWrapperElement:je,closeOnSelect:Ye,openOnFocus:n,openCombobox:eo,closeCombobox:oo,filterMode:Ze,setFilterActive:_e,inputHeight:Ae,inputWidth:ze,layout:y}),[o,$,se,Ue,Ge,d,P,a,$e,Je,I,L,w,G,V,A,Qe,v,We,je,Ye,n,eo,oo,Ze,_e,Ae,ze,y]),lt=h.useMemo(()=>I?o?se.length>0?se.map((g,H)=>{let K=F(g,a);return me("input",{type:"hidden",name:I,value:K,form:L,required:w&&H===0},K)}):me("input",{type:"hidden",name:I,value:"",form:L,required:w}):me("input",{type:"hidden",name:I,value:$!=null?F($,a):"",form:L,required:w}):null,[I,L,w,o,$,se,a]);return me(lo.Provider,{value:st,children:kt(po,{store:B,focusOwnerStore:Go,openChainStore:$o,disabled:G,depth:0,closeAll:Xo,registerSurface:Jo,virtualization:Qo,menuType:"dropdown",componentName:"combobox",debug:W,children:[lt,me(Tt.Root,{..._,open:Yo,onOpenChange:_o,onOpenChangeComplete:Zo,modal:q,actionsRef:i?Re:void 0,children:z})]})})}import*as Z from"react";var Ao={slot:"bazzaui-combobox-surface"};import{jsx as Ht}from"react/jsx-runtime";var De=Z.forwardRef(function(e,t){let{autoHighlightFirst:i,search:s,onSearchChange:r,onPointerMove:m,...b}=e,o=D(),l=Z.useCallback(a=>{m?.(a);let f=o.inputRef.current;f&&document.activeElement!==f&&f.focus()},[m,o.inputRef]),C=Z.useMemo(()=>{let a=i??!0;if(a==="selected"){let f=o.multiple?o.values[0]:o.value;return f!=null?F(f,o.itemToStringValue):!0}return a},[i,o.multiple,o.value,o.values,o.itemToStringValue]),{filterMode:p}=o,d=s??(p.type==="active"?o.inputValue:p.type==="showAll"?"":p.search),P=Z.useCallback(a=>{o.onInputValueChange(a),r?.(a)},[o,r]);return Ht(Po,{ref:t,autoHighlightFirst:C,search:d,onSearchChange:P,onPointerMove:l,skipAutoFocus:!0,[Ao.slot]:"",...b})});var zo=(m=>(m.slot="bazzaui-combobox-arrow",m.open="data-open",m.closed="data-closed",m.side="data-side",m.align="data-align",m.uncentered="data-uncentered",m))(zo||{});var Bo=(r=>(r.slot="bazzaui-combobox-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Bo||{});var Wo=(e=>(e.slot="bazzaui-combobox-empty",e))(Wo||{});var jo=(e=>(e.slot="bazzaui-combobox-group",e))(jo||{});var No=(e=>(e.slot="bazzaui-combobox-group-label",e))(No||{});var Ot={slot:"bazzaui-combobox-icon",open:"data-popup-open"};var qo=(t=>(t.slot="bazzaui-combobox-list",t.list="data-popup-menu-list",t))(qo||{});var Ko=(d=>(d.slot="bazzaui-combobox-popup",d.open="data-open",d.closed="data-closed",d.side="data-side",d.align="data-align",d.startingStyle="data-starting-style",d.endingStyle="data-ending-style",d.instant="data-instant",d.focused="data-focused",d.hasOpenSubmenu="data-has-open-submenu",d.submenu="data-submenu",d.navigating="data-navigating",d))(Ko||{});var Dt={slotUp:"bazzaui-combobox-scroll-up-arrow",slotDown:"bazzaui-combobox-scroll-down-arrow",direction:"data-direction",side:"data-side"};var Uo=(e=>(e.slot="bazzaui-combobox-separator",e))(Uo||{});export{Fo as Combobox,zo as ComboboxArrowDataAttributes,Bo as ComboboxBackdropDataAttributes,ve as ComboboxClear,Wo as ComboboxEmptyDataAttributes,jo as ComboboxGroupDataAttributes,No as ComboboxGroupLabelDataAttributes,Ot as ComboboxIconDataAttributes,Ee as ComboboxInput,Q as ComboboxInputDataAttributes,Le as ComboboxInputWrapper,Ce as ComboboxInputWrapperDataAttributes,we as ComboboxItem,ae as ComboboxItemDataAttributes,Te as ComboboxItemIndicator,ge as ComboboxItemIndicatorDataAttributes,ke as ComboboxItemLabel,Ct as ComboboxListCssVars,qo as ComboboxListDataAttributes,Ko as ComboboxPopupDataAttributes,He as ComboboxPositioner,xt as ComboboxPositionerCssVars,Pe as ComboboxPositionerDataAttributes,Oe as ComboboxRoot,Dt as ComboboxScrollArrowDataAttributes,Uo as ComboboxSeparatorDataAttributes,bt as ComboboxStore,De as ComboboxSurface,mt as commandScore,ct as defaultFilter,D as useComboboxContext,ie as useComboboxItemContext,Ve as useComboboxPositionerContext,dt as useMaybeComboboxContext,Rt as useMaybeComboboxItemContext,pt as useMaybeSurfaceContext,it as useSurfaceContext};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|