UNPKG

@crossed/primitive

Version:

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

32 lines (31 loc) 993 B
import { jsx } from "react/jsx-runtime"; import { forwardRef, useId } from "react"; import { Provider } from "./context"; import { RovingFocusGroupItem } from "../utils/RovingFocus"; import { ButtonGroupCollection } from "./contextCollection"; const createButtonMain = (StyledButton) => forwardRef((props, ref) => { const idDefault = useId(); const id = props.id ?? idDefault; return /* @__PURE__ */ jsx(Provider, { id, children: /* @__PURE__ */ jsx(ButtonGroupCollection.ItemSlot, { id, children: /* @__PURE__ */ jsx( RovingFocusGroupItem, { ref, focusable: props.focusable ?? !props.disabled, children: /* @__PURE__ */ jsx( StyledButton, { "aria-disabled": Boolean(props.disabled ?? false), "aria-labelledby": id, role: "button", tabIndex: props.disabled ? -1 : 0, ...props, id } ) } ) }) }); }); export { createButtonMain }; //# sourceMappingURL=Button.js.map