/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var helper = require('../../chunks/helper.js');
var VueCompositionAPI = require('@vue/composition-api');
var components_popup_index = require('../popup/index.js');
var components_configProvider_useConfig = require('../config-provider/useConfig.js');
var components_selectInput_props = require('./props.js');
var components_selectInput_hooks_useSingle = require('./hooks/use-single.js');
var components_selectInput_hooks_useMultiple = require('./hooks/use-multiple.js');
var components_selectInput_hooks_useOverlayInnerstyle = require('./hooks/use-overlay-innerstyle.js');
require('../../utils/map-props.js');
require('vue');
require('../../utils/with-install.js');
require('lodash');
require('../../config.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../../chunks/set-style.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('../../utils/render-node.js');
require('../../utils/helper.js');
require('lodash/camelCase');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/mixins.js');
require('../popup/props.js');
require('../popup/container.js');
require('lodash/isObject');
require('lodash/pick');
require('../input/index.js');
require('../input/input.js');
require('@ldesign/icons-vue');
require('lodash/kebabCase');
require('../../chunks/helper2.js');
require('../../utils/event.js');
require('../input/props.js');
require('../input/group.js');
require('../loading/index.js');
require('../loading/loading.js');
require('../../utils/transfer-dom.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../loading/plugin.js');
require('../../hooks/lnode.js');
require('lodash/isEmpty');
require('lodash/isFunction');
require('../../hooks/render-lnode.js');
require('../../hooks/use-config.js');
require('../../hooks/use-default-value.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../../hooks/use-global-icon.js');
require('../tag-input/props.js');
require('../tag-input/hooks/use-tag-scroll.js');
require('../tag-input/hooks/use-tag-list.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../../hooks/use-vmodel.js');
require('../tag-input/hooks/use-hover.js');
require('../tag-input/hooks/use-drag-sorter.js');

var _SelectInput = VueCompositionAPI.defineComponent({
  name: "LSelectInput",
  props: {
    ...components_selectInput_props["default"],
    updateScrollTop: {
      type: Function
    }
  },
  setup(props2, context) {
    const selectInputRef = VueCompositionAPI.ref();
    const selectInputWrapRef = VueCompositionAPI.ref();
    const {
      classPrefix
    } = components_configProvider_useConfig.useConfig("classPrefix");
    const {
      multiple,
      value,
      popupVisible,
      borderless
    } = VueCompositionAPI.toRefs(props2);
    const {
      commonInputProps,
      onInnerClear,
      renderSelectSingle
    } = components_selectInput_hooks_useSingle["default"](props2, context);
    const {
      renderSelectMultiple
    } = components_selectInput_hooks_useMultiple["default"](props2, context);
    const {
      tOverlayInnerStyle,
      innerPopupVisible,
      onInnerPopupVisibleChange
    } = components_selectInput_hooks_useOverlayInnerstyle["default"](props2);
    const popupClasses = VueCompositionAPI.computed(() => [{
      [`${classPrefix.value}-select-input--borderless`]: borderless.value,
      [`${classPrefix.value}-select-input--multiple`]: multiple.value,
      [`${classPrefix.value}-select-input--popup-visible`]: popupVisible.value ?? innerPopupVisible.value,
      [`${classPrefix.value}-select-input--empty`]: Array.isArray(value.value) ? !value.value.length : !value.value
    }]);
    return {
      selectInputWrapRef,
      innerPopupVisible,
      commonInputProps,
      tOverlayInnerStyle,
      selectInputRef,
      popupClasses,
      onInnerClear,
      renderSelectSingle,
      renderSelectMultiple,
      onInnerPopupVisibleChange,
      classPrefix
    };
  },
  render(h) {
    var _this$popupProps;
    const visibleProps = {
      visible: this.popupVisible ?? this.innerPopupVisible
    };
    const mainContent = h(components_popup_index.Popup, helper.helper([{
      "ref": "selectInputRef",
      "class": this.popupClasses,
      "attrs": {
        "trigger": ((_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.trigger) || "click",
        "placement": "bottom-left",
        "visible": this.popupVisible ?? this.innerPopupVisible,
        "content": this.panel,
        "hideEmptyPopup": true,
        "disabled": this.disabled
      },
      "scopedSlots": {
        ...this.$scopedSlots,
        content: this.$scopedSlots.panel
      }
    }, {
      "on": {
        "visible-change": this.onInnerPopupVisibleChange
      }
    }, {}, {
      "props": {
        ...this.popupProps,
        overlayInnerStyle: this.tOverlayInnerStyle
      }
    }, {
      "attrs": {
        "updateScrollTop": this.updateScrollTop
      }
    }]), [this.multiple ? this.renderSelectMultiple({
      commonInputProps: this.commonInputProps,
      onInnerClear: this.onInnerClear,
      popupVisible: visibleProps.visible
    }, h) : this.renderSelectSingle(h, visibleProps.visible)]);
    if (!this.tips) return mainContent;
    return h("div", {
      "ref": "selectInputWrapRef",
      "class": `${this.classPrefix}-select-input__wrap`
    }, [mainContent, h("div", {
      "class": `${this.classPrefix}-input__tips ${this.classPrefix}-input__tips--${this.status || "normal"}`
    }, [this.tips])]);
  }
});

exports["default"] = _SelectInput;
//# sourceMappingURL=select-input.js.map
