UNPKG

@crossed/primitive

Version:

A universal & performant styling library for React Native, Next.js & React

30 lines (29 loc) 942 B
import { jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { useContext } from "./context"; import { composeEventHandlers } from "@crossed/core"; import { RovingFocus } from "../utils/RovingFocus"; const createSelectItem = (Styled) => ( // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore forwardRef(({ value, ...props }, ref) => { const { setOpen, setValue } = useContext(); return /* @__PURE__ */ jsx(RovingFocus.Item, { ref, focusable: !props.disabled, children: /* @__PURE__ */ jsx( Styled, { tabIndex: props.disabled ? -1 : 0, "aria-disabled": (props.disabled || false).toString(), role: "menuitem", ...props, onPress: composeEventHandlers(props.onPress, () => { setOpen(false); setValue(value); }) } ) }); }) ); export { createSelectItem }; //# sourceMappingURL=SelectItem.js.map