react-scaled-scheduler
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -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("prop-types")},function(e,t){e.exports=require("shallow-utils")},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,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),a=(n=i)&&n.__esModule?n:{default:n};var s=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,a.default.Component),o(t,[{key:"render",value:function(){return this.props.children&&this.props.children.length?a.default.createElement("div",null,this.props.children):this.props.children||null}}]),t}();t.default=s},function(e,t){e.exports=require("classnames")},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=u(r(0)),a=(u(r(1)),r(5)),s=(u(r(2)),u(r(7))),p=r(4),l=r(3);function u(e){return e&&e.__esModule?e:{default:e}}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}var d={beginDrag:function(e,t){return o({},e,{action:"move",grabOffset:e.getDropRealTime()-e.begins})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var i=e.getDropRealTime();i=(0,p.nearestTime)(i-r.grabOffset,e.dropRounding),e.onDrop(r,e.rowData,o({},n,{moveTo:i}))}}};var f={beginDrag:function(e,t){return o({},e,{action:"beforeDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var i=e.getDropRealTime(),a=Math.min(i,+r.ends-e.minEventDuration);e.onDrop(r,e.rowData,o({},n,{begins:a}))}}};var v={beginDrag:function(e,t){return o({},e,{action:"afterDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var i=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(i){var a=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+i.begins+(+i.ends-+i.begins)*a;s=(0,p.nearestTime)(s,e.dropRounding);var l=Math.max(s,+r.begins+e.minEventDuration);e.onDrop(r,e.rowData,o({},n,{ends:l}))}}}};var h=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),a=0;a<o;a++)i[a]=arguments[a];return r=n=c(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)},c(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.Component),n(t,[{key:"shouldComponentUpdate",value:function(e,t){return!(0,l.shallowEqualExcept)(this.props,e,["dropRealTime"])}},{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 a=i.default.createElement("div",{className:"rscales-event-body"},i.default.createElement("div",{className:"rscales-event-contents",style:this.props.style},i.default.createElement("span",{className:"title"},this.props.title),this.props.location&&i.default.createElement("p",{className:"location"},this.props.location)),!this.props.disabled&&r,!this.props.disabled&&n);this.props.disabled||(a=this.props.connectMoveSource(a));var p=i.default.createElement("span",{style:{width:0,height:0}});return i.default.createElement("div",{className:(0,s.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),a)}}]),t}();h=(0,a.DragSource)("RSCALES_EVENT",d,function(e,t){return{connectMoveSource:e.dragSource(),connectMovePreview:e.dragPreview()}})(h),h=(0,a.DragSource)("RSCALES_EVENT",f,function(e,t){return{connectBeforeSource:e.dragSource(),connectBeforePreview:e.dragPreview()}})(h),h=(0,a.DragSource)("RSCALES_EVENT",v,function(e,t){return{afterSource:e.dragSource(),connectAfterPreview:e.dragPreview()}})(h),t.default=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o,i=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},a=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}}(),s=f(r(0)),p=(f(r(1)),r(5)),l=r(4),u=r(3),c=f(r(2)),d=f(r(8));function f(e){return e&&e.__esModule?e:{default:e}}function v(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 h=(o=n=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),a=0;a<o;a++)i[a]=arguments[a];return r=n=v(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.getDropRealTime=function(){var e=n.props.intervals[0].begins,t=n.props.intervals[Math.floor(n.props.intervals.length*n.props.droptime)];if(t){var r=n.props.droptime%(1/n.props.intervals.length)*n.props.intervals.length;e=+t.begins+(+t.ends-+t.begins)*r}return 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)},v(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,s.default.Component),a(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:"shouldComponentUpdate",value:function(e,t){var r=e.isOver&&e.canDrop,n=this.props.isOver&&this.props.canDrop;if(n!=r)return!0;if(n&&this.props.droptime!=e.droptime)return!0;if(!(0,u.shallowEqual)(this.props.events,e.events))return!0;if(!(0,u.shallowEqual)(this.props.rowData,e.rowData))return!0;if(!(0,u.shallowEqual)(this.props.intervals,e.intervals))return!0;return!(0,u.shallowEqualExcept)(this.props,e,["events","rowData","intervals"].concat(["droptime"]))}},{key:"updateDroptime",value:function(e){var t=this.refs.ruler.getBoundingClientRect(),r=0;(r=this.props.vertical?(e.clientY-t.top)/t.height:(e.clientX-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.getDropRealTime();"grabOffset"in this.props.dropItem&&(e-=this.props.dropItem.grabOffset),e=(0,l.nearestTime)(e,this.props.dropRounding);var t=i({},this.props.dropItem,{active:!0});switch(t.action){case"move":var r=+t.ends-+t.begins;t.begins=e,t.ends=+t.begins+r;break;case"beforeDrag":t.begins=Math.min(e,t.ends-this.props.minEventDuration);break;case"afterDrag":t.ends=Math.max(e,t.begins+this.props.minEventDuration)}return t}},{key:"renderEvents",value:function(e,t){var r=this;this.props.isOver&&this.props.canDrop;return e.map(function(e){var n=void 0,o=void 0,a=void 0,p=void 0;t.map(function(t,r){e.begins>=t.begins&&e.begins<t.ends&&(n=t,o=r),e.ends>=t.begins&&e.ends<t.ends&&(a=t,p=r)});var l=o;void 0===l?l=0:(l+=(e.begins-n.begins)/(n.ends-n.begins),l/=t.length),l=Math.max(l,0);var u=p;void 0===u?u=1:(u+=(e.ends-a.begins)/(a.ends-a.begins),u/=t.length);var c=(u=Math.min(u,100))-l,f=Math.max(r.props.eventHeight-8*e.stackIndex,25),v=r.props.eventHeight+2*r.props.eventMargin-f-r.props.eventMargin;return s.default.createElement(d.default,i({key:"event-"+e.id,className:"event"},e,{width:100*c+"%",height:f+"px",top:v+"px",left:100*l+"%",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,getDropRealTime:r.getDropRealTime,rowData:r.props.rowData}))})}},{key:"render",value:function(){var e=this,t=+this.props.intervals[0].begins,r=+this.props.intervals[this.props.intervals.length-1].ends,n=this.props.isOver&&this.props.canDrop,o=[],a=this.props.dropItem?this.props.dropItem.id:null,p=!1;this.props.events.map(function(t){if(a&&t.id==a)if(p=!0,n)o.push(e.adjustedDropItem());else{var r=i({},t);"move"==e.props.dropItem.action&&((r=e.adjustedDropItem()).hidden=!0),o.push(r)}else o.push(t)}),n&&!p&&"move"==this.props.dropItem.action&&o.push(this.adjustedDropItem()),o=(0,l.eventsInRange)(o,t,r);var u=(0,l.stackEvents)(o.sort(l.chronoEventsComparer),0),c={};this.props.vertical?c.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":c.height=this.props.eventHeight+2*this.props.eventMargin+"px";var d=void 0;return this.props.title&&this.props.titleRenderer&&(d=s.default.createElement(this.props.titleRenderer,{title:this.props.title})),s.default.createElement("div",{className:"rscales-row",style:c},this.props.showTitle&&s.default.createElement("div",{className:"rscales-title"},d,this.props.showActiveTime&&s.default.createElement("span",{className:"hours"},(0,l.activeTime)(this.props.events,t,r)+"h")),s.default.createElement("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(s.default.createElement("div",{className:"rscales-dropzone"},this.renderEvents(u,this.props.intervals)))))}}]),t}(),n.defaultProps={titleRenderer:function(e){return s.default.createElement("h2",null,e.title)}},n.propTypes={dragoverEvent:c.default.any,droptime:c.default.any,events:c.default.any,rowData:c.default.object,intervals:c.default.any,dropItem:c.default.any,title:c.default.string,titleRenderer:c.default.func,canDrop:c.default.bool,isOver:c.default.bool,vertical:c.default.any,lastDropCalc:c.default.any,dragoverTickrate:c.default.any},o);h=(0,p.DropTarget)(["RSCALES_EVENT","SCHEDULER_TASK"],{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(e,t){return{connectDropTarget:e.dropTarget(),isOver:t.isOver(),canDrop:t.canDrop(),dropItem:t.getItem(),dropItemType:t.getItemType()}})(h),t.default=h},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)),a=l(r(1)),s=l(r(7)),p=l(r(6));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=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=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,a.default)(t.begins,"x").format(e.props.titleFormat),i.default.createElement("div",{key:"interval-"+t.begins},i.default.createElement("h3",null,r))})))}}]),t}(),v=function(e){function t(e){u(this,t);var r=c(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 d(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&&n.type==p.default?t.push(n):r.push(i.default.cloneElement(n,{vertical:e.props.vertical,dropRounding:e.props.dropRounding,showTitle:e.props.showTitles,showActiveTime:e.props.showActiveTimes,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,onEventDrop:e.props.onEventDrop,onEventClick:e.props.onEventClick}))}),i.default.createElement("div",{className:(0,s.default)("rscales-root",{vertical:this.props.vertical}),style:this.props.style},i.default.createElement(f,{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}();v.defaultProps={style:{},vertical:!1,showTitles:!0,showActiveTimes:!1,dropRounding:a.default.duration({minutes:15}),headerTitleFormat:"ha",minEventDuration:a.default.duration({minutes:15}),dragoverDebounce:200,dragoverTickrate:200,animTransition:"ease-out",eventMargin:5,eventHeight:42,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=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScaledCorner=t.ScaledRow=t.ScaledScheduler=void 0;var n=a(r(10)),o=a(r(9)),i=a(r(6));function a(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("prop-types")},function(e,t){e.exports=require("shallow-utils")},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,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),a=(n=i)&&n.__esModule?n:{default:n};var s=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,a.default.Component),o(t,[{key:"render",value:function(){return this.props.children&&this.props.children.length?a.default.createElement("div",null,this.props.children):this.props.children||null}}]),t}();t.default=s},function(e,t){e.exports=require("classnames")},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=u(r(0)),a=(u(r(1)),r(5)),s=(u(r(2)),u(r(7))),p=r(4),l=r(3);function u(e){return e&&e.__esModule?e:{default:e}}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}var d={beginDrag:function(e,t){return o({},e,{action:"move",grabOffset:e.getDropRealTime()-e.begins})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var i=e.getDropRealTime();i=(0,p.nearestTime)(i-r.grabOffset,e.dropRounding),e.onDrop(r,e.rowData,o({},n,{moveTo:i}))}}};var f={beginDrag:function(e,t){return o({},e,{action:"beforeDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var i=e.getDropRealTime();i=(0,p.nearestTime)(i,e.dropRounding);var a=Math.min(i,+r.ends-e.minEventDuration);e.onDrop(r,e.rowData,o({},n,{begins:a}))}}};var v={beginDrag:function(e,t){return o({},e,{action:"afterDrag"})},endDrag:function(e,t){var r=t.getItem(),n=t.getDropResult();if(null!==n){var i=n.intervals[Math.floor(n.intervals.length*n.droptime)];if(i){var a=n.droptime%(1/n.intervals.length)*n.intervals.length,s=+i.begins+(+i.ends-+i.begins)*a;s=(0,p.nearestTime)(s,e.dropRounding);var l=Math.max(s,+r.begins+e.minEventDuration);e.onDrop(r,e.rowData,o({},n,{ends:l}))}}}};var h=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),a=0;a<o;a++)i[a]=arguments[a];return r=n=c(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)},c(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.Component),n(t,[{key:"shouldComponentUpdate",value:function(e,t){return!(0,l.shallowEqualExcept)(this.props,e,["dropRealTime"])}},{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 a=i.default.createElement("div",{className:"rscales-event-body"},i.default.createElement("div",{className:"rscales-event-contents",style:this.props.style},i.default.createElement("span",{className:"title"},this.props.title),this.props.location&&i.default.createElement("p",{className:"location"},this.props.location)),!this.props.disabled&&r,!this.props.disabled&&n);this.props.disabled||(a=this.props.connectMoveSource(a));var p=i.default.createElement("span",{style:{width:0,height:0}});return i.default.createElement("div",{className:(0,s.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),a)}}]),t}();h=(0,a.DragSource)("RSCALES_EVENT",d,function(e,t){return{connectMoveSource:e.dragSource(),connectMovePreview:e.dragPreview()}})(h),h=(0,a.DragSource)("RSCALES_EVENT",f,function(e,t){return{connectBeforeSource:e.dragSource(),connectBeforePreview:e.dragPreview()}})(h),h=(0,a.DragSource)("RSCALES_EVENT",v,function(e,t){return{afterSource:e.dragSource(),connectAfterPreview:e.dragPreview()}})(h),t.default=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o,i=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},a=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}}(),s=f(r(0)),p=(f(r(1)),r(5)),l=r(4),u=r(3),c=f(r(2)),d=f(r(8));function f(e){return e&&e.__esModule?e:{default:e}}function v(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 h=(o=n=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),a=0;a<o;a++)i[a]=arguments[a];return r=n=v(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.getDropRealTime=function(){var e=n.props.intervals[0].begins,t=n.props.intervals[Math.floor(n.props.intervals.length*n.props.droptime)];if(t){var r=n.props.droptime%(1/n.props.intervals.length)*n.props.intervals.length;e=+t.begins+(+t.ends-+t.begins)*r}return 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)},v(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,s.default.Component),a(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:"shouldComponentUpdate",value:function(e,t){var r=e.isOver&&e.canDrop,n=this.props.isOver&&this.props.canDrop;if(n!=r)return!0;if(n&&this.props.droptime!=e.droptime)return!0;if(!(0,u.shallowEqual)(this.props.events,e.events))return!0;if(!(0,u.shallowEqual)(this.props.rowData,e.rowData))return!0;if(!(0,u.shallowEqual)(this.props.intervals,e.intervals))return!0;return!(0,u.shallowEqualExcept)(this.props,e,["events","rowData","intervals"].concat(["droptime"]))}},{key:"updateDroptime",value:function(e){var t=this.refs.ruler.getBoundingClientRect(),r=0;(r=this.props.vertical?(e.clientY-t.top)/t.height:(e.clientX-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.getDropRealTime();"grabOffset"in this.props.dropItem&&(e-=this.props.dropItem.grabOffset),e=(0,l.nearestTime)(e,this.props.dropRounding);var t=i({},this.props.dropItem,{active:!0});switch(t.action){case"move":var r=+t.ends-+t.begins;t.begins=e,t.ends=+t.begins+r;break;case"beforeDrag":t.begins=Math.min(e,t.ends-this.props.minEventDuration);break;case"afterDrag":t.ends=Math.max(e,t.begins+this.props.minEventDuration)}return t}},{key:"renderEvents",value:function(e,t){var r=this;this.props.isOver&&this.props.canDrop;return e.map(function(e){var n=void 0,o=void 0,a=void 0,p=void 0;t.map(function(t,r){e.begins>=t.begins&&e.begins<t.ends&&(n=t,o=r),e.ends>=t.begins&&e.ends<t.ends&&(a=t,p=r)});var l=o;void 0===l?l=0:(l+=(e.begins-n.begins)/(n.ends-n.begins),l/=t.length),l=Math.max(l,0);var u=p;void 0===u?u=1:(u+=(e.ends-a.begins)/(a.ends-a.begins),u/=t.length);var c=(u=Math.min(u,100))-l,f=Math.max(r.props.eventHeight-8*e.stackIndex,25),v=r.props.eventHeight+2*r.props.eventMargin-f-r.props.eventMargin;return s.default.createElement(d.default,i({key:"event-"+e.id,className:"event"},e,{width:100*c+"%",height:f+"px",top:v+"px",left:100*l+"%",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,getDropRealTime:r.getDropRealTime,rowData:r.props.rowData}))})}},{key:"render",value:function(){var e=this,t=+this.props.intervals[0].begins,r=+this.props.intervals[this.props.intervals.length-1].ends,n=this.props.isOver&&this.props.canDrop,o=[],a=this.props.dropItem?this.props.dropItem.id:null,p=!1;this.props.events.map(function(t){if(a&&t.id==a)if(p=!0,n)o.push(e.adjustedDropItem());else{var r=i({},t);"move"==e.props.dropItem.action&&((r=e.adjustedDropItem()).hidden=!0),o.push(r)}else o.push(t)}),n&&!p&&"move"==this.props.dropItem.action&&o.push(this.adjustedDropItem()),o=(0,l.eventsInRange)(o,t,r);var u=(0,l.stackEvents)(o.sort(l.chronoEventsComparer),0),c={};this.props.vertical?c.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":c.height=this.props.eventHeight+2*this.props.eventMargin+"px";var d=void 0;return this.props.title&&this.props.titleRenderer&&(d=s.default.createElement(this.props.titleRenderer,{title:this.props.title})),s.default.createElement("div",{className:"rscales-row",style:c},this.props.showTitle&&s.default.createElement("div",{className:"rscales-title"},d,this.props.showActiveTime&&s.default.createElement("span",{className:"hours"},(0,l.activeTime)(this.props.events,t,r)+"h")),s.default.createElement("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(s.default.createElement("div",{className:"rscales-dropzone"},this.renderEvents(u,this.props.intervals)))))}}]),t}(),n.defaultProps={titleRenderer:function(e){return s.default.createElement("h2",null,e.title)}},n.propTypes={dragoverEvent:c.default.any,droptime:c.default.any,events:c.default.any,rowData:c.default.object,intervals:c.default.any,dropItem:c.default.any,title:c.default.string,titleRenderer:c.default.func,canDrop:c.default.bool,isOver:c.default.bool,vertical:c.default.any,lastDropCalc:c.default.any,dragoverTickrate:c.default.any},o);h=(0,p.DropTarget)(["RSCALES_EVENT","SCHEDULER_TASK"],{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(e,t){return{connectDropTarget:e.dropTarget(),isOver:t.isOver(),canDrop:t.canDrop(),dropItem:t.getItem(),dropItemType:t.getItemType()}})(h),t.default=h},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)),a=l(r(1)),s=l(r(7)),p=l(r(6));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=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=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,a.default)(t.begins,"x").format(e.props.titleFormat),i.default.createElement("div",{key:"interval-"+t.begins},i.default.createElement("h3",null,r))})))}}]),t}(),v=function(e){function t(e){u(this,t);var r=c(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 d(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&&n.type==p.default?t.push(n):r.push(i.default.cloneElement(n,{vertical:e.props.vertical,dropRounding:e.props.dropRounding,showTitle:e.props.showTitles,showActiveTime:e.props.showActiveTimes,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,onEventDrop:e.props.onEventDrop,onEventClick:e.props.onEventClick}))}),i.default.createElement("div",{className:(0,s.default)("rscales-root",{vertical:this.props.vertical}),style:this.props.style},i.default.createElement(f,{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}();v.defaultProps={style:{},vertical:!1,showTitles:!0,showActiveTimes:!1,dropRounding:a.default.duration({minutes:15}),headerTitleFormat:"ha",minEventDuration:a.default.duration({minutes:15}),dragoverDebounce:200,dragoverTickrate:200,animTransition:"ease-out",eventMargin:5,eventHeight:42,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=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScaledCorner=t.ScaledRow=t.ScaledScheduler=void 0;var n=a(r(10)),o=a(r(9)),i=a(r(6));function a(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.1.2", | ||
"version": "1.1.3", | ||
"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
30617
7