UNPKG

@navinc/base-react-components

Version:
33 lines 2.62 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from 'react'; import { cn } from '../../cn.js'; import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'; const BaseRadio = forwardRef((_a, forwardedRef) => { var { disabled, className } = _a, props = __rest(_a, ["disabled", "className"]); return (_jsx(RadioGroupPrimitive.Item, Object.assign({ className: cn('mb-auto rounded-full ring-1 ring-onSurfaceDim/50 flex min-w-300 min-h-300 items-center justify-center bg-gradient-to-b from-surfaceContainer/0 to-onSurface/4', !disabled && 'data-[state=unchecked]:group-hover:to-onSurface/8 data-[state=unchecked]:group-active:ring-onSurfaceDim data-[state=unchecked]:group-active:bg-gradient-to-t data-[state=unchecked]:group-active:from-onSurface/8 data-[state=unchecked]:group-active:to-onSurface/8', !disabled && 'data-[state=checked]:bg-primary data-[state=checked]:shadow-[inset_0_1px_0.5px_0_rgba(255,255,255,0.6)] data-[state=checked]:ring-onPrimaryContainer', disabled && 'bg-surfaceDim', className), ref: forwardedRef, disabled: disabled }, props, { children: _jsx(RadioGroupPrimitive.Indicator, { className: cn('w-100 h-100 rounded-full bg-white', !disabled && 'data-[state=unchecked]:group-hover:bg-outline/50 data-[state=unchecked]:group-active:bg-outline', !disabled && 'data-[state=checked]:bg-onPrimary', disabled && 'bg-outline/50') }) }))); }); export const RadioGroupInternal = { Root: RadioGroupPrimitive.Root, Radio: BaseRadio, }; /** Contains all the parts of a radio group. */ export const RadioGroup = RadioGroupInternal.Root; /** Contains radio and label **/ export const Radio = (_a) => { var { label, disabled, className } = _a, props = __rest(_a, ["label", "disabled", "className"]); return (_jsxs("label", { className: cn('group flex w-fit justify-start items-center', className), children: [_jsx(RadioGroupInternal.Radio, Object.assign({ disabled: disabled }, props)), _jsx("span", { className: cn('body1 ml-150', disabled && 'text-onSurfaceDim'), children: label })] })); }; //# sourceMappingURL=radio.js.map