UNPKG

@wordpress/components

Version:
31 lines (30 loc) • 1.06 kB
import { forwardRef, useContext } from "@wordpress/element"; import * as Ariakit from "@ariakit/react"; import Button from "../button/index.mjs"; import { RadioGroupContext } from "./context.mjs"; import { jsx } from "react/jsx-runtime"; // packages/components/src/radio-group/radio.tsx function UnforwardedRadio({ value, children, __next40pxDefaultSize: _next40pxDefaultSize, ...props }, ref) { const { store, disabled } = useContext(RadioGroupContext); const selectedValue = Ariakit.useStoreState(store, "value"); const isChecked = selectedValue !== void 0 && selectedValue === value; return /* @__PURE__ */ jsx(Ariakit.Radio, { disabled, store, ref, value, render: /* @__PURE__ */ jsx(Button, { variant: isChecked ? "primary" : "secondary", __next40pxDefaultSize: true, ...props }), children: children || value }); } /** * @deprecated Use `RadioControl` or `ToggleGroupControl` instead. */ const Radio = forwardRef(UnforwardedRadio); Radio.displayName = "Radio"; export { Radio, Radio as default }; //# sourceMappingURL=radio.mjs.map