Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nette-forms

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nette-forms - npm Package Compare versions

Comparing version 3.3.5 to 3.3.6

2

package.json
{
"name": "nette-forms",
"version": "3.3.5",
"version": "3.3.6",
"description": "Client side script for Nette Forms Component",

@@ -5,0 +5,0 @@ "keywords": [

@@ -5,4 +5,4 @@ Nette Forms: greatly facilitates web forms

[![Downloads this Month](https://img.shields.io/packagist/dm/nette/forms.svg)](https://packagist.org/packages/nette/forms)
[![Tests](https://github.com/nette/forms/workflows/Tests/badge.svg?branch=master)](https://github.com/nette/forms/actions)
[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=master)](https://coveralls.io/github/nette/forms?branch=master)
[![Tests](https://github.com/nette/forms/actions/workflows/tests.yml/badge.svg?branch=v3.2)](https://github.com/nette/forms/actions)
[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=v3.2)](https://coveralls.io/github/nette/forms?branch=v3.2)
[![Latest Stable Version](https://poser.pugx.org/nette/forms/v/stable)](https://github.com/nette/forms/releases)

@@ -48,3 +48,3 @@ [![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/forms/blob/master/license.md)

It requires PHP version 7.2 and supports PHP up to 8.3.
It requires PHP version 8.1 and supports PHP up to 8.3.

@@ -51,0 +51,0 @@

@@ -481,4 +481,8 @@ /**!

integer: function(elem, arg, val) {
return (/^-?[0-9]+$/).test(val);
integer: function(elem, arg, val, value) {
if ((/^-?[0-9]+$/).test(val)) {
value.value = parseFloat(val);
return true;
}
return false;
},

@@ -489,3 +493,3 @@

if ((/^-?[0-9]*\.?[0-9]+$/).test(val)) {
value.value = val;
value.value = parseFloat(val);
return true;

@@ -492,0 +496,0 @@ }

@@ -1,22 +0,22 @@

(function(p,d){if(p.JSON)if("function"===typeof define&&define.amd)define(function(){return d(p)});else if("object"===typeof module&&"object"===typeof module.exports)module.exports=d(p);else{var u=!p.Nette||!p.Nette.noInit;p.Nette=d(p);u&&p.Nette.initOnLoad()}})("undefined"!==typeof window?window:this,function(p){var d={},u={},r={},x=new p.WeakMap;d.formErrors=[];d.version="3.3.0";d.invalidNumberMessage="Please enter a valid value.";d.onDocumentReady=function(a){"loading"!==document.readyState?a.call(this):
document.addEventListener("DOMContentLoaded",a)};d.getValue=function(a){var b;if(a){if(a.tagName){if("radio"===a.type){var c=a.form.elements;for(b=0;b<c.length;b++)if(c[b].name===a.name&&c[b].checked)return c[b].value;return null}if("file"===a.type)return a.files||a.value;if("select"===a.tagName.toLowerCase()){b=a.selectedIndex;c=a.options;var e=[];if("select-one"===a.type)return 0>b?null:c[b].value;for(b=0;b<c.length;b++)c[b].selected&&e.push(c[b].value);return e}if(a.name&&"[]"===a.name.substr(-2)){c=
a.form.elements[a.name].tagName?[a]:a.form.elements[a.name];e=[];for(b=0;b<c.length;b++)("checkbox"!==c[b].type||c[b].checked)&&e.push(c[b].value);return e}return"checkbox"===a.type?a.checked:"textarea"===a.tagName.toLowerCase()?a.value.replace("\r",""):a.value.replace("\r","").replace(/^\s+|\s+$/g,"")}return a[0]?d.getValue(a[0]):null}return null};d.getEffectiveValue=function(a,b){var c=d.getValue(a);a.getAttribute&&c===a.getAttribute("data-nette-empty-value")&&(c="");b&&void 0===u[a.name]&&(u[a.name]=
!0,b={value:c},d.validateControl(a,null,!0,b),c=b.value,delete u[a.name]);return c};d.validateControl=function(a,b,c,e,f){a=a.tagName?a:a[0];b=b||JSON.parse(a.getAttribute("data-nette-rules")||"[]");e=void 0===e?{value:d.getEffectiveValue(a)}:e;f=void 0===f?!d.validateRule(a,":filled",null,e):f;for(var g=0,q=b.length;g<q;g++){var h=b[g],k=h.op.match(/(~)?([^?]+)/),n=h.control?a.form.elements.namedItem(h.control):a;h.neg=k[1];h.op=k[2];h.condition=!!h.rules;if(n&&(!f||h.condition||":filled"===h.op)&&
(n=n.tagName?n:n[0],k=d.validateRule(n,h.op,h.arg,a===n?e:void 0),null!==k))if(h.neg&&(k=!k),h.condition&&k){if(!d.validateControl(a,h.rules,c,e,":blank"===h.op?!1:f))return!1}else if(!h.condition&&!k&&!d.isDisabled(n)){if(!c){var w=Array.isArray(h.arg)?h.arg:[h.arg];b=h.msg.replace(/%(value|\d+)/g,function(l,m){return d.getValue("value"===m?n:a.form.elements.namedItem(w[m].control))});d.addError(n,b)}return!1}}return!0};d.validateForm=function(a,b){a=a.form||a;var c=!1;d.formErrors=[];if(a["nette-submittedBy"]&&
null!==a["nette-submittedBy"].getAttribute("formnovalidate"))if(c=JSON.parse(a["nette-submittedBy"].getAttribute("data-nette-validation-scope")||"[]"),c.length)c=new RegExp("^("+c.join("-|")+"-)");else return d.showFormErrors(a,[]),!0;var e={},f;for(f=0;f<a.elements.length;f++){var g=a.elements[f];if(!g.tagName||g.tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}){if("radio"===g.type){if(e[g.name])continue;e[g.name]=!0}else if("number"===g.type&&g.validity.badInput&&!d.isDisabled(g)){if(b)return!1;
d.addError(g,d.invalidNumberMessage);continue}if(!(c&&!g.name.replace(/]\[|\[|]|$/g,"-").match(c)||d.isDisabled(g)||d.validateControl(g,null,b)||d.formErrors.length))return!1}}b=!d.formErrors.length;d.showFormErrors(a,d.formErrors);return b};d.isDisabled=function(a){if("radio"===a.type){for(var b=0,c=a.form.elements;b<c.length;b++)if(c[b].name===a.name&&!c[b].disabled)return!1;return!0}return a.disabled};d.addError=function(a,b){d.formErrors.push({element:a,message:b})};d.showFormErrors=function(a,
b){a=[];for(var c,e=0;e<b.length;e++){var f=b[e].element,g=b[e].message;0>a.indexOf(g)&&(a.push(g),!c&&f.focus&&(c=f))}a.length&&d.showModal(a.join("\n"),function(){c&&c.focus()})};d.showModal=function(a,b){var c=document.createElement("dialog");if(c.showModal){var e=document.createElement("style");e.innerText=".netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }";var f=document.createElement("button");f.innerText=
"OK";f.onclick=function(){c.remove();b()};c.setAttribute("class","netteFormsModal");c.innerText=a+"\n\n";c.append(e,f);document.body.append(c);c.showModal()}else alert(a),b()};d.validateRule=function(a,b,c,e){if("number"===a.type&&a.validity.badInput)return"filled"===b;e=void 0===e?{value:d.getEffectiveValue(a,!0)}:e;":"===b.charAt(0)&&(b=b.substr(1));b=b.replace("::","_");b=b.replace(/\\/g,"");for(var f=Array.isArray(c)?c.slice(0):[c],g=0,q=f.length;g<q;g++)if(f[g]&&f[g].control){var h=a.form.elements.namedItem(f[g].control);
f[g]=h===a?e.value:d.getEffectiveValue(h,!0)}return d.validators[b]?d.validators[b](a,Array.isArray(c)?f:f[0],e.value,e):null};d.validators={filled:function(a,b,c){return""!==c&&!1!==c&&null!==c&&(!Array.isArray(c)||!!c.length)&&(!(c instanceof FileList)||c.length)},blank:function(a,b,c){return!d.validators.filled(a,b,c)},valid:function(a){return d.validateControl(a,null,!0)},equal:function(a,b,c){if(void 0===b)return null;a=function(h){return"number"===typeof h||"string"===typeof h?""+h:!0===h?"1":
""};c=Array.isArray(c)?c:[c];b=Array.isArray(b)?b:[b];var e=0,f=c.length;a:for(;e<f;e++){for(var g=0,q=b.length;g<q;g++)if(a(c[e])===a(b[g]))continue a;return!1}return 0<c.length},notEqual:function(a,b,c){return void 0===b?null:!d.validators.equal(a,b,c)},minLength:function(a,b,c){return c.length>=b},maxLength:function(a,b,c){return c.length<=b},length:function(a,b,c){b=Array.isArray(b)?b:[b,b];return(null===b[0]||c.length>=b[0])&&(null===b[1]||c.length<=b[1])},email:function(a,b,c){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(c)},
url:function(a,b,c,e){/^[a-z\d+.-]+:/.test(c)||(c="https://"+c);return/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(c)?(e.value=c,!0):!1},regexp:function(a,b,c){a="string"===typeof b?b.match(/^\/(.*)\/([imu]*)$/):
!1;try{return a&&(new RegExp(a[1],a[2].replace("u",""))).test(c)}catch(e){}},pattern:function(a,b,c,e,f){if("string"!==typeof b)return null;try{try{var g=new RegExp("^(?:"+b+")$",f?"ui":"u")}catch(q){g=new RegExp("^(?:"+b+")$",f?"i":"")}if(c instanceof FileList){for(a=0;a<c.length;a++)if(!g.test(c[a].name))return!1;return!0}return g.test(c)}catch(q){}},patternCaseInsensitive:function(a,b,c){return d.validators.pattern(a,b,c,null,!0)},numeric:function(a,b,c){return/^[0-9]+$/.test(c)},integer:function(a,
b,c){return/^-?[0-9]+$/.test(c)},"float":function(a,b,c,e){c=c.replace(/ +/g,"").replace(/,/g,".");return/^-?[0-9]*\.?[0-9]+$/.test(c)?(e.value=c,!0):!1},min:function(a,b,c){Number.isFinite(b)&&(c=parseFloat(c));return c>=b},max:function(a,b,c){Number.isFinite(b)&&(c=parseFloat(c));return c<=b},range:function(a,b,c){return Array.isArray(b)?"time"===a.type&&b[0]>b[1]?c>=b[0]||c<=b[1]:(null===b[0]||d.validators.min(a,b[0],c))&&(null===b[1]||d.validators.max(a,b[1],c)):null},submitted:function(a){return a.form["nette-submittedBy"]===
a},fileSize:function(a,b,c){for(a=0;a<c.length;a++)if(c[a].size>b)return!1;return!0},mimeType:function(a,b,c){b=Array.isArray(b)?b:[b];for(var e=0,f=b.length,g=[];e<f;e++)g.push("^"+b[e].replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$");g=new RegExp(g.join("|"));if(c instanceof FileList)for(e=0;e<c.length;e++){if(c[e].type&&!g.test(c[e].type))return!1;if(a.validity.badInput)return null}return!0},image:function(a,b,c){return d.validators.mimeType(a,b||["image/gif","image/png","image/jpeg","image/webp"],
c)},"static":function(a,b){return b}};d.toggleForm=function(a,b){var c;r={};for(c=0;c<a.elements.length;c++)a.elements[c].tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}&&d.toggleControl(a.elements[c],null,null,!b);for(c in r)d.toggle(c,r[c].state,r[c].elem,b)};d.toggleControl=function(a,b,c,e,f,g){b=b||JSON.parse(a.getAttribute("data-nette-rules")||"[]");f=void 0===f?{value:d.getEffectiveValue(a)}:f;g=void 0===g?!d.validateRule(a,":filled",null,f):g;for(var q=!1,h=function(y){d.toggleForm(a.form,
y)},k,n=0,w=b.length;n<w;n++){var l=b[n];k=l.op.match(/(~)?([^?]+)/);var m=l.control?a.form.elements.namedItem(l.control):a;l.neg=k[1];l.op=k[2];l.condition=!!l.rules;if(m&&(!g||l.condition||":filled"===l.op)){k=c;if(!1!==c){k=d.validateRule(m,l.op,l.arg,a===m?f:void 0);if(null===k)continue;else l.neg&&(k=!k);l.condition||(c=k)}if(l.condition&&d.toggleControl(a,l.rules,k,e,f,":blank"===l.op?!1:g)||l.toggle){q=!0;if(e){var z=m.tagName?m.name:m[0].name;m=m.tagName?m.form.elements:m;for(var t=0;t<m.length;t++)m[t].name!==
z||x.has(m[t])||(m[t].addEventListener("change",h),x.set(m[t],null))}for(var v in l.toggle||[])r[v]=r[v]||{elem:a},r[v].state=r[v].state||(l.toggle[v]?k:!k)}}}return q};d.toggle=function(a,b,c,e){/^\w[\w.:-]*$/.test(a)&&(a="#"+a);a=document.querySelectorAll(a);for(c=0;c<a.length;c++)a[c].hidden=!b};d.compactCheckboxes=function(a){var b,c={};for(b=0;b<a.elements.length;b++){var e=a.elements[b];if(e.tagName&&"input"===e.tagName.toLowerCase()&&"checkbox"===e.type){if(e.name&&"[]"===e.name.substr(-2)){var f=
e.name.substr(0,e.name.length-2);e.removeAttribute("name");e.setAttribute("data-nette-name",f)}if(f=e.getAttribute("data-nette-name"))c[f]=c[f]||[],e.checked&&!e.disabled&&c[f].push(e.value)}}for(f in c)void 0===a.elements[f]&&(e=document.createElement("input"),e.setAttribute("name",f),e.setAttribute("type","hidden"),a.append(e)),a.elements[f].value=c[f].join(","),a.elements[f].disabled=0===c[f].length};d.initForm=function(a){"get"===a.method&&a.hasAttribute("data-nette-compact")&&a.addEventListener("submit",
function(){d.compactCheckboxes(a)});a:{for(var b=0;b<a.elements.length;b++)if(a.elements[b].getAttribute("data-nette-rules"))break a;return}d.toggleForm(a);a.noValidate||(a.noValidate=!0,a.addEventListener("submit",function(c){d.validateForm(a)||(c.stopPropagation(),c.preventDefault())}),a.addEventListener("reset",function(){setTimeout(function(){d.toggleForm(a)})}))};d.initOnLoad=function(){d.onDocumentReady(function(){for(var a=0;a<document.forms.length;a++)d.initForm(document.forms[a]);document.body.addEventListener("click",
function(b){for(b=b.target;b;){if(b.form&&b.type in{submit:1,image:1}){b.form["nette-submittedBy"]=b;break}b=b.parentNode}})})};d.webalize=function(a){a=a.toLowerCase();var b="",c;for(c=0;c<a.length;c++){var e=d.webalizeTable[a.charAt(c)];b+=e?e:a.charAt(c)}return b.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")};d.webalizeTable={"\u00e1":"a","\u00e4":"a","\u010d":"c","\u010f":"d","\u00e9":"e","\u011b":"e","\u00ed":"i","\u013e":"l","\u0148":"n","\u00f3":"o","\u00f4":"o","\u0159":"r","\u0161":"s",
"\u0165":"t","\u00fa":"u","\u016f":"u","\u00fd":"y","\u017e":"z"};return d});
(function(p,e){if(p.JSON)if("function"===typeof define&&define.amd)define(function(){return e(p)});else if("object"===typeof module&&"object"===typeof module.exports)module.exports=e(p);else{var u=!p.Nette||!p.Nette.noInit;p.Nette=e(p);u&&p.Nette.initOnLoad()}})("undefined"!==typeof window?window:this,function(p){var e={},u={},r={},x=new p.WeakMap;e.formErrors=[];e.version="3.3.0";e.invalidNumberMessage="Please enter a valid value.";e.onDocumentReady=function(a){"loading"!==document.readyState?a.call(this):
document.addEventListener("DOMContentLoaded",a)};e.getValue=function(a){var b;if(a){if(a.tagName){if("radio"===a.type){var c=a.form.elements;for(b=0;b<c.length;b++)if(c[b].name===a.name&&c[b].checked)return c[b].value;return null}if("file"===a.type)return a.files||a.value;if("select"===a.tagName.toLowerCase()){b=a.selectedIndex;c=a.options;var d=[];if("select-one"===a.type)return 0>b?null:c[b].value;for(b=0;b<c.length;b++)c[b].selected&&d.push(c[b].value);return d}if(a.name&&"[]"===a.name.substr(-2)){c=
a.form.elements[a.name].tagName?[a]:a.form.elements[a.name];d=[];for(b=0;b<c.length;b++)("checkbox"!==c[b].type||c[b].checked)&&d.push(c[b].value);return d}return"checkbox"===a.type?a.checked:"textarea"===a.tagName.toLowerCase()?a.value.replace("\r",""):a.value.replace("\r","").replace(/^\s+|\s+$/g,"")}return a[0]?e.getValue(a[0]):null}return null};e.getEffectiveValue=function(a,b){var c=e.getValue(a);a.getAttribute&&c===a.getAttribute("data-nette-empty-value")&&(c="");b&&void 0===u[a.name]&&(u[a.name]=
!0,b={value:c},e.validateControl(a,null,!0,b),c=b.value,delete u[a.name]);return c};e.validateControl=function(a,b,c,d,f){a=a.tagName?a:a[0];b=b||JSON.parse(a.getAttribute("data-nette-rules")||"[]");d=void 0===d?{value:e.getEffectiveValue(a)}:d;f=void 0===f?!e.validateRule(a,":filled",null,d):f;for(var g=0,q=b.length;g<q;g++){var h=b[g],k=h.op.match(/(~)?([^?]+)/),n=h.control?a.form.elements.namedItem(h.control):a;h.neg=k[1];h.op=k[2];h.condition=!!h.rules;if(n&&(!f||h.condition||":filled"===h.op)&&
(n=n.tagName?n:n[0],k=e.validateRule(n,h.op,h.arg,a===n?d:void 0),null!==k))if(h.neg&&(k=!k),h.condition&&k){if(!e.validateControl(a,h.rules,c,d,":blank"===h.op?!1:f))return!1}else if(!h.condition&&!k&&!e.isDisabled(n)){if(!c){var w=Array.isArray(h.arg)?h.arg:[h.arg];b=h.msg.replace(/%(value|\d+)/g,function(l,m){return e.getValue("value"===m?n:a.form.elements.namedItem(w[m].control))});e.addError(n,b)}return!1}}return!0};e.validateForm=function(a,b){a=a.form||a;var c=!1;e.formErrors=[];if(a["nette-submittedBy"]&&
null!==a["nette-submittedBy"].getAttribute("formnovalidate"))if(c=JSON.parse(a["nette-submittedBy"].getAttribute("data-nette-validation-scope")||"[]"),c.length)c=new RegExp("^("+c.join("-|")+"-)");else return e.showFormErrors(a,[]),!0;var d={},f;for(f=0;f<a.elements.length;f++){var g=a.elements[f];if(!g.tagName||g.tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}){if("radio"===g.type){if(d[g.name])continue;d[g.name]=!0}else if("number"===g.type&&g.validity.badInput&&!e.isDisabled(g)){if(b)return!1;
e.addError(g,e.invalidNumberMessage);continue}if(!(c&&!g.name.replace(/]\[|\[|]|$/g,"-").match(c)||e.isDisabled(g)||e.validateControl(g,null,b)||e.formErrors.length))return!1}}b=!e.formErrors.length;e.showFormErrors(a,e.formErrors);return b};e.isDisabled=function(a){if("radio"===a.type){for(var b=0,c=a.form.elements;b<c.length;b++)if(c[b].name===a.name&&!c[b].disabled)return!1;return!0}return a.disabled};e.addError=function(a,b){e.formErrors.push({element:a,message:b})};e.showFormErrors=function(a,
b){a=[];for(var c,d=0;d<b.length;d++){var f=b[d].element,g=b[d].message;0>a.indexOf(g)&&(a.push(g),!c&&f.focus&&(c=f))}a.length&&e.showModal(a.join("\n"),function(){c&&c.focus()})};e.showModal=function(a,b){var c=document.createElement("dialog");if(c.showModal){var d=document.createElement("style");d.innerText=".netteFormsModal { text-align: center; margin: auto; border: 2px solid black; padding: 1rem } .netteFormsModal button { padding: .1em 2em }";var f=document.createElement("button");f.innerText=
"OK";f.onclick=function(){c.remove();b()};c.setAttribute("class","netteFormsModal");c.innerText=a+"\n\n";c.append(d,f);document.body.append(c);c.showModal()}else alert(a),b()};e.validateRule=function(a,b,c,d){if("number"===a.type&&a.validity.badInput)return"filled"===b;d=void 0===d?{value:e.getEffectiveValue(a,!0)}:d;":"===b.charAt(0)&&(b=b.substr(1));b=b.replace("::","_");b=b.replace(/\\/g,"");for(var f=Array.isArray(c)?c.slice(0):[c],g=0,q=f.length;g<q;g++)if(f[g]&&f[g].control){var h=a.form.elements.namedItem(f[g].control);
f[g]=h===a?d.value:e.getEffectiveValue(h,!0)}return e.validators[b]?e.validators[b](a,Array.isArray(c)?f:f[0],d.value,d):null};e.validators={filled:function(a,b,c){return""!==c&&!1!==c&&null!==c&&(!Array.isArray(c)||!!c.length)&&(!(c instanceof FileList)||c.length)},blank:function(a,b,c){return!e.validators.filled(a,b,c)},valid:function(a){return e.validateControl(a,null,!0)},equal:function(a,b,c){if(void 0===b)return null;a=function(h){return"number"===typeof h||"string"===typeof h?""+h:!0===h?"1":
""};c=Array.isArray(c)?c:[c];b=Array.isArray(b)?b:[b];var d=0,f=c.length;a:for(;d<f;d++){for(var g=0,q=b.length;g<q;g++)if(a(c[d])===a(b[g]))continue a;return!1}return 0<c.length},notEqual:function(a,b,c){return void 0===b?null:!e.validators.equal(a,b,c)},minLength:function(a,b,c){return c.length>=b},maxLength:function(a,b,c){return c.length<=b},length:function(a,b,c){b=Array.isArray(b)?b:[b,b];return(null===b[0]||c.length>=b[0])&&(null===b[1]||c.length<=b[1])},email:function(a,b,c){return/^("([ !#-[\]-~]|\\[ -~])+"|[-a-z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#$%&'*+/=?^_`{|}~]+)*)@([0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)+[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?$/i.test(c)},
url:function(a,b,c,d){/^[a-z\d+.-]+:/.test(c)||(c="https://"+c);return/^https?:\/\/((([-_0-9a-z\u00C0-\u02FF\u0370-\u1EFF]+\.)*[0-9a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,61}[0-9a-z\u00C0-\u02FF\u0370-\u1EFF])?\.)?[a-z\u00C0-\u02FF\u0370-\u1EFF]([-0-9a-z\u00C0-\u02FF\u0370-\u1EFF]{0,17}[a-z\u00C0-\u02FF\u0370-\u1EFF])?|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[[0-9a-f:]{3,39}\])(:\d{1,5})?(\/\S*)?$/i.test(c)?(d.value=c,!0):!1},regexp:function(a,b,c){a="string"===typeof b?b.match(/^\/(.*)\/([imu]*)$/):
!1;try{return a&&(new RegExp(a[1],a[2].replace("u",""))).test(c)}catch(d){}},pattern:function(a,b,c,d,f){if("string"!==typeof b)return null;try{try{var g=new RegExp("^(?:"+b+")$",f?"ui":"u")}catch(q){g=new RegExp("^(?:"+b+")$",f?"i":"")}if(c instanceof FileList){for(a=0;a<c.length;a++)if(!g.test(c[a].name))return!1;return!0}return g.test(c)}catch(q){}},patternCaseInsensitive:function(a,b,c){return e.validators.pattern(a,b,c,null,!0)},numeric:function(a,b,c){return/^[0-9]+$/.test(c)},integer:function(a,
b,c,d){return/^-?[0-9]+$/.test(c)?(d.value=parseFloat(c),!0):!1},"float":function(a,b,c,d){c=c.replace(/ +/g,"").replace(/,/g,".");return/^-?[0-9]*\.?[0-9]+$/.test(c)?(d.value=parseFloat(c),!0):!1},min:function(a,b,c){Number.isFinite(b)&&(c=parseFloat(c));return c>=b},max:function(a,b,c){Number.isFinite(b)&&(c=parseFloat(c));return c<=b},range:function(a,b,c){return Array.isArray(b)?"time"===a.type&&b[0]>b[1]?c>=b[0]||c<=b[1]:(null===b[0]||e.validators.min(a,b[0],c))&&(null===b[1]||e.validators.max(a,
b[1],c)):null},submitted:function(a){return a.form["nette-submittedBy"]===a},fileSize:function(a,b,c){for(a=0;a<c.length;a++)if(c[a].size>b)return!1;return!0},mimeType:function(a,b,c){b=Array.isArray(b)?b:[b];for(var d=0,f=b.length,g=[];d<f;d++)g.push("^"+b[d].replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$");g=new RegExp(g.join("|"));if(c instanceof FileList)for(d=0;d<c.length;d++){if(c[d].type&&!g.test(c[d].type))return!1;if(a.validity.badInput)return null}return!0},image:function(a,b,c){return e.validators.mimeType(a,
b||["image/gif","image/png","image/jpeg","image/webp"],c)},"static":function(a,b){return b}};e.toggleForm=function(a,b){var c;r={};for(c=0;c<a.elements.length;c++)a.elements[c].tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}&&e.toggleControl(a.elements[c],null,null,!b);for(c in r)e.toggle(c,r[c].state,r[c].elem,b)};e.toggleControl=function(a,b,c,d,f,g){b=b||JSON.parse(a.getAttribute("data-nette-rules")||"[]");f=void 0===f?{value:e.getEffectiveValue(a)}:f;g=void 0===g?!e.validateRule(a,
":filled",null,f):g;for(var q=!1,h=function(y){e.toggleForm(a.form,y)},k,n=0,w=b.length;n<w;n++){var l=b[n];k=l.op.match(/(~)?([^?]+)/);var m=l.control?a.form.elements.namedItem(l.control):a;l.neg=k[1];l.op=k[2];l.condition=!!l.rules;if(m&&(!g||l.condition||":filled"===l.op)){k=c;if(!1!==c){k=e.validateRule(m,l.op,l.arg,a===m?f:void 0);if(null===k)continue;else l.neg&&(k=!k);l.condition||(c=k)}if(l.condition&&e.toggleControl(a,l.rules,k,d,f,":blank"===l.op?!1:g)||l.toggle){q=!0;if(d){var z=m.tagName?
m.name:m[0].name;m=m.tagName?m.form.elements:m;for(var t=0;t<m.length;t++)m[t].name!==z||x.has(m[t])||(m[t].addEventListener("change",h),x.set(m[t],null))}for(var v in l.toggle||[])r[v]=r[v]||{elem:a},r[v].state=r[v].state||(l.toggle[v]?k:!k)}}}return q};e.toggle=function(a,b,c,d){/^\w[\w.:-]*$/.test(a)&&(a="#"+a);a=document.querySelectorAll(a);for(c=0;c<a.length;c++)a[c].hidden=!b};e.compactCheckboxes=function(a){var b,c={};for(b=0;b<a.elements.length;b++){var d=a.elements[b];if(d.tagName&&"input"===
d.tagName.toLowerCase()&&"checkbox"===d.type){if(d.name&&"[]"===d.name.substr(-2)){var f=d.name.substr(0,d.name.length-2);d.removeAttribute("name");d.setAttribute("data-nette-name",f)}if(f=d.getAttribute("data-nette-name"))c[f]=c[f]||[],d.checked&&!d.disabled&&c[f].push(d.value)}}for(f in c)void 0===a.elements[f]&&(d=document.createElement("input"),d.setAttribute("name",f),d.setAttribute("type","hidden"),a.append(d)),a.elements[f].value=c[f].join(","),a.elements[f].disabled=0===c[f].length};e.initForm=
function(a){"get"===a.method&&a.hasAttribute("data-nette-compact")&&a.addEventListener("submit",function(){e.compactCheckboxes(a)});a:{for(var b=0;b<a.elements.length;b++)if(a.elements[b].getAttribute("data-nette-rules"))break a;return}e.toggleForm(a);a.noValidate||(a.noValidate=!0,a.addEventListener("submit",function(c){e.validateForm(a)||(c.stopPropagation(),c.preventDefault())}),a.addEventListener("reset",function(){setTimeout(function(){e.toggleForm(a)})}))};e.initOnLoad=function(){e.onDocumentReady(function(){for(var a=
0;a<document.forms.length;a++)e.initForm(document.forms[a]);document.body.addEventListener("click",function(b){for(b=b.target;b;){if(b.form&&b.type in{submit:1,image:1}){b.form["nette-submittedBy"]=b;break}b=b.parentNode}})})};e.webalize=function(a){a=a.toLowerCase();var b="",c;for(c=0;c<a.length;c++){var d=e.webalizeTable[a.charAt(c)];b+=d?d:a.charAt(c)}return b.replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")};e.webalizeTable={"\u00e1":"a","\u00e4":"a","\u010d":"c","\u010f":"d","\u00e9":"e","\u011b":"e",
"\u00ed":"i","\u013e":"l","\u0148":"n","\u00f3":"o","\u00f4":"o","\u0159":"r","\u0161":"s","\u0165":"t","\u00fa":"u","\u016f":"u","\u00fd":"y","\u017e":"z"};return e});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc