react-block-ui
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -0,1 +1,11 @@ | ||
<a name="1.1.3"></a> | ||
## [1.1.3](https://github.com/Availity/react-block-ui/compare/v1.1.2...v1.1.3) (2018-09-07) | ||
### Bug Fixes | ||
* **FocusManagement:** fix scroll to top on unlock ([#20](https://github.com/Availity/react-block-ui/issues/20)) ([58c9e67](https://github.com/Availity/react-block-ui/commit/58c9e67)) | ||
<a name="1.1.2"></a> | ||
@@ -2,0 +12,0 @@ ## [1.1.2](https://github.com/Availity/react-block-ui/compare/v1.1.1...v1.1.2) (2018-07-31) |
@@ -182,7 +182,6 @@ 'use strict'; | ||
this.focused = safeActiveElement(); | ||
// We cannot just blur to remove focus due to IE bug so we must manually move the focus somewhere else. | ||
// https://www.tjvantoll.com/2013/08/30/bugs-with-document-activeelement-in-internet-explorer/#blurring-the-body-switches-windows-in-ie9-and-ie10 | ||
if (this.focused && this.focused !== document.body) { | ||
(window.setImmediate || setTimeout)(function () { | ||
return _this2.topFocus && _this2.topFocus.focus(); | ||
return _this2.focused && _this2.focused.blur(); | ||
}); | ||
@@ -189,0 +188,0 @@ } |
@@ -177,7 +177,6 @@ import React, { Component } from 'react'; | ||
this.focused = safeActiveElement(); | ||
// We cannot just blur to remove focus due to IE bug so we must manually move the focus somewhere else. | ||
// https://www.tjvantoll.com/2013/08/30/bugs-with-document-activeelement-in-internet-explorer/#blurring-the-body-switches-windows-in-ie9-and-ie10 | ||
if (this.focused && this.focused !== document.body) { | ||
(window.setImmediate || setTimeout)(function () { | ||
return _this2.topFocus && _this2.topFocus.focus(); | ||
return _this2.focused && _this2.focused.blur(); | ||
}); | ||
@@ -184,0 +183,0 @@ } |
@@ -1,2 +0,2 @@ | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b(require('react')):'function'==typeof define&&define.amd?define(['react'],b):a.ReactBlockUi=b(a.React)})(this,function(a){'use strict';function b(a){a=a||document;var b;try{b=document.activeElement,b&&b.nodeName||(b=a.body)}catch(c){b=a.body}return b}var c='default'in a?a['default']:a,d=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},e=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},g=function(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},h=function(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c},i=function(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a},j=function(a){function j(a){d(this,j);var b=i(this,(j.__proto__||Object.getPrototypeOf(j)).call(this,a));return b.tabbedUpTop=b.tabbedUpTop.bind(b),b.tabbedDownTop=b.tabbedDownTop.bind(b),b.tabbedUpBottom=b.tabbedUpBottom.bind(b),b.tabbedDownBottom=b.tabbedDownBottom.bind(b),b.setHelper=b.setRef.bind(b,'helper'),b.setBlocker=b.setRef.bind(b,'blocker'),b.setTopFocus=b.setRef.bind(b,'topFocus'),b.setContainer=b.setRef.bind(b,'container'),b.setMessageContainer=b.setRef.bind(b,'messageContainer'),b.handleScroll=b.handleScroll.bind(b),b.state={top:'50%'},b}return g(j,a),e(j,[{key:'componentWillReceiveProps',value:function(a){var c=this;if(a.blocking!==this.props.blocking)if(a.blocking)this.helper&&this.helper.parentNode&&this.helper.parentNode.contains&&this.helper.parentNode.contains(b())&&(this.focused=b(),this.focused&&this.focused!==document.body&&(window.setImmediate||setTimeout)(function(){return c.topFocus&&c.topFocus.focus()}));else{this.detachListeners();var d=b();this.focused&&(!d||d===document.body||d===this.topFocus)&&(this.focused.focus(),this.focused=null)}a.keepInView&&(a.keepInView!==this.props.keepInView||a.blocking&&a.blocking!==this.props.blocking)&&(this.attachListeners(),this.keepInView(a))}},{key:'componentWillUnmount',value:function(){this.detachListeners()}},{key:'setRef',value:function(a,b){this[a]=b}},{key:'attachListeners',value:function(){window.addEventListener('scroll',this.handleScroll)}},{key:'detachListeners',value:function(){window.removeEventListener('scroll',this.handleScroll)}},{key:'blockingTab',value:function(a){var b=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return this.props.blocking&&('Tab'===a.key||9===a.keyCode)&&a.shiftKey==b}},{key:'tabbedUpTop',value:function(a){this.blockingTab(a)&&this.blocker.focus()}},{key:'tabbedDownTop',value:function(a){this.blockingTab(a)&&(a.preventDefault(),this.blocker.focus())}},{key:'tabbedUpBottom',value:function(a){this.blockingTab(a,!0)&&this.topFocus.focus()}},{key:'tabbedDownBottom',value:function(a){this.blockingTab(a,!0)&&(a.preventDefault(),this.topFocus.focus())}},{key:'keepInView',value:function(){var a=Math.max,b=Math.min,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.props;if(c.blocking&&c.keepInView&&this.container){var d=this.container.getBoundingClientRect(),e=window.innerHeight;if(d.top>e||0>d.bottom)return;if(0<=d.top&&d.bottom<=e)return void('50%'!==this.state.top&&this.setState({top:'50%'}));var f=this.messageContainer?this.messageContainer.getBoundingClientRect().height:0,g=a(b(e,d.bottom)-a(d.top,0),f)/2;0>d.top&&(g=b(g-d.top,d.height-f/2)),this.state.top!==g&&this.setState({top:g})}}},{key:'handleScroll',value:function(){this.keepInView()}},{key:'render',value:function(){var a=this.props,b=a.tag,d=a.blocking,e=a.className,g=a.children,i=a.message,j=a.loader,k=a.renderChildren,l=a.keepInView,m=h(a,['tag','blocking','className','children','message','loader','renderChildren','keepInView']),n=d?'block-ui '+e:e;return c.createElement(b,f({},m,{className:n,"aria-busy":d,ref:this.setContainer}),d&&c.createElement('div',{tabIndex:'0',onKeyUp:this.tabbedUpTop,onKeyDown:this.tabbedDownTop,ref:this.setTopFocus}),(!d||k)&&g,d&&c.createElement('div',{className:'block-ui-container',tabIndex:'0',ref:this.setBlocker,onKeyUp:this.tabbedUpBottom,onKeyDown:this.tabbedDownBottom},c.createElement('div',{className:'block-ui-overlay'}),c.createElement('div',{className:'block-ui-message-container',ref:this.setMessageContainer,style:{top:l?this.state.top:void 0}},c.createElement('div',{className:'block-ui-message'},i,c.isValidElement(j)?j:c.createElement(j,null)))),c.createElement('span',{ref:this.setHelper}))}}]),j}(a.Component);return j.defaultProps={tag:'div',renderChildren:!0,loader:function(){return c.createElement('div',{className:'loading-indicator'},c.createElement('span',{className:'loading-bullet'},'\u2022'),' ',c.createElement('span',{className:'loading-bullet'},'\u2022'),' ',c.createElement('span',{className:'loading-bullet'},'\u2022'))}},j}); | ||
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b(require('react')):'function'==typeof define&&define.amd?define(['react'],b):a.ReactBlockUi=b(a.React)})(this,function(a){'use strict';function b(a){a=a||document;var b;try{b=document.activeElement,b&&b.nodeName||(b=a.body)}catch(c){b=a.body}return b}var c='default'in a?a['default']:a,d=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},e=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},g=function(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},h=function(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c},i=function(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a},j=function(a){function j(a){d(this,j);var b=i(this,(j.__proto__||Object.getPrototypeOf(j)).call(this,a));return b.tabbedUpTop=b.tabbedUpTop.bind(b),b.tabbedDownTop=b.tabbedDownTop.bind(b),b.tabbedUpBottom=b.tabbedUpBottom.bind(b),b.tabbedDownBottom=b.tabbedDownBottom.bind(b),b.setHelper=b.setRef.bind(b,'helper'),b.setBlocker=b.setRef.bind(b,'blocker'),b.setTopFocus=b.setRef.bind(b,'topFocus'),b.setContainer=b.setRef.bind(b,'container'),b.setMessageContainer=b.setRef.bind(b,'messageContainer'),b.handleScroll=b.handleScroll.bind(b),b.state={top:'50%'},b}return g(j,a),e(j,[{key:'componentWillReceiveProps',value:function(a){var c=this;if(a.blocking!==this.props.blocking)if(a.blocking)this.helper&&this.helper.parentNode&&this.helper.parentNode.contains&&this.helper.parentNode.contains(b())&&(this.focused=b(),this.focused&&this.focused!==document.body&&(window.setImmediate||setTimeout)(function(){return c.focused&&c.focused.blur()}));else{this.detachListeners();var d=b();this.focused&&(!d||d===document.body||d===this.topFocus)&&(this.focused.focus(),this.focused=null)}a.keepInView&&(a.keepInView!==this.props.keepInView||a.blocking&&a.blocking!==this.props.blocking)&&(this.attachListeners(),this.keepInView(a))}},{key:'componentWillUnmount',value:function(){this.detachListeners()}},{key:'setRef',value:function(a,b){this[a]=b}},{key:'attachListeners',value:function(){window.addEventListener('scroll',this.handleScroll)}},{key:'detachListeners',value:function(){window.removeEventListener('scroll',this.handleScroll)}},{key:'blockingTab',value:function(a){var b=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return this.props.blocking&&('Tab'===a.key||9===a.keyCode)&&a.shiftKey==b}},{key:'tabbedUpTop',value:function(a){this.blockingTab(a)&&this.blocker.focus()}},{key:'tabbedDownTop',value:function(a){this.blockingTab(a)&&(a.preventDefault(),this.blocker.focus())}},{key:'tabbedUpBottom',value:function(a){this.blockingTab(a,!0)&&this.topFocus.focus()}},{key:'tabbedDownBottom',value:function(a){this.blockingTab(a,!0)&&(a.preventDefault(),this.topFocus.focus())}},{key:'keepInView',value:function(){var a=Math.max,b=Math.min,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.props;if(c.blocking&&c.keepInView&&this.container){var d=this.container.getBoundingClientRect(),e=window.innerHeight;if(d.top>e||0>d.bottom)return;if(0<=d.top&&d.bottom<=e)return void('50%'!==this.state.top&&this.setState({top:'50%'}));var f=this.messageContainer?this.messageContainer.getBoundingClientRect().height:0,g=a(b(e,d.bottom)-a(d.top,0),f)/2;0>d.top&&(g=b(g-d.top,d.height-f/2)),this.state.top!==g&&this.setState({top:g})}}},{key:'handleScroll',value:function(){this.keepInView()}},{key:'render',value:function(){var a=this.props,b=a.tag,d=a.blocking,e=a.className,g=a.children,i=a.message,j=a.loader,k=a.renderChildren,l=a.keepInView,m=h(a,['tag','blocking','className','children','message','loader','renderChildren','keepInView']),n=d?'block-ui '+e:e;return c.createElement(b,f({},m,{className:n,"aria-busy":d,ref:this.setContainer}),d&&c.createElement('div',{tabIndex:'0',onKeyUp:this.tabbedUpTop,onKeyDown:this.tabbedDownTop,ref:this.setTopFocus}),(!d||k)&&g,d&&c.createElement('div',{className:'block-ui-container',tabIndex:'0',ref:this.setBlocker,onKeyUp:this.tabbedUpBottom,onKeyDown:this.tabbedDownBottom},c.createElement('div',{className:'block-ui-overlay'}),c.createElement('div',{className:'block-ui-message-container',ref:this.setMessageContainer,style:{top:l?this.state.top:void 0}},c.createElement('div',{className:'block-ui-message'},i,c.isValidElement(j)?j:c.createElement(j,null)))),c.createElement('span',{ref:this.setHelper}))}}]),j}(a.Component);return j.defaultProps={tag:'div',renderChildren:!0,loader:function(){return c.createElement('div',{className:'loading-indicator'},c.createElement('span',{className:'loading-bullet'},'\u2022'),' ',c.createElement('span',{className:'loading-bullet'},'\u2022'),' ',c.createElement('span',{className:'loading-bullet'},'\u2022'))}},j}); | ||
//# sourceMappingURL=reactblockui.min.js.map |
@@ -72,7 +72,6 @@ 'use strict'; | ||
this.focused = (0, _safeActiveElement2.default)(); | ||
// We cannot just blur to remove focus due to IE bug so we must manually move the focus somewhere else. | ||
// https://www.tjvantoll.com/2013/08/30/bugs-with-document-activeelement-in-internet-explorer/#blurring-the-body-switches-windows-in-ie9-and-ie10 | ||
if (this.focused && this.focused !== document.body) { | ||
(window.setImmediate || setTimeout)(function () { | ||
return _this2.topFocus && _this2.topFocus.focus(); | ||
return _this2.focused && _this2.focused.blur(); | ||
}); | ||
@@ -79,0 +78,0 @@ } |
{ | ||
"name": "react-block-ui", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"author": "Evan Sharp <evan.sharp@availity.com>", | ||
@@ -5,0 +5,0 @@ "description": "Block UI for react", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
102015
1570