|
|
@ -191,20 +191,21 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
|
|
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
|
|
|
css: null,
|
|
|
|
css: null,
|
|
|
|
|
|
|
|
|
|
|
|
exports: {
|
|
|
|
exports: {
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result: undefined
|
|
|
|
result: undefined,
|
|
|
|
|
|
|
|
validator: undefined,
|
|
|
|
|
|
|
|
class: undefined
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onMounted()
|
|
|
|
onMounted()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// creating formValidation
|
|
|
|
// creating formValidator
|
|
|
|
const formValidation = new _formValidator_js__WEBPACK_IMPORTED_MODULE_0__["default"](this.$('.form'), {
|
|
|
|
this.state.validator = new _formValidator_js__WEBPACK_IMPORTED_MODULE_0__["default"](this.$('.form'), {
|
|
|
|
'email': {
|
|
|
|
'email': {
|
|
|
|
'presence': true,
|
|
|
|
'presence': true,
|
|
|
|
'email': true
|
|
|
|
'email': true
|
|
|
@ -212,12 +213,47 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
'password': {
|
|
|
|
'password': {
|
|
|
|
'presence': true
|
|
|
|
'presence': true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, (event, data) => {
|
|
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.state.result = JSON.stringify(data)
|
|
|
|
|
|
|
|
this.update()
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// adding on success
|
|
|
|
|
|
|
|
this.state.validator.onSuccess((event, data) => {
|
|
|
|
|
|
|
|
this.handleSuccess(event, data)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// adding on error
|
|
|
|
|
|
|
|
this.state.validator.onError((event, errors, data) => {
|
|
|
|
|
|
|
|
this.handleError(event, errors, data)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {object} event
|
|
|
|
|
|
|
|
* @param {array} data
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
handleSuccess(event, data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.state.class = 'background-color-success'
|
|
|
|
|
|
|
|
this.state.result = JSON.stringify(data)
|
|
|
|
|
|
|
|
this.update()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {object} event
|
|
|
|
|
|
|
|
* @param {array} errors
|
|
|
|
|
|
|
|
* @param {array} data
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
handleError(event, errors, data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.state.class = 'background-color-danger'
|
|
|
|
|
|
|
|
this.state.result = JSON.stringify(errors)
|
|
|
|
|
|
|
|
this.update()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -227,16 +263,28 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
bindingTypes,
|
|
|
|
bindingTypes,
|
|
|
|
getComponent
|
|
|
|
getComponent
|
|
|
|
) => template(
|
|
|
|
) => template(
|
|
|
|
'<div><form class="form" novalidate method="post"><div class="field-group"><label class="field-label">\n email\n <input type="email" class="field-text" name="email"/></label><field-error expr2="expr2" name="email"></field-error></div><div class="field-group"><label class="field-label">\n password\n <input type="password" class="field-text" name="password"/></label><field-error expr3="expr3" name="password"></field-error></div><button class="button" type="submit">\n Send\n </button></form><div expr4="expr4" class="panel color-text-contrast background-color-success"></div></div>',
|
|
|
|
'<div><form expr2="expr2" class="form" novalidate method="post"><div class="field-group"><label class="field-label">\n email\n <input type="email" class="field-text" name="email"/></label><field-error expr3="expr3" name="email"></field-error></div><div class="field-group"><label class="field-label">\n password\n <input type="password" class="field-text" name="password"/></label><field-error expr4="expr4" name="password"></field-error></div><button class="button" type="submit">\n Send\n </button></form><div expr5="expr5"></div></div>',
|
|
|
|
[
|
|
|
|
[
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
redundantAttribute: 'expr2',
|
|
|
|
|
|
|
|
selector: '[expr2]',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expressions: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
type: expressionTypes.EVENT,
|
|
|
|
|
|
|
|
name: 'onsubmit',
|
|
|
|
|
|
|
|
evaluate: _scope => (event) => ( _scope.state.validator.submit(event) )
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
type: bindingTypes.TAG,
|
|
|
|
type: bindingTypes.TAG,
|
|
|
|
getComponent: getComponent,
|
|
|
|
getComponent: getComponent,
|
|
|
|
evaluate: _scope => 'field-error',
|
|
|
|
evaluate: _scope => 'field-error',
|
|
|
|
slots: [],
|
|
|
|
slots: [],
|
|
|
|
attributes: [],
|
|
|
|
attributes: [],
|
|
|
|
redundantAttribute: 'expr2',
|
|
|
|
redundantAttribute: 'expr3',
|
|
|
|
selector: '[expr2]'
|
|
|
|
selector: '[expr3]'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
type: bindingTypes.TAG,
|
|
|
|
type: bindingTypes.TAG,
|
|
|
@ -244,21 +292,36 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
evaluate: _scope => 'field-error',
|
|
|
|
evaluate: _scope => 'field-error',
|
|
|
|
slots: [],
|
|
|
|
slots: [],
|
|
|
|
attributes: [],
|
|
|
|
attributes: [],
|
|
|
|
redundantAttribute: 'expr3',
|
|
|
|
redundantAttribute: 'expr4',
|
|
|
|
selector: '[expr3]'
|
|
|
|
selector: '[expr4]'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
type: bindingTypes.IF,
|
|
|
|
type: bindingTypes.IF,
|
|
|
|
evaluate: _scope => _scope.state.result,
|
|
|
|
evaluate: _scope => _scope.state.result,
|
|
|
|
redundantAttribute: 'expr4',
|
|
|
|
redundantAttribute: 'expr5',
|
|
|
|
selector: '[expr4]',
|
|
|
|
selector: '[expr5]',
|
|
|
|
|
|
|
|
|
|
|
|
template: template(
|
|
|
|
template: template(
|
|
|
|
'<div class="panel__body"><div expr5="expr5" class="content m-bottom-last-child-0"> </div></div>',
|
|
|
|
'<div class="panel__body"><div expr6="expr6" class="content m-bottom-last-child-0"> </div></div>',
|
|
|
|
[
|
|
|
|
[
|
|
|
|
{
|
|
|
|
{
|
|
|
|
redundantAttribute: 'expr5',
|
|
|
|
expressions: [
|
|
|
|
selector: '[expr5]',
|
|
|
|
{
|
|
|
|
|
|
|
|
type: expressionTypes.ATTRIBUTE,
|
|
|
|
|
|
|
|
name: 'class',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
evaluate: _scope => [
|
|
|
|
|
|
|
|
'panel color-text-contrast ',
|
|
|
|
|
|
|
|
_scope.state.class
|
|
|
|
|
|
|
|
].join(
|
|
|
|
|
|
|
|
''
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
redundantAttribute: 'expr6',
|
|
|
|
|
|
|
|
selector: '[expr6]',
|
|
|
|
|
|
|
|
|
|
|
|
expressions: [
|
|
|
|
expressions: [
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -284,10 +347,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
|
|
/***/ "./src/demo.js":
|
|
|
|
/***/ "./src/example.js":
|
|
|
|
/*!*********************!*\
|
|
|
|
/*!************************!*\
|
|
|
|
!*** ./src/demo.js ***!
|
|
|
|
!*** ./src/example.js ***!
|
|
|
|
\*********************/
|
|
|
|
\************************/
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
@ -312,7 +375,8 @@ var formValidation = new _formValidator__WEBPACK_IMPORTED_MODULE_0__["default"](
|
|
|
|
'password': {
|
|
|
|
'password': {
|
|
|
|
'presence': true
|
|
|
|
'presence': true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function (event, data) {
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
formValidation.onSuccess(function (event, data) {
|
|
|
|
event.preventDefault(); // show message and content of data from form
|
|
|
|
event.preventDefault(); // show message and content of data from form
|
|
|
|
|
|
|
|
|
|
|
|
document.querySelector('#result .content').innerHTML = '<p>' + JSON.stringify(data) + '</p>';
|
|
|
|
document.querySelector('#result .content').innerHTML = '<p>' + JSON.stringify(data) + '</p>';
|
|
|
@ -351,7 +415,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author HerrHase
|
|
|
|
* @author HerrHase
|
|
|
|
* @
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
@ -361,47 +424,80 @@ var FormValidator = /*#__PURE__*/function () {
|
|
|
|
* @param {[type]} formSelector [description]
|
|
|
|
* @param {[type]} formSelector [description]
|
|
|
|
* @param {[type]} constraits [description]
|
|
|
|
* @param {[type]} constraits [description]
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function FormValidator(formElement, constraits, onSuccess) {
|
|
|
|
function FormValidator(formElement, constraits) {
|
|
|
|
var _this = this;
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var addSubmitEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
|
|
|
|
|
|
|
|
|
_classCallCheck(this, FormValidator);
|
|
|
|
_classCallCheck(this, FormValidator);
|
|
|
|
|
|
|
|
|
|
|
|
// constraits for validate.js
|
|
|
|
// constraits for validate.js
|
|
|
|
this.constraits = constraits; // adding onSuccess
|
|
|
|
this.constraits = constraits; // get form and elements
|
|
|
|
|
|
|
|
|
|
|
|
this._onSuccess = onSuccess; // if form not found
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this._onSuccess) {
|
|
|
|
this.formElement = formElement; // if form not found
|
|
|
|
console.error('FormValidator: onSuccess not found!');
|
|
|
|
|
|
|
|
} // get form and elements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.formElement) {
|
|
|
|
this.form = formElement; // if form not found
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.form) {
|
|
|
|
|
|
|
|
console.error('FormValidator: form not found!');
|
|
|
|
console.error('FormValidator: form not found!');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.elements = this.form.querySelectorAll('field-error'); // adding submit event
|
|
|
|
this.elements = this.formElement.querySelectorAll('field-error'); // adding event if a element is updated
|
|
|
|
|
|
|
|
|
|
|
|
this.form.addEventListener('submit', function (event) {
|
|
|
|
|
|
|
|
_this._onSubmit(event);
|
|
|
|
|
|
|
|
}); // adding event if a element is updated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.form.addEventListener('field-update', function (event) {
|
|
|
|
this.formElement.addEventListener('field-update', function (event) {
|
|
|
|
_this._onFieldUpdate(event);
|
|
|
|
_this._onFieldUpdate(event);
|
|
|
|
});
|
|
|
|
}); // adding submit event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (addSubmitEvent) {
|
|
|
|
|
|
|
|
this.formElement.addEventListener('submit', function (event) {
|
|
|
|
|
|
|
|
_this._onSubmit(event);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* handle submit
|
|
|
|
* trigger submit
|
|
|
|
*
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param {Event} event
|
|
|
|
* @param {object} event
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_createClass(FormValidator, [{
|
|
|
|
_createClass(FormValidator, [{
|
|
|
|
|
|
|
|
key: "submit",
|
|
|
|
|
|
|
|
value: function submit(event) {
|
|
|
|
|
|
|
|
this._onSubmit(event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {function} onError
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
key: "onError",
|
|
|
|
|
|
|
|
value: function onError(_onError) {
|
|
|
|
|
|
|
|
this._onError = _onError;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* settin onSuccess callback and add submit-event on form
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {function} onSuccess
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
key: "onSuccess",
|
|
|
|
|
|
|
|
value: function onSuccess(_onSuccess) {
|
|
|
|
|
|
|
|
// adding onSuccess
|
|
|
|
|
|
|
|
this._onSuccess = _onSuccess;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* handle submit
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {Event} event
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
key: "_onSubmit",
|
|
|
|
key: "_onSubmit",
|
|
|
|
value: function _onSubmit(event) {
|
|
|
|
value: function _onSubmit(event) {
|
|
|
|
var _this2 = this;
|
|
|
|
var _this2 = this;
|
|
|
@ -413,13 +509,17 @@ var FormValidator = /*#__PURE__*/function () {
|
|
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
var options = {
|
|
|
|
fullMessages: false
|
|
|
|
fullMessages: false
|
|
|
|
};
|
|
|
|
}; // check form and getting errors
|
|
|
|
validate_js__WEBPACK_IMPORTED_MODULE_0___default().async(data, this.constraits, options).then( // handling success
|
|
|
|
|
|
|
|
function () {
|
|
|
|
validate_js__WEBPACK_IMPORTED_MODULE_0___default().async(data, this.constraits, options).then(function () {
|
|
|
|
_this2._onSuccess(event, data);
|
|
|
|
_this2._onSuccess(event, data);
|
|
|
|
}, // handling error
|
|
|
|
}, function (errors) {
|
|
|
|
function (errors) {
|
|
|
|
event.preventDefault(); // if onError is set, tha
|
|
|
|
event.preventDefault(); // send each element a event
|
|
|
|
|
|
|
|
|
|
|
|
if (_this2._onError) {
|
|
|
|
|
|
|
|
_this2._onError(event, errors, data);
|
|
|
|
|
|
|
|
} // send each element a event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_this2.elements.forEach(function (element) {
|
|
|
|
_this2.elements.forEach(function (element) {
|
|
|
|
var elementErrors = false; // check for errors by name
|
|
|
|
var elementErrors = false; // check for errors by name
|
|
|
@ -759,10 +859,10 @@ module.exports = serialize;
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
|
|
/***/ "./src/demo.scss":
|
|
|
|
/***/ "./src/example.scss":
|
|
|
|
/*!***********************!*\
|
|
|
|
/*!**************************!*\
|
|
|
|
!*** ./src/demo.scss ***!
|
|
|
|
!*** ./src/example.scss ***!
|
|
|
|
\***********************/
|
|
|
|
\**************************/
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
@ -4695,8 +4795,8 @@ const __ = {
|
|
|
|
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
|
|
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
|
|
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
|
|
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
|
|
/******/ var installedChunks = {
|
|
|
|
/******/ var installedChunks = {
|
|
|
|
/******/ "/dist/demo": 0,
|
|
|
|
/******/ "/example/example": 0,
|
|
|
|
/******/ "dist/demo": 0
|
|
|
|
/******/ "example/example": 0
|
|
|
|
/******/ };
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // no chunk on demand loading
|
|
|
|
/******/ // no chunk on demand loading
|
|
|
@ -4746,8 +4846,8 @@ const __ = {
|
|
|
|
/******/ // startup
|
|
|
|
/******/ // startup
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
|
|
|
|
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
|
|
|
|
/******/ __webpack_require__.O(undefined, ["dist/demo"], () => (__webpack_require__("./src/demo.js")))
|
|
|
|
/******/ __webpack_require__.O(undefined, ["example/example"], () => (__webpack_require__("./src/example.js")))
|
|
|
|
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["dist/demo"], () => (__webpack_require__("./src/demo.scss")))
|
|
|
|
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["example/example"], () => (__webpack_require__("./src/example.scss")))
|
|
|
|
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
|
|
|
|
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ })()
|
|
|
|
/******/ })()
|