var Drop; export default window.Drop = Drop = class Drop extends React.Component { constructor(props) { super(props); this.state = { open: false, right: props.right != null ? props.right : props.right = false, title: props.title != null ? props.title : props.title = null, content: props.content != null ? props.content : props.content = null, bodyAddClass: props.bodyAddClass != null ? props.bodyAddClass : props.bodyAddClass = '' }; this.open = this.open.bind(this); this.toggle = this.toggle.bind(this); this.wrap = null; this.$wrap = null; } componentDidMount() { return document.addEventListener('click', this.handleOuterClick.bind(this)); } componentWillUnmount() { return document.removeEventListener('click', this.handleOuterClick.bind(this)); } handleOuterClick(e) { if (this.$wrap.has(e.target).length === 0 && $(document).has(e.target).length === 1) { return this.close(); } } close() { return this.setState({ open: false }); } aOpen(x) { return this.setState({ content: x }); } open() { var t; t = this; return this.setState({ open: true }, function () { var base; return typeof (base = t.props).onOpen === "function" ? base.onOpen(t.aOpen.bind(t)) : void 0; }); } toggle() { if (this.state.open) { return this.close(); } else { return this.open(); } } refWrap(i) { this.wrap = i; return this.$wrap = $(this.wrap); } render() { var isOpen, isRight; isOpen = this.state.open === true; isRight = this.state.right === true; return /*#__PURE__*/React.createElement("div", { className: ["drop", isOpen ? 'open' : ''].join(" "), ref: this.refWrap.bind(this) }, /*#__PURE__*/React.createElement("div", { className: "drop_title", onClick: this.toggle }, this.state.title), /*#__PURE__*/React.createElement("div", { className: ["drop_content", this.state.bodyAddClass, isRight ? 'd-right' : ''].join(" ") }, this.state.content)); } }; window.Drop = Drop; //# sourceMappingURL=drop.js.map