'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../../utils/index.cjs');
require('../../../../directives/index.cjs');
var vueTypes = require('../../../../utils/vue/vueTypes.cjs');
var index = require('../../../../directives/ant-input/index.cjs');
var vnode = require('../../../../utils/vue/vnode.cjs');
var _class = require('../../../../utils/dom/class.cjs');

const inputProps = {
  inputRef: vueTypes.default.any,
  prefixCls: String,
  id: String,
  inputElement: vueTypes.default.VueNode,
  disabled: {
    type: Boolean,
    default: void 0
  },
  autofocus: {
    type: Boolean,
    default: void 0
  },
  autocomplete: String,
  editable: {
    type: Boolean,
    default: void 0
  },
  activeDescendantId: String,
  value: String,
  open: {
    type: Boolean,
    default: void 0
  },
  tabindex: vueTypes.default.oneOfType([vueTypes.default.number, vueTypes.default.string]),
  /** Pass accessibility props to input */
  attrs: vueTypes.default.object,
  onKeydown: {
    type: Function
  },
  onMousedown: {
    type: Function
  },
  onChange: {
    type: Function
  },
  onPaste: {
    type: Function
  },
  onCompositionstart: {
    type: Function
  },
  onCompositionend: {
    type: Function
  },
  onFocus: {
    type: Function
  },
  onBlur: {
    type: Function
  }
};
const Input = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "SelectInput",
  inheritAttrs: false,
  props: inputProps,
  setup(props) {
    let blurTimeout = null;
    const VCSelectContainerEvent = vue.inject("VCSelectContainerEvent");
    return () => {
      var _a;
      const {
        prefixCls,
        id,
        inputElement,
        disabled,
        tabindex,
        autofocus,
        autocomplete,
        editable,
        activeDescendantId,
        value,
        onKeydown,
        onMousedown,
        onChange,
        onPaste,
        onCompositionstart,
        onCompositionend,
        onFocus,
        onBlur,
        open,
        inputRef,
        attrs
      } = props;
      let inputNode = inputElement || vue.withDirectives(vue.createVNode("input", null, null), [[index.antInputDirective]]);
      const getInputProps = inputNode.props || {};
      const {
        onKeydown: onOriginKeyDown,
        onInput: onOriginInput,
        onFocus: onOriginFocus,
        onBlur: onOriginBlur,
        onMousedown: onOriginMouseDown,
        onCompositionstart: onOriginCompositionStart,
        onCompositionend: onOriginCompositionEnd,
        style
      } = getInputProps;
      inputNode = vnode.cloneElement(inputNode, Object.assign({
        "type": "search",
        ...getInputProps,
        id,
        "ref": inputRef,
        disabled,
        tabindex,
        "autocomplete": autocomplete || "off",
        autofocus,
        "class": _class.classNames(`${prefixCls}-selection-search-input`, (_a = inputNode == null ? void 0 : inputNode.props) == null ? void 0 : _a.class),
        "role": "combobox",
        "aria-expanded": open,
        "aria-haspopup": "listbox",
        "aria-owns": `${id}_list`,
        "aria-autocomplete": "list",
        "aria-controls": `${id}_list`,
        "aria-activedescendant": activeDescendantId,
        ...attrs,
        "value": editable ? value : "",
        "readonly": !editable,
        "unselectable": !editable ? "on" : null,
        "style": {
          ...style,
          opacity: editable ? null : 0
        },
        "onKeydown": (event) => {
          onKeydown(event);
          if (onOriginKeyDown)
            onOriginKeyDown(event);
        },
        "onMousedown": (event) => {
          onMousedown(event);
          if (onOriginMouseDown)
            onOriginMouseDown(event);
        },
        "onInput": (event) => {
          onChange(event);
          if (onOriginInput)
            onOriginInput(event);
        },
        onCompositionstart(event) {
          onCompositionstart(event);
          if (onOriginCompositionStart)
            onOriginCompositionStart(event);
        },
        onCompositionend(event) {
          onCompositionend(event);
          if (onOriginCompositionEnd)
            onOriginCompositionEnd(event);
        },
        onPaste,
        "onFocus": (...args) => {
          clearTimeout(blurTimeout);
          onOriginFocus && onOriginFocus(args[0]);
          onFocus && onFocus(args[0]);
          VCSelectContainerEvent == null ? void 0 : VCSelectContainerEvent.focus(args[0]);
        },
        "onBlur": (...args) => {
          blurTimeout = setTimeout(() => {
            onOriginBlur && onOriginBlur(args[0]);
            onBlur && onBlur(args[0]);
            VCSelectContainerEvent == null ? void 0 : VCSelectContainerEvent.blur(args[0]);
          }, 100);
        }
      }, inputNode.type === "textarea" ? {} : {
        type: "search"
      }), true, true);
      return inputNode;
    };
  }
});

exports.default = Input;
exports.inputProps = inputProps;
//# sourceMappingURL=Input.cjs.map
