"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var factory_1 = require("../factory");
var moment = require("moment");
var DateField = /** @class */ (function (_super) {
    tslib_1.__extends(DateField, _super);
    function DateField() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DateField.prototype.render = function () {
        var _a = this.props, className = _a.className, value = _a.value, valueFormat = _a.valueFormat, format = _a.format, placeholder = _a.placeholder, cx = _a.classnames;
        var viewValue = React.createElement("span", { className: "text-muted" }, placeholder);
        if (value) {
            var date = moment(value, valueFormat);
            viewValue = date.isValid() ? date.format(format) : React.createElement("span", { className: "text-danger" }, "\u65E5\u671F\u65E0\u6548");
        }
        return React.createElement("span", { className: cx('DateField', className) }, viewValue);
    };
    DateField.defaultProps = {
        placeholder: '-',
        format: 'YYYY-MM-DD',
        valueFormat: 'X',
    };
    return DateField;
}(React.Component));
exports.DateField = DateField;
var DateFieldRenderer = /** @class */ (function (_super) {
    tslib_1.__extends(DateFieldRenderer, _super);
    function DateFieldRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DateFieldRenderer.defaultProps = tslib_1.__assign({}, DateField.defaultProps, { format: 'YYYY-MM-DD' });
    DateFieldRenderer = tslib_1.__decorate([
        factory_1.Renderer({
            test: /(^|\/)date$/,
            name: 'date-field',
        })
    ], DateFieldRenderer);
    return DateFieldRenderer;
}(DateField));
exports.DateFieldRenderer = DateFieldRenderer;
var DateTimeFieldRenderer = /** @class */ (function (_super) {
    tslib_1.__extends(DateTimeFieldRenderer, _super);
    function DateTimeFieldRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DateTimeFieldRenderer.defaultProps = tslib_1.__assign({}, DateField.defaultProps, { format: 'YYYY-MM-DD HH:mm:ss' });
    DateTimeFieldRenderer = tslib_1.__decorate([
        factory_1.Renderer({
            test: /(^|\/)datetime$/,
            name: 'datetime-field',
        })
    ], DateTimeFieldRenderer);
    return DateTimeFieldRenderer;
}(DateField));
exports.DateTimeFieldRenderer = DateTimeFieldRenderer;
var TimeFieldRenderer = /** @class */ (function (_super) {
    tslib_1.__extends(TimeFieldRenderer, _super);
    function TimeFieldRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TimeFieldRenderer.defaultProps = tslib_1.__assign({}, DateField.defaultProps, { format: 'HH:mm' });
    TimeFieldRenderer = tslib_1.__decorate([
        factory_1.Renderer({
            test: /(^|\/)time$/,
            name: 'time-field',
        })
    ], TimeFieldRenderer);
    return TimeFieldRenderer;
}(DateField));
exports.TimeFieldRenderer = TimeFieldRenderer;
//# sourceMappingURL=./renderers/Date.js.map
