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.0.3 to 3.0.4

2

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

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

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

It requires PHP version 7.1 and supports PHP up to 7.3.
It requires PHP version 7.1 and supports PHP up to 7.4.
Client-side support can be installed with npm or yarn:
```
npm install nette-forms
```
Usage

@@ -44,0 +50,0 @@ -----

@@ -539,8 +539,15 @@ /**

image: function (elem, arg, val) {
if (window.FileList && val instanceof window.FileList) {
for (var i = 0; i < val.length; i++) {
var type = val[i].type;
if (type && type !== 'image/gif' && type !== 'image/png' && type !== 'image/jpeg') {
mimeType: function (elem, arg, val) {
arg = Array.isArray(arg) ? arg : [arg];
for (var i = 0, len = arg.length, re = []; i < len; i++) {
re.push('^' + arg[i].replace(/([^\w])/g, '\\$1').replace('\\*', '.*') + '$');
}
re = new RegExp(re.join('|'));
if (window.FileList && val instanceof FileList) {
for (i = 0; i < val.length; i++) {
if (val[i].type && !re.test(val[i].type)) {
return false;
} else if (elem.validity.badInput) {
return null;
}

@@ -552,2 +559,6 @@ }

image: function (elem, arg, val) {
return Nette.validators.mimeType(elem, ['image/gif', 'image/png', 'image/jpeg', 'image/webp'], val);
},
'static': function (elem, arg) {

@@ -554,0 +565,0 @@ return arg;

@@ -5,9 +5,9 @@ /*! netteForms.js | (c) 2004 David Grudl (https://davidgrudl.com) */

f=[];for(c=0;c<b.length;c++)("checkbox"!==b[c].type||b[c].checked)&&f.push(b[c].value);return f}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,c){var b=d.getValue(a);a.getAttribute&&b===a.getAttribute("data-nette-empty-value")&&(b="");c&&void 0===q[a.name]&&(q[a.name]=!0,b={value:b},d.validateControl(a,null,!0,b),b=b.value,
delete q[a.name]);return b};d.validateControl=function(a,c,b,f,l){a=a.tagName?a:a[0];c=c||JSON.parse(a.getAttribute("data-nette-rules")||"[]");f=void 0===f?{value:d.getEffectiveValue(a)}:f;l=l||!d.validateRule(a,":filled",null,f);for(var h=0,p=c.length;h<p;h++){var g=c[h],k=g.op.match(/(~)?([^?]+)/),e=g.control?a.form.elements.namedItem(g.control):a;g.neg=k[1];g.op=k[2];g.condition=!!g.rules;if(e&&(!l||g.condition||":filled"===g.op)&&(e=e.tagName?e:e[0],k=d.validateRule(e,g.op,g.arg,a===e?f:void 0),
null!==k))if(g.neg&&(k=!k),g.condition&&k){if(!d.validateControl(a,g.rules,b,f,":blank"===g.op?!1:l))return!1}else if(!g.condition&&!k&&!d.isDisabled(e)){if(!b){var q=Array.isArray(g.arg)?g.arg:[g.arg];c=g.msg.replace(/%(value|\d+)/g,function(b,c){return d.getValue("value"===c?e:a.form.elements.namedItem(q[c].control))});d.addError(e,c)}return!1}}return"number"!==a.type||a.validity.valid?!0:(b||d.addError(a,"Please enter a valid value."),!1)};d.validateForm=function(a,c){var b=a.form||a,f=!1;d.formErrors=
[];if(b["nette-submittedBy"]&&null!==b["nette-submittedBy"].getAttribute("formnovalidate"))if(f=JSON.parse(b["nette-submittedBy"].getAttribute("data-nette-validation-scope")||"[]"),f.length)f=new RegExp("^("+f.join("-|")+"-)");else return d.showFormErrors(b,[]),!0;var l={},h;for(h=0;h<b.elements.length;h++){var e=b.elements[h];if(!e.tagName||e.tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}){if("radio"===e.type){if(l[e.name])continue;l[e.name]=!0}if(!(f&&!e.name.replace(/]\[|\[|]|$/g,
"-").match(f)||d.isDisabled(e)||d.validateControl(e,null,c)||d.formErrors.length))return!1}}f=!d.formErrors.length;d.showFormErrors(b,d.formErrors);return f};d.isDisabled=function(a){if("radio"===a.type){for(var c=0,b=a.form.elements;c<b.length;c++)if(b[c].name===a.name&&!b[c].disabled)return!1;return!0}return a.disabled};d.addError=function(a,c){d.formErrors.push({element:a,message:c})};d.showFormErrors=function(a,c){for(var b=[],d,e=0;e<c.length;e++){var h=c[e].element,p=c[e].message;0>b.indexOf(p)&&
(b.push(p),!d&&h.focus&&(d=h))}b.length&&(alert(b.join("\n")),d&&d.focus())};d.validateRule=function(a,c,b,f){f=void 0===f?{value:d.getEffectiveValue(a,!0)}:f;":"===c.charAt(0)&&(c=c.substr(1));c=c.replace("::","_");c=c.replace(/\\/g,"");for(var e=Array.isArray(b)?b.slice(0):[b],h=0,p=e.length;h<p;h++)if(e[h]&&e[h].control){var g=a.form.elements.namedItem(e[h].control);e[h]=g===a?f.value:d.getEffectiveValue(g,!0)}return d.validators[c]?d.validators[c](a,Array.isArray(b)?e:e[0],f.value,f):null};d.validators=
delete q[a.name]);return b};d.validateControl=function(a,c,b,f,l){a=a.tagName?a:a[0];c=c||JSON.parse(a.getAttribute("data-nette-rules")||"[]");f=void 0===f?{value:d.getEffectiveValue(a)}:f;l=l||!d.validateRule(a,":filled",null,f);for(var g=0,p=c.length;g<p;g++){var h=c[g],k=h.op.match(/(~)?([^?]+)/),e=h.control?a.form.elements.namedItem(h.control):a;h.neg=k[1];h.op=k[2];h.condition=!!h.rules;if(e&&(!l||h.condition||":filled"===h.op)&&(e=e.tagName?e:e[0],k=d.validateRule(e,h.op,h.arg,a===e?f:void 0),
null!==k))if(h.neg&&(k=!k),h.condition&&k){if(!d.validateControl(a,h.rules,b,f,":blank"===h.op?!1:l))return!1}else if(!h.condition&&!k&&!d.isDisabled(e)){if(!b){var q=Array.isArray(h.arg)?h.arg:[h.arg];c=h.msg.replace(/%(value|\d+)/g,function(b,c){return d.getValue("value"===c?e:a.form.elements.namedItem(q[c].control))});d.addError(e,c)}return!1}}return"number"!==a.type||a.validity.valid?!0:(b||d.addError(a,"Please enter a valid value."),!1)};d.validateForm=function(a,c){var b=a.form||a,f=!1;d.formErrors=
[];if(b["nette-submittedBy"]&&null!==b["nette-submittedBy"].getAttribute("formnovalidate"))if(f=JSON.parse(b["nette-submittedBy"].getAttribute("data-nette-validation-scope")||"[]"),f.length)f=new RegExp("^("+f.join("-|")+"-)");else return d.showFormErrors(b,[]),!0;var l={},g;for(g=0;g<b.elements.length;g++){var e=b.elements[g];if(!e.tagName||e.tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}){if("radio"===e.type){if(l[e.name])continue;l[e.name]=!0}if(!(f&&!e.name.replace(/]\[|\[|]|$/g,
"-").match(f)||d.isDisabled(e)||d.validateControl(e,null,c)||d.formErrors.length))return!1}}f=!d.formErrors.length;d.showFormErrors(b,d.formErrors);return f};d.isDisabled=function(a){if("radio"===a.type){for(var c=0,b=a.form.elements;c<b.length;c++)if(b[c].name===a.name&&!b[c].disabled)return!1;return!0}return a.disabled};d.addError=function(a,c){d.formErrors.push({element:a,message:c})};d.showFormErrors=function(a,c){for(var b=[],f,d=0;d<c.length;d++){var e=c[d].element,p=c[d].message;0>b.indexOf(p)&&
(b.push(p),!f&&e.focus&&(f=e))}b.length&&(alert(b.join("\n")),f&&f.focus())};d.validateRule=function(a,c,b,f){f=void 0===f?{value:d.getEffectiveValue(a,!0)}:f;":"===c.charAt(0)&&(c=c.substr(1));c=c.replace("::","_");c=c.replace(/\\/g,"");for(var e=Array.isArray(b)?b.slice(0):[b],g=0,p=e.length;g<p;g++)if(e[g]&&e[g].control){var h=a.form.elements.namedItem(e[g].control);e[g]=h===a?f.value:d.getEffectiveValue(h,!0)}return d.validators[c]?d.validators[c](a,Array.isArray(b)?e:e[0],f.value,f):null};d.validators=
{filled:function(a,c,b){return"number"===a.type&&a.validity.badInput?!0:""!==b&&!1!==b&&null!==b&&(!Array.isArray(b)||!!b.length)&&(!e.FileList||!(b instanceof e.FileList)||b.length)},blank:function(a,c,b){return!d.validators.filled(a,c,b)},valid:function(a){return d.validateControl(a,null,!0)},equal:function(a,c,b){function d(a){return"number"===typeof a||"string"===typeof a?""+a:!0===a?"1":""}if(void 0===c)return null;b=Array.isArray(b)?b:[b];c=Array.isArray(c)?c:[c];a=0;var e=b.length;a:for(;a<
e;a++){for(var h=0,p=c.length;h<p;h++)if(d(b[a])===d(c[h]))continue a;return!1}return!0},notEqual:function(a,c,b){return void 0===c?null:!d.validators.equal(a,c,b)},minLength:function(a,c,b){if("number"===a.type){if(a.validity.tooShort)return!1;if(a.validity.badInput)return null}return b.length>=c},maxLength:function(a,c,b){if("number"===a.type){if(a.validity.tooLong)return!1;if(a.validity.badInput)return null}return b.length<=c},length:function(a,c,b){if("number"===a.type){if(a.validity.tooShort||
e;a++){for(var g=0,p=c.length;g<p;g++)if(d(b[a])===d(c[g]))continue a;return!1}return!0},notEqual:function(a,c,b){return void 0===c?null:!d.validators.equal(a,c,b)},minLength:function(a,c,b){if("number"===a.type){if(a.validity.tooShort)return!1;if(a.validity.badInput)return null}return b.length>=c},maxLength:function(a,c,b){if("number"===a.type){if(a.validity.tooLong)return!1;if(a.validity.badInput)return null}return b.length<=c},length:function(a,c,b){if("number"===a.type){if(a.validity.tooShort||
a.validity.tooLong)return!1;if(a.validity.badInput)return null}c=Array.isArray(c)?c:[c,c];return(null===c[0]||b.length>=c[0])&&(null===c[1]||b.length<=c[1])},email:function(a,c,b){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(b)},

@@ -17,7 +17,8 @@ url:function(a,c,b,d){/^[a-z\d+.-]+:/.test(b)||(b="http://"+b);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(b)?(d.value=b,!0):!1},regexp:function(a,c,b){a="string"===typeof c?c.match(/^\/(.*)\/([imu]*)$/):

!1:/^[0-9]+$/.test(b)},integer:function(a,c,b){return"number"===a.type&&a.validity.badInput?!1:/^-?[0-9]+$/.test(b)},"float":function(a,c,b,d){if("number"===a.type&&a.validity.badInput)return!1;b=b.replace(/ +/g,"").replace(/,/g,".");return/^-?[0-9]*\.?[0-9]+$/.test(b)?(d.value=b,!0):!1},min:function(a,c,b){if("number"===a.type){if(a.validity.rangeUnderflow)return!1;if(a.validity.badInput)return null}return null===c||parseFloat(b)>=c},max:function(a,c,b){if("number"===a.type){if(a.validity.rangeOverflow)return!1;
if(a.validity.badInput)return null}return null===c||parseFloat(b)<=c},range:function(a,c,b){if("number"===a.type){if(a.validity.rangeUnderflow||a.validity.rangeOverflow)return!1;if(a.validity.badInput)return null}return Array.isArray(c)?(null===c[0]||parseFloat(b)>=c[0])&&(null===c[1]||parseFloat(b)<=c[1]):null},submitted:function(a){return a.form["nette-submittedBy"]===a},fileSize:function(a,c,b){if(e.FileList)for(a=0;a<b.length;a++)if(b[a].size>c)return!1;return!0},image:function(a,c,b){if(e.FileList&&
b instanceof e.FileList)for(a=0;a<b.length;a++)if((c=b[a].type)&&"image/gif"!==c&&"image/png"!==c&&"image/jpeg"!==c)return!1;return!0},"static":function(a,c){return c}};d.toggleForm=function(a,c){var b;t={};for(b=0;b<a.elements.length;b++)a.elements[b].tagName.toLowerCase()in{input:1,select:1,textarea:1,button:1}&&d.toggleControl(a.elements[b],null,null,!c);for(b in t)d.toggle(b,t[b],c)};d.toggleControl=function(a,c,b,e,l){c=c||JSON.parse(a.getAttribute("data-nette-rules")||"[]");l=void 0===l?{value:d.getEffectiveValue(a)}:
l;for(var f=!1,p=[],g=function(){d.toggleForm(a.form,a)},k,q=0,w=c.length;q<w;q++){var m=c[q],u=m.op.match(/(~)?([^?]+)/),n=m.control?a.form.elements.namedItem(m.control):a;if(n){k=b;if(!1!==b){m.neg=u[1];m.op=u[2];k=d.validateRule(n,m.op,m.arg,a===n?l:void 0);if(null===k)continue;else m.neg&&(k=!k);m.rules||(b=k)}if(m.rules&&d.toggleControl(a,m.rules,k,e,l)||m.toggle){f=!0;if(e){u=n.tagName?n.name:n[0].name;n=n.tagName?n.form.elements:n;for(var r=0;r<n.length;r++)n[r].name===u&&0>p.indexOf(n[r])&&
(n[r].addEventListener("change",g),p.push(n[r]))}for(var v in m.toggle||[])Object.prototype.hasOwnProperty.call(m.toggle,v)&&(t[v]=t[v]||(m.toggle[v]?k:!k))}}}return f};d.toggle=function(a,c,b){/^\w[\w.:-]*$/.test(a)&&(a="#"+a);a=document.querySelectorAll(a);for(b=0;b<a.length;b++)a[b].hidden=!c};d.initForm=function(a){d.toggleForm(a);a.noValidate||(a.noValidate=!0,a.addEventListener("submit",function(c){d.validateForm(a)||(c.stopPropagation(),c.preventDefault())}))};d.initOnLoad=function(){d.onDocumentReady(function(){for(var a=
0;a<document.forms.length;a++)for(var c=document.forms[a],b=0;b<c.elements.length;b++)if(c.elements[b].getAttribute("data-nette-rules")){d.initForm(c);break}document.body.addEventListener("click",function(a){for(a=a.target;a;){if(a.form&&a.type in{submit:1,image:1}){a.form["nette-submittedBy"]=a;break}a=a.parentNode}})})};d.webalize=function(a){a=a.toLowerCase();var c="",b;for(b=0;b<a.length;b++){var e=d.webalizeTable[a.charAt(b)];c+=e?e:a.charAt(b)}return c.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});
if(a.validity.badInput)return null}return null===c||parseFloat(b)<=c},range:function(a,c,b){if("number"===a.type){if(a.validity.rangeUnderflow||a.validity.rangeOverflow)return!1;if(a.validity.badInput)return null}return Array.isArray(c)?(null===c[0]||parseFloat(b)>=c[0])&&(null===c[1]||parseFloat(b)<=c[1]):null},submitted:function(a){return a.form["nette-submittedBy"]===a},fileSize:function(a,c,b){if(e.FileList)for(a=0;a<b.length;a++)if(b[a].size>c)return!1;return!0},mimeType:function(a,c,b){c=Array.isArray(c)?
c:[c];for(var d=0,l=c.length,g=[];d<l;d++)g.push("^"+c[d].replace(/([^\w])/g,"\\$1").replace("\\*",".*")+"$");g=new RegExp(g.join("|"));if(e.FileList&&b instanceof FileList)for(d=0;d<b.length;d++){if(b[d].type&&!g.test(b[d].type))return!1;if(a.validity.badInput)return null}return!0},image:function(a,c,b){return d.validators.mimeType(a,["image/gif","image/png","image/jpeg","image/webp"],b)},"static":function(a,c){return c}};d.toggleForm=function(a,c){var b;t={};for(b=0;b<a.elements.length;b++)a.elements[b].tagName.toLowerCase()in
{input:1,select:1,textarea:1,button:1}&&d.toggleControl(a.elements[b],null,null,!c);for(b in t)d.toggle(b,t[b],c)};d.toggleControl=function(a,c,b,f,e){c=c||JSON.parse(a.getAttribute("data-nette-rules")||"[]");e=void 0===e?{value:d.getEffectiveValue(a)}:e;for(var g=!1,p=[],h=function(){d.toggleForm(a.form,a)},k,l=0,q=c.length;l<q;l++){var m=c[l],u=m.op.match(/(~)?([^?]+)/),n=m.control?a.form.elements.namedItem(m.control):a;if(n){k=b;if(!1!==b){m.neg=u[1];m.op=u[2];k=d.validateRule(n,m.op,m.arg,a===
n?e:void 0);if(null===k)continue;else m.neg&&(k=!k);m.rules||(b=k)}if(m.rules&&d.toggleControl(a,m.rules,k,f,e)||m.toggle){g=!0;if(f){u=n.tagName?n.name:n[0].name;n=n.tagName?n.form.elements:n;for(var r=0;r<n.length;r++)n[r].name===u&&0>p.indexOf(n[r])&&(n[r].addEventListener("change",h),p.push(n[r]))}for(var v in m.toggle||[])Object.prototype.hasOwnProperty.call(m.toggle,v)&&(t[v]=t[v]||(m.toggle[v]?k:!k))}}}return g};d.toggle=function(a,c,b){/^\w[\w.:-]*$/.test(a)&&(a="#"+a);a=document.querySelectorAll(a);
for(b=0;b<a.length;b++)a[b].hidden=!c};d.initForm=function(a){d.toggleForm(a);a.noValidate||(a.noValidate=!0,a.addEventListener("submit",function(c){d.validateForm(a)||(c.stopPropagation(),c.preventDefault())}))};d.initOnLoad=function(){d.onDocumentReady(function(){for(var a=0;a<document.forms.length;a++)for(var c=document.forms[a],b=0;b<c.elements.length;b++)if(c.elements[b].getAttribute("data-nette-rules")){d.initForm(c);break}document.body.addEventListener("click",function(a){for(a=a.target;a;){if(a.form&&
a.type in{submit:1,image:1}){a.form["nette-submittedBy"]=a;break}a=a.parentNode}})})};d.webalize=function(a){a=a.toLowerCase();var c="",b;for(b=0;b<a.length;b++){var e=d.webalizeTable[a.charAt(b)];c+=e?e:a.charAt(b)}return c.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});
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