'use strict';

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

var vue = require('vue');
require('../../../hooks/index.js');
var iconsVue = require('@element-plus/icons-vue');
var transfer = require('./transfer2.js');
require('./composables/index.js');
var transferLeftPlane = require('./transfer-left-plane.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-locale/index.js');
var index$1 = require('../../../hooks/use-namespace/index.js');
var useComputedData = require('./composables/use-computed-data.js');

const __default__ = vue.defineComponent({
  name: "ElUnidirectionalTransfer"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: transfer.UnidirectionalTransferProps,
  emits: transfer.UnidirectionalTransferEmits,
  setup(__props, { emit }) {
    const props = __props;
    const leftPanel = vue.ref();
    const { t } = index.useLocale();
    const ns = index$1.useNamespace("unidirectionalTransfer");
    const { targetData } = useComputedData.useComputedData();
    const onSourceCheckedChange = (checkedData) => {
      targetData.value = checkedData;
    };
    const removeChecked = (key) => {
      var _a;
      (_a = leftPanel.value) == null ? void 0 : _a.removeChecked(key);
    };
    const panelFilterPlaceholder = vue.computed(() => props.filterPlaceholder || t("el.transfer.filterPlaceholder"));
    const update = (key) => {
      emit("update:modelValue", key);
      emit("change", key);
    };
    vue.onMounted(() => {
      var _a;
      props.modelValue && leftPanel.value && ((_a = leftPanel.value) == null ? void 0 : _a.setChecked(props.modelValue));
    });
    vue.watch(() => props.modelValue, (keys) => {
      var _a;
      (_a = leftPanel.value) == null ? void 0 : _a.setChecked(keys);
    });
    return (_ctx, _cache) => {
      const _component_el_icon = vue.resolveComponent("el-icon");
      return vue.openBlock(), vue.createElementBlock("div", {
        class: vue.normalizeClass(vue.unref(ns).b())
      }, [
        vue.createVNode(transferLeftPlane["default"], {
          ref_key: "leftPanel",
          ref: leftPanel,
          data: props.data,
          placeholder: vue.unref(panelFilterPlaceholder),
          filterable: _ctx.filterable,
          "filter-method": _ctx.filterMethod,
          props: props.props,
          onCheckedChange: onSourceCheckedChange,
          onChange: update
        }, null, 8, ["data", "placeholder", "filterable", "filter-method", "props"]),
        vue.createElementVNode("div", {
          class: vue.normalizeClass(vue.unref(ns).b("panel"))
        }, [
          vue.createElementVNode("p", {
            class: vue.normalizeClass(vue.unref(ns).be("panel", "header"))
          }, [
            vue.renderSlot(_ctx.$slots, "searchContent", {
              length: vue.unref(targetData).length
            }, () => [
              vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(t)("el.transfer.hasChecked")) + "\uFF08" + vue.toDisplayString(vue.unref(targetData).length) + "\uFF09", 1)
            ])
          ], 2),
          vue.createElementVNode("div", {
            class: vue.normalizeClass(vue.unref(ns).be("panel", "body"))
          }, [
            vue.createElementVNode("div", {
              class: vue.normalizeClass(vue.unref(ns).be("panel", "container"))
            }, [
              (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(targetData), (item, index) => {
                return vue.openBlock(), vue.createElementBlock("div", {
                  key: index,
                  class: vue.normalizeClass(vue.unref(ns).be("panel", "list"))
                }, [
                  vue.createElementVNode("div", null, vue.toDisplayString(item[props.props.label]), 1),
                  vue.createVNode(_component_el_icon, {
                    size: "12",
                    onClick: ($event) => removeChecked(item[props.props.key])
                  }, {
                    default: vue.withCtx(() => [
                      vue.createVNode(vue.unref(iconsVue.Close))
                    ]),
                    _: 2
                  }, 1032, ["onClick"])
                ], 2);
              }), 128))
            ], 2)
          ], 2)
        ], 2)
      ], 2);
    };
  }
});
var Transfer = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/Users/judai/code/d-element-plus/packages/components/unidirectionalTransfer/src/transfer.vue"]]);

exports["default"] = Transfer;
//# sourceMappingURL=transfer.js.map
