react-scaled-scheduler
Advanced tools
Comparing version 1.0.14 to 1.0.15
@@ -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=10)}([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,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(6)),l(r(5))),p=r(2);function l(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 u={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=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.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",u,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,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=l(r(7));function l(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 u=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=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 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),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 c=s;void 0===c?c=0:(c+=(e.begins-o.begins)/(o.ends-o.begins),c/=t.length),c=Math.max(c,0);var u=l;void 0===u?u=1:(u+=(e.ends-a.begins)/(a.ends-a.begins),u/=t.length);var d=(u=Math.min(u,100))-c,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*c+"%",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 c=(0,a.stackEvents)(s.sort(a.chronoEventsComparer),0),u={};return this.props.vertical?u.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":u.height=this.props.eventHeight+2*this.props.eventMargin+"px",i.default.createElement("div",{className:"rscales-row",style:u},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("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(i.default.createElement("div",{className:"rscales-dropzone"},this.renderEvents(c,this.props.intervals)))))}}]),t}();u=(0,s.DropTarget)(function(e){return["RSCALES_EVENT"].concat(e.customDropTypes)},{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()}})(u),t.default=u},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)),a=l(r(5)),p=l(r(4));function l(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 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}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)}!function(e){function t(){return c(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}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,s.default)(t.begins,"x").format(e.props.titleFormat),i.default.createElement("div",{key:"interval-"+t.begins},i.default.createElement("h3",null,r))})))}}])}();var f=function(e){function t(e){c(this,t);var r=u(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,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}))}),i.default.createElement("div",{className:(0,a.default)("rscales-root",{vertical:this.props.vertical}),style:this.props.style},this.props.children)}}]),t}();f.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=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ScaledCorner=t.ScaledRow=t.ScaledScheduler=void 0;var n=s(r(9)),o=s(r(8)),i=s(r(4));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=10)}([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,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){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)),a=(l(r(1)),r(3)),s=(l(r(6)),l(r(5))),p=r(2);function l(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 u={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,a=+o.begins+(+o.ends-+o.begins)*i;a=(0,p.nearestTime)(a,e.dropRounding),e.onDrop(r,{moveTo:a},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,a=+o.begins+(+o.ends-+o.begins)*i;a=(0,p.nearestTime)(a,e.dropRounding);var s=Math.min(a,+r.ends-e.minEventDuration);e.onDrop(r,{begins:s},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,a=+o.begins+(+o.ends-+o.begins)*i;a=(0,p.nearestTime)(a,e.dropRounding);var s=Math.max(a,+r.begins+e.minEventDuration);e.onDrop(r,{ends:s},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),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.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 a=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||(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}();v=(0,a.DragSource)("RSCALES_EVENT",u,function(e,t){return{connectMoveSource:e.dragSource(),connectMovePreview:e.dragPreview()}})(v),v=(0,a.DragSource)("RSCALES_EVENT",d,function(e,t){return{connectBeforeSource:e.dragSource(),connectBeforePreview:e.dragPreview()}})(v),v=(0,a.DragSource)("RSCALES_EVENT",f,function(e,t){return{afterSource:e.dragSource(),connectAfterPreview:e.dragPreview()}})(v),t.default=v},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)),r(3)),s=r(2),p=l(r(7));function l(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 u=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.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 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),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,s.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,a=void 0,s=void 0,l=void 0;t.map(function(t,r){e.begins>=t.begins&&e.begins<t.ends&&(o=t,a=r),e.ends>=t.begins&&e.ends<t.ends&&(s=t,l=r)});var c=a;void 0===c?c=0:(c+=(e.begins-o.begins)/(o.ends-o.begins),c/=t.length),c=Math.max(c,0);var u=l;void 0===u?u=1:(u+=(e.ends-s.begins)/(s.ends-s.begins),u/=t.length);var d=(u=Math.min(u,100))-c,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*c+"%",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,a=[],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)a.push(e.adjustedDropItem());else{var r=n({},t);"move"==e.props.dropItem.action&&((r=e.adjustedDropItem()).hidden=!0),a.push(r)}else a.push(t)}),o&&!l&&"move"==this.props.dropItem.action&&a.push(this.adjustedDropItem()),a=(0,s.eventsInRange)(a,t,r);var c=(0,s.stackEvents)(a.sort(s.chronoEventsComparer),0),u={};return this.props.vertical?u.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":u.height=this.props.eventHeight+2*this.props.eventMargin+"px",i.default.createElement("div",{className:"rscales-row",style:u},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("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(i.default.createElement("div",{className:"rscales-dropzone"},this.renderEvents(c,this.props.intervals)))))}}]),t}();u=(0,a.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()}})(u),t.default=u},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(5)),p=l(r(4));function l(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 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}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 c(this,t),u(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){c(this,t);var r=u(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,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,dropRounding:a.default.duration({minutes:15}),headerTitleFormat:"ha",minEventDuration:a.default.duration({minutes:15}),dragoverDebounce:50,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(9)),o=a(r(8)),i=a(r(4));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.0.14", | ||
"version": "1.0.15", | ||
"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
28417