UNPKG

ar-design

Version:

AR Design is a (react | nextjs) ui library.

30 lines (29 loc) 1.69 kB
"use client"; import React, { forwardRef, useRef } from "react"; import "../../../assets/css/components/form/radio/radio.css"; import Utils from "../../../libs/infrastructure/shared/Utils"; const Radio = forwardRef(({ label, size = "normal", status, border = { radius: "sm" }, trace, upperCase, ...attributes }, ref) => { // refs const _checkbox = useRef(null); const _checkboxClassName = ["ar-radio"]; const _traceClassName = ["trace", "filled"]; _checkboxClassName.push(...Utils.GetClassName("filled", status, border, size, undefined, attributes.className)); if (trace && Object.keys(trace).length > 0) _traceClassName.push(trace.color); return (React.createElement("div", { className: "ar-radio-wrapper" }, React.createElement("label", null, React.createElement("input", { ref: ref, type: "radio", ...attributes, size: 0, onChange: (event) => { (() => { const _current = _checkbox.current; if (!_current) return; })(); (() => attributes.onChange && attributes.onChange(event))(); } }), React.createElement("span", null, React.createElement("span", { ref: _checkbox, className: _checkboxClassName.map((c) => c).join(" ") }), trace && Object.keys(trace).length > 0 && (React.createElement("span", { className: _traceClassName.map((c) => c).join(" ") })), label && React.createElement("span", { className: "label" }, upperCase ? label.toUpperCase() : label))))); }); Radio.displayName = "Radio"; export default Radio;