import React, { memo, forwardRef } from 'react';
import { useToken, usePropsResolution } from '../../../hooks';
import type { IIconProps } from './types';
import SVGIcon from './SVGIcon';
import { Factory } from '../../../factory';
const Icon = ({ as, ...props }: IIconProps, ref?: any) => {
const { size, ...resolvedProps } = usePropsResolution('Icon', props);
const tokenizedFontSize = useToken('space', size);
if (!as) {
return ;
}
const isJSX = React.isValidElement(as);
const StyledAs = Factory(
isJSX
? (resolvedProps) =>
React.cloneElement(as, {
...resolvedProps,
...as.props,
})
: as
);
return (
);
};
export default memo(forwardRef(Icon));