@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/select/index.cjs","../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","SelectItemContext","useSelectItemContext","useMaybeSelectItemContext","stateAttributesMapping","value","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerMove","children","rest","selectContext","serializedValue","stringifyAsValue","generatedItemId","listboxId"],"mappings":"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","file":"/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","sourcesContent":[null,"// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.isHighlighted, disabled, selected],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","../../src/select/index.parts.ts","../../src/select/item/item.tsx","../../src/select/contexts/select-context.ts","../../src/select/item/item.data-attrs.ts","../../src/select/item/item-context.ts"],"names":["index_parts_exports","__export","PopupMenuArrow","PopupMenuBackdrop","PopupMenuEmpty","PopupMenuGroup","PopupMenuGroupLabel","PopupMenuIcon","PopupMenuInput","SelectItem","SelectItemIndicator","SelectItemLabel","PopupMenuList","SelectPopup","PopupMenuPortal","SelectPositioner","SelectRoot","PopupMenuScrollDownArrow","PopupMenuScrollUpArrow","PopupMenuSeparator","SelectSurface","SelectTrigger","SelectValue","SelectContext","useSelectContext","context","useMaybeSelectContext","SelectItemDataAttributes","SelectItemContext","useSelectItemContext","useMaybeSelectItemContext","stateAttributesMapping","value","SelectItemImpl","props","forwardedRef","textValueProp","keywordsProp","disabled","onSelect","forceMount","render","className","style","onClick","onPointerDown","onPointerMove","children","rest","selectContext","serializedValue","stringifyAsValue","generatedItemId","listboxId"],"mappings":"AAAA,4/BAA0C,yDAA2F,yDAA6O,yDAAmF,yDAA2C,ICAhfA,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,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,oBAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,aAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,SAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,MAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,UAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,eAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,aAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,SAAA,CAAA,CAAA,CAAA,EAAAC,oBAAAA,CAAA,OAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,OAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAAC,EAAAA,CAAAA,CAAAA,CCEA,sDAA0B,khBACH,IC2GjBC,EAAAA,CAAsB,EAAA,CAAA,aAAA,CAC1B,IACF,CAAA,CAMO,SAASC,CAAAA,CAAAA,CAA+D,CAC7E,IAAMC,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWF,EAAa,CAAA,CAC9C,EAAA,CAAI,CAACE,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,qDAAqD,CAAA,CAEvE,OAAOA,CACT,CAMO,SAASC,EAAAA,CAAAA,CAEsB,CACpC,OAAa,EAAA,CAAA,UAAA,CAAWH,EAAa,CACvC,CCtIO,IAAMI,EAAAA,CAA2B,CAKtC,IAAA,CAAM,qBAAA,CAIN,WAAA,CAAa,kBAAA,CAIb,QAAA,CAAU,eAAA,CAIV,QAAA,CAAU,eACZ,CAAA,CChBA,IAsBMC,EAAAA,CAA0B,EAAA,CAAA,aAAA,CAC9B,IACF,CAAA,CAEO,SAASC,EAAAA,CAAAA,CAEmB,CACjC,IAAMJ,CAAAA,CAAgB,EAAA,CAAA,UAAA,CAAWG,EAAiB,CAAA,CAClD,EAAA,CAAI,CAACH,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,gEACF,CAAA,CAEF,OAAOA,CACT,CAEO,SAASK,EAAAA,CAAAA,CAE0B,CACxC,OAAa,EAAA,CAAA,UAAA,CACXF,EACF,CACF,CHiSI,+CAAA,IA7PEG,EAAAA,CAAyB,CAC7B,WAAA,CAAcC,CAAAA,EACZA,CAAAA,CAAQ,CAAE,CAACL,EAAAA,CAAyB,WAAW,CAAA,CAAG,EAAG,CAAA,CAAI,IAAA,CAC3D,QAAA,CAAWK,CAAAA,EACTA,CAAAA,CAAQ,CAAE,CAACL,EAAAA,CAAyB,QAAQ,CAAA,CAAG,EAAG,CAAA,CAAI,IAAA,CACxD,QAAA,CAAWK,CAAAA,EACTA,CAAAA,CAAQ,CAAE,CAACL,EAAAA,CAAyB,QAAQ,CAAA,CAAG,EAAG,CAAA,CAAI,IAC1D,CAAA,CAQA,SAASM,EAAAA,CACPC,CAAAA,CACAC,CAAAA,CACA,CACA,GAAM,CACJ,KAAA,CAAAH,CAAAA,CACA,SAAA,CAAWI,CAAAA,CACX,QAAA,CAAUC,CAAAA,CACV,QAAA,CAAAC,CAAAA,CAAW,CAAA,CAAA,CACX,QAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CAAa,CAAA,CAAA,CACb,MAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,aAAA,CAAAC,CAAAA,CACA,aAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,GAAGC,CACL,CAAA,CAAId,CAAAA,CAEEe,CAAAA,CAAgBzB,CAAAA,CAAwB,CAAA,CAGxC0B,CAAAA,CAAwB,CAAA,CAAA,OAAA,CAC5B,CAAA,CAAA,EAAMC,kCAAAA,CAAiBnB,CAAOiB,CAAAA,CAAc,iBAAiB,CAAA,CAC7D,CAACjB,CAAAA,CAAOiB,CAAAA,CAAc,iBAAiB,CACzC,CAAA,CAKMG,CAAAA,CAAwB,CAAA,CAAA,KAAA,CAAM,CAAA,CAC9BC,CAAAA,CACJrB,CAAAA,GAAU,IAAA,CAAO,CAAA,aAAA,EAAgBoB,CAAe,CAAA,CAAA","file":"/home/runner/work/ui/ui/packages/react/dist/select/index.cjs","sourcesContent":[null,"// ============================================================================\n// Select Parts\n// ============================================================================\n// Re-exports shared components from internal/popup-menu with Select-specific\n// Root, Trigger, Value, Item, ItemLabel, and ItemIndicator components.\n\n// Re-export VirtualItem type from internal/listbox\nexport type { VirtualItem } from '../internal/listbox/index.js'\n\n// Re-export shared components from internal/popup-menu\nexport {\n PopupMenuArrow as Arrow,\n PopupMenuBackdrop as Backdrop,\n PopupMenuEmpty as Empty,\n // Structure\n PopupMenuGroup as Group,\n PopupMenuGroupLabel as GroupLabel,\n // Trigger components\n PopupMenuIcon as Icon,\n PopupMenuInput as Input,\n PopupMenuList as List,\n // Positioning & Container\n PopupMenuPortal as Portal,\n // Scroll indicators\n PopupMenuScrollDownArrow as ScrollDownArrow,\n PopupMenuScrollUpArrow as ScrollUpArrow,\n PopupMenuSeparator as Separator,\n} from '../internal/popup-menu/index.js'\nexport { SelectItem as Item } from './item/item.js'\nexport { SelectItemIndicator as ItemIndicator } from './item-indicator/item-indicator.js'\nexport { SelectItemLabel as ItemLabel } from './item-label/item-label.js'\n// Select-specific Popup with alignItemWithTriggerActive state\nexport type { SelectPopupProps, SelectPopupState } from './popup/popup.js'\nexport { SelectPopup as Popup } from './popup/popup.js'\n// Custom Select Positioner with alignItemWithTrigger support\nexport { SelectPositioner as Positioner } from './positioner/positioner.js'\n// Select-specific components\nexport { SelectRoot as Root } from './root/root.js'\n// Select-specific Surface with alignItemWithTrigger auto-highlight support\nexport { SelectSurface as Surface } from './surface/surface.js'\nexport { SelectTrigger as Trigger } from './trigger/trigger.js'\nexport { SelectValue as Value } from './value/value.js'\n","'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { usePopupMenuItem } from '../../internal/popup-menu/index.js'\nimport {\n compareItemEquality,\n itemIncludes,\n removeItem,\n} from '../../utils/item-equality.js'\nimport { mergeKeywords, resolveItemFromItems } from '../../utils/items.js'\nimport {\n resolveLabel,\n stringifyAsValue,\n} from '../../utils/resolve-value-label.js'\nimport type { ComponentProps } from '../../utils/types.js'\nimport { useSelectContext } from '../contexts/select-context.js'\nimport { SelectItemDataAttributes } from './item.data-attrs.js'\nimport {\n SelectItemContext,\n type SelectItemContextValue,\n} from './item-context.js'\n\nexport { SelectItemDataAttributes }\n\nexport interface SelectItemState extends Record<string, unknown> {\n /**\n * Whether the item is highlighted (via keyboard or pointer).\n */\n highlighted: boolean\n /**\n * Whether the item is disabled.\n */\n disabled: boolean\n /**\n * Whether the item is currently selected.\n */\n selected: boolean\n}\n\nexport interface SelectItemProps<Value = unknown>\n extends ComponentProps<'div', SelectItem.State> {\n /**\n * The value of this item. Required and must be unique within the Select.\n * Can be a primitive or an object.\n *\n * Pass `null` to render a clearable item: selecting it clears the selection\n * and its label is used as the trigger placeholder (Base UI parity).\n */\n value: Value | null\n\n /**\n * Text value to use for display in Select.Value when this item is selected.\n * If not provided, the text content of the item will be used.\n * For object values, this can be auto-detected from `{ label }` shape.\n */\n textValue?: string\n\n /**\n * Additional keywords to match against when filtering.\n * Useful for aliases or synonyms.\n */\n keywords?: string[]\n\n /**\n * Whether this item is disabled.\n * Disabled items are not selectable and are skipped during keyboard navigation.\n */\n disabled?: boolean\n\n /**\n * Callback when this item is selected.\n */\n onSelect?: () => void\n\n /**\n * Whether to force render this item regardless of filter results.\n * @default false\n */\n forceMount?: boolean\n}\n\nconst stateAttributesMapping = {\n highlighted: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.highlighted]: '' } : null,\n disabled: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.disabled]: '' } : null,\n selected: (value: unknown): Record<string, string> | null =>\n value ? { [SelectItemDataAttributes.selected]: '' } : null,\n}\n\n/**\n * A selectable item in the select dropdown.\n * Renders a `<div>` element with role=\"option\".\n *\n * @template Value - The type of the item value (can be a primitive or object)\n */\nfunction SelectItemImpl<Value = unknown>(\n props: SelectItemProps<Value>,\n forwardedRef: React.ForwardedRef<HTMLDivElement>,\n) {\n const {\n value,\n textValue: textValueProp,\n keywords: keywordsProp,\n disabled = false,\n onSelect,\n forceMount = false,\n render,\n className,\n style,\n onClick,\n onPointerDown,\n onPointerMove,\n children,\n ...rest\n } = props\n\n const selectContext = useSelectContext<Value>()\n\n // Serialize value for registry key and internal lookups\n const serializedValue = React.useMemo(\n () => stringifyAsValue(value, selectContext.itemToStringValue),\n [value, selectContext.itemToStringValue],\n )\n\n // A null value serializes to '' which the listbox treats as \"no id\" and skips\n // registration. Give a clearable (null) item an explicit id so it still\n // registers and is selectable; its label still feeds filtering via keywords.\n const generatedItemId = React.useId()\n const listboxId =\n value === null ? `select-clear-${generatedItemId}` : undefined\n\n // Resolve the item entry (label + keywords) from the items prop, for\n // auto-populating textValue and filter keywords.\n const itemFromItems = React.useMemo(\n () => resolveItemFromItems(selectContext.items, serializedValue),\n [selectContext.items, serializedValue],\n )\n const labelFromItems = itemFromItems?.label\n\n // Auto-resolve label from object value shape { label }\n const labelFromObjectValue = React.useMemo(\n () => resolveLabel(value, selectContext.itemToStringLabel),\n [value, selectContext.itemToStringLabel],\n )\n\n // Auto-populate textValue: explicit prop > label from items (if string) > label from object > undefined\n const textValue = React.useMemo(() => {\n if (textValueProp !== undefined) return textValueProp\n if (typeof labelFromItems === 'string') return labelFromItems\n // For object values, use the resolved label\n if (labelFromObjectValue && labelFromObjectValue !== serializedValue) {\n return labelFromObjectValue\n }\n return undefined\n }, [textValueProp, labelFromItems, labelFromObjectValue, serializedValue])\n\n // Auto-add the label plus any items[].keywords to the filter keywords.\n const keywords = React.useMemo(() => {\n const labelStr =\n typeof labelFromItems === 'string'\n ? labelFromItems\n : labelFromObjectValue && labelFromObjectValue !== serializedValue\n ? labelFromObjectValue\n : undefined\n return mergeKeywords(keywordsProp, [\n labelStr,\n ...(itemFromItems?.keywords ?? []),\n ])\n }, [\n keywordsProp,\n labelFromItems,\n labelFromObjectValue,\n serializedValue,\n itemFromItems,\n ])\n\n const textRef = React.useRef<string | undefined>(textValue)\n\n // Track if this item is selected using custom equality.\n // A `null` item is selected when there is no selection; an empty string is\n // still treated as \"no selection\" and never matches an item.\n const selected = selectContext.multiple\n ? itemIncludes(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : selectContext.value !== '' &&\n compareItemEquality(\n selectContext.value,\n value,\n selectContext.isItemEqualToValue,\n )\n\n // Determine close behavior: single-select closes, multi-select stays open\n const closeOnClick = !selectContext.multiple\n\n const item = usePopupMenuItem({\n id: listboxId,\n value: serializedValue,\n keywords,\n disabled,\n forceMount,\n closeOnClick,\n children,\n })\n\n // Register the select handler that updates the value\n React.useEffect(() => {\n const handleSelect = () => {\n if (disabled) return\n\n if (selectContext.multiple) {\n // A null item clears all selections in multi-select mode.\n if (value == null) {\n selectContext.onValuesChange([])\n } else {\n // Toggle value in array using custom equality\n const newValues = selected\n ? removeItem(\n selectContext.values,\n value,\n selectContext.isItemEqualToValue,\n )\n : [...selectContext.values, value]\n selectContext.onValuesChange(newValues)\n }\n } else {\n // Set single value (null clears the selection)\n selectContext.onValueChange(value)\n }\n\n onSelect?.()\n }\n return item.registerSelect(handleSelect)\n }, [disabled, selectContext, value, selected, onSelect, item])\n\n // Register item text for Select.Value display\n React.useEffect(() => {\n // Use textValue if provided, otherwise extract from children\n const text = textRef.current\n if (text) {\n return selectContext.registerItemText(serializedValue, text)\n }\n }, [serializedValue, selectContext])\n\n // Update text ref when children might have changed (for extraction)\n React.useEffect(() => {\n if (!textValue && typeof children === 'string') {\n textRef.current = children\n selectContext.registerItemText(serializedValue, children)\n }\n }, [children, textValue, serializedValue, selectContext])\n\n const state: SelectItem.State = React.useMemo(\n () => ({\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.isHighlighted, disabled, selected],\n )\n\n const itemContextValue: SelectItemContextValue<Value> = React.useMemo(\n () => ({\n id: item.id,\n value,\n textValue,\n highlighted: item.isHighlighted,\n disabled,\n selected,\n }),\n [item.id, value, textValue, item.isHighlighted, disabled, selected],\n )\n\n // Merge user-provided handlers with item handlers\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onClick(event)\n }\n },\n [onClick, item.handlers],\n )\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n item.handlers.onPointerDown(event)\n onPointerDown?.(event)\n },\n [item.handlers, onPointerDown],\n )\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent<HTMLDivElement>) => {\n onPointerMove?.(event)\n if (!event.defaultPrevented) {\n item.handlers.onPointerMove(event)\n }\n },\n [onPointerMove, item.handlers],\n )\n\n const element = useRender({\n render,\n ref: [item.ref, forwardedRef],\n state,\n stateAttributesMapping,\n props: {\n ...rest,\n [SelectItemDataAttributes.slot]: '',\n id: item.id,\n role: 'option',\n tabIndex: -1,\n 'aria-selected': selected,\n 'aria-disabled': disabled || undefined,\n className,\n style,\n onClick: handleClick,\n onPointerMove: handlePointerMove,\n onPointerDown: handlePointerDown,\n children,\n },\n enabled: item.isVisible,\n defaultTagName: 'div',\n })\n\n if (!item.isVisible) {\n return null\n }\n\n return (\n <SelectItemContext.Provider\n value={itemContextValue as SelectItemContextValue}\n >\n {element}\n </SelectItemContext.Provider>\n )\n}\n\nexport const SelectItem = React.forwardRef(SelectItemImpl) as <Value = unknown>(\n props: SelectItemProps<Value> & React.RefAttributes<HTMLDivElement>,\n) => React.ReactElement | null\n\nexport namespace SelectItem {\n export type State = SelectItemState\n export interface Props<Value = unknown> extends SelectItemProps<Value> {}\n}\n","'use client'\n\nimport * as React from 'react'\nimport type { ItemEqualityComparer } from '../../utils/item-equality.js'\nimport type { Items } from '../../utils/items.js'\n\n// ============================================================================\n// Select Context\n// ============================================================================\n// Provides value management and form integration for Select components.\n// Separate from PopupMenuContext to handle Select-specific concerns.\n\n/**\n * Item text registry for displaying selected values.\n * Maps serialized item value to its text content.\n */\nexport type ItemTextRegistry = Map<string, string>\n\n/**\n * Context value for Select components.\n * Provides value state, callbacks, and form integration.\n *\n * @template Value - The type of the select value (can be a primitive or object)\n */\nexport interface SelectContextValue<Value = unknown> {\n // ===== Selection State =====\n /** Whether multi-select mode is enabled */\n multiple: boolean\n /** Current selected value (single-select mode) */\n value: Value | null\n /** Current selected values (multi-select mode) */\n values: Value[]\n /** Callback when value changes (single-select mode; `null` clears it) */\n onValueChange: (value: Value | null) => void\n /** Callback when values change (multi-select mode) */\n onValuesChange: (values: Value[]) => void\n\n // ===== Object Value Support =====\n /**\n * Custom comparison logic used to determine if a select item value\n * matches the current selected value.\n * Useful when item values are objects without matching referentially.\n * Defaults to Object.is comparison.\n */\n isItemEqualToValue: ItemEqualityComparer<Value>\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for display in the trigger.\n * If the shape of the object is { value, label }, the label will be\n * used automatically without needing to specify this prop.\n */\n itemToStringLabel?: (itemValue: Value) => string\n /**\n * When the item values are objects, this function converts the object\n * value to a string representation for form submission.\n * If the shape of the object is { value, label }, the value will be\n * used automatically without needing to specify this prop.\n */\n itemToStringValue?: (itemValue: Value) => string\n\n // ===== Form Integration =====\n /** Form field name for submission */\n name?: string\n /** Associate with a form by ID */\n form?: string\n /** Whether this field is required */\n required?: boolean\n /** Whether the select is disabled */\n disabled: boolean\n /** Placeholder text when no value selected */\n placeholder: string\n\n // ===== Item Text Registry =====\n /** Registry of item values to their text content */\n itemTextRegistry: ItemTextRegistry\n /** Register an item's text content */\n registerItemText: (value: string, text: string) => () => void\n /**\n * Data structure of the items for label resolution.\n * Used to display labels before items mount (e.g., on initial render with defaultValue).\n * Can be a record mapping values to labels, or an array of\n * `{ value, label, keywords? }` objects.\n */\n items?: Items\n\n // ===== List ID for ARIA =====\n /** ID for the listbox element */\n listId: string\n\n // ===== Element Refs for Positioning =====\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>\n /** Ref to the value display element (text in trigger) */\n valueRef: React.RefObject<HTMLElement | null>\n /** Ref to the selected item's text element */\n selectedItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Ref to the first item's text element (used when no selection for alignItemWithTrigger) */\n firstItemTextRef: React.MutableRefObject<HTMLElement | null>\n /** Callback to set the trigger element */\n setTriggerElement: (element: HTMLElement | null) => void\n /** Callback to set the value element */\n setValueElement: (element: HTMLElement | null) => void\n\n // ===== Positioner Callback Registration =====\n /** Register a callback to reset positioning state after close animation */\n registerResetPositioningCallback: (\n callback: (() => void) | null,\n ) => () => void\n}\n\nconst SelectContext = React.createContext<SelectContextValue<unknown> | null>(\n null,\n)\n\n/**\n * Hook to access the Select context.\n * Throws if used outside a Select.Root.\n */\nexport function useSelectContext<Value = unknown>(): SelectContextValue<Value> {\n const context = React.useContext(SelectContext)\n if (!context) {\n throw new Error('Select components must be used within a Select.Root')\n }\n return context as SelectContextValue<Value>\n}\n\n/**\n * Hook to optionally access the Select context.\n * Returns null if used outside a Select.Root.\n */\nexport function useMaybeSelectContext<\n Value = unknown,\n>(): SelectContextValue<Value> | null {\n return React.useContext(SelectContext) as SelectContextValue<Value> | null\n}\n\nexport { SelectContext }\n","export const SelectItemDataAttributes = {\n /**\n * Identifies the component part.\n * @type {'bazzaui-select-item'}\n */\n slot: 'bazzaui-select-item',\n /**\n * Present when the item is highlighted via keyboard or pointer.\n */\n highlighted: 'data-highlighted',\n /**\n * Present when the item is disabled.\n */\n disabled: 'data-disabled',\n /**\n * Present when the item is currently selected.\n */\n selected: 'data-selected',\n} as const\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Select Item Context\n// ============================================================================\n// Provides select-specific item state to child components.\n\nexport interface SelectItemContextValue<Value = unknown> {\n /** Unique ID for this item (for DOM id attribute) */\n id: string\n /** The value of this item (`null` for a clearable item) */\n value: Value | null\n /** The text value/label for this item */\n textValue: string | undefined\n /** Whether the item is highlighted */\n highlighted: boolean\n /** Whether the item is disabled */\n disabled: boolean\n /** Whether the item is selected */\n selected: boolean\n}\n\nconst SelectItemContext = React.createContext<SelectItemContextValue | null>(\n null,\n)\n\nexport function useSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> {\n const context = React.useContext(SelectItemContext)\n if (!context) {\n throw new Error(\n 'Select.Item child components must be used within a Select.Item',\n )\n }\n return context as SelectItemContextValue<Value>\n}\n\nexport function useMaybeSelectItemContext<\n Value = unknown,\n>(): SelectItemContextValue<Value> | null {\n return React.useContext(\n SelectItemContext,\n ) as SelectItemContextValue<Value> | null\n}\n\nexport { SelectItemContext }\n"]}
|
package/dist/select/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ht,b as xt,c as bt,d as Pt,e as Rt,f as Pe,g as It}from"../chunk-KO3DXT3Y.js";import{Ab as St,L as et,La as nt,Ma as rt,N as tt,Na as to,P as ot,Qa as lt,Ra as at,Ua as ge,Va as Se,Wa as F,Xa as it,Ya as st,Za as ut,_a as oo,ab as ct,eb as pt,fb as mt,gb as dt,l as ye,yb as ft,zb as gt}from"../chunk-2D2HREBK.js";import{a as Qe,p as Kt,q as Jt,w as Zt,x as Qt,y as eo}from"../chunk-ZPRKUVIC.js";import{a as $t}from"../chunk-4C666HHU.js";var Dt={};$t(Dt,{Arrow:()=>tt,Backdrop:()=>ot,Empty:()=>st,Group:()=>ft,GroupLabel:()=>gt,Icon:()=>it,Input:()=>ut,Item:()=>De,ItemIndicator:()=>Oe,ItemLabel:()=>Ne,List:()=>ct,Popup:()=>Fe,Portal:()=>rt,Positioner:()=>_e,Root:()=>qe,ScrollDownArrow:()=>mt,ScrollUpArrow:()=>pt,Separator:()=>St,Surface:()=>Ue,Trigger:()=>Ye,Value:()=>Xe});import{useRender as lo}from"@base-ui/react/use-render";import*as y from"react";import*as Re from"react";var Ee=Re.createContext(null);function D(){let n=Re.useContext(Ee);if(!n)throw new Error("Select components must be used within a Select.Root");return n}function no(){return Re.useContext(Ee)}var he={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};import*as Ie from"react";var we=Ie.createContext(null);function Ce(){let n=Ie.useContext(we);if(!n)throw new Error("Select.Item child components must be used within a Select.Item");return n}function ro(){return Ie.useContext(we)}import{jsx as so}from"react/jsx-runtime";var ao={highlighted:n=>n?{[he.highlighted]:""}:null,disabled:n=>n?{[he.disabled]:""}:null,selected:n=>n?{[he.selected]:""}:null};function io(n,t){let{value:o,textValue:l,keywords:i,disabled:r=!1,onSelect:u,forceMount:h=!1,render:e,className:a,style:I,onClick:d,onPointerDown:p,onPointerMove:P,children:f,...s}=n,c=D(),g=y.useMemo(()=>F(o,c.itemToStringValue),[o,c.itemToStringValue]),T=y.useId(),L=o===null?`select-clear-${T}`:void 0,S=y.useMemo(()=>Rt(c.items,g),[c.items,g]),M=S?.label,w=y.useMemo(()=>Se(o,c.itemToStringLabel),[o,c.itemToStringLabel]),v=y.useMemo(()=>{if(l!==void 0)return l;if(typeof M=="string")return M;if(w&&w!==g)return w},[l,M,w,g]),Z=y.useMemo(()=>It(i,[typeof M=="string"?M:w&&w!==g?w:void 0,...S?.keywords??[]]),[i,M,w,g,S]),k=y.useRef(v),O=c.multiple?bt(c.values,o,c.isItemEqualToValue):c.value!==""&&xt(c.value,o,c.isItemEqualToValue),le=!c.multiple,x=at({id:L,value:g,keywords:Z,disabled:r,forceMount:h,closeOnClick:le,children:f});y.useEffect(()=>{let V=()=>{if(!r){if(c.multiple)if(o==null)c.onValuesChange([]);else{let J=O?Pt(c.values,o,c.isItemEqualToValue):[...c.values,o];c.onValuesChange(J)}else c.onValueChange(o);u?.()}};return x.registerSelect(V)},[r,c,o,O,u,x]),y.useEffect(()=>{let V=k.current;if(V)return c.registerItemText(g,V)},[g,c]),y.useEffect(()=>{!v&&typeof f=="string"&&(k.current=f,c.registerItemText(g,f))},[f,v,g,c]);let G=y.useMemo(()=>({highlighted:x.isHighlighted,disabled:r,selected:O}),[x.isHighlighted,r,O]),_=y.useMemo(()=>({id:x.id,value:o,textValue:v,highlighted:x.isHighlighted,disabled:r,selected:O}),[x.id,o,v,x.isHighlighted,r,O]),j=y.useCallback(V=>{d?.(V),V.defaultPrevented||x.handlers.onClick(V)},[d,x.handlers]),K=y.useCallback(V=>{x.handlers.onPointerDown(V),p?.(V)},[x.handlers,p]),q=y.useCallback(V=>{P?.(V),V.defaultPrevented||x.handlers.onPointerMove(V)},[P,x.handlers]),B=lo({render:e,ref:[x.ref,t],state:G,stateAttributesMapping:ao,props:{...s,[he.slot]:"",id:x.id,role:"option",tabIndex:-1,"aria-selected":O,"aria-disabled":r||void 0,className:a,style:I,onClick:j,onPointerMove:q,onPointerDown:K,children:f},enabled:x.isVisible,defaultTagName:"div"});return x.isVisible?so(we.Provider,{value:_,children:B}):null}var De=y.forwardRef(io);import{useRender as uo}from"@base-ui/react/use-render";import*as He from"react";var Ve={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var co={selected:n=>n?{[Ve.selected]:""}:null,highlighted:n=>n?{[Ve.highlighted]:""}:null},Oe=He.forwardRef(function(t,o){let{render:l,className:i,style:r,forceMount:u=!1,keepMounted:h=!1,children:e,...a}=t,I=Ce(),d=I.selected,p=I.highlighted,P=He.useMemo(()=>({selected:d,highlighted:p}),[d,p]),f=u||h||d,s=typeof e=="function"?e(P):h&&!d?null:e,c=uo({render:l,ref:o,state:P,stateAttributesMapping:co,props:{...a,[Ve.slot]:"","aria-hidden":!0,className:i,style:r,children:s},defaultTagName:"span"});return f?c:null});import{useRender as po}from"@base-ui/react/use-render";import*as W from"react";var Ct={slot:"bazzaui-select-item-label"};var Ne=W.forwardRef(function(t,o){let{render:l,className:i,style:r,children:u,...h}=t,e=D(),a=Ce(),I=W.useRef(null),d=F(a.value,e.itemToStringValue),p=W.useMemo(()=>{if(u!==void 0)return u;let s=Pe(e.items,d);return s!==void 0?s:a.textValue!==void 0?a.textValue:d},[u,e.items,d,a.textValue]),P=W.useMemo(()=>({value:d,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[d,a.selected,a.highlighted,a.disabled]);W.useEffect(()=>{if(typeof p=="string")return e.registerItemText(d,p)},[p,e,d]);let f=W.useCallback(s=>{I.current=s,a.selected&&s&&(e.selectedItemTextRef.current=s),s&&!a.disabled&&(e.firstItemTextRef.current||(e.firstItemTextRef.current=s))},[a.selected,a.disabled,e]);return po({render:l,ref:o,state:P,props:{...h,[Ct.slot]:"",ref:f,className:i,style:r,children:p},defaultTagName:"span"})});import"@base-ui/react/popover";import*as ue from"react";import*as Le from"react";var ze=Le.createContext(null);function Te(){return Le.useContext(ze)}import{jsx as mo}from"react/jsx-runtime";var Fe=ue.forwardRef(function(t,o){let{className:l,render:i,...r}=t,u=Te(),h=u?.alignItemWithTriggerActive??!1,e=u?.align,a=ue.useCallback(p=>({...p,side:h?"none":p.side,alignItemWithTriggerActive:h}),[h]),I=ue.useMemo(()=>typeof l=="function"?p=>l(a(p)):l,[l,a]),d=ue.useMemo(()=>typeof i=="function"?(p,P)=>i(p,a(P)):i,[i,a]);return mo(nt,{ref:o,className:I,render:d,"data-align-item-with-trigger":h?"":void 0,...h?{"data-side":"none","data-align":e}:{},...r})});import{useDirection as fo}from"@base-ui/react/internals/direction-context";import{Popover as go}from"@base-ui/react/popover";import*as R from"react";function ce(n,t,o){return n<t?t:n>o?o:n}function Ge(n){let t=n.getBoundingClientRect(),{offsetWidth:o,offsetHeight:l}=n,i=o>0?Math.round(t.width)/o:1,r=l>0?Math.round(t.height)/l:1;return(!Number.isFinite(i)||i===0)&&(i=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:i,y:r}}function Vt(n,t,o){return n/o[t]}function Me(n,t){let o=n.x/t.x,l=n.y/t.y,i=n.width/t.x,r=n.height/t.y;return{x:o,y:l,width:i,height:r,top:l,left:o,right:o+i,bottom:l+r}}var $=1;function xe(n,t){return Math.max(0,n-t)}var Tt=5,Mt=20,je=10,vt=100;function yt(n){let{triggerRect:t,positionerRect:o,valueRect:l,textRect:i,scrollHeight:r,documentClientHeight:u,documentClientWidth:h,marginTop:e,marginBottom:a,minHeight:I,maxPopupHeight:d,borderBottom:p,direction:P}=n,f=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:e,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),s=u-e-a,c=h,g=t.height,T=s-t.bottom+g,L=P==="rtl"?t.right-o.width:t.left,S=0,M=null;if(i&&l){L=o.left+(P==="rtl"?l.right-i.right:l.left-i.left);let U=l.top-t.top+l.height/2;S=i.top-o.top+i.height/2-U,M=i.top+i.height/2}let w=T+S+a+p,v=Math.min(s,w),Z=s-e-a,k=w-v,O=c-Tt,le=ce(L,Tt,O-o.width),x=xe(r,v),G=k>=x-$;if(G&&(v=Math.min(s,o.height)-(k-x)),t.top<Mt||t.bottom>s-Mt||Math.ceil(v)+$<Math.min(r,I))return f();let j=Math.max(I,v),K=a+p-e,q=0,B=k;if(G){let U=Math.max(0,s-w);q=o.height>=Z?0:Math.max(0,U+K),B=x}else B=Math.max(0,k-K);let V=null;if(M!=null){let U=o.top,A=o.height,m=A>0?(M-U)/A*100:50;V=`50% ${ce(m,0,100)}%`}let J=j===s||v>=d;return{fallback:!1,left:le,isTopPositioned:G,top:q,height:v,scrollTop:B,marginTop:e,marginBottom:a,reachedMaxHeight:J,transformOrigin:V}}function Et(n){let{isTopPositioned:t,currentHeight:o,scrollTop:l,maxScrollTop:i,maxAvailableHeight:r}=n,u=t?i-l:l;if(u<=$){let d=ce(u,0,r-o),p=o+d;return{height:d>0?p:null,scroll:{kind:"set",value:t?i:0},reachedMaxHeight:r-p<=$}}let h=Math.min(o+u,r),e={kind:"none"},a=!1;if(r-h>$)e=t?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!t&&l<i){let d=o+u-r;e={kind:"clamp",value:l-(u-d)}}let I=Math.ceil(h);return{height:I,scroll:e,reachedMaxHeight:a||I>=r-$}}var Be={slot:"bazzaui-select-positioner"};import{jsx as Lt}from"react/jsx-runtime";var _e=R.forwardRef(function(t,o){let{alignItemWithTrigger:l=!0,side:i="bottom",align:r="start",sideOffset:u=0,className:h,style:e,children:a,...I}=t,d=ye(),p=D(),P=fo()==="rtl"?"rtl":"ltr",f=d.store,s=f.useState("open"),c=f.useState("openMethod"),g=f.useState("hasInput"),[T,L]=R.useState(l),S=T&&c!=="touch"&&!g,[M,w]=R.useState(!1),[v,Z]=R.useState(null),k=R.useRef(null),O=R.useRef(null),le=R.useRef(null),x=R.useRef(!1),G=R.useRef(!1),_=R.useCallback(()=>{let m=k.current,C=f.context.refs.popupRef.current;m&&(m.style.height=""),C&&(C.style.height="",C.style.removeProperty("--transform-origin")),x.current=!1,G.current=!1},[f]),j=R.useCallback(()=>{_(),L(l),w(!1),Z(null)},[l,_]);R.useEffect(()=>p.registerResetPositioningCallback(j),[p,j]);let K=R.useCallback(()=>{if(f.state.hasInput)return;let m=k.current,C=p.triggerRef.current,N=f.context.refs.popupRef.current,Y=f.context.refs.listRef.current;if(!m||!C||!N||!Y)return;let Q=p.selectedItemTextRef.current;if(!Q?.isConnected){let z=p.firstItemTextRef.current;Q=z?.isConnected?z:null}let ee=p.valueRef.current,ae=ho(N),H;try{let z=We(m),ie=m.ownerDocument,te=Ge(C),se=z.getComputedStyle(m),X=z.getComputedStyle(N);H=yt({triggerRect:Me(C.getBoundingClientRect(),te),positionerRect:Me(m.getBoundingClientRect(),te),valueRect:ee?Me(ee.getBoundingClientRect(),te):null,textRect:Q?Me(Q.getBoundingClientRect(),te):null,scrollHeight:Y.scrollHeight,documentClientHeight:ie.documentElement.clientHeight,documentClientWidth:ie.documentElement.clientWidth,marginTop:Number.parseFloat(se.marginTop)||je,marginBottom:Number.parseFloat(se.marginBottom)||je,minHeight:Number.parseFloat(se.minHeight)||vt,maxPopupHeight:wt(X),borderBottom:Number.parseFloat(X.borderBottomWidth)||0,direction:P});let me=(z.visualViewport?.scale??1)!==1&&So(z);if(H.fallback||me){L(!1),w(!0);return}m.style.height=`${H.height}px`,N.style.height="100%",H.transformOrigin&&N.style.setProperty("--transform-origin",H.transformOrigin),Y.scrollTop=H.scrollTop,x.current=H.reachedMaxHeight,G.current=!0}finally{ae()}Z({left:H.left,top:H.isTopPositioned?H.top:null,bottom:H.isTopPositioned?null:0,marginTop:H.marginTop,marginBottom:H.marginBottom}),w(!0)},[f,p,P]);R.useEffect(()=>{!s||!S||M||K()},[s,S,M,K]),R.useEffect(()=>{s&&!S&&_()},[s,S,_]),R.useEffect(()=>{if(!s||!S)return;let m=k.current,C=m?We(m):window,N=Y=>{f.setOpen(!1,Qe.none,Y)};return C.addEventListener("resize",N),()=>{C.removeEventListener("resize",N)}},[s,S,f]);let q=R.useCallback(m=>{let C=k.current,N=f.context.refs.popupRef.current;if(!C||!N||!G.current||x.current||!S)return;let Y=C.style.top==="0px",Q=C.style.bottom==="0px";if(!Y&&!Q)return;let ee=We(C),ae=C.ownerDocument,H=Ge(C),z=Vt(C.getBoundingClientRect().height,"y",H),ie=ee.getComputedStyle(C),te=Number.parseFloat(ie.marginTop)||0,se=Number.parseFloat(ie.marginBottom)||0,X=wt(ee.getComputedStyle(N)),me=Math.min(ae.documentElement.clientHeight-te-se,X),oe=Et({isTopPositioned:Y,currentHeight:z,scrollTop:m.scrollTop,maxScrollTop:xe(m.scrollHeight,m.clientHeight),maxAvailableHeight:me});switch(oe.height!=null&&(C.style.height=`${oe.height}px`),oe.scroll.kind){case"set":m.scrollTop=oe.scroll.value;break;case"max":{let de=xe(m.scrollHeight,m.clientHeight);Math.abs(m.scrollTop-de)>$&&(m.scrollTop=de);break}case"clamp":{let de=xe(m.scrollHeight,m.clientHeight),ne=ce(oe.scroll.value,0,de);Math.abs(m.scrollTop-ne)>$&&(m.scrollTop=ne);break}default:break}oe.reachedMaxHeight&&(x.current=!0)},[f,S]);R.useEffect(()=>{if(!s||!S||!M)return;let m=f.context.refs.listRef.current;if(!m)return;let C=()=>q(m);return m.addEventListener("scroll",C,{passive:!0}),()=>{m.removeEventListener("scroll",C)}},[s,S,M,q,f]);let B=S?"none":i,V=R.useMemo(()=>({alignItemWithTriggerActive:S,side:B,align:r,scrollUpArrowRef:O,scrollDownArrowRef:le,setAlignItemWithTriggerActive:L,resetPositioningState:j}),[S,B,r,j]),J=R.useCallback(m=>{k.current=m,typeof o=="function"?o(m):o&&(o.current=m)},[o]),U=s&&S&&!M,A=S&&v?{position:"fixed",transform:"none",left:v.left,top:v.top??"auto",bottom:v.bottom??"auto",marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return Lt(ze.Provider,{value:V,children:Lt(go.Positioner,{ref:J,side:S?void 0:i,align:S?void 0:r,sideOffset:S?0:u,disableAnchorTracking:S||void 0,className:h,style:{...e,...A,...U?{visibility:"hidden"}:{}},...S?{"data-side":"none","data-align":r}:{},[Be.slot]:"",...I,children:a})})});function We(n){return n.ownerDocument?.defaultView??window}function wt(n){let t=n.maxHeight||"";return t.endsWith("px")&&Number.parseFloat(t)||Number.POSITIVE_INFINITY}function So(n){let t=n.navigator;return t?/AppleWebKit/.test(t.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(t.userAgent):!1}var Ht=[["transform","none"],["scale","1"],["translate","0 0"]];function ho(n){let{style:t}=n,o={};for(let[l,i]of Ht)o[l]=t.getPropertyValue(l),t.setProperty(l,i,"important");return()=>{for(let[l]of Ht){let i=o[l];i?t.setProperty(l,i):t.removeProperty(l)}}}import{Popover as xo}from"@base-ui/react/popover";import*as b from"react";import{jsx as ve,jsxs as bo}from"react/jsx-runtime";function qe(n){let{open:t,onOpenChange:o,onOpenChangeComplete:l,actionsRef:i,defaultOpen:r=!1,value:u,defaultValue:h,onValueChange:e,multiple:a=!1,values:I,defaultValues:d,onValuesChange:p,isItemEqualToValue:P=ht,itemToStringLabel:f,itemToStringValue:s,name:c,form:g,required:T,disabled:L=!1,placeholder:S="Select...",items:M,modal:w=!0,virtualized:v=!1,virtualItems:Z,onHighlightChange:k,debug:O,children:le,...x}=n,G=b.useId(),_=b.useRef(null),j=b.useRef(null),K=b.useRef(null),q=b.useRef(null),B=b.useCallback(E=>{_.current=E},[]),V=b.useCallback(E=>{j.current=E},[]),J=b.useRef(null),U=b.useCallback(E=>(J.current=E,()=>{J.current=null}),[]),{store:A,focusOwnerStore:m,openChainStore:C,registerSurface:N,closeAll:Y,virtualization:Q,handleOpenChange:ee,disabled:ae,setDisabled:H}=et({onOpenChange:o,defaultOpen:r,virtualized:v,items:Z,onHighlightChange:k,disabled:L}),z=b.useRef(null);b.useImperativeHandle(i,()=>({close:()=>{z.current?.close()},unmount:()=>{z.current?.unmount()},setDisabled:H}),[H]),A.useControlledProp("openProp",t);let ie=A.useState("open"),[te,se]=b.useState(h!==void 0?h:null),X=u!==void 0?u:te,me=b.useCallback(E=>{u===void 0&&se(E),e?.(E)},[u,e]),[oe,de]=b.useState(d??[]),ne=I!==void 0?I:oe,$e=b.useCallback(E=>{I===void 0&&de(E),p?.(E)},[I,p]),Ke=b.useRef(new Map),Je=b.useCallback((E,fe)=>(Ke.current.set(E,fe),()=>{}),[]),qt=b.useMemo(()=>({multiple:a,value:X,values:ne,onValueChange:me,onValuesChange:$e,isItemEqualToValue:P,itemToStringLabel:f,itemToStringValue:s,name:c,form:g,required:T,disabled:ae,placeholder:S,items:M,itemTextRegistry:Ke.current,registerItemText:Je,listId:G,triggerRef:_,valueRef:j,selectedItemTextRef:K,firstItemTextRef:q,setTriggerElement:B,setValueElement:V,registerResetPositioningCallback:U}),[a,X,ne,me,$e,P,f,s,c,g,T,ae,S,M,Je,G,B,V,U]),Ut=b.useMemo(()=>c?a?ne.length>0?ne.map((E,fe)=>{let Ze=F(E,s);return ve("input",{type:"hidden",name:c,value:Ze,form:g,required:T&&fe===0},Ze)}):ve("input",{type:"hidden",name:c,value:"",form:g,required:T}):ve("input",{type:"hidden",name:c,value:X!=null?F(X,s):"",form:g,required:T}):null,[c,g,T,a,X,ne,s]),Yt=b.useCallback((E,fe)=>{ee(E,fe.reason,fe.event)},[ee]),Xt=b.useCallback(E=>{!E&&A.context.clearSearchOnClose==="after-exit"&&(A.clearSearch(),A.setInputActive(!1)),E||(A.clearHighlight(),J.current?.(),q.current=null),l?.(E)},[A,l]);return ve(Ee.Provider,{value:qt,children:bo(lt,{store:A,focusOwnerStore:m,openChainStore:C,disabled:ae,depth:0,closeAll:Y,registerSurface:N,virtualization:Q,menuType:"dropdown",componentName:"select",debug:O,children:[Ut,ve(xo.Root,{...x,open:ie,onOpenChange:Yt,onOpenChangeComplete:Xt,modal:w,actionsRef:i?z:void 0,children:le})]})})}import*as ke from"react";var kt={slot:"bazzaui-select-surface"};import{jsx as Po}from"react/jsx-runtime";var Ue=ke.forwardRef(function(t,o){let{autoHighlightFirst:l,...i}=t,r=D(),u=Te(),h=ke.useMemo(()=>{let e=a=>ge(a)?!0:F(a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return e(a)}if(l!==void 0)return l;if(u?.alignItemWithTriggerActive){let a=r.multiple?r.values[0]:r.value;return e(a)}return!0},[l,u?.alignItemWithTriggerActive,r.multiple,r.value,r.values,r.itemToStringValue]);return Po(dt,{ref:o,autoHighlightFirst:h,[kt.slot]:"",...i})});import{Popover as Ro}from"@base-ui/react/popover";import{useRender as Io}from"@base-ui/react/use-render";import*as pe from"react";var be={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import{jsx as At}from"react/jsx-runtime";var Co={open:n=>n?{[be.open]:""}:null,disabled:n=>n?{[be.disabled]:""}:null,placeholder:n=>n?{[be.placeholder]:""}:null},Vo=pe.forwardRef(function(t,o){let{render:l,children:i,disabled:r,className:u,style:h,triggerProps:e,triggerState:a,...I}=t,d=D(),p=r??d.disabled,P=d.multiple?d.values.length>0:!ge(d.value),f=pe.useMemo(()=>({open:a.open,disabled:p,placeholder:!P}),[a.open,p,P]),s=pe.useCallback(c=>{d.setTriggerElement(c)},[d]);return Io({render:l,ref:o,state:f,stateAttributesMapping:Co,props:{...e,...I,[be.slot]:"",ref:s,role:"combobox","aria-haspopup":"listbox","aria-controls":d.listId,className:u,style:h,children:i},defaultTagName:"button"})}),Ye=pe.forwardRef(function(t,o){let{disabled:l,...i}=t,r=D(),u=ye(),h=(l??r.disabled)||u.disabled;return At(Ro.Trigger,{ref:o,disabled:h,render:(e,a)=>At(Vo,{...i,disabled:h,triggerProps:e,triggerState:a,ref:e.ref})})});import{useRender as To}from"@base-ui/react/use-render";import*as re from"react";var Ae={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var Mo={hasValue:n=>n?null:{[Ae.placeholder]:""},multiple:n=>n?{[Ae.multiple]:""}:null,getValueText:()=>null};function vo(n,t){let{render:o,className:l,style:i,placeholder:r,children:u,...h}=n,e=D(),a=r??e.placeholder,I=re.useMemo(()=>Pe(e.items,""),[e.items]),d=r??I??a,p=e.multiple?e.values.length>0:!ge(e.value),P=re.useCallback(g=>{let T=F(g,e.itemToStringValue),L=e.itemTextRegistry.get(T);if(L!==void 0)return L;let S=Pe(e.items,T);if(S!==void 0)return S;let M=Se(g,e.itemToStringLabel);if(M&&M!==T)return M},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),f=re.useMemo(()=>({value:e.value,values:e.values,multiple:e.multiple,hasValue:p,placeholder:a,getValueText:P}),[e.value,e.values,e.multiple,p,a,P]),s;if(typeof u=="function")s=u(f);else if(u!==void 0)s=u;else if(!p)s=d;else if(e.multiple){let g=e.values.map(T=>{let L=P(T);return L!==void 0?L:Se(T,e.itemToStringLabel)||F(T,e.itemToStringValue)}).filter(Boolean);s=g.length>2?`${g.length} selected`:g.join(", ")}else{let g=e.value;if(g!=null){let T=P(g);T!==void 0?s=T:s=Se(g,e.itemToStringLabel)||F(g,e.itemToStringValue)}}let c=re.useCallback(g=>{e.setValueElement(g)},[e]);return To({render:o,ref:t,state:f,stateAttributesMapping:Mo,props:{...h,[Ae.slot]:"",ref:c,className:l,style:i,children:s},defaultTagName:"span"})}var Xe=re.forwardRef(vo);var Ot=(u=>(u.slot="bazzaui-select-arrow",u.open="data-open",u.closed="data-closed",u.side="data-side",u.align="data-align",u.uncentered="data-uncentered",u))(Ot||{});var Nt=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(Nt||{});var zt=(t=>(t.slot="bazzaui-select-empty",t))(zt||{});var Ft=(t=>(t.slot="bazzaui-select-group",t))(Ft||{});var Gt=(t=>(t.slot="bazzaui-select-group-label",t))(Gt||{});var yo={slot:"bazzaui-select-icon",open:"data-popup-open"};var jt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(jt||{});var Bt=(o=>(o.slot="bazzaui-select-list",o.list="data-popup-menu-list",o))(Bt||{});var Wt=(t=>(t.alignItemWithTrigger="data-align-item-with-trigger",t))(Wt||{});var Eo={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var _t=(t=>(t.slot="bazzaui-select-separator",t))(_t||{});export{Dt as Select,Ot as SelectArrowDataAttributes,Nt as SelectBackdropDataAttributes,zt as SelectEmptyDataAttributes,Ft as SelectGroupDataAttributes,Gt as SelectGroupLabelDataAttributes,yo as SelectIconDataAttributes,jt as SelectInputDataAttributes,De as SelectItem,he as SelectItemDataAttributes,Oe as SelectItemIndicator,Ve as SelectItemIndicatorDataAttributes,Ne as SelectItemLabel,oo as SelectListCssVars,Bt as SelectListDataAttributes,Fe as SelectPopup,Wt as SelectPopupDataAttributes,_e as SelectPositioner,to as SelectPositionerCssVars,Be as SelectPositionerDataAttributes,qe as SelectRoot,Eo as SelectScrollArrowDataAttributes,_t as SelectSeparatorDataAttributes,eo as SelectStore,Ue as SelectSurface,Ye as SelectTrigger,be as SelectTriggerDataAttributes,Xe as SelectValue,Zt as commandScore,Qt as defaultFilter,no as useMaybeSelectContext,ro as useMaybeSelectItemContext,Jt as useMaybeSurfaceContext,D as useSelectContext,Ce as useSelectItemContext,Te as useSelectPositionerContext,Kt as useSurfaceContext};
|
|
1
|
+
import{a as ht}from"../chunk-IT372NHF.js";import{a as xt,b as bt,c as Pt,d as Rt,e as It,f as Pe,g as Ct}from"../chunk-KO3DXT3Y.js";import{Ab as St,L as et,La as nt,Ma as rt,N as tt,Na as oo,P as ot,Qa as lt,Ra as at,Ua as ge,Va as Se,Wa as F,Xa as it,Ya as st,Za as ut,_a as no,ab as ct,eb as pt,fb as mt,gb as dt,l as ye,yb as ft,zb as gt}from"../chunk-23NDAOAL.js";import{a as Qe,p as Jt,q as Zt,w as Qt,x as eo,y as to}from"../chunk-ZPRKUVIC.js";import{a as Kt}from"../chunk-4C666HHU.js";var Ot={};Kt(Ot,{Arrow:()=>tt,Backdrop:()=>ot,Empty:()=>st,Group:()=>ft,GroupLabel:()=>gt,Icon:()=>it,Input:()=>ut,Item:()=>De,ItemIndicator:()=>Oe,ItemLabel:()=>Ne,List:()=>ct,Popup:()=>Fe,Portal:()=>rt,Positioner:()=>_e,Root:()=>qe,ScrollDownArrow:()=>mt,ScrollUpArrow:()=>pt,Separator:()=>St,Surface:()=>Ue,Trigger:()=>Ye,Value:()=>Xe});import{useRender as ao}from"@base-ui/react/use-render";import*as y from"react";import*as Re from"react";var Ee=Re.createContext(null);function D(){let n=Re.useContext(Ee);if(!n)throw new Error("Select components must be used within a Select.Root");return n}function ro(){return Re.useContext(Ee)}var he={slot:"bazzaui-select-item",highlighted:"data-highlighted",disabled:"data-disabled",selected:"data-selected"};import*as Ie from"react";var we=Ie.createContext(null);function Ce(){let n=Ie.useContext(we);if(!n)throw new Error("Select.Item child components must be used within a Select.Item");return n}function lo(){return Ie.useContext(we)}import{jsx as uo}from"react/jsx-runtime";var io={highlighted:n=>n?{[he.highlighted]:""}:null,disabled:n=>n?{[he.disabled]:""}:null,selected:n=>n?{[he.selected]:""}:null};function so(n,t){let{value:o,textValue:l,keywords:i,disabled:r=!1,onSelect:u,forceMount:h=!1,render:e,className:a,style:I,onClick:d,onPointerDown:p,onPointerMove:P,children:f,...s}=n,c=D(),g=y.useMemo(()=>F(o,c.itemToStringValue),[o,c.itemToStringValue]),T=y.useId(),L=o===null?`select-clear-${T}`:void 0,S=y.useMemo(()=>It(c.items,g),[c.items,g]),M=S?.label,w=y.useMemo(()=>Se(o,c.itemToStringLabel),[o,c.itemToStringLabel]),v=y.useMemo(()=>{if(l!==void 0)return l;if(typeof M=="string")return M;if(w&&w!==g)return w},[l,M,w,g]),Z=y.useMemo(()=>Ct(i,[typeof M=="string"?M:w&&w!==g?w:void 0,...S?.keywords??[]]),[i,M,w,g,S]),k=y.useRef(v),O=c.multiple?Pt(c.values,o,c.isItemEqualToValue):c.value!==""&&bt(c.value,o,c.isItemEqualToValue),le=!c.multiple,x=at({id:L,value:g,keywords:Z,disabled:r,forceMount:h,closeOnClick:le,children:f});y.useEffect(()=>{let V=()=>{if(!r){if(c.multiple)if(o==null)c.onValuesChange([]);else{let J=O?Rt(c.values,o,c.isItemEqualToValue):[...c.values,o];c.onValuesChange(J)}else c.onValueChange(o);u?.()}};return x.registerSelect(V)},[r,c,o,O,u,x]),y.useEffect(()=>{let V=k.current;if(V)return c.registerItemText(g,V)},[g,c]),y.useEffect(()=>{!v&&typeof f=="string"&&(k.current=f,c.registerItemText(g,f))},[f,v,g,c]);let G=y.useMemo(()=>({highlighted:x.isHighlighted,disabled:r,selected:O}),[x.isHighlighted,r,O]),_=y.useMemo(()=>({id:x.id,value:o,textValue:v,highlighted:x.isHighlighted,disabled:r,selected:O}),[x.id,o,v,x.isHighlighted,r,O]),j=y.useCallback(V=>{d?.(V),V.defaultPrevented||x.handlers.onClick(V)},[d,x.handlers]),K=y.useCallback(V=>{x.handlers.onPointerDown(V),p?.(V)},[x.handlers,p]),q=y.useCallback(V=>{P?.(V),V.defaultPrevented||x.handlers.onPointerMove(V)},[P,x.handlers]),B=ao({render:e,ref:[x.ref,t],state:G,stateAttributesMapping:io,props:{...s,[he.slot]:"",id:x.id,role:"option",tabIndex:-1,"aria-selected":O,"aria-disabled":r||void 0,className:a,style:I,onClick:j,onPointerMove:q,onPointerDown:K,children:f},enabled:x.isVisible,defaultTagName:"div"});return x.isVisible?uo(we.Provider,{value:_,children:B}):null}var De=y.forwardRef(so);import{useRender as co}from"@base-ui/react/use-render";import*as He from"react";var Ve={slot:"bazzaui-select-item-indicator",selected:"data-selected",highlighted:"data-highlighted"};var po={selected:n=>n?{[Ve.selected]:""}:null,highlighted:n=>n?{[Ve.highlighted]:""}:null},Oe=He.forwardRef(function(t,o){let{render:l,className:i,style:r,forceMount:u=!1,keepMounted:h=!1,children:e,...a}=t,I=Ce(),d=I.selected,p=I.highlighted,P=He.useMemo(()=>({selected:d,highlighted:p}),[d,p]),f=u||h||d,s=typeof e=="function"?e(P):h&&!d?null:e,c=co({render:l,ref:o,state:P,stateAttributesMapping:po,props:{...a,[Ve.slot]:"","aria-hidden":!0,className:i,style:r,children:s},defaultTagName:"span"});return f?c:null});import{useRender as mo}from"@base-ui/react/use-render";import*as W from"react";var Vt={slot:"bazzaui-select-item-label"};var Ne=W.forwardRef(function(t,o){let{render:l,className:i,style:r,children:u,...h}=t,e=D(),a=Ce(),I=W.useRef(null),d=F(a.value,e.itemToStringValue),p=W.useMemo(()=>{if(u!==void 0)return u;let s=Pe(e.items,d);return s!==void 0?s:a.textValue!==void 0?a.textValue:d},[u,e.items,d,a.textValue]),P=W.useMemo(()=>({value:d,selected:a.selected,highlighted:a.highlighted,disabled:a.disabled}),[d,a.selected,a.highlighted,a.disabled]);W.useEffect(()=>{if(typeof p=="string")return e.registerItemText(d,p)},[p,e,d]);let f=W.useCallback(s=>{I.current=s,a.selected&&s&&(e.selectedItemTextRef.current=s),s&&!a.disabled&&(e.firstItemTextRef.current||(e.firstItemTextRef.current=s))},[a.selected,a.disabled,e]);return mo({render:l,ref:o,state:P,props:{...h,[Vt.slot]:"",ref:f,className:i,style:r,children:p},defaultTagName:"span"})});import"@base-ui/react/popover";import*as ue from"react";import*as Le from"react";var ze=Le.createContext(null);function Te(){return Le.useContext(ze)}import{jsx as fo}from"react/jsx-runtime";var Fe=ue.forwardRef(function(t,o){let{className:l,render:i,...r}=t,u=Te(),h=u?.alignItemWithTriggerActive??!1,e=u?.align,a=ue.useCallback(p=>({...p,side:h?"none":p.side,alignItemWithTriggerActive:h}),[h]),I=ue.useMemo(()=>typeof l=="function"?p=>l(a(p)):l,[l,a]),d=ue.useMemo(()=>typeof i=="function"?(p,P)=>i(p,a(P)):i,[i,a]);return fo(nt,{ref:o,className:I,render:d,"data-align-item-with-trigger":h?"":void 0,...h?{"data-side":"none","data-align":e}:{},...r})});import{useDirection as go}from"@base-ui/react/internals/direction-context";import{Popover as So}from"@base-ui/react/popover";import*as R from"react";function ce(n,t,o){return n<t?t:n>o?o:n}function Ge(n){let t=n.getBoundingClientRect(),{offsetWidth:o,offsetHeight:l}=n,i=o>0?Math.round(t.width)/o:1,r=l>0?Math.round(t.height)/l:1;return(!Number.isFinite(i)||i===0)&&(i=1),(!Number.isFinite(r)||r===0)&&(r=1),{x:i,y:r}}function Tt(n,t,o){return n/o[t]}function Me(n,t){let o=n.x/t.x,l=n.y/t.y,i=n.width/t.x,r=n.height/t.y;return{x:o,y:l,width:i,height:r,top:l,left:o,right:o+i,bottom:l+r}}var $=1;function xe(n,t){return Math.max(0,n-t)}var Mt=5,vt=20,je=10,yt=100;function Et(n){let{triggerRect:t,positionerRect:o,valueRect:l,textRect:i,scrollHeight:r,documentClientHeight:u,documentClientWidth:h,marginTop:e,marginBottom:a,minHeight:I,maxPopupHeight:d,borderBottom:p,direction:P}=n,f=()=>({fallback:!0,left:0,isTopPositioned:!1,top:0,height:0,scrollTop:0,marginTop:e,marginBottom:a,reachedMaxHeight:!1,transformOrigin:null}),s=u-e-a,c=h,g=t.height,T=s-t.bottom+g,L=P==="rtl"?t.right-o.width:t.left,S=0,M=null;if(i&&l){L=o.left+(P==="rtl"?l.right-i.right:l.left-i.left);let U=l.top-t.top+l.height/2;S=i.top-o.top+i.height/2-U,M=i.top+i.height/2}let w=T+S+a+p,v=Math.min(s,w),Z=s-e-a,k=w-v,O=c-Mt,le=ce(L,Mt,O-o.width),x=xe(r,v),G=k>=x-$;if(G&&(v=Math.min(s,o.height)-(k-x)),t.top<vt||t.bottom>s-vt||Math.ceil(v)+$<Math.min(r,I))return f();let j=Math.max(I,v),K=a+p-e,q=0,B=k;if(G){let U=Math.max(0,s-w);q=o.height>=Z?0:Math.max(0,U+K),B=x}else B=Math.max(0,k-K);let V=null;if(M!=null){let U=o.top,A=o.height,m=A>0?(M-U)/A*100:50;V=`50% ${ce(m,0,100)}%`}let J=j===s||v>=d;return{fallback:!1,left:le,isTopPositioned:G,top:q,height:v,scrollTop:B,marginTop:e,marginBottom:a,reachedMaxHeight:J,transformOrigin:V}}function wt(n){let{isTopPositioned:t,currentHeight:o,scrollTop:l,maxScrollTop:i,maxAvailableHeight:r}=n,u=t?i-l:l;if(u<=$){let d=ce(u,0,r-o),p=o+d;return{height:d>0?p:null,scroll:{kind:"set",value:t?i:0},reachedMaxHeight:r-p<=$}}let h=Math.min(o+u,r),e={kind:"none"},a=!1;if(r-h>$)e=t?{kind:"max"}:{kind:"clamp",value:0};else if(a=!0,!t&&l<i){let d=o+u-r;e={kind:"clamp",value:l-(u-d)}}let I=Math.ceil(h);return{height:I,scroll:e,reachedMaxHeight:a||I>=r-$}}var Be={slot:"bazzaui-select-positioner"};import{jsx as kt}from"react/jsx-runtime";var _e=R.forwardRef(function(t,o){let{alignItemWithTrigger:l=!0,side:i="bottom",align:r="start",sideOffset:u=0,className:h,style:e,children:a,...I}=t,d=ye(),p=D(),P=go()==="rtl"?"rtl":"ltr",f=d.store,s=f.useState("open"),c=f.useState("openMethod"),g=f.useState("hasInput"),[T,L]=R.useState(l),S=T&&c!=="touch"&&!g,[M,w]=R.useState(!1),[v,Z]=R.useState(null),k=R.useRef(null),O=R.useRef(null),le=R.useRef(null),x=R.useRef(!1),G=R.useRef(!1),_=R.useCallback(()=>{let m=k.current,C=f.context.refs.popupRef.current;m&&(m.style.height=""),C&&(C.style.height="",C.style.removeProperty("--transform-origin")),x.current=!1,G.current=!1},[f]),j=R.useCallback(()=>{_(),L(l),w(!1),Z(null)},[l,_]);R.useEffect(()=>p.registerResetPositioningCallback(j),[p,j]);let K=R.useCallback(()=>{if(f.state.hasInput)return;let m=k.current,C=p.triggerRef.current,N=f.context.refs.popupRef.current,Y=f.context.refs.listRef.current;if(!m||!C||!N||!Y)return;let Q=p.selectedItemTextRef.current;if(!Q?.isConnected){let z=p.firstItemTextRef.current;Q=z?.isConnected?z:null}let ee=p.valueRef.current,ae=xo(N),H;try{let z=We(m),ie=m.ownerDocument,te=Ge(C),se=z.getComputedStyle(m),X=z.getComputedStyle(N);H=Et({triggerRect:Me(C.getBoundingClientRect(),te),positionerRect:Me(m.getBoundingClientRect(),te),valueRect:ee?Me(ee.getBoundingClientRect(),te):null,textRect:Q?Me(Q.getBoundingClientRect(),te):null,scrollHeight:Y.scrollHeight,documentClientHeight:ie.documentElement.clientHeight,documentClientWidth:ie.documentElement.clientWidth,marginTop:Number.parseFloat(se.marginTop)||je,marginBottom:Number.parseFloat(se.marginBottom)||je,minHeight:Number.parseFloat(se.minHeight)||yt,maxPopupHeight:Ht(X),borderBottom:Number.parseFloat(X.borderBottomWidth)||0,direction:P});let me=(z.visualViewport?.scale??1)!==1&&ho(z);if(H.fallback||me){L(!1),w(!0);return}m.style.height=`${H.height}px`,N.style.height="100%",H.transformOrigin&&N.style.setProperty("--transform-origin",H.transformOrigin),Y.scrollTop=H.scrollTop,x.current=H.reachedMaxHeight,G.current=!0}finally{ae()}Z({left:H.left,top:H.isTopPositioned?H.top:null,bottom:H.isTopPositioned?null:0,marginTop:H.marginTop,marginBottom:H.marginBottom}),w(!0)},[f,p,P]);R.useEffect(()=>{!s||!S||M||K()},[s,S,M,K]),R.useEffect(()=>{s&&!S&&_()},[s,S,_]),R.useEffect(()=>{if(!s||!S)return;let m=k.current,C=m?We(m):window,N=Y=>{f.setOpen(!1,Qe.none,Y)};return C.addEventListener("resize",N),()=>{C.removeEventListener("resize",N)}},[s,S,f]);let q=R.useCallback(m=>{let C=k.current,N=f.context.refs.popupRef.current;if(!C||!N||!G.current||x.current||!S)return;let Y=C.style.top==="0px",Q=C.style.bottom==="0px";if(!Y&&!Q)return;let ee=We(C),ae=C.ownerDocument,H=Ge(C),z=Tt(C.getBoundingClientRect().height,"y",H),ie=ee.getComputedStyle(C),te=Number.parseFloat(ie.marginTop)||0,se=Number.parseFloat(ie.marginBottom)||0,X=Ht(ee.getComputedStyle(N)),me=Math.min(ae.documentElement.clientHeight-te-se,X),oe=wt({isTopPositioned:Y,currentHeight:z,scrollTop:m.scrollTop,maxScrollTop:xe(m.scrollHeight,m.clientHeight),maxAvailableHeight:me});switch(oe.height!=null&&(C.style.height=`${oe.height}px`),oe.scroll.kind){case"set":m.scrollTop=oe.scroll.value;break;case"max":{let de=xe(m.scrollHeight,m.clientHeight);Math.abs(m.scrollTop-de)>$&&(m.scrollTop=de);break}case"clamp":{let de=xe(m.scrollHeight,m.clientHeight),ne=ce(oe.scroll.value,0,de);Math.abs(m.scrollTop-ne)>$&&(m.scrollTop=ne);break}default:break}oe.reachedMaxHeight&&(x.current=!0)},[f,S]);R.useEffect(()=>{if(!s||!S||!M)return;let m=f.context.refs.listRef.current;if(!m)return;let C=()=>q(m);return m.addEventListener("scroll",C,{passive:!0}),()=>{m.removeEventListener("scroll",C)}},[s,S,M,q,f]);let B=S?"none":i,V=R.useMemo(()=>({alignItemWithTriggerActive:S,side:B,align:r,scrollUpArrowRef:O,scrollDownArrowRef:le,setAlignItemWithTriggerActive:L,resetPositioningState:j}),[S,B,r,j]),J=R.useCallback(m=>{k.current=m,typeof o=="function"?o(m):o&&(o.current=m)},[o]),U=s&&S&&!M,A=S&&v?{position:"fixed",transform:"none",left:v.left,top:v.top??"auto",bottom:v.bottom??"auto",marginTop:v.marginTop,marginBottom:v.marginBottom,maxHeight:"none"}:{};return kt(ze.Provider,{value:V,children:kt(So.Positioner,{ref:J,side:S?void 0:i,align:S?void 0:r,sideOffset:S?0:u,disableAnchorTracking:S||void 0,className:h,style:{...e,...A,...U?{visibility:"hidden"}:{}},...S?{"data-side":"none","data-align":r}:{},[Be.slot]:"",...I,children:a})})});function We(n){return n.ownerDocument?.defaultView??window}function Ht(n){let t=n.maxHeight||"";return t.endsWith("px")&&Number.parseFloat(t)||Number.POSITIVE_INFINITY}function ho(n){let t=n.navigator;return t?/AppleWebKit/.test(t.userAgent)&&!/Chrome|Chromium|Edg|OPR/.test(t.userAgent):!1}var Lt=[["transform","none"],["scale","1"],["translate","0 0"]];function xo(n){let{style:t}=n,o={};for(let[l,i]of Lt)o[l]=t.getPropertyValue(l),t.setProperty(l,i,"important");return()=>{for(let[l]of Lt){let i=o[l];i?t.setProperty(l,i):t.removeProperty(l)}}}import{Popover as bo}from"@base-ui/react/popover";import*as b from"react";import{jsx as ve,jsxs as Po}from"react/jsx-runtime";function qe(n){let{open:t,onOpenChange:o,onOpenChangeComplete:l,actionsRef:i,defaultOpen:r=!1,value:u,defaultValue:h,onValueChange:e,multiple:a=!1,values:I,defaultValues:d,onValuesChange:p,isItemEqualToValue:P=xt,itemToStringLabel:f,itemToStringValue:s,name:c,form:g,required:T,disabled:L=!1,placeholder:S="Select...",items:M,modal:w=!0,virtualized:v=!1,virtualItems:Z,onHighlightChange:k,debug:O,children:le,...x}=n,G=b.useId(),_=b.useRef(null),j=b.useRef(null),K=b.useRef(null),q=b.useRef(null),B=b.useCallback(E=>{_.current=E},[]),V=b.useCallback(E=>{j.current=E},[]),J=b.useRef(null),U=b.useCallback(E=>(J.current=E,()=>{J.current=null}),[]),{store:A,focusOwnerStore:m,openChainStore:C,registerSurface:N,closeAll:Y,virtualization:Q,handleOpenChange:ee,disabled:ae,setDisabled:H}=et({onOpenChange:o,defaultOpen:r,virtualized:v,items:Z,onHighlightChange:k,disabled:L}),z=b.useRef(null);b.useImperativeHandle(i,()=>({close:()=>{z.current?.close()},unmount:()=>{z.current?.unmount()},setDisabled:H}),[H]),A.useControlledProp("openProp",t);let ie=A.useState("open"),[te,se]=b.useState(h!==void 0?h:null),X=u!==void 0?u:te,me=b.useCallback(E=>{u===void 0&&se(E),e?.(E)},[u,e]),[oe,de]=b.useState(d??[]),ne=I!==void 0?I:oe,$e=b.useCallback(E=>{I===void 0&&de(E),p?.(E)},[I,p]),Ke=b.useRef(new Map),Je=b.useCallback((E,fe)=>(Ke.current.set(E,fe),()=>{}),[]),Ut=b.useMemo(()=>({multiple:a,value:X,values:ne,onValueChange:me,onValuesChange:$e,isItemEqualToValue:P,itemToStringLabel:f,itemToStringValue:s,name:c,form:g,required:T,disabled:ae,placeholder:S,items:M,itemTextRegistry:Ke.current,registerItemText:Je,listId:G,triggerRef:_,valueRef:j,selectedItemTextRef:K,firstItemTextRef:q,setTriggerElement:B,setValueElement:V,registerResetPositioningCallback:U}),[a,X,ne,me,$e,P,f,s,c,g,T,ae,S,M,Je,G,B,V,U]),Yt=b.useMemo(()=>c?a?ne.length>0?ne.map((E,fe)=>{let Ze=F(E,s);return ve("input",{type:"hidden",name:c,value:Ze,form:g,required:T&&fe===0},Ze)}):ve("input",{type:"hidden",name:c,value:"",form:g,required:T}):ve("input",{type:"hidden",name:c,value:X!=null?F(X,s):"",form:g,required:T}):null,[c,g,T,a,X,ne,s]),Xt=b.useCallback((E,fe)=>{ee(E,fe.reason,fe.event)},[ee]),$t=b.useCallback(E=>{!E&&A.context.clearSearchOnClose==="after-exit"&&(A.clearSearch(),A.setInputActive(!1)),E||(A.clearHighlight(),J.current?.(),q.current=null),l?.(E)},[A,l]);return ve(Ee.Provider,{value:Ut,children:Po(lt,{store:A,focusOwnerStore:m,openChainStore:C,disabled:ae,depth:0,closeAll:Y,registerSurface:N,virtualization:Q,menuType:"dropdown",componentName:"select",debug:O,children:[Yt,ve(bo.Root,{...x,open:ie,onOpenChange:Xt,onOpenChangeComplete:$t,modal:w,actionsRef:i?z:void 0,children:le})]})})}import*as ke from"react";var At={slot:"bazzaui-select-surface"};import{jsx as Ro}from"react/jsx-runtime";var Ue=ke.forwardRef(function(t,o){let{autoHighlightFirst:l,...i}=t,r=D(),u=Te(),h=ke.useMemo(()=>{let e=a=>ge(a)?!0:F(a,r.itemToStringValue);if(l==="selected"){let a=r.multiple?r.values[0]:r.value;return e(a)}if(l!==void 0)return l;if(u?.alignItemWithTriggerActive){let a=r.multiple?r.values[0]:r.value;return e(a)}return!0},[l,u?.alignItemWithTriggerActive,r.multiple,r.value,r.values,r.itemToStringValue]);return Ro(dt,{ref:o,autoHighlightFirst:h,[At.slot]:"",...i})});import{Popover as Io}from"@base-ui/react/popover";import{useRender as Co}from"@base-ui/react/use-render";import*as pe from"react";var be={slot:"bazzaui-select-trigger",open:"data-open",closed:"data-closed",disabled:"data-disabled",placeholder:"data-placeholder"};import{jsx as Dt}from"react/jsx-runtime";var Vo={open:n=>n?{[be.open]:""}:null,disabled:n=>n?{[be.disabled]:""}:null,placeholder:n=>n?{[be.placeholder]:""}:null},To=pe.forwardRef(function(t,o){let{render:l,children:i,disabled:r,className:u,style:h,triggerProps:e,triggerState:a,...I}=t,d=D(),p=r??d.disabled,P=d.multiple?d.values.length>0:!ge(d.value),f=pe.useMemo(()=>({open:a.open,disabled:p,placeholder:!P}),[a.open,p,P]),s=pe.useCallback(c=>{d.setTriggerElement(c)},[d]);return Co({render:l,ref:o,state:f,stateAttributesMapping:Vo,props:{...ht(e,{...I,className:u,style:h,children:i}),[be.slot]:"",ref:s,role:"combobox","aria-haspopup":"listbox","aria-controls":d.listId},defaultTagName:"button"})}),Ye=pe.forwardRef(function(t,o){let{disabled:l,...i}=t,r=D(),u=ye(),h=(l??r.disabled)||u.disabled;return Dt(Io.Trigger,{ref:o,disabled:h,render:(e,a)=>Dt(To,{...i,disabled:h,triggerProps:e,triggerState:a,ref:e.ref})})});import{useRender as Mo}from"@base-ui/react/use-render";import*as re from"react";var Ae={slot:"bazzaui-select-value",placeholder:"data-placeholder",multiple:"data-multiple"};var vo={hasValue:n=>n?null:{[Ae.placeholder]:""},multiple:n=>n?{[Ae.multiple]:""}:null,getValueText:()=>null};function yo(n,t){let{render:o,className:l,style:i,placeholder:r,children:u,...h}=n,e=D(),a=r??e.placeholder,I=re.useMemo(()=>Pe(e.items,""),[e.items]),d=r??I??a,p=e.multiple?e.values.length>0:!ge(e.value),P=re.useCallback(g=>{let T=F(g,e.itemToStringValue),L=e.itemTextRegistry.get(T);if(L!==void 0)return L;let S=Pe(e.items,T);if(S!==void 0)return S;let M=Se(g,e.itemToStringLabel);if(M&&M!==T)return M},[e.itemTextRegistry,e.items,e.itemToStringLabel,e.itemToStringValue]),f=re.useMemo(()=>({value:e.value,values:e.values,multiple:e.multiple,hasValue:p,placeholder:a,getValueText:P}),[e.value,e.values,e.multiple,p,a,P]),s;if(typeof u=="function")s=u(f);else if(u!==void 0)s=u;else if(!p)s=d;else if(e.multiple){let g=e.values.map(T=>{let L=P(T);return L!==void 0?L:Se(T,e.itemToStringLabel)||F(T,e.itemToStringValue)}).filter(Boolean);s=g.length>2?`${g.length} selected`:g.join(", ")}else{let g=e.value;if(g!=null){let T=P(g);T!==void 0?s=T:s=Se(g,e.itemToStringLabel)||F(g,e.itemToStringValue)}}let c=re.useCallback(g=>{e.setValueElement(g)},[e]);return Mo({render:o,ref:t,state:f,stateAttributesMapping:vo,props:{...h,[Ae.slot]:"",ref:c,className:l,style:i,children:s},defaultTagName:"span"})}var Xe=re.forwardRef(yo);var Nt=(u=>(u.slot="bazzaui-select-arrow",u.open="data-open",u.closed="data-closed",u.side="data-side",u.align="data-align",u.uncentered="data-uncentered",u))(Nt||{});var zt=(r=>(r.slot="bazzaui-select-backdrop",r.open="data-open",r.closed="data-closed",r.startingStyle="data-starting-style",r.endingStyle="data-ending-style",r))(zt||{});var Ft=(t=>(t.slot="bazzaui-select-empty",t))(Ft||{});var Gt=(t=>(t.slot="bazzaui-select-group",t))(Gt||{});var jt=(t=>(t.slot="bazzaui-select-group-label",t))(jt||{});var Eo={slot:"bazzaui-select-icon",open:"data-popup-open"};var Bt=(l=>(l.slot="bazzaui-select-input",l.open="data-open",l.closed="data-closed",l))(Bt||{});var Wt=(o=>(o.slot="bazzaui-select-list",o.list="data-popup-menu-list",o))(Wt||{});var _t=(t=>(t.alignItemWithTrigger="data-align-item-with-trigger",t))(_t||{});var wo={slotUp:"bazzaui-select-scroll-up-arrow",slotDown:"bazzaui-select-scroll-down-arrow",direction:"data-direction",side:"data-side"};var qt=(t=>(t.slot="bazzaui-select-separator",t))(qt||{});export{Ot as Select,Nt as SelectArrowDataAttributes,zt as SelectBackdropDataAttributes,Ft as SelectEmptyDataAttributes,Gt as SelectGroupDataAttributes,jt as SelectGroupLabelDataAttributes,Eo as SelectIconDataAttributes,Bt as SelectInputDataAttributes,De as SelectItem,he as SelectItemDataAttributes,Oe as SelectItemIndicator,Ve as SelectItemIndicatorDataAttributes,Ne as SelectItemLabel,no as SelectListCssVars,Wt as SelectListDataAttributes,Fe as SelectPopup,_t as SelectPopupDataAttributes,_e as SelectPositioner,oo as SelectPositionerCssVars,Be as SelectPositionerDataAttributes,qe as SelectRoot,wo as SelectScrollArrowDataAttributes,qt as SelectSeparatorDataAttributes,to as SelectStore,Ue as SelectSurface,Ye as SelectTrigger,be as SelectTriggerDataAttributes,Xe as SelectValue,Qt as commandScore,eo as defaultFilter,ro as useMaybeSelectContext,lo as useMaybeSelectItemContext,Zt as useMaybeSurfaceContext,D as useSelectContext,Ce as useSelectItemContext,Te as useSelectPositionerContext,Jt as useSurfaceContext};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|