🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@form-validation/plugin-icon

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@form-validation/plugin-icon - npm Package Compare versions

Comparing version
2.0.2
to
2.1.0
+205
lib/esm/index.js
import { utils, Plugin } from '../core/index.js';
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
/**
* FormValidation (https://formvalidation.io)
* The best validation library for JavaScript
* (c) 2013 - 2023 Nguyen Huu Phuoc <me@phuoc.ng>
*/
var classSet = utils.classSet;
var Icon = /** @class */ (function (_super) {
__extends(Icon, _super);
function Icon(opts) {
var _this = _super.call(this, opts) || this;
// Map the field element with icon
_this.icons = new Map();
_this.opts = Object.assign({}, {
invalid: 'fv-plugins-icon--invalid',
onPlaced: function () { },
onSet: function () { },
valid: 'fv-plugins-icon--valid',
validating: 'fv-plugins-icon--validating',
}, opts);
_this.elementValidatingHandler = _this.onElementValidating.bind(_this);
_this.elementValidatedHandler = _this.onElementValidated.bind(_this);
_this.elementNotValidatedHandler = _this.onElementNotValidated.bind(_this);
_this.elementIgnoredHandler = _this.onElementIgnored.bind(_this);
_this.fieldAddedHandler = _this.onFieldAdded.bind(_this);
return _this;
}
Icon.prototype.install = function () {
this.core
.on('core.element.validating', this.elementValidatingHandler)
.on('core.element.validated', this.elementValidatedHandler)
.on('core.element.notvalidated', this.elementNotValidatedHandler)
.on('core.element.ignored', this.elementIgnoredHandler)
.on('core.field.added', this.fieldAddedHandler);
};
Icon.prototype.uninstall = function () {
this.icons.forEach(function (icon) { return icon.parentNode.removeChild(icon); });
this.icons.clear();
this.core
.off('core.element.validating', this.elementValidatingHandler)
.off('core.element.validated', this.elementValidatedHandler)
.off('core.element.notvalidated', this.elementNotValidatedHandler)
.off('core.element.ignored', this.elementIgnoredHandler)
.off('core.field.added', this.fieldAddedHandler);
};
Icon.prototype.onFieldAdded = function (e) {
var _this = this;
var elements = e.elements;
if (elements) {
elements.forEach(function (ele) {
var icon = _this.icons.get(ele);
if (icon) {
icon.parentNode.removeChild(icon);
_this.icons.delete(ele);
}
});
this.prepareFieldIcon(e.field, elements);
}
};
Icon.prototype.prepareFieldIcon = function (field, elements) {
var _this = this;
if (elements.length) {
var type = elements[0].getAttribute('type');
if ('radio' === type || 'checkbox' === type) {
this.prepareElementIcon(field, elements[0]);
}
else {
elements.forEach(function (ele) { return _this.prepareElementIcon(field, ele); });
}
}
};
Icon.prototype.prepareElementIcon = function (field, ele) {
var i = document.createElement('i');
i.setAttribute('data-field', field);
// Append the icon right after the field element
ele.parentNode.insertBefore(i, ele.nextSibling);
classSet(i, {
'fv-plugins-icon': true,
});
var e = {
classes: {
invalid: this.opts.invalid,
valid: this.opts.valid,
validating: this.opts.validating,
},
element: ele,
field: field,
iconElement: i,
};
this.core.emit('plugins.icon.placed', e);
this.opts.onPlaced(e);
this.icons.set(ele, i);
};
Icon.prototype.onElementValidating = function (e) {
var _a;
var icon = this.setClasses(e.field, e.element, e.elements, (_a = {},
_a[this.opts.invalid] = false,
_a[this.opts.valid] = false,
_a[this.opts.validating] = true,
_a));
var evt = {
element: e.element,
field: e.field,
iconElement: icon,
status: 'Validating',
};
this.core.emit('plugins.icon.set', evt);
this.opts.onSet(evt);
};
Icon.prototype.onElementValidated = function (e) {
var _a;
var icon = this.setClasses(e.field, e.element, e.elements, (_a = {},
_a[this.opts.invalid] = !e.valid,
_a[this.opts.valid] = e.valid,
_a[this.opts.validating] = false,
_a));
var evt = {
element: e.element,
field: e.field,
iconElement: icon,
status: e.valid ? 'Valid' : 'Invalid',
};
this.core.emit('plugins.icon.set', evt);
this.opts.onSet(evt);
};
Icon.prototype.onElementNotValidated = function (e) {
var _a;
var icon = this.setClasses(e.field, e.element, e.elements, (_a = {},
_a[this.opts.invalid] = false,
_a[this.opts.valid] = false,
_a[this.opts.validating] = false,
_a));
var evt = {
element: e.element,
field: e.field,
iconElement: icon,
status: 'NotValidated',
};
this.core.emit('plugins.icon.set', evt);
this.opts.onSet(evt);
};
Icon.prototype.onElementIgnored = function (e) {
var _a;
var icon = this.setClasses(e.field, e.element, e.elements, (_a = {},
_a[this.opts.invalid] = false,
_a[this.opts.valid] = false,
_a[this.opts.validating] = false,
_a));
var evt = {
element: e.element,
field: e.field,
iconElement: icon,
status: 'Ignored',
};
this.core.emit('plugins.icon.set', evt);
this.opts.onSet(evt);
};
Icon.prototype.setClasses = function (field, element, elements, classes) {
var type = element.getAttribute('type');
var ele = 'radio' === type || 'checkbox' === type ? elements[0] : element;
if (this.icons.has(ele)) {
var icon = this.icons.get(ele);
classSet(icon, classes);
return icon;
}
else {
return null;
}
};
return Icon;
}(Plugin));
export { Icon };
/**
* FormValidation (https://formvalidation.io)
* The best validation library for JavaScript
* (c) 2013 - 2023 Nguyen Huu Phuoc <me@phuoc.ng>
*
* @license https://formvalidation.io/license
* @package @form-validation/plugin-icon
* @version 2.1.0
*/
import{utils as e,Plugin as t}from"../core/index.min.js";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};var i=e.classSet,o=function(e){function t(t){var n=e.call(this,t)||this;return n.icons=new Map,n.opts=Object.assign({},{invalid:"fv-plugins-icon--invalid",onPlaced:function(){},onSet:function(){},valid:"fv-plugins-icon--valid",validating:"fv-plugins-icon--validating"},t),n.elementValidatingHandler=n.onElementValidating.bind(n),n.elementValidatedHandler=n.onElementValidated.bind(n),n.elementNotValidatedHandler=n.onElementNotValidated.bind(n),n.elementIgnoredHandler=n.onElementIgnored.bind(n),n.fieldAddedHandler=n.onFieldAdded.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t.prototype.install=function(){this.core.on("core.element.validating",this.elementValidatingHandler).on("core.element.validated",this.elementValidatedHandler).on("core.element.notvalidated",this.elementNotValidatedHandler).on("core.element.ignored",this.elementIgnoredHandler).on("core.field.added",this.fieldAddedHandler)},t.prototype.uninstall=function(){this.icons.forEach((function(e){return e.parentNode.removeChild(e)})),this.icons.clear(),this.core.off("core.element.validating",this.elementValidatingHandler).off("core.element.validated",this.elementValidatedHandler).off("core.element.notvalidated",this.elementNotValidatedHandler).off("core.element.ignored",this.elementIgnoredHandler).off("core.field.added",this.fieldAddedHandler)},t.prototype.onFieldAdded=function(e){var t=this,n=e.elements;n&&(n.forEach((function(e){var n=t.icons.get(e);n&&(n.parentNode.removeChild(n),t.icons.delete(e))})),this.prepareFieldIcon(e.field,n))},t.prototype.prepareFieldIcon=function(e,t){var n=this;if(t.length){var i=t[0].getAttribute("type");"radio"===i||"checkbox"===i?this.prepareElementIcon(e,t[0]):t.forEach((function(t){return n.prepareElementIcon(e,t)}))}},t.prototype.prepareElementIcon=function(e,t){var n=document.createElement("i");n.setAttribute("data-field",e),t.parentNode.insertBefore(n,t.nextSibling),i(n,{"fv-plugins-icon":!0});var o={classes:{invalid:this.opts.invalid,valid:this.opts.valid,validating:this.opts.validating},element:t,field:e,iconElement:n};this.core.emit("plugins.icon.placed",o),this.opts.onPlaced(o),this.icons.set(t,n)},t.prototype.onElementValidating=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!0,t)),i={element:e.element,field:e.field,iconElement:n,status:"Validating"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.onElementValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!e.valid,t[this.opts.valid]=e.valid,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:e.valid?"Valid":"Invalid"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.onElementNotValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"NotValidated"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.onElementIgnored=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"Ignored"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.setClasses=function(e,t,n,o){var l=t.getAttribute("type"),a="radio"===l||"checkbox"===l?n[0]:t;if(this.icons.has(a)){var d=this.icons.get(a);return i(d,o),d}return null},t}(t);export{o as Icon};
+1
-1

@@ -8,5 +8,5 @@ /**

* @package @form-validation/plugin-icon
* @version 2.0.2
* @version 2.1.0
*/
define(["exports","@form-validation/core"],(function(e,t){"use strict";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};var i=t.utils.classSet,o=function(e){function t(t){var n=e.call(this,t)||this;return n.icons=new Map,n.opts=Object.assign({},{invalid:"fv-plugins-icon--invalid",onPlaced:function(){},onSet:function(){},valid:"fv-plugins-icon--valid",validating:"fv-plugins-icon--validating"},t),n.elementValidatingHandler=n.onElementValidating.bind(n),n.elementValidatedHandler=n.onElementValidated.bind(n),n.elementNotValidatedHandler=n.onElementNotValidated.bind(n),n.elementIgnoredHandler=n.onElementIgnored.bind(n),n.fieldAddedHandler=n.onFieldAdded.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t.prototype.install=function(){this.core.on("core.element.validating",this.elementValidatingHandler).on("core.element.validated",this.elementValidatedHandler).on("core.element.notvalidated",this.elementNotValidatedHandler).on("core.element.ignored",this.elementIgnoredHandler).on("core.field.added",this.fieldAddedHandler)},t.prototype.uninstall=function(){this.icons.forEach((function(e){return e.parentNode.removeChild(e)})),this.icons.clear(),this.core.off("core.element.validating",this.elementValidatingHandler).off("core.element.validated",this.elementValidatedHandler).off("core.element.notvalidated",this.elementNotValidatedHandler).off("core.element.ignored",this.elementIgnoredHandler).off("core.field.added",this.fieldAddedHandler)},t.prototype.onFieldAdded=function(e){var t=this,n=e.elements;n&&(n.forEach((function(e){var n=t.icons.get(e);n&&(n.parentNode.removeChild(n),t.icons.delete(e))})),this.prepareFieldIcon(e.field,n))},t.prototype.prepareFieldIcon=function(e,t){var n=this;if(t.length){var i=t[0].getAttribute("type");"radio"===i||"checkbox"===i?this.prepareElementIcon(e,t[0]):t.forEach((function(t){return n.prepareElementIcon(e,t)}))}},t.prototype.prepareElementIcon=function(e,t){var n=document.createElement("i");n.setAttribute("data-field",e),t.parentNode.insertBefore(n,t.nextSibling),i(n,{"fv-plugins-icon":!0});var o={classes:{invalid:this.opts.invalid,valid:this.opts.valid,validating:this.opts.validating},element:t,field:e,iconElement:n};this.core.emit("plugins.icon.placed",o),this.opts.onPlaced(o),this.icons.set(t,n)},t.prototype.onElementValidating=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!0,t)),i={element:e.element,field:e.field,iconElement:n,status:"Validating"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.onElementValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!e.valid,t[this.opts.valid]=e.valid,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:e.valid?"Valid":"Invalid"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.onElementNotValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"NotValidated"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.onElementIgnored=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"Ignored"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},t.prototype.setClasses=function(e,t,n,o){var l=t.getAttribute("type"),a="radio"===l||"checkbox"===l?n[0]:t;if(this.icons.has(a)){var d=this.icons.get(a);return i(d,o),d}return null},t}(t.Plugin);e.Icon=o}));

@@ -8,5 +8,5 @@ /**

* @package @form-validation/plugin-icon
* @version 2.0.2
* @version 2.1.0
*/
"use strict";var e=require("@form-validation/core"),t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=e.utils.classSet,i=function(e){function i(t){var n=e.call(this,t)||this;return n.icons=new Map,n.opts=Object.assign({},{invalid:"fv-plugins-icon--invalid",onPlaced:function(){},onSet:function(){},valid:"fv-plugins-icon--valid",validating:"fv-plugins-icon--validating"},t),n.elementValidatingHandler=n.onElementValidating.bind(n),n.elementValidatedHandler=n.onElementValidated.bind(n),n.elementNotValidatedHandler=n.onElementNotValidated.bind(n),n.elementIgnoredHandler=n.onElementIgnored.bind(n),n.fieldAddedHandler=n.onFieldAdded.bind(n),n}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(i,e),i.prototype.install=function(){this.core.on("core.element.validating",this.elementValidatingHandler).on("core.element.validated",this.elementValidatedHandler).on("core.element.notvalidated",this.elementNotValidatedHandler).on("core.element.ignored",this.elementIgnoredHandler).on("core.field.added",this.fieldAddedHandler)},i.prototype.uninstall=function(){this.icons.forEach((function(e){return e.parentNode.removeChild(e)})),this.icons.clear(),this.core.off("core.element.validating",this.elementValidatingHandler).off("core.element.validated",this.elementValidatedHandler).off("core.element.notvalidated",this.elementNotValidatedHandler).off("core.element.ignored",this.elementIgnoredHandler).off("core.field.added",this.fieldAddedHandler)},i.prototype.onFieldAdded=function(e){var t=this,n=e.elements;n&&(n.forEach((function(e){var n=t.icons.get(e);n&&(n.parentNode.removeChild(n),t.icons.delete(e))})),this.prepareFieldIcon(e.field,n))},i.prototype.prepareFieldIcon=function(e,t){var n=this;if(t.length){var i=t[0].getAttribute("type");"radio"===i||"checkbox"===i?this.prepareElementIcon(e,t[0]):t.forEach((function(t){return n.prepareElementIcon(e,t)}))}},i.prototype.prepareElementIcon=function(e,t){var i=document.createElement("i");i.setAttribute("data-field",e),t.parentNode.insertBefore(i,t.nextSibling),n(i,{"fv-plugins-icon":!0});var o={classes:{invalid:this.opts.invalid,valid:this.opts.valid,validating:this.opts.validating},element:t,field:e,iconElement:i};this.core.emit("plugins.icon.placed",o),this.opts.onPlaced(o),this.icons.set(t,i)},i.prototype.onElementValidating=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!0,t)),i={element:e.element,field:e.field,iconElement:n,status:"Validating"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.onElementValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!e.valid,t[this.opts.valid]=e.valid,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:e.valid?"Valid":"Invalid"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.onElementNotValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"NotValidated"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.onElementIgnored=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"Ignored"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.setClasses=function(e,t,i,o){var l=t.getAttribute("type"),a="radio"===l||"checkbox"===l?i[0]:t;if(this.icons.has(a)){var d=this.icons.get(a);return n(d,o),d}return null},i}(e.Plugin);exports.Icon=i;

@@ -8,5 +8,5 @@ /**

* @package @form-validation/plugin-icon
* @version 2.0.2
* @version 2.1.0
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@form-validation/core")):"function"==typeof define&&define.amd?define(["@form-validation/core"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).FormValidation=e.FormValidation||{},e.FormValidation.plugins=e.FormValidation.plugins||{},e.FormValidation.plugins.Icon=t(e.FormValidation))}(this,(function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n=e.utils.classSet;return function(e){function i(t){var n=e.call(this,t)||this;return n.icons=new Map,n.opts=Object.assign({},{invalid:"fv-plugins-icon--invalid",onPlaced:function(){},onSet:function(){},valid:"fv-plugins-icon--valid",validating:"fv-plugins-icon--validating"},t),n.elementValidatingHandler=n.onElementValidating.bind(n),n.elementValidatedHandler=n.onElementValidated.bind(n),n.elementNotValidatedHandler=n.onElementNotValidated.bind(n),n.elementIgnoredHandler=n.onElementIgnored.bind(n),n.fieldAddedHandler=n.onFieldAdded.bind(n),n}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(i,e),i.prototype.install=function(){this.core.on("core.element.validating",this.elementValidatingHandler).on("core.element.validated",this.elementValidatedHandler).on("core.element.notvalidated",this.elementNotValidatedHandler).on("core.element.ignored",this.elementIgnoredHandler).on("core.field.added",this.fieldAddedHandler)},i.prototype.uninstall=function(){this.icons.forEach((function(e){return e.parentNode.removeChild(e)})),this.icons.clear(),this.core.off("core.element.validating",this.elementValidatingHandler).off("core.element.validated",this.elementValidatedHandler).off("core.element.notvalidated",this.elementNotValidatedHandler).off("core.element.ignored",this.elementIgnoredHandler).off("core.field.added",this.fieldAddedHandler)},i.prototype.onFieldAdded=function(e){var t=this,n=e.elements;n&&(n.forEach((function(e){var n=t.icons.get(e);n&&(n.parentNode.removeChild(n),t.icons.delete(e))})),this.prepareFieldIcon(e.field,n))},i.prototype.prepareFieldIcon=function(e,t){var n=this;if(t.length){var i=t[0].getAttribute("type");"radio"===i||"checkbox"===i?this.prepareElementIcon(e,t[0]):t.forEach((function(t){return n.prepareElementIcon(e,t)}))}},i.prototype.prepareElementIcon=function(e,t){var i=document.createElement("i");i.setAttribute("data-field",e),t.parentNode.insertBefore(i,t.nextSibling),n(i,{"fv-plugins-icon":!0});var o={classes:{invalid:this.opts.invalid,valid:this.opts.valid,validating:this.opts.validating},element:t,field:e,iconElement:i};this.core.emit("plugins.icon.placed",o),this.opts.onPlaced(o),this.icons.set(t,i)},i.prototype.onElementValidating=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!0,t)),i={element:e.element,field:e.field,iconElement:n,status:"Validating"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.onElementValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!e.valid,t[this.opts.valid]=e.valid,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:e.valid?"Valid":"Invalid"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.onElementNotValidated=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"NotValidated"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.onElementIgnored=function(e){var t,n=this.setClasses(e.field,e.element,e.elements,((t={})[this.opts.invalid]=!1,t[this.opts.valid]=!1,t[this.opts.validating]=!1,t)),i={element:e.element,field:e.field,iconElement:n,status:"Ignored"};this.core.emit("plugins.icon.set",i),this.opts.onSet(i)},i.prototype.setClasses=function(e,t,i,o){var l=t.getAttribute("type"),a="radio"===l||"checkbox"===l?i[0]:t;if(this.icons.has(a)){var d=this.icons.get(a);return n(d,o),d}return null},i}(e.Plugin)}));
{
"name": "@form-validation/plugin-icon",
"version": "2.0.2",
"version": "2.1.0",
"description": "The best validation library for JavaScript",

@@ -21,2 +21,3 @@ "license": "https://formvalidation.io/license",

"lib/cjs/*.*",
"lib/esm/*.*",
"lib/styles/*.*",

@@ -31,7 +32,7 @@ "lib/umd/*.*",

"devDependencies": {
"@form-validation/validator-email-address": "2.0.2",
"@form-validation/validator-not-empty": "2.0.2"
"@form-validation/validator-email-address": "2.1.0",
"@form-validation/validator-not-empty": "2.1.0"
},
"dependencies": {
"@form-validation/core": "2.0.2"
"@form-validation/core": "2.1.0"
},

@@ -38,0 +39,0 @@ "scripts": {