UNPKG

@ark-ui/react

Version:

A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.

54 lines (51 loc) 1.74 kB
'use client'; import { jsx } from 'react/jsx-runtime'; import { mergeProps } from '@zag-js/react'; import { forwardRef } from 'react'; import { createSplitProps } from '../../utils/create-split-props.js'; import { ark } from '../factory.js'; import { splitPresenceProps } from '../presence/split-presence-props.js'; import { usePresence } from '../presence/use-presence.js'; import { PresenceProvider } from '../presence/use-presence-context.js'; import { useSelect } from './use-select.js'; import { SelectProvider } from './use-select-context.js'; const SelectImpl = (props, ref) => { const [presenceProps, selectProps] = splitPresenceProps(props); const [useSelectProps, localProps] = createSplitProps()(selectProps, [ "closeOnSelect", "collection", "composite", "defaultHighlightedValue", "defaultOpen", "defaultValue", "deselectable", "disabled", "form", "highlightedValue", "id", "ids", "invalid", "loopFocus", "multiple", "name", "onFocusOutside", "onHighlightChange", "onInteractOutside", "onOpenChange", "onPointerDownOutside", "onSelect", "onValueChange", "open", "positioning", "readOnly", "required", "scrollToIndexFn", "value" ]); const select = useSelect(useSelectProps); const presence = usePresence(mergeProps({ present: select.open }, presenceProps)); const mergedProps = mergeProps(select.getRootProps(), localProps); return /* @__PURE__ */ jsx(SelectProvider, { value: select, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presence, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }) }) }); }; const SelectRoot = forwardRef(SelectImpl); export { SelectRoot };