25 lines
671 B
JavaScript
25 lines
671 B
JavaScript
import { Tag } from "sigpro";
|
|
import { val, joinClass } from "../core/utils.js";
|
|
|
|
/** RADIO */
|
|
export const Radio = (props) => {
|
|
const { label, tooltip, value, inputValue, name, ...rest } = props;
|
|
|
|
const radioEl = Tag("input", {
|
|
...rest,
|
|
type: "radio",
|
|
name: name,
|
|
class: joinClass("radio", props.class),
|
|
checked: () => val(value) === inputValue,
|
|
onclick: () => {
|
|
if (typeof value === "function") value(inputValue);
|
|
},
|
|
});
|
|
|
|
if (!label && !tooltip) return radioEl;
|
|
|
|
return Tag("label", { class: "label cursor-pointer justify-start gap-3" }, [
|
|
radioEl,
|
|
label ? Tag("span", { class: "label-text" }, label) : null,
|
|
]);
|
|
}; |