diff --git a/dist/demo.js b/dist/demo.js index c2f7e18..5addb29 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -1,10 +1,10 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ "./src/field-error.riot": -/*!******************************!*\ - !*** ./src/field-error.riot ***! - \******************************/ +/***/ "./src/fieldError.riot": +/*!*****************************!*\ + !*** ./src/fieldError.riot ***! + \*****************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; @@ -176,9 +176,156 @@ __webpack_require__.r(__webpack_exports__); /***/ }), -/***/ "./src/FormValidator.js": +/***/ "./src/formComponent.riot": +/*!********************************!*\ + !*** ./src/formComponent.riot ***! + \********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _formValidator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./formValidator.js */ "./src/formValidator.js"); + + + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + css: null, + + exports: { + state: + { + result: undefined + }, + + onMounted() + { + // creating formValidation + const formValidation = new _formValidator_js__WEBPACK_IMPORTED_MODULE_0__["default"](this.$('.form'), { + 'email': { + 'presence': true, + 'email': true + }, + 'password': { + 'presence': true + } + }, (event, data) => { + event.preventDefault() + + this.state.result = JSON.stringify(data) + this.update() + }) + } + }, + + template: ( + template, + expressionTypes, + bindingTypes, + getComponent + ) => template( + '
' + JSON.stringify(data) + '
'; + document.querySelector('#result').classList.remove('hidden'); +}); +riot__WEBPACK_IMPORTED_MODULE_3__.register('form-component', _formComponent_riot__WEBPACK_IMPORTED_MODULE_2__["default"]); +riot__WEBPACK_IMPORTED_MODULE_3__.mount('form-component'); + +/***/ }), + +/***/ "./src/formValidator.js": /*!******************************!*\ - !*** ./src/FormValidator.js ***! + !*** ./src/formValidator.js ***! \******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { @@ -214,14 +361,12 @@ var FormValidator = /*#__PURE__*/function () { * @param {[type]} formSelector [description] * @param {[type]} constraits [description] */ - function FormValidator(formSelector, constraits, onSuccess) { + function FormValidator(formElement, constraits, onSuccess) { var _this = this; _classCallCheck(this, FormValidator); - // getting selector to find form-element - this.formSelector = formSelector; // constraits for validate.js - + // constraits for validate.js this.constraits = constraits; // adding onSuccess this._onSuccess = onSuccess; // if form not found @@ -231,7 +376,7 @@ var FormValidator = /*#__PURE__*/function () { } // get form and elements - this.form = document.querySelector(this.formSelector); // if form not found + this.form = formElement; // if form not found if (!this.form) { console.error('FormValidator: form not found!'); @@ -344,38 +489,6 @@ var FormValidator = /*#__PURE__*/function () { /***/ }), -/***/ "./src/demo.js": -/*!*********************!*\ - !*** ./src/demo.js ***! - \*********************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var riot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js"); -/* harmony import */ var _FormValidator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FormValidator */ "./src/FormValidator.js"); -/* harmony import */ var _field_error_riot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./field-error.riot */ "./src/field-error.riot"); - - - -riot__WEBPACK_IMPORTED_MODULE_2__.register('field-error', _field_error_riot__WEBPACK_IMPORTED_MODULE_1__["default"]); -riot__WEBPACK_IMPORTED_MODULE_2__.mount('field-error'); -var formValidation = new _FormValidator__WEBPACK_IMPORTED_MODULE_0__["default"]('form', { - 'email': { - 'presence': true, - 'email': true - }, - 'password': { - 'presence': true - } -}, function (event, data) { - event.preventDefault(); - document.querySelector('#result .content').innerHTML = '' + JSON.stringify(data) + '
'; - document.querySelector('#result').classList.remove('hidden'); -}); - -/***/ }), - /***/ "./node_modules/form-serialize/index.js": /*!**********************************************!*\ !*** ./node_modules/form-serialize/index.js ***! diff --git a/dist/index.html b/dist/index.html index 475dd79..8515302 100644 --- a/dist/index.html +++ b/dist/index.html @@ -31,7 +31,12 @@