react-kronos
Advanced tools
Comparing version 1.4.2 to 1.5.0
Changelog | ||
========= | ||
## 1.5.0 | ||
- [feature] added `hideOutsideDateTimes` to hide times that cannot be selected [#45](https://github.com/dubert/react-kronos/pull/45) (thanks [Commander-lol](https://github.com/Commander-lol)) | ||
- [feature] added `timeStep` prop to configure the number of minutes in an interval [#48](https://github.com/dubert/react-kronos/issues/48) (thanks [ochervak](https://github.com/ochervak)) | ||
## 1.4.2 | ||
@@ -5,0 +10,0 @@ |
@@ -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 n="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 o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,function(e,t,n,o,r,s,i,a,u,l,p,c,d,f){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(12)},function(e,t){e.exports=require("react")},function(e,t,n){"use strict";function o(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,n){function o(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,n="x"===e?t:3&t|8;return n.toString(16)})}var p=function(p){function d(){return r(this,d),s(this,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 n?n(this.props,e):n;this.sheet=o(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 n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();t["default"]=a;var p=n(1),c=o(p),d=n(7),f=o(d)},function(e,t,n){"use strict";function o(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,n){r(t.options),t.options&&s(t.options,n);var o={color:"#1e7e9e",corners:4,font:"Source Sans Pro"},i=(0,f["default"])(o,g[n]),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=n(21),c=o(p),d=n(19),f=o(d),h=n(14),y=o(h),m=n(5),b=o(m);n(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,n){"use strict";function o(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?"symbol":typeof e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(1),p=o(l),c=n(9),d=o(c),f=n(20),h=o(f),y=n(5),m=o(y);n(8);var b=n(4),v=o(b),g=n(6),T=n(13),x=o(T),w=n(11),k=o(w),O=n(2),S=o(O),j=n(3),P=o(j),C=function(e){function t(e){r(this,t);var n=s(this,Object.getPrototypeOf(t).call(this,e));return n.state={windowHeight:window.innerHeight},n}return i(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 n=function(){switch(e){case"years":var n=t.clone().subtract(4,"years"),o=t.clone().add(7,"years"),r=[];return(0,m["default"])().range(n,o).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 n?"undefined":a(n)))return n.v}},{key:"getCells",value:function(e,t){var n=this;switch(t=t||(0,m["default"])(),e){case"years":var o=function(){var e=t.clone().subtract(4,"years"),o=t.clone().add(7,"years"),r=[],s=(0,h["default"])(n.props,"options.format.year")||"YYYY";return(0,m["default"])().range(e,o).by(g.Units.YEAR,function(e){r.push({moment:e,label:e.format(s),selected:e.isSame(t,"year")})}),{v:r}}();if("object"===("undefined"==typeof o?"undefined":a(o)))return o.v;case"months":var r=function(){var e=t.clone().startOf("year"),o=t.clone().endOf("year"),r=[],s=(0,h["default"])(n.props,"options.format.month")||"MMM";return(0,m["default"])().range(e,o).by(g.Units.MONTH,function(e){r.push({moment:e,label:e.format(s),selected:e.isSame(t,"month")})}),{v:r}}();if("object"===("undefined"==typeof r?"undefined":a(r)))return r.v;case"days":var s=function(){var e=t.clone().startOf("month").weekday(0),o=t.clone().endOf("month").weekday(6),r=[],s=(0,h["default"])(n.props,"options.format.day")||"D";return m["default"].weekdaysMin().forEach(function(e){r.push({label:e,header:!0})}),(0,m["default"])().range(e,o).by(g.Units.DAY,function(e){r.push({moment:e,label:e.format(s),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 s?"undefined":a(s)))return s.v;case"hours":var i=function(){var e=t.clone().startOf("day"),o=t.clone().endOf("day"),r=[],s=t.clone().subtract(31,"minutes"),i=t.clone().add(31,"minutes"),a=(0,h["default"])(n.props,"options.format.hour")||"h:mm a";return(0,m["default"])().range(e,o).by(g.Units.HOUR,function(e){r.push({moment:e,label:e.format(a),selected:e.isSame(t,"minute"),nearestBefore:e.isBetween(s,t),nearestAfter:e.isBetween(t,i)});var n=e.clone().add(30,"minutes");r.push({moment:n,label:n.format(a),selected:n.isSame(t,"minute"),nearestBefore:n.isBetween(s,t),nearestAfter:n.isBetween(t,i)})}),{v:r}}();if("object"===("undefined"==typeof i?"undefined":a(i)))return i.v}}},{key:"render",value:function(){var e=this,t=this.props,n=t.level,o=t.datetime,r=t.classes,s=t.inputRect,i=r.calendarBelow;return s.top+s.height+237>this.state.windowHeight&&(i=r.calendarAbove),p["default"].createElement("div",{className:i,onMouseDown:function(t){return e.props.above(!0)},onMouseUp:function(t){return e.props.above(!1)}},"hours"!=n&&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(n,o)}),p["default"].createElement("div",{className:(0,v["default"])(r.grid,n)},this.getCells(n,o).map(function(t,o){var s=void 0;switch(!0){case t.header:s="header";break;case t.past:s="past";break;case t.future:s="future";break;default:s="base"}return p["default"].createElement(k["default"],{key:o,ref:t.selected||t.nearestBefore?"selected":null,label:t.label,level:n,type:s,selected:t.selected,today:t.today,moment:t.moment,onClick:e.onNavigateCell.bind(e),classes:r,invalid:e.props.validate(t.moment,n)})}),"hours"!=n&&p["default"].createElement("div",{className:r.today,onClick:this.onToday.bind(this)},(0,h["default"])(this.props,"options.format.today")||"Today")))}}]),t}(l.Component);C.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},C._isMounted=!1,t["default"]=(0,S["default"])(C,function(e,t){return(0,P["default"])("calendar",e,t)})},function(e,t,n){"use strict";function o(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 n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(1),l=o(u),p=n(4),c=o(p),d=function(e){function t(){return r(this,t),s(this,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,n){"use strict";function o(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?"symbol":typeof e},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(1),p=o(l),c=n(9),d=o(c),f=n(5),h=o(f),y=n(4),m=o(y),b=n(7),v=o(b),g=n(17),T=o(g),x=n(15),w=o(x),k=n(18),O=o(k),S=n(16),j=o(S),P=n(6),C=n(10),_=o(C),E=n(2),M=o(E),D=n(3),q=o(D);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 n=s(this,Object.getPrototypeOf(t).call(this,e));return n.state={datetime:n.getDateTimeInput().datetime,input:n.getDateTimeInput().input,type:n.getDateTimeInput().type,visible:!1,level:n.getDefaultLevel()},n}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,n=void 0,o=void 0,r=void 0;if(null===t)n=(0,h["default"])(),o=null,r=P.Types.MOMENT;else switch(n=this.parse(t),o=n.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:n,input:o,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 n=new Date(e);isNaN(n.getTime())&&(n=this.state&&this.state.datetime||(0,h["default"])()),t=(0,h["default"])(n)}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,n){var o=!1;return this.props.min&&(0,h["default"])(e).isBefore(this.props.min)&&(o=!0),this.props.max&&(0,h["default"])(e).isAfter(this.props.max)&&(o=!0),this.props.minTime&&N(e)<N(this.props.minTime)&&(o=!0),this.props.maxTime&&N(e)>N(this.props.maxTime)&&(o=!0),o&&"hours"!==t&&((0,h["default"])(e).isSame(this.props.min,t)||(0,h["default"])(e).isSame(this.props.max,t))&&(o=!1),!(!n||(this.setState({dateTimeExceedsValidRange:o}),!this.props.shouldTriggerOnChangeForDateTimeOutsideRange))||!o}},{key:"commit",value:function(e){var t=this.props.returnAs||this.state.type,n=void 0;switch(t){case P.Types.ISO:n=e.toISOString();break;case P.Types.JS_DATE:n=e.toDate();break;case P.Types.MOMENT:n=e;break;case P.Types.STRING:n=e.format(this.format())}this.props.onChangeDateTime&&this.props.onChangeDateTime(n)}},{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,n=(0,h["default"])(t,this.format(),!0);n.isValid()?this.save(n):""==t?(this.setState({datetime:null,input:""}),this.props.onChangeDateTime&&this.props.onChangeDateTime(null)):this.setState({input:t})}},{key:"onSelect",value:function(e,t,n){var o=t,r=this.state.visible,s=this.props,i=s.closeOnSelect,a=s.preventClickOnDateTimeOutsideRange;if(n?this.validate(e,n.unit)||(o=!1):this.validate(e)||(o=!1),!t||o!==!1||!a){var u=i&&o?!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"])(),n=P.Levels[this.state.level];switch(e){case P.Keys.UP:this.onSelect(t.subtract(n.key.span,n.key.unit));break;case P.Keys.DOWN:this.onSelect(t.add(n.key.span,n.key.unit));break;case P.Keys.ENTER:n.down?this.setState({level:n.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=(0,m["default"])("react-kronos",this.props.id,this.props.classes.kronos),n=(0,m["default"])(this.props.classes.input,{"outside-range":this.state.dateTimeExceedsValidRange}),o=this.props.controlVisibility?this.props.visible:this.state.visible;return p["default"].createElement("div",{className:t},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:n}),o&&p["default"].createElement(_["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]}))}}]),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,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,M["default"])(I,function(e,t){return(0,q["default"])("index",e,t)})},function(e,t,n){"use strict";function o(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 n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(1),l=o(u),p=n(2),c=o(p),d=n(3),f=o(d),h=function(e){function t(){return r(this,t),s(this,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")}])}); | ||
!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 n="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 o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,function(e,t,n,o,r,i,s,a,u,l,p,c,d,f){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(12)},function(e,t){e.exports=require("react")},function(e,t,n){"use strict";function o(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,n){function o(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,n="x"===e?t:3&t|8;return n.toString(16)})}var p=function(p){function d(){return r(this,d),i(this,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 n?n(this.props,e):n;this.sheet=o(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 n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();t["default"]=a;var p=n(1),c=o(p),d=n(7),f=o(d)},function(e,t,n){"use strict";function o(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,n){r(t.options),t.options&&i(t.options,n);var o={color:"#1e7e9e",corners:4,font:"Source Sans Pro"},s=(0,f["default"])(o,g[n]),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,m["default"])(e.color).alpha(.2).rgbString(),fontSize:16,padding:"3px 6px",background:"white","&.outside-range":{color:"white",background:"#d0021b"},"&:focus":{outline:"none",borderColor:(0,m["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,m["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,m["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,m["default"])(e.color).alpha(.2).rgbString(),"&:not(.today)":{color:"hsl(0, 0%, 25%)"},"&.outside-range":{color:"#d0021b",backgroundColor:(0,m["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,m["default"])(e.color).alpha(.4).rgbString(),fontWeight:700},"&.past":{opacity:.4},"&.future":{opacity:.4},"&.today":{fontWeight:700,border:"1px solid",borderColor:(0,m["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,m["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=n(21),c=o(p),d=n(19),f=o(d),h=n(14),m=o(h),y=n(5),b=o(y);n(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",MINUTE:"minutes"},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,n){"use strict";function o(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 n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(1),p=o(l),c=n(9),d=o(c),f=n(20),h=o(f),m=n(5),y=o(m);n(8);var b=n(4),v=o(b),g=n(6),T=n(13),x=o(T),w=n(11),k=o(w),O=n(2),S=o(O),j=n(3),P=o(j),C=function(e){function t(e){r(this,t);var n=i(this,Object.getPrototypeOf(t).call(this,e));return n.state={windowHeight:window.innerHeight},n}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,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){t=t||(0,y["default"])();var n=function(){switch(e){case"years":var n=t.clone().subtract(4,"years"),o=t.clone().add(7,"years"),r=[];return(0,y["default"])().range(n,o).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 n?"undefined":a(n)))return n.v}},{key:"getCells",value:function(e,t){var n=this;t=t||(0,y["default"])();var o=this.props.timeStep?"minutes":e;switch(o){case"years":var r=function(){var e=t.clone().subtract(4,"years"),o=t.clone().add(7,"years"),r=[],i=(0,h["default"])(n.props,"options.format.year")||"YYYY";return(0,y["default"])().range(e,o).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 r?"undefined":a(r)))return r.v;case"months":var i=function(){var e=t.clone().startOf("year"),o=t.clone().endOf("year"),r=[],i=(0,h["default"])(n.props,"options.format.month")||"MMM";return(0,y["default"])().range(e,o).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 i?"undefined":a(i)))return i.v;case"days":var s=function(){var e=t.clone().startOf("month").weekday(0),o=t.clone().endOf("month").weekday(6),r=[],i=(0,h["default"])(n.props,"options.format.day")||"D";return y["default"].weekdaysMin().forEach(function(e){r.push({label:e,header:!0})}),(0,y["default"])().range(e,o).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,y["default"])(),"day")})}),{v:r}}();if("object"===("undefined"==typeof s?"undefined":a(s)))return s.v;case"hours":var u=function(){var e=t.clone().startOf("day"),o=t.clone().endOf("day"),r=[],i=t.clone().subtract(31,"minutes"),s=t.clone().add(31,"minutes"),a=(0,h["default"])(n.props,"options.format.hour")||"h:mm a";return(0,y["default"])().range(e,o).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 n=e.clone().add(30,"minutes");r.push({moment:n,label:n.format(a),selected:n.isSame(t,"minute"),nearestBefore:n.isBetween(i,t),nearestAfter:n.isBetween(t,s)})}),{v:r}}();if("object"===("undefined"==typeof u?"undefined":a(u)))return u.v;case"minutes":var l=function(){var e=t.clone().startOf("day"),o=t.clone().endOf("day"),r=[],i=(0,h["default"])(n.props,"options.format.minute")||"HH:mm";return(0,y["default"])().range(e,o).by(g.Units.MINUTE,function(e){var o=e.minutes();0===o?r.push({moment:e,label:e.format(i),selected:e.isSame(t,"minute")}):o%n.props.timeStep===0&&r.push({moment:e,label:e.format(i),selected:e.isSame(t,"minute")})}),{v:r}}();if("object"===("undefined"==typeof l?"undefined":a(l)))return l.v}}},{key:"render",value:function(){var e=this,t=this.props,n=t.level,o=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"!=n&&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(n,o)}),p["default"].createElement("div",{className:(0,v["default"])(r.grid,n)},this.getCells(n,o).map(function(t,o){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"===n&&s&&!e.props.validate(t.moment,n)?null:p["default"].createElement(k["default"],{key:o,ref:t.selected||t.nearestBefore?"selected":null,label:t.label,level:n,type:i,selected:t.selected,today:t.today,moment:t.moment,onClick:e.onNavigateCell.bind(e),classes:r,invalid:e.props.validate(t.moment,n)})}).filter(function(e){return null!=e}),"hours"!=n&&p["default"].createElement("div",{className:r.today,onClick:this.onToday.bind(this)},(0,h["default"])(this.props,"options.format.today")||"Today")))}}]),t}(l.Component);C.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},C._isMounted=!1,t["default"]=(0,S["default"])(C,function(e,t){return(0,P["default"])("calendar",e,t)})},function(e,t,n){"use strict";function o(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 n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(1),l=o(u),p=n(4),c=o(p),d=function(e){function t(){return r(this,t),i(this,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,n){"use strict";function o(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 n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),l=n(1),p=o(l),c=n(9),d=o(c),f=n(5),h=o(f),m=n(4),y=o(m),b=n(7),v=o(b),g=n(17),T=o(g),x=n(15),w=o(x),k=n(18),O=o(k),S=n(16),j=o(S),P=n(6),C=n(10),_=o(C),E=n(2),M=o(E),D=n(3),q=o(D);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 n=i(this,Object.getPrototypeOf(t).call(this,e));return n.state={datetime:n.getDateTimeInput().datetime,input:n.getDateTimeInput().input,type:n.getDateTimeInput().type,visible:!1,level:n.getDefaultLevel()},n}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,n=void 0,o=void 0,r=void 0;if(null===t)n=(0,h["default"])(),o=null,r=P.Types.MOMENT;else switch(n=this.parse(t),o=n.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:n,input:o,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 n=new Date(e);isNaN(n.getTime())&&(n=this.state&&this.state.datetime||(0,h["default"])()),t=(0,h["default"])(n)}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,n){var o=!1;return this.props.min&&(0,h["default"])(e).isBefore(this.props.min)&&(o=!0),this.props.max&&(0,h["default"])(e).isAfter(this.props.max)&&(o=!0),this.props.minTime&&N(e)<N(this.props.minTime)&&(o=!0),this.props.maxTime&&N(e)>N(this.props.maxTime)&&(o=!0),o&&"hours"!==t&&((0,h["default"])(e).isSame(this.props.min,t)||(0,h["default"])(e).isSame(this.props.max,t))&&(o=!1),!(!n||(this.setState({dateTimeExceedsValidRange:o}),!this.props.shouldTriggerOnChangeForDateTimeOutsideRange))||!o}},{key:"commit",value:function(e){var t=this.props.returnAs||this.state.type,n=void 0;switch(t){case P.Types.ISO:n=e.toISOString();break;case P.Types.JS_DATE:n=e.toDate();break;case P.Types.MOMENT:n=e;break;case P.Types.STRING:n=e.format(this.format())}this.props.onChangeDateTime&&this.props.onChangeDateTime(n)}},{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,n=(0,h["default"])(t,this.format(),!0);n.isValid()?this.save(n):""==t?(this.setState({datetime:null,input:""}),this.props.onChangeDateTime&&this.props.onChangeDateTime(null)):this.setState({input:t})}},{key:"onSelect",value:function(e,t,n){var o=t,r=this.state.visible,i=this.props,s=i.closeOnSelect,a=i.preventClickOnDateTimeOutsideRange;if(n?this.validate(e,n.unit)||(o=!1):this.validate(e)||(o=!1),!t||o!==!1||!a){var u=s&&o?!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"])(),n=P.Levels[this.state.level];switch(e){case P.Keys.UP:this.onSelect(t.subtract(n.key.span,n.key.unit));break;case P.Keys.DOWN:this.onSelect(t.add(n.key.span,n.key.unit));break;case P.Keys.ENTER:n.down?this.setState({level:n.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=(0,y["default"])("react-kronos",this.props.id,this.props.classes.kronos),n=(0,y["default"])(this.props.classes.input,{"outside-range":this.state.dateTimeExceedsValidRange}),o=this.props.controlVisibility?this.props.visible:this.state.visible;return p["default"].createElement("div",{className:t},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:n}),o&&p["default"].createElement(_["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:this.props.hideOutsideDateTimes,timeStep:this.props.timeStep}))}}]),t}(l.Component);I.propTypes={date:l.PropTypes.any,time:l.PropTypes.any,timeStep:l.PropTypes.number,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,M["default"])(I,function(e,t){return(0,q["default"])("index",e,t)})},function(e,t,n){"use strict";function o(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 n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(1),l=o(u),p=n(2),c=o(p),d=n(3),f=o(d),h=function(e){function t(){return r(this,t),i(this,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")}])}); |
@@ -195,3 +195,5 @@ 'use strict'; | ||
datetime = datetime || (0, _moment2.default)(); | ||
switch (unit) { | ||
var type = this.props.timeStep ? 'minutes' : unit; | ||
switch (type) { | ||
case 'years': | ||
@@ -315,2 +317,36 @@ { | ||
case 'minutes': | ||
{ | ||
var _ret6 = function () { | ||
var start = datetime.clone().startOf('day'); | ||
var end = datetime.clone().endOf('day'); | ||
var minutes = []; | ||
var format = (0, _get2.default)(_this2.props, 'options.format.minute') || 'HH:mm'; | ||
(0, _moment2.default)().range(start, end).by(_constants.Units.MINUTE, function (minute) { | ||
var _minutes = minute.minutes(); | ||
if (_minutes === 0) { | ||
minutes.push({ | ||
moment: minute, | ||
label: minute.format(format), | ||
selected: minute.isSame(datetime, 'minute') | ||
}); | ||
} else if (_minutes % _this2.props.timeStep === 0) { | ||
minutes.push({ | ||
moment: minute, | ||
label: minute.format(format), | ||
selected: minute.isSame(datetime, 'minute') | ||
}); | ||
} | ||
}); | ||
return { | ||
v: minutes | ||
}; | ||
}(); | ||
if ((typeof _ret6 === 'undefined' ? 'undefined' : _typeof(_ret6)) === "object") return _ret6.v; | ||
} | ||
} | ||
@@ -328,2 +364,3 @@ } | ||
var inputRect = _props.inputRect; | ||
var hideOutsideDateTimes = _props.hideOutsideDateTimes; | ||
@@ -374,2 +411,7 @@ | ||
} | ||
if (level === 'hours' && hideOutsideDateTimes && !_this3.props.validate(cell.moment, level)) { | ||
return null; | ||
} | ||
return _react2.default.createElement(_cell2.default, { | ||
@@ -388,2 +430,4 @@ key: i, | ||
}); | ||
}).filter(function (cell) { | ||
return cell != null; | ||
}), | ||
@@ -390,0 +434,0 @@ level != 'hours' && _react2.default.createElement( |
@@ -19,3 +19,4 @@ 'use strict'; | ||
DAY: 'days', | ||
HOUR: 'hours' | ||
HOUR: 'hours', | ||
MINUTE: 'minutes' | ||
}; | ||
@@ -22,0 +23,0 @@ |
@@ -432,3 +432,5 @@ 'use strict'; | ||
options: this.props.options, | ||
inputRect: this._input.getClientRects()[0] | ||
inputRect: this._input.getClientRects()[0], | ||
hideOutsideDateTimes: this.props.hideOutsideDateTimes, | ||
timeStep: this.props.timeStep | ||
}) | ||
@@ -445,2 +447,3 @@ ); | ||
time: _react.PropTypes.any, | ||
timeStep: _react.PropTypes.number, | ||
min: _react.PropTypes.any, | ||
@@ -460,2 +463,3 @@ max: _react.PropTypes.any, | ||
options: _react.PropTypes.object, | ||
hideOutsideDateTimes: _react.PropTypes.bool, | ||
// Advanced controls | ||
@@ -462,0 +466,0 @@ controlVisibility: _react.PropTypes.bool, |
{ | ||
"name": "react-kronos", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "A fast, intuitive, and elegant date and time picker for React.", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.js", |
@@ -1,2 +0,2 @@ | ||
React Kronos 1.4 | ||
React Kronos 1.5 | ||
================ | ||
@@ -43,2 +43,3 @@ | ||
- `time` - *Date()*, *Moment()*, *ISO*, or *string* (if string, must match `format`) | ||
- `timeStep` - *number* : minutes for time step (if not specified: 30 minutes) | ||
- `format` - *string* : [Moment formatting](http://momentjs.com/docs/#/parsing/string-format/) of date / time | ||
@@ -56,2 +57,3 @@ - `onChange` - *function* : native onChange method | ||
- `preventClickOnDateTimeOutsideRange` - *boolean*: optionally prevent users from clicking on dates outside min/max range (default: `false`) | ||
- `hideOutsideDateTimes` - *boolean*: optionally hide times that do not pass validation | ||
- `placeholder` - *string* : placeholder text when there is no value | ||
@@ -58,0 +60,0 @@ - `name` - *string* : name used for the input form |
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
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
92864
1412
103