import { useCallback } from "react";
//#region src/components/PisellCards/components/GraphicTextCard/hooks/useGraphicTextCardClick.ts
/**
* useGraphicTextCardClick Hook
* 处理组件点击事件的逻辑
* 
* @param props - GraphicTextCard 组件的 Props
* @returns 点击事件处理函数
* 
* @example
* ```tsx
* const handleClick = useGraphicTextCardClick(props);
* <div onClick={handleClick}>...</div>
* ```
*/
const useGraphicTextCardClick = (props) => {
	const { onClick, active, disabled, loading, clickable = true } = props;
	return useCallback((event) => {
		if ((disabled === null || disabled === void 0 ? void 0 : disabled.value) || (loading === null || loading === void 0 ? void 0 : loading.value) || !clickable) {
			event.preventDefault();
			return;
		}
		if ((active === null || active === void 0 ? void 0 : active.onChange) && !active.value) active.onChange(true);
		if (onClick) onClick(event);
	}, [
		onClick,
		active,
		disabled,
		loading,
		clickable
	]);
};
//#endregion
export { useGraphicTextCardClick };
