* 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>
52 lines
1.0 KiB
JavaScript
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')
|
|
}
|