Installations
npm install vue-use-model-helpers
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.19.0
NPM Version
8.19.3
Score
51.2
Supply Chain
97.7
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (93.69%)
JavaScript (6.31%)
Developer
Download Statistics
Total Downloads
2,273
Last Day
1
Last Week
4
Last Month
13
Last Year
154
GitHub Statistics
3 Stars
20 Commits
3 Watching
5 Branches
1 Contributors
Bundle Size
758.00 B
Minified
436.00 B
Minified + Gzipped
Package Meta Information
Latest Version
4.0.0-beta.4
Package Id
vue-use-model-helpers@4.0.0-beta.4
Unpacked Size
12.13 kB
Size
4.24 kB
File Count
14
NPM Version
8.19.3
Node Version
16.19.0
Publised On
01 Mar 2023
Total Downloads
Cumulative downloads
Total Downloads
2,273
Last day
0%
1
Compared to previous day
Last week
0%
4
Compared to previous week
Last month
44.4%
13
Compared to previous month
Last year
-72.1%
154
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
1
Vue use model helpers 4
This library provides a helper to convert a component's property to a local Ref you can mutate when you are using composition-api, simplifying the management of the custom v-model
and .sync
This library works with Vue 2.7+ and Vue 3
Motivation
When you create a component that gets a property and then needs to mutate it into the component you get this vue warn
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component
You need to copy the property value to a local value to use in the component,
Also should update your local value when the property value changes
If the property is a v-model
or uses .sync
you also must take care of emitting an event when your local value changes to keep updated the property value in the parent component.
The motivation of this library is simplifying this task and reducing the amount of repetitive code.
Requeriments
Vue 2.7+ or 3.x
If you need support for vue 2.5+ and composition Api, please use the 2.x
version
Improvements in 4.x
- The library return just one property at time in order of be able to infer prop type
- Same code runs in vue 2.7 and 3.x
Getting started
Install
npm i vue-use-model-helper@4 --save
or
yarn add vue-use-model-helper@4
Usage
In your component:
1import { useLocalModel } from 'vue-use-model-helpers' 2 3export default defineComponent({ 4 ... 5 props: { 6 value: String 7 } , 8 setup(props) { 9 10 const localValue = useLocalModel(props, 'value') 11 12 return { 13 localValue 14 } 15 } 16 ... 17})
Now you can use localValue
in your component, and the helper takes care of sync the values, emit the update event, etc
The component can work with both value
and .sync
emitting the correct event to keep the property updated
Examples
1<template> 2 <div> 3 {{ localCounter }} 4 <button @click="increaseCounter"></button> 5 </div> 6</template> 7import { useLocalModel } from 'vue-use-model-helpers' 8 9export default defineComponent({ 10 ... 11 props: { 12 value: String, 13 counter: Number // This propery has .sync in the parent component 14 } , 15 setup(props) { 16 const localValue = useLocalModel(props, 'value') 17 const localCounter = useLocalModel(props, 'counter') 18 19 const increaseCounter = () => { 20 localCounter.value = localCounter.value + 1 21 } 22 23 return { 24 localValue, 25 localCounter, 26 increaseCounter 27 } 28 } 29 ... 30})
Proudly created in Vigo and around its local community
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/sergiocarracedo/vue-use-model-helpers/publish.yml/3.x?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/sergiocarracedo/vue-use-model-helpers/publish.yml/3.x?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/sergiocarracedo/vue-use-model-helpers/publish.yml/3.x?enable=pin
- Info: 0 out of 1 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Info: no jobLevel write permissions found
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch '3.x'
Reason
20 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.4
/10
Last Scanned on 2025-01-27
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