UNPKG

@metacell/geppetto-meta-ui

Version:

React components from geppetto-meta to create neuroscience applications and visualize data.

51 lines 3.46 kB
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } import React from 'react'; var CanvasToolTip = /*#__PURE__*/React.forwardRef(function (props, ref) { var _intersected$o, _intersected$o2; var _React$useState = React.useState(null), _React$useState2 = _slicedToArray(_React$useState, 2), intersected = _React$useState2[0], setIntersected = _React$useState2[1]; var _React$useState3 = React.useState(false), _React$useState4 = _slicedToArray(_React$useState3, 2), tooltipVisible = _React$useState4[0], setTooltipVisible = _React$useState4[1]; React.useImperativeHandle(ref, function () { return { updateIntersected: function updateIntersected(updatedIntersection) { if (updatedIntersection) { setIntersected(updatedIntersection); setTooltipVisible(true); } else { setTooltipVisible(false); } } }; }); return /*#__PURE__*/React.createElement(React.Fragment, null, intersected && intersected.o && /*#__PURE__*/React.createElement("div", { id: "canvas-tooltip-".concat(intersected === null || intersected === void 0 || (_intersected$o = intersected.o) === null || _intersected$o === void 0 ? void 0 : _intersected$o.object.uuid), style: { position: 'fixed', left: intersected === null || intersected === void 0 ? void 0 : intersected.x, top: intersected === null || intersected === void 0 ? void 0 : intersected.y, zIndex: 9999, minWidth: '100px', textAlign: 'center', padding: '5px 12px', fontFamily: 'monospace', background: '#a0c020', display: tooltipVisible ? 'block' : 'none', opacity: '1', border: '1px solid black', boxShadow: '2px 2px 3px rgba(0, 0, 0, 0.5)', transition: 'opacity 0.25s linear', borderRadius: '3px' } }, intersected === null || intersected === void 0 || (_intersected$o2 = intersected.o) === null || _intersected$o2 === void 0 ? void 0 : _intersected$o2.object.uuid)); }); export default CanvasToolTip;