'use strict';

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

var vue = require('vue');
require('../../../directives/index.js');
var index$1 = require('../../tooltip/index.js');
var index = require('../../tag/index.js');
var index$2 = require('../../icon/index.js');
var selectDropdown = require('./select-dropdown.js');
var useSelect = require('./useSelect.js');
var defaults = require('./defaults.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index$3 = require('../../../directives/click-outside/index.js');

const _sfc_main = vue.defineComponent({
  name: "PsSelectV2",
  components: {
    PsSelectMenu: selectDropdown["default"],
    PsTag: index.PsTag,
    PsTooltip: index$1.PsTooltip,
    PsIcon: index$2.PsIcon
  },
  directives: { ClickOutside: index$3["default"], ModelText: vue.vModelText },
  props: defaults.SelectProps,
  setup(props, { emit }) {
    const API = useSelect["default"](props, emit);
    return API;
  }
});
const _hoisted_1 = { key: 0 };
const _hoisted_2 = ["id", "autocomplete", "aria-expanded", "aria-labelledby", "disabled", "readonly", "name", "unselectable"];
const _hoisted_3 = ["textContent"];
const _hoisted_4 = ["id", "aria-labelledby", "aria-expanded", "autocomplete", "disabled", "name", "readonly", "unselectable"];
const _hoisted_5 = ["textContent"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  var _a;
  const _component_ps_tag = vue.resolveComponent("ps-tag");
  const _component_ps_icon = vue.resolveComponent("ps-icon");
  const _directive_model_text = vue.resolveDirective("model-text");
  const _directive_click_outside = vue.resolveDirective("click-outside");
  return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
    ref: "selectRef",
    class: vue.normalizeClass([_ctx.nsSelectV2.b(), _ctx.nsSelectV2.m(_ctx.selectSize)])
  }, [
    vue.createElementVNode("div", {
      ref: "selectionRef",
      class: vue.normalizeClass([
        _ctx.nsSelectV2.e("wrapper"),
        _ctx.nsSelectV2.is("focused", _ctx.states.isComposing),
        _ctx.nsSelectV2.is("hovering", _ctx.states.comboBoxHovering),
        _ctx.nsSelectV2.is("filterable", _ctx.filterable),
        _ctx.nsSelectV2.is("disabled", _ctx.selectDisabled)
      ])
    }, [
      _ctx.$slots.prefix ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.renderSlot(_ctx.$slots, "prefix")
      ])) : vue.createCommentVNode("v-if", true),
      _ctx.multiple ? (vue.openBlock(), vue.createElementBlock("div", {
        key: 1,
        class: vue.normalizeClass(_ctx.nsSelectV2.e("selection"))
      }, [
        _ctx.collapseTags && _ctx.modelValue.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", {
          key: 0,
          class: vue.normalizeClass(_ctx.nsSelectV2.e("selected-item"))
        }, [
          vue.createVNode(_component_ps_tag, {
            closable: !_ctx.selectDisabled && !((_a = _ctx.states.cachedOptions[0]) == null ? void 0 : _a.disable),
            size: _ctx.collapseTagSize,
            type: "info",
            "disable-transitions": ""
          }, {
            default: vue.withCtx(() => {
              var _a2;
              return [
                vue.createElementVNode("span", {
                  class: vue.normalizeClass(_ctx.nsSelectV2.e("tags-text")),
                  style: vue.normalizeStyle({
                    maxWidth: `${_ctx.tagMaxWidth}px`
                  })
                }, vue.toDisplayString((_a2 = _ctx.states.cachedOptions[0]) == null ? void 0 : _a2.label), 7)
              ];
            }),
            _: 1
          }, 8, ["closable", "size"]),
          _ctx.modelValue.length > 1 ? (vue.openBlock(), vue.createBlock(_component_ps_tag, {
            key: 0,
            closable: false,
            size: _ctx.collapseTagSize,
            type: "info",
            "disable-transitions": ""
          }, {
            default: vue.withCtx(() => [
              _ctx.collapseTagsTooltip ? (vue.openBlock(), vue.createElementBlock("span", {
                key: 0,
                class: vue.normalizeClass(_ctx.nsSelectV2.e("tags-text")),
                style: vue.normalizeStyle({
                  maxWidth: `${_ctx.tagMaxWidth}px`
                })
              }, "+ " + vue.toDisplayString(_ctx.modelValue.length - 1), 7)) : (vue.openBlock(), vue.createElementBlock("span", {
                key: 1,
                class: vue.normalizeClass(_ctx.nsSelectV2.e("tags-text")),
                style: vue.normalizeStyle({
                  maxWidth: `${_ctx.tagMaxWidth}px`
                })
              }, "+ " + vue.toDisplayString(_ctx.modelValue.length - 1), 7))
            ]),
            _: 1
          }, 8, ["size"])) : vue.createCommentVNode("v-if", true)
        ], 2)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(_ctx.states.cachedOptions, (selected, idx) => {
          return vue.openBlock(), vue.createElementBlock("div", {
            key: idx,
            class: vue.normalizeClass(_ctx.nsSelectV2.e("selected-item"))
          }, [
            (vue.openBlock(), vue.createBlock(_component_ps_tag, {
              key: _ctx.getValueKey(selected),
              closable: !_ctx.selectDisabled && !selected.disabled,
              size: _ctx.collapseTagSize,
              type: "info",
              "disable-transitions": ""
            }, {
              default: vue.withCtx(() => [
                vue.createElementVNode("span", {
                  class: vue.normalizeClass(_ctx.nsSelectV2.e("tags-text")),
                  style: vue.normalizeStyle({
                    maxWidth: `${_ctx.tagMaxWidth}px`
                  })
                }, vue.toDisplayString(_ctx.getLabel(selected)), 7)
              ]),
              _: 2
            }, 1032, ["closable", "size"]))
          ], 2);
        }), 128)),
        vue.createElementVNode("div", {
          class: vue.normalizeClass([
            _ctx.nsSelectV2.e("selected-item"),
            _ctx.nsSelectV2.e("input-wrapper")
          ]),
          style: vue.normalizeStyle(_ctx.inputWrapperStyle)
        }, [
          vue.withDirectives(vue.createElementVNode("input", {
            id: _ctx.id,
            ref: "inputRef",
            autocomplete: _ctx.autocomplete,
            "aria-autocomplete": "list",
            "aria-haspopup": "listbox",
            autocapitalize: "off",
            "aria-expanded": _ctx.expanded,
            "aria-labelledby": _ctx.label,
            class: vue.normalizeClass([
              _ctx.nsSelectV2.is(_ctx.selectSize),
              _ctx.nsSelectV2.e("combobox-input")
            ]),
            disabled: _ctx.disabled,
            role: "combobox",
            readonly: !_ctx.filterable,
            spellcheck: "false",
            type: "text",
            name: _ctx.name,
            unselectable: _ctx.expanded ? "on" : void 0
          }, null, 10, _hoisted_2), [
            [_directive_model_text, _ctx.states.displayInputValue]
          ]),
          _ctx.filterable ? (vue.openBlock(), vue.createElementBlock("span", {
            key: 0,
            ref: "calculatorRef",
            "aria-hidden": "true",
            class: vue.normalizeClass(_ctx.nsSelectV2.e("input-calculator")),
            textContent: vue.toDisplayString(_ctx.states.displayInputValue)
          }, null, 10, _hoisted_3)) : vue.createCommentVNode("v-if", true)
        ], 6)
      ], 2)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
        vue.createElementVNode("div", {
          class: vue.normalizeClass([
            _ctx.nsSelectV2.e("selected-item"),
            _ctx.nsSelectV2.e("input-wrapper")
          ])
        }, [
          vue.withDirectives(vue.createElementVNode("input", {
            id: _ctx.id,
            ref: "inputRef",
            "aria-autocomplete": "list",
            "aria-haspopup": "listbox",
            "aria-labelledby": _ctx.label,
            "aria-expanded": _ctx.expanded,
            autocapitalize: "off",
            autocomplete: _ctx.autocomplete,
            class: vue.normalizeClass(_ctx.nsSelectV2.e("combobox-input")),
            disabled: _ctx.disabled,
            name: _ctx.name,
            role: "combobox",
            readonly: !_ctx.filterable,
            spellcheck: "false",
            type: "text",
            unselectable: _ctx.expanded ? "on" : void 0
          }, null, 10, _hoisted_4), [
            [_directive_model_text, _ctx.states.displayInputValue]
          ])
        ], 2),
        _ctx.filterable ? (vue.openBlock(), vue.createElementBlock("span", {
          key: 0,
          ref: "calculatorRef",
          "aria-hidden": "true",
          class: vue.normalizeClass([
            _ctx.nsSelectV2.e("selected-item"),
            _ctx.nsSelectV2.e("input-calculator")
          ]),
          textContent: vue.toDisplayString(_ctx.states.displayInputValue)
        }, null, 10, _hoisted_5)) : vue.createCommentVNode("v-if", true)
      ], 64)),
      _ctx.shouldShowPlaceholder ? (vue.openBlock(), vue.createElementBlock("span", {
        key: 3,
        class: vue.normalizeClass([
          _ctx.nsSelectV2.e("placeholder"),
          _ctx.nsSelectV2.is("transparent", _ctx.states.isComposing || (_ctx.placeholder && _ctx.multiple ? _ctx.modelValue.length === 0 : !_ctx.hasModelValue))
        ])
      }, vue.toDisplayString(_ctx.currentPlaceholder), 3)) : vue.createCommentVNode("v-if", true),
      vue.createElementVNode("span", {
        class: vue.normalizeClass(_ctx.nsSelectV2.e("suffix"))
      }, [
        _ctx.iconComponent ? vue.withDirectives((vue.openBlock(), vue.createBlock(_component_ps_icon, {
          key: 0,
          class: vue.normalizeClass([_ctx.nsSelectV2.e("caret"), _ctx.nsInput.e("icon"), _ctx.iconReverse])
        }, {
          default: vue.withCtx(() => [
            (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.iconComponent)))
          ]),
          _: 1
        }, 8, ["class"])), [
          [vue.vShow, !_ctx.showClearBtn]
        ]) : vue.createCommentVNode("v-if", true),
        _ctx.showClearBtn && _ctx.clearIcon ? (vue.openBlock(), vue.createBlock(_component_ps_icon, {
          key: 1,
          class: vue.normalizeClass([_ctx.nsSelectV2.e("caret"), _ctx.nsInput.e("icon")])
        }, {
          default: vue.withCtx(() => [
            (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.clearIcon)))
          ]),
          _: 1
        }, 8, ["class"])) : vue.createCommentVNode("v-if", true),
        _ctx.validateState && _ctx.validateIcon ? (vue.openBlock(), vue.createBlock(_component_ps_icon, {
          key: 2,
          class: vue.normalizeClass([_ctx.nsInput.e("icon"), _ctx.nsInput.e("validateIcon")])
        }, {
          default: vue.withCtx(() => [
            (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.validateIcon)))
          ]),
          _: 1
        }, 8, ["class"])) : vue.createCommentVNode("v-if", true)
      ], 2)
    ], 2)
  ], 2)), [
    [_directive_click_outside, _ctx.handleClickOutside, _ctx.popperRef]
  ]);
}
var Select = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "/Users/meng/workspace/element-ps/packages/components/select-v2/src/select.vue"]]);

exports["default"] = Select;
//# sourceMappingURL=select.js.map
