'use strict';

var vue = require('vue');
require('../../../utils/index.cjs');
var keyCode = require('../../../utils/keyCode.cjs');

const inlineStyle = {
  border: 0,
  background: "transparent",
  padding: 0,
  lineHeight: "inherit",
  display: "inline-block"
};
const TransButton = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "TransButton",
  inheritAttrs: false,
  props: {
    noStyle: {
      type: Boolean,
      default: void 0
    },
    onClick: Function,
    disabled: {
      type: Boolean,
      default: void 0
    },
    autofocus: {
      type: Boolean,
      default: void 0
    }
  },
  setup(props, {
    slots,
    emit,
    attrs,
    expose
  }) {
    const domRef = vue.shallowRef();
    const onKeyDown = (event) => {
      const {
        keyCode: keyCode$1
      } = event;
      if (keyCode$1 === keyCode.KeyCode.ENTER)
        event.preventDefault();
    };
    const onKeyUp = (event) => {
      const {
        keyCode: keyCode$1
      } = event;
      if (keyCode$1 === keyCode.KeyCode.ENTER)
        emit("click", event);
    };
    const onClick = (e) => {
      emit("click", e);
    };
    const focus = () => {
      if (domRef.value)
        domRef.value.focus();
    };
    const blur = () => {
      if (domRef.value)
        domRef.value.blur();
    };
    vue.onMounted(() => {
      if (props.autofocus)
        focus();
    });
    expose({
      focus,
      blur
    });
    return () => {
      var _a;
      const {
        noStyle,
        disabled,
        ...restProps
      } = props;
      let mergedStyle = {};
      if (!noStyle) {
        mergedStyle = {
          ...inlineStyle
        };
      }
      if (disabled)
        mergedStyle.pointerEvents = "none";
      return vue.createVNode("div", {
        "role": "button",
        "tabindex": 0,
        "ref": domRef,
        ...restProps,
        ...attrs,
        "onClick": onClick,
        "onKeydown": onKeyDown,
        "onKeyup": onKeyUp,
        "style": {
          ...mergedStyle,
          ...attrs.style || {}
        }
      }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
    };
  }
});

exports.TransButton = TransButton;
//# sourceMappingURL=transButton.cjs.map
