/**
 * 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 isObject = require('lodash/isObject');
var iconsVue = require('@ldesign/icons-vue');
var hooks_useConfig = require('../../hooks/use-config.js');
var hooks_useGlobalIcon = require('../../hooks/use-global-icon.js');
var components_button_index = require('../button/index.js');
var components_jumper_props = require('./props.js');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('lodash');
require('../../chunks/zh_CN.js');
require('../../utils/with-install.js');
require('vue');
require('../../config.js');
require('../button/button.js');
require('../loading/index.js');
require('../loading/loading.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/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../utils/mixins.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');
require('../loading/plugin.js');
require('../../utils/ripple.js');
require('../button/props.js');

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

var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);

const defaultTipsConfig = {
  prev: "\u4E0A\u4E00\u9875",
  current: "\u5F53\u524D",
  next: "\u4E0B\u4E00\u9875"
};
var _Jumper = VueCompositionAPI.defineComponent({
  name: "LJumper",
  components: {
    LButton: components_button_index.Button
  },
  props: {
    ...components_jumper_props["default"]
  },
  setup(props2, _ref) {
    let {
      emit
    } = _ref;
    const COMPONENT_NAME = hooks_useConfig.usePrefixClass("jumper");
    const {
      ChevronLeftIcon,
      RoundIcon,
      ChevronRightIcon,
      ChevronUpIcon,
      ChevronDownIcon
    } = hooks_useGlobalIcon.useGlobalIcon({
      ChevronLeftIcon: iconsVue.ChevronLeftIcon,
      RoundIcon: iconsVue.RoundIcon,
      ChevronRightIcon: iconsVue.ChevronRightIcon,
      ChevronUpIcon: iconsVue.ChevronUpIcon,
      ChevronDownIcon: iconsVue.ChevronDownIcon
    });
    const titleConfig = VueCompositionAPI.computed(() => {
      if (isObject__default["default"](props2.tips)) return props2.tips;
      if (props2.tips === true) return defaultTipsConfig;
      return {};
    });
    const disabledConfig = VueCompositionAPI.computed(() => {
      if (isObject__default["default"](props2.disabled)) return props2.disabled;
      if (props2.disabled === true) return {
        prev: true,
        current: true,
        next: true
      };
      return {
        prev: false,
        current: false,
        next: false
      };
    });
    function handleChange(context) {
      var _props2$onChange;
      emit("change", context);
      (_props2$onChange = props2.onChange) === null || _props2$onChange === void 0 ? void 0 : _props2$onChange.call(props2, context);
    }
    return {
      COMPONENT_NAME,
      ChevronLeftIcon,
      RoundIcon,
      ChevronRightIcon,
      ChevronUpIcon,
      ChevronDownIcon,
      titleConfig,
      disabledConfig,
      handleChange
    };
  },
  render() {
    const h = arguments[0];
    const {
      COMPONENT_NAME,
      ChevronLeftIcon,
      RoundIcon,
      ChevronRightIcon,
      ChevronUpIcon,
      ChevronDownIcon,
      titleConfig,
      disabledConfig,
      handleChange
    } = this;
    const classes = [COMPONENT_NAME, {
      [`${COMPONENT_NAME}--outline`]: this.variant === "outline"
    }];
    return h("div", {
      "class": classes
    }, [h("l-button", {
      "attrs": {
        "title": titleConfig.prev,
        "variant": this.variant,
        "size": this.size,
        "shape": "square",
        "icon": this.layout === "horizontal" ? () => h(ChevronLeftIcon) : () => h(ChevronUpIcon),
        "disabled": disabledConfig.prev
      },
      "on": {
        "click": e => handleChange({
          e,
          trigger: "prev"
        })
      },
      "class": `${COMPONENT_NAME}__prev`
    }), this.showCurrent && h("l-button", {
      "attrs": {
        "title": titleConfig.current,
        "variant": this.variant,
        "size": this.size,
        "shape": "square",
        "icon": () => h(RoundIcon),
        "disabled": disabledConfig.current
      },
      "on": {
        "click": e => handleChange({
          e,
          trigger: "current"
        })
      },
      "class": `${COMPONENT_NAME}__current`
    }), h("l-button", {
      "attrs": {
        "title": titleConfig.next,
        "variant": this.variant,
        "size": this.size,
        "shape": "square",
        "icon": this.layout === "horizontal" ? () => h(ChevronRightIcon) : () => h(ChevronDownIcon),
        "disabled": disabledConfig.next
      },
      "on": {
        "click": e => handleChange({
          e,
          trigger: "next"
        })
      },
      "class": `${COMPONENT_NAME}__next`
    })]);
  }
});

exports["default"] = _Jumper;
//# sourceMappingURL=jumper.js.map
