<template>
  <view :class="stepsClass" :style="stepsStyle">
    <view
      v-for="(item, i) in itemList"
      :key="i"
      :class="
        classNames(
          bem.e('step'),
          bem.em('step', item.status ?? getStatus(current, i)),
          bem.em('step', getPosition(current, i)),
        )
      "
    >
      <view :class="bem.e('header')">
        <view :class="classNames(bem.e('line'), bem.e('line-before'))"></view>
        <view :class="bem.e('icon')">
          <sar-icon
            :name="getStatusIcon(item.status ?? getStatus(current, i))"
            :size="iconSize"
            :family="iconFamily"
          />
        </view>
        <view :class="classNames(bem.e('line'), bem.e('line-after'))"></view>
      </view>
      <view :class="bem.e('body')">
        <view :class="bem.e('name')">{{ item.name }}</view>
        <view v-if="item.description" :class="bem.e('description')">
          {{ item.description }}
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed } from "vue";
import { classNames, stringifyStyle, createBem } from "../utils";
import SarIcon from "../icon/icon.vue";
import { stepsProps } from "./common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "steps",
  props: stepsProps,
  setup(__props, { expose: __expose }) {
    __expose();
    const props = __props;
    const getStatus = (current, index) => {
      return index < current ? "finish" : index === current ? props.status ?? "process" : "wait";
    };
    const getStatusIcon = (status) => {
      return {
        finish: props.finishIcon,
        process: props.processIcon,
        wait: props.waitIcon,
        error: props.errorIcon
      }[status];
    };
    const getPosition = (current, index) => {
      return index < current ? "behind" : current === index ? "self" : "front";
    };
    const bem = createBem("steps");
    const stepsClass = computed(() => {
      return classNames(
        bem.b(),
        bem.m(props.direction),
        bem.m("center", props.center),
        props.rootClass
      );
    });
    const stepsStyle = computed(() => {
      return stringifyStyle(props.rootStyle);
    });
    const __returned__ = { props, getStatus, getStatusIcon, getPosition, bem, stepsClass, stepsStyle, get classNames() {
      return classNames;
    }, SarIcon };
    return __returned__;
  }
});
</script>

<style lang="scss">
@use './index.scss';
</style>