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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import isFunction from 'lodash/isFunction';
import { CheckIcon, CloseIcon } from '@ldesign/icons-vue';
import mixins from '../../utils/mixins.js';
import getConfigReceiverMixins, { getGlobalIconMixins } from '../config-provider/config-receiver.js';
import { StepsItemProps } from './props.js';
import { renderLNodeJSX, renderContent } from '../../utils/render-node.js';
import 'vue';
import 'lodash/mergeWith';
import 'lodash';
import '../config-provider/context.js';
import '../../_chunks/dep-a0f2090c.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/camelCase';
import 'lodash/kebabCase';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _StepItem = mixins(getConfigReceiverMixins("steps"), getGlobalIconMixins()).extend({
  name: "LStepItem",
  props: _objectSpread(_objectSpread({}, StepsItemProps), {}, {
    index: Number
  }),
  inject: {
    steps: {
      "default": void 0
    }
  },
  computed: {
    current: function current() {
      return this.steps && this.steps.current;
    },
    baseClass: function baseClass() {
      return ["".concat(this.componentName, "-item"), _defineProperty({}, "".concat(this.componentName, "-item--").concat(this.status), this.status)];
    },
    iconClass: function iconClass() {
      return ["".concat(this.componentName, "-item__icon"), _defineProperty({}, "".concat(this.componentName, "-item--").concat(this.status), this.status)];
    },
    canClick: function canClick() {
      var _this$steps;

      return this.status !== "process" && !((_this$steps = this.steps) !== null && _this$steps !== void 0 && _this$steps.readonly);
    }
  },
  methods: {
    renderIcon: function renderIcon() {
      var h = this.$createElement;
      var defaultIcon;

      if (this.steps.theme === "default") {
        var icon = "";

        var _this$useGlobalIcon = this.useGlobalIcon({
          CheckIcon: CheckIcon,
          CloseIcon: CloseIcon
        }),
            CheckIcon$1 = _this$useGlobalIcon.CheckIcon,
            CloseIcon$1 = _this$useGlobalIcon.CloseIcon;

        switch (this.status) {
          case "finish":
            icon = h(CheckIcon$1);
            break;

          case "error":
            if (isFunction(this.global.errorIcon)) {
              icon = this.global.errorIcon(this.$createElement);
            } else {
              icon = h(CloseIcon$1);
            }

            break;

          default:
            icon = String(this.index + 1);
            break;
        }

        defaultIcon = h("span", {
          "class": "".concat(this.componentName, "-item__icon--number")
        }, [icon]);
      }

      return renderLNodeJSX(this, "icon", defaultIcon);
    },
    onStepClick: function onStepClick(e) {
      if (!this.canClick) return;
      var val = this.value === void 0 ? this.index : this.value;
      this.steps.handleChange(val, this.current, e);
    }
  },
  render: function render() {
    var h = arguments[0];
    var content = renderContent(this, "default", "content");
    return h("div", {
      "class": this.baseClass
    }, [h("div", {
      "class": "".concat(this.componentName, "-item__inner ").concat(this.canClick ? "".concat(this.componentName, "-item--clickable") : ""),
      "on": {
        "click": this.onStepClick
      }
    }, [h("div", {
      "class": this.iconClass
    }, [this.renderIcon()]), h("div", {
      "class": "".concat(this.componentName, "-item__content")
    }, [h("div", {
      "class": "".concat(this.componentName, "-item__title")
    }, [renderLNodeJSX(this, "title")]), h("div", {
      "class": "".concat(this.componentName, "-item__description")
    }, [content]), h("div", {
      "class": "".concat(this.componentName, "-item__extra")
    }, [renderLNodeJSX(this, "extra")])])])]);
  }
});

export { _StepItem as default };
//# sourceMappingURL=step-item.js.map
