import React, { forwardRef, memo, useMemo } from 'react'; import clsx from 'clsx'; import MuiButton from '@mui/material/Button'; import MuiTypography from '@mui/material/Typography'; import { CustomIcon } from '../custom-icon'; import type { ButtonProps } from './types'; import createClasses from './styles'; const Button = forwardRef(function Button(props, ref) { const { color = 'primary', children, startIconUrl, endIconUrl, active, size = 'medium', changed, variant: _variant, className, clickArea = true, customSize, onBtnClick, ...other } = props; const classes = createClasses(); const variant = useMemo(() => (clickArea ? _variant : 'text'), [_variant, clickArea]); const isActiveText = useMemo( () => active && color === 'third' && size === 'medium' && typeof children === 'string', [active, color, size, children] ); const isActiveIcon = useMemo( () => active && color === 'third' && typeof children !== 'string', [active, color, children] ); const isChangedIcon = useMemo( () => changed && color === 'third' && typeof children !== 'string', [changed, color, children] ); return ( ) : undefined } endIcon={ endIconUrl ? ( ) : undefined } data-testid="button" {...other} > {children} ); }); const m = memo(Button); export { m as Button };