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

'use strict';

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

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

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

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
var Alert = /** @class */ (function (_super) {
    tslib.__extends(Alert, _super);
    function Alert(props) {
        var _this = _super.call(this, props) || this;
        _this.handleClick = _this.handleClick.bind(_this);
        _this.state = {
            show: true
        };
        return _this;
    }
    Alert.prototype.handleClick = function () {
        this.setState({
            show: false
        }, this.props.onClose);
    };
    Alert.prototype.render = function () {
        var _a = this.props, cx = _a.classnames, className = _a.className, style = _a.style, level = _a.level, children = _a.children, actions = _a.actions, showCloseButton = _a.showCloseButton, title = _a.title, icon = _a.icon, showIcon = _a.showIcon, iconClassName = _a.iconClassName, closeButtonClassName = _a.closeButtonClassName;
        // 优先使用内置svg，其次使用icon库
        var iconNode = showIcon ? (_J$X_(icons.Icon, { cx: cx, icon: icon || "alert-".concat(level), className: "icon" })) : null;
        return this.state.show ? (_J$X_("div", { className: cx('Alert', level ? "Alert--".concat(level) : '', title ? 'Alert-has-title' : '', className), style: style },
            showIcon && iconNode ? (_J$X_("div", { className: cx('Alert-icon', iconClassName) }, iconNode)) : null,
            _J$X_("div", { className: cx('Alert-content') },
                title ? _J$X_("div", { className: cx('Alert-title') }, title) : null,
                _J$X_("div", { className: cx('Alert-desc') }, children)),
            actions ? _J$X_("div", { className: cx('Alert-actions') }, actions) : null,
            showCloseButton ? (_J$X_("button", { className: cx('Alert-close', closeButtonClassName), onClick: this.handleClick, type: "button" },
                _J$X_(icons.Icon, { icon: "close", className: "icon" }))) : null)) : null;
    };
    Alert.defaultProps = {
        level: 'info',
        className: '',
        showCloseButton: false
    };
    Alert.propsList = [
        'level',
        'className',
        'showCloseButton',
        'onClose'
    ];
    return Alert;
}(React__default["default"].Component));
var Alert2 = amisCore.themeable(Alert);

exports.Alert = Alert;
exports["default"] = Alert2;
