Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diasbruno/vue-form-state-manager
Simple form state manager used as directive.
https://github.com/diasbruno/vue-form-state-manager
Last synced: 9 days ago
JSON representation
Simple form state manager used as directive.
- Host: GitHub
- URL: https://github.com/diasbruno/vue-form-state-manager
- Owner: diasbruno
- License: mit
- Created: 2020-11-26T19:35:54.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-28T19:21:09.000Z (almost 4 years ago)
- Last Synced: 2024-09-27T05:11:11.747Z (about 1 month ago)
- Language: JavaScript
- Size: 63.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# vue-form-state-manager
A simple form state manager that can be used as directive.
## usage
To register:
```vue
import FormState from "vue-form-state-manager";
Vue.directive('form-control', FormState);
```Use:
```vue
```
Checking the form state:
```js
import { formState, formIsDirty, formIsPristine } from "vue-form-state-manager";formState(formId) == { dirty: Boolean, pristine: Boolean };
formState(formId).dirty == formIsDirty(formId);
formState(formId).pristine == formIsPristine(formId);
```Reseting a single input:
```js
export default {
name: "MyComp",
...
methods: {
myMethod() {
this.prop = NEW_VALUE;
resetInitialValueFor("test-form", "field-name", this.prop);
}
},
...
}
```## roadmap
- [x] API to control the state programmatically.
## licence
MIT