
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
A helper cross-platform tool for muti-miniprograms that can more convenient to use modal components.
A helper cross-platform tool for miniprograms that can more convenient to use modal components.
$ npm install --save mp-modal
// pages/index/index.js
Page({
showModal() {
this.setData({
visible: true,
detail: {
title: 'modal title',
content: 'modal content'
}
})
},
hideModal() {
this.setData({ visible: false })
},
onModalConfirm(e) {
this.hideModal();
console.log('confirmd', e);
},
onModalCancel(e) {
this.hideModal();
console.log('canceled', e);
},
})
<!--page/index/index.wxss-->
<button type="default" bindtap="showModal" >Open Modal</button>
<modal shown="{{visible}}" detail="{{detail}}" bindconfirm="onModalConfirm" bindcancel="onModalCancel" bindclose="onModalCancel"></modal>
//pages/index/index.js
import { Modal } from 'mp-modal';
const modal = new Modal({ name: 'modal' });
Page({
showModal() {
modal.bind(this).show({
title: 'modal title',
content: 'modal content'
})
.then(e => console.log('confirmd', e))
.catch(e => console.error(e));
}
})
<!--pages/index/index.wxml-->
<button type="default" bindtap="showModal" >Open Modal</button>
<modal shown="{{modal.visible}}" detail="{{modal.data}}" bindconfirm="{{modal.success}}" bindcancel="{{modal.fail}}" bindclose="{{modal.fial}}"></modal>
import { Component } from '@tarojs/taro'
import { View, Button } from '@tarojs/components'
import MyModal from '../modal/modal';
import { Modal } from 'mp-modal';
const modal = new Modal();
export default class Index extends Component {
showModal() {
modal.bind(this).show({
title: 'modal title',
content: 'modal content'
})
.then((e) => console.log('confirmed', e))
.catch(e => console.log('canceled or closed', e))
}
render() {
return
<View className='index'>
<Button type="default" onClick={this.showModal.bind(this)} >Open Modal</Button>
<MyModal shown={modal.visible()} detail={modal.data()} onConfirm={modal.success()} onCancel={modal.fail()} onClose={modal.fail()} />
</View >
}
}
The modal constructor.
In a native miniprogram application, the name option must be set and must be a string type of data.
true.import { Modal } from 'mp-modal';
const modal = new Modal({ name: 'myModal' });
Page({
onRead(){
modal.bind(this);
},
showModal(){
modal.show();
}
})
<modal shown="{{modal.visible}}" bindconfirm="{{modal.success}}" bindcancel="{{modal.fail}}"/>
Bind this argument(page or component object) for current modal. You must bind a page or component object for current modal before calling the show method.
import { Modal } from 'mp-modal';
const modal=new Modal({name:'myModal'});
Page({
onRead(){
modal.bind(this);
},
showModal(){
modal.show();
}
})
Hide the modal.
The show method will invoke method
setDatato bind data{[name]:{visible:false}}for current page or component.
Show modal.
The show method will invoke method
setDatato bind data{[name]:{data, visible:true},...extra}for current page or component.
import { Modal } from 'mp-modal';
const modal=new Modal({name: 'myModal'});
Page({
showModal(){
modal.bind(this)
.show()
.then(e=>{}) // success callback function
.catch(err=>{}); // fail callback function
}
})
<modal shown="{{modal.visible}}" bindconfirm="{{modal.success}}" bindcancel="{{modal.fail}}"/>
The methods can be easily used in the taro framework.
Get the binding data by the modal box, in the native program, you can get it by ${name}.data.
// taro
const modal = new Modal();
<MyModal detail={modal.data()} />
// native miniprogram
const modal=new Modal({ name:'myModal' });
<my-modal data="{{myModal.data}}"/>
Get the registered failure function, in the native program, you can get it by {{modal.fail}} by default.
//taro
const modal = new Modal();
<MyModal onFail={modal.fail()} />
<!--native miniprogram-->
const modal=new Modal({ name:'myModal' });
<my-modal bindfail="{{myModal.fail}}"/>
Get the registered success callback function, in the native program, you can get it by {{modal.success}} by default.
//taro
const modal = new Modal();
<MyModal onFail={modal.success()} />
//native miniprogram
const modal=new Modal({ name:'myModal' });
<my-modal bindsuccess="{{myModal.success}}"/>
Get the modal box display status, in the native program, you can get it by {{modal.visible}}.
//taro
const modal = new Modal();
{ modal.visible()&&<MyModal /> }
//native miniprogram
const modal=new Modal({ name:'myModal' });
<my-modal wx:if="{{myModal.visible}}"/>
mp-event: a simple event subscription publishing system implementation;
mp-i18n: a cross-platform i18n library for muti-miniprograms (wx、alipay、baidu、tt);
mp-mem: a lightweight memoize library that can be used on both normal functions and class methods;
auto-mapping: map and convert objects automatically in typescript;
FAQs
A helper cross-platform tool for muti-miniprograms that can more convenient to use modal components.
We found that mp-modal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.