Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-scaled-scheduler

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scaled-scheduler - npm Package Compare versions

Comparing version 1.0.21 to 1.0.22

2

dist/react-scaled-scheduler.js

@@ -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 o=e.getDropRealTime();o=(0,p.nearestTime)(o-r.grabOffset,e.dropRounding),e.onDrop(r,{moveTo:o},n.rowData)}}};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 o=e.getDropRealTime(),i=Math.min(o,+r.ends-e.minEventDuration);e.onDrop(r,{begins:i},n.rowData)}}};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 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 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"},i.default.createElement("span",{className:"title"},this.props.title),this.props.location&&i.default.createElement("p",{className:"location"},this.props.location.trim())),!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}))})}},{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("classnames")},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,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(2)),r(6)),s=(u(r(3)),u(r(1))),p=r(5),l=r(4);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 o=e.getDropRealTime();o=(0,p.nearestTime)(o-r.grabOffset,e.dropRounding),e.onDrop(r,{moveTo:o},n.rowData)}}};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 o=e.getDropRealTime(),i=Math.min(o,+r.ends-e.minEventDuration);e.onDrop(r,{begins:i},n.rowData)}}};var h={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.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.dragoverDebounce/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.location&&i.default.createElement("p",{className:"location"},this.props.location.trim())),!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",d,function(e,t){return{connectMoveSource:e.dragSource(),connectMovePreview:e.dragPreview()}})(v),v=(0,a.DragSource)("RSCALES_EVENT",f,function(e,t){return{connectBeforeSource:e.dragSource(),connectBeforePreview:e.dragPreview()}})(v),v=(0,a.DragSource)("RSCALES_EVENT",h,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,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=h(r(0)),p=h(r(1)),l=(h(r(2)),r(6)),u=r(5),c=r(4),d=h(r(3)),f=h(r(8));function h(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 m=(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.updateDroptime=function(e){var t=n.refs.ruler.getBoundingClientRect(),r=0;(r=n.props.vertical?(e.clientY-t.top)/t.height:(e.clientX-t.left)/t.width)>1?r=1:r<0&&(r=0),"droptimeDebounce"in n&&(window.clearTimeout(n.droptimeDebounce),delete n.droptimeDebounce),n.props.updateDroptime(r)},n.getDropRealTime=function(){return n.props.getDropRealTime(n.props.intervals)},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.updateDroptime),this.refs.ruler.addEventListener("mousemove",this.updateDroptime)}},{key:"componentWillUnmount",value:function(){this.refs.ruler.removeEventListener("dragover",this.updateDroptime),this.refs.ruler.removeEventListener("mousemove",this.updateDroptime)}},{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,c.shallowEqual)(this.props.events,e.events))return!0;if(!(0,c.shallowEqual)(this.props.rowData,e.rowData))return!0;if(!(0,c.shallowEqual)(this.props.intervals,e.intervals))return!0;return!(0,c.shallowEqualExcept)(this.props,e,["events","rowData","intervals"].concat(["droptime"]))}},{key:"adjustedDropItem",value:function(){var e=this.getDropRealTime();"grabOffset"in this.props.dropItem&&(e-=this.props.dropItem.grabOffset),e=(0,u.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,d=Math.max(r.props.eventHeight-8*e.stackIndex,25),h=r.props.eventHeight+2*r.props.eventMargin-d-r.props.eventMargin;return s.default.createElement(f.default,i({key:"event-"+e.id,className:"event"},e,{width:100*c+"%",height:d+"px",top:h+"px",left:100*l+"%",vertical:r.props.vertical,dropRounding:r.props.dropRounding,dragoverDebounce:r.props.dragoverDebounce,animTransition:r.props.animTransition,minEventDuration:r.props.minEventDuration,clickable:null!==r.props.onEventClick,onClick:r.handleEventClick,onDrop:r.props.onEventDrop,getDropRealTime:r.getDropRealTime}))})}},{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,l=!1;this.props.events.map(function(t){if(a&&t.id==a)if(l=!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&&!l&&"move"==this.props.dropItem.action&&o.push(this.adjustedDropItem()),o=(0,u.eventsInRange)(o,t,r);var c=(0,u.stackEvents)(o.sort(u.chronoEventsComparer),0),d={};this.props.vertical?d.flexBasis=this.props.eventHeight+2*this.props.eventMargin+"px":d.height=this.props.eventHeight+2*this.props.eventMargin+"px";var f=void 0;return this.props.title&&this.props.titleRenderer&&(f=s.default.createElement(this.props.titleRenderer,{title:this.props.title})),s.default.createElement("div",{className:"rscales-row",style:d},this.props.showTitle&&s.default.createElement("div",{className:"rscales-title"},f,this.props.showActiveTime&&s.default.createElement("span",{className:"hours"},(0,u.activeTime)(this.props.events,t,r)+"h")),s.default.createElement("div",{className:"rscales-data",ref:"ruler"},this.props.connectDropTarget(s.default.createElement("div",{className:(0,p.default)("rscales-dropzone",{active:n})},this.renderEvents(c,this.props.intervals)))))}}]),t}(),n.defaultProps={titleRenderer:function(e){return s.default.createElement("h2",null,e.title)}},n.propTypes={dragoverEvent:d.default.any,droptime:d.default.any,events:d.default.any,rowData:d.default.object,intervals:d.default.any,dropItem:d.default.any,title:d.default.string,titleRenderer:d.default.func,canDrop:d.default.bool,isOver:d.default.bool,vertical:d.default.any,dragoverTickrate:d.default.any},o);m=(0,l.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()}})(m),t.default=m},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=p(r(0)),i=p(r(2)),a=p(r(1)),s=p(r(7));function p(e){return e&&e.__esModule?e:{default:e}}function l(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 c(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 d=function(e){function t(){return l(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,o.default.Component),n(t,[{key:"render",value:function(){var e=this;return o.default.createElement("div",{className:"rscales-header"},this.props.showTitle&&o.default.createElement("div",{className:"rscales-title"},this.props.children),o.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,i.default)(t.begins,"x").format(e.props.titleFormat),o.default.createElement("div",{key:"interval-"+t.begins},o.default.createElement("h3",null,r))})))}}]),t}(),f=function(e){function t(){var e,r,n;l(this,t);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return r=n=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),n.state={droptime:0,lastDropUpdate:0},n.updateDroptime=function(e){n.currentDroptime=e,+(new Date).getTime()-n.state.lastDropUpdate<n.props.dragoverDebounce?n.updateDroptimeState():(window.clearTimeout(n.droptimeDebounce),n.droptimeDebounce=window.setTimeout(n.updateDroptimeState,n.dragoverDebounce))},n.updateDroptimeState=function(){n.setState({droptime:n.currentDroptime,lastDropUpdate:+(new Date).getTime()})},n.getDropRealTime=function(e){var t=n.droptime||n.state.droptime,r=e[0].begins,o=e[Math.floor(e.length*t)];if(o){var i=t%(1/e.length)*e.length;r=+o.begins+(+o.ends-+o.begins)*i}return r},u(n,r)}return c(t,o.default.Component),n(t,[{key:"render",value:function(){var e=this,t=[],r=[];return o.default.Children.map(this.props.children,function(n){n&&"type"in n&&n.type==s.default?t.push(n):r.push(o.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,animTransition:e.props.animTransition,eventMargin:e.props.eventMargin,eventHeight:e.props.eventHeight,droptime:e.state.droptime,getDropRealTime:e.getDropRealTime,updateDroptime:e.updateDroptime,onEventDrop:e.props.onEventDrop,onEventClick:e.props.onEventClick}))}),o.default.createElement("div",{className:(0,a.default)("rscales-root",{vertical:this.props.vertical}),style:this.props.style},o.default.createElement(d,{vertical:this.props.vertical,showTitle:this.props.showTitles,intervals:this.props.intervals,titleFormat:this.props.headerTitleFormat},t),o.default.createElement("div",{className:"rscales-body"},r))}}]),t}();f.defaultProps={style:{},vertical:!1,showTitles:!0,showActiveTimes:!1,dropRounding:i.default.duration({minutes:15}),headerTitleFormat:"ha",minEventDuration:i.default.duration({minutes:15}),dragoverDebounce: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=f},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(7));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.21",
"version": "1.0.22",
"description": "Scheduler with events drawn to scale along a time axis, with drag and drop support",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc