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

flatpickr

Package Overview
Dependencies
Maintainers
1
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatpickr - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2-1

Project.sublime-project

2

dist/flatpickr.min.js

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

var flatpickr=function(e,t){"use strict";var n,a,r,i=[];if(flatpickr.prototype=flatpickr.init.prototype,a=function(e){return e._flatpickr&&e._flatpickr.destroy(),e._flatpickr=new flatpickr.init(e,t),e._flatpickr},e.nodeName)return a(e);if(n=document.querySelectorAll(e),1===n.length)return a(n[0]);for(var r=0;r<n.length;r++)i.push(a(n[r]));return{calendars:i,byID:function(e){for(var t=0;t<this.calendars.length;t++)if(this.calendars[t].element.id===e)return this.calendars[t]}}};flatpickr.init=function(e,t){"use strict";var n,a,r,i,c,o,l,u,d,s,f,p,m,g,h,v,D,M,b,L,E,y,k,O,w,j,C,T,N,H=this,S=document.createElement("div"),F=document.createElement("span"),I=document.createElement("div"),Y=document.createElement("span"),x=document.createElement("span"),A=document.createElement("table"),_=document.createElement("tbody"),q=new Date,J=document.createElement("div");return E=function(){S.className="flatpickr-calendar",F.className="flatpickr-current-month",t=t||{},H.config={},H.element=e,H.destroy=L;for(var r in H.defaultConfig)H.config[r]=t[r]||H.element.dataset[r.toLowerCase()]||H.defaultConfig[r];H.input=H.config.wrap?e.querySelector("[data-input]"):e,H.config.defaultDate=a(H.config.defaultDate),(H.input.value||H.config.defaultDate)&&(H.selectedDateObj=a(H.config.defaultDate||H.input.value)),H.config.minDate=a("today"===H.config.minDate?new Date:H.config.minDate,!0),H.config.maxDate=a(H.config.maxDate,!0),w(H.selectedDateObj||H.config.minDate||q),n(),M(),b(),H.config.noCalendar||p()},a=function(e,t){return t=t||!1,"string"==typeof e&&(e=new Date(e.replace(/[-.]/g,"/"))),t&&e&&e.setHours(0,0,0,0),e},r=function(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()},n=function(){J.className="flatpickr-wrapper",H.element.parentNode.insertBefore(J,H.element),J.appendChild(H.element),H.config.inline&&J.classList.add("inline"),H.config.altInput&&(j=document.createElement(H.input.nodeName),j.className=H.input.className,H.input.type="hidden",J.appendChild(j))},O=function(e){var t=H.currentYear,n=e||H.currentMonth;return 1!==n||t%4||!(t%100)&&t%400?H.l10n.daysInMonth[n]:29},p=function(){if(H.selectedDateObj&&H.config.enableTime){var e=parseInt(C.value),t=(60+parseInt(T.value))%60;H.config.time_24hr||(e=e%12+12*("PM"===N.innerHTML)),H.selectedDateObj.setHours(e,t),C.value=i(H.config.time_24hr?e:(12+e)%12+12*(e%12===0)),T.value=i(t)}H.selectedDateObj&&(H.input.value=c(H.config.dateFormat)),H.config.altInput&&H.selectedDateObj&&(j.value=c(H.config.altFormat)),y()},i=function(e){return("0"+e).slice(-2)},c=function(e){H.config.noCalendar&&(e=""),H.config.enableTime&&(e+=" "+H.config.timeFormat);var t="",n={d:function(){return i(n.j())},D:function(){return H.l10n.weekdays.shorthand[n.w()]},j:function(){return H.selectedDateObj.getDate()},l:function(){return H.l10n.weekdays.longhand[n.w()]},w:function(){return H.selectedDateObj.getDay()},F:function(){return o(n.n()-1,!1)},m:function(){return i(n.n())},M:function(){return o(n.n()-1,!0)},n:function(){return H.selectedDateObj.getMonth()+1},U:function(){return H.selectedDateObj.getTime()/1e3},y:function(){return String(n.Y()).substring(2)},Y:function(){return H.selectedDateObj.getFullYear()},h:function(){return H.selectedDateObj.getHours()%12?H.selectedDateObj.getHours()%12:12},H:function(){return i(H.selectedDateObj.getHours())},i:function(){return i(H.selectedDateObj.getMinutes())},K:function(){return H.selectedDateObj.getHours()>11?"PM":"AM"}},a=e.split("");return[].forEach.call(a,function(e,r){n[e]&&"\\"!==a[r-1]?t+=n[e]():"\\"!==e&&(t+=e)}),t},o=function(e,t){return t?H.l10n.months.shorthand[e]:H.l10n.months.longhand[e]},l=function(e){for(var t=0;t<H.config.disable.length;t++)if(e>=a(H.config.disable[t].from)&&e<=a(H.config.disable[t].to))return!0;return!1},f=function(e){e.preventDefault();var t=parseInt(e.target.min),n=parseInt(e.target.max),a=parseInt(e.target.step),r=a*Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),c=(parseInt(e.target.value)+r)%(n+(0===t));t>c&&(c=n+(0===t)-a*(0===t)),e.target.value=i(c)},m=function(){F.innerHTML="<span>"+o(H.currentMonth,H.config.shorthandCurrentMonth)+"</span> "+H.currentYear},h=function(){(H.currentMonth<0||H.currentMonth>11)&&(H.currentYear+=H.currentMonth%11,H.currentMonth=(H.currentMonth+12)%12)},v=function(e){J.classList.contains("open")&&!J.contains(e.target)&&H.close()},k=function(e){H.currentMonth+=e,h(),m(),d()},D=function(e){e.preventDefault();var t=e.target;(t.classList.contains("slot")||t.parentNode.classList.contains("slot"))&&(H.selectedDateObj=new Date(H.currentYear,H.currentMonth,t.childNodes[0].innerHTML||t.innerHTML),p(),d(),H.config.inline||H.config.enableTime||H.close())},M=function(){H.config.noCalendar||(g(),u(),d(),A.appendChild(_),S.appendChild(A)),J.appendChild(S),H.config.enableTime&&s()},g=function(){I.className="flatpickr-months",Y.className="flatpickr-prev-month",Y.innerHTML=H.config.prevArrow,x.className="flatpickr-next-month",x.innerHTML=H.config.nextArrow,I.appendChild(Y),I.appendChild(F),I.appendChild(x),m(),S.appendChild(I)},u=function(){var e=document.createElement("thead"),t=H.l10n.firstDayOfWeek,n=H.l10n.weekdays.shorthand.slice();t>0&&t<n.length&&(n=[].concat(n.splice(t,n.length),n.splice(0,t))),e.innerHTML="<tr><th>"+n.join("</th><th>")+"</th></tr>",A.appendChild(e)},d=function(){var e,t,n,a,i,c=(new Date(H.currentYear,H.currentMonth,1).getDay()-H.l10n.firstDayOfWeek+7)%7,o=O(),u=(H.currentMonth-1+12)%12,d=O(u),s=document.createDocumentFragment(),f=document.createElement("tr");for(e=d+1-c;d>=e;e++)f.innerHTML+='<td class="disabled"><span class="flatpickr-day">'+e+"</span></td>";for(_.innerHTML="",e=1;42-c>=e;e++)o>=e&&(n=new Date(H.currentYear,H.currentMonth,e)),(e+c-1)%7===0&&(s.appendChild(f),f=document.createElement("tr")),i=H.config.minDate&&n<H.config.minDate||H.config.maxDate&&n>H.config.maxDate,a=e>o||i||l(n),t=a?"disabled":"slot",a||H.selectedDateObj||!r(n,q)||(t+=" today"),!a&&H.selectedDateObj&&r(n,H.selectedDateObj)&&(t+=" selected"),f.innerHTML+='<td class="'+t+'"><span class="flatpickr-day">'+(e>o?e%o:e)+"</span></td>";s.appendChild(f),_.appendChild(s)},s=function(){var e=document.createElement("div"),t=document.createElement("span");e.className="flatpickr-time",C=document.createElement("input"),T=document.createElement("input"),t.className="flatpickr-time-separator",t.innerHTML=":",C.className="flatpickr-hour",C.type=T.type="number",T.className="flatpickr-minute",C.value=H.selectedDateObj?i(H.selectedDateObj.getHours()):12,T.value=H.selectedDateObj?i(H.selectedDateObj.getMinutes()):"00",C.step=H.config.hourIncrement,T.step=H.config.minuteIncrement,C.min=+!H.config.time_24hr,C.max=H.config.time_24hr?23:12,T.min=0,T.max=59,e.appendChild(C),e.appendChild(t),e.appendChild(T),H.config.time_24hr||(N=document.createElement("span"),N.className="flatpickr-am-pm",N.innerHTML=["AM","PM"][C.value>11|0],e.appendChild(N)),H.config.noCalendar&&(H.selectedDateObj=new Date),S.appendChild(e)},b=function(){function e(e){e.preventDefault(),N.innerHTML=["AM","PM"]["AM"===N.innerHTML|0]}"true"===String(H.config.clickOpens)&&(H.input.addEventListener("focus",H.open),H.config.altInput&&j.addEventListener("focus",H.open)),H.config.wrap&&H.element.querySelector("[data-open]")&&H.element.querySelector("[data-open]").addEventListener("click",H.open),H.config.wrap&&H.element.querySelector("[data-close]")&&H.element.querySelector("[data-close]").addEventListener("click",H.close),H.config.wrap&&H.element.querySelector("[data-toggle]")&&H.element.querySelector("[data-toggle]").addEventListener("click",H.toggle),H.config.wrap&&H.element.querySelector("[data-clear]")&&H.element.querySelector("[data-clear]").addEventListener("click",H.clear),Y.addEventListener("click",function(){k(-1)}),x.addEventListener("click",function(){k(1)}),A.addEventListener("click",D),document.addEventListener("click",v,!0),H.config.enableTime&&(C.addEventListener("mousewheel",f),C.addEventListener("DOMMouseScroll",f),T.addEventListener("mousewheel",f),T.addEventListener("DOMMouseScroll",f),C.addEventListener("mouseout",p),T.addEventListener("mouseout",p),C.addEventListener("change",p),T.addEventListener("change",p),C.addEventListener("click",function(){C.select()}),T.addEventListener("click",function(){T.select()}),H.config.time_24hr||(N.addEventListener("focus",function(){N.blur()}),N.addEventListener("click",e),N.addEventListener("mousewheel",e),N.addEventListener("DOMMouseScroll",e),N.addEventListener("mouseout",p)))},H.open=function(){H.input.disabled||(H.input.blur(),H.input.classList.add("active"),j&&j.blur(),!H.config.inline&&H.element.parentNode.classList.add("open"))},H.toggle=function(){H.input.disabled||(H.element.parentNode.classList.toggle("open"),H.input.classList.toggle("active"))},H.close=function(){H.element.parentNode.classList.remove("open"),H.input.classList.remove("active")},H.clear=function(){H.input.value="",H.selectedDateObj=null,w(),H.redraw()},y=function(){if("createEvent"in document){var t=document.createEvent("Event");t.initEvent("change",!0,!0),e.dispatchEvent(t)}else e.fireEvent("onchange");H.config.onChange(H.selectedDateObj,H.input.value)},L=function(){var e,t;document.removeEventListener("click",v,!1),H.input.removeEventListener("focus",H.open,!1),H.input.removeEventListener("click",H.open,!1),e=H.element.parentNode,e.removeChild(S),t=e.removeChild(H.element),e.parentNode.replaceChild(t,e)},w=function(e){e=a(e||H.selectedDateObj||H.config.defaultDate||H.config.minDate||q),H.currentYear=e.getFullYear(),H.currentMonth=e.getMonth()},H.redraw=function(){m(),d()},H.jumpToDate=function(e){w(a(e)||new Date),H.redraw()},H.setDate=function(e,t){H.selectedDateObj=a(e),H.jumpToDate(H.selectedDateObj),p(),t=t||!1,t&&y()},H.set=function(e,t){e in H.config&&(H.config[e]=t,w(),H.redraw())},E(),H},flatpickr.init.prototype={l10n:{weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0},defaultConfig:{noCalendar:!1,wrap:!1,clickOpens:!0,dateFormat:"Y-m-d",altInput:!1,altFormat:"F j, Y",defaultDate:null,minDate:null,maxDate:null,disable:[],shorthandCurrentMonth:!1,inline:!1,prevArrow:"&lt;",nextArrow:"&gt;",enableTime:!1,timeFormat:"h:i K",time_24hr:!1,hourIncrement:1,minuteIncrement:5,onChange:function(e,t){}}},Date.prototype.fp_incr=function(e){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+parseInt(e,10))},"undefined"!=typeof module&&(module.exports=flatpickr);
var flatpickr=function(e,t){"use strict";var n,a,r,i=[];if(flatpickr.prototype=flatpickr.init.prototype,a=function(e){return e._flatpickr&&e._flatpickr.destroy(),e._flatpickr=new flatpickr.init(e,t),e._flatpickr},e.nodeName)return a(e);if(/^\#[a-zA-Z0-9\-\_]*$/.test(e))return a(document.getElementById(e.slice(1)));for(n=/^\.[a-zA-Z0-9\-\_]*$/.test(e)?document.getElementsByClassName(e.slice(1)):document.querySelectorAll(e),r=0;r<n.length;r++)i.push(a(n[r]));return{calendars:i,byID:function(e){for(var t=0;t<this.calendars.length;t++)if(this.calendars[t].element.id===e)return this.calendars[t]}}};flatpickr.init=function(e,t){"use strict";var n,a,r,i,c,l,o,u,d,s,f,p,m,g,h,v,D,M,b,L,E,y,k,O,w,j,C,I,T=this,N=document.createElement("div"),H=document.createElement("span"),S=document.createElement("div"),F=document.createElement("span"),Y=document.createElement("span"),A=document.createElement("table"),_=document.createElement("tbody"),x=new Date,q=document.createElement("div");return E=function(){N.className="flatpickr-calendar",H.className="flatpickr-current-month",t=t||{},T.config={},T.element=e,T.destroy=L;for(var r in T.defaultConfig)T.config[r]=t[r]||T.element.dataset[r.toLowerCase()]||T.defaultConfig[r];T.input=T.config.wrap?e.querySelector("[data-input]"):e,T.config.defaultDate&&(T.config.defaultDate=a(T.config.defaultDate),console.log("2016-03-01 00:00:00 -0300")),(T.input.value||T.config.defaultDate)&&(T.selectedDateObj=a(T.config.defaultDate||T.input.value)),T.config.minDate=a("today"===T.config.minDate?new Date:T.config.minDate,!0),T.config.maxDate=a(T.config.maxDate,!0),w(T.selectedDateObj||T.config.minDate||x),n(),M(),b(),T.config.noCalendar||p()},a=function(e,t){return t=t||!1,"string"==typeof e&&(e=new Date(e.replace(/(\d*)[\-\.](\d*)[\-\.](\d*)/g,"$1/$2/$3"))),t&&e&&e.setHours(0,0,0,0),e},r=function(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()},n=function(){q.className="flatpickr-wrapper",T.element.parentNode.insertBefore(q,T.element),q.appendChild(T.element),T.config.inline&&q.classList.add("inline"),T.config.altInput&&(T.altInput=document.createElement(T.input.nodeName),T.altInput.placeholder=T.input.placeholder,T.input.type="hidden",q.appendChild(T.altInput))},O=function(e){var t=T.currentYear,n=e||T.currentMonth;return 1!==n||t%4||!(t%100)&&t%400?T.l10n.daysInMonth[n]:29},p=function(){if(T.selectedDateObj&&T.config.enableTime){var e=parseInt(j.value),t=(60+parseInt(C.value))%60;T.config.time_24hr||(e=e%12+12*("PM"===I.innerHTML)),T.selectedDateObj.setHours(e,t),j.value=i(T.config.time_24hr?e:(12+e)%12+12*(e%12===0)),C.value=i(t)}T.altInput&&T.selectedDateObj&&(T.altInput.value=c(T.config.altFormat)),T.selectedDateObj&&(T.input.value=c(T.config.dateFormat)),y()},i=function(e){return("0"+e).slice(-2)},c=function(e){T.config.noCalendar&&(e=""),T.config.enableTime&&(e+=" "+T.config.timeFormat);var t="",n={d:function(){return i(n.j())},D:function(){return T.l10n.weekdays.shorthand[n.w()]},j:function(){return T.selectedDateObj.getDate()},l:function(){return T.l10n.weekdays.longhand[n.w()]},w:function(){return T.selectedDateObj.getDay()},F:function(){return l(n.n()-1,!1)},m:function(){return i(n.n())},M:function(){return l(n.n()-1,!0)},n:function(){return T.selectedDateObj.getMonth()+1},U:function(){return T.selectedDateObj.getTime()/1e3},y:function(){return String(n.Y()).substring(2)},Y:function(){return T.selectedDateObj.getFullYear()},h:function(){return T.selectedDateObj.getHours()%12?T.selectedDateObj.getHours()%12:12},H:function(){return i(T.selectedDateObj.getHours())},i:function(){return i(T.selectedDateObj.getMinutes())},K:function(){return T.selectedDateObj.getHours()>11?"PM":"AM"}},a=e.split("");return[].forEach.call(a,function(e,r){n[e]&&"\\"!==a[r-1]?t+=n[e]():"\\"!==e&&(t+=e)}),t},l=function(e,t){return t?T.l10n.months.shorthand[e]:T.l10n.months.longhand[e]},o=function(e){for(var t=0;t<T.config.disable.length;t++)if(e>=a(T.config.disable[t].from)&&e<=a(T.config.disable[t].to))return!0;return!1},f=function(e){e.preventDefault();var t=parseInt(e.target.min),n=parseInt(e.target.max),a=parseInt(e.target.step),r=a*Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),c=(parseInt(e.target.value)+r)%(n+(0===t));t>c&&(c=n+(0===t)-a*(0===t)),e.target.value=i(c)},m=function(){H.innerHTML="<span>"+l(T.currentMonth,T.config.shorthandCurrentMonth)+"</span> "+T.currentYear},h=function(){(T.currentMonth<0||T.currentMonth>11)&&(T.currentYear+=T.currentMonth%11,T.currentMonth=(T.currentMonth+12)%12)},v=function(e){q.classList.contains("open")&&!q.contains(e.target)&&T.close()},k=function(e){T.currentMonth+=e,h(),m(),d()},D=function(e){e.preventDefault();var t=e.target;(t.classList.contains("slot")||t.parentNode.classList.contains("slot"))&&(T.selectedDateObj=new Date(T.currentYear,T.currentMonth,t.childNodes[0].innerHTML||t.innerHTML),p(),d(),T.config.inline||T.config.enableTime||T.close())},M=function(){T.config.noCalendar||(g(),u(),d(),A.appendChild(_),N.appendChild(A)),q.appendChild(N),T.config.enableTime&&s()},g=function(){S.className="flatpickr-months",F.className="flatpickr-prev-month",F.innerHTML=T.config.prevArrow,Y.className="flatpickr-next-month",Y.innerHTML=T.config.nextArrow,S.appendChild(F),S.appendChild(H),S.appendChild(Y),m(),N.appendChild(S)},u=function(){var e=document.createElement("thead"),t=T.l10n.firstDayOfWeek,n=T.l10n.weekdays.shorthand.slice();t>0&&t<n.length&&(n=[].concat(n.splice(t,n.length),n.splice(0,t))),e.innerHTML="<tr><th>"+n.join("</th><th>")+"</th></tr>",A.appendChild(e)},d=function(){var e,t,n,a,i,c=(new Date(T.currentYear,T.currentMonth,1).getDay()-T.l10n.firstDayOfWeek+7)%7,l=O(),u=(T.currentMonth-1+12)%12,d=O(u),s=document.createDocumentFragment(),f=document.createElement("tr");for(e=d+1-c;d>=e;e++)f.innerHTML+='<td class="disabled"><span class="flatpickr-day">'+e+"</span></td>";for(_.innerHTML="",e=1;42-c>=e;e++)l>=e&&(n=new Date(T.currentYear,T.currentMonth,e)),(e+c-1)%7===0&&(s.appendChild(f),f=document.createElement("tr")),i=T.config.minDate&&n<T.config.minDate||T.config.maxDate&&n>T.config.maxDate,a=e>l||i||o(n),t=a?"disabled":"slot",a||T.selectedDateObj||!r(n,x)||(t+=" today"),!a&&T.selectedDateObj&&r(n,T.selectedDateObj)&&(t+=" selected"),f.innerHTML+='<td class="'+t+'"><span class="flatpickr-day">'+(e>l?e%l:e)+"</span></td>";s.appendChild(f),_.appendChild(s)},s=function(){var e=document.createElement("div"),t=document.createElement("span");e.className="flatpickr-time",j=document.createElement("input"),C=document.createElement("input"),t.className="flatpickr-time-separator",t.innerHTML=":",j.className="flatpickr-hour",j.type=C.type="number",C.className="flatpickr-minute",j.value=T.selectedDateObj?i(T.selectedDateObj.getHours()):12,C.value=T.selectedDateObj?i(T.selectedDateObj.getMinutes()):"00",j.step=T.config.hourIncrement,C.step=T.config.minuteIncrement,j.min=+!T.config.time_24hr,j.max=T.config.time_24hr?23:12,C.min=0,C.max=59,j.title=C.title="Scroll to increment",e.appendChild(j),e.appendChild(t),e.appendChild(C),T.config.time_24hr||(I=document.createElement("span"),I.className="flatpickr-am-pm",I.innerHTML=["AM","PM"][j.value>11|0],I.title="Click to toggle",e.appendChild(I)),T.config.noCalendar&&(T.selectedDateObj=new Date),N.appendChild(e)},b=function(){function e(e){e.preventDefault(),I.innerHTML=["AM","PM"]["AM"===I.innerHTML|0]}"true"===String(T.config.clickOpens)&&(T.input.addEventListener("focus",T.open),T.altInput&&T.altInput.addEventListener("focus",T.open)),T.config.wrap&&T.element.querySelector("[data-open]")&&T.element.querySelector("[data-open]").addEventListener("click",T.open),T.config.wrap&&T.element.querySelector("[data-close]")&&T.element.querySelector("[data-close]").addEventListener("click",T.close),T.config.wrap&&T.element.querySelector("[data-toggle]")&&T.element.querySelector("[data-toggle]").addEventListener("click",T.toggle),T.config.wrap&&T.element.querySelector("[data-clear]")&&T.element.querySelector("[data-clear]").addEventListener("click",T.clear),F.addEventListener("click",function(){k(-1)}),Y.addEventListener("click",function(){k(1)}),A.addEventListener("click",D),document.addEventListener("click",v,!0),T.config.enableTime&&(j.addEventListener("mousewheel",f),j.addEventListener("DOMMouseScroll",f),C.addEventListener("mousewheel",f),C.addEventListener("DOMMouseScroll",f),j.addEventListener("mouseout",p),C.addEventListener("mouseout",p),j.addEventListener("change",p),C.addEventListener("change",p),j.addEventListener("click",function(){j.select()}),C.addEventListener("click",function(){C.select()}),T.config.time_24hr||(I.addEventListener("focus",function(){I.blur()}),I.addEventListener("click",e),I.addEventListener("mousewheel",e),I.addEventListener("DOMMouseScroll",e),I.addEventListener("mouseout",p)))},T.open=function(){T.input.disabled||(T.input.blur(),T.input.classList.add("active"),T.altInput&&(T.altInput.blur(),T.altInput.classList.add("active")),!T.config.inline&&T.element.parentNode.classList.add("open"))},T.toggle=function(){T.input.disabled||(T.element.parentNode.classList.toggle("open"),T.altInput&&T.altInput.classList.toggle("active"),T.input.classList.toggle("active"))},T.close=function(){T.element.parentNode.classList.remove("open"),T.input.classList.remove("active"),T.altInput&&T.altInput.classList.remove("active")},T.clear=function(){T.input.value="",T.selectedDateObj=null,w(),T.redraw()},y=function(){if("createEvent"in document){var t=document.createEvent("Event");t.initEvent("change",!0,!0),e.dispatchEvent(t)}else e.fireEvent("onchange");T.config.onChange(T.selectedDateObj,T.input.value)},L=function(){var e,t;document.removeEventListener("click",v,!1),T.input.removeEventListener("focus",T.open,!1),T.input.removeEventListener("click",T.open,!1),e=T.element.parentNode,e.removeChild(N),t=e.removeChild(T.element),e.parentNode.replaceChild(t,e)},w=function(e){e=a(e||T.selectedDateObj||T.config.defaultDate||T.config.minDate||x),T.currentYear=e.getFullYear(),T.currentMonth=e.getMonth()},T.redraw=function(){m(),d()},T.jumpToDate=function(e){w(a(e)||new Date),T.redraw()},T.setDate=function(e,t){T.selectedDateObj=a(e),T.jumpToDate(T.selectedDateObj),p(),t=t||!1,t&&y()},T.set=function(e,t){e in T.config&&(T.config[e]=t,w(),T.redraw())},E(),T},flatpickr.init.prototype={l10n:{weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0},defaultConfig:{noCalendar:!1,wrap:!1,clickOpens:!0,dateFormat:"Y-m-d",altInput:!1,altFormat:"F j, Y",defaultDate:null,minDate:null,maxDate:null,disable:[],shorthandCurrentMonth:!1,inline:!1,prevArrow:"&lt;",nextArrow:"&gt;",enableTime:!1,timeFormat:"h:i K",time_24hr:!1,hourIncrement:1,minuteIncrement:5,onChange:function(e,t){}}},Date.prototype.fp_incr=function(e){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+parseInt(e,10))},"undefined"!=typeof module&&(module.exports=flatpickr);
{
"name": "flatpickr",
"version": "1.7.1",
"description": "A fast, feature-rich, and elegant javascript date picker (vanilla/no dependencies)",
"version": "1.7.2-1",
"description": "A lightweight, powerful datetimepicker",
"dependencies": {},

@@ -13,3 +13,2 @@ "devDependencies": {

},
"scripts": {},
"main": "dist/flatpickr.min.js",

@@ -20,3 +19,3 @@ "repository": {

},
"author": "Gregory M",
"author": "Gregory",
"license": "MIT",

@@ -29,9 +28,9 @@ "bugs": {

"javascript",
"js",
"datetimepicker",
"calendar",
"date",
"time",
"picker",
"vanilla",
"lightweight"
]
}

@@ -1,18 +0,24 @@

[![npm version](https://badge.fury.io/js/flatpickr.svg)](https://badge.fury.io/js/flatpickr)
[![Bower version](https://badge.fury.io/bo/flatpickr-calendar.svg)](https://badge.fury.io/bo/flatpickr-calendar)
[![npm version](https://badge.fury.io/js/flatpickr.svg)](https://www.npmjs.com/package/flatpickr)
![Bower version](https://badge.fury.io/bo/flatpickr-calendar.svg)
# flatpickr
## Preamble
![wew](https://cloud.githubusercontent.com/assets/11352152/14397836/d02d2f7c-fdad-11e5-9658-bedfb997ff52.png)
Almost every large SPA or project involves date and time input. There are limited options, however, if you also prefer to keep your projects lean and consequently stay away from heavy frameworks such as [jQuery](https://jsperf.com/jquery-vs-javascript-performance-comparison/22), or even Bootstrap.
<!-- ![](https://cloud.githubusercontent.com/assets/11352152/12774092/8574034c-ca0f-11e5-9656-14711e806479.png)-->
![scr_custom](https://cloud.githubusercontent.com/assets/11352152/14218528/b80adb0a-f822-11e5-9e89-0020345fa80d.PNG)
Unfortunately, current HTML5 implementations (`input[type='datetime']`) are neither aesthetically pleasing nor [widely supported](http://caniuse.com/#feat=input-datetime). So that's out of the way.
A lightweight (only 2.75kb minified and gzipped), feature-packed datetime picker.
Framework-agnostic, and written in vanilla JS.
Appalled at the fact that I have to load 300kb of jquery and jquery UI or hook up bootstrap just to use a calendar, I created this \[date\]\[time\]picker that's powerful, easy to use, and looks good out of the box.
![wew](https://cloud.githubusercontent.com/assets/11352152/13730755/d79b5c4a-e92e-11e5-9fc9-b4f1acd50abd.png)
Written in vanilla javascript, works with anything, anywhere.
### Installing
## Screenshots
`npm i flatpickr` or `bower install flatpickr-calendar`
![light datetimepicker](https://cloud.githubusercontent.com/assets/11352152/14218528/b80adb0a-f822-11e5-9e89-0020345fa80d.PNG)
![dark datetimepicker](https://cloud.githubusercontent.com/assets/11352152/12774092/8574034c-ca0f-11e5-9656-14711e806479.png)
## Install & Use
Along with demos and documentation: http://chmln.github.io/flatpickr
See also:

@@ -23,3 +29,2 @@ * [ember.js package](https://www.npmjs.com/package/ember-cli-flatpickr)

### Using
Demos and documentation : http://chmln.github.io/flatpickr

@@ -18,16 +18,22 @@ var flatpickr = function (selector, config) {

if (selector.nodeName) {
if (selector.nodeName)
return createInstance(selector);
}
/*
Utilize the performance of native getters if applicable
https://jsperf.com/getelementsbyclassname-vs-queryselectorall/18
https://jsperf.com/jquery-vs-javascript-performance-comparison/22
*/
else if ( /^\#[a-zA-Z0-9\-\_]*$/.test(selector) )
return createInstance(document.getElementById(selector.slice(1)));
elements = document.querySelectorAll(selector);
else if ( /^\.[a-zA-Z0-9\-\_]*$/.test(selector) )
elements = document.getElementsByClassName(selector.slice(1));
else
elements = document.querySelectorAll(selector);
if (elements.length === 1) {
return createInstance(elements[0]);
}
for (i = 0; i < elements.length; i++)
instances.push(createInstance(elements[i]));
for (var i = 0; i < elements.length; i++) {
instances.push(createInstance(elements[i]));
}
return {

@@ -89,3 +95,2 @@ calendars: instances,

currentDate = new Date(),
altInput,
wrapperElement = document.createElement('div'),

@@ -115,4 +120,8 @@ hourElement,

self.input = (self.config.wrap) ? element.querySelector("[data-input]") : element;
self.config.defaultDate = uDate(self.config.defaultDate);
if(self.config.defaultDate){
self.config.defaultDate = uDate(self.config.defaultDate);
console.log(("2016-03-01 00:00:00 -0300"));
}
if ( self.input.value || self.config.defaultDate )

@@ -140,4 +149,6 @@ self.selectedDateObj = uDate(self.config.defaultDate||self.input.value);

// dashes to slashes (just in case) to keep firefox happy
typeof date === 'string' && (date = new Date(date.replace(/[-.]/g, "/")));
// dashes to slashes because firefox sucks
if (typeof date === 'string')
date = new Date(date.replace(/(\d*)[\-\.](\d*)[\-\.](\d*)/g, "$1/$2/$3"));
timeless && date && ( date.setHours(0,0,0,0) );

@@ -167,7 +178,7 @@

// replicate self.element
altInput = document.createElement(self.input.nodeName);
altInput.className = self.input.className;
self.altInput = document.createElement(self.input.nodeName);
self.altInput.placeholder = self.input.placeholder;
self.input.type='hidden';
wrapperElement.appendChild(altInput);
wrapperElement.appendChild(self.altInput);

@@ -208,9 +219,10 @@ }

}
if ( self.altInput && self.selectedDateObj )
self.altInput.value = formatDate(self.config.altFormat);
if ( self.selectedDateObj )
self.input.value = formatDate(self.config.dateFormat);
if ( self.config.altInput && self.selectedDateObj )
altInput.value = formatDate(self.config.altFormat);
triggerChange();

@@ -554,2 +566,4 @@

hourElement.title = minuteElement.title = "Scroll to increment";
timeContainer.appendChild(hourElement);

@@ -563,2 +577,3 @@ timeContainer.appendChild(separator);

am_pm.innerHTML = ["AM","PM"][(hourElement.value > 11)|0];
am_pm.title="Click to toggle";
timeContainer.appendChild(am_pm);

@@ -585,3 +600,5 @@ }

self.input.addEventListener( 'focus' , self.open);
self.config.altInput && (altInput.addEventListener( 'focus' , self.open) );
if(self.altInput)
self.altInput.addEventListener( 'focus' , self.open);
}

@@ -642,3 +659,6 @@

self.input.classList.add('active');
altInput && (altInput.blur());
if(self.altInput){
self.altInput.blur();
self.altInput.classList.add('active');
}

@@ -652,3 +672,8 @@ !self.config.inline && ( self.element.parentNode.classList.add('open') );

return;
self.element.parentNode.classList.toggle('open');
if(self.altInput)
self.altInput.classList.toggle('active');
self.input.classList.toggle('active');

@@ -660,2 +685,4 @@ };

self.input.classList.remove('active');
if (self.altInput)
self.altInput.classList.remove('active');

@@ -662,0 +689,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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