office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
44 lines (42 loc) • 2 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var SpinButton_1 = require("office-ui-fabric-react/lib/SpinButton");
var SpinButtonStatefulExample = (function (_super) {
tslib_1.__extends(SpinButtonStatefulExample, _super);
function SpinButtonStatefulExample() {
return _super !== null && _super.apply(this, arguments) || this;
}
SpinButtonStatefulExample.prototype.render = function () {
var _this = this;
var suffix = ' cm';
return (React.createElement("div", { style: { width: '203px' } },
React.createElement(SpinButton_1.SpinButton, { label: 'SpinButton with custom implementation:', value: '7' + suffix, onValidate: function (value) {
value = _this.removeSuffix(value, suffix);
if (isNaN(+value)) {
return '0' + suffix;
}
return String(value) + suffix;
}, onIncrement: function (value) {
value = _this.removeSuffix(value, suffix);
return String(+value + 2) + suffix;
}, onDecrement: function (value) {
value = _this.removeSuffix(value, suffix);
return String(+value - 2) + suffix;
} })));
};
SpinButtonStatefulExample.prototype.hasSuffix = function (string, suffix) {
var subString = string.substr(string.length - suffix.length);
return subString === suffix;
};
SpinButtonStatefulExample.prototype.removeSuffix = function (string, suffix) {
if (!this.hasSuffix(string, suffix)) {
return string;
}
return string.substr(0, string.length - suffix.length);
};
return SpinButtonStatefulExample;
}(React.Component));
exports.SpinButtonStatefulExample = SpinButtonStatefulExample;
//# sourceMappingURL=SpinButton.Stateful.Example.js.map
;