react-scaled-scheduler
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-scaled-scheduler"]=t():e["react-scaled-scheduler"]=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=11)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("moment")},function(e,t){e.exports=require("event-time-utils")},function(e,t){e.exports=require("react-dnd")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=l(r(0)),s=(l(r(1)),r(3)),a=r(2),p=(r(9),l(r(8)));function l(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(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 d(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)}var f={drop:function(e,t){if(!t.didDrop())return{droptime:e.droptime,intervals:e.intervals,rowData:e.rowData}},canDrop:function(e,t){var r=t.getItem();if("move"==r.action)return!0;var n=!1;return e.events.map(function(e){e.id==r.id&&(n=!0)}),n}};function v(e,t){return{connectDropTarget:e.dropTarget(),isOver:t.isOver(),canDrop:t.canDrop(),dropItem:t.getItem(),dropItemType:t.getItemType()}}var h=function(e){function t(){var e,r,n;u(this,t);for(var o=arguments.length,i=Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=n=c(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),n.dragoverEvent=function(e){(new Date).getTime()-n.props.lastDropCalc<n.props.dragoverTickrate?n.setState(function(t){return"droptimeDebounce"in n&&window.clearTimeout(n.droptimeDebounce),n.droptimeDebounce=window.setTimeout(function(){n.updateDroptime(e)},n.props.dragoverDebounce),t}):n.updateDroptime(e)},n.handleEventClick=function(e){var t=void 0;n.props.events.map(function(r){r.id==e&&(t=r)}),t&&null!==n.props.onEventClick&&n.props.onEventClick(t)},c(n,r)}return d(t,i.default.Component),o(t,[{key:"componentDidMount",value:function(){this.refs.ruler.addEventListener("dragover",this.dragoverEvent),this.refs.ruler.addEventListener("mousemove",this.dragoverEvent)}},{key:"componentWillUnmount",value:function(){this.refs.ruler.removeEventListener("dragover",this.dragoverEvent),this.refs.ruler.removeEventListener("mousemove",this.dragoverEvent)}},{key:"updateDroptime",value:function(e){var t=this.refs.ruler.getBoundingClientRect(),r=0;(r=this.props.vertical?(e.pageY-t.top)/t.height:(e.pageX-t.left)/t.width)>1?r=1:r<0&&(r=0),"droptimeDebounce"in this&&(window.clearTimeout(this.droptimeDebounce),delete this.droptimeDebounce),this.props.updateDroptime(r)}},{key:"adjustedDropItem",value:function(){var e=this.props.intervals[0].begins,t=this.props.intervals[Math.floor(this.props.intervals.length*this.props.droptime)];if(t){var r=this.props.droptime%(1/this.props.intervals.length)*this.props.intervals.length;e=+t.begins+(+t.ends-+t.begins)*r,e=(0,a.nearestTime)(e,this.props.dropRounding)}var o=n({},this.props.dropItem,{active:!0});switch(o.action){case"move":var i=+o.ends-+o.begins;o.begins=e,o.ends=+o.begins+i;break;case"beforeDrag":o.begins=Math.min(e,o.ends-this.props.minEventDuration);break;case"afterDrag":o.ends=Math.max(e,o.begins+this.props.minEventDuration)}return o}},{key:"renderEvents",value:function(e,t){var r=this;this.props.isOver&&this.props.canDrop;return e.map(function(e){var o=void 0,s=void 0,a=void 0,l=void 0;t.map(function(t,r){e.begins>=t.begins&&e.begins<t.ends&&(o=t,s=r),e.ends>=t.begins&&e.ends<t.ends&&(a=t,l=r)});var u=s;void 0===u?u=0:(u+=(e.begins-o.begins)/(o.ends-o.begins),u/=t.length),u=Math.max(u,0);var c=l;void 0===c?c=1:(c+=(e.ends-a.begins)/(a.ends-a.begins),c/=t.length);var d=(c=Math.min(c,100))-u,f=Math.max(r.props.eventHeight-8*e.stackIndex,25),v=r.props.eventHeight+2*r.props.eventMargin-f-r.props.eventMargin;return i.default.createElement(p.default,n({key:"event-"+e.id,className:"event"},e,{width:100*d+"%",height:f+"px",top:v+"px",left:100*u+"%",vertical:r.props.vertical,dropRounding:r.props.dropRounding,dragoverDebounce:r.props.dragoverDebounce,dragoverTickrate:r.props.dragoverTickrate,animTransition:r.props.animTransition,minEventDuration:r.props.minEventDuration,clickable:null!==r.props.onEventClick,onClick:r.handleEventClick,onDrop:r.props.onEventDrop}))})}},{key:"render",value:function(){var e=this,t=+this.props.intervals[0].begins,r=+this.props.intervals[this.props.intervals.length-1].ends,o=this.props.isOver&&this.props.canDrop,s=[],p=this.props.dropItem?this.props.dropItem.id:null,l=!1;this.props.events.map(function(t){if(p&&t.id==p)if(l=!0,o)s.push(e.adjustedDropItem());else{var r=n({},t);"move"==e.props.dropItem.action&&((r=e.adjustedDropItem()).hidden=!0),s.push(r)}else s.push(t)}),o&&!l&&"move"==this.props.dropItem.action&&s.push(this.adjustedDropItem()),s=(0,a.eventsInRange)(s,t,r);var u=(0,a.stackEvents)(s.sort(a.chronoEventsComparer),0);return i.default.createElement("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(i.default.createElement("div",{className:"rscales-dropzone"},this.renderEvents(u,this.props.intervals))))}}]),t}(),m=(0,s.DropTarget)(["RSCALES_EVENT"],f,v)(h);var g=function(e){function t(){return u(this,t),c(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,i.default.Component),o(t,[{key:"render",value:function(){var e="function"==typeof this.props.onEventDrop,t={};this.props.vertical?t.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":t.height=this.props.eventHeight+2*this.props.eventMargin+"px";var r,n=m;return e&&this.props.customDropTypes.length>0?(console.log("using custom renderer with",this.props.customDropTypes),r=this.props.customDropTypes,n=(0,s.DropTarget)(["RSCALES_EVENT"].concat(r),f,v)(h)):console.log("using vanilla renderer"),i.default.createElement("div",{className:"rscales-row",style:t},this.props.showTitle&&i.default.createElement("div",{className:"rscales-title"},"title"in this.props&&i.default.createElement("h2",null,this.props.title)),i.default.createElement(n,this.props))}}]),t}();t.default=g},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),s=(n=i)&&n.__esModule?n:{default:n};var a=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(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)}(t,s.default.Component),o(t,[{key:"render",value:function(){return this.props.children&&this.props.children.length?s.default.createElement("div",null,this.props.children):this.props.children||null}}]),t}();t.default=a},function(e,t){e.exports=require("classnames")},function(e,t){e.exports=require("prop-types")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=l(r(0)),s=(l(r(1)),r(3)),a=(l(r(7)),l(r(6))),p=r(2);function l(e){return e&&e.__esModule?e:{default:e}}function u(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}var c={beginDrag:function(e,t){return o({},e,{action:"move"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var o=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(o){var i=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+o.begins+(+o.ends-+o.begins)*i;s=(0,p.nearestTime)(s,e.dropRounding),e.onDrop(r,{moveTo:s},n.rowData)}}}};var d={beginDrag:function(e,t){return o({},e,{action:"beforeDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var o=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(o){var i=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+o.begins+(+o.ends-+o.begins)*i;s=(0,p.nearestTime)(s,e.dropRounding);var a=Math.min(s,+r.ends-e.minEventDuration);e.onDrop(r,{begins:a},n.rowData)}}}};var f={beginDrag:function(e,t){return o({},e,{action:"afterDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var o=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(o){var i=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+o.begins+(+o.ends-+o.begins)*i;s=(0,p.nearestTime)(s,e.dropRounding);var a=Math.max(s,+r.begins+e.minEventDuration);e.onDrop(r,{ends:a},n.rowData)}}}};var v=function(e){function t(){var e,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,i=Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=n=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),n.handleClick=function(e){e&&e.preventDefault(),n.props.clickable&&!n.props.disabled&&n.props.onClick(n.props.id)},u(n,r)}return function(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)}(t,i.default.PureComponent),n(t,[{key:"render",value:function(){var e=this.props.dragoverTickrate/1e3+"s",t={transition:"width "+e+" "+this.props.animTransition+", left "+e+" "+this.props.animTransition+", height "+e+" "+this.props.animTransition+", top "+e+" "+this.props.animTransition};t=this.props.vertical?o({},t,{height:this.props.width,maxWidth:this.props.height,minWidth:this.props.height,left:this.props.top,top:this.props.left}):o({},t,{width:this.props.width,maxHeight:this.props.height,minHeight:this.props.height,top:this.props.top,left:this.props.left});var r=void 0;this.props.pending||(r=this.props.connectBeforeSource(i.default.createElement("span",{className:"resize before"})));var n=void 0;this.props.pending||(n=this.props.afterSource(i.default.createElement("span",{className:"resize after"})));this.props.property&&i.default.createElement("span",{className:"property"},this.props.property);var s=i.default.createElement("div",{className:"rscales-event-body"},i.default.createElement("div",{className:"rscales-event-contents"},i.default.createElement("span",{className:"title"},this.props.title)),!this.props.disabled&&r,!this.props.disabled&&n);this.props.disabled||(s=this.props.connectMoveSource(s));var p=i.default.createElement("span",{style:{width:0,height:0}});return i.default.createElement("div",{className:(0,a.default)("rscales-event",{active:this.props.active,hidden:this.props.hidden,clickable:this.props.clickable,disabled:this.props.disabled},this.props.extraClasses),style:t,onClick:this.handleClick},this.props.connectMovePreview(p),this.props.connectAfterPreview(p),this.props.connectBeforePreview(p),s)}}]),t}();v=(0,s.DragSource)("RSCALES_EVENT",c,function(e,t){return{connectMoveSource:e.dragSource(),connectMovePreview:e.dragPreview()}})(v),v=(0,s.DragSource)("RSCALES_EVENT",d,function(e,t){return{connectBeforeSource:e.dragSource(),connectBeforePreview:e.dragPreview()}})(v),v=(0,s.DragSource)("RSCALES_EVENT",f,function(e,t){return{afterSource:e.dragSource(),connectAfterPreview:e.dragPreview()}})(v),t.default=v},function(e,t){e.exports=require("shallow-utils")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=u(r(0)),s=u(r(1)),a=u(r(6)),p=u(r(5)),l=u(r(4));function u(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(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 f(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)}var v=function(e){function t(){return c(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return f(t,i.default.Component),o(t,[{key:"render",value:function(){var e=this;return i.default.createElement("div",{className:"rscales-header"},this.props.showTitle&&i.default.createElement("div",{className:"rscales-title"},this.props.children),i.default.createElement("div",{className:"rscales-data"},this.props.intervals.map(function(t){var r=void 0;return r="function"==typeof e.props.titleFormat?e.props.titleFormat(t):(0,s.default)(t.begins,"x").format(e.props.titleFormat),i.default.createElement("div",{key:"interval-"+t.begins},i.default.createElement("h3",null,r))})))}}]),t}(),h=function(e){function t(e){c(this,t);var r=d(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.updateDroptime=function(e){r.setState({droptime:e})},r.state=n({},r.state,{droptime:0}),r}return f(t,i.default.Component),o(t,[{key:"render",value:function(){var e=this,t=[],r=[];return i.default.Children.map(this.props.children,function(n){n&&"type"in n!=0&&(n.type!=p.default?n.type!=l.default||r.push(i.default.cloneElement(n,{vertical:e.props.vertical,dropRounding:e.props.dropRounding,showTitle:e.props.showTitles,intervals:e.props.intervals,minEventDuration:e.props.minEventDuration,dragoverDebounce:e.props.dragoverDebounce,dragoverTickrate:e.props.dragoverTickrate,animTransition:e.props.animTransition,eventMargin:e.props.eventMargin,eventHeight:e.props.eventHeight,droptime:e.state.droptime,updateDroptime:e.updateDroptime,customDropTypes:e.props.customDropTypes,onEventDrop:e.props.onEventDrop,onEventClick:e.props.onEventClick})):t.push(n))}),i.default.createElement("div",{className:(0,a.default)("rscales-root",{vertical:this.props.vertical}),style:this.props.style},i.default.createElement(v,{vertical:this.props.vertical,showTitle:this.props.showTitles,intervals:this.props.intervals,titleFormat:this.props.headerTitleFormat},t),i.default.createElement("div",{className:"rscales-body"},r))}}]),t}();h.defaultProps={style:{},vertical:!1,showTitles:!0,dropRounding:s.default.duration({minutes:15}),headerTitleFormat:"ha",minEventDuration:s.default.duration({minutes:15}),dragoverDebounce:50,dragoverTickrate:200,animTransition:"ease-out",eventMargin:5,eventHeight:42,customDropTypes:[],onEventDrop:function(e,t,r){console.log("RScaleS: dropped rscales event",e,"at",t,r)},onEventClick:function(e){console.log("RScaleS: clicked rscales event",e)}},t.default=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScaledCorner=t.ScaledRow=t.ScaledScheduler=void 0;var n=s(r(10)),o=s(r(4)),i=s(r(5));function s(e){return e&&e.__esModule?e:{default:e}}t.ScaledScheduler=n.default,t.ScaledRow=o.default,t.ScaledCorner=i.default}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-scaled-scheduler"]=t():e["react-scaled-scheduler"]=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=11)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("moment")},function(e,t){e.exports=require("event-time-utils")},function(e,t){e.exports=require("react-dnd")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=u(r(0)),s=(u(r(1)),r(3)),a=r(2),p=r(9),l=u(r(8));function u(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(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 f(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)}var v={drop:function(e,t){if(!t.didDrop())return{droptime:e.droptime,intervals:e.intervals,rowData:e.rowData}},canDrop:function(e,t){var r=t.getItem();if("move"==r.action)return!0;var n=!1;return e.events.map(function(e){e.id==r.id&&(n=!0)}),n}};function h(e,t){return{connectDropTarget:e.dropTarget(),isOver:t.isOver(),canDrop:t.canDrop(),dropItem:t.getItem(),dropItemType:t.getItemType()}}var m=function(e){function t(){var e,r,n;c(this,t);for(var o=arguments.length,i=Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=n=d(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),n.dragoverEvent=function(e){(new Date).getTime()-n.props.lastDropCalc<n.props.dragoverTickrate?n.setState(function(t){return"droptimeDebounce"in n&&window.clearTimeout(n.droptimeDebounce),n.droptimeDebounce=window.setTimeout(function(){n.updateDroptime(e)},n.props.dragoverDebounce),t}):n.updateDroptime(e)},n.handleEventClick=function(e){var t=void 0;n.props.events.map(function(r){r.id==e&&(t=r)}),t&&null!==n.props.onEventClick&&n.props.onEventClick(t)},d(n,r)}return f(t,i.default.Component),o(t,[{key:"componentDidMount",value:function(){this.refs.ruler.addEventListener("dragover",this.dragoverEvent),this.refs.ruler.addEventListener("mousemove",this.dragoverEvent)}},{key:"componentWillUnmount",value:function(){this.refs.ruler.removeEventListener("dragover",this.dragoverEvent),this.refs.ruler.removeEventListener("mousemove",this.dragoverEvent)}},{key:"updateDroptime",value:function(e){var t=this.refs.ruler.getBoundingClientRect(),r=0;(r=this.props.vertical?(e.pageY-t.top)/t.height:(e.pageX-t.left)/t.width)>1?r=1:r<0&&(r=0),"droptimeDebounce"in this&&(window.clearTimeout(this.droptimeDebounce),delete this.droptimeDebounce),this.props.updateDroptime(r)}},{key:"adjustedDropItem",value:function(){var e=this.props.intervals[0].begins,t=this.props.intervals[Math.floor(this.props.intervals.length*this.props.droptime)];if(t){var r=this.props.droptime%(1/this.props.intervals.length)*this.props.intervals.length;e=+t.begins+(+t.ends-+t.begins)*r,e=(0,a.nearestTime)(e,this.props.dropRounding)}var o=n({},this.props.dropItem,{active:!0});switch(o.action){case"move":var i=+o.ends-+o.begins;o.begins=e,o.ends=+o.begins+i;break;case"beforeDrag":o.begins=Math.min(e,o.ends-this.props.minEventDuration);break;case"afterDrag":o.ends=Math.max(e,o.begins+this.props.minEventDuration)}return o}},{key:"renderEvents",value:function(e,t){var r=this;this.props.isOver&&this.props.canDrop;return e.map(function(e){var o=void 0,s=void 0,a=void 0,p=void 0;t.map(function(t,r){e.begins>=t.begins&&e.begins<t.ends&&(o=t,s=r),e.ends>=t.begins&&e.ends<t.ends&&(a=t,p=r)});var u=s;void 0===u?u=0:(u+=(e.begins-o.begins)/(o.ends-o.begins),u/=t.length),u=Math.max(u,0);var c=p;void 0===c?c=1:(c+=(e.ends-a.begins)/(a.ends-a.begins),c/=t.length);var d=(c=Math.min(c,100))-u,f=Math.max(r.props.eventHeight-8*e.stackIndex,25),v=r.props.eventHeight+2*r.props.eventMargin-f-r.props.eventMargin;return i.default.createElement(l.default,n({key:"event-"+e.id,className:"event"},e,{width:100*d+"%",height:f+"px",top:v+"px",left:100*u+"%",vertical:r.props.vertical,dropRounding:r.props.dropRounding,dragoverDebounce:r.props.dragoverDebounce,dragoverTickrate:r.props.dragoverTickrate,animTransition:r.props.animTransition,minEventDuration:r.props.minEventDuration,clickable:null!==r.props.onEventClick,onClick:r.handleEventClick,onDrop:r.props.onEventDrop}))})}},{key:"render",value:function(){var e=this,t=+this.props.intervals[0].begins,r=+this.props.intervals[this.props.intervals.length-1].ends,o=this.props.isOver&&this.props.canDrop,s=[],p=this.props.dropItem?this.props.dropItem.id:null,l=!1;this.props.events.map(function(t){if(p&&t.id==p)if(l=!0,o)s.push(e.adjustedDropItem());else{var r=n({},t);"move"==e.props.dropItem.action&&((r=e.adjustedDropItem()).hidden=!0),s.push(r)}else s.push(t)}),o&&!l&&"move"==this.props.dropItem.action&&s.push(this.adjustedDropItem()),s=(0,a.eventsInRange)(s,t,r);var u=(0,a.stackEvents)(s.sort(a.chronoEventsComparer),0);return i.default.createElement("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(i.default.createElement("div",{className:"rscales-dropzone"},this.renderEvents(u,this.props.intervals))))}}]),t}(),g=(0,s.DropTarget)(["RSCALES_EVENT"],v,h)(m);var b=function(e){function t(){return c(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return f(t,i.default.Component),o(t,[{key:"shouldComponentUpdate",value:function(e,t){if(!(0,p.shallowEqual)(this.props.intervals,e.intervals))return!0;if(!(0,p.shallowEqual)(this.props.customDropTypes,e.customDropTypes))return!0;if(!(0,p.shallowEqual)(this.props.events,e.events))return!0;return!(0,p.shallowEqualExcept)(this.props,e,["intervals","customDropTypes","events"])}},{key:"render",value:function(){var e="function"==typeof this.props.onEventDrop,t={};this.props.vertical?t.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":t.height=this.props.eventHeight+2*this.props.eventMargin+"px";var r,n=g;return e&&this.props.customDropTypes.length>0?(console.log("using custom renderer with",this.props.customDropTypes),r=this.props.customDropTypes,n=(0,s.DropTarget)(["RSCALES_EVENT"].concat(r),v,h)(m)):console.log("using vanilla renderer"),i.default.createElement("div",{className:"rscales-row",style:t},this.props.showTitle&&i.default.createElement("div",{className:"rscales-title"},"title"in this.props&&i.default.createElement("h2",null,this.props.title)),i.default.createElement(n,this.props))}}]),t}();t.default=b},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),s=(n=i)&&n.__esModule?n:{default:n};var a=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(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)}(t,s.default.Component),o(t,[{key:"render",value:function(){return this.props.children&&this.props.children.length?s.default.createElement("div",null,this.props.children):this.props.children||null}}]),t}();t.default=a},function(e,t){e.exports=require("classnames")},function(e,t){e.exports=require("prop-types")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=l(r(0)),s=(l(r(1)),r(3)),a=(l(r(7)),l(r(6))),p=r(2);function l(e){return e&&e.__esModule?e:{default:e}}function u(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}var c={beginDrag:function(e,t){return o({},e,{action:"move"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var o=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(o){var i=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+o.begins+(+o.ends-+o.begins)*i;s=(0,p.nearestTime)(s,e.dropRounding),e.onDrop(r,{moveTo:s},n.rowData)}}}};var d={beginDrag:function(e,t){return o({},e,{action:"beforeDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var o=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(o){var i=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+o.begins+(+o.ends-+o.begins)*i;s=(0,p.nearestTime)(s,e.dropRounding);var a=Math.min(s,+r.ends-e.minEventDuration);e.onDrop(r,{begins:a},n.rowData)}}}};var f={beginDrag:function(e,t){return o({},e,{action:"afterDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var o=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(o){var i=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+o.begins+(+o.ends-+o.begins)*i;s=(0,p.nearestTime)(s,e.dropRounding);var a=Math.max(s,+r.begins+e.minEventDuration);e.onDrop(r,{ends:a},n.rowData)}}}};var v=function(e){function t(){var e,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,i=Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=n=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),n.handleClick=function(e){e&&e.preventDefault(),n.props.clickable&&!n.props.disabled&&n.props.onClick(n.props.id)},u(n,r)}return function(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)}(t,i.default.PureComponent),n(t,[{key:"render",value:function(){var e=this.props.dragoverTickrate/1e3+"s",t={transition:"width "+e+" "+this.props.animTransition+", left "+e+" "+this.props.animTransition+", height "+e+" "+this.props.animTransition+", top "+e+" "+this.props.animTransition};t=this.props.vertical?o({},t,{height:this.props.width,maxWidth:this.props.height,minWidth:this.props.height,left:this.props.top,top:this.props.left}):o({},t,{width:this.props.width,maxHeight:this.props.height,minHeight:this.props.height,top:this.props.top,left:this.props.left});var r=void 0;this.props.pending||(r=this.props.connectBeforeSource(i.default.createElement("span",{className:"resize before"})));var n=void 0;this.props.pending||(n=this.props.afterSource(i.default.createElement("span",{className:"resize after"})));this.props.property&&i.default.createElement("span",{className:"property"},this.props.property);var s=i.default.createElement("div",{className:"rscales-event-body"},i.default.createElement("div",{className:"rscales-event-contents"},i.default.createElement("span",{className:"title"},this.props.title)),!this.props.disabled&&r,!this.props.disabled&&n);this.props.disabled||(s=this.props.connectMoveSource(s));var p=i.default.createElement("span",{style:{width:0,height:0}});return i.default.createElement("div",{className:(0,a.default)("rscales-event",{active:this.props.active,hidden:this.props.hidden,clickable:this.props.clickable,disabled:this.props.disabled},this.props.extraClasses),style:t,onClick:this.handleClick},this.props.connectMovePreview(p),this.props.connectAfterPreview(p),this.props.connectBeforePreview(p),s)}}]),t}();v=(0,s.DragSource)("RSCALES_EVENT",c,function(e,t){return{connectMoveSource:e.dragSource(),connectMovePreview:e.dragPreview()}})(v),v=(0,s.DragSource)("RSCALES_EVENT",d,function(e,t){return{connectBeforeSource:e.dragSource(),connectBeforePreview:e.dragPreview()}})(v),v=(0,s.DragSource)("RSCALES_EVENT",f,function(e,t){return{afterSource:e.dragSource(),connectAfterPreview:e.dragPreview()}})(v),t.default=v},function(e,t){e.exports=require("shallow-utils")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=u(r(0)),s=u(r(1)),a=u(r(6)),p=u(r(5)),l=u(r(4));function u(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(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 f(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)}var v=function(e){function t(){return c(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return f(t,i.default.Component),o(t,[{key:"render",value:function(){var e=this;return i.default.createElement("div",{className:"rscales-header"},this.props.showTitle&&i.default.createElement("div",{className:"rscales-title"},this.props.children),i.default.createElement("div",{className:"rscales-data"},this.props.intervals.map(function(t){var r=void 0;return r="function"==typeof e.props.titleFormat?e.props.titleFormat(t):(0,s.default)(t.begins,"x").format(e.props.titleFormat),i.default.createElement("div",{key:"interval-"+t.begins},i.default.createElement("h3",null,r))})))}}]),t}(),h=function(e){function t(e){c(this,t);var r=d(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.updateDroptime=function(e){r.setState({droptime:e})},r.state=n({},r.state,{droptime:0}),r}return f(t,i.default.Component),o(t,[{key:"render",value:function(){var e=this,t=[],r=[];return i.default.Children.map(this.props.children,function(n){n&&"type"in n!=0&&(n.type!=p.default?n.type!=l.default||r.push(i.default.cloneElement(n,{vertical:e.props.vertical,dropRounding:e.props.dropRounding,showTitle:e.props.showTitles,intervals:e.props.intervals,minEventDuration:e.props.minEventDuration,dragoverDebounce:e.props.dragoverDebounce,dragoverTickrate:e.props.dragoverTickrate,animTransition:e.props.animTransition,eventMargin:e.props.eventMargin,eventHeight:e.props.eventHeight,droptime:e.state.droptime,updateDroptime:e.updateDroptime,customDropTypes:e.props.customDropTypes,onEventDrop:e.props.onEventDrop,onEventClick:e.props.onEventClick})):t.push(n))}),i.default.createElement("div",{className:(0,a.default)("rscales-root",{vertical:this.props.vertical}),style:this.props.style},i.default.createElement(v,{vertical:this.props.vertical,showTitle:this.props.showTitles,intervals:this.props.intervals,titleFormat:this.props.headerTitleFormat},t),i.default.createElement("div",{className:"rscales-body"},r))}}]),t}();h.defaultProps={style:{},vertical:!1,showTitles:!0,dropRounding:s.default.duration({minutes:15}),headerTitleFormat:"ha",minEventDuration:s.default.duration({minutes:15}),dragoverDebounce:50,dragoverTickrate:200,animTransition:"ease-out",eventMargin:5,eventHeight:42,customDropTypes:[],onEventDrop:function(e,t,r){console.log("RScaleS: dropped rscales event",e,"at",t,r)},onEventClick:function(e){console.log("RScaleS: clicked rscales event",e)}},t.default=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScaledCorner=t.ScaledRow=t.ScaledScheduler=void 0;var n=s(r(10)),o=s(r(4)),i=s(r(5));function s(e){return e&&e.__esModule?e:{default:e}}t.ScaledScheduler=n.default,t.ScaledRow=o.default,t.ScaledCorner=i.default}])}); |
{ | ||
"name": "react-scaled-scheduler", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Scheduler with events drawn to scale along a time axis, with drag and drop support", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
29438
6