/**
 * ldesign v0.2.3
 * (c) 2022年9月24日 swimly
 * @license MIT
 */

import { h as helper } from '../../_chunks/dep-9cf53923.js';
import { defineComponent, ref, toRefs, computed } from '@vue/composition-api';
import { Popup } from '../popup/index.js';
import props from './props.js';
import useSingle from './hooks/use-single.js';
import useMultiple from './hooks/use-multiple.js';
import useOverlayInnerStyle from './hooks/use-overlay-innerstyle.js';
import { useConfig } from '../config-provider/useConfig.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../_chunks/dep-1aed710a.js';
import '../../utils/dom.js';
import 'vue';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../utils/helper.js';
import '../popup/props.js';
import '../popup/container.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../_chunks/dep-b1584b65.js';
import '../../utils/mixins.js';
import '../../utils/map-props.js';
import '../../utils/with-install.js';
import '../../config.js';
import 'lodash/isObject';
import 'lodash/pick';
import '../../hooks/lnode.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import '../../hooks/render-lnode.js';
import '../../hooks/use-config.js';
import '../../hooks/use-default-value.js';

var _SelectInput = defineComponent({
  name: "LSelectInput",
  components: {
    LPopup: Popup
  },
  props: { ...props,
    updateScrollTop: {
      type: Function
    }
  },

  setup(props2, context) {
    const selectInputRef = ref();
    const selectInputWrapRef = ref();
    const {
      classPrefix
    } = useConfig("classPrefix");
    const {
      multiple,
      value,
      popupVisible,
      borderless
    } = toRefs(props2);
    const {
      commonInputProps,
      onInnerClear,
      renderSelectSingle
    } = useSingle(props2, context);
    const {
      renderSelectMultiple
    } = useMultiple(props2, context);
    const {
      tOverlayInnerStyle,
      innerPopupVisible,
      onInnerPopupVisibleChange
    } = useOverlayInnerStyle(props2);
    const popupClasses = 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`]: value.value instanceof Array ? !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("l-popup", 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])]);
  }

});

export { _SelectInput as default };
//# sourceMappingURL=select-input.js.map
