1
0
mirror of synced 2025-03-19 22:44:00 +03:00
vue-formulario/src/libs/library.js
Justin Schroeder adf8299a33
Feature/form errors (#13)
* Adds support form FormulateError form errors

* Adds support for form-errors prop

Also includes tests for both named-form-errors as well, form-errors prop, positioning form errors with the <FormulateErrors /> component, and allowing multiple <FormulateErrors />

* Adds form error support, error handling, and supporting tests

* Remove unused util functions

* fixes bug that resulted in validation failing if run more than once

Credit to @luan-nk-nguyen for discovering the bug

Co-authored-by: Andrew Boyd <andrew@wearebraid.com>
2020-03-06 16:10:25 -05:00

52 lines
1.0 KiB
JavaScript

/**
* library.js
*
* Note: We're shipping front end code here, file size is critical. This file is
* overly terse for that reason alone, we wouldn't necessarily recommend this.
*/
const fi = 'FormulateInput'
const add = (n, c) => ({
classification: n,
component: fi + (c || (n[0].toUpperCase() + n.substr(1)))
})
export default {
// === SINGLE LINE TEXT STYLE INPUTS
...[
'text',
'email',
'number',
'color',
'date',
'hidden',
'month',
'password',
'search',
'tel',
'time',
'url',
'week',
'datetime-local'
].reduce((lib, type) => ({ ...lib, [type]: add('text') }), {}),
// === SLIDER INPUTS
range: add('slider'),
// === MULTI LINE TEXT INPUTS
textarea: add('textarea', 'TextArea'),
// === BOX STYLE INPUTS
checkbox: add('box'),
radio: add('box'),
// === BUTTON STYLE INPUTS
submit: add('button'),
button: add('button'),
// === SELECT STYLE INPUTS
select: add('select'),
// === FILE TYPE
file: add('file'),
image: add('file')
}