mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-03 18:54:11 +08:00

Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: jZonG <jzongcode@gmail.com>
40 lines
755 B
TypeScript
40 lines
755 B
TypeScript
import { generate } from './utils'
|
|
import type { AbstractNode } from './utils'
|
|
|
|
export type IconData = {
|
|
name: string
|
|
icon: AbstractNode
|
|
}
|
|
|
|
export type IconBaseProps = {
|
|
data: IconData
|
|
className?: string
|
|
onClick?: React.MouseEventHandler<SVGElement>
|
|
style?: React.CSSProperties
|
|
}
|
|
|
|
const IconBase = (
|
|
{
|
|
ref,
|
|
...props
|
|
}: IconBaseProps & {
|
|
ref?: React.RefObject<React.MutableRefObject<HTMLOrSVGElement>>;
|
|
},
|
|
) => {
|
|
const { data, className, onClick, style, ...restProps } = props
|
|
|
|
return generate(data.icon, `svg-${data.name}`, {
|
|
className,
|
|
onClick,
|
|
style,
|
|
'data-icon': data.name,
|
|
'aria-hidden': 'true',
|
|
...restProps,
|
|
'ref': ref,
|
|
})
|
|
}
|
|
|
|
IconBase.displayName = 'IconBase'
|
|
|
|
export default IconBase
|