/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

'use strict';

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

require('react');
var amisCore = require('amis-core');
var icons = require('./icons.js');

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
exports.StepStatus = void 0;
(function (StepStatus) {
    StepStatus["wait"] = "wait";
    StepStatus["process"] = "process";
    StepStatus["finish"] = "finish";
    StepStatus["error"] = "error";
})(exports.StepStatus || (exports.StepStatus = {}));
function Steps(props) {
    var stepsRow = props.steps, cx = props.classnames, className = props.className, style = props.style, current = props.current, status = props.status, _a = props.mode, mode = _a === void 0 ? 'horizontal' : _a, _b = props.labelPlacement, labelPlacement = _b === void 0 ? 'horizontal' : _b, _c = props.progressDot, progressDot = _c === void 0 ? false : _c, iconPosition = props.iconPosition, mobileUI = props.mobileUI, iconClassName = props.iconClassName, subTitleClassName = props.subTitleClassName, titleClassName = props.titleClassName, descriptionClassName = props.descriptionClassName, onClickStep = props.onClickStep;
    var FINISH_ICON = 'check';
    var ERROR_ICON = 'close';
    function getStepStatus(step, i) {
        var stepStatus = exports.StepStatus.wait;
        var icon = step.icon;
        if (i < current) {
            stepStatus = exports.StepStatus.finish;
            !icon && (icon = FINISH_ICON);
        }
        else if (i === current) {
            stepStatus = exports.StepStatus.process;
        }
        if (typeof status === 'string') {
            if (i === current) {
                stepStatus = step.status || status || exports.StepStatus.process;
                stepStatus === exports.StepStatus.error && !icon && (icon = ERROR_ICON);
            }
        }
        else if (typeof status === 'object') {
            var key = step.value;
            key && status[key] && (stepStatus = status[key]);
        }
        return {
            stepStatus: stepStatus,
            icon: icon
        };
    }
    return (_J$X_("ul", { className: cx(
        // 纵向步骤条暂时不支持labelPlacement属性
        'Steps', "Steps--Placement-".concat(progressDot || (labelPlacement === 'vertical' && mode != 'vertical')
            ? 'vertical'
            : ''), "Steps--".concat(progressDot ? 'ProgressDot' : ''), "Steps--".concat(mode), mobileUI ? 'Steps-mobile' : '', className), style: style }, stepsRow.map(function (step, i) {
        var _a = getStepStatus(step, i), stepStatus = _a.stepStatus, icon = _a.icon;
        return (_J$X_("li", { key: i, className: cx('StepsItem', "is-".concat(stepStatus), step.className, "".concat(progressDot ? 'StepsItem-ProgressDot' : ''), "".concat(onClickStep && stepStatus === exports.StepStatus.finish
                ? 'is-clickable'
                : '')) },
            _J$X_("div", { className: cx('StepsItem-container', iconPosition && mode != 'vertical' && 'StepsItem-vertical') },
                _J$X_("div", { className: cx('StepsItem-containerTail') }),
                progressDot ? (_J$X_("div", { className: cx('StepsItem-containerProgressDot'), onClick: function () { return onClickStep && onClickStep(i, step); } })) : (_J$X_("div", { className: cx('StepsItem-containerIcon', i < current && 'is-success'), onClick: function () { return onClickStep && onClickStep(i, step); } },
                    _J$X_("span", { className: cx('StepsItem-icon', iconClassName, step.iconClassName) }, icon ? _J$X_(icons.Icon, { icon: icon, className: "icon" }) : i + 1))),
                _J$X_("div", { className: cx('StepsItem-containerWrapper'), onClick: function () { return onClickStep && onClickStep(i, step); } },
                    _J$X_("div", { className: cx('StepsItem-body') },
                        _J$X_("div", { className: cx('StepsItem-title', "StepsItem-".concat(progressDot ? 'vertical-ProgressDot' : ''), i < current && 'is-success') },
                            _J$X_("span", { className: cx('StepsItem-ellText', titleClassName), title: typeof step.title === 'string' ? step.title : undefined }, step.title),
                            step.subTitle && (_J$X_("span", { className: cx('StepsItem-subTitle', 'StepsItem-ellText', subTitleClassName), title: typeof step.subTitle === 'string'
                                    ? step.subTitle
                                    : undefined }, step.subTitle))),
                        _J$X_("div", { className: cx('StepsItem-description', 'StepsItem-ellText'), title: typeof step.description === 'string'
                                ? step.description
                                : undefined },
                            _J$X_("span", { className: cx(descriptionClassName) }, step.description))),
                    mode === 'simple' && i < stepsRow.length - 1 && (_J$X_("div", { className: cx('StepsItem-icon-line') },
                        _J$X_(icons.Icon, { icon: "right-arrow", className: "icon", iconContent: "StepsItem-icon-line" })))))));
    })));
}
var Steps$1 = amisCore.themeable(Steps);

exports.Steps = Steps;
exports["default"] = Steps$1;
