UNPKG

vuejs-datepicker-mobile

Version:

A Vue.js datepick mobile project

6 lines 18.5 kB
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["vuejs-datepicker-mobile"]=e():t["vuejs-datepicker-mobile"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"24fb":function(t,e,n){"use strict";function i(t,e){var n=t[1]||"",i=t[3];if(!i)return n;if(e&&"function"===typeof btoa){var a=r(i),o=i.sources.map((function(t){return"/*# sourceURL=".concat(i.sourceRoot).concat(t," */")}));return[n].concat(o).concat([a]).join("\n")}return[n].join("\n")}function r(t){var e=btoa(unescape(encodeURIComponent(JSON.stringify(t)))),n="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(e);return"/*# ".concat(n," */")}t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=i(e,t);return e[2]?"@media ".concat(e[2],"{").concat(n,"}"):n})).join("")},e.i=function(t,n){"string"===typeof t&&(t=[[null,t,""]]);for(var i={},r=0;r<this.length;r++){var a=this[r][0];null!=a&&(i[a]=!0)}for(var o=0;o<t.length;o++){var s=t[o];null!=s[0]&&i[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="(".concat(s[2],") and (").concat(n,")")),e.push(s))}},e}},"320c":function(t,e,n){"use strict"; /* object-assign (c) Sindre Sorhus @license MIT */var i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function o(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function s(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;var i=Object.getOwnPropertyNames(e).map((function(t){return e[t]}));if("0123456789"!==i.join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(t){r[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(a){return!1}}t.exports=s()?Object.assign:function(t,e){for(var n,s,c=o(t),d=1;d<arguments.length;d++){for(var h in n=Object(arguments[d]),n)r.call(n,h)&&(c[h]=n[h]);if(i){s=i(n);for(var l=0;l<s.length;l++)a.call(n,s[l])&&(c[s[l]]=n[s[l]])}}return c}},"3a54":function(t,e,n){e=t.exports=n("24fb")(!1),e.push([t.i,".m-picker{font-size:4.26667vw;color:#666;position:fixed;width:100vw;height:100vh;top:0;left:0;z-index:1000}.m-picker .m-picker-item-box{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;overflow:hidden}.m-picker .m-picker-mark{position:absolute;z-index:99;background:#000;opacity:.6;width:100%;height:100%}.m-picker .m-picker-header{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;height:10.66667vw;line-height:10.66667vw;border-bottom:1px solid #eee;-webkit-box-sizing:border-box;box-sizing:border-box;padding:0 5.33333vw;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.m-picker .m-picker-header span:last-of-type{color:#41b883}.m-picker .m-picker-box{position:absolute;z-index:100;bottom:0;background:#fff;width:100%;height:94.66667vw}.m-picker-item{height:84vw;overflow:hidden}.m-picker-item,.m-picker-item .m-scroller-item-box{position:relative;width:100%}.m-picker-item .m-scroller-item{text-align:center;font-size:4.8vw;height:9.33333vw;line-height:9.33333vw}.m-picker-item .m-scroller-mask{top:0;height:100%;margin:0 auto;z-index:3;background-image:-webkit-gradient(linear,left top,left bottom,from(hsla(0,0%,100%,.95)),to(hsla(0,0%,100%,.6))),-webkit-gradient(linear,left bottom,left top,from(hsla(0,0%,100%,.95)),to(hsla(0,0%,100%,.6)));background-image:linear-gradient(180deg,hsla(0,0%,100%,.95),hsla(0,0%,100%,.6)),linear-gradient(0deg,hsla(0,0%,100%,.95),hsla(0,0%,100%,.6));background-size:100% 37.33333vw}.m-picker-item .m-scroller-indicator,.m-picker-item .m-scroller-mask{position:absolute;left:0;width:100%;background-position:top,bottom;background-repeat:no-repeat}.m-picker-item .m-scroller-indicator{height:9.33333vw;top:37.33333vw;z-index:2;-webkit-box-sizing:border-box;box-sizing:border-box;background-image:-webkit-gradient(linear,left top,left bottom,from(#d0d0d0),color-stop(#d0d0d0),color-stop(transparent),to(transparent)),-webkit-gradient(linear,left bottom,left top,from(#d0d0d0),color-stop(#d0d0d0),color-stop(transparent),to(transparent));background-image:linear-gradient(180deg,#d0d0d0,#d0d0d0,transparent,transparent),linear-gradient(0deg,#d0d0d0,#d0d0d0,transparent,transparent);background-size:100% 2px}.fade-enter-active,.fade-leave-active{transition:opacity .3s;-webkit-transition:opacity .3s;opacity:1}.fade-enter,.fade-leave-to{opacity:0}",""])},"499e":function(t,e,n){"use strict";function i(t,e){for(var n=[],i={},r=0;r<e.length;r++){var a=e[r],o=a[0],s=a[1],c=a[2],d=a[3],h={id:t+":"+r,css:s,media:c,sourceMap:d};i[o]?i[o].parts.push(h):n.push(i[o]={id:o,parts:[h]})}return n}n.r(e),n.d(e,"default",(function(){return m}));var r="undefined"!==typeof document;if("undefined"!==typeof DEBUG&&DEBUG&&!r)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 a={},o=r&&(document.head||document.getElementsByTagName("head")[0]),s=null,c=0,d=!1,h=function(){},l=null,u="data-vue-ssr-id",p="undefined"!==typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function m(t,e,n,r){d=n,l=r||{};var o=i(t,e);return f(o),function(e){for(var n=[],r=0;r<o.length;r++){var s=o[r],c=a[s.id];c.refs--,n.push(c)}e?(o=i(t,e),f(o)):o=[];for(r=0;r<n.length;r++){c=n[r];if(0===c.refs){for(var d=0;d<c.parts.length;d++)c.parts[d]();delete a[c.id]}}}}function f(t){for(var e=0;e<t.length;e++){var n=t[e],i=a[n.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](n.parts[r]);for(;r<n.parts.length;r++)i.parts.push(v(n.parts[r]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var o=[];for(r=0;r<n.parts.length;r++)o.push(v(n.parts[r]));a[n.id]={id:n.id,refs:1,parts:o}}}}function g(){var t=document.createElement("style");return t.type="text/css",o.appendChild(t),t}function v(t){var e,n,i=document.querySelector("style["+u+'~="'+t.id+'"]');if(i){if(d)return h;i.parentNode.removeChild(i)}if(p){var r=c++;i=s||(s=g()),e=b.bind(null,i,r,!1),n=b.bind(null,i,r,!0)}else i=g(),e=k.bind(null,i),n=function(){i.parentNode.removeChild(i)};return e(t),function(i){if(i){if(i.css===t.css&&i.media===t.media&&i.sourceMap===t.sourceMap)return;e(t=i)}else n()}}var y=function(){var t=[];return function(e,n){return t[e]=n,t.filter(Boolean).join("\n")}}();function b(t,e,n,i){var r=n?"":i.css;if(t.styleSheet)t.styleSheet.cssText=y(e,r);else{var a=document.createTextNode(r),o=t.childNodes;o[e]&&t.removeChild(o[e]),o.length?t.insertBefore(a,o[e]):t.appendChild(a)}}function k(t,e){var n=e.css,i=e.media,r=e.sourceMap;if(i&&t.setAttribute("media",i),l.ssrId&&t.setAttribute(u,e.id),r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),t.styleSheet)t.styleSheet.cssText=n;else{while(t.firstChild)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}},cb43:function(t,e,n){var i=n("3a54");"string"===typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);var r=n("499e").default;r("6e92bf31",i,!0,{sourceMap:!1,shadowMode:!1})},f6fd:function(t,e){(function(t){var e="currentScript",n=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(i){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(i.stack)||[!1])[1];for(t in n)if(n[t].src==e||"interactive"==n[t].readyState)return n[t];return null}}})})(document)},fb15:function(t,e,n){"use strict";var i;(n.r(e),"undefined"!==typeof window)&&(n("f6fd"),(i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.show?n("div",{staticClass:"m-picker"},[n("div",{staticClass:"m-picker-mark",on:{click:t.cal}}),n("div",{staticClass:"m-picker-box"},[n("div",{staticClass:"m-picker-header"},[n("span",{on:{click:t.cal}},[t._v("取消")]),n("span",{on:{click:t.sel}},[t._v("确定")])]),n("div",{staticClass:"m-picker-content"},["picker"===t.type?n("div",{staticClass:"m-picker-item-box"},[n("PickerItem",{attrs:{change:t.change,d:t.dateList[0],selType:"year",val:t.year},on:{"update:val":function(e){t.year=e}}}),n("PickerItem",{attrs:{change:t.change,d:t.dateList[1],selType:"month",val:t.month},on:{"update:val":function(e){t.month=e}}}),n("PickerItem",{attrs:{change:t.change,d:t.dateList[2],selType:"day",val:t.day},on:{"update:val":function(e){t.day=e}}})],1):n("div",{staticClass:"m-picker-item-box"},[n("PickerItem",{attrs:{change:t.change,d:t.dateList[0],selType:"year",val:t.year},on:{"update:val":function(e){t.year=e}}}),n("PickerItem",{attrs:{change:t.change,d:t.dateList[1],selType:"month",val:t.month},on:{"update:val":function(e){t.month=e}}}),n("PickerItem",{attrs:{change:t.change,d:t.dateList[2],selType:"day",val:t.day},on:{"update:val":function(e){t.day=e}}}),n("PickerItem",{attrs:{change:t.change,d:t.dateList[3],selType:"hour",val:t.hour},on:{"update:val":function(e){t.hour=e}}}),n("PickerItem",{attrs:{change:t.change,d:t.dateList[4],selType:"minute",val:t.minute},on:{"update:val":function(e){t.minute=e}}})],1)])])]):t._e()},a=[],o=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"m-picker-item"},[n("div",{staticClass:"m-scroller-indicator"}),n("div",{staticClass:"m-scroller-mask",on:{touchend:t.end,touchmove:t.move,touchstart:t.start}}),n("div",{staticClass:"m-scroller-item-box",style:t.domStyle},t._l(t.d,(function(e,i){return n("div",{key:i,staticClass:"m-scroller-item"},[t._v(t._s(e))])})),0)])},s=[],c=n("320c"),d=n.n(c),h=function(t,e){var n={};for(var i in t.$options.props)"value"!==i&&(n[i]=t.$options.props[i].default);var r=d()({},n,e);for(var a in r)t[a]=r[a]};function l(t,e){var n,i,r;try{n=t.toString().split(".")[1].length}catch(a){n=0}try{i=e.toString().split(".")[1].length}catch(a){i=0}return r=Math.pow(10,Math.max(n,i)),(p(t,r)+p(e,r))/r}function u(t,e){var n,i,r;try{n=t.toString().split(".")[1].length}catch(a){n=0}try{i=e.toString().split(".")[1].length}catch(a){i=0}return r=Math.pow(10,Math.max(n,i)),(p(t,r)-p(e,r))/r}function p(t,e){var n=0,i=t.toString(),r=e.toString();try{n+=i.split(".")[1].length}catch(a){}try{n+=r.split(".")[1].length}catch(a){}return Number(i.replace(".",""))*Number(r.replace(".",""))/Math.pow(10,n)}function m(t,e){var n,i,r=0,a=0;try{r=t.toString().split(".")[1].length}catch(o){}try{a=e.toString().split(".")[1].length}catch(o){}return n=Number(t.toString().replace(".","")),i=Number(e.toString().replace(".","")),p(n/i,Math.pow(10,a-r))}function f(t,e){return u(t,p(parseInt(m(t,e)),e))}function g(t){if(void 0===t)return!1;var e=t.toString().split("-");return e[1]=1===e[1].length&&e[1]<10?"0"+e[1]:e[1],e[2]=1===e[2].length&&e[2]<10?"0"+e[2]:e[2],"".concat(e[0],"-").concat(e[1],"-").concat(e[2])}var v={props:{change:{},val:{},selType:{},d:{default:function(){return[]}}},data:function(){return{startY:"",endY:"",lastPoint:[],value:"",dY:0,itemKey:0,changeY:"",domStyle:{transform:"translate3d(0, 0, 0)"}}},computed:{itemHeight:function(){return(+window.getComputedStyle(document.querySelector(".m-scroller-item")).height.replace("px","")).toFixed(2)},itemLen:function(){return this.d.length}},watch:{d:function(t){var e=this;t.map((function(t,n){t.match(/\d*/g)[0]===e.val&&(e.itemKey=n)})),this.dY=p(4-this.itemKey,this.itemHeight),this.scroll(this.dY,.4)}},mounted:function(){this.val?this.moveTo(this.val):(this.dY=p(this.itemHeight,4),this.domStyle=this.style={transform:"translate3d(0px, ".concat(this.dY,"px, 0px)")})},methods:{scroll:function(t,e){var n=f(t,this.itemHeight)>m(this.itemHeight,2)?this.itemHeight:0;t=l(u(t,f(t,this.itemHeight)),n),t>p(this.itemHeight,4)&&(t=p(this.itemHeight,4));var i=p(5-this.itemLen,this.itemHeight);t<i&&(t=i),this.dY=t,this.itemKey=m(u(p(this.itemHeight,4),t),this.itemHeight),this.domStyle=this.style={transform:"translate3d(0px, ".concat(t,"px, 0px)"),transition:"all ".concat(e,"s cubic-bezier(0.1, 0.85, 0.25, 1) 0s")},this.change(this.d[this.itemKey],this.itemKey,this.selType)},start:function(t){this.startY=t.touches[0].pageY,this.domStyle=this.style={transform:"translate3d(0px, ".concat(this.dY,"px, 0px)"),transition:"none"}},end:function(t){this.endY=t.changedTouches[0].pageY;var e=parseInt(Math.sqrt(Math.abs(this.endY-this.startY)))/10;this.scroll(this.dY+this.endY-this.startY,e)},move:function(t){t.preventDefault();var e=t.touches[0].pageY-this.startY;this.domStyle={transform:"translate3d(0px, ".concat(e,"px, 0px)")}},moveTo:function(t){var e=this;"year"===this.selType?(this.itemKey=0,this.d.map((function(n,i){Number(n.match(/\d*/g)[0])===t&&(e.itemKey=i)}))):("month"===this.selType||this.selType,this.itemKey=0,this.d.map((function(n,i){Number(n.match(/\d*/g)[0])===t&&(e.itemKey=i)}))),this.dY=p(4-this.itemKey,this.itemHeight),this.scroll(this.dY,0)}}},y=v;function b(t,e,n,i,r,a,o,s){var c,d="function"===typeof t?t.options:t;if(e&&(d.render=e,d.staticRenderFns=n,d._compiled=!0),i&&(d.functional=!0),a&&(d._scopeId="data-v-"+a),o?(c=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(o)},d._ssrRegister=c):r&&(c=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),c)if(d.functional){d._injectStyles=c;var h=d.render;d.render=function(t,e){return c.call(e),h(t,e)}}else{var l=d.beforeCreate;d.beforeCreate=l?[].concat(l,c):[c]}return{exports:t,options:d}}var k=b(y,o,s,!1,null,null,null),x=k.exports,w={name:"datePicker",components:{PickerItem:x},data:function(){return{show:!1,type:"picker",dateList:[],year:1,month:1,day:1,hour:1,minute:1,endTime:"",startTime:"",succeed:function(t){},cancel:function(){}}},computed:{isR:function(){return this.year%4===0},startTimeArr:function(){return this.startTime?this.startTime.split("-"):[]},endTimeArr:function(){return this.endTime?this.endTime.split("-"):[]}},mounted:function(){this.setMonth()},methods:{sel:function(){if(this.show=!1,this.month<10&&(this.month="0".concat(this.month)),this.day<10&&(this.day="0".concat(this.day)),this.hour<10&&(this.hour="0".concat(this.hour)),this.minute<10&&(this.minute="0".concat(this.minute)),"moment"===this.type)return this.succeed("".concat(this.year,"-").concat(this.month,"-").concat(this.day," ").concat(this.hour,":").concat(this.minute));this.succeed("".concat(this.year,"-").concat(this.month,"-").concat(this.day))},setMonth:function(){var t=2===this.month,e=[1,3,5,7,8,10,12].join().indexOf(parseInt(this.month)),n=[],i=[1,12],r=[],a="",o=[],s=[0,23],c=[],d=[0,59];this.endTimeArr&&this.year===+this.endTimeArr[0]&&(i[1]=+this.endTimeArr[1],this.month===+this.endTimeArr[1]&&(a[1]=+this.endTimeArr[2])),a=t?this.isR?[1,29]:[1,28]:e<0?[1,30]:[1,31],this.startTimeArr&&this.year===+this.startTimeArr[0]&&(i[0]=+this.startTimeArr[1],this.month===+this.startTimeArr[1]&&(a[0]=+this.startTimeArr[2]));for(var h=i[0];h<=i[1];h++)n.push(h+"月");for(var l=a[0];l<=a[1];l++)r.push(l+"日");for(var u=s[0];u<=s[1];u++)o.push(u+"时");for(var p=d[0];p<=d[1];p++)c.push(p+"分");this.dateList[1]=n,this.dateList[2]=r,this.dateList[3]=o,this.dateList[4]=c},change:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";"year"===n?(this.year=t.match(/\d*/g)[0],this.setMonth()):"month"===n?(this.month=t.match(/\d*/g)[0],this.setMonth()):"day"===n?this.day=t.match(/\d*/g)[0]:"hour"===n?this.hour=t.match(/\d*/g)[0]:"minute"===n&&(this.minute=t.match(/\d*/g)[0])},cal:function(){this.show=!1,this.cancel()}}},T=w,j=b(T,r,a,!1,null,null,null),S=j.exports,C=(n("cb43"),{install:function(t){t.prototype.$picker={};var e=t.extend(S),n=new e({el:document.createElement("div")});document.body.appendChild(n.$el),t.prototype.$picker.show=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new Date;n=Object.assign(n,{show:!0,type:"picker",data:[],year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),startTime:"",endTime:"",date:"",succeed:function(t){},cancel:function(){}});var i=[1949,2099];if(t.startTime){var r=new Date(g(t.startTime)).getFullYear();i[0]=r}if(t.endTime){var a=new Date(g(t.endTime)).getFullYear();i[1]=a}if(t.startTime&&t.endTime&&new Date(g(t.startTime)).getTime()>=new Date(g(t.endTime)).getTime()&&(i[0]=1949,t.startTime="1949-01-01"),t.date){var o=new Date(g(t.date)),s=new Date(g(t.endTime)||"2099-12-31").getTime(),c=new Date(g(t.startTime)||"1949-01-01").getTime();o.getTime()>=c&&o.getTime()<=s?(t.year=o.getFullYear(),t.month=o.getMonth()+1,t.day=o.getDate(),t.hour=o.getHours(),t.minute=o.getMinutes()):t.date=""}for(var d=[1,12],l=[1,30],u=[0,23],p=[0,59],m=[],f=[],v=[],y=[],b=[];i[0]<=i[1];i[0]++)m.push(i[0]+"年");for(;d[0]<=d[1];d[0]++)f.push(d[0]+"月");for(;l[0]<=l[1];l[0]++)v.push(l[0]+"日");for(;u[0]<=u[1];u[0]++)y.push(u[0]+"时");for(;p[0]<=p[1];p[0]++)b.push(p[0]+"分");t.dateList=[m,f,v,y,b],h(n,t)},t.prototype.$picker.hide=function(){n.show=!1}}}),_=C,O=_;e["default"]=O}})}));