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
1.2.2

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="infinite",c=864e5;function f(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)&&M(t,r)}function v(t,e){return y(e,t)}function g(t,e){return y(t,e)}function y(t,e){return m(t).valueOf()-m(e).valueOf()===c}function M(t,e){return t<e}function p(t,e){return t>e}function w(t,e){return t===e}function O(t,e){return t===e}function S(t,e){return new Date(t,e)}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 w(e,t)})}(this.formatted,t.map(function(t){return t.formatted}))};var x={};function N(e,n,r){for(var a,i=[],s=n+x[r],o=n,u=e,h=n;o<s;){var c=S(u,h),f=c.getFullYear(),d=c.getMonth(),l=b(f,d),m=function(e,n,r){var a=[],i=r-1,s=t;for(;a.length!==e;){var o=new F(n,i,s,{isOtherMonthDay:!0});O(r,o.month)||a.unshift(o),s--}return a}((a=l[0]).dayOfWeek,a.year,a.month),D=B(l[l.length-1]);i.push({dates:m.concat(l,D),month:d,year:f}),u=f,h=d+1,o++}return i}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 O(n,t.month)})}function B(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 P(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(),c=u.getMonth(),f=r+1;return w(h,e)&&M(c,f)}(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(),c=u.getMonth(),f=r-1;return w(h,e)&&p(c,f)}(a,e,r)}x[o]=1,x[u]=2,x[h]=12;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(){for(var t=new Date,e=[],n=t.getMonth()+12,r=t.getMonth();r<n;r++){var a=S(t.getFullYear(),r);e.push({year:a.getFullYear(),month:a.getMonth()})}return e};var k={};k[o]={prevPage:function(){},nextPage:function(){}},k[u]={prevPage:function(){},nextPage:function(){}};var L={name:"RenderlessCalendar",props:{viewMode:{type:String,validator:function(t){return-1!==[o,u,h].indexOf(t)},default:o},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}},data:function(){return{today:new Date,calendar:null,selectedDates:[],currentMonth:null,currentYear:null,currentHoveredDate:null,viewState:[]}},created:function(){var t;this.selectedDates=this.defaultSelectedDates.map(F.fromString),this.currentMonth=this.today.getMonth(),this.currentYear=this.today.getFullYear(),this.viewState=(t=this.viewMode,A[t]()),this.viewNavigator=function(t){return k[t]}(this.viewMode),this.calendar=Object.freeze(N(this.currentYear,this.currentMonth,this.viewMode))},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(),c=u.getMonth(),f=r[c];s.push({isActive:a.some(d(h,c)),id:h+"-"+c,short:f.short,full:f.full,month:c,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!P({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!P({minDate:this.minDate,maxDate:this.maxDate,currentMonth:e,currentYear:n,step:1})}},methods:{onDateSelect:function(t){this.selectedDates=this.dateChangeHangler(this.selectedDates,t),this.$emit("onDateChange",this.selectedDates)},onDateMouseOver:function(t){this.currentHoveredDate=t},onDateMouseOut:function(){this.currentHoveredDate=null},resetDates:function(t){this.selectedDates=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=t[0],r=n.year,a=n.month,i=[];if(!this.shouldPreventMonthChange(r,a,-1)){var s=S(r,a-1),h=N(s.getFullYear(),s.getMonth(),e);if(e===o&&(i=[{year:s.getFullYear(),month:s.getMonth()}]),e===u){var c=t[0];i=[{year:s.getFullYear(),month:s.getMonth()},c]}this.calendar=h,this.viewState=i}},nextPage:function(){var t=this.viewMode,e=this.viewState,n=[],r=t===o?e[0]:e[1],a=r.year,i=r.month;if(!this.shouldPreventMonthChange(a,i,1)){if(t===u){var s=e[0];a=s.year,i=s.month}var h=S(a,i+1),c=N(h.getFullYear(),h.getMonth(),t);if(t===o)n=[{year:h.getFullYear(),month:h.getMonth()}];else if(t===u){var f=e[1],d=S(a,i+2);n=[f,{year:d.getFullYear(),month:d.getMonth()}]}this.calendar=c,this.viewState=n}},isBetween:function(t){return this.captureHover&&t.isBetween({currentHoveredDate:this.currentHoveredDate,captureThirdDate:this.captureThirdDate,selectedDates:this.selectedDates})},shouldPreventMonthChange:function(t,e,n){return this.preventOutOfRange&&P({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=[];if(r===o&&(a=[{month:e,year:n}]),r===u){var i=S(n,e+1);a=[{month:e,year:n},{year:i.getFullYear(),month:i.getMonth()}]}this.calendar=N(n,e,r),this.viewState=a}},watch:{mode:{handler:function(t){this.dateChangeHangler=this.dateSelectStrategy||function(t){switch(t){case i:return f;case s:return l;default:throw new Error("unkown mode: "+t)}}(t)},immediate:!0}},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,isBetween:this.isBetween,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})}},T={name:"RenderlessDate",props:{selectedDates:{required:!0,type:Array},date:{required:!0,validator:function(t){return t instanceof F}},minDate:{default:"",type:String},maxDate:{default:"",type:String},disabledDates:{type:Array,default:function(){return[]}},markedDates:{type:Array,default:function(){return[]}}},computed:{formatted:function(){return this.date.formatted},isSelected:function(){return this.date.isSelected(this.selectedDates)},isDisabled:function(){return this.minDate&&M(this.formatted,this.minDate)||this.maxDate&&p(this.formatted,this.maxDate)||(t=this.formatted,-1!==this.disabledDates.indexOf(t));var t},isOneDayAfter:function(){var t=this;return this.selectedDates.map(function(t){return t.formatted}).some(function(e){return g(e,t.formatted)})},isOneDayBefore:function(){var t=this;return this.selectedDates.map(function(t){return t.formatted}).some(function(e){return v(e,t.formatted)})},isOneDayBeforeFirst:function(){var t=this.selectedDates[0];return t&&v(t.formatted,this.formatted)},isOneDayAfterFirst:function(){var t=this.selectedDates[0];return t&&g(this.formatted,t.formatted)},isOneDayBeforeLast:function(){var t=this.selectedDates[1];return t&&v(t.formatted,this.formatted)},isOneDayAfterLast:function(){var t=this.selectedDates[1];return t&&g(this.formatted,t.formatted)},isFirst:function(){var t=this.selectedDates[0];return t&&w(this.formatted,t.formatted)},isLast:function(){var t=this.selectedDates[1];return t&&w(this.formatted,t.formatted)},isMarked:function(){return t=this.formatted,-1!==this.markedDates.indexOf(t);var t}},render:function(){return this.$scopedSlots.default({isMarked:this.isMarked,isFirst:this.isFirst,isLast:this.isLast,isSelected:this.isSelected,isDisabled:this.isDisabled,isOneDayAfter:this.isOneDayAfter,isOneDayBefore:this.isOneDayBefore,isOneDayBeforeFirst:this.isOneDayBeforeFirst,isOneDayAfterFirst:this.isOneDayAfterFirst,isOneDayBeforeLast:this.isOneDayBeforeLast,isOneDayAfterLast:this.isOneDayAfterLast})}};export{L as RenderlessCalendar,T as RenderlessDate};
var t=31,e=6,n=1,r=0,a=6,i="single",s="range",o="single",u="double",h="infinite",c=864e5;function f(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)&&M(t,r)}function v(t,e){return y(e,t)}function g(t,e){return y(t,e)}function y(t,e){return m(t).valueOf()-m(e).valueOf()===c}function M(t,e){return t<e}function p(t,e){return t>e}function w(t,e){return t===e}function O(t,e){return t===e}function S(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&&M(t,a)||r&&p(t,r)||function(t,e){return-1!==e.indexOf(t)}(t,n)}function F(t){return t<10?"0"+t:t}function x(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(F).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}x.fromString=function(t){var e=t.split("-"),r=e[0],a=e[1],i=e[2];return new x(r,a-n,i)},x.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])},x.prototype.isSelected=function(t){return void 0===t&&(t=[]),function(t,e){return e.some(function(e){return w(e,t)})}(this.formatted,t.map(function(t){return t.formatted}))};var b={};function N(e,n,r){for(var a,i=[],s=n+b[r],o=n,u=e,h=n;o<s;){var c=S(u,h),f=c.getFullYear(),d=c.getMonth(),l=B(f,d),m=function(e,n,r){var a=[],i=r-1,s=t;for(;a.length!==e;){var o=new x(n,i,s,{isOtherMonthDay:!0});O(r,o.month)||a.unshift(o),s--}return a}((a=l[0]).dayOfWeek,a.year,a.month),D=P(l[l.length-1]);i.push({dates:m.concat(l,D),month:d,year:f}),u=f,h=d+1,o++}return i}function B(e,n){for(var r=[],a=1;a<=t;a++)r.push(new x(e,n,a));return r.filter(function(t){return O(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 x(e,a,i,{isOtherMonthDay:!0});r.push(s)}return r}(e-t.dayOfWeek,t.year,t.month)}function A(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(),c=u.getMonth(),f=r+1;return w(h,e)&&M(c,f)}(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(),c=u.getMonth(),f=r-1;return w(h,e)&&p(c,f)}(a,e,r)}b[o]=1,b[u]=2,b[h]=12;var k={};k[o]=function(){var t=new Date,e=t.getFullYear(),n=t.getMonth();return[{year:e,month:n}]},k[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}]},k[h]=function(){for(var t=new Date,e=[],n=t.getMonth()+12,r=t.getMonth();r<n;r++){var a=S(t.getFullYear(),r);e.push({year:a.getFullYear(),month:a.getMonth()})}return e};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},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[]}}},data:function(){return{today:new Date,calendar:null,selectedDates:[],currentMonth:null,currentYear:null,currentHoveredDate:null,viewState:[]}},created:function(){var t;this.selectedDates=this.defaultSelectedDates.map(x.fromString),this.currentMonth=this.today.getMonth(),this.currentYear=this.today.getFullYear(),this.viewState=(t=this.viewMode,k[t]()),this.viewNavigator=function(t){return L[t]}(this.viewMode),this.calendar=Object.freeze(N(this.currentYear,this.currentMonth,this.viewMode))},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(),c=u.getMonth(),f=r[c];s.push({isActive:a.some(d(h,c)),id:h+"-"+c,short:f.short,full:f.full,month:c,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!A({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!A({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.selectedDates=this.dateChangeHangler(this.selectedDates,t),this.$emit("onDateChange",this.selectedDates))},onDateMouseOver:function(t){this.currentHoveredDate=t},onDateMouseOut:function(){this.currentHoveredDate=null},resetDates:function(t){this.selectedDates=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=t[0],r=n.year,a=n.month,i=[];if(!this.shouldPreventMonthChange(r,a,-1)){var s=S(r,a-1),h=N(s.getFullYear(),s.getMonth(),e);if(e===o&&(i=[{year:s.getFullYear(),month:s.getMonth()}]),e===u){var c=t[0];i=[{year:s.getFullYear(),month:s.getMonth()},c]}this.calendar=h,this.viewState=i}},nextPage:function(){var t=this.viewMode,e=this.viewState,n=[],r=t===o?e[0]:e[1],a=r.year,i=r.month;if(!this.shouldPreventMonthChange(a,i,1)){if(t===u){var s=e[0];a=s.year,i=s.month}var h=S(a,i+1),c=N(h.getFullYear(),h.getMonth(),t);if(t===o)n=[{year:h.getFullYear(),month:h.getMonth()}];else if(t===u){var f=e[1],d=S(a,i+2);n=[f,{year:d.getFullYear(),month:d.getMonth()}]}this.calendar=c,this.viewState=n}},isBetween:function(t){return this.captureHover&&t.isBetween({currentHoveredDate:this.currentHoveredDate,captureThirdDate:this.captureThirdDate,selectedDates:this.selectedDates})},shouldPreventMonthChange:function(t,e,n){return this.preventOutOfRange&&A({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=[];if(r===o&&(a=[{month:e,year:n}]),r===u){var i=S(n,e+1);a=[{month:e,year:n},{year:i.getFullYear(),month:i.getMonth()}]}this.calendar=N(n,e,r),this.viewState=a}},watch:{mode:{handler:function(t){this.dateChangeHangler=this.dateSelectStrategy||function(t){switch(t){case i:return f;case s:return l;default:throw new Error("unkown mode: "+t)}}(t)},immediate:!0}},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,isBetween:this.isBetween,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})}},H={name:"RenderlessDate",props:{selectedDates:{required:!0,type:Array},date:{required:!0,validator:function(t){return t instanceof x}},minDate:{default:"",type:String},maxDate:{default:"",type:String},disabledDates:{type:Array,default:function(){return[]}},markedDates:{type:Array,default:function(){return[]}}},computed:{formatted:function(){return this.date.formatted},isSelected:function(){return this.date.isSelected(this.selectedDates)},isDisabled:function(){return Y(this.formatted,{disabledDates:this.disabledDates,maxDate:this.maxDate,minDate:this.minDate})},isOneDayAfter:function(){var t=this;return this.selectedDates.map(function(t){return t.formatted}).some(function(e){return g(e,t.formatted)})},isOneDayBefore:function(){var t=this;return this.selectedDates.map(function(t){return t.formatted}).some(function(e){return v(e,t.formatted)})},isOneDayBeforeFirst:function(){var t=this.selectedDates[0];return t&&v(t.formatted,this.formatted)},isOneDayAfterFirst:function(){var t=this.selectedDates[0];return t&&g(this.formatted,t.formatted)},isOneDayBeforeLast:function(){var t=this.selectedDates[1];return t&&v(t.formatted,this.formatted)},isOneDayAfterLast:function(){var t=this.selectedDates[1];return t&&g(this.formatted,t.formatted)},isFirst:function(){var t=this.selectedDates[0];return t&&w(this.formatted,t.formatted)},isLast:function(){var t=this.selectedDates[1];return t&&w(this.formatted,t.formatted)},isMarked:function(){return t=this.formatted,-1!==this.markedDates.indexOf(t);var t}},render:function(){return this.$scopedSlots.default({isMarked:this.isMarked,isFirst:this.isFirst,isLast:this.isLast,isSelected:this.isSelected,isDisabled:this.isDisabled,isOneDayAfter:this.isOneDayAfter,isOneDayBefore:this.isOneDayBefore,isOneDayBeforeFirst:this.isOneDayBeforeFirst,isOneDayAfterFirst:this.isOneDayAfterFirst,isOneDayBeforeLast:this.isOneDayBeforeLast,isOneDayAfterLast:this.isOneDayAfterLast})}};export{T as RenderlessCalendar,H as RenderlessDate};

@@ -15,3 +15,3 @@ import {

import CalendarDate from './classes/CalendarDate';
import { getMonthDateSafely } from './utils/renderless-date.service';
import { getMonthDateSafely, isRestricted } from './utils/renderless-date.service';
import { viewModeInitializer, getViewNavigator } from './utils/view-mode.service';

@@ -68,2 +68,6 @@

default: true
},
disabledDates: {
type: Array,
default: () => []
}

@@ -137,2 +141,10 @@ },

onDateSelect(date) {
if (isRestricted(date.formatted, {
disabledDates: this.disabledDates,
maxDate: this.maxDate,
minDate: this.minDate
})) {
return;
}
this.selectedDates = this.dateChangeHangler(this.selectedDates, date);

@@ -139,0 +151,0 @@ this.$emit('onDateChange', this.selectedDates);

import CalendarDate from './classes/CalendarDate';
import {
isDisabled,
isEqual,
isGreaterThan,
isLessThan, isMarked,
isMarked,
isNextDate,
isPrevDate
isPrevDate,
isRestricted
} from './utils/renderless-date.service';

@@ -49,5 +48,7 @@

isDisabled() {
return (this.minDate && isLessThan(this.formatted, this.minDate))
|| (this.maxDate && isGreaterThan(this.formatted, this.maxDate))
|| (isDisabled(this.formatted, this.disabledDates));
return isRestricted(this.formatted, {
disabledDates: this.disabledDates,
maxDate: this.maxDate,
minDate: this.minDate
});
},

@@ -54,0 +55,0 @@ isOneDayAfter() {

@@ -75,1 +75,11 @@ import { MILLISECONDS_IN_DAY, SATURDAY, SUNDAY } from './constants';

}
export function isRestricted(date, {
disabledDates = [],
maxDate = '',
minDate = ''
}) {
return (minDate && isLessThan(date, minDate))
|| (maxDate && isGreaterThan(date, maxDate))
|| (isDisabled(date, disabledDates));
}

@@ -106,1 +106,36 @@ import test from 'ava';

});
test('isRestricted without full parameters', t => {
const minDate = '2019-06-01';
const maxDate = '2019-06-31';
const disabledDates = ['2019-06-20'];
const test1 = renderlessDateService.isRestricted('2019-06-01', { disabledDates, minDate, maxDate });
const test2 = renderlessDateService.isRestricted('2019-06-20', { disabledDates, minDate, maxDate });
const test3 = renderlessDateService.isRestricted('2019-05-20', { disabledDates, minDate, maxDate });
const test4 = renderlessDateService.isRestricted('2019-07-01', { disabledDates, minDate, maxDate });
t.is(test1, false);
t.is(test2, true);
t.is(test3, true);
t.is(test4, true);
});
test('isRestricted without min/max Date param', t => {
const minDate = '2019-06-01';
const maxDate = '2019-06-31';
const disabledDates = ['2019-06-20'];
const emptyDisabledDates = [];
const test1 = renderlessDateService.isRestricted('2019-06-01', { disabledDates, maxDate });
const test2 = renderlessDateService.isRestricted('2019-06-20', { disabledDates, maxDate });
const test3 = renderlessDateService.isRestricted('2019-05-20', { disabledDates, maxDate });
const test4 = renderlessDateService.isRestricted('2019-07-01', { disabledDates, minDate });
const test5 = renderlessDateService.isRestricted('2019-06-20', { disabledDates: emptyDisabledDates, maxDate });
t.is(test1, false);
t.is(test2, true);
t.is(test3, false);
t.is(test4, false);
t.is(test5, false);
});
{
"name": "vue-renderless-calendar",
"version": "1.2.1",
"version": "1.2.2",
"module": "./dist/index.js",

@@ -5,0 +5,0 @@ "author": "Seitmagambet Olzhas <seit7magambet@gmail.com>",