New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-renderless-calendar

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-renderless-calendar - npm Package Compare versions

Comparing version

to
2.1.0-beta.0

lib/utils/locale-strings.js

2

dist/index.js

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

var t=31,e=6,n=1,r=0,a=6,i="single",s="range",o="single",u="double",h="custom",f=864e5;function c(t,e){return[e]}function d(t,e){return[t,e].slice(0).sort(function(t,e){return t.ms-e.ms})}function l(t,e){return 2===t.length?[e]:function(t,e){if(0===t.length)return[e];var n=t[0],r=t[1];return 1===t.length?d(n,e):n.formatted===e.formatted?[n,e]:r.formatted===e.formatted?[r,e]:d(Math.abs(n.ms-e.ms)<Math.abs(r.ms-e.ms)?r:n,e)}(t,e)}function m(t){return new(Function.prototype.bind.apply(Date,[null].concat(t.split("-"))))}function D(t,e){var n=e[0],r=e[1];return p(t,n)&&y(t,r)}function v(t,e){return M(e,t)}function g(t,e){return M(t,e)}function M(t,e){return m(t).valueOf()-m(e).valueOf()===f}function y(t,e){return t<e}function p(t,e){return t>e}function O(t,e){return t===e}function w(t,e){return t===e}function S(t,e){return new Date(t,e)}function b(t,e){var n=e.disabledDates;void 0===n&&(n=[]);var r=e.maxDate;void 0===r&&(r="");var a=e.minDate;return void 0===a&&(a=""),a&&y(t,a)||r&&p(t,r)||function(t,e){return-1!==e.indexOf(t)}(t,n)}function Y(t){return t<10?"0"+t:t}function F(t,e,i,s){void 0===s&&(s={});var o=s.isOtherMonthDay;void 0===o&&(o=!1);var u=new Date(t,e,i);this.ms=u.valueOf(),this.dayOfWeek=(u.getDay()+6)%7,this.year=u.getFullYear(),this.month=u.getMonth(),this.day=u.getDate(),this.actualMonthNumber=this.month+n,this.formatted=[this.year,this.actualMonthNumber,this.day].map(Y).join("-"),this.isWeekend=function(t){var e=t.getDay();return e===r||e===a}(u),this.isToday=function(t){var e=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(u),this.isOtherMonthDay=o}F.fromString=function(t){var e=t.split("-"),r=e[0],a=e[1],i=e[2];return new F(r,a-n,i)},F.prototype.isBetween=function(t){var e=t.currentHoveredDate,n=t.captureThirdDate,r=t.selectedDates;if(0===r.length)return!1;var a=this.formatted,i=r[0],s=r[1],o=e&&e.formatted,u=i&&i.formatted,h=s&&s.formatted;return!s&&o?D(a,[u,o])||D(a,[o,u]):n&&o?D(a,[u,o])||D(a,[o,h]):D(a,[u,h])},F.prototype.isSelected=function(t){return void 0===t&&(t=[]),function(t,e){return e.some(function(e){return O(e,t)})}(this.formatted,t.map(function(t){return t.formatted}))};var x={};function N(e){for(var n,r=e.numberOfMonths,a=e.viewMode,i=e.month,s=e.year,o=[],u=i+(a===h?r:x[a]),f=i,c=s,d=i;f<u;){var l=S(c,d),m=l.getFullYear(),D=l.getMonth(),v=B(m,D),g=function(e,n,r){var a=[],i=r-1,s=t;for(;a.length!==e;){var o=new F(n,i,s,{isOtherMonthDay:!0});w(r,o.month)||a.unshift(o),s--}return a}((n=v[0]).dayOfWeek,n.year,n.month),M=P(v[v.length-1]);o.push({dates:g.concat(v,M),month:D,year:m}),c=m,d=D+1,f++}return o}function B(e,n){for(var r=[],a=1;a<=t;a++)r.push(new F(e,n,a));return r.filter(function(t){return w(n,t.month)})}function P(t){return function(t,e,n){for(var r=[],a=n+1,i=1;i<=t;i++){var s=new F(e,a,i,{isOtherMonthDay:!0});r.push(s)}return r}(e-t.dayOfWeek,t.year,t.month)}function k(t){var e=t.currentYear,r=t.currentMonth,a=t.minDate,i=t.maxDate;return 1===t.step?function(t,e,r){var a=t.split("-"),i=a[0],s=a[1],o=a[2],u=new Date(i,s-n,o),h=u.getFullYear(),f=u.getMonth(),c=r+1;return O(h,e)&&y(f,c)}(i,e,r):function(t,e,r){var a=t.split("-"),i=a[0],s=a[1],o=a[2],u=new Date(i,s-n,o),h=u.getFullYear(),f=u.getMonth(),c=r-1;return O(h,e)&&p(f,c)}(a,e,r)}x[o]=1,x[u]=2;var A={};A[o]=function(){var t=new Date,e=t.getFullYear(),n=t.getMonth();return[{year:e,month:n}]},A[u]=function(){var t=new Date,e=t.getFullYear(),n=t.getMonth(),r=S(t.getFullYear(),t.getMonth()+1),a=r.getFullYear(),i=r.getMonth();return[{year:e,month:n},{year:a,month:i}]},A[h]=function(t){for(var e=new Date,n=[],r=e.getMonth()+t,a=e.getMonth();a<r;a++){var i=S(e.getFullYear(),a);n.push({year:i.getFullYear(),month:i.getMonth()})}return n};var L={};L[o]={prevPage:function(){},nextPage:function(){}},L[u]={prevPage:function(){},nextPage:function(){}};var T={name:"RenderlessCalendar",props:{viewMode:{type:String,validator:function(t){return-1!==[o,u,h].indexOf(t)},default:o},customNumberOfMonths:{type:Number,default:0},mode:{type:String,validator:function(t){return-1!==[i,s].indexOf(t)},default:i},locale:{type:Object,required:!0},minDate:{type:String,default:""},maxDate:{type:String,default:""},preventOutOfRange:{default:!0,type:Boolean},captureThirdDate:{type:Boolean,default:!1},dateSelectStrategy:{type:Function,default:null},defaultSelectedDates:{type:Array,default:function(){return[]}},captureHover:{type:Boolean,default:!0},disabledDates:{type:Array,default:function(){return[]}},markedDates:{type:Array,default:function(){return[]}}},data:function(){return{today:new Date,calendar:null,selectedDates:[],currentMonth:null,currentYear:null,currentHoveredDate:null,viewState:[]}},created:function(){var t,e;this.selectedDates=this.defaultSelectedDates.map(F.fromString),this.currentMonth=this.today.getMonth(),this.currentYear=this.today.getFullYear(),this.viewState=(t=this.viewMode,e=this.customNumberOfMonths,A[t](e)),this.viewNavigator=function(t){return L[t]}(this.viewMode),this.calendar=Object.freeze(N({numberOfMonths:this.customNumberOfMonths,month:this.currentMonth,viewMode:this.viewMode,year:this.currentYear}))},computed:{weekDayNames:function(){return Object.freeze(this.locale.days)},monthNames:function(){return Object.freeze(this.locale.months.map(function(t,e){return Object.assign(t,{id:e})}))},monthsList:function(){return function(t){for(var e=t.currentMonth,n=t.currentYear,r=t.monthNames,a=t.viewState,i=e,s=[],o=i;o<=i+12;o++){var u=new Date(n,o),h=u.getFullYear(),f=u.getMonth(),c=r[f];s.push({isActive:a.some(d(h,f)),id:h+"-"+f,short:c.short,full:c.full,month:f,year:h})}return s;function d(t,e){return function(n){return n.year===t&&n.month===e}}}({currentMonth:this.currentMonth,currentYear:this.currentYear,monthNames:this.monthNames,viewState:this.viewState})},canGoToPrevMonth:function(){var t=this.viewState[0],e=t.month,n=t.year;return!k({minDate:this.minDate,maxDate:this.maxDate,currentMonth:e,currentYear:n,step:-1})},canGoToNextMonth:function(){var t=this.viewState[this.viewState.length-1],e=t.month,n=t.year;return!k({minDate:this.minDate,maxDate:this.maxDate,currentMonth:e,currentYear:n,step:1})}},methods:{onDateSelect:function(t){b(t.formatted,{disabledDates:this.disabledDates,maxDate:this.maxDate,minDate:this.minDate})||this.setDates(this.dateChangeHangler(this.selectedDates,t))},onDateMouseOver:function(t){this.currentHoveredDate=t},onDateMouseOut:function(){this.currentHoveredDate=null},setDates:function(t){this.selectedDates=t,this.$emit("onDateChange",t)},resetDates:function(t){this.setDates(function(t,e){return Number.isNaN(e)?[]:t.filter(function(t,n){return n!==e})}(this.selectedDates,t))},prevPage:function(){var t=this.viewState,e=this.viewMode,n=this.customNumberOfMonths,r=t[0],a=r.year,i=r.month,s=[];if(!this.shouldPreventMonthChange(a,i,-1)){var h=S(a,i-1),f=N({numberOfMonths:n,year:h.getFullYear(),month:h.getMonth(),viewMode:e});if(e===o)s=[{year:h.getFullYear(),month:h.getMonth()}];else if(e===u){var c=t[0];s=[{year:h.getFullYear(),month:h.getMonth()},c]}this.calendar=f,this.viewState=s}},nextPage:function(){var t=this.viewMode,e=this.viewState,n=this.customNumberOfMonths,r=[],a=t===o?e[0]:e[1],i=a.year,s=a.month;if(!this.shouldPreventMonthChange(i,s,1)){if(t===u){var h=e[0];i=h.year,s=h.month}var f=S(i,s+1),c=N({numberOfMonths:n,year:f.getFullYear(),month:f.getMonth(),viewMode:t});if(t===o)r=[{year:f.getFullYear(),month:f.getMonth()}];else if(t===u){var d=e[1],l=S(i,s+2);r=[d,{year:l.getFullYear(),month:l.getMonth()}]}this.calendar=c,this.viewState=r}},shouldPreventMonthChange:function(t,e,n){return this.preventOutOfRange&&k({currentMonth:e,currentYear:t,minDate:this.minDate,maxDate:this.maxDate,step:n})},setMonth:function(t){var e=t.month,n=t.year,r=this.viewMode,a=this.customNumberOfMonths,i=[];if(r===o&&(i=[{month:e,year:n}]),r===u){var s=S(n,e+1);i=[{month:e,year:n},{year:s.getFullYear(),month:s.getMonth()}]}this.calendar=N({numberOfMonths:a,viewMode:r,month:e,year:n}),this.viewState=i},isBetween:function(t){return this.captureHover&&t.isBetween({currentHoveredDate:this.currentHoveredDate,captureThirdDate:this.captureThirdDate,selectedDates:this.selectedDates})},isSelected:function(t){return t.isSelected(this.selectedDates)},isDisabled:function(t){return b(t.formatted,{disabledDates:this.disabledDates,maxDate:this.maxDate,minDate:this.minDate})},isOneDayAfter:function(t){return this.selectedDates.map(function(t){return t.formatted}).some(function(e){return g(e,t.formatted)})},isOneDayBefore:function(t){return this.selectedDates.map(function(t){return t.formatted}).some(function(e){return v(e,t.formatted)})},isOneDayBeforeFirst:function(t){var e=this.selectedDates[0];return e&&v(e.formatted,t.formatted)},isOneDayAfterFirst:function(t){var e=this.selectedDates[0];return e&&g(t.formatted,e.formatted)},isOneDayBeforeLast:function(t){var e=this.selectedDates[1];return e&&v(e.formatted,t.formatted)},isOneDayAfterLast:function(t){var e=this.selectedDates[1];return e&&g(t.formatted,e.formatted)},isFirst:function(t){var e=this.selectedDates[0];return e&&O(t.formatted,e.formatted)},isLast:function(t){var e=this.selectedDates[1];return e&&O(t.formatted,e.formatted)},isMarked:function(t){return function(t,e){return-1!==e.indexOf(t)}(t.formatted,this.markedDates)},getModifiers:function(t){return{isBetween:this.isBetween(t),isSelected:this.isSelected(t),isDisabled:this.isDisabled(t),isOneDayAfter:this.isOneDayAfter(t),isOneDayBefore:this.isOneDayBefore(t),isOneDayBeforeFirst:this.isOneDayBeforeFirst(t),isOneDayAfterFirst:this.isOneDayAfterFirst(t),isOneDayBeforeLast:this.isOneDayBeforeLast(t),isOneDayAfterLast:this.isOneDayAfterLast(t),isFirst:this.isFirst(t),isLast:this.isLast(t),isMarked:this.isMarked(t)}}},watch:{mode:{handler:function(t){this.dateChangeHangler=this.dateSelectStrategy||function(t){switch(t){case i:return c;case s:return l;default:throw new Error("unkown mode: "+t)}}(t)},immediate:!0},defaultSelectedDates:function(t){this.selectedDates=t.map(F.fromString)}},render:function(){return this.$scopedSlots.default({weekDayNames:this.weekDayNames,monthNames:this.monthNames,monthsList:this.monthsList,calendar:this.calendar,selectedDates:this.selectedDates,currentMonth:this.currentMonth,currentYear:this.currentYear,canGoToPrevMonth:this.canGoToPrevMonth,canGoToNextMonth:this.canGoToNextMonth,prevPage:this.prevPage,nextPage:this.nextPage,resetDates:this.resetDates,setMonth:this.setMonth,onDateMouseOut:this.onDateMouseOut,onDateMouseOver:this.onDateMouseOver,onDateSelect:this.onDateSelect,getModifiers:this.getModifiers})}};export{T as RenderlessCalendar};
var t="single",e="range",n="single",r="double",a="custom";function i(t,e){return[e]}function o(t,e){return[t,e].slice(0).sort((function(t,e){return t.ms-e.ms}))}function s(t,e){return 2===t.length?[e]:function(t,e){if(0===t.length)return[e];var n=t[0],r=t[1];return 1===t.length?o(n,e):n.formatted===e.formatted?[n,e]:r.formatted===e.formatted?[r,e]:o(Math.abs(n.ms-e.ms)<Math.abs(r.ms-e.ms)?r:n,e)}(t,e)}function u(t){return new(Function.prototype.bind.apply(Date,[null].concat(t.split("-"))))}function h(t,e){var n=e[0],r=e[1];return m(t,n)&&d(t,r)}function c(t,e){return l(e,t)}function f(t,e){return l(t,e)}function l(t,e){return u(t).valueOf()-u(e).valueOf()==864e5}function d(t,e){return t<e}function m(t,e){return t>e}function D(t,e){return t===e}function v(t,e){return t===e}function g(t,e){return new Date(t,e)}function y(t,e){var n=e.disabledDates;void 0===n&&(n=[]);var r=e.maxDate;void 0===r&&(r="");var a=e.minDate;return void 0===a&&(a=""),a&&d(t,a)||r&&m(t,r)||function(t,e){return-1!==e.indexOf(t)}(t,n)}function M(t){return t<10?"0"+t:t}function p(t,e,n,r){void 0===r&&(r={});var a=r.isOtherMonthDay;void 0===a&&(a=!1);var i=new Date(t,e,n);this.ms=i.valueOf(),this.dayOfWeek=(i.getDay()+6)%7,this.year=i.getFullYear(),this.month=i.getMonth(),this.day=i.getDate(),this.actualMonthNumber=this.month+1,this.formatted=[this.year,this.actualMonthNumber,this.day].map(M).join("-"),this.isWeekend=function(t){var e=t.getDay();return 0===e||6===e}(i),this.isToday=function(t){var e=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(i),this.isOtherMonthDay=a}p.fromString=function(t){var e=t.split("-");return new p(e[0],e[1]-1,e[2])},p.prototype.isBetween=function(t){var e=t.currentHoveredDate,n=t.captureThirdDate,r=t.selectedDates;if(0===r.length)return!1;var a=this.formatted,i=r[0],o=r[1],s=e&&e.formatted,u=i&&i.formatted,c=o&&o.formatted;return!o&&s?h(a,[u,s])||h(a,[s,u]):n&&s?h(a,[u,s])||h(a,[s,c]):h(a,[u,c])},p.prototype.isSelected=function(t){return void 0===t&&(t=[]),function(t,e){return e.some((function(e){return D(e,t)}))}(this.formatted,t.map((function(t){return t.formatted})))};var w={};function O(t){for(var e,n=t.numberOfMonths,r=t.viewMode,i=t.month,o=t.year,s=[],u=i+(r===a?n:w[r]),h=i,c=o,f=i;h<u;){var l=g(c,f),d=l.getFullYear(),m=l.getMonth(),D=S(d,m),y=function(t,e,n){var r=[],a=n-1,i=31;for(;r.length!==t;){var o=new p(e,a,i,{isOtherMonthDay:!0});v(n,o.month)||r.unshift(o),i--}return r}((e=D[0]).dayOfWeek,e.year,e.month),M=Y(D[D.length-1]);s.push({dates:y.concat(D,M),month:m,year:d}),c=d,f=m+1,h++}return s}function S(t,e){for(var n=[],r=1;r<=31;r++)n.push(new p(t,e,r));return n.filter((function(t){return v(e,t.month)}))}function Y(t){return function(t,e,n){for(var r=[],a=n+1,i=1;i<=t;i++){var o=new p(e,a,i,{isOtherMonthDay:!0});r.push(o)}return r}(6-t.dayOfWeek,t.year,t.month)}function F(t){var e=t.currentYear,n=t.currentMonth,r=t.minDate,a=t.maxDate;return 1===t.step?function(t,e,n){var r=t.split("-"),a=r[0],i=r[1],o=r[2],s=new Date(a,i-1,o),u=s.getFullYear(),h=s.getMonth(),c=n+1;return D(u,e)&&d(h,c)}(a,e,n):function(t,e,n){var r=t.split("-"),a=r[0],i=r[1],o=r[2],s=new Date(a,i-1,o),u=s.getFullYear(),h=s.getMonth(),c=n-1;return D(u,e)&&m(h,c)}(r,e,n)}w[n]=1,w[r]=2;var b={};b[n]=function(){var t=new Date,e=t.getFullYear(),n=t.getMonth();return[{year:e,month:n}]},b[r]=function(){var t=new Date,e=t.getFullYear(),n=t.getMonth(),r=g(t.getFullYear(),t.getMonth()+1),a=r.getFullYear(),i=r.getMonth();return[{year:e,month:n},{year:a,month:i}]},b[a]=function(t){for(var e=new Date,n=[],r=e.getMonth()+t,a=e.getMonth();a<r;a++){var i=g(e.getFullYear(),a);n.push({year:i.getFullYear(),month:i.getMonth()})}return n};var x={};x[n]={prevPage:function(){},nextPage:function(){}},x[r]={prevPage:function(){},nextPage:function(){}};var N={};function B(t){return/^[a-z]{2,3}(-[A-Za-z]{2})?$/.test(t)||(t=navigator.language),N.hasOwnProperty(t)||(N[t]=function(t){var e=new Date,n=e.getFullYear(),r=e.getMonth(),a=e.getDay(),i=[].concat(Array(12)).map((function(e,r){var a=new Date(n,r);return{short:a.toLocaleString(t,{month:"short"}),full:a.toLocaleString(t,{month:"long"})}})),o=e.getDate()-a+(0===a?-6:1),s=[].concat(Array(7)).map((function(e,a){var i=new Date(n,r,o+a);return{short:i.toLocaleString(t,{weekday:"short"}),full:i.toLocaleString(t,{weekday:"long"})}}));return{months:i,days:s}}(t)),N[t]}var P={name:"RenderlessCalendar",props:{viewMode:{type:String,validator:function(t){return-1!==[n,r,a].indexOf(t)},default:n},customNumberOfMonths:{type:Number,default:0},mode:{type:String,validator:function(n){return-1!==[t,e].indexOf(n)},default:t},locale:{type:[String,Object],default:""},minDate:{type:String,default:""},maxDate:{type:String,default:""},preventOutOfRange:{default:!0,type:Boolean},captureThirdDate:{type:Boolean,default:!1},dateSelectStrategy:{type:Function,default:null},defaultSelectedDates:{type:Array,default:function(){return[]}},captureHover:{type:Boolean,default:!0},disabledDates:{type:Array,default:function(){return[]}},markedDates:{type:Array,default:function(){return[]}}},data:function(){return{today:new Date,calendar:null,selectedDates:[],currentMonth:null,currentYear:null,currentHoveredDate:null,viewState:[]}},created:function(){var t,e;this.selectedDates=this.defaultSelectedDates.map(p.fromString),this.currentMonth=this.today.getMonth(),this.currentYear=this.today.getFullYear(),this.viewState=(t=this.viewMode,e=this.customNumberOfMonths,b[t](e)),this.viewNavigator=function(t){return x[t]}(this.viewMode),this.calendar=Object.freeze(O({numberOfMonths:this.customNumberOfMonths,month:this.currentMonth,viewMode:this.viewMode,year:this.currentYear}))},computed:{localeStrings:function(){return"string"==typeof this.locale?B(this.locale):this.locale},weekDayNames:function(){return this.localeStrings.days},monthNames:function(){return this.localeStrings.months.map((function(t,e){return{short:t.short,full:t.full,id:e}}))},monthsList:function(){return function(t){for(var e=t.currentMonth,n=t.currentYear,r=t.monthNames,a=t.viewState,i=e,o=[],s=i;s<=i+12;s++){var u=new Date(n,s),h=u.getFullYear(),c=u.getMonth(),f=r[c];o.push({isActive:a.some(l(h,c)),id:h+"-"+c,short:f.short,full:f.full,month:c,year:h})}return o;function l(t,e){return function(n){return n.year===t&&n.month===e}}}({currentMonth:this.currentMonth,currentYear:this.currentYear,monthNames:this.monthNames,viewState:this.viewState})},canGoToPrevMonth:function(){var t=this.viewState[0],e=t.month,n=t.year;return!F({minDate:this.minDate,maxDate:this.maxDate,currentMonth:e,currentYear:n,step:-1})},canGoToNextMonth:function(){var t=this.viewState[this.viewState.length-1],e=t.month,n=t.year;return!F({minDate:this.minDate,maxDate:this.maxDate,currentMonth:e,currentYear:n,step:1})}},methods:{onDateSelect:function(t){y(t.formatted,{disabledDates:this.disabledDates,maxDate:this.maxDate,minDate:this.minDate})||this.setDates(this.dateChangeHangler(this.selectedDates,t))},onDateMouseOver:function(t){this.currentHoveredDate=t},onDateMouseOut:function(){this.currentHoveredDate=null},setDates:function(t){this.selectedDates=t,this.$emit("onDateChange",t)},resetDates:function(t){this.setDates(function(t,e){return Number.isNaN(e)?[]:t.filter((function(t,n){return n!==e}))}(this.selectedDates,t))},prevPage:function(){var t=this.viewState,e=this.viewMode,a=this.customNumberOfMonths,i=t[0],o=i.year,s=i.month,u=[];if(!this.shouldPreventMonthChange(o,s,-1)){var h=g(o,s-1),c=O({numberOfMonths:a,year:h.getFullYear(),month:h.getMonth(),viewMode:e});if(e===n)u=[{year:h.getFullYear(),month:h.getMonth()}];else if(e===r){var f=t[0];u=[{year:h.getFullYear(),month:h.getMonth()},f]}this.calendar=c,this.viewState=u}},nextPage:function(){var t=this.viewMode,e=this.viewState,a=this.customNumberOfMonths,i=[],o=t===n?e[0]:e[1],s=o.year,u=o.month;if(!this.shouldPreventMonthChange(s,u,1)){if(t===r){var h=e[0];s=h.year,u=h.month}var c=g(s,u+1),f=O({numberOfMonths:a,year:c.getFullYear(),month:c.getMonth(),viewMode:t});if(t===n)i=[{year:c.getFullYear(),month:c.getMonth()}];else if(t===r){var l=e[1],d=g(s,u+2);i=[l,{year:d.getFullYear(),month:d.getMonth()}]}this.calendar=f,this.viewState=i}},shouldPreventMonthChange:function(t,e,n){return this.preventOutOfRange&&F({currentMonth:e,currentYear:t,minDate:this.minDate,maxDate:this.maxDate,step:n})},setMonth:function(t){var e=t.month,a=t.year,i=this.viewMode,o=this.customNumberOfMonths,s=[];if(i===n&&(s=[{month:e,year:a}]),i===r){var u=g(a,e+1);s=[{month:e,year:a},{year:u.getFullYear(),month:u.getMonth()}]}this.calendar=O({numberOfMonths:o,viewMode:i,month:e,year:a}),this.viewState=s},isBetween:function(t){return this.captureHover&&t.isBetween({currentHoveredDate:this.currentHoveredDate,captureThirdDate:this.captureThirdDate,selectedDates:this.selectedDates})},isSelected:function(t){return t.isSelected(this.selectedDates)},isDisabled:function(t){return y(t.formatted,{disabledDates:this.disabledDates,maxDate:this.maxDate,minDate:this.minDate})},isOneDayAfter:function(t){return this.selectedDates.map((function(t){return t.formatted})).some((function(e){return f(e,t.formatted)}))},isOneDayBefore:function(t){return this.selectedDates.map((function(t){return t.formatted})).some((function(e){return c(e,t.formatted)}))},isOneDayBeforeFirst:function(t){var e=this.selectedDates[0];return e&&c(e.formatted,t.formatted)},isOneDayAfterFirst:function(t){var e=this.selectedDates[0];return e&&f(t.formatted,e.formatted)},isOneDayBeforeLast:function(t){var e=this.selectedDates[1];return e&&c(e.formatted,t.formatted)},isOneDayAfterLast:function(t){var e=this.selectedDates[1];return e&&f(t.formatted,e.formatted)},isFirst:function(t){var e=this.selectedDates[0];return e&&D(t.formatted,e.formatted)},isLast:function(t){var e=this.selectedDates[1];return e&&D(t.formatted,e.formatted)},isMarked:function(t){return function(t,e){return-1!==e.indexOf(t)}(t.formatted,this.markedDates)},getModifiers:function(t){return{isBetween:this.isBetween(t),isSelected:this.isSelected(t),isDisabled:this.isDisabled(t),isOneDayAfter:this.isOneDayAfter(t),isOneDayBefore:this.isOneDayBefore(t),isOneDayBeforeFirst:this.isOneDayBeforeFirst(t),isOneDayAfterFirst:this.isOneDayAfterFirst(t),isOneDayBeforeLast:this.isOneDayBeforeLast(t),isOneDayAfterLast:this.isOneDayAfterLast(t),isFirst:this.isFirst(t),isLast:this.isLast(t),isMarked:this.isMarked(t)}}},watch:{mode:{handler:function(n){this.dateChangeHangler=this.dateSelectStrategy||function(n){switch(n){case t:return i;case e:return s;default:throw new Error("unkown mode: "+n)}}(n)},immediate:!0},defaultSelectedDates:function(t){this.selectedDates=t.map(p.fromString)}},render:function(){return this.$scopedSlots.default({weekDayNames:this.weekDayNames,monthNames:this.monthNames,monthsList:this.monthsList,calendar:this.calendar,selectedDates:this.selectedDates,currentMonth:this.currentMonth,currentYear:this.currentYear,canGoToPrevMonth:this.canGoToPrevMonth,canGoToNextMonth:this.canGoToNextMonth,prevPage:this.prevPage,nextPage:this.nextPage,resetDates:this.resetDates,setMonth:this.setMonth,onDateMouseOut:this.onDateMouseOut,onDateMouseOver:this.onDateMouseOver,onDateSelect:this.onDateSelect,getModifiers:this.getModifiers})}};export{P as RenderlessCalendar};

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

export default{months:[{short:"Jan",full:"January"},{short:"Feb",full:"February"},{short:"Mar",full:"March"},{short:"Apr",full:"April"},{short:"May",full:"May"},{short:"Jun",full:"June"},{short:"Jul",full:"July"},{short:"Aug",full:"August"},{short:"Sep",full:"September"},{short:"Oct",full:"October"},{short:"Nov",full:"November"},{short:"Dec",full:"December"}],days:[{short:"Mon",full:"Monday"},{short:"Tue",full:"Tuesday"},{short:"Wed",full:"Wednesday"},{short:"Thu",full:"Thursday"},{short:"Fri",full:"Friday"},{short:"Sat",full:"Saturday"},{short:"Sun",full:"Sunday"}]};
var l={months:[{short:"Jan",full:"January"},{short:"Feb",full:"February"},{short:"Mar",full:"March"},{short:"Apr",full:"April"},{short:"May",full:"May"},{short:"Jun",full:"June"},{short:"Jul",full:"July"},{short:"Aug",full:"August"},{short:"Sep",full:"September"},{short:"Oct",full:"October"},{short:"Nov",full:"November"},{short:"Dec",full:"December"}],days:[{short:"Mon",full:"Monday"},{short:"Tue",full:"Tuesday"},{short:"Wed",full:"Wednesday"},{short:"Thu",full:"Thursday"},{short:"Fri",full:"Friday"},{short:"Sat",full:"Saturday"},{short:"Sun",full:"Sunday"}]};export default l;

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

export default{months:[{short:"Янв",full:"Январь"},{short:"Фев",full:"Февраль"},{short:"Мар",full:"Март"},{short:"Апр",full:"Апрель"},{short:"Май",full:"Май"},{short:"Июн",full:"Июнь"},{short:"Июл",full:"Июль"},{short:"Авг",full:"Август"},{short:"Сен",full:"Сентябрь"},{short:"Окт",full:"Октябрь"},{short:"Ноя",full:"Ноябрь"},{short:"Дек",full:"Декабрь"}],days:[{short:"Пн",full:"Понедельник"},{short:"Вт",full:"Вторник"},{short:"Ср",full:"Среда"},{short:"Чт",full:"Четверг"},{short:"Пт",full:"Пятница"},{short:"Сб",full:"Суббота"},{short:"Вс",full:"Воскресенье"}]};
var l={months:[{short:"Янв",full:"Январь"},{short:"Фев",full:"Февраль"},{short:"Мар",full:"Март"},{short:"Апр",full:"Апрель"},{short:"Май",full:"Май"},{short:"Июн",full:"Июнь"},{short:"Июл",full:"Июль"},{short:"Авг",full:"Август"},{short:"Сен",full:"Сентябрь"},{short:"Окт",full:"Октябрь"},{short:"Ноя",full:"Ноябрь"},{short:"Дек",full:"Декабрь"}],days:[{short:"Пн",full:"Понедельник"},{short:"Вт",full:"Вторник"},{short:"Ср",full:"Среда"},{short:"Чт",full:"Четверг"},{short:"Пт",full:"Пятница"},{short:"Сб",full:"Суббота"},{short:"Вс",full:"Воскресенье"}]};export default l;

@@ -23,2 +23,9 @@ import {

import { viewModeInitializer, getViewNavigator } from './utils/view-mode.service';
import { getCalendarStringsForLocale } from './utils/locale-strings';
/**
* @typedef {{
* months:{short: string, full: string}[],
* days:{short: string, full: string}[]
* }} LocaleStrings
*/

@@ -48,4 +55,4 @@ export default {

locale: {
type: Object,
required: true
type: [String, Object],
default: ''
},

@@ -119,7 +126,18 @@ minDate: {

computed: {
/**
* @return {LocaleStrings}
*/
localeStrings() {
return typeof this.locale === 'string'
? getCalendarStringsForLocale(this.locale)
: this.locale;
},
weekDayNames() {
return Object.freeze(this.locale.days);
// @ts-ignore
return this.localeStrings.days;
},
monthNames() {
return Object.freeze(this.locale.months.map((month, idx) => Object.assign(month, { id: idx })));
// @ts-ignore
return this.localeStrings.months
.map((month, id) => ({ short: month.short, full: month.full, id }));
},

@@ -126,0 +144,0 @@ monthsList() {

{
"name": "vue-renderless-calendar",
"version": "2.0.0",
"version": "2.1.0-beta.0",
"main": "./dist/index.js",

@@ -34,4 +34,2 @@ "module": "./dist/index.js",

"devDependencies": {
"vue": "^2.6.10",
"vue-hot-reload-api": "^2.3.3",
"@babel/core": "^7.4.5",

@@ -50,9 +48,11 @@ "@babel/preset-env": "^7.4.5",

"esm": "^3.2.25",
"node-sass": "^4.9.0",
"parcel-bundler": "^1.12.3",
"node-sass": "^4.13.1",
"parcel-bundler": "^1.12.4",
"rollup": "^1.15.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-terser": "^5.0.0",
"rollup-plugin-terser": "^5.2.0",
"sass-loader": "^7.1.0",
"vue": "^2.6.10",
"vue-hot-reload-api": "^2.3.3",
"vue-template-compiler": "^2.6.10"

@@ -59,0 +59,0 @@ },

@@ -12,14 +12,2 @@ # vue-renderless-calendar 📆

## Locale
```javascript
import enLocale from 'vue-renderless-calendar/dist/locale/en';
```
> Available locales
- English `locale/en`
- Russian `locale/ru`
## RenderlessCalendar

@@ -31,16 +19,16 @@

| Prop | Required | Type | Default | Description
|----------------------|-------------|-----------------------|---------| ---------------------------------
| viewMode | false | String | | 'single', 'double', 'infinite'
| mode | false | String | | 'single', 'range'
| locale | true | Object | | Locale object containing `months`, `days` properties
| minDate | false | String | '' | Minimal valid date (`YYYY-MM-DDD`)
| maxDate | false | String | '' | Maximal valid date (`YYYY-MM-DDD`)
| preventOutOfRange | false | Boolean | true | Prevent user go out of valid dates range
| dateSelectStrategy | false | Function | null | If you want custom behaviour for handling date select, you can implement this function
| defaultSelectedDates | false | Array | [] | Array of date strings with `YYYY-MM-DDD` format
| captureHover | false | Boolean | true | `captureHover` prop is used for computing dates which are between selected date and current hovered date
| captureThirdDate | false | Boolean | false | `captureThirdDate` prop is used for capturing dates between in case when 2 dates already selected and you have third element hovered
| disabledDates | false | Array<String> | [] | Array of `YYYY-MM-DDD` strings containing dates that can't be selected |
| markedDates | false | Array<String> | [] | Array of `YYYY-MM-DDD` strings with special meaning, that later will be accessed via `isMarked` modifier |
| Prop | Required | Type | Default | Description
|----------------------|-------------|-----------------------|---------------------|----------------------------------
| viewMode | false | String | | 'single', 'double', 'infinite'
| mode | false | String | | 'single', 'range'
| locale | false | Object or String | navigator.language | Locale string (e.g. 'ru'), it will automatically generate locale object using `Date.prototype.toLocaleString`, otherwise you can provide this object manually
| minDate | false | String | '' | Minimal valid date (`YYYY-MM-DDD`)
| maxDate | false | String | '' | Maximal valid date (`YYYY-MM-DDD`)
| preventOutOfRange | false | Boolean | true | Prevent user go out of valid dates range
| dateSelectStrategy | false | Function | null | If you want custom behaviour for handling date select, you can implement this function
| defaultSelectedDates | false | Array | [] | Array of date strings with `YYYY-MM-DDD` format
| captureHover | false | Boolean | true | `captureHover` prop is used for computing dates which are between selected date and current hovered date
| captureThirdDate | false | Boolean | false | `captureThirdDate` prop is used for capturing dates between in case when 2 dates already selected and you have third element hovered
| disabledDates | false | Array<String> | [] | Array of `YYYY-MM-DDD` strings containing dates that can't be selected |
| markedDates | false | Array<String> | [] | Array of `YYYY-MM-DDD` strings with special meaning, that later will be accessed via `isMarked` modifier |

@@ -47,0 +35,0 @@