react-hint
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -0,1 +1,7 @@ | ||
## 3.2.0 (December 5, 2018) | ||
* #29: Allow setting different show & hide delay | ||
## 3.1.1 (August 2, 2018) | ||
* #28: Make react-hint ARIA-compliant | ||
## 3.1.0 (May 12, 2018) | ||
@@ -2,0 +8,0 @@ * #25: Add support for tooltip autopositioning via `autoPosition` property |
@@ -42,10 +42,9 @@ 'use strict'; | ||
target = _this.getHint(target); | ||
clearTimeout(_this._timeout); | ||
_this._timeout = setTimeout(function () { | ||
return _this.setState(function () { | ||
return { | ||
target: _this.getHint(target) | ||
}; | ||
return { target: target }; | ||
}); | ||
}, _this.props.delay); | ||
}, target === null ? _this.props.delay.hide === undefined ? _this.props.delay : _this.props.delay.hide : _this.props.delay.show === undefined ? _this.props.delay : _this.props.delay.show); | ||
}, _this.getHint = function (el) { | ||
@@ -52,0 +51,0 @@ var _this$props = _this.props, |
{ | ||
"name": "react-hint", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"license": "MIT", | ||
@@ -16,3 +16,3 @@ "description": "Tooltip component for React, Preact, Inferno", | ||
"devDependencies": { | ||
"nwb": "0.22.x", | ||
"nwb": "0.23.x", | ||
"react": "16.x", | ||
@@ -19,0 +19,0 @@ "react-dom": "16.x" |
@@ -48,3 +48,3 @@ React-hint | ||
| 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. | ||
| delay | Number or {show: Number, hide: 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. | ||
@@ -87,3 +87,3 @@ | onRenderContent | Function | | Passing a function which returns a react node allows rendering custom content with attached event handlers. | ||
return <div> | ||
<ReactHint autoPosition events delay={100} /> | ||
<ReactHint autoPosition events delay={{show: 100, hide: 1000}} /> | ||
<ReactHint persist | ||
@@ -90,0 +90,0 @@ attribute="data-custom" |
@@ -37,6 +37,12 @@ export default ({Component, createElement}) => | ||
toggleHint = ({target = null} = {}) => { | ||
target = this.getHint(target) | ||
clearTimeout(this._timeout) | ||
this._timeout = setTimeout(() => this.setState(() => ({ | ||
target: this.getHint(target) | ||
})), this.props.delay) | ||
this._timeout = setTimeout(() => this.setState(() => | ||
({target})), target === null | ||
? this.props.delay.hide === undefined | ||
? this.props.delay | ||
: this.props.delay.hide | ||
: this.props.delay.show === undefined | ||
? this.props.delay | ||
: this.props.delay.show) | ||
} | ||
@@ -43,0 +49,0 @@ |
/*! | ||
* react-hint v3.1.1 - https://react-hint.js.org | ||
* react-hint v3.2.0 - https://react-hint.js.org | ||
* MIT Licensed | ||
@@ -53,7 +53,3 @@ */ | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
@@ -64,5 +60,24 @@ /******/ }; | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
@@ -85,3 +100,3 @@ /******/ __webpack_require__.n = function(module) { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 1); | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
@@ -91,2 +106,9 @@ /************************************************************************/ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(1); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -133,10 +155,9 @@ | ||
target = _this.getHint(target); | ||
clearTimeout(_this._timeout); | ||
_this._timeout = setTimeout(function () { | ||
return _this.setState(function () { | ||
return { | ||
target: _this.getHint(target) | ||
}; | ||
return { target: target }; | ||
}); | ||
}, _this.props.delay); | ||
}, target === null ? _this.props.delay.hide === undefined ? _this.props.delay : _this.props.delay.hide : _this.props.delay.show === undefined ? _this.props.delay : _this.props.delay.show); | ||
}, _this.getHint = function (el) { | ||
@@ -325,11 +346,4 @@ var _this$props = _this.props, | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(0); | ||
/***/ }) | ||
/******/ ])["default"]; | ||
}); |
@@ -1,2 +0,6 @@ | ||
!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()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},o.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=1)}([function(t,e,o){"use strict";function n(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}o.r(e),e.default=function(t){var e,o,r=t.Component,i=t.createElement;return o=e=function(t){function e(){var o,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;a<i;a++)u[a]=arguments[a];return o=r=n(this,t.call.apply(t,[this].concat(u))),r.state={target:null},r._containerStyle={position:"relative"},r.toggleEvents=function(t,e){var o=t.events,n=t.events,i=n.click,u=n.focus,a=n.hover,c=e?"addEventListener":"removeEventListener",s=!0===o;(i||s)&&document[c]("click",r.toggleHint),(u||s)&&document[c]("focusin",r.toggleHint),(a||s)&&document[c]("mouseover",r.toggleHint),(i||a||s)&&document[c]("touchend",r.toggleHint)},r.toggleHint=function(){var t=(arguments.length>0&&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,o=e.attribute,n=e.persist,i=r.state.target;t&&t!==document;){if(n&&t===r._hint)return i;if(t.hasAttribute(o))return t;t=t.parentNode}return null},r.shallowEqual=function(t,e){var o=Object.keys(t);return o.length===Object.keys(e).length&&o.reduce(function(o,n){return o&&("function"==typeof t[n]&&"function"==typeof e[n]||t[n]===e[n])},!0)},r.getHintData=function(t,e){var o=t.target,n=e.attribute,i=e.autoPosition,u=e.position,a=o.getAttribute(n)||"",c=o.getAttribute(n+"-at")||u,s=r._container.getBoundingClientRect(),l=s.top,f=s.left,p=r._hint.getBoundingClientRect(),h=p.width,d=p.height,g=o.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))<j,bottom:(_?m+(v+d>>1):m+v+d)<E,top:(_?m-(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}},n(r,o)}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,o=e.className,n=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:o+" "+o+"--"+c,ref:function(e){return t._hint=e},role:"tooltip",style:{top:s,left:l}},n?n(u,a):i("div",{className:o+"__content"},a)))},e}(r),e.defaultProps={attribute:"data-rh",autoPosition:!1,className:"react-hint",delay:0,events:!1,onRenderContent:null,persist:!1,position:"top"},o}},function(t,e,o){t.exports=o(0)}]).default}); | ||
/*! | ||
* react-hint v3.2.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()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){t.exports=o(1)},function(t,e,o){"use strict";function n(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}o.r(e),e.default=function(t){var e,o,r=t.Component,i=t.createElement;return o=e=function(t){function e(){var o,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;a<i;a++)u[a]=arguments[a];return o=r=n(this,t.call.apply(t,[this].concat(u))),r.state={target:null},r._containerStyle={position:"relative"},r.toggleEvents=function(t,e){var o=t.events,n=t.events,i=n.click,u=n.focus,a=n.hover,c=e?"addEventListener":"removeEventListener",l=!0===o;(i||l)&&document[c]("click",r.toggleHint),(u||l)&&document[c]("focusin",r.toggleHint),(a||l)&&document[c]("mouseover",r.toggleHint),(i||a||l)&&document[c]("touchend",r.toggleHint)},r.toggleHint=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).target,e=void 0===t?null:t;e=r.getHint(e),clearTimeout(r._timeout),r._timeout=setTimeout(function(){return r.setState(function(){return{target:e}})},null===e?void 0===r.props.delay.hide?r.props.delay:r.props.delay.hide:void 0===r.props.delay.show?r.props.delay:r.props.delay.show)},r.getHint=function(t){for(var e=r.props,o=e.attribute,n=e.persist,i=r.state.target;t&&t!==document;){if(n&&t===r._hint)return i;if(t.hasAttribute(o))return t;t=t.parentNode}return null},r.shallowEqual=function(t,e){var o=Object.keys(t);return o.length===Object.keys(e).length&&o.reduce(function(o,n){return o&&("function"==typeof t[n]&&"function"==typeof e[n]||t[n]===e[n])},!0)},r.getHintData=function(t,e){var o=t.target,n=e.attribute,i=e.autoPosition,u=e.position,a=o.getAttribute(n)||"",c=o.getAttribute(n+"-at")||u,l=r._container.getBoundingClientRect(),s=l.top,f=l.left,p=r._hint.getBoundingClientRect(),d=p.width,h=p.height,g=o.getBoundingClientRect(),y=g.top,b=g.left,m=g.width,v=g.height;if(i){var _=["left","right"].includes(c),w=document.documentElement,j=w.clientHeight,O=w.clientWidth,E={left:(_?b-d:b+(m-d>>1))>0,right:(_?b+m+d:b+(m+d>>1))<O,bottom:(_?y+(v+h>>1):y+v+h)<j,top:(_?y-(h>>1):y-h)>0};switch(c){case"left":E.left||(c="right"),E.top||(c="bottom"),E.bottom||(c="top");break;case"right":E.right||(c="left"),E.top||(c="bottom"),E.bottom||(c="top");break;case"bottom":E.bottom||(c="top"),E.left||(c="right"),E.right||(c="left");break;case"top":default:E.top||(c="bottom"),E.left||(c="right"),E.right||(c="left")}}var H=void 0,x=void 0;switch(c){case"left":H=v-h>>1,x=-d;break;case"right":H=v-h>>1,x=m;break;case"bottom":H=v,x=m-d>>1;break;case"top":default:H=-h,x=m-d>>1}return{content:a,at:c,top:H+y-s|0,left:x+b-f|0}},n(r,o)}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,o=e.className,n=e.onRenderContent,r=this.state,u=r.target,a=r.content,c=r.at,l=r.top,s=r.left;return i("div",{ref:function(e){return t._container=e},style:this._containerStyle},u&&i("div",{className:o+" "+o+"--"+c,ref:function(e){return t._hint=e},role:"tooltip",style:{top:l,left:s}},n?n(u,a):i("div",{className:o+"__content"},a)))},e}(r),e.defaultProps={attribute:"data-rh",autoPosition:!1,className:"react-hint",delay:0,events:!1,onRenderContent:null,persist:!1,position:"top"},o}}]).default}); | ||
//# sourceMappingURL=react-hint.min.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57576
744