UNPKG

vue-easy-range-date-picker

Version:
2 lines 20.1 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("vueRangeDatePicker",[],e):"object"==typeof exports?exports.vueRangeDatePicker=e():t.vueRangeDatePicker=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(a[r])return a[r].exports;var n=a[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var a={};return e.m=t,e.c=a,e.d=function(t,a,r){e.o(t,a)||Object.defineProperty(t,a,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(a,"a",a),a},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=6)}([function(t,e){function a(t,e){var a=t[1]||"",n=t[3];if(!n)return a;if(e&&"function"==typeof btoa){var i=r(n);return[a].concat(n.sources.map(function(t){return"/*# sourceURL="+n.sourceRoot+t+" */"})).concat([i]).join("\n")}return[a].join("\n")}function r(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var r=a(e,t);return e[2]?"@media "+e[2]+"{"+r+"}":r}).join("")},e.i=function(t,a){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},n=0;n<this.length;n++){var i=this[n][0];"number"==typeof i&&(r[i]=!0)}for(n=0;n<t.length;n++){var o=t[n];"number"==typeof o[0]&&r[o[0]]||(a&&!o[2]?o[2]=a:a&&(o[2]="("+o[2]+") and ("+a+")"),e.push(o))}},e}},function(t,e,a){function r(t){for(var e=0;e<t.length;e++){var a=t[e],r=d[a.id];if(r){r.refs++;for(var n=0;n<r.parts.length;n++)r.parts[n](a.parts[n]);for(;n<a.parts.length;n++)r.parts.push(i(a.parts[n]));r.parts.length>a.parts.length&&(r.parts.length=a.parts.length)}else{for(var o=[],n=0;n<a.parts.length;n++)o.push(i(a.parts[n]));d[a.id]={id:a.id,refs:1,parts:o}}}}function n(){var t=document.createElement("style");return t.type="text/css",l.appendChild(t),t}function i(t){var e,a,r=document.querySelector("style["+g+'~="'+t.id+'"]');if(r){if(f)return v;r.parentNode.removeChild(r)}if(m){var i=p++;r=u||(u=n()),e=o.bind(null,r,i,!1),a=o.bind(null,r,i,!0)}else r=n(),e=s.bind(null,r),a=function(){r.parentNode.removeChild(r)};return e(t),function(r){if(r){if(r.css===t.css&&r.media===t.media&&r.sourceMap===t.sourceMap)return;e(t=r)}else a()}}function o(t,e,a,r){var n=a?"":r.css;if(t.styleSheet)t.styleSheet.cssText=x(e,n);else{var i=document.createTextNode(n),o=t.childNodes;o[e]&&t.removeChild(o[e]),o.length?t.insertBefore(i,o[e]):t.appendChild(i)}}function s(t,e){var a=e.css,r=e.media,n=e.sourceMap;if(r&&t.setAttribute("media",r),y.ssrId&&t.setAttribute(g,e.id),n&&(a+="\n/*# sourceURL="+n.sources[0]+" */",a+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),t.styleSheet)t.styleSheet.cssText=a;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(a))}}var c="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!c)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var h=a(10),d={},l=c&&(document.head||document.getElementsByTagName("head")[0]),u=null,p=0,f=!1,v=function(){},y=null,g="data-vue-ssr-id",m="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());t.exports=function(t,e,a,n){f=a,y=n||{};var i=h(t,e);return r(i),function(e){for(var a=[],n=0;n<i.length;n++){var o=i[n],s=d[o.id];s.refs--,a.push(s)}e?(i=h(t,e),r(i)):i=[];for(var n=0;n<a.length;n++){var s=a[n];if(0===s.refs){for(var c=0;c<s.parts.length;c++)s.parts[c]();delete d[s.id]}}}};var x=function(){var t=[];return function(e,a){return t[e]=a,t.filter(Boolean).join("\n")}}()},function(t,e){t.exports=function(t,e,a,r,n,i){var o,s=t=t||{},c=typeof t.default;"object"!==c&&"function"!==c||(o=t,s=t.default);var h="function"==typeof s?s.options:s;e&&(h.render=e.render,h.staticRenderFns=e.staticRenderFns,h._compiled=!0),a&&(h.functional=!0),n&&(h._scopeId=n);var d;if(i?(d=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},h._ssrRegister=d):r&&(d=r),d){var l=h.functional,u=l?h.render:h.beforeCreate;l?(h._injectStyles=d,h.render=function(t,e){return d.call(e),u(t,e)}):h.beforeCreate=u?[].concat(u,d):[d]}return{esModule:o,exports:s,options:h}}},function(t,e,a){"use strict";function r(t){if(Array.isArray(t)){for(var e=0,a=Array(t.length);e<t.length;e++)a[e]=t[e];return a}return Array.from(t)}var n=a(11);e.a={name:"VueRangeDatePicker",components:{date:n.a},props:{value:{type:Object,default:null},language:{type:String,default:"zh"},colorToday:{type:String,default:"#41b883"},colorSelected:{type:String,default:"#34495e"},colorActive:{type:String,default:"#41b883"}},data:function(){return{leftYear:this.initLeftYear(),leftMonth:this.initLeftMonth(),rightYear:this.initRightYear(),rightMonth:this.initRightMonth(),certainDays:this.initCertainDays(),hoverDay:this.initHoverDay()}},computed:{selected:function(){return 2===this.certainDays.length},canHover:function(){return 1===this.certainDays.length},canPrevMonth:function(){return this.rightYear-this.leftYear>1||(this.rightYear-this.leftYear==1?this.rightMonth-this.leftMonth>-11:this.rightYear===this.leftYear&&this.rightMonth-this.leftMonth>1)},canPrevYear:function(){return this.rightYear-this.leftYear>1||this.rightYear-this.leftYear==1&&this.rightMonth>this.leftMonth},canNextMonth:function(){return this.rightYear-this.leftYear>1||(this.rightYear-this.leftYear==1?this.rightMonth-this.leftMonth>-11:this.rightYear===this.leftYear&&this.rightMonth-this.leftMonth>1)},canNextYear:function(){return this.rightYear-this.leftYear>1||this.rightYear-this.leftYear==1&&this.rightMonth>this.leftMonth}},methods:{initLeftYear:function(){return this.value.start?new Date(this.value.start).getFullYear():(new Date).getFullYear()},initLeftMonth:function(){return this.value.start?new Date(this.value.start).getMonth():(new Date).getMonth()},initRightYear:function(){if(this.value.start&&this.value.end){if(this.isSameYearMonth()){var t=new Date(this.value.start);return 11===t.getMonth()?t.getFullYear()+1:t.getFullYear()}return new Date(this.value.end).getFullYear()}return 11===(new Date).getMonth()?(new Date).getFullYear()+1:(new Date).getFullYear()},initRightMonth:function(){if(this.value.start&&this.value.end){if(this.isSameYearMonth()){var t=new Date(this.value.start);return 11===t.getMonth()?0:t.getMonth()+1}return new Date(this.value.end).getMonth()}return 11===(new Date).getMonth()?0:(new Date).getMonth()+1},isSameYearMonth:function(){var t=new Date(this.value.start).getFullYear(),e=new Date(this.value.start).getMonth(),a=new Date(this.value.end).getFullYear(),r=new Date(this.value.end).getMonth();return t===a&&e===r},initCertainDays:function(){var t=[],e=this.value,a=e.start,r=e.end;return a&&t.push(this.formatDayToMidnight(a)),r&&t.push(this.formatDayToMidnight(r)),t},formatDayToMidnight:function(t){var e=new Date(t);return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Date.parse(e)},initHoverDay:function(){return this.value.start&&this.value.end&&this.value.start<this.value.end?this.formatDayToMidnight(this.value.end):null},leftNextYear:function(){this.leftYear+=1},leftNextMonth:function(){11===this.leftMonth?(this.leftMonth=0,this.leftYear+=1):this.leftMonth+=1},leftPrevYear:function(){this.leftYear-=1},leftPrevMonth:function(){0===this.leftMonth?(this.leftMonth=11,this.leftYear-=1):this.leftMonth-=1},rightNextYear:function(){this.rightYear+=1},rightNextMonth:function(){11===this.rightMonth?(this.rightMonth=0,this.rightYear+=1):this.rightMonth+=1},rightPrevYear:function(){this.rightYear-=1},rightPrevMonth:function(){0===this.rightMonth?(this.rightMonth=11,this.rightYear-=1):this.rightMonth-=1}},watch:{certainDays:function(t){2===t.length&&(this.$emit("closePicker"),this.$emit("input",{start:Math.min.apply(Math,r(t)),end:Math.max.apply(Math,r(t))}))}}}},function(t,e,a){"use strict";var r=a(14);e.a={props:{certainDays:{type:Array},hoverDay:{type:Number},year:{type:Number},month:{type:Number},canNextMonth:{type:Boolean,default:!0},canNextYear:{type:Boolean,default:!0},canPrevMonth:{type:Boolean,default:!0},canPrevYear:{type:Boolean,default:!0},canHover:{type:Boolean,default:!1},language:{type:String},colorToday:{type:String},colorSelected:{type:String},colorActive:{type:String}},data:function(){return{days:[],weeks:{zh:["日","一","二","三","四","五","六"],jp:["日","月","火","水","木","金","土"],en:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},monthsInEnglish:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}},components:{day:r.a},methods:{firstDay:function(){var t=new Date(this.year,this.month,1),e=t.setDate(1);return new Date(e)},isToday:function(t){var e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()},getDayCountOfMonth:function(t,e){return[3,5,8,10].includes(e)?30:1===e?t%4==0&&t%100!=0||t%400==0?29:28:31},prevDays:function(){if(0===this.firstDay().getDay())return[];for(var t=this.getDayCountOfMonth(this.year,this.month-1),e=new Date(this.year,this.month-1,t),a=e.getDay()+1,r=[],n=0;n<a;n++){var i={stamp:+new Date(this.year,this.month-1,t-n),day:t-n,valid:!1,today:!1};r.unshift(i)}return r},currentDays:function(){for(var t=this,e=t.getDayCountOfMonth(t.year,t.month),a=[],r=0;r<e;r++){var n=new Date(t.year,t.month,r+1),i={stamp:+n,day:r+1,valid:!0,today:t.isToday(n)};a.push(i)}return a},nextDays:function(){if(6===this.firstDay().getDay)return[];for(var t=this.getDayCountOfMonth(this.year,this.month),e=new Date(this.year,this.month,t),a=6-e.getDay(),r=[],n=0;n<a;n++){var i={stamp:+new Date(this.year,this.month+1,n+1),day:n+1,valid:!1,today:!1};r.push(i)}return r},getDays:function(){var t=[],e=this.prevDays(),a=this.currentDays(),r=this.nextDays();return t.concat(e).concat(a).concat(r)},nextMonth:function(){this.$emit("nextMonth")},prevMonth:function(){this.$emit("prevMonth")},nextYear:function(){this.$emit("nextYear")},prevYear:function(){this.$emit("prevYear")}},created:function(){this.days=this.getDays()},watch:{year:function(){this.days=this.getDays()},month:function(){this.days=this.getDays()}}}},function(t,e,a){"use strict";e.a={props:{item:{type:Object,default:null},canHover:{type:Boolean,default:!1},hoverDay:{type:Number},certainDays:{type:Array},colorToday:{type:String},colorSelected:{type:String},colorActive:{type:String}},data:function(){return{clicked:!1}},methods:{toggleDay:function(){this.item.valid&&(this.clicked=!this.clicked,this.clicked||this.selected||this.active?(2===this.$parent.$parent.certainDays.length&&(this.$parent.$parent.certainDays=[],this.$parent.$parent.hoverDay=null),this.$parent.$parent.certainDays.push(this.item.stamp)):this.$parent.$parent.certainDays.pop())},changeHoverDay:function(){this.canHover&&this.item.valid&&!this.selected&&(this.$parent.$parent.hoverDay=this.item.stamp)}},computed:{selected:function(){return-1!==this.certainDays.indexOf(this.item.stamp)&&this.item.valid||this.item.stamp===this.hoverDay&&this.item.valid},start:function(){if(this.hoverDay&&this.item.valid){var t=this.certainDays[0],e=Math.min(t,this.hoverDay);return this.item.stamp===e}},end:function(){if(this.hoverDay&&this.item.valid){var t=this.certainDays[0],e=Math.max(t,this.hoverDay);return this.item.stamp===e}},active:function(){if(this.hoverDay&&this.item.valid){var t=this.certainDays[0],e=Math.min(t,this.hoverDay),a=Math.max(t,this.hoverDay);return this.item.stamp<=a&&this.item.stamp>=e}},dayColor:function(){return this.selected?"#fff":this.active?"#222":this.item.today?this.colorToday:this.item.valid?"#222":"#999"},circleBackgroundColor:function(){return this.selected?this.colorSelected:""},wrapperBackgroundColor:function(){return this.end||this.start?this.colorActive:""},dayBackgroundColor:function(){return this.active&&!this.selected?this.colorActive:""},wrapperBorderTopLeftRadius:function(){return this.selected?this.end?"":"13px":""},wrapperBorderBottomLeftRadius:function(){return this.selected?this.end?"":"13px":""},wrapperBorderTopRightRadius:function(){return this.selected?this.start?"":"13px":""},wrapperBorderBottomRightRadius:function(){return this.selected?this.start?"":"13px":""},wrapperStyleObject:function(){return{backgroundColor:this.wrapperBackgroundColor,borderTopLeftRadius:this.wrapperBorderTopLeftRadius,borderBottomLeftRadius:this.wrapperBorderBottomLeftRadius,borderTopRightRadius:this.wrapperBorderTopRightRadius,borderBottomRightRadius:this.wrapperBorderBottomRightRadius}}}}},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=a(7);e.default=r.a},function(t,e,a){"use strict";function r(t){a(8)}var n=a(3),i=a(19),o=a(2),s=r,c=o(n.a,i.a,!1,s,"data-v-cbb889ae",null);e.a=c.exports},function(t,e,a){var r=a(9);"string"==typeof r&&(r=[[t.i,r,""]]),r.locals&&(t.exports=r.locals);a(1)("70178521",r,!0,{})},function(t,e,a){e=t.exports=a(0)(!1),e.push([t.i,'.picker[data-v-cbb889ae]{background-color:#fff;box-shadow:0 2px 8px 0 rgba(0,0,0,.1);width:641px;margin:0 auto}.picker .dates-wrapper[data-v-cbb889ae]{display:flex;border-top:1px solid #e6e6e6;position:relative}.picker .dates-wrapper[data-v-cbb889ae]:before{content:"";display:block;width:1px;height:100%;background-color:#e6e6e6;position:absolute;left:320px;top:0}',""])},function(t,e){t.exports=function(t,e){for(var a=[],r={},n=0;n<e.length;n++){var i=e[n],o=i[0],s=i[1],c=i[2],h=i[3],d={id:t+":"+n,css:s,media:c,sourceMap:h};r[o]?r[o].parts.push(d):a.push(r[o]={id:o,parts:[d]})}return a}},function(t,e,a){"use strict";function r(t){a(12)}var n=a(4),i=a(18),o=a(2),s=r,c=o(n.a,i.a,!1,s,"data-v-923ee85e",null);e.a=c.exports},function(t,e,a){var r=a(13);"string"==typeof r&&(r=[[t.i,r,""]]),r.locals&&(t.exports=r.locals);a(1)("4dc423e6",r,!0,{})},function(t,e,a){e=t.exports=a(0)(!1),e.push([t.i,".date-picker[data-v-923ee85e]{width:320px;margin:0 auto}.date-picker .main[data-v-923ee85e]{width:280px;margin:0 auto}.date-picker .days[data-v-923ee85e]{padding-bottom:32px}.date-picker .head[data-v-923ee85e]{padding-bottom:20px;padding-top:20px;display:flex;align-items:center}.date-picker .head .text[data-v-923ee85e]{flex-grow:1;text-align:center;font-size:14px;font-weight:700}.date-picker .head .side[data-v-923ee85e]{width:49px;height:20px;flex-shrink:0;position:relative}.date-picker .head .side .year[data-v-923ee85e]{display:flex;cursor:pointer;position:absolute;top:1px;padding:5px}.date-picker .head .side .year.next-year[data-v-923ee85e]{right:3px}.date-picker .head .side .year.next-year .icon[data-v-923ee85e]:first-child{position:relative;right:-1px}.date-picker .head .side .year.prev-year[data-v-923ee85e]{left:3px}.date-picker .head .side .year.prev-year .icon[data-v-923ee85e]:nth-child(2){position:relative;left:-1px}.date-picker .head .side .month[data-v-923ee85e]{cursor:pointer;position:absolute;top:1px;padding:5px}.date-picker .head .side .month.next-month[data-v-923ee85e]{right:42px}.date-picker .head .side .month.prev-month[data-v-923ee85e]{left:42px}.date-picker .head .side .icon[data-v-923ee85e]{width:7px;height:7px;border-left:1px solid #222;border-bottom:1px solid #222}.date-picker .head .side .icon.prev[data-v-923ee85e]{transform:rotate(45deg)}.date-picker .head .side .icon.next[data-v-923ee85e]{transform:rotate(-135deg)}.date-picker .weeks[data-v-923ee85e]{display:flex;padding-bottom:10px;border-bottom:1px dashed #e6e6e6}.date-picker .weeks .week[data-v-923ee85e]{display:inline-block;text-align:center;width:40px;color:#222;font-size:12px}",""])},function(t,e,a){"use strict";function r(t){a(15)}var n=a(5),i=a(17),o=a(2),s=r,c=o(n.a,i.a,!1,s,"data-v-1348ec51",null);e.a=c.exports},function(t,e,a){var r=a(16);"string"==typeof r&&(r=[[t.i,r,""]]),r.locals&&(t.exports=r.locals);a(1)("4b1ea8ba",r,!0,{})},function(t,e,a){e=t.exports=a(0)(!1),e.push([t.i,".day[data-v-1348ec51]{margin-top:10px;display:inline-block;width:40px;text-align:center;font-size:12px;box-sizing:border-box}.day .wrapper[data-v-1348ec51]{padding:3px 0}.day .circle[data-v-1348ec51]{line-height:20px;text-align:center;display:inline-block;width:20px;height:20px;border-radius:50%;cursor:pointer}.day.today[data-v-1348ec51]{font-weight:700}.day.end[data-v-1348ec51]{padding-right:6px}.day.end .circle[data-v-1348ec51]{position:relative;right:-3px}.day.start[data-v-1348ec51]{padding-left:6px}.day.start .circle[data-v-1348ec51]{position:relative;left:-3px}",""])},function(t,e,a){"use strict";var r=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"day",class:{invalid:!t.item.valid,today:t.item.today,selected:t.selected,active:t.active,end:t.end,start:t.start},style:{color:t.dayColor,backgroundColor:t.dayBackgroundColor},on:{click:t.toggleDay,mouseover:t.changeHoverDay}},[a("div",{staticClass:"wrapper",style:t.wrapperStyleObject},[a("div",{staticClass:"circle",style:{backgroundColor:t.circleBackgroundColor}},[t._v("\n "+t._s(t.item.day)+"\n ")])])])},n=[],i={render:r,staticRenderFns:n};e.a=i},function(t,e,a){"use strict";var r=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"date-picker"},[a("div",{staticClass:"main"},[a("div",{staticClass:"head"},[a("div",{staticClass:"side"},[t.canPrevYear?a("div",{staticClass:"prev-year year",on:{click:t.prevYear}},[a("div",{staticClass:"icon prev"}),t._v(" "),a("div",{staticClass:"icon prev"})]):t._e(),t._v(" "),t.canPrevMonth?a("div",{staticClass:"prev-month month",on:{click:t.prevMonth}},[a("div",{staticClass:"icon prev"})]):t._e()]),t._v(" "),"en"===t.language?a("div",{staticClass:"text"},[t._v("\n "+t._s(t.monthsInEnglish[t.month])+" "+t._s(t.year)+"\n ")]):a("div",{staticClass:"text"},[t._v("\n "+t._s(t.year)+"年"+t._s(t.month+1)+"月\n ")]),t._v(" "),a("div",{staticClass:"side"},[t.canNextMonth?a("div",{staticClass:"next-month month",on:{click:t.nextMonth}},[a("div",{staticClass:"icon next"})]):t._e(),t._v(" "),t.canNextYear?a("div",{staticClass:"next-year year",on:{click:t.nextYear}},[a("div",{staticClass:"icon next"}),t._v(" "),a("div",{staticClass:"icon next"})]):t._e()])]),t._v(" "),a("div",{staticClass:"weeks"},t._l(t.weeks[t.language],function(e,r){return a("span",{key:r,staticClass:"week"},[t._v("\n "+t._s(e)+"\n ")])}),0),t._v(" "),a("div",{staticClass:"days"},t._l(t.days,function(e){return a("day",{key:e.stamp,attrs:{item:e,canHover:t.canHover,certainDays:t.certainDays,hoverDay:t.hoverDay,colorToday:t.colorToday,colorSelected:t.colorSelected,colorActive:t.colorActive}})}),1)])])},n=[],i={render:r,staticRenderFns:n};e.a=i},function(t,e,a){"use strict";var r=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"picker"},[a("div",{staticClass:"dates-wrapper"},[a("date",{attrs:{year:t.leftYear,month:t.leftMonth,canNextMonth:t.canNextMonth,canNextYear:t.canNextYear,canHover:t.canHover,certainDays:t.certainDays,hoverDay:t.hoverDay,language:t.language,colorToday:t.colorToday,colorSelected:t.colorSelected,colorActive:t.colorActive},on:{prevYear:t.leftPrevYear,nextYear:t.leftNextYear,prevMonth:t.leftPrevMonth,nextMonth:t.leftNextMonth}}),t._v(" "),a("date",{attrs:{year:t.rightYear,month:t.rightMonth,canPrevMonth:t.canPrevMonth,canPrevYear:t.canPrevYear,canHover:t.canHover,certainDays:t.certainDays,hoverDay:t.hoverDay,language:t.language,colorToday:t.colorToday,colorSelected:t.colorSelected,colorActive:t.colorActive},on:{prevYear:t.rightPrevYear,nextYear:t.rightNextYear,prevMonth:t.rightPrevMonth,nextMonth:t.rightNextMonth}})],1)])},n=[],i={render:r,staticRenderFns:n};e.a=i}])}); //# sourceMappingURL=vueRangeDatePicker.js.map