/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import isFunction from 'lodash/isFunction';
import { CheckIcon, CloseIcon } from 'tdesign-icons-vue';
import mixins from '../utils/mixins.js';
import getConfigReceiverMixins from '../config-provider/config-receiver.js';
import { prefix } from '../config.js';
import props from './step-item-props.js';
import { renderTNodeJSX, renderContent } from '../utils/render-tnode.js';
import 'vue';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../config-provider/type.js';
import '@babel/runtime/helpers/typeof';

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 name = "".concat(prefix, "-steps-item");
var _StepItem = mixins(getConfigReceiverMixins("steps")).extend({
  name: "TStepItem",
  props: _objectSpread(_objectSpread({}, props), {}, {
    index: Number
  }),
  components: {
    CheckIcon: CheckIcon,
    CloseIcon: CloseIcon
  },
  inject: {
    steps: {
      "default": void 0
    }
  },
  computed: {
    current: function current() {
      return this.steps && this.steps.current;
    },
    baseClass: function baseClass() {
      return [name, _defineProperty({}, "".concat(name, "--").concat(this.status), this.status)];
    },
    iconClass: function iconClass() {
      return ["".concat(name, "__icon"), _defineProperty({}, "".concat(name, "--").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 = "";

        switch (this.status) {
          case "finish":
            icon = h("check-icon");
            break;

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

            break;

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

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

      return renderTNodeJSX(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(name, "__inner ").concat(this.canClick ? "".concat(name, "--clickable") : ""),
      "on": {
        "click": this.onStepClick
      }
    }, [h("div", {
      "class": this.iconClass
    }, [this.renderIcon()]), h("div", {
      "class": "".concat(name, "__content")
    }, [h("div", {
      "class": "".concat(name, "__title")
    }, [renderTNodeJSX(this, "title")]), h("div", {
      "class": "".concat(name, "__description")
    }, [content]), h("div", {
      "class": "".concat(name, "__extra")
    }, [renderTNodeJSX(this, "extra")])])])]);
  }
});

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