Gathering detailed insights and metrics for vf-modal
Gathering detailed insights and metrics for vf-modal
Gathering detailed insights and metrics for vf-modal
Gathering detailed insights and metrics for vf-modal
npm install vf-modal
Typescript
Module System
Node Version
NPM Version
TypeScript (74.12%)
JavaScript (17.76%)
Vue (5.03%)
Stylus (3.08%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
23 Stars
110 Commits
20 Branches
1 Contributors
Updated on Nov 30, 2023
Latest Version
0.2.7-next
Package Id
vf-modal@0.2.7-next
Unpacked Size
30.02 kB
Size
7.69 kB
File Count
10
NPM Version
6.14.11
Node Version
14.16.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
38
only 3KB gzip size
1$ npm install vf-modal@next 2$ yarn add vf-modal@next 3
It is compiled to es6 by default. If you need compatibility with lower versions of browsers, you can refer to the following configuration.
1module.exports = { 2 transpileDependencies: ['vf-modal'] 3}
1module.exports = { 2 modules: { 3 rules: [ 4 test: /\.m?js$/, 5 use: { 6 loader: 'babel-loader', 7 }, 8 include: [/vf-modal/] 9 ] 10 } 11}
create a file like modal.js
1import { createVfModal, } from 'vf-modal/index' 2import NetError from './modals/NetError.vue' 3import 'vf-modal/dist/index.css' 4 5const { VfModal, Controller } = createVfModal({ 6 // define some modals 7 modals: { 8 net: { 9 component: NetError 10 }, 11 hello: { 12 component: defineComponent({ 13 props: { 14 msg: { 15 default: 'hello', 16 required: true, 17 type: String 18 } 19 }, 20 setup (props) { 21 const { msg } = toRefs(props) 22 return <> 23 <p>Hello World</p> 24 <p> msg:{msg.value}</p> 25 </> 26 } 27 }) 28 } 29 } 30}) 31 32export { 33 VfModal, 34 Controller 35}
import VfModal
in App.vue
1<template> 2 <router-view /> 3 <vf-modal /> 4</template> 5 6<script> 7import {VfModal} from './modal' 8 9export default { 10 name: 'App', 11 components: { 12 VfModal 13 } 14} 15</script>
Open a modal anywhere
1import { Controller } from './modal' 2 3/** 4 * open a modal with key 5 * @param key {ModalKey} 6 * @param opt { 7 * props: {Record<string, any>} props of the modal component 8 * zIndex: {number} default is 1 9 * on: {EventMap} event listener 10 * } 11 * @return { 12 * renderList: RenderList 13 * isClosed: () => Promise<void> 14 * close: () => void 15 * } 16 */ 17Controller.open('net') 18const { close, isClosed } = Controller.open('hello', { 19 props: { 20 msg: 'haha' 21 }, 22 on: { 23 // like <Component @xxx="function" /> 24 xxx: (...args) => { 25 // do something 26 } 27 }, 28 // maybe useful when stacking multiple modals 29 zIndex: 10 30}) 31 32// ```only``` close the 'hello' modal 33close() 34// ```only``` await the 'hello' modal closed 35isClosed() 36 .then(() => { 37 // do something 38 }) 39 40 41/** 42* close a modal 43* @param key key of modal that you would close , if not provided, will close modal directly 44*/ 45Controller.close() 46Controller.close('hello') 47 48/** 49* returns a promise that will be resolved when the ```VFModal``` component is invisible 50* that means it will be resolved on the ```onAfterEnter``` hook is triggered. 51*/ 52Controller.isClosed() 53 .then(() => { 54 // do something 55 })
modals
: The map object of modal.
type
:
1interface ModalObj { 2 component: any 3 zIndex?: number 4 props?: Record<string, any>, 5 on?: EventMap 6}
component
: vue componet
zIndex
: style z-index, which can be overridden on open
props
: props of component, which can be overridden on open
on
: listener of component, which can be overridden on open
1type Handler<T = any> = (event?: T) => void; 2interface EventMap { 3 [ x: string ]: Handler 4}
provide
: the function called in setup
mask
: mask of modal
clickHandler
: the function called when mask is clicked
1type clickHandler = (controller: Controller, emiiter: Emitter, instance: VfModal) => void
The emitter
can also be obtained in modal through the injection
autoCloseModal
: if true modal will be closed when clicking mask, default is false
classname
: classname for mask, default is 'vf-modal-mask-wrapper'
transition
: Vue's transition for modal
name
: Vue's transition name, default is 'vf-modal-fade'type
: Vue's transition name, default is 'transition'on
: modal open/close hooks
1interface on { 2 modalOpen?: Function 3 modalClose?: Function 4}
multipleModal
: control whether the same modal can open multiple
closeWhenRouteChanges
: close modal when route changed.
container
: the component that wrap the modal, it's classname is 'vf-modal-container-wrapper', default is 'div'
You can provide your own injection using the provide
property in createConfig, but vf-modal also provides an injection with the basic state of current context.
type
1interface VfModalInstanceState { 2 renderList: RenderList 3 close: (key?: string) => void 4 emitter: Emitter 5}
renderList
: list of currently rendered modal
close
: same close method as provided by the Controller
emitter
: a emitter create by mitt
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
53 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More