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.2.29 to 2.3.0

16

CHANGELOG.md

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

# [2.3.0](https://gitlab.alibaba-inc.com/nuke/mask/compare/v2.2.29...v2.3.0) (2018-11-14)
### Bug Fixes
* liscene fix ([ff9b7fd](https://gitlab.alibaba-inc.com/nuke/mask/commit/ff9b7fd))
### Features
* 将UI组件与功能库拆分 ([f5d0a2c](https://gitlab.alibaba-inc.com/nuke/mask/commit/f5d0a2c))
## [2.2.29](https://gitlab.alibaba-inc.com/nuke/mask/compare/v2.2.28...v2.2.29) (2018-10-09)

@@ -8,0 +24,0 @@

20

docs/advanced.md

@@ -1,8 +0,26 @@

# Mask 遮罩层 Demo
# Mask 遮罩层 模拟浮层效果
* order: 1
- title_en: simulate floating layer effect
Mask 模拟浮层效果
---
```js
<NukePlayGround>
<Button type="primary" onPress={e => this.showMask()}>打开浮层(空白区域不能关闭)</Button>
<Mask
defaultVisible={false}
noPress={true}
ref="myMask"
animate={true}
style={styles.mask}
contentStyle={styles.body}
>
...
</Mask>
</NukePlayGround>
```
---

@@ -9,0 +27,0 @@ ```js

117

docs/basic.md

@@ -1,13 +0,21 @@

# Mask 遮罩层 Demo
#Mask 基础用法
- order: 0
- title_en: Mask basic usage
Mask 基础用法
---
```js
<NukePlayGround>
<Mask onShow={func} onHide={func} ref="myMask" maskClosable={true}>
{children}
</Mask>
</NukePlayGround>
```
---
````js
```js
/** @jsx createElement */
import {createElement, Component,findDOMNode,render} from 'rax';
import { createElement, Component, findDOMNode, render } from 'rax';
import View from 'nuke-view';

@@ -21,6 +29,6 @@ import Text from 'nuke-text';

super();
this.state={
maskVisible : false,
log : ''
}
this.state = {
maskVisible: false,
log: ''
};
this.onShow = this.onShow.bind(this);

@@ -31,21 +39,22 @@ this.onHide = this.onHide.bind(this);

showMask(e){
showMask(e) {
this.refs.myMask.show();
}
onVisibleChanged=(e)=>{
}
hideMask(e){
onVisibleChanged = (e) => {};
hideMask(e) {
this.refs.myMask.hide();
}
onShow(e){
this.setState({log:this.state.log.concat('\n触发 onShow 事件')});
onShow(e) {
this.setState({ log: this.state.log.concat('\n onShow event') });
}
onHide(e){
this.setState({log:this.state.log.concat('\n触发 onHide 事件')});
onHide(e) {
this.setState({ log: this.state.log.concat('\n onHide event') });
}
renderOverlay(){
renderOverlay() {
return (
<View style={styles.dialogWrap}>
<Text style={styles.text}>点击外层 mask 区域可关闭</Text>
<Button type="primary" style={styles.btn} onPress={(e)=>this.hideMask(e)}>关闭</Button>
<Text style={styles.text}>touch background area will close window</Text>
<Button type="primary" style={styles.btn} onPress={(e) => this.hideMask(e)}>
Close
</Button>
</View>

@@ -57,49 +66,45 @@ );

<Page title="Mask">
<Page.Intro main="普通用法"></Page.Intro>
<Button type="primary" onPress={(e)=>this.showMask(e)}>打开浮层</Button>
<Mask
onShow={this.onShow}
onHide={this.onHide}
defaultVisible={true}
onVisibleChanged={this.onVisibleChanged}
ref="myMask"
animate={false}
style={styles.mask}
maskClosable={true}
>
<Page.Intro main="normal" />
<Button type="primary" onPress={(e) => this.showMask(e)}>
open Overlay
</Button>
<Mask
onShow={this.onShow}
onHide={this.onHide}
defaultVisible={true}
onVisibleChanged={this.onVisibleChanged}
ref="myMask"
animate={false}
style={styles.mask}
maskClosable={true}>
{this.renderOverlay()}
</Mask>
<Text style={{whiteSpace:'pre-wrap',fontSize:28,color:'grey'}}>{this.state.log}</Text>
<Text style={{ whiteSpace: 'pre-wrap', fontSize: 28, color: 'grey' }}>{this.state.log}</Text>
</Page>
);
}
}
const styles={
mask:{
flex:1,
width:750,
}
};
const styles = {
mask: {
flex: 1,
width: 750,
alignItems: 'center',
justifyContent: 'center',
backgroundColor:'rgba(0,0,0,0.7)'
backgroundColor: 'rgba(0,0,0,0.7)'
},
dialogWrap:{
width:600,
dialogWrap: {
width: 600,
height: 300,
padding:30,
padding: 30,
alignItems: 'center',
justifyContent: 'center',
backgroundColor:'#ffffff'
backgroundColor: '#ffffff'
},
text:{
marginBottom:20,
fontSize:32,
flex:1,
text: {
marginBottom: 20,
fontSize: 32,
flex: 1
}
}
render(<App/>);
````
};
render(<App />);
```
{
"name": "nuke-mask",
"version": "2.2.29",
"version": "2.3.0",
"description": "遮罩层",

@@ -55,13 +55,13 @@ "main": "lib/index",

"dependencies": {
"nuke-dimensions": "^2.2.29",
"nuke-env": "^2.2.29",
"nuke-transition": "^2.2.29",
"nuke-view": "^2.2.29"
"nuke-dimensions": "^2.3.0",
"nuke-env": "^2.3.0",
"nuke-transition": "^2.3.0",
"nuke-view": "^2.3.0"
},
"devDependencies": {
"nuke-button": "^2.2.29",
"nuke-checkbox": "^2.2.29",
"nuke-input": "^2.2.29",
"nuke-page": "^2.2.29",
"nuke-text": "^2.2.29"
"nuke-button": "^2.3.0",
"nuke-checkbox": "^2.3.0",
"nuke-input": "^2.3.0",
"nuke-page": "^2.3.0",
"nuke-text": "^2.3.0"
},

@@ -71,4 +71,4 @@ "publishConfig": {

},
"license": "Apache",
"gitHead": "0375bb11b20b155440e12aa572843944be7d8760"
"license": "Apache-2.0",
"gitHead": "454e1430a04b6e345edb1d2632b1e051408d070d"
}

@@ -8,42 +8,33 @@ # Mask

---
<a href="http://nuke.alibaba-inc.com/" target="_blank"> Nuke UI </a>
![nuke-mask@ALINPM](http://web.npm.alibaba-inc.com/badge/v/nuke-mask.svg?style=flat-square) ![nuke-mask@ALINPM](http://web.npm.alibaba-inc.com/badge/d/nuke-mask.svg?style=flat-square)
## Usage
## Design
As a simple mask layer, Mask component is usually used to display dialogs, prompt and so on.
This component is used as mask layer of a popup window, and controls the whole popup window show or hide.
<img src="https://img.alicdn.com/tfs/TB1AlB.SFXXXXarXVXXXXXXXXXX-1242-2208.png" width="240" />
## Implement Structure
This component implement use weex `mask` component, and use `div` and absolute layout in web environment.
**New web side support**
**Notice** This component use aliweex sdk , so your app needs to integrate it.
**Pay attention to the android client whose weex is less than 0.15 version, Mask may have compatibility problem. Caution!**
Mask is encapsulated as a `mask` component in native side and encapsulated by `View` component in web side. So if you want to achieve the effect of blocking the full screen, you'd better follow the requirements for component hierarchy and style writing like this:
- The root node of the page can't have any styles such as padding, margin, border ( make sure that the edges didn't overflow ).
- Mask should be the last child element of the root node ( make sure of the View stack sequence)
## API
Attribute | Explanation | Type | Default
-----|-----|-----|-----
style | style object |obj |
animate| animation is enabled while showing |boolean|true
effect | Effects of animation if `animate=true`, enumerated values:`ease-in` `ease-in-out` `ease-out` `linear` `cubic-bezier` |string|`ease-in-out`
maskClosable| closing with clicking on blank area|boolean|false
duration | animation duration(ms) |number|200
contentStyle| contentStyle, it may be used if children of the Mask is not only one ( See the following explanation )| obj |
| Props | Description | Type | Default |
| ------------ | ------------------------------------------------------------------------------------------------------------------ | -------- | ------------- |
| style | style object | obj |
| animate | animation is enabled while showing | boolean | true |
| effect | Animation effects if `animate=true`, enumerated values:`ease-in` `ease-in-out` `ease-out` `linear` `cubic-bezier` | string | `ease-in-out` |
| maskClosable | is closable when touching mask grey area | boolean | false |
| duration | animation duration(ms) | number | 200 |
| contentStyle | contentStyle | obj |
| onShow | 浮层展示后的回调 | function |
| onHide | 浮层隐藏后的回调 | function |
### About contentStyle
If the Mask has more than one child component inside it, we will put a View on the outside of the children by default. Using contentStyle is in order to control the style of this View.
If Mask has more than one child inside it, we will add an extra View node as parent. ContentStyle props will be added to this parent node.
<img src="https://img.alicdn.com/tfs/TB1LYU0kPihSKJjy0FlXXadEXXa-1100-750.png" width="600" />
### Instance Methods:

@@ -54,167 +45,2 @@

## Demo Reference
<img src="https://img.alicdn.com/tfs/TB1AlB.SFXXXXarXVXXXXXXXXXX-1242-2208.png" width="240" />
Sweep the qr code to preview( use apps like Taobao, Qianniu, Tmall... )
<img src="https://img.alicdn.com/tfs/TB1lpKqSFXXXXcvXpXXXXXXXXXX-280-280.png" width="160" />
## How To Use
- Install
```bash
// Switch to your rax project
tnpm i nuke-mask --save
// following that demo, maybe you also need this...
// tnpm i nuke-view nuke-text nuke-checkbox nuke-button nuke-page --save
```
- Example
```js
/** @jsx createElement */
import {createElement, Component,render} from 'rax';
import Input from 'nuke-input';
import View from 'nuke-view';
import Text from 'nuke-text';
import Env from 'nuke-env';
import Checkbox from 'nuke-checkbox';
import Button from 'nuke-button';
import Mask from 'nuke-mask';
import Page from 'nuke-page';
const {isWeb} =Env;
let App = class NukeDemoIndex extends Component {
constructor() {
super();
this.GroupFruit = [
{value: 'zj', label: '浙江'},
{value: 'ah', label: '安徽'},
{value: 'sh', label: '上海'}
];
this.state = {
fruitChecked:['ah'],
}
}
showMask(){
this.refs.myMask.show();
}
hideMask(){
this.refs.myMask.hide();
}
onChange =(value) =>{
this.setState({
fruitChecked:value
})
}
render() {
return (
<Page title="Mask">
<Page.Intro main="浮层中嵌入简易表单操作"></Page.Intro>
<View style={styles.result}>
{this.state.fruitChecked ? <Text style={styles.resultText}>已选择: {this.state.fruitChecked.join(',')}</Text> :null}
</View>
<Button type="primary" onPress={(e)=>this.showMask()}>打开浮层(空白区域不能关闭)</Button>
<Mask defaultVisible={false} ref="myMask" animate={true} style={styles.mask} contentStyle={styles.body}>
<View style={styles.head}><Text style={styles.textHead}>选择区域</Text></View>
<View style={styles.topicsWrap}>
<Checkbox.Group value={this.state.fruitChecked} onChange={ this.onChange } size="small" dataSource={ this.GroupFruit } style={{marginRight:10}}></Checkbox.Group>
</View>
<View style={styles.footer}>
<Button rect block style={styles.dlgBtn} type="primary" size="large" onPress={()=>this.hideMask()}>确定</Button>
</View>
</Mask>
</Page>
);
}
}
const styles={
textarea:{
// position:'absolute'
width: 600,
height: 200,
borderWidth:1,
borderStyle:'solid',
borderColor:'#cccccc'
},
mask:{
flex:1,
backgroundColor:'rgba(0,0,0,0.7)',
justifyContent: 'flex-end',
},
body: {
width: 750,
height: 468,
borderRadius: 8,
paddingTop:30,
borderRadius:'8,
backgroundColor: '#ffffff',
},
head:{
height: 60,
alignItems: 'center',
justifyContent: 'center',
borderBottomColor:'#eeeeee',
borderBottomStyle:'solid',
borderBottomWidth:1,
},
textHead:{
color:'#3d4145',
fontSize: 32,
},
topics:{
paddingLeft: 40,
paddingRight: 40,
flexDirection:'row',
},
text:{
fontSize: 28,
padding: 10,
color:'#3089dc',
borderColor:'#3089dc',
borderStyle:'solid',
borderWidth: 1,
marginRight: 20
},
footer: {
borderTopColor:'#dddddd',
flexDirection:'row',
borderTopStyle:'solid',
borderTopWidth: 1,
alignItems: 'center',
justifyContent: 'flex-end',
height: 94
},
dlgBtn:{
flex:1,
},
result : {
height: 480,
margin: 30,
padding: 10,
backgroundColor:'#ffffff',
justifyContent:'center',
alignItems:'center'
},
resultText : {
fontSize: 28
},
}
render(<App/>);
```
## The Other
- Chat with <a href="dingtalk://dingtalkclient/action/sendmsg?dingtalk_id=kjwo3w5">@翊晨[yichen]</a> in Dingtalk desktop App <a href='https://tms.dingtalk.com/markets/dingtalk/download'>Download</a>
- DingTalk Group
<img src="https://img.alicdn.com/tfs/TB101EESpXXXXXFXpXXXXXXXXXX-1122-1362.jpg" width="260" />

@@ -8,33 +8,26 @@ # Mask

---
<a href="http://nuke.alibaba-inc.com/" target="_blank"> Nuke UI </a>
![nuke-mask@ALINPM](http://web.npm.alibaba-inc.com/badge/v/nuke-mask.svg?style=flat-square) ![nuke-mask@ALINPM](http://web.npm.alibaba-inc.com/badge/d/nuke-mask.svg?style=flat-square)
## 何时使用
Mask 是一个简单的遮罩层,常用于展示上层的对话框、提示等
## 设计思路
**新增 web 端支持**
Mask 是一个简单的遮罩层,常用于展示上层的对话框、自定义浮层,如图:
**注意 weex < 0.15 的安卓客户端,mask 可能存在兼容性问题,请慎用**
<img src="https://img.alicdn.com/tfs/TB1AlB.SFXXXXarXVXXXXXXXXXX-1242-2208.png" width="240" />
Mask 在 native 端封装了 `mask` 组件,在 web 端使用 View 封装,因此如果要实现遮挡全屏的效果,对组件层级和样式书写有如下要求:
Mask 在 native 端封装了 `mask` 组件,在 web 端使用 View + 全屏绝对定位布局进行封装。
- 页面根节点不能有任何 padding、margin、border 样式 (确保边缘不漏出来)
- Mask 组件必须是根节点的最后一个子元素 (确保 View 堆叠顺序)
**注意** Mask 依赖 aliweex 提供的 mask 组件,因此客户端内需要集成 aliweex sdk。
## API
参数 | 说明 | 类型 | 默认值
-----|-----|-----|-----
style | 样式object |obj |
animate| 显示时是否开启动画|boolean|true
effect | 显示的动画效果,animate = true 时生效,枚举值可选:ease-in,ease-in-out,ease-out,linear,cubic-bezier|string|'ease-in-out'
maskClosable| 能否点击空白区域关闭|boolean|false
duration | 动画时长,默认 200(单位是 ms)|number|200
contentStyle| 内容 style, 如果 Mask 的Children 数量超过1个,可能需要使用。参见如下解释| obj|
| 参数 | 说明 | 类型 | 默认值 |
| ------------ | --------------------------------------------------------------------------------------------------- | -------- | ------------- |
| style | 样式object | obj |
| animate | 显示时是否开启动画 | boolean | true |
| effect | 显示的动画效果,animate = true 时生效,枚举值可选:ease-in,ease-in-out,ease-out,linear,cubic-bezier | string | 'ease-in-out' |
| maskClosable | 能否点击空白区域关闭 | boolean | false |
| duration | 动画时长,默认 200(单位是 ms) | number | 200 |
| contentStyle | 内容 style, 如果 Mask 的Children 数量超过1个,可能需要使用。参见如下解释 | obj |
| onShow | 浮层展示后的回调 | function |
| onHide | 浮层隐藏后的回调 | function |

@@ -49,172 +42,10 @@ ### 关于 contentStyle

### 实例方法:
### 实例方法控制浮层显隐
你可以预埋一个 Mask 节点到 dom 元素中,然后找到 mask 实例,通过实例方法控制浮层显隐。
- this.refs.myMask.show() : 显示浮层
- this.refs.myMask.hide() : 关闭浮层
## demo 参考
<img src="https://img.alicdn.com/tfs/TB1AlB.SFXXXXarXVXXXXXXXXXX-1242-2208.png" width="240" />
扫码预览(手淘、千牛、天猫等)
<img src="https://img.alicdn.com/tfs/TB1lpKqSFXXXXcvXpXXXXXXXXXX-280-280.png" width="160" />
## 使用方法
- 安装
```bash
// 切换到你的 rax 项目中
tnpm i nuke-mask --save
// 参考如下 demo 您可能还需要安装
// tnpm i nuke-view nuke-text nuke-checkbox nuke-button nuke-page --save
```
- 调用示例
```js
/** @jsx createElement */
import {createElement, Component,render} from 'rax';
import Input from 'nuke-input';
import View from 'nuke-view';
import Text from 'nuke-text';
import Env from 'nuke-env';
import Checkbox from 'nuke-checkbox';
import Button from 'nuke-button';
import Mask from 'nuke-mask';
import Page from 'nuke-page';
const {isWeb} =Env;
let App = class NukeDemoIndex extends Component {
constructor() {
super();
this.GroupFruit = [
{value: 'zj', label: '浙江'},
{value: 'ah', label: '安徽'},
{value: 'sh', label: '上海'}
];
this.state = {
fruitChecked:['ah'],
}
}
showMask(){
this.refs.myMask.show();
}
hideMask(){
this.refs.myMask.hide();
}
onChange =(value) =>{
this.setState({
fruitChecked:value
})
}
render() {
return (
<Page title="Mask">
<Page.Intro main="浮层中嵌入简易表单操作"></Page.Intro>
<View style={styles.result}>
{this.state.fruitChecked ? <Text style={styles.resultText}>已选择: {this.state.fruitChecked.join(',')}</Text> :null}
</View>
<Button type="primary" onPress={(e)=>this.showMask()}>打开浮层(空白区域不能关闭)</Button>
<Mask defaultVisible={false} ref="myMask" animate={true} style={styles.mask} contentStyle={styles.body}>
<View style={styles.head}><Text style={styles.textHead}>选择区域</Text></View>
<View style={styles.topicsWrap}>
<Checkbox.Group value={this.state.fruitChecked} onChange={ this.onChange } size="small" dataSource={ this.GroupFruit } style={{marginRight:10}}></Checkbox.Group>
</View>
<View style={styles.footer}>
<Button rect block style={styles.dlgBtn} type="primary" size="large" onPress={()=>this.hideMask()}>确定</Button>
</View>
</Mask>
</Page>
);
}
}
const styles={
textarea:{
// position:'absolute'
width: '600rem',
height: '200rem',
borderWidth:'1rem',
borderStyle:'solid',
borderColor:'#cccccc'
},
mask:{
flex:1,
backgroundColor:'rgba(0,0,0,0.7)',
justifyContent: 'flex-end',
},
body: {
width: '750rem',
height: '468rem',
borderRadius:'8rem',
paddingTop:30,
borderRadius:'8rem',
backgroundColor: '#ffffff',
},
head:{
height: 60,
alignItems: 'center',
justifyContent: 'center',
borderBottomColor:'#eeeeee',
borderBottomStyle:'solid',
borderBottomWidth:'1rem',
},
textHead:{
color:'#3d4145',
fontSize:32,
},
topics:{
paddingLeft:40,
paddingRight:40,
flexDirection:'row',
},
text:{
fontSize:'28rem',
padding:'10rem',
color:'#3089dc',
borderColor:'#3089dc',
borderStyle:'solid',
borderWidth:'1rem',
marginRight:'20rem'
},
footer: {
borderTopColor:'#dddddd',
flexDirection:'row',
borderTopStyle:'solid',
borderTopWidth:1,
alignItems: 'center',
justifyContent: 'flex-end',
height: '94rem'
},
dlgBtn:{
flex:1,
},
result : {
height:'480rem',
margin:'30rem',
padding:'10rem',
backgroundColor:'#ffffff',
justifyContent:'center',
alignItems:'center'
},
resultText : {
fontSize:'28rem'
},
}
render(<App/>);
```
## 其他
- bug、建议联系 <a href="dingtalk://dingtalkclient/action/sendmsg?dingtalk_id=kjwo3w5">@翊晨</a>
- 钉钉交流群
<img src="https://img.alicdn.com/tfs/TB101EESpXXXXXFXpXXXXXXXXXX-1122-1362.jpg" width="260" />
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