react-life-design
Version:
Life Design UI components
40 lines • 1.83 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var AccordionWrapper_1 = require("./AccordionWrapper");
var Accordion = (function (_super) {
__extends(Accordion, _super);
function Accordion() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = {
active: false,
activeIndex: null,
};
_this.toggle = function (e, index) {
_this.setState(({ active: e, activeIndex: index }));
if (e && _this.props.automatic && _this.state.activeIndex === index) {
_this.setState({ activeIndex: null });
}
};
_this.render = function () {
return _this.props.items.map(function (item, index) { return (React.createElement(AccordionWrapper_1.default, { active: index, activeIndex: _this.state.activeIndex, key: index, click: function (e) { return _this.toggle(e, index); }, header: item.header, content: item.content, labels: item.labels, automatic: _this.props.automatic })); });
};
return _this;
}
return Accordion;
}(React.PureComponent));
exports.default = Accordion;
//# sourceMappingURL=Accordion.js.map
;