@jdlien/validator 1.4.3 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@ Validator includes the following built-in validation types:
17
17
  - Pattern (regular expression)
18
18
  - Numbers (with decimals and negative values)
19
19
  - Integers (positive whole numbers)
20
- - North-American Phone Numbers
20
+ - North American Phone Numbers
21
21
  - US Zip Codes
22
22
  - Email Addresses
23
23
  - Canadian Postal Codes
@@ -26,7 +26,7 @@ Validator includes the following built-in validation types:
26
26
  - Time of day
27
27
  - URLs
28
28
 
29
- You can also add custom validation, and can customize error messages per field or for the whole form.
29
+ You can also add custom validation and customize error messages per field or for the whole form.
30
30
 
31
31
  Validator is compatible with all modern browsers. It has no dependencies (other than its validator-utils package). It is written in TypeScript with 100% test coverage.
32
32
 
@@ -44,12 +44,12 @@ yarn add @jdlien/validator
44
44
 
45
45
  Create a form as you normally would, adding attributes for inputs to control how Validator will
46
46
  check the input, such as `required`, `type`, or `data-type`. Native HTML5 attributes are supported,
47
- although often the browser's built-in validation is problematic or inflexible. In those cases, you
47
+ although often, the browser's built-in validation is problematic or inflexible. In those cases, you
48
48
  can use a `data-` variant of these attributes to avoid the browser's built-in validation.
49
49
 
50
50
  Any input that you want to validate should have a unique name attribute. If you want to display error messages for the input, you must also have a div with an id that is the name of the input + `-error`.
51
51
 
52
- Then create a new Validator instance and pass it the form element as the first argument. An optional second argument allows you to pass in options. Here is a simplified example:
52
+ Then, create a new Validator instance and pass it the form element as the first argument. An optional second argument allows you to pass in options. Here is a simplified example:
53
53
 
54
54
  ```html
55
55
  <form id="myForm">
@@ -90,7 +90,7 @@ When initialized, Validator disables browser validation and displays error messa
90
90
  2. The ID of the input + `-error`
91
91
  3. The name of the input + `-error`
92
92
 
93
- Using the aria-describedby attribute to link an error message with an input is the most robust and effective method, and also enhances accessibility by enabling screen readers to announce the error when the input is focused.
93
+ Using the aria-describedby attribute to link an error message with an input is the most robust and effective method. Also, this enhances accessibility by enabling screen readers to announce the error when the input is focused.
94
94
 
95
95
  If you wish to customize the default error message, you can also set one for a field using `data-error-default`.
96
96
 
@@ -98,18 +98,18 @@ If you wish to customize the default error message, you can also set one for a f
98
98
 
99
99
  [Working demo on jdlien.com](https://jdlien.com/validator/demo/).
100
100
 
101
- ## Supported Input Types and Atributes
101
+ ## Supported Input Types and Attributes
102
102
 
103
103
  Validator works by checking for certain attributes on the form inputs and applying validation based on those.
104
- In many cases you can use the native HTML5 attributes, but you can also use the `data-` attributes if you do not want the behavior to be affected by built-in browser validation behavior (e.g., for min-length, max-length, and input types such as date and time).
104
+ In many cases, you can use the native HTML5 attributes, but you can also use the `data-` attributes if you do not want the behavior to be affected by built-in browser validation behavior (e.g., for min-length, max-length, and input types such as date and time).
105
105
 
106
106
  There are a few attributes that Validator looks for on the form element:
107
107
 
108
- - `data-prevent-submit` - If this attribute is present, the form will never be submitted, even if it is valid. This is useful if you want to handle the submission yourself. (By default the form will be submitted if it is valid and not if it is invalid.)
108
+ - `data-prevent-submit` - If this attribute is present, the form will never be submitted, even if it is valid. This is useful if you want to handle the submission yourself. (By default, the form will be submitted if it is valid and not if it is invalid.)
109
109
 
110
- - `novalidate` - This is a native HTML5 attribute that will disable browser validation on the form. If this attribute is present. Validator adds this by default and remove it if `destroy()` is called. If you add it yourself, it will not be added back by Validator.
110
+ - `novalidate` - This is a native HTML5 attribute that will disable browser validation on the form. If this attribute is present. Validator adds this by default and removes it if `destroy()` is called. If you add it yourself, it will not be added back by Validator.
111
111
 
112
- On input (and sometimes select and textarea) elements the following attributes are supported:
112
+ On input (and sometimes select and textarea) elements, the following attributes are supported:
113
113
 
114
114
  - `required` - The input must have a value.
115
115
  - `minlength`/`data-min-length` - The input must be at least the specified number of characters.
@@ -119,7 +119,7 @@ On input (and sometimes select and textarea) elements the following attributes a
119
119
 
120
120
  - `number` - The input must be a number (use `data-type` to avoid quirky browser behavior)
121
121
  - `integer` - The input must be a positive whole number.
122
- - `tel` - The input must be a valid North-American phone number.
122
+ - `tel` - The input must be a valid North American phone number.
123
123
  - `email` - The input must be a valid email address.
124
124
  - `zip` - The input must be a valid US zip code.
125
125
  - `postal` - The input must be a valid Canadian postal code.
@@ -135,7 +135,7 @@ On input (and sometimes select and textarea) elements the following attributes a
135
135
  - `data-validation` - The name of a custom validation function.
136
136
  - `data-novalidate` - If this attribute is present, the input will not be validated when `input` or `change` events are triggered on it.
137
137
 
138
- A validation function will be called with the input value as the argument. The function may either return a boolean (true/false) or an object with a `valid` property that is a boolean. If the function returns string, an object with a `message` property, that will be used as the error message for the input. A `messages` array may also be specified which will be used to display multiple error messages for the input.
138
+ A validation function will be called with the input value as the argument. The function may either return a boolean (true/false) or an object with a `valid` property that is a boolean. If the function returns a string or an object with a `message` property, that will be used as the error message for the input. A `messages` array may also be specified which will be used to display multiple error messages for the input.
139
139
 
140
140
  You may also use a promise that resolves to such an object for asynchronous validation.
141
141
 
@@ -174,7 +174,7 @@ You can customize the class(es) that Validator uses to hide the error messages b
174
174
 
175
175
  ## Color Picker Support
176
176
 
177
- If you need to allow a user to pick a color, you can use data-type="color" and the input will be required to be any valid CSS color supported by the browser. This type can also work in conjunction with a native color input. If you do this, you will need to add an input with `type="color"` and the name of the data-color input + `-color`. This should be inside a linked label which will become the color preview swatch. Such a label should have an ID of the color input's name + `-color-label` so that Validator can change the background to the specified color.
177
+ If you need to allow a user to pick a color, you can use data-type="color" and the input will be required to be any valid CSS color supported by the browser. This type can also work in conjunction with a native color input. If you do this, you will need to add an input with `type="color"` and the name of the data-color input + `-color`. This should be inside a linked label, which will become the color preview swatch. Such a label should have an ID of the color input's name + `-color-label` so that Validator can change the background to the specified color.
178
178
 
179
179
  A basic example that would work:
180
180
 
package/dist/validator.js CHANGED
@@ -1 +1 @@
1
- (function(y,R){typeof exports=="object"&&typeof module<"u"?module.exports=R():typeof define=="function"&&define.amd?define(R):(y=typeof globalThis<"u"?globalThis:y||self,y.Validator=R())})(this,function(){"use strict";var le=Object.defineProperty;var de=(y,R,o)=>R in y?le(y,R,{enumerable:!0,configurable:!0,writable:!0,value:o}):y[R]=o;var p=(y,R,o)=>(de(y,typeof R!="symbol"?R+"":R,o),o);var y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},R={exports:{}};(function(L,t){(function(r,n){n(t)})(y,function(r){function n(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function l(e,a){typeof a=="string"&&(a=[a]);const s=e.dataset.type||"",i=e.type;return!!(a.includes(s)||a.includes(i))}function g(e){return e.replace(/YYYY/g,"Y").replace(/YY/g,"y").replace(/MMMM/g,"F").replace(/MMM/g,"{3}").replace(/MM/g,"{2}").replace(/M/g,"n").replace(/DD/g,"{5}").replace(/D/g,"j").replace(/dddd/g,"l").replace(/ddd/g,"D").replace(/dd/g,"D").replace(/d/g,"w").replace(/HH/g,"{6}").replace(/H/g,"G").replace(/hh/g,"h").replace(/mm/g,"i").replace(/m/g,"i").replace(/ss/g,"S").replace(/s/g,"s").replace(/A/gi,"K").replace(/\{3\}/g,"M").replace(/\{2\}/g,"m").replace(/\{5\}/g,"d").replace(/\{6\}/g,"H")}function E(e){const a=parseInt(e);if(typeof e=="number"||!isNaN(a))return a-1;const s=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(s))return s;const i={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};for(const h in i)if(e.toLowerCase().startsWith(h))return i[h];throw new Error("Invalid month name: "+e)}function T(e){return typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99?e:e<(new Date().getFullYear()+20)%100?e+2e3:e+1900}function w(e){if(e instanceof Date)return e;e=e.trim().toLowerCase();let a=0,s=0,i=0,h=0,d=0,u=0;const m=new RegExp(/\d{1,2}\:\d\d(?:\:\d\ds?)?\s?(?:[a|p]m?)?/gi);if(m.test(e)){const v=e.match(m)[0];e=e.replace(v,"").trim();const b=I(v);if(b!==null&&({hour:h,minute:d,second:u}=b),e.length<=2){const C=new Date;return new Date(C.getFullYear(),C.getMonth(),C.getDate(),h,d,u)}}const f=/(^|\b)(mo|tu|we|th|fr|sa|su|lu|mard|mer|jeu|ve|dom)[\w]*\.?/gi;e=e.replace(f,"").trim();const c=new Date(new Date().setHours(0,0,0,0));if(/(now|today)/.test(e))return c;if(e.includes("tomorrow"))return new Date(c.setDate(c.getDate()+1));e.length===8&&(e=e.replace(/(\d\d\d\d)(\d\d)(\d\d)/,"$1-$2-$3")),e.length===6&&(e=e.replace(/(\d\d)(\d\d)(\d\d)/,T(e.slice(0,2))+"-$2-$3"));try{({year:a,month:s,day:i}=Y(e))}catch{return new Date("")}return new Date(a,s-1,i,h,d,u)}function $(e,a=[null,null,null]){const s=i=>i.filter(h=>!a.includes(h));return e===0||e>31?s(["y"]):e>12?s(["d","y"]):e>=1&&e<=12?s(["m","d","y"]):[]}function Y(e){const a=e.split(/[\s-/:.,]+/).filter(d=>d!=="");if(a.length<3){if(e.match(/\d{4}/)!==null)throw new Error("Invalid Date");a.unshift(String(new Date().getFullYear()))}const s={year:0,month:0,day:0};function i(d,u){d==="year"?s.year=T(u):s[d]=u}let h=0;for(;!(s.year&&s.month&&s.day);){e:for(const d of a){if(h++,/^[a-zA-Zé]+$/.test(d)){s.month||i("month",E(d)+1);continue}if(/^'\d\d$/.test(d)||/^\d{3,5}$/.test(d)){s.year||i("year",parseInt(d.replace(/'/,"")));continue}const u=parseInt(d);if(isNaN(u))throw console.error(`not date because ${d} isNaN`),new Error("Invalid Date");const m=$(u,[s.year?"y":null,s.month?"m":null,s.day?"d":null]);if(m.length==1){if(m[0]==="m"&&!s.month){i("month",u);continue e}if(m[0]==="d"&&!s.day){i("day",u);continue e}if(m[0]==="y"&&!s.year){i("year",u);continue e}}h>3&&(!s.month&&m.includes("m")?i("month",u):!s.day&&m.includes("d")&&i("day",u))}if(h>6)throw new Error("Invalid Date")}if(s.year&&s.month&&s.day)return s;throw new Error("Invalid Date")}function I(e){if(e=e.trim().toLowerCase(),e==="now"){const c=new Date;return{hour:c.getHours(),minute:c.getMinutes(),second:c.getSeconds()}}if(e==="noon")return{hour:12,minute:0,second:0};const a=e.match(/(\d{3,4})/);if(a){const c=a[1].length,v=a[1].slice(0,c==3?1:2),b=a[1].slice(-2);e=e.replace(a[1],v+":"+b)}const s=new RegExp(/^(\d{1,2})(?::(\d{1,2}))?\s*(?:(a|p)\.?m?\.?)?$/i);if(s.test(e)){const c=e.match(s);if(c===null)return null;e=c[1]+":"+(c[2]||"00")+(c[3]||"")}const i=new RegExp(/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?\s*(?:(a|p)m?)?$/i);if(!i.test(e))return null;const h=e.match(i);if(h===null)return null;const d=parseInt(h[1]),u=parseInt(h[2]),m=h[3]?parseInt(h[3]):0,f=h[4];return isNaN(d)||isNaN(u)||isNaN(m)?null:f==="p"&&d<12?{hour:d+12,minute:u,second:m}:f==="a"&&d===12?{hour:0,minute:u,second:m}:d<0||d>23||u<0||u>59||m<0||m>59?null:{hour:d,minute:u,second:m}}function V(e,a="h:mm A"){const s=I(e);if(s){const i=new Date;return i.setHours(s.hour),i.setMinutes(s.minute),i.setSeconds(s.second),i.setMilliseconds(0),M(i,a)}return""}function S(e){if(e instanceof Date)return e;if(e.trim().length<3)return null;e=e.replace(/(\d)T(\d)/,"$1 $2");let a=e.split(/[\s,]+/).filter(f=>f!==""),s="",i="",h="";a.forEach((f,c)=>{const v=f.match(/^(\d{1,4})([apAP]\.?[mM]?\.?)/);v?i=v[0]:(f.includes(":")||f==="now"||f==="noon")&&(i=f),H(f)&&(h=f,!i&&c>0&&O(a[c-1])&&(i=a[c-1]))}),i?a=a.filter(f=>f!==i&&f!==h):[s,a]=P(a);const d=i?`${i} ${h}`:s?a.join(" "):"",u=I(d)||{hour:0,minute:0,second:0},m=w(s||a.join(" ").trim()||"today");return!m||isNaN(m.getTime())?null:new Date(m.getFullYear(),m.getMonth(),m.getDate(),u.hour,u.minute,u.second)}function P(e){for(let a=3;a>0;a--){const s=e.slice(0,a).join(" ");if(N(s))return[s,e.slice(a)]}return["",e]}function M(e,a="YYYY-MM-DD"){if(e=w(e),isNaN(e.getTime()))return"";const s={y:e.getFullYear(),M:e.getMonth(),D:e.getDate(),W:e.getDay(),H:e.getHours(),m:e.getMinutes(),s:e.getSeconds(),ms:e.getMilliseconds()},i=(c,v=2)=>(c+"").padStart(v,"0"),h=()=>s.H%12||12,d=c=>c<12?"AM":"PM",u=c=>"January|February|March|April|May|June|July|August|September|October|November|December".split("|")[c];function m(c,v=0){const b="Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday".split("|");return v?b[c].slice(0,v):b[c]}const f={YY:String(s.y).slice(-2),YYYY:s.y,M:s.M+1,MM:i(s.M+1),MMMM:u(s.M),MMM:u(s.M).slice(0,3),D:String(s.D),DD:i(s.D),d:String(s.W),dd:m(s.W,2),ddd:m(s.W,3),dddd:m(s.W),H:String(s.H),HH:i(s.H),h:h(),hh:i(h()),A:d(s.H),a:d(s.H).toLowerCase(),m:String(s.m),mm:i(s.m),s:String(s.s),ss:i(s.s),SSS:i(s.ms,3)};return a.replace(/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,(c,v)=>v||f[c])}function U(e,a){const s=w(e);return isNaN(s.getTime())?"":((!a||a.length===0)&&(a="YYYY-MMM-DD"),M(s,a))}function F(e,a){const s=S(e);return s===null||isNaN(s.getTime())?"":((!a||a.length===0)&&(a="YYYY-MMM-DD h:mm A"),M(s,a))}function N(e){if(typeof e!="string"&&!(e instanceof Date))return!1;let a=w(e);return a==null?!1:!isNaN(a.getTime())}function q(e){if(typeof e!="string"&&!(e instanceof Date))return!1;let a=S(e);return a==null?!1:!isNaN(a.getTime())}function Z(e,a){return!(a==="past"&&e>new Date||a==="future"&&e.getTime()<new Date().setHours(0,0,0,0))}function H(e){const a=e.toLowerCase().replace(/[.\s]/g,"");return["am","pm","a","p"].includes(a)}function O(e){let a=I(e);return a===null?!1:!isNaN(a.hour)&&!isNaN(a.minute)&&!isNaN(a.second)}function j(e){if(e.length>255||!new RegExp(/^.+@.+\.[a-zA-Z0-9]{2,}$/).test(e))return!1;let a="";return a+="^([a-zA-Z0-9!#$%'*+/=?^_`{|}~-]+",a+="(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*",a+="|",a+='"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*"',a+=")@(",a+="(",a+="(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+",a+="[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?",a+=")",a+=")$",new RegExp(a).test(e)}function z(e){return e=e.replace(/^[^2-90]+/g,""),e=e.replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4"),e}function G(e){return/^\d\d\d-\d\d\d-\d\d\d\d$/.test(e)}function B(e){return e.replace(/[^0-9]/g,"")}function K(e){return/^\-?\d*\.?\d*$/.test(e)}function W(e){return e.replace(/[^\-0-9.]/g,"").replace(/(^-)|(-)/g,(a,s)=>s?"-":"").replace(/(\..*)\./g,"$1")}function J(e){return/^\-?\d*$/.test(e)}function Q(e){return e=e.trim(),new RegExp("^(?:[a-z+]+:)?//","i").test(e)?e:"https://"+e}function X(e){return new RegExp("^(?:[-a-z+]+:)?//","i").test(e)}function ee(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6&&(e=e.replace(/-/,"")),e}function te(e){return new RegExp(/^\d{5}(-\d{4})?$/).test(e)}function re(e){return e=e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim(),e}function ae(e){return new RegExp(/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/).test(e)}function se(e){return["transparent","currentColor"].includes(e)?!0:typeof e!="string"||!e.trim()?!1:typeof CSS=="object"&&typeof CSS.supports=="function"?CSS.supports("color",e):ne(e)}function ne(e){const a=new RegExp(/^rgba?\(\s*(\d{1,3}%?,\s*){2}\d{1,3}%?\s*(?:,\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),s=new RegExp(/^hsla?\(\s*\d+(deg|grad|rad|turn)?,\s*\d{1,3}%,\s*\s*\d{1,3}%(?:,\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),i=new RegExp(/^rgba?\(\s*(\d{1,3}%?\s+){2}\d{1,3}%?\s*(?:\s*\/\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),h=new RegExp(/^hsla?\(\s*\d+(deg|grad|rad|turn)?\s+\d{1,3}%\s+\s*\d{1,3}%(?:\s*\/\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),d=new RegExp(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);let u="aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";const m=new RegExp(`^(${u})$`,"i");return a.test(e)||s.test(e)||i.test(e)||h.test(e)||d.test(e)||m.test(e)}let D=null;const A=new Map;function ie(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(A.has(e))return A.get(e);D===null&&(D=document.createElement("canvas"),D.willReadFrequently=!0);let a=D.getContext("2d");if(!a)throw new Error("Can't get context from colorCanvas");a.fillStyle=e,a.fillRect(0,0,1,1);let s=a.getImageData(0,0,1,1).data,i="#"+("000000"+(s[0]<<16|s[1]<<8|s[2]).toString(16)).slice(-6);return A.set(e,i),i}function oe(e){let a={valid:!1,error:!1,messages:[]};return typeof e=="boolean"?{valid:e,error:!1,messages:[]}:typeof e=="string"?{valid:!1,error:!1,messages:[e]}:(typeof e.valid=="boolean"&&(a.valid=e.valid),typeof e.message=="string"&&(a.messages=[e.message]),typeof e.messages=="string"&&(a.messages=[e.messages]),Array.isArray(e.messages)&&(a.messages=e.messages),e.error===!0&&(a.error=!0),a)}r.formatDateTime=M,r.isColor=se,r.isDate=N,r.isDateInRange=Z,r.isDateTime=q,r.isEmail=j,r.isFormControl=n,r.isInteger=J,r.isMeridiem=H,r.isNANPTel=G,r.isNumber=K,r.isPostalCA=ae,r.isTime=O,r.isType=l,r.isUrl=X,r.isZip=te,r.momentToFPFormat=g,r.monthToNumber=E,r.normalizeValidationResult=oe,r.parseColor=ie,r.parseDate=w,r.parseDateTime=S,r.parseDateTimeToString=F,r.parseDateToString=U,r.parseInteger=B,r.parseNANPTel=z,r.parseNumber=W,r.parsePostalCA=re,r.parseTime=I,r.parseTimeToString=V,r.parseUrl=Q,r.parseZip=ee,r.yearToFull=T,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})})})(R,R.exports);var o=R.exports;class k extends Event{constructor(r){super("validationSuccess",{cancelable:!0});p(this,"submitEvent");this.submitEvent=r}}class _ extends Event{constructor(r){super("validationError",{cancelable:!0});p(this,"submitEvent");this.submitEvent=r}}class x{constructor(t,r={}){p(this,"form");p(this,"inputs",[]);p(this,"inputErrors",{});p(this,"messages",{ERROR_MAIN:"There is a problem with your submission.",ERROR_GENERIC:"Enter a valid value.",ERROR_REQUIRED:"This field is required.",OPTION_REQUIRED:"An option must be selected.",CHECKED_REQUIRED:"This must be checked.",ERROR_MAXLENGTH:"This must be ${val} characters or fewer.",ERROR_MINLENGTH:"This must be at least ${val} characters.",ERROR_NUMBER:"This must be a number.",ERROR_INTEGER:"This must be a whole number.",ERROR_TEL:"This is not a valid telephone number.",ERROR_EMAIL:"This is not a valid email address.",ERROR_ZIP:"This is not a valid zip code.",ERROR_POSTAL:"This is not a valid postal code.",ERROR_DATE:"This is not a valid date.",ERROR_DATE_PAST:"The date must be in the past.",ERROR_DATE_FUTURE:"The date must be in the future.",ERROR_DATE_RANGE:"The date is outside the allowed range.",ERROR_DATETIME:"This is not a valid date and time.",ERROR_TIME:"This is not a valid time.",ERROR_TIME_RANGE:"The time is outside the allowed range.",ERROR_URL:"This is not a valid URL.",ERROR_COLOR:"This is not a valid CSS colour.",ERROR_CUSTOM_VALIDATION:"There was a problem validating this field."});p(this,"debug");p(this,"autoInit");p(this,"preventSubmit",!1);p(this,"hiddenClasses");p(this,"errorMainClasses");p(this,"errorInputClasses");p(this,"dispatchTimeout",0);p(this,"timeoutId",0);p(this,"debouncedInit");p(this,"originalNoValidate",!1);p(this,"validationSuccessCallback");p(this,"validationErrorCallback");p(this,"submitHandlerRef",this.submitHandler.bind(this));p(this,"inputInputHandlerRef",this.inputInputHandler.bind(this));p(this,"inputChangeHandlerRef",this.inputChangeHandler.bind(this));p(this,"inputKeydownHandlerRef",this.inputKeydownHandler.bind(this));p(this,"inputHandlers",{number:{parse:o.parseNumber,isValid:o.isNumber,error:this.messages.ERROR_NUMBER},integer:{parse:o.parseInteger,isValid:o.isInteger,error:this.messages.ERROR_INTEGER},tel:{parse:o.parseNANPTel,isValid:o.isNANPTel,error:this.messages.ERROR_TEL},email:{parse:t=>t.trim(),isValid:o.isEmail,error:this.messages.ERROR_EMAIL},zip:{parse:o.parseZip,isValid:o.isZip,error:this.messages.ERROR_ZIP},postal:{parse:o.parsePostalCA,isValid:o.isPostalCA,error:this.messages.ERROR_POSTAL},url:{parse:o.parseUrl,isValid:o.isUrl,error:this.messages.ERROR_URL},date:{parse:o.parseDateToString,isValid:o.isDate,error:this.messages.ERROR_DATE},datetime:{parse:o.parseDateTimeToString,isValid:o.isDateTime,error:this.messages.ERROR_DATETIME},time:{parse:o.parseTimeToString,isValid:o.isTime,error:this.messages.ERROR_TIME},color:{parse:t=>t.trim().toLowerCase(),isValid:o.isColor,error:this.messages.ERROR_COLOR}});p(this,"isSubmitting",!1);if(!t)throw new Error("Validator requires a form to be passed as the first argument.");if(!(t instanceof HTMLFormElement))throw new Error("form argument must be an instance of HTMLFormElement");this.form=t,(t.dataset.preventSubmit===""||t.dataset.preventSubmit)&&(this.preventSubmit=!0),Object.assign(this.messages,r.messages||{}),this.debug=r.debug||!1,this.autoInit=r.autoInit!==!1,this.preventSubmit=r.preventSubmit!==void 0?r.preventSubmit:this.preventSubmit,this.hiddenClasses=r.hiddenClasses||"hidden opacity-0",this.errorMainClasses=r.errorMainClasses||"m-2 border border-red-500 bg-red-100 p-3 dark:bg-red-900/80 text-center",this.errorInputClasses=r.errorInputClasses||"border-red-600 dark:border-red-500",this.validationSuccessCallback=r.validationSuccessCallback||(()=>{}),this.validationErrorCallback=r.validationErrorCallback||(()=>{}),this.debouncedInit=this.debounce(this.init.bind(this),45),this.autoInit&&this.init(),new MutationObserver(()=>this.autoInit&&this.debouncedInit()).observe(t,{childList:!0})}debounce(t,r){return(...n)=>{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>t(...n),r)}}addEventListeners(){this.form.addEventListener("submit",this.submitHandlerRef),this.form.addEventListener("input",this.inputInputHandlerRef),this.form.addEventListener("change",this.inputChangeHandlerRef),this.form.addEventListener("keydown",this.inputKeydownHandlerRef),this.form.addEventListener("remove",this.destroy,{once:!0})}removeEventListeners(){this.form.removeEventListener("submit",this.submitHandlerRef),this.form.removeEventListener("input",this.inputInputHandlerRef),this.form.removeEventListener("change",this.inputChangeHandlerRef),this.form.removeEventListener("keydown",this.inputKeydownHandlerRef),this.form.removeEventListener("remove",this.destroy)}init(){this.inputs=Array.from(this.form.elements).filter(t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement),this.inputs.forEach(t=>{!t.name&&!t.id&&(t.id=`vl-input-${Math.random().toString(36).slice(2)}`),this.inputErrors[t.name||t.id]=[]}),this.originalNoValidate=this.form.hasAttribute("novalidate"),this.form.setAttribute("novalidate","novalidate"),this.removeEventListeners(),this.addEventListeners()}getErrorEl(t){const r=E=>{const T=E.replace(/([.#{}()\\?*[\]-])/g,"\\$1");return this.form.querySelector(`#${T}`)||document.getElementById(E)||null},n=t.getAttribute("aria-describedby");if(n){const E=r(n);if(E)return E}const l=r(t.id+"-error");return l||r(t.name+"-error")||null}addErrorMain(t){const r=document.createElement("div");r.id="form-error-main",this.errorMainClasses.split(" ").forEach(n=>{r.classList.add(n)}),t?r.innerHTML=t:r.innerHTML=this.messages.ERROR_MAIN,this.form.appendChild(r)}addInputError(t,r=t.dataset.errorDefault||this.messages.ERROR_GENERIC){const n=t.name||t.id;this.debug&&console.log("Invalid value for "+n+": "+r),n in this.inputErrors||(this.inputErrors[n]=[]),this.inputErrors[n].includes(r)||this.inputErrors[n].push(r)}showInputErrors(t){if(!t||!t.name&&!t.id)return;const r=t.name||t.id,n=r in this.inputErrors?this.inputErrors[r]:[];if(!n.length)return;t.setAttribute("aria-invalid","true"),this.errorInputClasses.split(" ").forEach(g=>{t.classList.add(g)});let l=this.getErrorEl(t);l&&(l.innerHTML=n.join("<br>"),this.hiddenClasses.split(" ").forEach(g=>{l&&l.classList.remove(g)}))}showFormErrors(){if(this.inputs.forEach(t=>this.showInputErrors(t)),Object.values(this.inputErrors).some(t=>Array.isArray(t)&&t.length)){const t=this.form.querySelectorAll("#form-error-main");t.length?t.forEach(r=>{r.innerHTML||(r.innerHTML=this.messages.ERROR_MAIN),this.hiddenClasses.split(" ").forEach(n=>{r.classList.remove(n)})}):this.addErrorMain()}}clearInputErrors(t){this.inputErrors[t.name||t.id]=[],t.removeAttribute("aria-invalid");let r=this.getErrorEl(t);r&&(this.errorInputClasses.split(" ").forEach(n=>{t.classList.remove(n)}),this.hiddenClasses.split(" ").forEach(n=>{r&&r.classList.add(n)}),r.textContent="")}clearFormErrors(){this.form.querySelectorAll("#form-error-main").forEach(t=>{this.hiddenClasses.split(" ").forEach(r=>{t.classList.add(r)})}),this.inputs.forEach(t=>this.clearInputErrors(t))}validateRequired(t){let r=!0;if(t.required&&(t.value===""||t instanceof HTMLInputElement&&["checkbox","radio"].includes(t.type)&&!t.checked))if(t instanceof HTMLInputElement&&["checkbox","radio"].includes(t.type)){let n=!1,l=t.name;const g=this.form.querySelectorAll(`input[name="${l}"]`);if(g.forEach(E=>{if(E instanceof HTMLInputElement&&E.checked===!0){n=!0;return}}),n===!1){r=!1;let E=g.length>1?this.messages.OPTION_REQUIRED:this.messages.CHECKED_REQUIRED;t.dataset.errorDefault&&(E=t.dataset.errorDefault),this.addInputError(t,E)}}else o.isFormControl(t)&&(r=!1,this.addInputError(t,t.dataset.errorDefault||this.messages.ERROR_REQUIRED));return r}validateLength(t){let r=!0;if(t.disabled)return r;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.value.length){let n=t.minLength>0?t.minLength:t.dataset.minLength?parseInt(t.dataset.minLength):0,l=t.maxLength>0&&t.maxLength<5e5?t.maxLength:t.dataset.maxLength?parseInt(t.dataset.maxLength):1/0;n>0&&t.value.length<n&&(r=!1,this.addInputError(t,this.messages.ERROR_MINLENGTH.replace("${val}",n.toString()))),t.value.length>l&&(r=!1,this.addInputError(t,this.messages.ERROR_MAXLENGTH.replace("${val}",l.toString())))}return r}validateInputType(t){const r=t.dataset.type||t.type,n=this.inputHandlers[t.type]||this.inputHandlers[r];if(n){const l=t.dataset.dateFormat||t.dataset.timeFormat,g=n.parse(t.value,l),E=["date","time","datetime-local","month","week"];if(g.length&&!E.includes(t.type)&&(t.value=g),!n.isValid(t.value))return this.addInputError(t,n.error),!1}return!0}validateDateRange(t){if(t.dataset.dateRange){const r=t.dataset.dateRange,n=o.parseDate(t.value);if(!isNaN(n.getTime())&&!o.isDateInRange(n,r)){let l=t.dataset.errorDefault||this.messages.ERROR_DATE_RANGE;return r==="past"?l=this.messages.ERROR_DATE_PAST:r==="future"&&(l=this.messages.ERROR_DATE_FUTURE),this.addInputError(t,l),!1}}return!0}validatePattern(t){const r=t.dataset.pattern||t instanceof HTMLInputElement&&t.pattern||null;return r&&!new RegExp(r).test(t.value)?(this.addInputError(t),!1):!0}async validateCustom(t){if(t.disabled)return!0;const r=t.dataset.validation;if(!r||typeof r!="string")return!0;const n=window[r];if(!n||typeof n!="function")return!0;let l;try{l=await Promise.resolve(n(t.value)),l=o.normalizeValidationResult(l)}catch{return this.addInputError(t,this.messages.ERROR_CUSTOM_VALIDATION),!1}const g=l.messages.join("<br>")||this.messages.ERROR_CUSTOM_VALIDATION;return l.valid||this.addInputError(t,g),l.valid}async validateInput(t){if(!(t instanceof HTMLInputElement)||!t.value.length)return!0;let r=!0;return t.disabled||(r=this.validateInputType(t)&&r,r=this.validateDateRange(t)&&r,r=this.validatePattern(t)&&r,r=await this.validateCustom(t)&&r),r}async validate(t){let r=!0;for(const n of this.inputs)n.disabled||(r=this.validateRequired(n)&&r,r=this.validateLength(n)&&r,r=await this.validateInput(n)&&r,n.value.length||(r=await this.validateCustom(n)&&r));return r}async submitHandler(t){if(this.isSubmitting)return;t.preventDefault(),this.clearFormErrors();let r=await this.validate(t);this.showFormErrors();const n=new k(t),l=new _(t);r?(this.form.dispatchEvent(n),this.validationSuccessCallback&&this.validationSuccessCallback(t)):(this.form.dispatchEvent(l),this.validationErrorCallback&&this.validationErrorCallback(t)),r&&!this.preventSubmit&&(this.isSubmitting=!0,n.defaultPrevented||this.form.submit(),this.isSubmitting=!1)}shouldSkipValidation(t){return typeof t.dataset.novalidate>"u"?!1:t.dataset.novalidate===""?!0:t.dataset.novalidate==="true"}async inputChangeHandler(t){!(t.target instanceof HTMLInputElement)||this.shouldSkipValidation(t.target)||(this.clearInputErrors(t.target),this.validateLength(t.target),await this.validateInput(t.target),this.showInputErrors(t.target))}inputInputHandler(t){const r=t.target;this.shouldSkipValidation(r)||(o.isType(r,"integer")&&(r.value=o.parseInteger(r.value)),r.type!=="number"&&o.isType(r,["number","float","decimal"])&&(r.value=o.parseNumber(r.value)),o.isType(r,"color")&&this.syncColorInput(t))}syncColorInput(t){let r=t.target,n=r;r.type==="color"&&(n=this.form.querySelector(`#${r.id.replace(/-color/,"")}`));let l=this.form.querySelector(`#${n.id}-color-label`);if((r.dataset.type||"")==="color"){let g=this.form.querySelector(`input#${r.id}-color`);if(!g||!o.isColor(r.value))return;g.value=o.parseColor(r.value)}r.type==="color"&&(n.value=r.value),l&&(l.style.backgroundColor=r.value),clearTimeout(this.dispatchTimeout),this.dispatchTimeout=window.setTimeout(()=>{n.dispatchEvent(new Event("change",{bubbles:!0}))},200)}inputKeydownHandler(t){t.target instanceof HTMLInputElement&&o.isType(t.target,"integer")&&(t.key==="ArrowUp"?(t.preventDefault(),t.target.value===""&&(t.target.value="0"),t.target.value=(parseInt(t.target.value)+1).toString()):t.key==="ArrowDown"&&(parseInt(t.target.value)>0?t.target.value=(parseInt(t.target.value)-1).toString():t.target.value="0"))}destroy(){this.removeEventListeners(),this.originalNoValidate||this.form.removeAttribute("novalidate")}}return x});
1
+ (function(R,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(R=typeof globalThis<"u"?globalThis:R||self,R.Validator=y())})(this,function(){"use strict";var ue=Object.defineProperty;var ce=(R,y,b)=>y in R?ue(R,y,{enumerable:!0,configurable:!0,writable:!0,value:b}):R[y]=b;var p=(R,y,b)=>ce(R,typeof y!="symbol"?y+"":y,b);var R={exports:{}},y=R.exports,b;function _(){return b||(b=1,function(S,t){(function(r,n){n(t)})(y,function(r){function n(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function l(e,a){typeof a=="string"&&(a=[a]);const s=e.dataset.type||"",i=e.type;return!!(a.includes(s)||a.includes(i))}function g(e){return e.replace(/YYYY/g,"Y").replace(/YY/g,"y").replace(/MMMM/g,"F").replace(/MMM/g,"{3}").replace(/MM/g,"{2}").replace(/M/g,"n").replace(/DD/g,"{5}").replace(/D/g,"j").replace(/dddd/g,"l").replace(/ddd/g,"D").replace(/dd/g,"D").replace(/d/g,"w").replace(/HH/g,"{6}").replace(/H/g,"G").replace(/hh/g,"h").replace(/mm/g,"i").replace(/m/g,"i").replace(/ss/g,"S").replace(/s/g,"s").replace(/A/gi,"K").replace(/\{3\}/g,"M").replace(/\{2\}/g,"m").replace(/\{5\}/g,"d").replace(/\{6\}/g,"H")}function E(e){const a=parseInt(e);if(typeof e=="number"||!isNaN(a))return a-1;const s=new Date(`1 ${e} 2000`).getMonth();if(!isNaN(s))return s;const i={ja:0,en:0,fe:1,fé:1,ap:3,ab:3,av:3,mai:4,juin:5,juil:6,au:7,ag:7,ao:7,se:8,o:9,n:10,d:11};for(const h in i)if(e.toLowerCase().startsWith(h))return i[h];throw new Error("Invalid month name: "+e)}function w(e){return typeof e=="string"&&(e=parseInt(e.replace(/\D/g,""))),e>99?e:e<(new Date().getFullYear()+20)%100?e+2e3:e+1900}function I(e){if(e instanceof Date)return e;e=e.trim().toLowerCase();let a=0,s=0,i=0,h=0,d=0,u=0;const m=new RegExp(/\d{1,2}\:\d\d(?:\:\d\ds?)?\s?(?:[a|p]m?)?/gi);if(m.test(e)){const v=e.match(m)[0];e=e.replace(v,"").trim();const T=M(v);if(T!==null&&({hour:h,minute:d,second:u}=T),e.length<=2){const N=new Date;return new Date(N.getFullYear(),N.getMonth(),N.getDate(),h,d,u)}}const f=/(^|\b)(mo|tu|we|th|fr|sa|su|lu|mard|mer|jeu|ve|dom)[\w]*\.?/gi;e=e.replace(f,"").trim();const c=new Date(new Date().setHours(0,0,0,0));if(/(now|today)/.test(e))return c;if(e.includes("tomorrow"))return new Date(c.setDate(c.getDate()+1));e.length===8&&(e=e.replace(/(\d\d\d\d)(\d\d)(\d\d)/,"$1-$2-$3")),e.length===6&&(e=e.replace(/(\d\d)(\d\d)(\d\d)/,w(e.slice(0,2))+"-$2-$3"));try{({year:a,month:s,day:i}=U(e))}catch{return new Date("")}return new Date(a,s-1,i,h,d,u)}function Y(e,a=[null,null,null]){const s=i=>i.filter(h=>!a.includes(h));return e===0||e>31?s(["y"]):e>12?s(["d","y"]):e>=1&&e<=12?s(["m","d","y"]):[]}function U(e){const a=e.split(/[\s-/:.,]+/).filter(d=>d!=="");if(a.length<3){if(e.match(/\d{4}/)!==null)throw new Error("Invalid Date");a.unshift(String(new Date().getFullYear()))}const s={year:0,month:0,day:0};function i(d,u){d==="year"?s.year=w(u):s[d]=u}let h=0;for(;!(s.year&&s.month&&s.day);){e:for(const d of a){if(h++,/^[a-zA-Zé]+$/.test(d)){s.month||i("month",E(d)+1);continue}if(/^'\d\d$/.test(d)||/^\d{3,5}$/.test(d)){s.year||i("year",parseInt(d.replace(/'/,"")));continue}const u=parseInt(d);if(isNaN(u))throw console.error(`not date because ${d} isNaN`),new Error("Invalid Date");const m=Y(u,[s.year?"y":null,s.month?"m":null,s.day?"d":null]);if(m.length==1){if(m[0]==="m"&&!s.month){i("month",u);continue e}if(m[0]==="d"&&!s.day){i("day",u);continue e}if(m[0]==="y"&&!s.year){i("year",u);continue e}}h>3&&(!s.month&&m.includes("m")?i("month",u):!s.day&&m.includes("d")&&i("day",u))}if(h>6)throw new Error("Invalid Date")}if(s.year&&s.month&&s.day)return s;throw new Error("Invalid Date")}function M(e){if(e=e.trim().toLowerCase(),e==="now"){const c=new Date;return{hour:c.getHours(),minute:c.getMinutes(),second:c.getSeconds()}}if(e==="noon")return{hour:12,minute:0,second:0};const a=e.match(/(\d{3,4})/);if(a){const c=a[1].length,v=a[1].slice(0,c==3?1:2),T=a[1].slice(-2);e=e.replace(a[1],v+":"+T)}const s=new RegExp(/^(\d{1,2})(?::(\d{1,2}))?\s*(?:(a|p)\.?m?\.?)?$/i);if(s.test(e)){const c=e.match(s);if(c===null)return null;e=c[1]+":"+(c[2]||"00")+(c[3]||"")}const i=new RegExp(/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?\s*(?:(a|p)m?)?$/i);if(!i.test(e))return null;const h=e.match(i);if(h===null)return null;const d=parseInt(h[1]),u=parseInt(h[2]),m=h[3]?parseInt(h[3]):0,f=h[4];return isNaN(d)||isNaN(u)||isNaN(m)?null:f==="p"&&d<12?{hour:d+12,minute:u,second:m}:f==="a"&&d===12?{hour:0,minute:u,second:m}:d<0||d>23||u<0||u>59||m<0||m>59?null:{hour:d,minute:u,second:m}}function P(e,a="h:mm A"){const s=M(e);if(s){const i=new Date;return i.setHours(s.hour),i.setMinutes(s.minute),i.setSeconds(s.second),i.setMilliseconds(0),D(i,a)}return""}function A(e){if(e instanceof Date)return e;if(e.trim().length<3)return null;e=e.replace(/(\d)T(\d)/,"$1 $2");let a=e.split(/[\s,]+/).filter(f=>f!==""),s="",i="",h="";a.forEach((f,c)=>{const v=f.match(/^(\d{1,4})([apAP]\.?[mM]?\.?)/);v?i=v[0]:(f.includes(":")||f==="now"||f==="noon")&&(i=f),O(f)&&(h=f,!i&&c>0&&k(a[c-1])&&(i=a[c-1]))}),i?a=a.filter(f=>f!==i&&f!==h):[s,a]=F(a);const d=i?`${i} ${h}`:s?a.join(" "):"",u=M(d)||{hour:0,minute:0,second:0},m=I(s||a.join(" ").trim()||"today");return!m||isNaN(m.getTime())?null:new Date(m.getFullYear(),m.getMonth(),m.getDate(),u.hour,u.minute,u.second)}function F(e){for(let a=3;a>0;a--){const s=e.slice(0,a).join(" ");if(H(s))return[s,e.slice(a)]}return["",e]}function D(e,a="YYYY-MM-DD"){if(e=I(e),isNaN(e.getTime()))return"";const s={y:e.getFullYear(),M:e.getMonth(),D:e.getDate(),W:e.getDay(),H:e.getHours(),m:e.getMinutes(),s:e.getSeconds(),ms:e.getMilliseconds()},i=(c,v=2)=>(c+"").padStart(v,"0"),h=()=>s.H%12||12,d=c=>c<12?"AM":"PM",u=c=>"January|February|March|April|May|June|July|August|September|October|November|December".split("|")[c];function m(c,v=0){const T="Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday".split("|");return v?T[c].slice(0,v):T[c]}const f={YY:String(s.y).slice(-2),YYYY:s.y,M:s.M+1,MM:i(s.M+1),MMMM:u(s.M),MMM:u(s.M).slice(0,3),D:String(s.D),DD:i(s.D),d:String(s.W),dd:m(s.W,2),ddd:m(s.W,3),dddd:m(s.W),H:String(s.H),HH:i(s.H),h:h(),hh:i(h()),A:d(s.H),a:d(s.H).toLowerCase(),m:String(s.m),mm:i(s.m),s:String(s.s),ss:i(s.s),SSS:i(s.ms,3)};return a.replace(/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,(c,v)=>v||f[c])}function q(e,a){const s=I(e);return isNaN(s.getTime())?"":((!a||a.length===0)&&(a="YYYY-MMM-DD"),D(s,a))}function Z(e,a){const s=A(e);return s===null||isNaN(s.getTime())?"":((!a||a.length===0)&&(a="YYYY-MMM-DD h:mm A"),D(s,a))}function H(e){if(typeof e!="string"&&!(e instanceof Date))return!1;let a=I(e);return a==null?!1:!isNaN(a.getTime())}function z(e){if(typeof e!="string"&&!(e instanceof Date))return!1;let a=A(e);return a==null?!1:!isNaN(a.getTime())}function j(e,a){return!(a==="past"&&e>new Date||a==="future"&&e.getTime()<new Date().setHours(0,0,0,0))}function O(e){const a=e.toLowerCase().replace(/[.\s]/g,"");return["am","pm","a","p"].includes(a)}function k(e){let a=M(e);return a===null?!1:!isNaN(a.hour)&&!isNaN(a.minute)&&!isNaN(a.second)}function G(e){if(e.length>255||!new RegExp(/^.+@.+\.[a-zA-Z0-9]{2,}$/).test(e))return!1;let a="";return a+="^([a-zA-Z0-9!#$%'*+/=?^_`{|}~-]+",a+="(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*",a+="|",a+='"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*"',a+=")@(",a+="(",a+="(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+",a+="[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?",a+=")",a+=")$",new RegExp(a).test(e)}function B(e){return e=e.replace(/^[^2-90]+/g,""),e=e.replace(/(\d\d\d).*?(\d\d\d).*?(\d\d\d\d)(.*)/,"$1-$2-$3$4"),e}function K(e){return/^\d\d\d-\d\d\d-\d\d\d\d$/.test(e)}function W(e){return e.replace(/[^0-9]/g,"")}function J(e){return/^\-?\d*\.?\d*$/.test(e)}function Q(e){return e.replace(/[^\-0-9.]/g,"").replace(/(^-)|(-)/g,(a,s)=>s?"-":"").replace(/(\..*)\./g,"$1")}function X(e){return/^\-?\d*$/.test(e)}function ee(e){return e=e.trim(),new RegExp("^(?:[a-z+]+:)?//","i").test(e)?e:"https://"+e}function te(e){return new RegExp("^(?:[-a-z+]+:)?//","i").test(e)}function re(e){return e=e.replace(/[^0-9]/g,"").replace(/(.{5})(.*)/,"$1-$2").trim(),e.length===6&&(e=e.replace(/-/,"")),e}function ae(e){return new RegExp(/^\d{5}(-\d{4})?$/).test(e)}function se(e){return e=e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/(.{3})\s*(.*)/,"$1 $2").trim(),e}function ne(e){return new RegExp(/^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/).test(e)}function ie(e){return["transparent","currentColor"].includes(e)?!0:typeof e!="string"||!e.trim()?!1:typeof CSS=="object"&&typeof CSS.supports=="function"?CSS.supports("color",e):oe(e)}function oe(e){const a=new RegExp(/^rgba?\(\s*(\d{1,3}%?,\s*){2}\d{1,3}%?\s*(?:,\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),s=new RegExp(/^hsla?\(\s*\d+(deg|grad|rad|turn)?,\s*\d{1,3}%,\s*\s*\d{1,3}%(?:,\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),i=new RegExp(/^rgba?\(\s*(\d{1,3}%?\s+){2}\d{1,3}%?\s*(?:\s*\/\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),h=new RegExp(/^hsla?\(\s*\d+(deg|grad|rad|turn)?\s+\d{1,3}%\s+\s*\d{1,3}%(?:\s*\/\s*(\.\d+|0+(\.\d+)?|1(\.0+)?|0|1\.0|\d{1,2}(\.\d*)?%|100%))?\s*\)$/),d=new RegExp(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);let u="aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen";const m=new RegExp(`^(${u})$`,"i");return a.test(e)||s.test(e)||i.test(e)||h.test(e)||d.test(e)||m.test(e)}let L=null;const C=new Map;function le(e){if(e=e.trim().toLowerCase(),["transparent","currentcolor"].includes(e))return e;if(C.has(e))return C.get(e);L===null&&(L=document.createElement("canvas"),L.willReadFrequently=!0);let a=L.getContext("2d");if(!a)throw new Error("Can't get context from colorCanvas");a.fillStyle=e,a.fillRect(0,0,1,1);let s=a.getImageData(0,0,1,1).data,i="#"+("000000"+(s[0]<<16|s[1]<<8|s[2]).toString(16)).slice(-6);return C.set(e,i),i}function de(e){let a={valid:!1,error:!1,messages:[]};return typeof e=="boolean"?{valid:e,error:!1,messages:[]}:typeof e=="string"?{valid:!1,error:!1,messages:[e]}:(typeof e.valid=="boolean"&&(a.valid=e.valid),typeof e.message=="string"&&(a.messages=[e.message]),typeof e.messages=="string"&&(a.messages=[e.messages]),Array.isArray(e.messages)&&(a.messages=e.messages),e.error===!0&&(a.error=!0),a)}r.formatDateTime=D,r.isColor=ie,r.isDate=H,r.isDateInRange=j,r.isDateTime=z,r.isEmail=G,r.isFormControl=n,r.isInteger=X,r.isMeridiem=O,r.isNANPTel=K,r.isNumber=J,r.isPostalCA=ne,r.isTime=k,r.isType=l,r.isUrl=te,r.isZip=ae,r.momentToFPFormat=g,r.monthToNumber=E,r.normalizeValidationResult=de,r.parseColor=le,r.parseDate=I,r.parseDateTime=A,r.parseDateTimeToString=Z,r.parseDateToString=q,r.parseInteger=W,r.parseNANPTel=B,r.parseNumber=Q,r.parsePostalCA=se,r.parseTime=M,r.parseTimeToString=P,r.parseUrl=ee,r.parseZip=re,r.yearToFull=w,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})})}(R,R.exports)),R.exports}var o=_();class x extends Event{constructor(r){super("validationSuccess",{cancelable:!0});p(this,"submitEvent");this.submitEvent=r}}class $ extends Event{constructor(r){super("validationError",{cancelable:!0});p(this,"submitEvent");this.submitEvent=r}}class V{constructor(t,r={}){p(this,"form");p(this,"inputs",[]);p(this,"inputErrors",{});p(this,"messages",{ERROR_MAIN:"There is a problem with your submission.",ERROR_GENERIC:"Enter a valid value.",ERROR_REQUIRED:"This field is required.",OPTION_REQUIRED:"An option must be selected.",CHECKED_REQUIRED:"This must be checked.",ERROR_MAXLENGTH:"This must be ${val} characters or fewer.",ERROR_MINLENGTH:"This must be at least ${val} characters.",ERROR_NUMBER:"This must be a number.",ERROR_INTEGER:"This must be a whole number.",ERROR_TEL:"This is not a valid telephone number.",ERROR_EMAIL:"This is not a valid email address.",ERROR_ZIP:"This is not a valid zip code.",ERROR_POSTAL:"This is not a valid postal code.",ERROR_DATE:"This is not a valid date.",ERROR_DATE_PAST:"The date must be in the past.",ERROR_DATE_FUTURE:"The date must be in the future.",ERROR_DATE_RANGE:"The date is outside the allowed range.",ERROR_DATETIME:"This is not a valid date and time.",ERROR_TIME:"This is not a valid time.",ERROR_TIME_RANGE:"The time is outside the allowed range.",ERROR_URL:"This is not a valid URL.",ERROR_COLOR:"This is not a valid CSS colour.",ERROR_CUSTOM_VALIDATION:"There was a problem validating this field."});p(this,"debug");p(this,"autoInit");p(this,"preventSubmit",!1);p(this,"hiddenClasses");p(this,"errorMainClasses");p(this,"errorInputClasses");p(this,"dispatchTimeout",0);p(this,"timeoutId",0);p(this,"debouncedInit");p(this,"originalNoValidate",!1);p(this,"validationSuccessCallback");p(this,"validationErrorCallback");p(this,"submitHandlerRef",this.submitHandler.bind(this));p(this,"inputInputHandlerRef",this.inputInputHandler.bind(this));p(this,"inputChangeHandlerRef",this.inputChangeHandler.bind(this));p(this,"inputKeydownHandlerRef",this.inputKeydownHandler.bind(this));p(this,"inputHandlers",{number:{parse:o.parseNumber,isValid:o.isNumber,error:this.messages.ERROR_NUMBER},integer:{parse:o.parseInteger,isValid:o.isInteger,error:this.messages.ERROR_INTEGER},tel:{parse:o.parseNANPTel,isValid:o.isNANPTel,error:this.messages.ERROR_TEL},email:{parse:t=>t.trim(),isValid:o.isEmail,error:this.messages.ERROR_EMAIL},zip:{parse:o.parseZip,isValid:o.isZip,error:this.messages.ERROR_ZIP},postal:{parse:o.parsePostalCA,isValid:o.isPostalCA,error:this.messages.ERROR_POSTAL},url:{parse:o.parseUrl,isValid:o.isUrl,error:this.messages.ERROR_URL},date:{parse:o.parseDateToString,isValid:o.isDate,error:this.messages.ERROR_DATE},datetime:{parse:o.parseDateTimeToString,isValid:o.isDateTime,error:this.messages.ERROR_DATETIME},time:{parse:o.parseTimeToString,isValid:o.isTime,error:this.messages.ERROR_TIME},color:{parse:t=>t.trim().toLowerCase(),isValid:o.isColor,error:this.messages.ERROR_COLOR}});p(this,"isSubmitting",!1);if(!t)throw new Error("Validator requires a form to be passed as the first argument.");if(!(t instanceof HTMLFormElement))throw new Error("form argument must be an instance of HTMLFormElement");this.form=t,(t.dataset.preventSubmit===""||t.dataset.preventSubmit)&&(this.preventSubmit=!0),Object.assign(this.messages,r.messages||{}),this.debug=r.debug||!1,this.autoInit=r.autoInit!==!1,this.preventSubmit=r.preventSubmit!==void 0?r.preventSubmit:this.preventSubmit,this.hiddenClasses=r.hiddenClasses||"hidden opacity-0",this.errorMainClasses=r.errorMainClasses||"m-2 border border-red-500 bg-red-100 p-3 dark:bg-red-900/80 text-center",this.errorInputClasses=r.errorInputClasses||"border-red-600 dark:border-red-500",this.validationSuccessCallback=r.validationSuccessCallback||(()=>{}),this.validationErrorCallback=r.validationErrorCallback||(()=>{}),this.debouncedInit=this.debounce(this.init.bind(this),45),this.autoInit&&this.init(),new MutationObserver(()=>this.autoInit&&this.debouncedInit()).observe(t,{childList:!0})}debounce(t,r){return(...n)=>{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>t(...n),r)}}addEventListeners(){this.form.addEventListener("submit",this.submitHandlerRef),this.form.addEventListener("input",this.inputInputHandlerRef),this.form.addEventListener("change",this.inputChangeHandlerRef),this.form.addEventListener("keydown",this.inputKeydownHandlerRef),this.form.addEventListener("remove",this.destroy,{once:!0})}removeEventListeners(){this.form.removeEventListener("submit",this.submitHandlerRef),this.form.removeEventListener("input",this.inputInputHandlerRef),this.form.removeEventListener("change",this.inputChangeHandlerRef),this.form.removeEventListener("keydown",this.inputKeydownHandlerRef),this.form.removeEventListener("remove",this.destroy)}init(){this.inputs=Array.from(this.form.elements).filter(t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement),this.inputs.forEach(t=>{!t.name&&!t.id&&(t.id=`vl-input-${Math.random().toString(36).slice(2)}`),this.inputErrors[t.name||t.id]=[]}),this.originalNoValidate=this.form.hasAttribute("novalidate"),this.form.setAttribute("novalidate","novalidate"),this.removeEventListeners(),this.addEventListeners()}getErrorEl(t){const r=E=>{const w=E.replace(/([.#{}()\\?*[\]-])/g,"\\$1");return this.form.querySelector(`#${w}`)||document.getElementById(E)||null},n=t.getAttribute("aria-describedby");if(n){const E=r(n);if(E)return E}const l=r(t.id+"-error");return l||r(t.name+"-error")||null}addErrorMain(t){const r=document.createElement("div");r.id="form-error-main",this.errorMainClasses.split(" ").forEach(n=>{r.classList.add(n)}),t?r.innerHTML=t:r.innerHTML=this.messages.ERROR_MAIN,this.form.appendChild(r)}addInputError(t,r=t.dataset.errorDefault||this.messages.ERROR_GENERIC){const n=t.name||t.id;this.debug&&console.log("Invalid value for "+n+": "+r),n in this.inputErrors||(this.inputErrors[n]=[]),this.inputErrors[n].includes(r)||this.inputErrors[n].push(r)}showInputErrors(t){if(!t||!t.name&&!t.id)return;const r=t.name||t.id,n=r in this.inputErrors?this.inputErrors[r]:[];if(!n.length)return;t.setAttribute("aria-invalid","true"),this.errorInputClasses.split(" ").forEach(g=>{t.classList.add(g)});let l=this.getErrorEl(t);l&&(l.innerHTML=n.join("<br>"),this.hiddenClasses.split(" ").forEach(g=>{l&&l.classList.remove(g)}))}showFormErrors(){if(this.inputs.forEach(t=>this.showInputErrors(t)),Object.values(this.inputErrors).some(t=>Array.isArray(t)&&t.length)){const t=this.form.querySelectorAll("#form-error-main");t.length?t.forEach(r=>{r.innerHTML||(r.innerHTML=this.messages.ERROR_MAIN),this.hiddenClasses.split(" ").forEach(n=>{r.classList.remove(n)})}):this.addErrorMain()}}clearInputErrors(t){this.inputErrors[t.name||t.id]=[],t.removeAttribute("aria-invalid");let r=this.getErrorEl(t);r&&(this.errorInputClasses.split(" ").forEach(n=>{t.classList.remove(n)}),this.hiddenClasses.split(" ").forEach(n=>{r&&r.classList.add(n)}),r.textContent="")}clearFormErrors(){this.form.querySelectorAll("#form-error-main").forEach(t=>{this.hiddenClasses.split(" ").forEach(r=>{t.classList.add(r)})}),this.inputs.forEach(t=>this.clearInputErrors(t))}validateRequired(t){let r=!0;if(t.required&&(t.value===""||t instanceof HTMLInputElement&&["checkbox","radio"].includes(t.type)&&!t.checked))if(t instanceof HTMLInputElement&&["checkbox","radio"].includes(t.type)){let n=!1,l=t.name;const g=this.form.querySelectorAll(`input[name="${l}"]`);if(g.forEach(E=>{if(E instanceof HTMLInputElement&&E.checked===!0){n=!0;return}}),n===!1){r=!1;let E=g.length>1?this.messages.OPTION_REQUIRED:this.messages.CHECKED_REQUIRED;t.dataset.errorDefault&&(E=t.dataset.errorDefault),this.addInputError(t,E)}}else o.isFormControl(t)&&(r=!1,this.addInputError(t,t.dataset.errorDefault||this.messages.ERROR_REQUIRED));return r}validateLength(t){let r=!0;if(t.disabled)return r;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.value.length){let n=t.minLength>0?t.minLength:t.dataset.minLength?parseInt(t.dataset.minLength):0,l=t.maxLength>0&&t.maxLength<5e5?t.maxLength:t.dataset.maxLength?parseInt(t.dataset.maxLength):1/0;n>0&&t.value.length<n&&(r=!1,this.addInputError(t,this.messages.ERROR_MINLENGTH.replace("${val}",n.toString()))),t.value.length>l&&(r=!1,this.addInputError(t,this.messages.ERROR_MAXLENGTH.replace("${val}",l.toString())))}return r}validateInputType(t){const r=t.dataset.type||t.type,n=this.inputHandlers[t.type]||this.inputHandlers[r];if(n){const l=t.dataset.dateFormat||t.dataset.timeFormat,g=n.parse(t.value,l),E=["date","time","datetime-local","month","week"];if(g.length&&!E.includes(t.type)&&(t.value=g),!n.isValid(t.value))return this.addInputError(t,n.error),!1}return!0}validateDateRange(t){if(t.dataset.dateRange){const r=t.dataset.dateRange,n=o.parseDate(t.value);if(!isNaN(n.getTime())&&!o.isDateInRange(n,r)){let l=t.dataset.errorDefault||this.messages.ERROR_DATE_RANGE;return r==="past"?l=this.messages.ERROR_DATE_PAST:r==="future"&&(l=this.messages.ERROR_DATE_FUTURE),this.addInputError(t,l),!1}}return!0}validatePattern(t){const r=t.dataset.pattern||t instanceof HTMLInputElement&&t.pattern||null;return r&&!new RegExp(r).test(t.value)?(this.addInputError(t),!1):!0}async validateCustom(t){if(t.disabled)return!0;const r=t.dataset.validation;if(!r||typeof r!="string")return!0;const n=window[r];if(!n||typeof n!="function")return!0;let l;try{l=await Promise.resolve(n(t.value)),l=o.normalizeValidationResult(l)}catch{return this.addInputError(t,this.messages.ERROR_CUSTOM_VALIDATION),!1}const g=l.messages.join("<br>")||this.messages.ERROR_CUSTOM_VALIDATION;return l.valid||this.addInputError(t,g),l.valid}async validateInput(t){if(!(t instanceof HTMLInputElement)||!t.value.length)return!0;let r=!0;return t.disabled||(r=this.validateInputType(t)&&r,r=this.validateDateRange(t)&&r,r=this.validatePattern(t)&&r,r=await this.validateCustom(t)&&r),r}async validate(t){let r=!0;for(const n of this.inputs)n.disabled||(r=this.validateRequired(n)&&r,r=this.validateLength(n)&&r,r=await this.validateInput(n)&&r,n.value.length||(r=await this.validateCustom(n)&&r));return r}async submitHandler(t){if(this.isSubmitting)return;t.preventDefault(),this.clearFormErrors();let r=await this.validate(t);this.showFormErrors();const n=new x(t),l=new $(t);r?(this.form.dispatchEvent(n),this.validationSuccessCallback&&this.validationSuccessCallback(t)):(this.form.dispatchEvent(l),this.validationErrorCallback&&this.validationErrorCallback(t)),r&&!this.preventSubmit&&(this.isSubmitting=!0,n.defaultPrevented||this.form.submit(),this.isSubmitting=!1)}shouldSkipValidation(t){return typeof t.dataset.novalidate>"u"?!1:t.dataset.novalidate===""?!0:t.dataset.novalidate==="true"}async inputChangeHandler(t){!(t.target instanceof HTMLInputElement)||this.shouldSkipValidation(t.target)||(this.clearInputErrors(t.target),this.validateLength(t.target),await this.validateInput(t.target),this.showInputErrors(t.target))}inputInputHandler(t){const r=t.target;this.shouldSkipValidation(r)||(o.isType(r,"integer")&&(r.value=o.parseInteger(r.value)),r.type!=="number"&&o.isType(r,["number","float","decimal"])&&(r.value=o.parseNumber(r.value)),o.isType(r,"color")&&this.syncColorInput(t))}syncColorInput(t){let r=t.target,n=r;r.type==="color"&&(n=this.form.querySelector(`#${r.id.replace(/-color/,"")}`));let l=this.form.querySelector(`#${n.id}-color-label`);if((r.dataset.type||"")==="color"){let g=this.form.querySelector(`input#${r.id}-color`);if(!g||!o.isColor(r.value))return;g.value=o.parseColor(r.value)}r.type==="color"&&(n.value=r.value),l&&(l.style.backgroundColor=r.value),clearTimeout(this.dispatchTimeout),this.dispatchTimeout=window.setTimeout(()=>{n.dispatchEvent(new Event("change",{bubbles:!0}))},200)}inputKeydownHandler(t){t.target instanceof HTMLInputElement&&o.isType(t.target,"integer")&&(t.key==="ArrowUp"?(t.preventDefault(),t.target.value===""&&(t.target.value="0"),t.target.value=(parseInt(t.target.value)+1).toString()):t.key==="ArrowDown"&&(parseInt(t.target.value)>0?t.target.value=(parseInt(t.target.value)-1).toString():t.target.value="0"))}destroy(){this.removeEventListeners(),this.originalNoValidate||this.form.removeAttribute("novalidate")}}return V});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdlien/validator",
3
- "version": "1.4.3",
3
+ "version": "1.4.6",
4
4
  "type": "module",
5
5
  "module": "dist/validator.js",
6
6
  "types": "dist/Validator.d.ts",
@@ -44,21 +44,20 @@
44
44
  "homepage": "https://github.com/jdlien/validator#readme",
45
45
  "devDependencies": {
46
46
  "@sheerun/mutationobserver-shim": "^0.3.3",
47
- "@tailwindcss/forms": "^0.5.3",
48
- "@types/jsdom": "^21.1.0",
49
- "@vitest/coverage-c8": "^0.33.0",
50
- "@vitest/coverage-v8": "^0.34.2",
51
- "canvas": "^2.11.2",
52
- "jsdom": "^22.1.0",
47
+ "@tailwindcss/forms": "^0.5.10",
48
+ "@types/jsdom": "^21.1.7",
49
+ "@vitest/coverage-v8": "^3.1.1",
50
+ "canvas": "^3.1.0",
51
+ "jsdom": "^26.1.0",
53
52
  "jsdom-global": "^3.0.2",
54
- "prettier": "^3.0.1",
55
- "tailwindcss": "^3.2.7",
56
- "typescript": "^5.1.6",
57
- "vite": "^4.1.0",
58
- "vitest": "^0.34.1"
53
+ "prettier": "^3.5.3",
54
+ "tailwindcss": "^4.1.4",
55
+ "typescript": "^5.8.3",
56
+ "vite": "^6.3.0",
57
+ "vitest": "^3.1.1"
59
58
  },
60
59
  "sideEffects": false,
61
60
  "dependencies": {
62
- "@jdlien/validator-utils": "^1.2.7"
61
+ "@jdlien/validator-utils": "^1.2.8"
63
62
  }
64
63
  }