import { useComponent } from 'functional-mini/component';
import fmtEvent from '../fmtEvent';
export function useComponentEvent(props) {
    var component = useComponent();
    return {
        triggerEvent: function (eventName, value, e) {
            // 首字母大写，然后加上 on
            var alipayCallbackName = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
            if (props[alipayCallbackName]) {
                props[alipayCallbackName](value, fmtEvent(props, e));
            }
        },
        triggerEventOnly: function (eventName, e) {
            // 首字母大写，然后加上 on
            var alipayCallbackName = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
            if (props[alipayCallbackName]) {
                props[alipayCallbackName](fmtEvent(props, e));
            }
        },
        // 转发 catch 事件
        alipayForwardCatchEvent: function (eventName, e) {
            // 首字母大写，然后加上 catch
            var alipayCallbackName = 'catch' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
            if (props[alipayCallbackName]) {
                props[alipayCallbackName](fmtEvent(props, e));
            }
        },
        // 转发事件
        alipayForwardEvent: function (eventName, e) {
            // 首字母大写，然后加上 on
            var alipayCallbackName = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
            if (props[alipayCallbackName]) {
                props[alipayCallbackName](fmtEvent(props, e));
            }
        },
    };
}
