Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuke-mask

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-mask - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

<a name="2.1.4"></a>
## [2.1.4](https://gitlab.alibaba-inc.com/nuke/mask/compare/v2.1.3...v2.1.4) (2018-08-15)
### Bug Fixes
* eslint for import {isWeb} from nuke-env ([d856e2c](https://gitlab.alibaba-inc.com/nuke/mask/commit/d856e2c))
<a name="2.1.3"></a>

@@ -8,0 +20,0 @@ ## [2.1.3](https://gitlab.alibaba-inc.com/nuke/mask/compare/v2.1.2...v2.1.3) (2018-08-15)

2

lib/index.js

@@ -1,1 +0,1 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeView=require('nuke-view'),_nukeView2=_interopRequireDefault(_nukeView),_nukeEnv=require('nuke-env'),_nukeEnv2=_interopRequireDefault(_nukeEnv),_nukeTransition=require('nuke-transition'),_nukeTransition2=_interopRequireDefault(_nukeTransition),_nukeDimensions=require('nuke-dimensions'),_nukeDimensions2=_interopRequireDefault(_nukeDimensions);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj)0<=keys.indexOf(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var isWeb=_nukeEnv2.default.isWeb,isWeex=_nukeEnv2.default.isWeex,appInfo=_nukeEnv2.default.appInfo,Mask=function(_Component){function Mask(props){_classCallCheck(this,Mask);var _this=_possibleConstructorReturn(this,(Mask.__proto__||Object.getPrototypeOf(Mask)).call(this,props));_this.initFlag=!1;var visible=!0;return'defaultVisible'in props&&(visible=props.defaultVisible),_this.state={visible:visible},_this}return _inherits(Mask,_Component),_createClass(Mask,[{key:'shouldComponentUpdate',value:function shouldComponentUpdate(nextProps,nextState){return!!this.initFlag||(this.initFlag=!0,nextProps.style!==this.props.style||nextState.visible!==this.state.visible)}},{key:'componentDidMount',value:function componentDidMount(){this.state.visible&&(this.props.animate?this.animateShow():this.show())}},{key:'show',value:function show(){this.setState({visible:!0}),this.props.onShow&&this.props.onShow()}},{key:'change',value:function change(e){this.setState({visible:e.visible||!this.state.visible}),this.props.onVisibleChanged&&this.props.onVisibleChanged(e)}},{key:'componentDidUpdate',value:function componentDidUpdate(){this.state.visible&&this.props.animate&&this.animateShow()}},{key:'animateShow',value:function animateShow(){var _this2=this,box=(0,_rax.findDOMNode)(this.maskNode),_props=this.props,effect=_props.effect,duration=_props.duration;setTimeout(function(){box&&(0,_nukeTransition2.default)(box,{opacity:1},{timingFunction:effect,duration:duration},function(){_this2.props.onShow&&_this2.props.onShow()})},10)}},{key:'hide',value:function hide(){var _this3=this,_props2=this.props,animate=_props2.animate,effect=_props2.effect,duration=_props2.duration;if(animate){var box=this.maskNode;box&&(0,_nukeTransition2.default)(box,{opacity:0},{timingFunction:effect,duration:duration},function(){_this3.setState({visible:!1}),_this3.props.onHide&&_this3.props.onHide()})}else this.setState({visible:!1}),this.props.onHide&&this.props.onHide()}},{key:'maskPress',value:function maskPress(){this.props.maskClosable&&this.hide(),this.props.onMaskPress&&this.props.onMaskPress()}},{key:'emptyEvent',value:function emptyEvent(e){isWeb&&e.stopPropagation()}},{key:'getChildren',value:function getChildren(){var _this4=this,_props3=this.props,children=_props3.children,_props3$contentStyle=_props3.contentStyle,contentStyle=void 0===_props3$contentStyle?{}:_props3$contentStyle;return children?Array.isArray(children)?1===children.length?(0,_rax.cloneElement)(children[0],{onClick:function onClick(e){_this4.emptyEvent(e)}}):(0,_rax.createElement)(_nukeView2.default,{style:contentStyle,x:'autowrap',onClick:function onClick(e){return _this4.emptyEvent(e)}},children):(0,_rax.cloneElement)(children,{onClick:function onClick(e){_this4.emptyEvent(e)}}):null}},{key:'render',value:function render(){var _this5=this,visible=this.state.visible,_props4=this.props,content=_props4.content,children=_props4.children,_props4$style=_props4.style,style=void 0===_props4$style?{}:_props4$style,onVisibleChanged=_props4.onVisibleChanged,onClick=_props4.onClick,_props4$noPress=_props4.noPress,others=_objectWithoutProperties(_props4,['content','children','style','onVisibleChanged','onClick','noPress']);if(isWeex){var nativeAttrs=_extends({},others,{style:['iOS'===appInfo.platform?styles.maskNativeIOS:{},style],onClick:function(e){return _this5.maskPress(e)},onVisibleChanged:function(e){return _this5.change(e)}});void 0!==_props4$noPress&&_props4$noPress&&delete nativeAttrs.onClick;var maskWeex=visible?(0,_rax.createElement)('mask',_extends({ref:function ref(n){_this5.maskNode=(0,_rax.findDOMNode)(n)}},nativeAttrs),this.getChildren()):null;return maskWeex}return visible?(0,_rax.createElement)('div',_extends({},others,{ref:function ref(n){_this5.maskNode=(0,_rax.findDOMNode)(n)},style:[styles.maskWeb,style],onClick:function(e){return _this5.maskPress(e)}}),this.getChildren()):null}}]),Mask}(_rax.Component),styles={maskNativeIOS:{position:'absolute',width:750,height:Math.round(_nukeDimensions2.default.get('screen').height/window.devicePixelRatio)+'wx'},maskWeb:{display:'flex',boxSizing:'border-box',flexDirection:'column',alignContent:'flex-start',flexShrink:0,position:'fixed',top:0,left:0,right:0,bottom:0,zIndex:100},transparent:{opacity:0},shown:{opacity:1}};Mask.propTypes={},Mask.defaultProps={animate:!0,effect:'ease-in-out',duration:200,contentStyle:{}},exports.default=Mask,module.exports=exports['default'];
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeView=require('nuke-view'),_nukeView2=_interopRequireDefault(_nukeView),_nukeEnv=require('nuke-env'),_nukeTransition=require('nuke-transition'),_nukeTransition2=_interopRequireDefault(_nukeTransition),_nukeDimensions=require('nuke-dimensions'),_nukeDimensions2=_interopRequireDefault(_nukeDimensions);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj)0<=keys.indexOf(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return call&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)throw new TypeError('Super expression must either be null or a function, not '+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Mask=function(_Component){function Mask(props){_classCallCheck(this,Mask);var _this=_possibleConstructorReturn(this,(Mask.__proto__||Object.getPrototypeOf(Mask)).call(this,props));_this.initFlag=!1;var visible=!0;return'defaultVisible'in props&&(visible=props.defaultVisible),_this.state={visible:visible},_this}return _inherits(Mask,_Component),_createClass(Mask,[{key:'shouldComponentUpdate',value:function shouldComponentUpdate(nextProps,nextState){return!!this.initFlag||(this.initFlag=!0,nextProps.style!==this.props.style||nextState.visible!==this.state.visible)}},{key:'componentDidMount',value:function componentDidMount(){this.state.visible&&(this.props.animate?this.animateShow():this.show())}},{key:'show',value:function show(){this.setState({visible:!0}),this.props.onShow&&this.props.onShow()}},{key:'change',value:function change(e){this.setState({visible:e.visible||!this.state.visible}),this.props.onVisibleChanged&&this.props.onVisibleChanged(e)}},{key:'componentDidUpdate',value:function componentDidUpdate(){this.state.visible&&this.props.animate&&this.animateShow()}},{key:'animateShow',value:function animateShow(){var _this2=this,box=(0,_rax.findDOMNode)(this.maskNode),_props=this.props,effect=_props.effect,duration=_props.duration;setTimeout(function(){box&&(0,_nukeTransition2.default)(box,{opacity:1},{timingFunction:effect,duration:duration},function(){_this2.props.onShow&&_this2.props.onShow()})},10)}},{key:'hide',value:function hide(){var _this3=this,_props2=this.props,animate=_props2.animate,effect=_props2.effect,duration=_props2.duration;if(animate){var box=this.maskNode;box&&(0,_nukeTransition2.default)(box,{opacity:0},{timingFunction:effect,duration:duration},function(){_this3.setState({visible:!1}),_this3.props.onHide&&_this3.props.onHide()})}else this.setState({visible:!1}),this.props.onHide&&this.props.onHide()}},{key:'maskPress',value:function maskPress(){this.props.maskClosable&&this.hide(),this.props.onMaskPress&&this.props.onMaskPress()}},{key:'emptyEvent',value:function emptyEvent(e){_nukeEnv.isWeb&&e.stopPropagation()}},{key:'getChildren',value:function getChildren(){var _this4=this,_props3=this.props,children=_props3.children,_props3$contentStyle=_props3.contentStyle,contentStyle=void 0===_props3$contentStyle?{}:_props3$contentStyle;return children?Array.isArray(children)?1===children.length?(0,_rax.cloneElement)(children[0],{onClick:function onClick(e){_this4.emptyEvent(e)}}):(0,_rax.createElement)(_nukeView2.default,{style:contentStyle,x:'autowrap',onClick:function onClick(e){return _this4.emptyEvent(e)}},children):(0,_rax.cloneElement)(children,{onClick:function onClick(e){_this4.emptyEvent(e)}}):null}},{key:'render',value:function render(){var _this5=this,visible=this.state.visible,_props4=this.props,content=_props4.content,children=_props4.children,_props4$style=_props4.style,style=void 0===_props4$style?{}:_props4$style,onVisibleChanged=_props4.onVisibleChanged,onClick=_props4.onClick,_props4$noPress=_props4.noPress,others=_objectWithoutProperties(_props4,['content','children','style','onVisibleChanged','onClick','noPress']);if(_nukeEnv.isWeex){var nativeAttrs=_extends({},others,{style:['iOS'===_nukeEnv.appInfo.platform?styles.maskNativeIOS:{},style],onClick:function(e){return _this5.maskPress(e)},onVisibleChanged:function(e){return _this5.change(e)}});void 0!==_props4$noPress&&_props4$noPress&&delete nativeAttrs.onClick;var maskWeex=visible?(0,_rax.createElement)('mask',_extends({ref:function ref(n){_this5.maskNode=(0,_rax.findDOMNode)(n)}},nativeAttrs),this.getChildren()):null;return maskWeex}return visible?(0,_rax.createElement)('div',_extends({},others,{ref:function ref(n){_this5.maskNode=(0,_rax.findDOMNode)(n)},style:[styles.maskWeb,style],onClick:function(e){return _this5.maskPress(e)}}),this.getChildren()):null}}]),Mask}(_rax.Component),styles={maskNativeIOS:{position:'absolute',width:750,height:Math.round(_nukeDimensions2.default.get('screen').height/window.devicePixelRatio)+'wx'},maskWeb:{display:'flex',boxSizing:'border-box',flexDirection:'column',alignContent:'flex-start',flexShrink:0,position:'fixed',top:0,left:0,right:0,bottom:0,zIndex:100},transparent:{opacity:0},shown:{opacity:1}};Mask.propTypes={},Mask.defaultProps={animate:!0,effect:'ease-in-out',duration:200,contentStyle:{}},exports.default=Mask,module.exports=exports['default'];
{
"name": "nuke-mask",
"version": "2.1.3",
"version": "2.1.4",
"description": "遮罩层",

@@ -57,4 +57,4 @@ "main": "lib/index",

"nuke-env": "^2.1.3",
"nuke-transition": "^2.1.3",
"nuke-view": "^2.1.3"
"nuke-transition": "^2.1.4",
"nuke-view": "^2.1.4"
},

@@ -68,6 +68,6 @@ "devDependencies": {

"eslint-plugin-react": "7.1.0",
"nuke-button": "^2.1.3",
"nuke-button": "^2.1.4",
"nuke-checkbox": "^2.1.3",
"nuke-input": "^2.1.3",
"nuke-page": "^2.1.3",
"nuke-input": "^2.1.4",
"nuke-page": "^2.1.4",
"nuke-text": "^2.1.3"

@@ -79,3 +79,3 @@ },

"license": "Apache",
"gitHead": "c5505fdafa2a561e741007ab32582394b5f028aa"
"gitHead": "8b2a213253ed6cdf6d613a10bea387e80043fa6a"
}
'use strict';
/** @jsx createElement */
import { Component, createElement, cloneElement, findDOMNode } from 'rax';
import View from 'nuke-view';
import Env from 'nuke-env';
import { isWeb, isWeex, appInfo } from 'nuke-env';
import Transition from 'nuke-transition';
import Dimensions from 'nuke-dimensions';
const { isWeb, isWeex, appInfo } = Env;

@@ -20,3 +20,3 @@ class Mask extends Component {

this.state = {
visible: visible
visible,
};

@@ -27,6 +27,3 @@ }

this.initFlag = true;
return (
nextProps.style !== this.props.style ||
nextState.visible !== this.state.visible
);
return nextProps.style !== this.props.style || nextState.visible !== this.state.visible;
}

@@ -68,3 +65,3 @@ return true;

timingFunction: effect,
duration: duration
duration,
},

@@ -88,3 +85,3 @@ () => {

timingFunction: effect,
duration: duration
duration,
},

@@ -99,3 +96,3 @@ () => {

this.setState({
visible: false
visible: false,
});

@@ -122,5 +119,5 @@ this.props.onHide && this.props.onHide();

return cloneElement(children, {
onClick: e => {
onClick: (e) => {
this.emptyEvent(e);
}
},
});

@@ -130,36 +127,23 @@ }

return cloneElement(children[0], {
onClick: e => {
onClick: (e) => {
this.emptyEvent(e);
}
},
});
} else {
return (
<View
style={contentStyle}
x="autowrap"
onClick={e => this.emptyEvent(e)}
>
{children}
</View>
);
}
return (
<View style={contentStyle} x="autowrap" onClick={e => this.emptyEvent(e)}>
{children}
</View>
);
}
render() {
const { visible } = this.state;
const {
content,
children,
style = {},
onVisibleChanged,
onClick,
noPress = false,
...others
} = this.props;
const { content, children, style = {}, onVisibleChanged, onClick, noPress = false, ...others } = this.props;
if (isWeex) {
let nativeAttrs = {
const nativeAttrs = {
...others,
style: [appInfo.platform === 'iOS' ? styles.maskNativeIOS : {}, style],
onClick: e => this.maskPress(e),
onVisibleChanged: e => this.change(e)
onVisibleChanged: e => this.change(e),
};

@@ -169,5 +153,5 @@ if (noPress) {

}
let maskWeex = visible ? (
const maskWeex = visible ? (
<mask
ref={n => {
ref={(n) => {
this.maskNode = findDOMNode(n);

@@ -181,16 +165,15 @@ }}

return maskWeex;
} else {
return visible ? (
<div
{...others}
ref={n => {
this.maskNode = findDOMNode(n);
}}
style={[styles.maskWeb, style]}
onClick={e => this.maskPress(e)}
>
{this.getChildren()}
</div>
}
return visible ? (
<div
{...others}
ref={(n) => {
this.maskNode = findDOMNode(n);
}}
style={[styles.maskWeb, style]}
onClick={e => this.maskPress(e)}
>
{this.getChildren()}
</div>
) : null;
}
}

@@ -204,3 +187,3 @@ }

// To get fullscreen mask , we set screen height
height: Math.round(Dimensions.get('screen').height / window.devicePixelRatio) + 'wx'
height: `${Math.round(Dimensions.get('screen').height / window.devicePixelRatio)}wx`,
},

@@ -219,14 +202,12 @@

bottom: 0,
zIndex: 100
zIndex: 100,
},
transparent: {
opacity: 0
opacity: 0,
},
shown: {
opacity: 1
}
opacity: 1,
},
};
Mask.propTypes = {
};
Mask.propTypes = {};
Mask.defaultProps = {

@@ -237,3 +218,3 @@ animate: true,

contentStyle: {},
}
};
export default Mask;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc