Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
vue-dataform-mixin
Advanced tools
Vue Mixin util to help create data entry component
$ npm install vue-dataform-mixin
vue-dataform-mixin
and register it in the mixins
sectiononSave
, onCancel
, onDelete
methods to the form componentvue-dataform-mixin
)
data
-- the data objectkeys
-- the properties inside the data object that you want to map into form componentvalidate-callback
-- the validation callback function defined in main Vue instance
to be called by form component before the data are saved or updateddelete-button
-- set to true
if you want to show a delete buttonRequired: true
Expect: Array
Usage:
Array of property names to be mapped to input
object inside the data form.
[ 'prop_a', 'prop_b', 'prop_c' ]
If the property has nested object, use the following format:
[ 'prop_a', 'prop_b', { name: 'prop_c', value: ['prop_c_1', 'prop_c_2'] } ]
The nested object can also contain nested object as well.
Expect: Object
Default: {}
Usage:
The data which its value will be used to populate in the data form. This data will not be modified until the changes have been committed (saved) by the user.
Expect: String
Default: ''
Usage:
Name of the callback to be called for the data validation. If no callback is defined, the validation will always return true
(which is considered as passed)
Expect: Boolean
Default: false
Usage:
Whether to display the delete
button or not?
Note: You need to make sure that the delete button will be conditionally displayed in your template and the its click event is bound to
onDelete()
method.
Default: null
Description:
This is where the values in the data
prop will be copied to and used inside data form.
Note: Only the values of property given in the
keys
prop will be copied, the rests are ignored.
Default: null
Description:
If it is not null
, it will contain all the validation errors of the fileds not passing validation.
Note: Normally, this property can be set via
dataform:set-errors
event, which will internally callsetErrors()
method.
Default: false
Description:
Its value will be automatically set by setData()
method. If the pass-in data is null, it will be set to true
to indicate a new data. Otherwise, its value will be set to false
.
Default: dataform:
Description:
The prefix string that should be applied to all event emitted by the data form.
In order for the data form to work, you will need to correctly bind these methods to the corresponding buttons.
Usage:
<template>
...
<button @click="onSave">Save</button>
...
</template>
Description:
When triggered, it will do the following, in order:
dataform:no-changed
event will be dispatched and exit.input
to data
dataform:stored
or dataform:updated
event depending on the valid of isNew
.Usage:
<template>
...
<button @click="onCancel">Cancel</button>
...
</template>
Description:
When triggered, it will dispatch the dataform:cancelled
event, then exit.
Usage:
<template>
...
<button @click="onDelete">Delete</button>
...
</template>
Description:
When triggered, it will dispatch the dataform:request-delete
event, then exit.
Argument: {Object} data
Description:
This method will copy the values of the provided keys
prop in the given data
to the input
object. It will also set the value of isNew
property depending on the content of the given argument.
Note: This method is called when
dataform:set-data
event was received. You should usedataform:set-data
event when possible.
Returns: boolean
Description:
Return true
if the data in the data form has been modified to be different than the original value. Otherwise, return false
.
Argument: {String} name (optional)
Returns: boolean
Description:
Check if there is any error from validation when called without an argument.
Or, check if there is any error for the given field.
Argument: {String} name
Returns: {Array}
-- array of error messages of the given field name
or empty array if there is no error
Description:
Get the array of validation error message(s) for the given field.
Argument: {Array} errors
Description:
Set the internal errors
property to the given object.
Note: This method is called when
dataform:set-errors
event was received. You should usedataform:set-errors
event when possible.
Description:
Set the internal errors
property to null
.
Description:
Set all input inside data form to empty string ''
.
Arguments:
{String} value
{KeyboardEvent} event
Usage:
<template>
...
<input type="text" v-model="input.price"
id="inputPrice"
@keypress="numericInputFilter(input.price, $event)">
...
</template>
- __Description:__
Filter the input to accept only numeric digits, decimal, and minus sign.
## Events
#### # dataform:set-data
- __Argument:__ `{Object} data`
- __Type:__ Listening
- __Description:__
You can use this event to set the data to be used in the form.
#### # dataform:clear-form
- __Type:__ Listening
- __Description:__
Use this event to clear all the input value in the data form.
#### # dataform:set-errors
- __Argument:__ `{Array} errors`
- __Type:__ Listening
- __Description:__
Use this event to send the validation errors to the data form component.
#### # dataform:clear-errors
- __Type:__ Listening
- __Description:__
Use this event to clear all the errors by setting `errors` object to `null`.
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# run unit tests
npm run unit
# run all tests
npm test
vue-dataform-mixin
is open-sourced software licensed under the MIT license.
FAQs
Vue Mixin util to help create data entry component
We found that vue-dataform-mixin 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.