@commander-lol/react-kronos
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("classnames"),require("moment"),require("jss"),require("moment-range"),require("react-dom"),require("color"),require("jss-camel-case"),require("jss-default-unit"),require("jss-nested"),require("jss-vendor-prefixer"),require("lodash/assign"),require("lodash/get"),require("lodash/omit"));else if("function"==typeof define&&define.amd)define(["react","classnames","moment","jss","moment-range","react-dom","color","jss-camel-case","jss-default-unit","jss-nested","jss-vendor-prefixer","lodash/assign","lodash/get","lodash/omit"],t);else{var o="object"==typeof exports?t(require("react"),require("classnames"),require("moment"),require("jss"),require("moment-range"),require("react-dom"),require("color"),require("jss-camel-case"),require("jss-default-unit"),require("jss-nested"),require("jss-vendor-prefixer"),require("lodash/assign"),require("lodash/get"),require("lodash/omit")):t(e.react,e.classnames,e.moment,e.jss,e["moment-range"],e["react-dom"],e.color,e["jss-camel-case"],e["jss-default-unit"],e["jss-nested"],e["jss-vendor-prefixer"],e["lodash/assign"],e["lodash/get"],e["lodash/omit"]);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,function(e,t,o,n,r,i,s,a,u,l,p,c,d,f){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){e.exports=o(12)},function(e,t){e.exports=require("react")},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t,o){function n(e,t){return f["default"].createStyleSheet(e,t).attach()}function a(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,o="x"===e?t:3&t|8;return o.toString(16)})}var p=function(p){function d(){return r(this,d),i(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return s(d,p),l(d,[{key:"componentWillMount",value:function(){var e=this.props.id?this.props.id:a(),r="function"==typeof t?t(this.props,e):t,i="function"==typeof o?o(this.props,e):o;this.sheet=n(r,i),this.uuid=e}},{key:"componentWillUnmount",value:function(){this.sheet.detach(),this.sheet=null}},{key:"classSet",value:function(e){return Object.keys(e).filter(function(t){return e[t]}).map(function(e){return this.sheet.classes[e]||e}).join(" ")}},{key:"render",value:function(){return c["default"].createElement(e,u({id:this.uuid,ref:"kronos",classes:this.sheet.classes,classSet:this.classSet},this.props))}}]),d}(c["default"].Component);return p}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},l=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}();t["default"]=a;var p=o(1),c=n(p),d=o(7),f=n(d)},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e){v||(e&&e.moment?e.moment.settings?b["default"].locale(e.moment.lang,e.moment.settings):b["default"].locale(e.moment.lang):b["default"].updateLocale("en",{week:{dow:1},weekdaysMin:["M","T","W","T","F","S","S"]})),v=!0}function i(e,t){g[t]=(0,c["default"])(e,"moment")}function s(e,t,o){r(t.options),t.options&&i(t.options,o);var n={color:"#1e7e9e",corners:4,font:"Source Sans Pro"},s=(0,f["default"])(n,g[o]),p=void 0;switch(e){case"index":p=a(s);break;case"calendar":p=u(s);break;case"navigation":p=l(s);break;case"cell":p=cell(s)}return p}function a(e){return{kronos:{position:"relative",display:"flex",color:"hsl(0, 0%, 50%)","& *":{fontFamily:e.font,margin:0,padding:0,boxSizing:"border-box",userSelect:"none"}},input:{border:"1px solid transparent",borderRadius:e.corners,borderColor:(0,y["default"])(e.color).alpha(.2).rgbString(),fontSize:16,padding:"3px 6px",background:"white","&.outside-range":{color:"white",background:"#d0021b"},"&:focus":{outline:"none",borderColor:(0,y["default"])(e.color).alpha(.5).rgbString()}}}}function u(e){return{calendarBelow:{position:"absolute",top:"100%",left:0,padding:6,background:"white",border:"1px solid hsla(0, 0%, 0%, 0.15)",borderRadius:e.corners,boxShadow:"0 0 7px 5px hsla(0, 0%, 0%, 0.05)",textAlign:"center",zIndex:2},calendarAbove:{position:"absolute",bottom:"100%",left:0,padding:6,background:"white",border:"1px solid hsla(0, 0%, 0%, 0.15)",borderRadius:e.corners,boxShadow:"0 0 7px 5px hsla(0, 0%, 0%, 0.05)",textAlign:"center",zIndex:2},grid:{width:182,"&.hours":{height:223,width:96+2*e.corners,overflow:"auto",paddingRight:6},"&::-webkit-scrollbar":{width:e.corners<=2?4:2*e.corners},"&::-webkit-scrollbar-track":{background:(0,y["default"])(e.color).alpha(.05).rgbString(),boxShadow:"inset 0 0 3px rgba(0, 0, 0, 0.15)",borderRadius:e.corners},"&::-webkit-scrollbar-thumb":{borderRadius:e.corners,background:e.color,boxShadow:"inset 0 0 3px rgba(0, 0, 0, 0.3)"}},today:{display:"flex",justifyContent:"center",alignItems:"center",height:30,cursor:"pointer",border:"1px solid transparent",borderRadius:e.corners,marginTop:3,"&:hover":{borderColor:(0,y["default"])(e.color).alpha(.5).rgbString(),color:e.color}},cell:{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid transparent",borderRadius:e.corners,fontSize:15,cursor:"pointer","&:not(.selected):not(.header):hover":{backgroundColor:(0,y["default"])(e.color).alpha(.2).rgbString(),"&:not(.today)":{color:"hsl(0, 0%, 25%)"},"&.outside-range":{color:"#d0021b",backgroundColor:(0,y["default"])("#d0021b").alpha(.2).rgbString(),cursor:"not-allowed"}},"&.years":{width:58,height:38},"&.months":{width:58,height:38},"&.days":{width:26,height:26},"&.hours":{display:"flex",lineHeight:1.5},"&.header":{cursor:"default",color:(0,y["default"])(e.color).alpha(.4).rgbString(),fontWeight:700},"&.past":{opacity:.4},"&.future":{opacity:.4},"&.today":{fontWeight:700,border:"1px solid",borderColor:(0,y["default"])(e.color).alpha(.75).rgbString(),color:e.color},"&.selected":{backgroundColor:e.color,color:"white","&.outside-range":{backgroundColor:"#d0021b"}},"&:not(.selected).outside-range":{color:"#d0021b"}}}}function l(e){return{nav:{display:"flex",cursor:"pointer",lineHeight:"32px","& > div":{border:"1px solid",borderColor:"transparent",borderRadius:e.corners,"&:hover":{borderColor:(0,y["default"])(e.color).alpha(.5).rgbString(),color:e.color},"&.arrow":{flex:1,fontSize:24},"&.title":{flex:2}}}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=s;var p=o(21),c=n(p),d=o(19),f=n(d),h=o(14),y=n(h),m=o(5),b=n(m);o(8);var v=!1,g={}},function(e,t){e.exports=require("classnames")},function(e,t){e.exports=require("moment")},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Keys={ENTER:13,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40},t.Units={YEAR:"years",MONTH:"months",DAY:"days",HOUR:"hours"},t.Types={JS_DATE:"JS_DATE",MOMENT:"MOMENT",ISO:"ISO",STRING:"STRING"},t.Levels={years:{up:null,down:"months",nav:{unit:"years",span:10},key:{unit:"year",span:1}},months:{up:"years",down:"days",nav:{unit:"year",span:1},key:{unit:"month",span:1}},days:{up:"months",down:null,nav:{unit:"month",span:1},key:{unit:"day",span:1}},hours:{up:null,down:null,key:{unit:"minutes",span:30}}}},function(e,t){e.exports=require("jss")},function(e,t){e.exports=require("moment-range")},function(e,t){e.exports=require("react-dom")},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},u=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(1),p=n(l),c=o(9),d=n(c),f=o(20),h=n(f),y=o(5),m=n(y);o(8);var b=o(4),v=n(b),g=o(6),T=o(13),x=n(T),w=o(11),k=n(w),O=o(2),S=n(O),j=o(3),P=n(j),_=function(e){function t(e){r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.state={windowHeight:window.innerHeight},o}return s(t,e),u(t,[{key:"componentWillMount",value:function(){window.addEventListener("resize",this.updateDimensions.bind(this))}},{key:"componentDidMount",value:function(){this._isMounted=!0,this.scrollToHour(),this.updateDimensions()}},{key:"componentDidUpdate",value:function(e){this.props.above()||this.scrollToHour()}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,window.removeEventListener("resize",this.updateDimensions.bind(this))}},{key:"updateDimensions",value:function(){this._isMounted&&this.setState({windowHeight:window.innerHeight})}},{key:"scrollToHour",value:function(){if("hours"==this.props.level&&this.refs.selected){var e=d["default"].findDOMNode(this.refs.selected);e.parentNode.scrollTop=e.offsetTop-6}}},{key:"onNavigateCell",value:function(e){var t=g.Levels[this.props.level];t.down&&this.props.setLevel(t.down),this.props.onSelect(e,!t.down,t.key)}},{key:"onNavigateUp",value:function(){var e=g.Levels[this.props.level];e.up&&this.props.setLevel(e.up)}},{key:"onNavigateLeft",value:function(){var e=g.Levels[this.props.level].nav;this.props.onSelect(this.props.datetime.subtract(e.span,e.unit))}},{key:"onNavigateRight",value:function(){var e=g.Levels[this.props.level].nav;this.props.onSelect(this.props.datetime.add(e.span,e.unit))}},{key:"onToday",value:function(){var e=g.Levels[this.props.level];(0,m["default"])(this.props.datetime).isSame((0,m["default"])(),"day")?this.props.onSelect((0,m["default"])(),!e.down):this.props.onSelect((0,m["default"])())}},{key:"getTitle",value:function(e,t){t=t||(0,m["default"])();var o=function(){switch(e){case"years":var o=t.clone().subtract(4,"years"),n=t.clone().add(7,"years"),r=[];return(0,m["default"])().range(o,n).by(g.Units.YEAR,function(e){r.push({label:e.format("YYYY"),selected:e.isSame(t,"year")})}),{v:[r[0].label,r[r.length-1].label].join("-")};case"months":return{v:t.format("YYYY")};case"days":return{v:t.format("MMMM")};case"hours":return{v:null}}}();if("object"===("undefined"==typeof o?"undefined":a(o)))return o.v}},{key:"getCells",value:function(e,t){var o=this;switch(t=t||(0,m["default"])(),e){case"years":var n=function(){var e=t.clone().subtract(4,"years"),n=t.clone().add(7,"years"),r=[],i=(0,h["default"])(o.props,"options.format.year")||"YYYY";return(0,m["default"])().range(e,n).by(g.Units.YEAR,function(e){r.push({moment:e,label:e.format(i),selected:e.isSame(t,"year")})}),{v:r}}();if("object"===("undefined"==typeof n?"undefined":a(n)))return n.v;case"months":var r=function(){var e=t.clone().startOf("year"),n=t.clone().endOf("year"),r=[],i=(0,h["default"])(o.props,"options.format.month")||"MMM";return(0,m["default"])().range(e,n).by(g.Units.MONTH,function(e){r.push({moment:e,label:e.format(i),selected:e.isSame(t,"month")})}),{v:r}}();if("object"===("undefined"==typeof r?"undefined":a(r)))return r.v;case"days":var i=function(){var e=t.clone().startOf("month").weekday(0),n=t.clone().endOf("month").weekday(6),r=[],i=(0,h["default"])(o.props,"options.format.day")||"D";return m["default"].weekdaysMin().forEach(function(e){r.push({label:e,header:!0})}),(0,m["default"])().range(e,n).by(g.Units.DAY,function(e){r.push({moment:e,label:e.format(i),past:e.isBefore(t,"month"),future:e.isAfter(t,"month"),selected:e.isSame(t,"day"),today:e.isSame((0,m["default"])(),"day")})}),{v:r}}();if("object"===("undefined"==typeof i?"undefined":a(i)))return i.v;case"hours":var s=function(){var e=t.clone().startOf("day"),n=t.clone().endOf("day"),r=[],i=t.clone().subtract(31,"minutes"),s=t.clone().add(31,"minutes"),a=(0,h["default"])(o.props,"options.format.hour")||"h:mm a";return(0,m["default"])().range(e,n).by(g.Units.HOUR,function(e){r.push({moment:e,label:e.format(a),selected:e.isSame(t,"minute"),nearestBefore:e.isBetween(i,t),nearestAfter:e.isBetween(t,s)});var o=e.clone().add(30,"minutes");r.push({moment:o,label:o.format(a),selected:o.isSame(t,"minute"),nearestBefore:o.isBetween(i,t),nearestAfter:o.isBetween(t,s)})}),{v:r}}();if("object"===("undefined"==typeof s?"undefined":a(s)))return s.v}}},{key:"render",value:function(){var e=this,t=this.props,o=t.level,n=t.datetime,r=t.classes,i=t.inputRect,s=t.hideOutsideDateTimes,a=r.calendarBelow;return i.top+i.height+237>this.state.windowHeight&&(a=r.calendarAbove),p["default"].createElement("div",{className:a,onMouseDown:function(t){return e.props.above(!0)},onMouseUp:function(t){return e.props.above(!1)}},"hours"!=o&&p["default"].createElement(x["default"],{id:this.props.id,onPrev:this.onNavigateLeft.bind(this),onNext:this.onNavigateRight.bind(this),onTitle:this.onNavigateUp.bind(this),title:this.getTitle(o,n)}),p["default"].createElement("div",{className:(0,v["default"])(r.grid,o)},this.getCells(o,n).map(function(t,n){var i=void 0;switch(!0){case t.header:i="header";break;case t.past:i="past";break;case t.future:i="future";break;default:i="base"}return"hours"===o&&s&&!e.props.validate(t.moment,o)?null:p["default"].createElement(k["default"],{key:n,ref:t.selected||t.nearestBefore?"selected":null,label:t.label,level:o,type:i,selected:t.selected,today:t.today,moment:t.moment,onClick:e.onNavigateCell.bind(e),classes:r,invalid:e.props.validate(t.moment,o)})}).filter(function(e){return null!=e}),"hours"!=o&&p["default"].createElement("div",{className:r.today,onClick:this.onToday.bind(this)},(0,h["default"])(this.props,"options.format.today")||"Today")))}}]),t}(l.Component);_.PropTypes={datetime:l.PropTypes.object.isRequired,onSelect:l.PropTypes.func.isRequired,level:l.PropTypes.string.isRequired,setLevel:l.PropTypes.func.isRequired,onMouseDown:l.PropTypes.func,onMouseUp:l.PropTypes.func},_._isMounted=!1,t["default"]=(0,S["default"])(_,function(e,t){return(0,P["default"])("calendar",e,t)})},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(1),l=n(u),p=o(4),c=n(p),d=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,e),a(t,[{key:"render",value:function(){var e=this,t=(0,c["default"])(this.props.classes.cell,this.props.level,this.props.type,{selected:this.props.selected},{today:this.props.today},{"outside-range":!this.props.invalid});return l["default"].createElement("div",{className:t,onClick:function(){return e.props.onClick(e.props.moment)}},this.props.label)}}]),t}(u.Component);d.propTypes={label:u.PropTypes.string,level:u.PropTypes.string,type:u.PropTypes.string,selected:u.PropTypes.bool,today:u.PropTypes.bool,onClick:u.PropTypes.func,classes:u.PropTypes.object},t["default"]=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},u=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(1),p=n(l),c=o(9),d=n(c),f=o(5),h=n(f),y=o(4),m=n(y),b=o(7),v=n(b),g=o(17),T=n(g),x=o(15),w=n(x),k=o(18),O=n(k),S=o(16),j=n(S),P=o(6),_=o(10),C=n(_),D=o(2),E=n(D),M=o(3),q=n(M);v["default"].use((0,T["default"])(),(0,w["default"])(),(0,O["default"])(),(0,j["default"])());var R=/((\d{4}\-\d\d\-\d\d)[tT]([\d:\.]*)?)([zZ]|([+\-])(\d\d):?(\d\d))/,N=function(e){return(0,h["default"])(e).minutes()+60*(0,h["default"])(e).hours()},I=function(e){function t(e){r(this,t);var o=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.state={datetime:o.getDateTimeInput().datetime,input:o.getDateTimeInput().input,type:o.getDateTimeInput().type,visible:!1,level:o.getDefaultLevel()},o}return s(t,e),u(t,[{key:"componentWillReceiveProps",value:function(e){this.props!=e&&(this.validate(this.getDateTimeInput(e).datetime,null,!0),this.setState({datetime:this.getDateTimeInput(e).datetime,input:this.getDateTimeInput(e).input}))}},{key:"getDateTimeInput",value:function(e){e=e||this.props;var t=e.date||e.time||null,o=void 0,n=void 0,r=void 0;if(null===t)o=(0,h["default"])(),n=null,r=P.Types.MOMENT;else switch(o=this.parse(t),n=o.format(this.format(e)),"undefined"==typeof t?"undefined":a(t)){case"object":r=h["default"].isDate(t)?P.Types.JS_DATE:h["default"].isMoment(t)?P.Types.MOMENT:null;break;case"string":r=t.match(R)?P.Types.ISO:P.Types.STRING}return{datetime:o,input:n,type:r}}},{key:"getDefaultLevel",value:function(){return"undefined"!=typeof this.props.date?P.Units.DAY:"undefined"!=typeof this.props.time?P.Units.HOUR:(console.warn("Please set a date or time prop. It can be null but not undefined."),P.Units.DAY)}},{key:"format",value:function(e){return e=e||this.props,"undefined"!=typeof e.format?e.format:"undefined"!=typeof e.date?"MM-DD-YYYY":"undefined"!=typeof e.time?"h:mm a":null}},{key:"toggle",value:function(e){e!==this.state.visible&&("undefined"==typeof e&&(e=!this.state.visible),e!==this.state.visible&&this.setState({visible:e}))}},{key:"parse",value:function(e){if(null===e)return null;var t=(0,h["default"])(e,this.format(),!0);if(!t.isValid()){var o=new Date(e);isNaN(o.getTime())&&(o=this.state&&this.state.datetime||(0,h["default"])()),t=(0,h["default"])(o)}return t}},{key:"save",value:function(e){var t=this.state.datetime;"undefined"!=typeof this.props.date&&(e.hours(t.hours()),e.minutes(t.minutes())),"undefined"!=typeof this.props.time&&(e.date(t.date()),e.month(t.month()),e.year(t.year())),this.setState({datetime:e,input:e.format(this.format())}),this.validate(e,null,!0)&&this.commit(e)}},{key:"validate",value:function(e,t,o){var n=!1;return this.props.min&&(0,h["default"])(e).isBefore(this.props.min)&&(n=!0),this.props.max&&(0,h["default"])(e).isAfter(this.props.max)&&(n=!0),this.props.minTime&&N(e)<N(this.props.minTime)&&(n=!0),this.props.maxTime&&N(e)>N(this.props.maxTime)&&(n=!0),n&&"hours"!==t&&((0,h["default"])(e).isSame(this.props.min,t)||(0,h["default"])(e).isSame(this.props.max,t))&&(n=!1),!(!o||(this.setState({dateTimeExceedsValidRange:n}),!this.props.shouldTriggerOnChangeForDateTimeOutsideRange))||!n}},{key:"commit",value:function(e){var t=this.props.returnAs||this.state.type,o=void 0;switch(t){case P.Types.ISO:o=e.toISOString();break;case P.Types.JS_DATE:o=e.toDate();break;case P.Types.MOMENT:o=e;break;case P.Types.STRING:o=e.format(this.format())}this.props.onChangeDateTime&&this.props.onChangeDateTime(o)}},{key:"onClickInput",value:function(e){this.props.controlVisibility?this.props.onClick&&this.props.onClick(e):this.toggle(!0)}},{key:"onFocusInput",value:function(e){this.props.controlVisibility?this.props.onFocus&&this.props.onFocus(e):this.toggle(!0)}},{key:"onBlurInput",value:function(e){var t=this.state.datetime||(0,h["default"])();this.above?d["default"].findDOMNode(this._input).focus():this.props.closeOnBlur&&(this.toggle(!1),this.props.onBlur&&this.props.onBlur(e)),this.state.input!=this.state.datetime.format(this.format())&&(t=this.parse(this.state.input),t&&this.save(t))}},{key:"onChangeInput",value:function(e){this.props.onChange&&this.props.onChange(e);var t=e.target.value,o=(0,h["default"])(t,this.format(),!0);o.isValid()?this.save(o):""==t?(this.setState({datetime:null,input:""}),this.props.onChangeDateTime&&this.props.onChangeDateTime(null)):this.setState({input:t})}},{key:"onSelect",value:function(e,t,o){var n=t,r=this.state.visible,i=this.props,s=i.closeOnSelect,a=i.preventClickOnDateTimeOutsideRange;if(o?this.validate(e,o.unit)||(n=!1):this.validate(e)||(n=!1),!t||n!==!1||!a){var u=s&&n?!r:r;this.setState({visible:u}),this.save(e),this.props.onSelect&&this.props.onSelect(e,u)}}},{key:"onKeyDown",value:function(e){var t=this.state.datetime||(0,h["default"])(),o=P.Levels[this.state.level];switch(e){case P.Keys.UP:this.onSelect(t.subtract(o.key.span,o.key.unit));break;case P.Keys.DOWN:this.onSelect(t.add(o.key.span,o.key.unit));break;case P.Keys.ENTER:o.down?this.setState({level:o.down}):this.state.input==t.format(this.format())?this.validate(t)?this.toggle():this.toggle(!0):(this.state.visible||this.toggle(!0),t=this.parse(this.state.input),t&&this.save(t))}}},{key:"render",value:function(){var e=this,t=this.props,o=t.hideOutsideDateTimes,n=t.disabled,r=(0,m["default"])("react-kronos",this.props.id,this.props.classes.kronos),i=(0,m["default"])(this.props.classes.input,{"outside-range":this.state.dateTimeExceedsValidRange}),s=!n&&this.props.controlVisibility?this.props.visible:this.state.visible;return p["default"].createElement("div",{className:r},p["default"].createElement("input",{type:"text",ref:function(t){return e._input=t},value:this.state.input||"",onClick:this.onClickInput.bind(this),onFocus:this.onFocusInput.bind(this),onBlur:this.onBlurInput.bind(this),onKeyDown:function(t){return e.onKeyDown(t.keyCode)},onChange:this.onChangeInput.bind(this),placeholder:this.props.placeholder,name:this.props.name,className:i,disabled:n}),s&&p["default"].createElement(C["default"],{id:this.props.id,datetime:this.state.datetime,onSelect:this.onSelect.bind(this),above:function(t){return"undefined"==typeof t?e.above:e.above=t},level:this.state.level,setLevel:function(t){return e.setState({level:t})},validate:this.validate.bind(this),options:this.props.options,inputRect:this._input.getClientRects()[0],hideOutsideDateTimes:o}))}}]),t}(l.Component);I.propTypes={date:l.PropTypes.any,time:l.PropTypes.any,min:l.PropTypes.any,max:l.PropTypes.any,minTime:l.PropTypes.any,maxTime:l.PropTypes.any,shouldTriggerOnChangeForDateTimeOutsideRange:l.PropTypes.bool,preventClickOnDateTimeOutsideRange:l.PropTypes.bool,format:l.PropTypes.string,onChangeDateTime:l.PropTypes.func,returnAs:l.PropTypes.oneOf([P.Types.ISO,P.Types.JS_DATE,P.Types.MOMENT,P.Types.STRING]),closeOnSelect:l.PropTypes.bool,closeOnBlur:l.PropTypes.bool,placeholder:l.PropTypes.string,name:l.PropTypes.string,options:l.PropTypes.object,hideOutsideDateTimes:l.PropTypes.bool,controlVisibility:l.PropTypes.bool,visible:l.PropTypes.bool,onClick:l.PropTypes.func,onFocus:l.PropTypes.func,onBlur:l.PropTypes.func,onChange:l.PropTypes.func,onSelect:l.PropTypes.func},I.defaultProps={closeOnSelect:!0,closeOnBlur:!0,controlVisibility:!1,shouldTriggerOnChangeForDateTimeOutsideRange:!1,preventClickOnDateTimeOutsideRange:!1,visible:!1},I.above=!1,t["default"]=(0,E["default"])(I,function(e,t){return(0,q["default"])("index",e,t)})},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(1),l=n(u),p=o(2),c=n(p),d=o(3),f=n(d),h=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,e),a(t,[{key:"render",value:function(){return l["default"].createElement("div",{className:this.props.classes.nav},l["default"].createElement("div",{className:"arrow",onClick:this.props.onPrev},"«"),l["default"].createElement("div",{className:"title",onClick:this.props.onTitle},this.props.title),l["default"].createElement("div",{className:"arrow",onClick:this.props.onNext},"»"))}}]),t}(u.Component);h.propTypes={onPrev:u.PropTypes.func,onNext:u.PropTypes.func,onTitle:u.PropTypes.func,title:u.PropTypes.string},t["default"]=(0,c["default"])(h,function(e,t){return(0,f["default"])("navigation",e,t)})},function(e,t){e.exports=require("color")},function(e,t){e.exports=require("jss-camel-case")},function(e,t){e.exports=require("jss-default-unit")},function(e,t){e.exports=require("jss-nested")},function(e,t){e.exports=require("jss-vendor-prefixer")},function(e,t){e.exports=require("lodash/assign")},function(e,t){e.exports=require("lodash/get")},function(e,t){e.exports=require("lodash/omit")}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("classnames"),require("moment"),require("jss"),require("moment-range"),require("react-dom"),require("color"),require("jss-camel-case"),require("jss-default-unit"),require("jss-nested"),require("jss-vendor-prefixer"),require("lodash/assign"),require("lodash/get"),require("lodash/omit"));else if("function"==typeof define&&define.amd)define(["react","classnames","moment","jss","moment-range","react-dom","color","jss-camel-case","jss-default-unit","jss-nested","jss-vendor-prefixer","lodash/assign","lodash/get","lodash/omit"],t);else{var o="object"==typeof exports?t(require("react"),require("classnames"),require("moment"),require("jss"),require("moment-range"),require("react-dom"),require("color"),require("jss-camel-case"),require("jss-default-unit"),require("jss-nested"),require("jss-vendor-prefixer"),require("lodash/assign"),require("lodash/get"),require("lodash/omit")):t(e.react,e.classnames,e.moment,e.jss,e["moment-range"],e["react-dom"],e.color,e["jss-camel-case"],e["jss-default-unit"],e["jss-nested"],e["jss-vendor-prefixer"],e["lodash/assign"],e["lodash/get"],e["lodash/omit"]);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,function(e,t,o,n,r,s,i,a,u,l,p,c,d,f){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){e.exports=o(12)},function(e,t){e.exports=require("react")},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t,o){function n(e,t){return f.default.createStyleSheet(e,t).attach()}function a(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,o="x"===e?t:3&t|8;return o.toString(16)})}var p=function(p){function d(){return r(this,d),s(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return i(d,p),l(d,[{key:"componentWillMount",value:function(){var e=this.props.id?this.props.id:a(),r="function"==typeof t?t(this.props,e):t,s="function"==typeof o?o(this.props,e):o;this.sheet=n(r,s),this.uuid=e}},{key:"componentWillUnmount",value:function(){this.sheet.detach(),this.sheet=null}},{key:"classSet",value:function(e){return Object.keys(e).filter(function(t){return e[t]}).map(function(e){return this.sheet.classes[e]||e}).join(" ")}},{key:"render",value:function(){return c.default.createElement(e,u({id:this.uuid,ref:"kronos",classes:this.sheet.classes,classSet:this.classSet},this.props))}}]),d}(c.default.Component);return p}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},l=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}();t.default=a;var p=o(1),c=n(p),d=o(7),f=n(d)},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e){v||(e&&e.moment?e.moment.settings?b.default.locale(e.moment.lang,e.moment.settings):b.default.locale(e.moment.lang):b.default.updateLocale("en",{week:{dow:1},weekdaysMin:["M","T","W","T","F","S","S"]})),v=!0}function s(e,t){g[t]=(0,c.default)(e,"moment")}function i(e,t,o){r(t.options),t.options&&s(t.options,o);var n={color:"#1e7e9e",corners:4,font:"Source Sans Pro"},i=(0,f.default)(n,g[o]),p=void 0;switch(e){case"index":p=a(i);break;case"calendar":p=u(i);break;case"navigation":p=l(i);break;case"cell":p=cell(i)}return p}function a(e){return{kronos:{position:"relative",display:"flex",color:"hsl(0, 0%, 50%)","& *":{fontFamily:e.font,margin:0,padding:0,boxSizing:"border-box",userSelect:"none"}},input:{border:"1px solid transparent",borderRadius:e.corners,borderColor:(0,y.default)(e.color).alpha(.2).rgbString(),fontSize:16,padding:"3px 6px",background:"white","&.outside-range":{color:"white",background:"#d0021b"},"&:focus":{outline:"none",borderColor:(0,y.default)(e.color).alpha(.5).rgbString()}}}}function u(e){return{calendarBelow:{position:"absolute",top:"100%",left:0,padding:6,background:"white",border:"1px solid hsla(0, 0%, 0%, 0.15)",borderRadius:e.corners,boxShadow:"0 0 7px 5px hsla(0, 0%, 0%, 0.05)",textAlign:"center",zIndex:2},calendarAbove:{position:"absolute",bottom:"100%",left:0,padding:6,background:"white",border:"1px solid hsla(0, 0%, 0%, 0.15)",borderRadius:e.corners,boxShadow:"0 0 7px 5px hsla(0, 0%, 0%, 0.05)",textAlign:"center",zIndex:2},grid:{width:182,"&.hours":{height:223,width:96+2*e.corners,overflow:"auto",paddingRight:6},"&::-webkit-scrollbar":{width:e.corners<=2?4:2*e.corners},"&::-webkit-scrollbar-track":{background:(0,y.default)(e.color).alpha(.05).rgbString(),boxShadow:"inset 0 0 3px rgba(0, 0, 0, 0.15)",borderRadius:e.corners},"&::-webkit-scrollbar-thumb":{borderRadius:e.corners,background:e.color,boxShadow:"inset 0 0 3px rgba(0, 0, 0, 0.3)"}},today:{display:"flex",justifyContent:"center",alignItems:"center",height:30,cursor:"pointer",border:"1px solid transparent",borderRadius:e.corners,marginTop:3,"&:hover":{borderColor:(0,y.default)(e.color).alpha(.5).rgbString(),color:e.color}},cell:{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"1px solid transparent",borderRadius:e.corners,fontSize:15,cursor:"pointer","&:not(.selected):not(.header):hover":{backgroundColor:(0,y.default)(e.color).alpha(.2).rgbString(),"&:not(.today)":{color:"hsl(0, 0%, 25%)"},"&.outside-range":{color:"#d0021b",backgroundColor:(0,y.default)("#d0021b").alpha(.2).rgbString(),cursor:"not-allowed"}},"&.years":{width:58,height:38},"&.months":{width:58,height:38},"&.days":{width:26,height:26},"&.hours":{display:"flex",lineHeight:1.5},"&.header":{cursor:"default",color:(0,y.default)(e.color).alpha(.4).rgbString(),fontWeight:700},"&.past":{opacity:.4},"&.future":{opacity:.4},"&.today":{fontWeight:700,border:"1px solid",borderColor:(0,y.default)(e.color).alpha(.75).rgbString(),color:e.color},"&.selected":{backgroundColor:e.color,color:"white","&.outside-range":{backgroundColor:"#d0021b"}},"&:not(.selected).outside-range":{color:"#d0021b"}}}}function l(e){return{nav:{display:"flex",cursor:"pointer",lineHeight:"32px","& > div":{border:"1px solid",borderColor:"transparent",borderRadius:e.corners,"&:hover":{borderColor:(0,y.default)(e.color).alpha(.5).rgbString(),color:e.color},"&.arrow":{flex:1,fontSize:24},"&.title":{flex:2}}}}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var p=o(21),c=n(p),d=o(19),f=n(d),h=o(14),y=n(h),m=o(5),b=n(m);o(8);var v=!1,g={}},function(e,t){e.exports=require("classnames")},function(e,t){e.exports=require("moment")},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Keys={ENTER:13,ESC:27,LEFT:37,UP:38,RIGHT:39,DOWN:40},t.Units={YEAR:"years",MONTH:"months",DAY:"days",HOUR:"hours"},t.Types={JS_DATE:"JS_DATE",MOMENT:"MOMENT",ISO:"ISO",STRING:"STRING"},t.Levels={years:{up:null,down:"months",nav:{unit:"years",span:10},key:{unit:"year",span:1}},months:{up:"years",down:"days",nav:{unit:"year",span:1},key:{unit:"month",span:1}},days:{up:"months",down:null,nav:{unit:"month",span:1},key:{unit:"day",span:1}},hours:{up:null,down:null,key:{unit:"minutes",span:30}}}},function(e,t){e.exports=require("jss")},function(e,t){e.exports=require("moment-range")},function(e,t){e.exports=require("react-dom")},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(1),l=n(u),p=o(9),c=n(p),d=o(20),f=n(d),h=o(5),y=n(h);o(8);var m=o(4),b=n(m),v=o(6),g=o(13),T=n(g),x=o(11),w=n(x),k=o(2),O=n(k),S=o(3),P=n(S),_=function(e){function t(e){r(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.state={windowHeight:window.innerHeight,virtualdatetime:e.datetime},o}return i(t,e),a(t,[{key:"componentWillMount",value:function(){window.addEventListener("resize",this.updateDimensions.bind(this))}},{key:"componentDidMount",value:function(){this._isMounted=!0,this.scrollToHour(),this.updateDimensions()}},{key:"componentDidUpdate",value:function(e){this.props.above()||this.scrollToHour()}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,window.removeEventListener("resize",this.updateDimensions.bind(this))}},{key:"updateDimensions",value:function(){this._isMounted&&this.setState({windowHeight:window.innerHeight})}},{key:"scrollToHour",value:function(){if("hours"==this.props.level&&this.refs.selected){var e=c.default.findDOMNode(this.refs.selected);e.parentNode.scrollTop=e.offsetTop-6}}},{key:"onNavigateCell",value:function(e){var t=v.Levels[this.props.level];t.down&&this.props.setLevel(t.down),this.props.onSelect(e,!t.down,t.key)}},{key:"onNavigateUp",value:function(){var e=v.Levels[this.props.level];e.up&&this.props.setLevel(e.up)}},{key:"onNavigateLeft",value:function(){var e=this,t=v.Levels[this.props.level].nav;this.setState(function(){return{virtualdatetime:e.state.virtualdatetime.subtract(t.span,t.unit)}})}},{key:"onNavigateRight",value:function(){var e=this,t=v.Levels[this.props.level].nav;this.setState(function(){return{virtualdatetime:e.state.virtualdatetime.add(t.span,t.unit)}})}},{key:"onToday",value:function(){var e=v.Levels[this.props.level];(0,y.default)(this.props.datetime).isSame((0,y.default)(),"day")?this.props.onSelect((0,y.default)(),!e.down):this.props.onSelect((0,y.default)())}},{key:"getTitle",value:function(e,t){switch(t=t||(0,y.default)(),e){case"years":var o=t.clone().subtract(4,"years"),n=t.clone().add(7,"years"),r=[];return(0,y.default)().range(o,n).by(v.Units.YEAR,function(e){r.push({label:e.format("YYYY"),selected:e.isSame(t,"year")})}),[r[0].label,r[r.length-1].label].join("-");case"months":return t.format("YYYY");case"days":return t.format("MMMM");case"hours":return null}}},{key:"getCells",value:function(e,t){switch(t=t||(0,y.default)(),e){case"years":var o=t.clone().subtract(4,"years"),n=t.clone().add(7,"years"),r=[],s=(0,f.default)(this.props,"options.format.year")||"YYYY";return(0,y.default)().range(o,n).by(v.Units.YEAR,function(e){r.push({moment:e,label:e.format(s),selected:e.isSame(t,"year")})}),r;case"months":var i=t.clone().startOf("year"),a=t.clone().endOf("year"),u=[],l=(0,f.default)(this.props,"options.format.month")||"MMM";return(0,y.default)().range(i,a).by(v.Units.MONTH,function(e){u.push({moment:e,label:e.format(l),selected:e.isSame(t,"month")})}),u;case"days":var p=t.clone().startOf("month").weekday(0),c=t.clone().endOf("month").weekday(6),d=[],h=(0,f.default)(this.props,"options.format.day")||"D";return y.default.weekdaysMin().forEach(function(e){d.push({label:e,header:!0})}),(0,y.default)().range(p,c).by(v.Units.DAY,function(e){d.push({moment:e,label:e.format(h),past:e.isBefore(t,"month"),future:e.isAfter(t,"month"),selected:e.isSame(t,"day"),today:e.isSame((0,y.default)(),"day")})}),d;case"hours":var m=t.clone().startOf("day"),b=t.clone().endOf("day"),g=[],T=t.clone().subtract(31,"minutes"),x=t.clone().add(31,"minutes"),w=(0,f.default)(this.props,"options.format.hour")||"h:mm a";return(0,y.default)().range(m,b).by(v.Units.HOUR,function(e){g.push({moment:e,label:e.format(w),selected:e.isSame(t,"minute"),nearestBefore:e.isBetween(T,t),nearestAfter:e.isBetween(t,x)});var o=e.clone().add(30,"minutes");g.push({moment:o,label:o.format(w),selected:o.isSame(t,"minute"),nearestBefore:o.isBetween(T,t),nearestAfter:o.isBetween(t,x)})}),g}}},{key:"render",value:function(){var e=this,t=this.props,o=t.level,n=(t.datetime,t.classes),r=t.inputRect,s=t.hideOutsideDateTimes,i=t.className,a=this.state.virtualdatetime,u=n.calendarBelow;return r.top+r.height+237>this.state.windowHeight&&(u=n.calendarAbove),l.default.createElement("div",{className:(0,b.default)(u,i),onMouseDown:function(t){return e.props.above(!0)},onMouseUp:function(t){return e.props.above(!1)}},"hours"!=o&&l.default.createElement(T.default,{id:this.props.id,onPrev:this.onNavigateLeft.bind(this),onNext:this.onNavigateRight.bind(this),onTitle:this.onNavigateUp.bind(this),title:this.getTitle(o,a)}),l.default.createElement("div",{className:(0,b.default)(n.grid,o)},this.getCells(o,a).map(function(t,r){var i=void 0;switch(!0){case t.header:i="header";break;case t.past:i="past";break;case t.future:i="future";break;default:i="base"}return"hours"===o&&s&&!e.props.validate(t.moment,o)?null:l.default.createElement(w.default,{key:r,ref:t.selected||t.nearestBefore?"selected":null,label:t.label,level:o,type:i,selected:t.selected,today:t.today,moment:t.moment,onClick:e.onNavigateCell.bind(e),classes:n,invalid:e.props.validate(t.moment,o)})}).filter(function(e){return null!=e}),"hours"!=o&&l.default.createElement("div",{className:n.today,onClick:this.onToday.bind(this)},(0,f.default)(this.props,"options.format.today")||"Today")))}}]),t}(u.Component);_.PropTypes={datetime:u.PropTypes.object.isRequired,onSelect:u.PropTypes.func.isRequired,level:u.PropTypes.string.isRequired,setLevel:u.PropTypes.func.isRequired,onMouseDown:u.PropTypes.func,onMouseUp:u.PropTypes.func},_._isMounted=!1,t.default=(0,O.default)(_,function(e,t){return(0,P.default)("calendar",e,t)})},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(1),l=n(u),p=o(4),c=n(p),d=function(e){function t(){return r(this,t),s(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),a(t,[{key:"render",value:function(){var e=this,t=(0,c.default)(this.props.classes.cell,this.props.level,this.props.type,{selected:this.props.selected},{today:this.props.today},{"outside-range":!this.props.invalid});return l.default.createElement("div",{className:t,onClick:function(){return e.props.onClick(e.props.moment)}},this.props.label)}}]),t}(u.Component);d.propTypes={label:u.PropTypes.string,level:u.PropTypes.string,type:u.PropTypes.string,selected:u.PropTypes.bool,today:u.PropTypes.bool,onClick:u.PropTypes.func,classes:u.PropTypes.object},t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),l=o(1),p=n(l),c=o(9),d=n(c),f=o(5),h=n(f),y=o(4),m=n(y),b=o(7),v=n(b),g=o(17),T=n(g),x=o(15),w=n(x),k=o(18),O=n(k),S=o(16),P=n(S),_=o(6),j=o(10),C=n(j),D=o(2),E=n(D),M=o(3),q=n(M);v.default.use((0,T.default)(),(0,w.default)(),(0,O.default)(),(0,P.default)());var R=/((\d{4}\-\d\d\-\d\d)[tT]([\d:\.]*)?)([zZ]|([+\-])(\d\d):?(\d\d))/,N=function(e){return(0,h.default)(e).minutes()+60*(0,h.default)(e).hours()},I=function(e){function t(e){r(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.state={datetime:o.getDateTimeInput().datetime,input:o.getDateTimeInput().input,type:o.getDateTimeInput().type,visible:!1,level:o.getDefaultLevel()},o}return i(t,e),u(t,[{key:"componentWillReceiveProps",value:function(e){this.props!=e&&(this.validate(this.getDateTimeInput(e).datetime,null,!0),this.setState({datetime:this.getDateTimeInput(e).datetime,input:this.getDateTimeInput(e).input}))}},{key:"getDateTimeInput",value:function(e){e=e||this.props;var t=e.date||e.time||null,o=void 0,n=void 0,r=void 0;if(null===t)o=(0,h.default)(),n=null,r=_.Types.MOMENT;else switch(o=this.parse(t),n=o.format(this.format(e)),"undefined"==typeof t?"undefined":a(t)){case"object":r=h.default.isDate(t)?_.Types.JS_DATE:h.default.isMoment(t)?_.Types.MOMENT:null;break;case"string":r=t.match(R)?_.Types.ISO:_.Types.STRING}return{datetime:o,input:n,type:r}}},{key:"getDefaultLevel",value:function(){return"undefined"!=typeof this.props.date?_.Units.DAY:"undefined"!=typeof this.props.time?_.Units.HOUR:(console.warn("Please set a date or time prop. It can be null but not undefined."),_.Units.DAY)}},{key:"format",value:function(e){return e=e||this.props,"undefined"!=typeof e.format?e.format:"undefined"!=typeof e.date?"MM-DD-YYYY":"undefined"!=typeof e.time?"h:mm a":null}},{key:"toggle",value:function(e){e!==this.state.visible&&("undefined"==typeof e&&(e=!this.state.visible),e!==this.state.visible&&this.setState({visible:e}))}},{key:"parse",value:function(e){if(null===e)return null;var t=(0,h.default)(e,this.format(),!0);if(!t.isValid()){var o=new Date(e);isNaN(o.getTime())&&(o=this.state&&this.state.datetime||(0,h.default)()),t=(0,h.default)(o)}return t}},{key:"save",value:function(e){var t=this.state.datetime;"undefined"!=typeof this.props.date&&(e.hours(t.hours()),e.minutes(t.minutes())),"undefined"!=typeof this.props.time&&(e.date(t.date()),e.month(t.month()),e.year(t.year())),this.setState({datetime:e,input:e.format(this.format())}),this.validate(e,null,!0)&&this.commit(e)}},{key:"validate",value:function(e,t,o){var n=!1;return this.props.min&&(0,h.default)(e).isBefore(this.props.min)&&(n=!0),this.props.max&&(0,h.default)(e).isAfter(this.props.max)&&(n=!0),this.props.minTime&&N(e)<N(this.props.minTime)&&(n=!0),this.props.maxTime&&N(e)>N(this.props.maxTime)&&(n=!0),n&&"hours"!==t&&((0,h.default)(e).isSame(this.props.min,t)||(0,h.default)(e).isSame(this.props.max,t))&&(n=!1),!(!o||(this.setState({dateTimeExceedsValidRange:n}),!this.props.shouldTriggerOnChangeForDateTimeOutsideRange))||!n}},{key:"commit",value:function(e){var t=this.props.returnAs||this.state.type,o=void 0;switch(t){case _.Types.ISO:o=e.toISOString();break;case _.Types.JS_DATE:o=e.toDate();break;case _.Types.MOMENT:o=e;break;case _.Types.STRING:o=e.format(this.format())}this.props.onChangeDateTime&&this.props.onChangeDateTime(o)}},{key:"onClickInput",value:function(e){this.props.controlVisibility?this.props.onClick&&this.props.onClick(e):this.toggle(!0)}},{key:"onFocusInput",value:function(e){this.props.controlVisibility?this.props.onFocus&&this.props.onFocus(e):this.toggle(!0)}},{key:"onBlurInput",value:function(e){var t=this.state.datetime||(0,h.default)();this.above?d.default.findDOMNode(this._input).focus():this.props.closeOnBlur&&(this.toggle(!1),this.props.onBlur&&this.props.onBlur(e)),this.state.input!=this.state.datetime.format(this.format())&&(t=this.parse(this.state.input),t&&this.save(t))}},{key:"onChangeInput",value:function(e){this.props.onChange&&this.props.onChange(e);var t=e.target.value,o=(0,h.default)(t,this.format(),!0);o.isValid()?this.save(o):""==t?(this.setState({datetime:null,input:""}),this.props.onChangeDateTime&&this.props.onChangeDateTime(null)):this.setState({input:t})}},{key:"onSelect",value:function(e,t,o){var n=t,r=this.state.visible,s=this.props,i=s.closeOnSelect,a=s.preventClickOnDateTimeOutsideRange;if(o?this.validate(e,o.unit)||(n=!1):this.validate(e)||(n=!1),!t||n!==!1||!a){var u=i&&n?!r:r;this.setState({visible:u}),this.save(e),this.props.onSelect&&this.props.onSelect(e,u)}}},{key:"onKeyDown",value:function(e){var t=this.state.datetime||(0,h.default)(),o=_.Levels[this.state.level];switch(e){case _.Keys.UP:this.onSelect(t.subtract(o.key.span,o.key.unit));break;case _.Keys.DOWN:this.onSelect(t.add(o.key.span,o.key.unit));break;case _.Keys.ENTER:o.down?this.setState({level:o.down}):this.state.input==t.format(this.format())?this.validate(t)?this.toggle():this.toggle(!0):(this.state.visible||this.toggle(!0),t=this.parse(this.state.input),t&&this.save(t))}}},{key:"render",value:function(){var e=this,t=this.props,o=t.hideOutsideDateTimes,n=t.disabled,r=(0,m.default)("react-kronos",this.props.id,this.props.classes.kronos),s=(0,m.default)(this.props.classes.input,{"outside-range":this.state.dateTimeExceedsValidRange}),i=!n&&this.props.controlVisibility?this.props.visible:this.state.visible;return p.default.createElement("div",{className:r},p.default.createElement("input",{type:"text",ref:function(t){return e._input=t},value:this.state.input||"",onClick:this.onClickInput.bind(this),onFocus:this.onFocusInput.bind(this),onBlur:this.onBlurInput.bind(this),onKeyDown:function(t){return e.onKeyDown(t.keyCode)},onChange:this.onChangeInput.bind(this),placeholder:this.props.placeholder,name:this.props.name,className:s,disabled:n}),i&&p.default.createElement(C.default,{id:this.props.id,datetime:this.state.datetime,onSelect:this.onSelect.bind(this),above:function(t){return"undefined"==typeof t?e.above:e.above=t},level:this.state.level,setLevel:function(t){return e.setState({level:t})},validate:this.validate.bind(this),options:this.props.options,inputRect:this._input.getClientRects()[0],hideOutsideDateTimes:o,className:this.props.classes.calendar}))}}]),t}(l.Component);I.propTypes={date:l.PropTypes.any,time:l.PropTypes.any,min:l.PropTypes.any,max:l.PropTypes.any,minTime:l.PropTypes.any,maxTime:l.PropTypes.any,shouldTriggerOnChangeForDateTimeOutsideRange:l.PropTypes.bool,preventClickOnDateTimeOutsideRange:l.PropTypes.bool,format:l.PropTypes.string,onChangeDateTime:l.PropTypes.func,returnAs:l.PropTypes.oneOf([_.Types.ISO,_.Types.JS_DATE,_.Types.MOMENT,_.Types.STRING]),classes:l.PropTypes.shape({kronos:l.PropTypes.string,input:l.PropTypes.string,calendar:l.PropTypes.string}),closeOnSelect:l.PropTypes.bool,closeOnBlur:l.PropTypes.bool,placeholder:l.PropTypes.string,name:l.PropTypes.string,options:l.PropTypes.object,hideOutsideDateTimes:l.PropTypes.bool,controlVisibility:l.PropTypes.bool,visible:l.PropTypes.bool,onClick:l.PropTypes.func,onFocus:l.PropTypes.func,onBlur:l.PropTypes.func,onChange:l.PropTypes.func,onSelect:l.PropTypes.func},I.defaultProps={closeOnSelect:!0,closeOnBlur:!0,controlVisibility:!1,shouldTriggerOnChangeForDateTimeOutsideRange:!1,preventClickOnDateTimeOutsideRange:!1,visible:!1},I.above=!1,t.default=(0,E.default)(I,function(e,t){return(0,q.default)("index",e,t)})},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),u=o(1),l=n(u),p=o(2),c=n(p),d=o(3),f=n(d),h=function(e){function t(){return r(this,t),s(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),a(t,[{key:"render",value:function(){return l.default.createElement("div",{className:this.props.classes.nav},l.default.createElement("div",{className:"arrow",onClick:this.props.onPrev},"«"),l.default.createElement("div",{className:"title",onClick:this.props.onTitle},this.props.title),l.default.createElement("div",{className:"arrow",onClick:this.props.onNext},"»"))}}]),t}(u.Component);h.propTypes={onPrev:u.PropTypes.func,onNext:u.PropTypes.func,onTitle:u.PropTypes.func,title:u.PropTypes.string},t.default=(0,c.default)(h,function(e,t){return(0,f.default)("navigation",e,t)})},function(e,t){e.exports=require("color")},function(e,t){e.exports=require("jss-camel-case")},function(e,t){e.exports=require("jss-default-unit")},function(e,t){e.exports=require("jss-nested")},function(e,t){e.exports=require("jss-vendor-prefixer")},function(e,t){e.exports=require("lodash/assign")},function(e,t){e.exports=require("lodash/get")},function(e,t){e.exports=require("lodash/omit")}])}); |
{ | ||
"name": "@commander-lol/react-kronos", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "A fast, intuitive, and elegant date and time picker for React.", | ||
@@ -15,3 +15,4 @@ "main": "dist/bundle.js", | ||
"clean:examples": "rimraf examples/bundle.*", | ||
"push_examples": "./scripts/push_ghpages" | ||
"push_examples": "./scripts/push_ghpages", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -18,0 +19,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
88026
20
1401