UNPKG

@risecx/carespace-chat-ui

Version:

carespace-chat-ui React component

75 lines (55 loc) 3.54 kB
"use strict"; exports.__esModule = true; exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var PopupWindow = /*#__PURE__*/function (_Component) { _inheritsLoose(PopupWindow, _Component); function PopupWindow() { var _this; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _Component.call.apply(_Component, [this].concat(args)) || this; _defineProperty(_assertThisInitialized(_this), "interceptLauncherClick", function (e) { var isOpen = _this.props.isOpen; var clickedOutside = !_this.emojiPopup.contains(e.target) && isOpen; clickedOutside && _this.props.onClickedOutside(e); }); return _this; } var _proto = PopupWindow.prototype; _proto.componentDidMount = function componentDidMount() { this.scLauncher = document.querySelector('#sc-launcher'); this.scLauncher.addEventListener('click', this.interceptLauncherClick); }; _proto.componentWillUnmount = function componentWillUnmount() { this.scLauncher.removeEventListener('click', this.interceptLauncherClick); }; _proto.render = function render() { var _this2 = this; var _this$props = this.props, isOpen = _this$props.isOpen, children = _this$props.children; return /*#__PURE__*/_react["default"].createElement("div", { className: "sc-popup-window", ref: function ref(e) { return _this2.emojiPopup = e; } }, /*#__PURE__*/_react["default"].createElement("div", { className: "sc-popup-window--cointainer " + (isOpen ? '' : 'closed') }, /*#__PURE__*/_react["default"].createElement("input", { onChange: this.props.onInputChange, className: "sc-popup-window--search", placeholder: "Search emoji..." }), children)); }; return PopupWindow; }(_react.Component); var _default = PopupWindow; exports["default"] = _default; module.exports = exports.default;