jenesius-vue-form
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ module.exports = { |
{ | ||
"name": "jenesius-vue-form", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Heavy form system for Vue.js", | ||
@@ -5,0 +5,0 @@ "author": "Jenesius", |
@@ -7,3 +7,3 @@ # Jenesius Vue Form | ||
- [Documentation](https://form.jenesius.com/) | ||
- Examples | ||
- [Examples](https://form.jenesius.com/examples/list.html) | ||
- [GitHub](https://github.com/Jenesius/vue-form) | ||
@@ -26,4 +26,5 @@ ## Reason For Use | ||
![Alt Text](./gif-example.gif) | ||
## Usage | ||
This example demonstrates a simple use of this library using the login form as an example. | ||
@@ -41,6 +42,4 @@ | ||
const form = new Form(); | ||
function handleLogin() { | ||
// { login: "", password: "" } | ||
console.log(form.values) | ||
console.log(form.values) // { login: "", password: "" } | ||
} | ||
@@ -59,54 +58,16 @@ </script> | ||
### Main Form state | ||
The reactive form state can be obtained from the **useFormState** hook: | ||
The reactive form state can be obtained from the **useFormState** hook, and reactive values from | ||
**useFormValues**: | ||
```js | ||
import {useFormState} from "jenesius-vue-form" | ||
const {state} = useFormState(form) // disabled changed | ||
import {useFormState, useFormValues} from "jenesius-vue-form" | ||
const state = useFormState(form) // disabled changed | ||
const state = useFormValues(form) // disabled changed | ||
``` | ||
## Proxy Form | ||
Composite objects (For example, Address, which contains country, city etc.) | ||
can be created by calling the **useProxyState** hook. | ||
```ts | ||
import {useProxyState} from "jenesius-vue-form" | ||
const {state} = useProxyState(name); | ||
``` | ||
In this example, the Composite field will automatically subscribe to the parent form, | ||
and will also serve as a bridge for all its child elements. | ||
You can flexibly create complex inputs (compound) using FormProxy. | ||
[More Information](https://github.com/Jenesius/vue-form/tree/main/examples/form-proxy) | ||
## Input | ||
When using the built-in input field, the library will do everything for you. | ||
You don't need to sign it on the form yourself. | ||
```vue | ||
<template> | ||
<input-field type = "text" name = "user" label = "Username"/> | ||
<input-field type = "text" name = "age" label = "Age"/> | ||
</template> | ||
<script setup> | ||
import {Form, InputField} from "jenesius-vue-form" | ||
const form = new Form(); | ||
</script> | ||
``` | ||
### Custom Input | ||
In most cases, you will use your own input fields. | ||
In this case, you need to implement a small layer: | ||
```vue | ||
<input type = "text" | ||
@input = "input.change($event.target.value)" | ||
:value="state.value" | ||
:disabled = "state.disabled" | ||
> | ||
``` | ||
```js | ||
import {useInputState} from "jenesius-vue-form" | ||
const {state, input} = useInputState(props.name) | ||
// state - {value, disabled, errors} | ||
``` | ||
- **input** - an instance of Input which has several methods to work with | ||
form interaction. | ||
## Example | ||
The current example shows the simplest binding of two fields to a form and working with them | ||
@@ -113,0 +74,0 @@ ```vue |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
3967
154494
99