@wordpress/components
Version:
UI components for WordPress.
42 lines (41 loc) • 1.13 kB
JavaScript
import { forwardRef, useContext } from "@wordpress/element";
import * as Ariakit from "@ariakit/react";
import Button from "../button";
import { RadioGroupContext } from "./context";
import { maybeWarnDeprecated36pxSize } from "../utils/deprecated-36px-size";
import { jsx as _jsx } from "react/jsx-runtime";
function UnforwardedRadio({
value,
children,
...props
}, ref) {
const {
store,
disabled
} = useContext(RadioGroupContext);
const selectedValue = Ariakit.useStoreState(store, "value");
const isChecked = selectedValue !== void 0 && selectedValue === value;
maybeWarnDeprecated36pxSize({
componentName: "Radio",
size: void 0,
__next40pxDefaultSize: props.__next40pxDefaultSize
});
return /* @__PURE__ */ _jsx(Ariakit.Radio, {
disabled,
store,
ref,
value,
render: /* @__PURE__ */ _jsx(Button, {
variant: isChecked ? "primary" : "secondary",
...props
}),
children: children || value
});
}
const Radio = forwardRef(UnforwardedRadio);
var radio_default = Radio;
export {
Radio,
radio_default as default
};
//# sourceMappingURL=radio.js.map