From 8cdbe130613e80e8291f1ceb25d32fceb46d15e3 Mon Sep 17 00:00:00 2001 From: slmgc Date: Sat, 12 May 2018 23:16:53 -0700 Subject: [PATCH] #25: Add support for tooltip autopositioning --- README.md | 3 ++- demo/src/index.js | 2 +- lib/index.js | 45 +++++++++++++++++++++++++++++++ src/index.js | 56 +++++++++++++++++++++++++++++++++++++-- umd/react-hint.js | 47 +++++++++++++++++++++++++++++++- umd/react-hint.min.js | 4 +-- umd/react-hint.min.js.map | 2 +- 7 files changed, 151 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9982887..8237be4 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Options | ReactHint Property | Type | Default Value | Description | :----------------- | :---------------------------------------------------------- | :------------ | :---------- | attribute | String | "data-rh" | Allows setting a custom tooltip attribute instead of the default one. +| autoPosition | Boolean | false | Autopositions tooltips based on closeness to window borders. | className | String | "react-hint" | You can override the tooltip style by passing the `className` property. | delay | Number | 0 | The default delay before showing/hiding the tooltip. | events | Boolean or {click: Boolean, focus: Boolean, hover: Boolean} | false | Enables/disables all events or a subset of events. @@ -82,7 +83,7 @@ class App extends React.Component { render() { return
- + - + > 1)) > 0, + right: (isHoriz ? targetLeft + targetWidth + hintWidth : targetLeft + (targetWidth + hintWidth >> 1)) < clientWidth, + bottom: (isHoriz ? targetTop + (targetHeight + hintHeight >> 1) : targetTop + targetHeight + hintHeight) < clientHeight, + top: (isHoriz ? targetTop - (hintHeight >> 1) : targetTop - hintHeight) > 0 + }; + + switch (at) { + case 'left': + if (!directions.left) at = 'right'; + if (!directions.top) at = 'bottom'; + if (!directions.bottom) at = 'top'; + break; + + case 'right': + if (!directions.right) at = 'left'; + if (!directions.top) at = 'bottom'; + if (!directions.bottom) at = 'top'; + break; + + case 'bottom': + if (!directions.bottom) at = 'top'; + if (!directions.left) at = 'right'; + if (!directions.right) at = 'left'; + break; + + case 'top': + default: + if (!directions.top) at = 'bottom'; + if (!directions.left) at = 'right'; + if (!directions.right) at = 'left'; + break; + } + } + var top = void 0, left = void 0; switch (at) { @@ -175,6 +219,7 @@ exports.default = function (_ref) { return ReactHint; }(Component), _class.defaultProps = { attribute: 'data-rh', + autoPosition: false, className: 'react-hint', delay: 0, events: false, diff --git a/src/index.js b/src/index.js index 20e2085..0ccb01c 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ export default ({Component, createElement}) => class ReactHint extends Component { static defaultProps = { attribute: 'data-rh', + autoPosition: false, className: 'react-hint', delay: 0, events: false, @@ -69,9 +70,9 @@ export default ({Component, createElement}) => if (this.state.target) this.setState(this.getHintData) } - getHintData = ({target}, {attribute, position}) => { + getHintData = ({target}, {attribute, autoPosition, position}) => { const content = target.getAttribute(attribute) || '' - const at = target.getAttribute(`${attribute}-at`) || position + let at = target.getAttribute(`${attribute}-at`) || position const { top: containerTop, @@ -90,6 +91,57 @@ export default ({Component, createElement}) => height: targetHeight } = target.getBoundingClientRect() + if (autoPosition) { + const isHoriz = ['left', 'right'].includes(at) + + const { + clientHeight, + clientWidth + } = document.documentElement + + const directions = { + left: (isHoriz + ? targetLeft - hintWidth + : targetLeft + (targetWidth - hintWidth >> 1)) > 0, + right: (isHoriz + ? targetLeft + targetWidth + hintWidth + : targetLeft + (targetWidth + hintWidth >> 1)) < clientWidth, + bottom: (isHoriz + ? targetTop + (targetHeight + hintHeight >> 1) + : targetTop + targetHeight + hintHeight) < clientHeight, + top: (isHoriz + ? targetTop - (hintHeight >> 1) + : targetTop - hintHeight) > 0 + } + + switch (at) { + case 'left': + if (!directions.left) at = 'right' + if (!directions.top) at = 'bottom' + if (!directions.bottom) at = 'top' + break + + case 'right': + if (!directions.right) at = 'left' + if (!directions.top) at = 'bottom' + if (!directions.bottom) at = 'top' + break + + case 'bottom': + if (!directions.bottom) at = 'top' + if (!directions.left) at = 'right' + if (!directions.right) at = 'left' + break + + case 'top': + default: + if (!directions.top) at = 'bottom' + if (!directions.left) at = 'right' + if (!directions.right) at = 'left' + break + } + } + let top, left switch (at) { case 'left': diff --git a/umd/react-hint.js b/umd/react-hint.js index 02a14ad..601ef6b 100644 --- a/umd/react-hint.js +++ b/umd/react-hint.js @@ -1,5 +1,5 @@ /*! - * react-hint v3.0.1 - https://react-hint.js.org + * react-hint v3.1.0 - https://react-hint.js.org * MIT Licensed */ (function webpackUniversalModuleDefinition(root, factory) { @@ -156,6 +156,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" }, _this.getHintData = function (_ref4, _ref5) { var target = _ref4.target; var attribute = _ref5.attribute, + autoPosition = _ref5.autoPosition, position = _ref5.position; var content = target.getAttribute(attribute) || ''; @@ -175,6 +176,49 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" targetWidth = _target$getBoundingCl.width, targetHeight = _target$getBoundingCl.height; + if (autoPosition) { + var isHoriz = ['left', 'right'].includes(at); + + var _document$documentEle = document.documentElement, + clientHeight = _document$documentEle.clientHeight, + clientWidth = _document$documentEle.clientWidth; + + + var directions = { + left: (isHoriz ? targetLeft - hintWidth : targetLeft + (targetWidth - hintWidth >> 1)) > 0, + right: (isHoriz ? targetLeft + targetWidth + hintWidth : targetLeft + (targetWidth + hintWidth >> 1)) < clientWidth, + bottom: (isHoriz ? targetTop + (targetHeight + hintHeight >> 1) : targetTop + targetHeight + hintHeight) < clientHeight, + top: (isHoriz ? targetTop - (hintHeight >> 1) : targetTop - hintHeight) > 0 + }; + + switch (at) { + case 'left': + if (!directions.left) at = 'right'; + if (!directions.top) at = 'bottom'; + if (!directions.bottom) at = 'top'; + break; + + case 'right': + if (!directions.right) at = 'left'; + if (!directions.top) at = 'bottom'; + if (!directions.bottom) at = 'top'; + break; + + case 'bottom': + if (!directions.bottom) at = 'top'; + if (!directions.left) at = 'right'; + if (!directions.right) at = 'left'; + break; + + case 'top': + default: + if (!directions.top) at = 'bottom'; + if (!directions.left) at = 'right'; + if (!directions.right) at = 'left'; + break; + } + } + var top = void 0, left = void 0; switch (at) { @@ -263,6 +307,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" return ReactHint; }(Component), _class.defaultProps = { attribute: 'data-rh', + autoPosition: false, className: 'react-hint', delay: 0, events: false, diff --git a/umd/react-hint.min.js b/umd/react-hint.min.js index 798f0e1..403f09d 100644 --- a/umd/react-hint.min.js +++ b/umd/react-hint.min.js @@ -1,6 +1,6 @@ /*! - * react-hint v3.0.1 - https://react-hint.js.org + * react-hint v3.1.0 - https://react-hint.js.org * MIT Licensed */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReactHintFactory=e():t.ReactHintFactory=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e,n,r=t.Component,i=t.createElement;return n=e=function(t){function e(){var n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,u=Array(i),a=0;a0&&void 0!==arguments[0]?arguments[0]:{}).target,e=void 0===t?null:t;clearTimeout(r._timeout),r._timeout=setTimeout(function(){return r.setState(function(){return{target:r.getHint(e)}})},r.props.delay)},r.getHint=function(t){for(var e=r.props,n=e.attribute,o=e.persist,i=r.state.target;t&&t!==document;){if(o&&t===r._hint)return i;if(t.hasAttribute(n))return t;t=t.parentNode}return null},r.shallowEqual=function(t,e){var n=Object.keys(t);return n.length===Object.keys(e).length&&n.reduce(function(n,o){return n&&("function"==typeof t[o]&&"function"==typeof e[o]||t[o]===e[o])},!0)},r.getHintData=function(t,e){var n=t.target,o=e.attribute,i=e.position,u=n.getAttribute(o)||"",a=n.getAttribute(o+"-at")||i,c=r._container.getBoundingClientRect(),s=c.top,l=c.left,f=r._hint.getBoundingClientRect(),p=f.width,d=f.height,h=n.getBoundingClientRect(),g=h.top,y=h.left,v=h.width,m=h.height,b=void 0,_=void 0;switch(a){case"left":b=m-d>>1,_=-p;break;case"right":b=m-d>>1,_=v;break;case"bottom":b=m,_=v-p>>1;break;case"top":default:b=-d,_=v-p>>1}return{content:u,at:a,top:b+g-s|0,left:_+y-l|0}},o(r,n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.componentDidMount=function(){this.toggleEvents(this.props,!0)},e.prototype.componentWillUnmount=function(){this.toggleEvents(this.props,!1),clearTimeout(this._timeout)},e.prototype.shouldComponentUpdate=function(t,e){return!this.shallowEqual(e,this.state)||!this.shallowEqual(t,this.props)},e.prototype.componentDidUpdate=function(){this.state.target&&this.setState(this.getHintData)},e.prototype.render=function(){var t=this,e=this.props,n=e.className,o=e.onRenderContent,r=this.state,u=r.target,a=r.content,c=r.at,s=r.top,l=r.left;return i("div",{ref:function(e){return t._container=e},style:this._containerStyle},u&&i("div",{className:n+" "+n+"--"+c,ref:function(e){return t._hint=e},style:{top:s,left:l}},o?o(u,a):i("div",{className:n+"__content"},a)))},e}(r),e.defaultProps={attribute:"data-rh",className:"react-hint",delay:0,events:!1,onRenderContent:null,persist:!1,position:"top"},n}}]).default}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ReactHintFactory=e():t.ReactHintFactory=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e,n,r=t.Component,i=t.createElement;return n=e=function(t){function e(){var n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,u=Array(i),a=0;a0&&void 0!==arguments[0]?arguments[0]:{}).target,e=void 0===t?null:t;clearTimeout(r._timeout),r._timeout=setTimeout(function(){return r.setState(function(){return{target:r.getHint(e)}})},r.props.delay)},r.getHint=function(t){for(var e=r.props,n=e.attribute,o=e.persist,i=r.state.target;t&&t!==document;){if(o&&t===r._hint)return i;if(t.hasAttribute(n))return t;t=t.parentNode}return null},r.shallowEqual=function(t,e){var n=Object.keys(t);return n.length===Object.keys(e).length&&n.reduce(function(n,o){return n&&("function"==typeof t[o]&&"function"==typeof e[o]||t[o]===e[o])},!0)},r.getHintData=function(t,e){var n=t.target,o=e.attribute,i=e.autoPosition,u=e.position,a=n.getAttribute(o)||"",c=n.getAttribute(o+"-at")||u,s=r._container.getBoundingClientRect(),l=s.top,f=s.left,p=r._hint.getBoundingClientRect(),h=p.width,d=p.height,g=n.getBoundingClientRect(),m=g.top,b=g.left,y=g.width,v=g.height;if(i){var _=["left","right"].includes(c),w=document.documentElement,E=w.clientHeight,j=w.clientWidth,H={left:(_?b-h:b+(y-h>>1))>0,right:(_?b+y+h:b+(y+h>>1))>1):m+v+d)>1):m-d)>0};switch(c){case"left":H.left||(c="right"),H.top||(c="bottom"),H.bottom||(c="top");break;case"right":H.right||(c="left"),H.top||(c="bottom"),H.bottom||(c="top");break;case"bottom":H.bottom||(c="top"),H.left||(c="right"),H.right||(c="left");break;case"top":default:H.top||(c="bottom"),H.left||(c="right"),H.right||(c="left")}}var x=void 0,O=void 0;switch(c){case"left":x=v-d>>1,O=-h;break;case"right":x=v-d>>1,O=y;break;case"bottom":x=v,O=y-h>>1;break;case"top":default:x=-d,O=y-h>>1}return{content:a,at:c,top:x+m-l|0,left:O+b-f|0}},o(r,n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.componentDidMount=function(){this.toggleEvents(this.props,!0)},e.prototype.componentWillUnmount=function(){this.toggleEvents(this.props,!1),clearTimeout(this._timeout)},e.prototype.shouldComponentUpdate=function(t,e){return!this.shallowEqual(e,this.state)||!this.shallowEqual(t,this.props)},e.prototype.componentDidUpdate=function(){this.state.target&&this.setState(this.getHintData)},e.prototype.render=function(){var t=this,e=this.props,n=e.className,o=e.onRenderContent,r=this.state,u=r.target,a=r.content,c=r.at,s=r.top,l=r.left;return i("div",{ref:function(e){return t._container=e},style:this._containerStyle},u&&i("div",{className:n+" "+n+"--"+c,ref:function(e){return t._hint=e},style:{top:s,left:l}},o?o(u,a):i("div",{className:n+"__content"},a)))},e}(r),e.defaultProps={attribute:"data-rh",autoPosition:!1,className:"react-hint",delay:0,events:!1,onRenderContent:null,persist:!1,position:"top"},n}}]).default}); //# sourceMappingURL=react-hint.min.js.map \ No newline at end of file diff --git a/umd/react-hint.min.js.map b/umd/react-hint.min.js.map index 7017cc5..74c5297 100644 --- a/umd/react-hint.min.js.map +++ b/umd/react-hint.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap c0f767c3a035748ef7dd","webpack:///./src/index.js"],"names":["root","factory","exports","module","define","amd","self","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","_ref","_class","_temp2","Component","createElement","_Component","ReactHint","_temp","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_possibleConstructorReturn","apply","concat","state","target","_containerStyle","position","toggleEvents","_ref2","flag","events","_ref2$events","click","focus","hover","action","hasEvents","document","toggleHint","_ref3$target","undefined","clearTimeout","_timeout","setTimeout","setState","getHint","props","delay","el","_this$props","attribute","persist","_hint","hasAttribute","parentNode","shallowEqual","a","b","keys","reduce","result","key","getHintData","_ref4","_ref5","content","getAttribute","at","_this$_container$getB","_container","getBoundingClientRect","containerTop","top","containerLeft","left","_this$_hint$getBoundi","hintWidth","width","hintHeight","height","_target$getBoundingCl","targetTop","targetLeft","targetWidth","targetHeight","_inherits","componentDidMount","componentWillUnmount","shouldComponentUpdate","componentDidUpdate","render","_this2","_props","className","onRenderContent","_state","ref","style","defaultProps"],"mappings":";;;;CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,IACA,mBAAAG,eAAAC,IACAD,UAAAH,GACA,iBAAAC,QACAA,QAAA,iBAAAD,IAEAD,EAAA,iBAAAC,IARA,CASC,oBAAAK,UAAAC,KAAA,WACD,mBCTA,IAAAC,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAR,QAGA,IAAAC,EAAAK,EAAAE,IACAC,EAAAD,EACAE,GAAA,EACAV,YAUA,OANAW,EAAAH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VF,EACUE,gBADVC,EAEiCvH,KAAK+C,MAAvCC,EAFCuE,EAEDvE,OAAQyC,EAFP8B,EAEO9B,QAASE,EAFhB4B,EAEgB5B,GAAIK,EAFpBuB,EAEoBvB,IAAKE,EAFzBqB,EAEyBrB,KAEjC,OAAOlE,EAAA,OAAKwF,IAAK,SAACA,GAAD,OAASL,EAAKtB,WAAa2B,GAC3CC,MAAOzH,KAAKiD,iBACVD,GACAhB,EAAA,OAAKqF,UAAcA,EAAd,IAA2BA,EAA3B,KAAyC1B,EAC7C6B,IAAK,SAACA,GAAD,OAASL,EAAKvC,MAAQ4C,GAC3BC,OAAQzB,MAAKE,SACXoB,EACEA,EAAgBtE,EAAQyC,GACxBzD,EAAA,OAAKqF,UAAcA,EAAd,aACL5B,MAvIIvD,EAAA,CACUH,GADVF,EAEN6F,cACNhD,UAAW,UACX2C,UAAW,aACX9C,MAAO,EACPjB,QAAQ,EACRgE,gBAAiB,KACjB3C,SAAS,EACTzB,SAAU,OATEpB","file":"react-hint.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ReactHintFactory\"] = factory();\n\telse\n\t\troot[\"ReactHintFactory\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c0f767c3a035748ef7dd","export default ({Component, createElement}) =>\n\tclass ReactHint extends Component {\n\t\tstatic defaultProps = {\n\t\t\tattribute: 'data-rh',\n\t\t\tclassName: 'react-hint',\n\t\t\tdelay: 0,\n\t\t\tevents: false,\n\t\t\tonRenderContent: null,\n\t\t\tpersist: false,\n\t\t\tposition: 'top'\n\t\t}\n\n\t\tstate = {target: null}\n\t\t_containerStyle = {position: 'relative'}\n\n\t\tcomponentDidMount() {\n\t\t\tthis.toggleEvents(this.props, true)\n\t\t}\n\n\t\tcomponentWillUnmount() {\n\t\t\tthis.toggleEvents(this.props, false)\n\t\t\tclearTimeout(this._timeout)\n\t\t}\n\n\t\ttoggleEvents = ({events, events: {click, focus, hover}}, flag) => {\n\t\t\tconst action = flag ? 'addEventListener' : 'removeEventListener'\n\t\t\tconst hasEvents = events === true\n\n\t\t\t;(click || hasEvents) && document[action]('click', this.toggleHint)\n\t\t\t;(focus || hasEvents) && document[action]('focusin', this.toggleHint)\n\t\t\t;(hover || hasEvents) && document[action]('mouseover', this.toggleHint)\n\t\t\t;(click || hover || hasEvents) && document[action]('touchend', this.toggleHint)\n\t\t}\n\n\t\ttoggleHint = ({target = null} = {}) => {\n\t\t\tclearTimeout(this._timeout)\n\t\t\tthis._timeout = setTimeout(() => this.setState(() => ({\n\t\t\t\ttarget: this.getHint(target)\n\t\t\t})), this.props.delay)\n\t\t}\n\n\t\tgetHint = (el) => {\n\t\t\tconst {attribute, persist} = this.props\n\t\t\tconst {target} = this.state\n\n\t\t\twhile (el) {\n\t\t\t\tif (el === document) break\n\t\t\t\tif (persist && el === this._hint) return target\n\t\t\t\tif (el.hasAttribute(attribute)) return el\n\t\t\t\tel = el.parentNode\n\t\t\t} return null\n\t\t}\n\n\t\tshouldComponentUpdate(props, state) {\n\t\t\treturn !this.shallowEqual(state, this.state) ||\n\t\t\t\t!this.shallowEqual(props, this.props)\n\t\t}\n\n\t\tshallowEqual = (a, b) => {\n\t\t\tconst keys = Object.keys(a)\n\t\t\treturn keys.length === Object.keys(b).length &&\n\t\t\t\tkeys.reduce((result, key) => result &&\n\t\t\t\t\t((typeof a[key] === 'function' &&\n\t\t\t\t\t\ttypeof b[key] === 'function') ||\n\t\t\t\t\t\t\ta[key] === b[key]), true)\n\t\t}\n\n\t\tcomponentDidUpdate() {\n\t\t\tif (this.state.target) this.setState(this.getHintData)\n\t\t}\n\n\t\tgetHintData = ({target}, {attribute, position}) => {\n\t\t\tconst content = target.getAttribute(attribute) || ''\n\t\t\tconst at = target.getAttribute(`${attribute}-at`) || position\n\n\t\t\tconst {\n\t\t\t\ttop: containerTop,\n\t\t\t\tleft: containerLeft\n\t\t\t} = this._container.getBoundingClientRect()\n\n\t\t\tconst {\n\t\t\t\twidth: hintWidth,\n\t\t\t\theight: hintHeight\n\t\t\t} = this._hint.getBoundingClientRect()\n\n\t\t\tconst {\n\t\t\t\ttop: targetTop,\n\t\t\t\tleft: targetLeft,\n\t\t\t\twidth: targetWidth,\n\t\t\t\theight: targetHeight\n\t\t\t} = target.getBoundingClientRect()\n\n\t\t\tlet top, left\n\t\t\tswitch (at) {\n\t\t\t\tcase 'left':\n\t\t\t\t\ttop = targetHeight - hintHeight >> 1\n\t\t\t\t\tleft = -hintWidth\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'right':\n\t\t\t\t\ttop = targetHeight - hintHeight >> 1\n\t\t\t\t\tleft = targetWidth\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'bottom':\n\t\t\t\t\ttop = targetHeight\n\t\t\t\t\tleft = targetWidth - hintWidth >> 1\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'top':\n\t\t\t\tdefault:\n\t\t\t\t\ttop = -hintHeight\n\t\t\t\t\tleft = targetWidth - hintWidth >> 1\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontent, at,\n\t\t\t\ttop: (top + targetTop - containerTop)|0,\n\t\t\t\tleft: (left + targetLeft - containerLeft)|0\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\tconst {className, onRenderContent} = this.props\n\t\t\tconst {target, content, at, top, left} = this.state\n\n\t\t\treturn
this._container = ref}\n\t\t\t\tstyle={this._containerStyle}>\n\t\t\t\t\t{target &&\n\t\t\t\t\t\t
this._hint = ref}\n\t\t\t\t\t\t\tstyle={{top, left}}>\n\t\t\t\t\t\t\t\t{onRenderContent\n\t\t\t\t\t\t\t\t\t? onRenderContent(target, content)\n\t\t\t\t\t\t\t\t\t:
\n\t\t\t\t\t\t\t\t\t\t{content}\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t
\n\t\t\t\t\t}\n\t\t\t\t
\n\t\t}\n\t}\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 6c3de8052a5de8830aac","webpack:///./src/index.js"],"names":["root","factory","exports","module","define","amd","self","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","_ref","_class","_temp2","Component","createElement","_Component","ReactHint","_temp","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_possibleConstructorReturn","apply","concat","state","target","_containerStyle","position","toggleEvents","_ref2","flag","events","_ref2$events","click","focus","hover","action","hasEvents","document","toggleHint","_ref3$target","undefined","clearTimeout","_timeout","setTimeout","setState","getHint","props","delay","el","_this$props","attribute","persist","_hint","hasAttribute","parentNode","shallowEqual","a","b","keys","reduce","result","key","getHintData","_ref4","_ref5","autoPosition","content","getAttribute","at","_this$_container$getB","_container","getBoundingClientRect","containerTop","top","containerLeft","left","_this$_hint$getBoundi","hintWidth","width","hintHeight","height","_target$getBoundingCl","targetTop","targetLeft","targetWidth","targetHeight","isHoriz","includes","_document$documentEle","documentElement","clientHeight","clientWidth","directions","right","bottom","_inherits","componentDidMount","componentWillUnmount","shouldComponentUpdate","componentDidUpdate","render","_this2","_props","className","onRenderContent","_state","ref","style","defaultProps"],"mappings":";;;;CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,IACA,mBAAAG,eAAAC,IACAD,UAAAH,GACA,iBAAAC,QACAA,QAAA,iBAAAD,IAEAD,EAAA,iBAAAC,IARA,CASC,oBAAAK,UAAAC,KAAA,WACD,mBCTA,IAAAC,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAR,QAGA,IAAAC,EAAAK,EAAAE,IACAC,EAAAD,EACAE,GAAA,EACAV,YAUA,OANAW,EAAAH,GAAAI,KAAAX,EAAAD,Q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C3BC,OAAQlC,MAAKE,SACX6B,EACEA,EAAgBhF,EAAQ0C,GACxB1D,EAAA,OAAK+F,UAAcA,EAAd,aACLrC,MA3LIxD,EAAA,CACUH,GADVF,EAENuG,cACN1D,UAAW,UACXe,cAAc,EACdsC,UAAW,aACXxD,MAAO,EACPjB,QAAQ,EACR0E,gBAAiB,KACjBrD,SAAS,EACTzB,SAAU,OAVEpB","file":"react-hint.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ReactHintFactory\"] = factory();\n\telse\n\t\troot[\"ReactHintFactory\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 6c3de8052a5de8830aac","export default ({Component, createElement}) =>\n\tclass ReactHint extends Component {\n\t\tstatic defaultProps = {\n\t\t\tattribute: 'data-rh',\n\t\t\tautoPosition: false,\n\t\t\tclassName: 'react-hint',\n\t\t\tdelay: 0,\n\t\t\tevents: false,\n\t\t\tonRenderContent: null,\n\t\t\tpersist: false,\n\t\t\tposition: 'top'\n\t\t}\n\n\t\tstate = {target: null}\n\t\t_containerStyle = {position: 'relative'}\n\n\t\tcomponentDidMount() {\n\t\t\tthis.toggleEvents(this.props, true)\n\t\t}\n\n\t\tcomponentWillUnmount() {\n\t\t\tthis.toggleEvents(this.props, false)\n\t\t\tclearTimeout(this._timeout)\n\t\t}\n\n\t\ttoggleEvents = ({events, events: {click, focus, hover}}, flag) => {\n\t\t\tconst action = flag ? 'addEventListener' : 'removeEventListener'\n\t\t\tconst hasEvents = events === true\n\n\t\t\t;(click || hasEvents) && document[action]('click', this.toggleHint)\n\t\t\t;(focus || hasEvents) && document[action]('focusin', this.toggleHint)\n\t\t\t;(hover || hasEvents) && document[action]('mouseover', this.toggleHint)\n\t\t\t;(click || hover || hasEvents) && document[action]('touchend', this.toggleHint)\n\t\t}\n\n\t\ttoggleHint = ({target = null} = {}) => {\n\t\t\tclearTimeout(this._timeout)\n\t\t\tthis._timeout = setTimeout(() => this.setState(() => ({\n\t\t\t\ttarget: this.getHint(target)\n\t\t\t})), this.props.delay)\n\t\t}\n\n\t\tgetHint = (el) => {\n\t\t\tconst {attribute, persist} = this.props\n\t\t\tconst {target} = this.state\n\n\t\t\twhile (el) {\n\t\t\t\tif (el === document) break\n\t\t\t\tif (persist && el === this._hint) return target\n\t\t\t\tif (el.hasAttribute(attribute)) return el\n\t\t\t\tel = el.parentNode\n\t\t\t} return null\n\t\t}\n\n\t\tshouldComponentUpdate(props, state) {\n\t\t\treturn !this.shallowEqual(state, this.state) ||\n\t\t\t\t!this.shallowEqual(props, this.props)\n\t\t}\n\n\t\tshallowEqual = (a, b) => {\n\t\t\tconst keys = Object.keys(a)\n\t\t\treturn keys.length === Object.keys(b).length &&\n\t\t\t\tkeys.reduce((result, key) => result &&\n\t\t\t\t\t((typeof a[key] === 'function' &&\n\t\t\t\t\t\ttypeof b[key] === 'function') ||\n\t\t\t\t\t\t\ta[key] === b[key]), true)\n\t\t}\n\n\t\tcomponentDidUpdate() {\n\t\t\tif (this.state.target) this.setState(this.getHintData)\n\t\t}\n\n\t\tgetHintData = ({target}, {attribute, autoPosition, position}) => {\n\t\t\tconst content = target.getAttribute(attribute) || ''\n\t\t\tlet at = target.getAttribute(`${attribute}-at`) || position\n\n\t\t\tconst {\n\t\t\t\ttop: containerTop,\n\t\t\t\tleft: containerLeft\n\t\t\t} = this._container.getBoundingClientRect()\n\n\t\t\tconst {\n\t\t\t\twidth: hintWidth,\n\t\t\t\theight: hintHeight\n\t\t\t} = this._hint.getBoundingClientRect()\n\n\t\t\tconst {\n\t\t\t\ttop: targetTop,\n\t\t\t\tleft: targetLeft,\n\t\t\t\twidth: targetWidth,\n\t\t\t\theight: targetHeight\n\t\t\t} = target.getBoundingClientRect()\n\n\t\t\tif (autoPosition) {\n\t\t\t\tconst isHoriz = ['left', 'right'].includes(at)\n\n\t\t\t\tconst {\n\t\t\t\t\tclientHeight,\n\t\t\t\t\tclientWidth\n\t\t\t\t} = document.documentElement\n\n\t\t\t\tconst directions = {\n\t\t\t\t\tleft: (isHoriz\n\t\t\t\t\t\t? targetLeft - hintWidth\n\t\t\t\t\t\t: targetLeft + (targetWidth - hintWidth >> 1)) > 0,\n\t\t\t\t\tright: (isHoriz\n\t\t\t\t\t\t? targetLeft + targetWidth + hintWidth\n\t\t\t\t\t\t: targetLeft + (targetWidth + hintWidth >> 1)) < clientWidth,\n\t\t\t\t\tbottom: (isHoriz\n\t\t\t\t\t\t? targetTop + (targetHeight + hintHeight >> 1)\n\t\t\t\t\t\t: targetTop + targetHeight + hintHeight) < clientHeight,\n\t\t\t\t\ttop: (isHoriz\n\t\t\t\t\t\t? targetTop - (hintHeight >> 1)\n\t\t\t\t\t\t: targetTop - hintHeight) > 0\n\t\t\t\t}\n\n\t\t\t\tswitch (at) {\n\t\t\t\t\tcase 'left':\n\t\t\t\t\t\tif (!directions.left) at = 'right'\n\t\t\t\t\t\tif (!directions.top) at = 'bottom'\n\t\t\t\t\t\tif (!directions.bottom) at = 'top'\n\t\t\t\t\t\tbreak\n\n\t\t\t\t\tcase 'right':\n\t\t\t\t\t\tif (!directions.right) at = 'left'\n\t\t\t\t\t\tif (!directions.top) at = 'bottom'\n\t\t\t\t\t\tif (!directions.bottom) at = 'top'\n\t\t\t\t\t\tbreak\n\n\t\t\t\t\tcase 'bottom':\n\t\t\t\t\t\tif (!directions.bottom) at = 'top'\n\t\t\t\t\t\tif (!directions.left) at = 'right'\n\t\t\t\t\t\tif (!directions.right) at = 'left'\n\t\t\t\t\t\tbreak\n\n\t\t\t\t\tcase 'top':\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (!directions.top) at = 'bottom'\n\t\t\t\t\t\tif (!directions.left) at = 'right'\n\t\t\t\t\t\tif (!directions.right) at = 'left'\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet top, left\n\t\t\tswitch (at) {\n\t\t\t\tcase 'left':\n\t\t\t\t\ttop = targetHeight - hintHeight >> 1\n\t\t\t\t\tleft = -hintWidth\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'right':\n\t\t\t\t\ttop = targetHeight - hintHeight >> 1\n\t\t\t\t\tleft = targetWidth\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'bottom':\n\t\t\t\t\ttop = targetHeight\n\t\t\t\t\tleft = targetWidth - hintWidth >> 1\n\t\t\t\t\tbreak\n\n\t\t\t\tcase 'top':\n\t\t\t\tdefault:\n\t\t\t\t\ttop = -hintHeight\n\t\t\t\t\tleft = targetWidth - hintWidth >> 1\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontent, at,\n\t\t\t\ttop: (top + targetTop - containerTop)|0,\n\t\t\t\tleft: (left + targetLeft - containerLeft)|0\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\tconst {className, onRenderContent} = this.props\n\t\t\tconst {target, content, at, top, left} = this.state\n\n\t\t\treturn
this._container = ref}\n\t\t\t\tstyle={this._containerStyle}>\n\t\t\t\t\t{target &&\n\t\t\t\t\t\t
this._hint = ref}\n\t\t\t\t\t\t\tstyle={{top, left}}>\n\t\t\t\t\t\t\t\t{onRenderContent\n\t\t\t\t\t\t\t\t\t? onRenderContent(target, content)\n\t\t\t\t\t\t\t\t\t:
\n\t\t\t\t\t\t\t\t\t\t{content}\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t
\n\t\t\t\t\t}\n\t\t\t\t
\n\t\t}\n\t}\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file