"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Button_1 = require("office-ui-fabric-react/lib/Button");
var TextField_1 = require("office-ui-fabric-react/lib/TextField");
var NumberTextField = /** @class */ (function (_super) {
    tslib_1.__extends(NumberTextField, _super);
    function NumberTextField(props) {
        var _this = _super.call(this, props) || this;
        _this._restore = _this._restore.bind(_this);
        _this._onChanged = _this._onChanged.bind(_this);
        _this._validateNumber = _this._validateNumber.bind(_this);
        _this.state = {
            value: props.initialValue
        };
        return _this;
    }
    NumberTextField.prototype.render = function () {
        return (React.createElement("div", { className: "NumberTextField" },
            React.createElement(TextField_1.TextField, { className: "NumberTextField-textField", label: this.props.label, value: this.state.value, onChanged: this._onChanged, onGetErrorMessage: this._validateNumber }),
            React.createElement("div", { className: "NumberTextField-restoreButton" },
                React.createElement(Button_1.DefaultButton, { onClick: this._restore }, "Restore"))));
    };
    NumberTextField.prototype._validateNumber = function (value) {
        return isNaN(Number(value)) ? "The value should be a number, actual is " + value + "." : '';
    };
    NumberTextField.prototype._onChanged = function (value) {
        return this.setState({
            value: value
        });
    };
    NumberTextField.prototype._restore = function () {
        this.setState({
            value: this.props.initialValue
        });
    };
    return NumberTextField;
}(React.Component));
exports.NumberTextField = NumberTextField;
//# sourceMappingURL=NumberTextField.js.map