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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var omit = require('lodash/omit');
var components_selectInput_index = require('../select-input/index.js');
var components_common_fakeArrow = require('../common/fake-arrow.js');
var hooks_useConfig = require('../../hooks/use-config.js');
var hooks_useFormDisabled = require('../../hooks/use-form-disabled.js');
var components_cascader_props = require('./props.js');
var components_cascader_hooks_index = require('./hooks/index.js');
var components_cascader_components_Panel = require('./components/Panel.js');
var components_cascader_utils_effect = require('./utils/effect.js');
var components_cascader_utils_helper = require('./utils/helper.js');
var components_cascader_utils_className = require('./utils/className.js');
var components_configProvider_useConfig = require('../config-provider/useConfig.js');
require('../../utils/with-install.js');
require('vue');
require('lodash');
require('../../config.js');
require('../select-input/select-input.js');
require('../../chunks/helper.js');
require('../popup/index.js');
require('../../utils/map-props.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('../select-input/props.js');
require('../select-input/hooks/use-single.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-default-value.js');
require('../select-input/hooks/use-multiple.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');
require('../select-input/hooks/use-overlay-innerstyle.js');
require('lodash/isEqual');
require('../../chunks/tree-store.js');
require('../../chunks/get-5e1abd10.js');
require('../../chunks/isArray-cd7357b9.js');
require('../../chunks/isSymbol-a38a5184.js');
require('../../chunks/isObjectLike-c22c7e3b.js');
require('../../chunks/isFunction-91acade7.js');
require('../../chunks/tree-node.js');
require('../../chunks/_isIndex-52887d1e.js');
require('./components/Item.js');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('lodash/intersection');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../../utils/ripple.js');
require('lodash/isNumber');
require('lodash/cloneDeep');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);

var _Cascader = VueCompositionAPI.defineComponent({
  name: "LCascader",
  components: {
    LFakeArrow: components_common_fakeArrow["default"]
  },
  props: {
    ...components_cascader_props["default"]
  },
  setup(props2, _ref) {
    let {
      slots,
      emit
    } = _ref;
    const COMPONENT_NAME = hooks_useConfig.usePrefixClass("cascader");
    const classPrefix = hooks_useConfig.usePrefixClass();
    const {
      STATUS
    } = hooks_useConfig.useCommonClassName();
    const overlayClassName = hooks_useConfig.usePrefixClass("cascader__popup");
    const {
      global
    } = components_configProvider_useConfig.useConfig("cascader");
    const {
      cascaderContext,
      isFilterable
    } = components_cascader_hooks_index.useCascaderContext(props2);
    const displayValue = VueCompositionAPI.computed(() => props2.multiple ? components_cascader_utils_helper.getMultipleContent(cascaderContext.value) : components_cascader_utils_helper.getSingleContent(cascaderContext.value));
    const panels = VueCompositionAPI.computed(() => components_cascader_utils_helper.getPanels(cascaderContext.value.treeNodes));
    const inputPlaceholder = VueCompositionAPI.computed(() => cascaderContext.value.visible && !props2.multiple && components_cascader_utils_helper.getSingleContent(cascaderContext.value) || (props2.placeholder ?? global.value.placeholder));
    const {
      formDisabled
    } = hooks_useFormDisabled["default"]();
    const isDisabled = VueCompositionAPI.computed(() => formDisabled.value || cascaderContext.value.disabled);
    return {
      COMPONENT_NAME,
      overlayClassName,
      panels,
      displayValue,
      inputPlaceholder,
      isFilterable,
      isDisabled,
      STATUS,
      classPrefix,
      cascaderContext,
      slots,
      emit
    };
  },
  render() {
    var _this$popupProps;
    const h = arguments[0];
    const {
      COMPONENT_NAME,
      overlayClassName,
      panels,
      displayValue,
      inputPlaceholder,
      isFilterable,
      isDisabled,
      STATUS,
      classPrefix,
      cascaderContext,
      slots,
      emit
    } = this;
    const renderSuffixIcon = () => {
      const {
        visible: visible2
      } = cascaderContext;
      return h("l-fake-arrow", {
        "attrs": {
          "overlayClassName": components_cascader_utils_className.getFakeArrowIconClass(classPrefix, STATUS, cascaderContext),
          "isActive": visible2,
          "disabled": isDisabled
        }
      });
    };
    const {
      setVisible,
      visible,
      inputVal,
      setInputVal
    } = cascaderContext;
    return h(components_selectInput_index.SelectInput, {
      "class": COMPONENT_NAME,
      "props": {
        ...{
          value: displayValue,
          inputValue: visible ? inputVal : "",
          popupVisible: visible,
          keys: this.keys,
          allowInput: isFilterable,
          minCollapsedNum: this.minCollapsedNum,
          collapsedItems: this.collapsedItems,
          readonly: this.readonly,
          disabled: isDisabled,
          clearable: this.clearable,
          placeholder: inputPlaceholder,
          multiple: this.multiple,
          loading: this.loading,
          status: this.status,
          tips: this.tips,
          suffixIcon: () => renderSuffixIcon(),
          popupProps: {
            ...this.popupProps,
            overlayInnerStyle: panels.length && !this.loading ? {
              width: "auto"
            } : "",
            overlayClassName: [overlayClassName, (_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.overlayClassName]
          },
          inputProps: {
            size: this.size,
            ...this.inputProps
          },
          tagInputProps: {
            size: this.size,
            ...this.tagInputProps
          },
          tagProps: {
            ...this.tagProps
          },
          onInputChange: (value, ctx) => {
            var _this$selectInputProp, _this$selectInputProp2;
            if (!this.isFilterable) return;
            setInputVal(`${value}`);
            this === null || this === void 0 ? void 0 : (_this$selectInputProp = this.selectInputProps) === null || _this$selectInputProp === void 0 ? void 0 : (_this$selectInputProp2 = _this$selectInputProp.onInputChange) === null || _this$selectInputProp2 === void 0 ? void 0 : _this$selectInputProp2.call(_this$selectInputProp, value, ctx);
          },
          onTagChange: (val, ctx) => {
            var _this$selectInputProp3, _this$selectInputProp4;
            if (ctx.trigger === "enter") return;
            components_cascader_utils_effect.handleRemoveTagEffect(cascaderContext, ctx.index, this.onRemove);
            this === null || this === void 0 ? void 0 : (_this$selectInputProp3 = this.selectInputProps) === null || _this$selectInputProp3 === void 0 ? void 0 : (_this$selectInputProp4 = _this$selectInputProp3.onTagChange) === null || _this$selectInputProp4 === void 0 ? void 0 : _this$selectInputProp4.call(_this$selectInputProp3, val, ctx);
          },
          onPopupVisibleChange: (val, context) => {
            var _this$selectInputProp5, _this$selectInputProp6;
            if (this.disabled) return;
            setVisible(val, context);
            this === null || this === void 0 ? void 0 : (_this$selectInputProp5 = this.selectInputProps) === null || _this$selectInputProp5 === void 0 ? void 0 : (_this$selectInputProp6 = _this$selectInputProp5.onPopupVisibleChange) === null || _this$selectInputProp6 === void 0 ? void 0 : _this$selectInputProp6.call(_this$selectInputProp5, val, context);
          },
          onBlur: (val, context) => {
            var _this$onBlur, _this$selectInputProp7, _this$selectInputProp8;
            const ctx = {
              value: cascaderContext.value,
              e: context.e
            };
            (_this$onBlur = this.onBlur) === null || _this$onBlur === void 0 ? void 0 : _this$onBlur.call(this, ctx);
            emit("blur", ctx);
            this === null || this === void 0 ? void 0 : (_this$selectInputProp7 = this.selectInputProps) === null || _this$selectInputProp7 === void 0 ? void 0 : (_this$selectInputProp8 = _this$selectInputProp7.onBlur) === null || _this$selectInputProp8 === void 0 ? void 0 : _this$selectInputProp8.call(_this$selectInputProp7, val, context);
          },
          onFocus: (val, context) => {
            var _this$onFocus, _this$selectInputProp9, _this$selectInputProp10;
            const ctx = {
              value: cascaderContext.value,
              e: context.e
            };
            (_this$onFocus = this.onFocus) === null || _this$onFocus === void 0 ? void 0 : _this$onFocus.call(this, ctx);
            emit("focus", ctx);
            this === null || this === void 0 ? void 0 : (_this$selectInputProp9 = this.selectInputProps) === null || _this$selectInputProp9 === void 0 ? void 0 : (_this$selectInputProp10 = _this$selectInputProp9.onFocus) === null || _this$selectInputProp10 === void 0 ? void 0 : _this$selectInputProp10.call(_this$selectInputProp9, val, context);
          },
          onClear: context => {
            var _this$selectInputProp11, _this$selectInputProp12;
            components_cascader_utils_effect.closeIconClickEffect(cascaderContext);
            this === null || this === void 0 ? void 0 : (_this$selectInputProp11 = this.selectInputProps) === null || _this$selectInputProp11 === void 0 ? void 0 : (_this$selectInputProp12 = _this$selectInputProp11.onClear) === null || _this$selectInputProp12 === void 0 ? void 0 : _this$selectInputProp12.call(_this$selectInputProp11, context);
          },
          ...omit__default["default"](this.selectInputProps, ["onTagChange", "onInputChange", "onPopupVisibleChange", "onBlur", "onFocus", "onClear"])
        }
      },
      "scopedSlots": {
        panel: () => h(components_cascader_components_Panel["default"], {
          "attrs": {
            "empty": this.empty,
            "trigger": this.trigger,
            "loading": this.loading,
            "loadingText": this.loadingText,
            "cascaderContext": cascaderContext
          },
          "scopedSlots": {
            empty: slots.empty,
            loadingText: slots.loadingText
          }
        }),
        collapsedItems: slots.collapsedItems
      }
    });
  }
});

exports["default"] = _Cascader;
//# sourceMappingURL=cascader.js.map
