UNPKG

tui-calendar-react

Version:
3 lines (2 loc) 11.7 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("tui-calendar")):"function"==typeof define&&define.amd?define(["react","tui-calendar"],t):e.TuiCalendar=t(e.React,e.tui.Calendar)}(this,function(e,t){"use strict";var n="default"in e?e.default:e;function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}t=t&&t.hasOwnProperty("default")?t.default:t;"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function c(e,t){return e(t={exports:{}},t.exports),t.exports}var u=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign;var d="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";function h(){}var p=c(function(e){e.exports=function(){function e(e,t,n,r,a,s){if(s!==d){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=h,n.PropTypes=n,n}()}),y=c(function(e,t){e.exports=function(){var e="millisecond",t="second",n="minute",r="hour",a="day",s="week",i="month",o="year",c=/^(\d{4})-?(\d{1,2})-?(\d{0,2})(.*?(\d{1,2}):(\d{1,2}):(\d{1,2}))?.?(\d{1,3})?$/,u=/\[.*?\]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},l=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},d={padStart:l,padZoneStr:function(e){var t=Math.abs(e),n=Math.floor(t/60),r=t%60;return(e<=0?"+":"-")+l(n,2,"0")+":"+l(r,2,"0")},monthDiff:function(e,t){var n=12*(t.year()-e.year())+(t.month()-e.month()),r=e.clone().add(n,"months"),a=t-r<0,s=e.clone().add(n+(a?-1:1),"months");return Number(-(n+(t-r)/(a?r-s:s-r)))},absFloor:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},prettyUnit:function(c){return{M:i,y:o,w:s,d:a,h:r,m:n,s:t,ms:e}[c]||String(c||"").toLowerCase().replace(/s$/,"")},isUndefined:function(e){return void 0===e}},h="en",p={};p[h]=f;var y=function(e){return e instanceof v},$=function(e,t,n){var r;if(!e)return null;if("string"==typeof e)p[e]&&(r=e),t&&(p[e]=t,r=e);else{var a=e.name;p[a]=e,r=a}return n||(h=r),r},m=function(e,t){if(y(e))return e.clone();var n=t||{};return n.date=e,new v(n)},b=function(e,t){return m(e,{locale:t.$L})},g=d;g.parseLocale=$,g.isDayjs=y,g.wrapper=b;var v=function(){function f(e){this.parse(e)}var l=f.prototype;return l.parse=function(e){var t,n;this.$d=null===(t=e.date)?new Date(NaN):g.isUndefined(t)?new Date:t instanceof Date?t:"string"==typeof t&&/.*[^Z]$/i.test(t)&&(n=t.match(c))?new Date(n[1],n[2]-1,n[3]||1,n[5]||0,n[6]||0,n[7]||0,n[8]||0):new Date(t),this.init(e)},l.init=function(e){this.$y=this.$d.getFullYear(),this.$M=this.$d.getMonth(),this.$D=this.$d.getDate(),this.$W=this.$d.getDay(),this.$H=this.$d.getHours(),this.$m=this.$d.getMinutes(),this.$s=this.$d.getSeconds(),this.$ms=this.$d.getMilliseconds(),this.$L=this.$L||$(e.locale,null,!0)||h},l.$utils=function(){return g},l.isValid=function(){return!("Invalid Date"===this.$d.toString())},l.$compare=function(e){return this.valueOf()-m(e).valueOf()},l.isSame=function(e){return 0===this.$compare(e)},l.isBefore=function(e){return this.$compare(e)<0},l.isAfter=function(e){return this.$compare(e)>0},l.year=function(){return this.$y},l.month=function(){return this.$M},l.day=function(){return this.$W},l.date=function(){return this.$D},l.hour=function(){return this.$H},l.minute=function(){return this.$m},l.second=function(){return this.$s},l.millisecond=function(){return this.$ms},l.unix=function(){return Math.floor(this.valueOf()/1e3)},l.valueOf=function(){return this.$d.getTime()},l.startOf=function(e,c){var u=this,f=!!g.isUndefined(c)||c,l=function(e,t){var n=b(new Date(u.$y,t,e),u);return f?n:n.endOf(a)},d=function(e,t){return b(u.toDate()[e].apply(u.toDate(),f?[0,0,0,0].slice(t):[23,59,59,999].slice(t)),u)};switch(g.prettyUnit(e)){case o:return f?l(1,0):l(31,11);case i:return f?l(1,this.$M):l(0,this.$M+1);case s:return l(f?this.$D-this.$W:this.$D+(6-this.$W),this.$M);case a:case"date":return d("setHours",0);case r:return d("setMinutes",1);case n:return d("setSeconds",2);case t:return d("setMilliseconds",3);default:return this.clone()}},l.endOf=function(e){return this.startOf(e,!1)},l.$set=function(s,c){switch(g.prettyUnit(s)){case a:this.$d.setDate(this.$D+(c-this.$W));break;case"date":this.$d.setDate(c);break;case i:this.$d.setMonth(c);break;case o:this.$d.setFullYear(c);break;case r:this.$d.setHours(c);break;case n:this.$d.setMinutes(c);break;case t:this.$d.setSeconds(c);break;case e:this.$d.setMilliseconds(c)}return this.init(),this},l.set=function(e,t){return this.clone().$set(e,t)},l.add=function(e,c){var u=this;e=Number(e);var f,l=g.prettyUnit(c),d=function(t,n){var r=u.set("date",1).set(t,n+e);return r.set("date",Math.min(u.$D,r.daysInMonth()))};if(l===i)return d(i,this.$M);if(l===o)return d(o,this.$y);switch(l){case n:f=6e4;break;case r:f=36e5;break;case a:f=864e5;break;case s:f=6048e5;break;case t:f=1e3;break;default:f=1}var h=this.valueOf()+e*f;return b(h,this)},l.subtract=function(e,t){return this.add(-1*e,t)},l.format=function(e){var t=this,n=e||"YYYY-MM-DDTHH:mm:ssZ",r=g.padZoneStr(this.$d.getTimezoneOffset()),a=this.$locale(),s=a.weekdays,i=a.months,o=function(e,t,n,r){return e&&e[t]||n[t].substr(0,r)};return n.replace(u,function(e){if(e.indexOf("[")>-1)return e.replace(/\[|\]/g,"");switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return String(t.$y);case"M":return String(t.$M+1);case"MM":return g.padStart(t.$M+1,2,"0");case"MMM":return o(a.monthsShort,t.$M,i,3);case"MMMM":return i[t.$M];case"D":return String(t.$D);case"DD":return g.padStart(t.$D,2,"0");case"d":return String(t.$W);case"dd":return o(a.weekdaysMin,t.$W,s,2);case"ddd":return o(a.weekdaysShort,t.$W,s,3);case"dddd":return s[t.$W];case"H":return String(t.$H);case"HH":return g.padStart(t.$H,2,"0");case"h":case"hh":return 0===t.$H?12:g.padStart(t.$H<13?t.$H:t.$H-12,"hh"===e?2:1,"0");case"a":return t.$H<12?"am":"pm";case"A":return t.$H<12?"AM":"PM";case"m":return String(t.$m);case"mm":return g.padStart(t.$m,2,"0");case"s":return String(t.$s);case"ss":return g.padStart(t.$s,2,"0");case"SSS":return g.padStart(t.$ms,3,"0");case"Z":return r;default:return r.replace(":","")}})},l.diff=function(e,c,u){var f=g.prettyUnit(c),l=m(e),d=this-l,h=g.monthDiff(this,l);switch(f){case o:h/=12;break;case i:break;case"quarter":h/=3;break;case s:h=d/6048e5;break;case a:h=d/864e5;break;case r:h=d/36e5;break;case n:h=d/6e4;break;case t:h=d/1e3;break;default:h=d}return u?h:g.absFloor(h)},l.daysInMonth=function(){return this.endOf(i).$D},l.$locale=function(){return p[this.$L]},l.locale=function(e,t){var n=this.clone();return n.$L=$(e,t,!0),n},l.clone=function(){return b(this.toDate(),this)},l.toDate=function(){return new Date(this.$d)},l.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]},l.toJSON=function(){return this.toISOString()},l.toISOString=function(){return this.toDate().toISOString()},l.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}},l.toString=function(){return this.$d.toUTCString()},f}();return m.extend=function(e,t){return e(t,v,m),m},m.locale=$,m.isDayjs=y,m.en=p[h],m}()}),$=["beforeCreateSchedule","afterRenderSchedule","beforeUpdateSchedule","beforeDeleteSchedule","clickSchedule","clickDayname"];function m(e,t){var n=[],r=y(e.start.toUTCString());return t||n.push("<strong>"+r.format("HH:mm")+"</strong> "),e.isPrivate?(n.push('<span class="calendar-font-icon ic-lock-b"></span>'),n.push(" Private")):(e.isReadOnly?n.push('<span class="calendar-font-icon ic-readonly-b"></span>'):e.recurrenceRule?n.push('<span class="calendar-font-icon ic-repeat-b"></span>'):e.attendees.length>0?n.push('<span class="calendar-font-icon ic-user-b"></span>'):e.location&&n.push('<span class="calendar-font-icon ic-location-b"></span>'),n.push(" "+e.title)),n.join("")}var b=function(c){function u(){var t,n,r,i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u);for(var c=arguments.length,f=new Array(c),l=0;l<c;l++)f[l]=arguments[l];return r=this,a(o(o(n=!(i=(t=s(u)).call.apply(t,[this].concat(f)))||"object"!=typeof i&&"function"!=typeof i?o(r):i)),"calRef",e.createRef()),n}var f,l,d;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,e.PureComponent),f=u,(l=[{key:"componentDidMount",value:function(){this.calendar=new t(this.calRef.current,Object.assign({defaultView:"month",taskView:!0,useCreationPopup:!0,useDetailPopup:!0,timezones:[{timezoneOffset:420,displayLabel:"GMT+08:00",tooltip:"Hong Kong"}],template:{monthGridHeader:function(e){return'<span class="tui-full-calendar-weekday-grid-date">'+new Date(e.date).getDate()+"</span>"},milestone:function(e){return'<span class="calendar-font-icon ic-milestone-b"></span> <span style="background-color: '+e.bgColor+'">'+e.title+"</span>"},allday:function(e){return m(e,!0)},time:function(e){return m(e,!1)}}},this.props.options)),this.registerEvents(),this.renderCal()}},{key:"componentDidUpdate",value:function(e){var t=this;$.map(function(n){t.props[n]!==e[n]&&(t.calendar.off(n),t.calendar.on(n,t.props[n]))}),this.renderCal()}},{key:"componentWillUnmount",value:function(){this.calendar.destroy()}},{key:"registerEvents",value:function(){var e=this;this.calendar.on($.reduce(function(t,n){return Object.assign({},t,a({},n,e.props[n]))},{}))}},{key:"renderCal",value:function(){this.calendar.clear(),this.calendar.createSchedules(this.props.schedules),this.calendar.render()}},{key:"render",value:function(){return n.createElement("div",{ref:this.calRef,style:{height:800}})}}])&&r(f.prototype,l),d&&r(f,d),u}();return b.defaultProps=Object.assign({schedules:[],options:{}},$.reduce(function(e,t){return Object.assign({},e,a({},t,function(){}))},{})),b.propTypes=Object.assign({schedules:p.array,options:p.object},$.reduce(function(e,t){return Object.assign({},e,a({},t,p.func))},{})),b}); //# sourceMappingURL=react-tui-calendar.min.js.map