/** @jsxImportSource @emotion/react */ 'use client'; import { Interpolation, Theme } from '@emotion/react'; import { ForwardedRef, HTMLAttributes, useState } from 'react'; // import { colors } from '@/libs/themes'; // type Types = { themes?: { check?: { defaultColor?: string; checkColor?: string; hoverColor?: string; disabledColor?: string; borderColor?: string; borderRadius?: string | number; checkSize?: number; }; label?: { titleColor?: string; titleSize?: number; titleWeight?: 'lighter' | 'normal' | 'medium' | 'bold'; txtColor?: string; txtSize?: number; opacity?: number; }; }; label?: { title: string; edgeTitle?: string; txt?: string; txtOnClick?: any; }; labelActive?: boolean; checked: boolean; disabled?: boolean; onClick?: any; css?: Interpolation; children?: never[]; } & Omit, 'onClick'>; // // function Checkbox(props: Types & { ref?: ForwardedRef }) { const [hover, setHover] = useState(false); const checkColors = () => { if (props?.disabled) return props?.themes?.check?.disabledColor ?? '#fafafa'; if (!!props?.checked) return props?.themes?.check?.checkColor ?? colors.keyColor; return props?.themes?.check?.defaultColor ?? '#e2e2e2'; }; const checkBorderColors = () => { if (props?.disabled) return props?.themes?.check?.disabledColor ?? '#e0e0e0'; if (!!props?.checked) return props?.themes?.check?.checkColor ?? colors.keyColor; return props?.themes?.check?.defaultColor ?? '#e2e2e2'; }; const checkIconColors = () => { if (props?.disabled) return props?.themes?.check?.disabledColor ?? '#aaa'; if (!!props?.checked) return props?.themes?.check?.checkColor ?? '#fff'; return props?.themes?.check?.defaultColor ?? '#fff'; }; const handleOnClick = (event: React.MouseEvent) => { if (typeof props.onClick === 'function') props.onClick(event); }; const TYPOGRAPH_WEIGHT = { lighter: { fontWeight: '300' }, normal: { fontWeight: '400' }, medium: { fontWeight: '500' }, bold: { fontWeight: '600' }, } as const; return (
setHover(true)} onMouseLeave={() => setHover(false)} onClick={handleOnClick} {...(props || {})} ref={props.ref} css={{ display: 'flex', alignItems: 'start', gap: 7 }} >
{props?.disabled ? (
) : ( )}
{!!props?.label && (

{props?.label.title} {!!props?.label.edgeTitle && ( {props?.label.edgeTitle} )}

{props?.label.txt}

)}
); } const CheckIcon = ({ size, fill }: { size: any; fill: string }) => ( ); export { Checkbox };