/** * Created by jiangzhixiong on 2024/04/28 */ import React, { forwardRef, MouseEventHandler, ReactNode, useContext, useImperativeHandle } from 'react' import { ConfigProvider, EMPTY_BASE64 } from '@zhst/meta' import { Flex, Image } from 'antd'; import './index.less' const { ConfigContext } = ConfigProvider export interface IData { id?: string | number; url?: string; sort?: number; title?: string; subtitle?: string; } export interface CommonCardProps extends IData { prefixCls?: string; data?: IData width?: string; height?: string; onCreateTxt?: string; onCreate?: () => void; onAddTxt?: string; onAdd?: (data: any) => void; onRemoveTxt?: string; onRemove?: (data: any) => void; actions?: ReactNode[] onItemClick?: (data: any, e: React.MouseEvent) => void; } export interface CommonCardRefProps { } const CommonCard = forwardRef((props, ref) => { const { prefixCls: customizePrefixCls, url, id, title, subtitle, sort, data, actions = [], width = '184px', height = '100%', onItemClick } = props const { getPrefixCls } = useContext(ConfigContext) const componentName = getPrefixCls('biz-search-card', customizePrefixCls); const optionListRender = (_actions: ReactNode[]) => { return _actions.map((action, i) => ( // eslint-disable-next-line react/no-array-index-key
  • {action} {i !== _actions.length - 1 && }
  • )) } const handleItemClick = (e: React.MouseEvent, _data: IData | undefined) => { onItemClick?.(data, e) } useImperativeHandle(ref, () => ({ })) return (
    handleItemClick(e, data)} >
    {sort || id}
      {optionListRender(actions)}

    {title || data?.title}

    {subtitle || data?.subtitle}

    ) }) export default CommonCard