New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@marinos33/react-week-time-range-picker

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marinos33/react-week-time-range-picker - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

5

dist/cjs/index.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e);
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}r(".wtrp-fl {\n float: left;\n}\n.wtrp-fr {\n float: right;\n}\n.wtrp-flex {\n display: flex;\n}\n.wtrp-flex-1 {\n flex: 1;\n}\n.wtrp-break {\n word-break: break-all;\n}\n");r(".week-time-range-picker {\n position: relative;\n display: inline-block;\n}\n.week-time-range-picker .wtrp-schedule {\n background: #598fe6;\n width: 0;\n height: 0;\n position: fixed;\n opacity: 0.6;\n top: 0;\n left: 0;\n pointer-events: none;\n -webkit-transition: all 0.4s ease;\n -moz-transition: all 0.4s ease;\n -ms-transition: all 0.4s ease;\n transition: all 0.4s ease;\n}\n.week-time-range-picker .wtrp-table {\n background-color: transparent;\n border-collapse: collapse;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper {\n text-align: left;\n display: inline-block;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .transition-popover-enter-active,\n.week-time-range-picker .wtrp-byted-popover-wrapper .transition-popover-appear {\n opacity: 0;\n animation: popoverTransitionIn 0.5s;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .transition-drop-leave-active {\n animation: popoverTransitionOut 0.5s;\n}\n@keyframes popoverTransitionIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n@keyframes popoverTransitionOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n color: rgba(0, 0, 0, 0.65);\n font-size: 14px;\n font-variant: tabular-nums;\n line-height: 1.5;\n list-style: none;\n font-feature-settings: 'tnum';\n position: absolute;\n z-index: 1060;\n display: block;\n max-width: 250px;\n visibility: visible;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip-placement-top .ant-tooltip-arrow {\n left: 50%;\n transform: translateX(-50%);\n position: absolute;\n display: block;\n width: 13.07106781px;\n height: 13.07106781px;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n bottom: -12.07106781px;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip-placement-top .ant-tooltip-arrow::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: 5px;\n height: 5px;\n margin: auto;\n background-color: rgba(0, 0, 0, 0.75);\n content: '';\n pointer-events: auto;\n box-shadow: 3px 3px 7px rgba(0, 0, 0, 0.07);\n transform: translateY(-6.53553391px) rotate(45deg);\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip-placement-top .ant-tooltip-inner {\n min-width: 30px;\n min-height: 32px;\n padding: 6px 8px;\n color: #fff;\n text-align: left;\n text-decoration: none;\n word-wrap: break-word;\n background-color: rgba(0, 0, 0, 0.75);\n border-radius: 4px;\n -webkit-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n}\n");
/*! *****************************************************************************

@@ -15,3 +15,4 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function a(e,t,r){if(r||2===arguments.length)for(var a,n=0,o=t.length;n<o;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}const n=[{hour:0,time:"00:00"},{hour:30,time:"00:30"},{hour:1,time:"01:00"},{hour:30,time:"01:30"},{hour:2,time:"02:00"},{hour:30,time:"02:30"},{hour:3,time:"03:00"},{hour:30,time:"03:30"},{hour:4,time:"04:00"},{hour:30,time:"04:30"},{hour:5,time:"05:00"},{hour:30,time:"05:30"},{hour:6,time:"06:00"},{hour:30,time:"06:30"},{hour:7,time:"07:00"},{hour:30,time:"07:30"},{hour:8,time:"08:00"},{hour:30,time:"08:30"},{hour:9,time:"09:00"},{hour:30,time:"09:30"},{hour:10,time:"10:00"},{hour:30,time:"10:30"},{hour:11,time:"11:00"},{hour:30,time:"11:30"},{hour:12,time:"12:00"},{hour:30,time:"12:30"},{hour:13,time:"13:00"},{hour:30,time:"13:30"},{hour:14,time:"14:00"},{hour:30,time:"14:30"},{hour:15,time:"15:00"},{hour:30,time:"15:30"},{hour:16,time:"16:00"},{hour:30,time:"16:30"},{hour:17,time:"17:00"},{hour:30,time:"17:30"},{hour:18,time:"18:00"},{hour:30,time:"18:30"},{hour:19,time:"19:00"},{hour:30,time:"19:30"},{hour:20,time:"20:00"},{hour:30,time:"20:30"},{hour:21,time:"21:00"},{hour:30,time:"21:30"},{hour:22,time:"22:00"},{hour:30,time:"22:30"},{hour:23,time:"23:00"},{hour:30,time:"23:30"}],o=[{hour:0,time:"00:00"},{hour:1,time:"01:00"},{hour:2,time:"02:00"},{hour:3,time:"03:00"},{hour:4,time:"04:00"},{hour:5,time:"05:00"},{hour:6,time:"06:00"},{hour:7,time:"07:00"},{hour:8,time:"08:00"},{hour:9,time:"09:00"},{hour:10,time:"10:00"},{hour:11,time:"11:00"},{hour:12,time:"12:00"},{hour:13,time:"13:00"},{hour:14,time:"14:00"},{hour:15,time:"15:00"},{hour:16,time:"16:00"},{hour:17,time:"17:00"},{hour:18,time:"18:00"},{hour:19,time:"19:00"},{hour:20,time:"20:00"},{hour:21,time:"21:00"},{hour:22,time:"22:00"},{hour:23,time:"23:00"}],i=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],u=["00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00","05:30","06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00","23:30"],l=[{iden:"1",dayName:"Monday"},{iden:"2",dayName:"Tuesday"},{iden:"3",dayName:"Wednesday"},{iden:"4",dayName:"Thursday"},{iden:"5",dayName:"Friday"},{iden:"6",dayName:"Saturday"},{iden:"7",dayName:"Sunday"}],c=new Map;l.forEach((e=>{c.set(e.iden,e.dayName)}));const s=(e,t)=>e-t,d=(e,t)=>e.substring(0,2)-t.substring(0,2),m=({cacheChecked:e,hasStart:t,has:r,idenIndex:a,iden:n,timeRange:o})=>{let i={iden:n,times:[]},u=-1;t||r||e.push(i);for(let n of o)if(u=r?e[a].times.indexOf(n):-1,t&&r){if(u>=0&&e[a].times.splice(u,1),0===e[a].times.length){e.splice(a,1);break}}else if(!t){if(-1===u&&a>=0){e[a].times.push(n);continue}i.times.push(n)}};var h=function(e,t){return e.iden?e.iden-t.iden:e.substring(0,2)===t.substring(0,2)?e.substring(3)-t.substring(3):e.substring(0,2)-t.substring(0,2)},f=function(e,t){e.forEach((function(r){var a=t.slice(-1)[0],n=r.substring(0,2)-a.slice(-1)[0].substring(0,2)==1;n&&a.push(r),n||r===e[0]||t.push([r])}))},p=function(e,t){e.forEach((function(r){var a=t.slice(-1)[0],n=a.slice(-1)[0],o=100*r.substring(0,2)+("30"===r.substring(3)?50:0)-(100*n.substring(0,2)+("30"===n.substring(3)?50:0))==50;o&&a.push(r),o||r===e[0]||t.push([r])})),t.forEach((function(e){var t=+e.slice(-1)[0].substring(0,2);"30"===e.slice(-1)[0].substring(3)?t>8?e.push("".concat(t+1,":00")):e.push("0".concat(t+1,":00")):t>8?e.push("".concat(t,":30")):e.push("0".concat(t,":30"))}))},y=function(e){var t=e.hasHalfHour,a=e.checkedDatas,n=e.handleEmpty,o=e.summaryColor,i=e.fontColor,u=a.filter((function(e){return""!==e.iden}))||[];u.sort(h),u.forEach((function(e,r){u[r].dayName=c.get(e.iden),e.times.sort(h),u[r].timeRanges=function(e,t){var r=[[t[0]]];return e?p(t,r):f(t,r),r}(t,e.times)}));return r.default.createElement("tr",{className:"wtrp-time-range-selected",style:{backgroundColor:o}},r.default.createElement("td",{colSpan:49,className:"wtrp-selected-td"},r.default.createElement("div",{className:"wtrp-clearfix"},0===a.length?r.default.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Drag the mouse to select the time period"):r.default.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Time period selected"),r.default.createElement("a",{className:"wtrp-fr",onClick:function(){n()},style:{color:i}},"clear selection")),u.map((function(e,t){return r.default.createElement("div",{className:"wtrp-selected-td__selected-time",key:t},r.default.createElement("p",{className:"wtrp-flex wtrp-break"},r.default.createElement("span",{className:"tip-text",style:{color:i}},e.dayName,":"),r.default.createElement("span",{className:"wtrp-flex-1"},e.timeRanges.map((function(e,t){return console.log(e),r.default.createElement("span",{className:"wtrp-selected-text",key:t,style:{color:i}},"".concat(e[0],"~").concat(e[e.length-1]))})))))}))))},g=!1,v=!1,E={cacheStart:{iden:"",hour:"",group:""},cacheEnd:{iden:"",hour:"",group:""}},C=function(t){var c=e.useState(t.checkedDatas),h=c[0],f=c[1];e.useEffect((function(){return document.body.addEventListener("mouseup",w),function(){return document.body.removeEventListener("mouseup",w)}}));var p=t.hasHalfHour,C=t.handleDrag,b=t.handleSelect,x=t.handleMoveOut,N=t.fontColor,S=p?n:o,k=p?1:2,w=function(e){e&&!e.target.dataset.hour&&(v=!1)},H=function(e,t){if(e.target.dataset.hour){var r=e.target.dataset.iden,n=e.target.dataset.hour;return E[t].iden=r,E[t].hour=n,E[t].group=r+n,"cacheStart"===t&&Y(r,n),"cacheEnd"===t&&E[t].group===E.cacheStart.group&&function(e,t){var r=h,n=Y(e,t),o=n.has,i=n.idenIndex,u=n.index;o?g?(1===r[i].times.length?r.splice(i,1):r[i].times.splice(u,1),f(a([],r,!0))):(r[i].times.push(t),f(a([],r,!0))):(r.push({iden:e,times:[t]}),f(a([],r,!0)))}(r,n),"cacheEnd"===t&&E[t].group!==E.cacheStart.group&&D(),!0}return!1},X=function(e){E[e].iden="",E[e].hour="",E[e].group=""},Y=function(e,t){g=!1;for(var r,a,n=h,o=n.length,i=!1,u=0;u<o;u++)if(n[u].iden===e){a=u,r=n[u].times.indexOf(t),i=!0,g=-1!==r;break}return{has:i,idenIndex:a,index:r}},D=function(){var e=[E.cacheStart.iden,E.cacheEnd.iden],t=[E.cacheStart.hour,E.cacheEnd.hour],r=g,a=JSON.parse(JSON.stringify(h));e.sort(s),t.sort(d);for(var n=(e=>{let t=[];for(let r=e[0];r<=e[1];r++)t.push(String(r));return t})(e),o=((e,t)=>{let r,a;return e?(r=u.indexOf(t[0]),a=u.indexOf(t[1]),u.slice(r,a+1)):(r=i.indexOf(t[0]),a=i.indexOf(t[1]),i.slice(r,a+1))})(p,t),l=0,c=n;l<c.length;l++){var y=c[l],v=Y(y),C=v.has,b=v.idenIndex;m({cacheChecked:a,hasStart:r,has:C,idenIndex:b,iden:y,timeRange:o})}f(a)};return r.default.createElement("tbody",{className:"wtrp-tbody",onMouseDown:function(e){if(e.preventDefault(),e.stopPropagation(),v=!0,H(e,"cacheStart")){var t={type:"down",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:E.cacheStart.iden,hour:E.cacheStart.hour};C(t)}Y(E.cacheStart.iden,E.cacheStart.hour)},onMouseUp:function(e){e.preventDefault(),e.stopPropagation(),v=!1,H(e,"cacheEnd"),X("cacheStart"),X("cacheEnd"),C({type:"up"}),b(h)},onMouseMove:function(e){if(e.target.dataset.hour){x(!1);var t={type:"move",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:e.target.dataset.iden,hour:e.target.dataset.hour,value:e.target.dataset.value,isDrag:v};C(t)}}},l.map((function(e,a){return r.default.createElement("tr",{className:"wtrp-tbody-tr",key:a},r.default.createElement("td",{className:"week-td",style:{backgroundColor:t.outerCellColor,color:N}},e.dayName),S.map((function(a,n){var o=h.some((function(t){return t.iden===e.iden&&-1!==t.times.indexOf(a.time)}));return r.default.createElement("td",{colSpan:k,style:o?null:{backgroundColor:t.innerCellColor},className:o?"wtrp-active-td":"wtrp-freeze-td",key:n,"data-hour":a.time,"data-iden":e.iden,"data-value":"".concat(e.dayName," ").concat(a.time)})})))})),r.default.createElement(y,{hasHalfHour:p,checkedDatas:h,handleEmpty:function(){g=!1,X("cacheStart"),X("cacheEnd"),f([])},summaryColor:t.summaryColor,fontColor:t.fontColor}))},b=function(e){var t=e.hasHalfHour?n:o,a=e.hasHalfHour?1:2;return r.default.createElement("thead",null,r.default.createElement("tr",null,r.default.createElement("th",{rowSpan:8,className:"week-td",style:{backgroundColor:e.outerCellColor,color:e.fontColor}},"day/hour"),t.map((function(t,n){return r.default.createElement("td",{colSpan:a,style:{backgroundColor:e.outerCellColor,color:e.fontColor},key:n},t.time)}))))},x=0,N=0,S=0,k=0,w=0,H=0;exports.ReactWeekTimeRangePicker=function(t){var a=e.useState(!1),n=a[0],o=a[1],i=e.useState(0),u=i[0],l=i[1],c=e.useState(0),s=c[0],d=c[1],m=e.useState(0),h=m[0],f=m[1],p=e.useState(0),y=p[0],g=p[1],v=e.useState(t.selectedData||[]),E=v[0],X=v[1];e.useEffect((function(){return document.body.addEventListener("mouseup",W),document.body.addEventListener("mousemove",T),function(){document.body.removeEventListener("mouseup",W),document.body.removeEventListener("mousemove",T)}}));var Y=t.selectTimeRange,D=t.outerCellColor,M=t.innerCellColor,O=t.fontColor,I=t.summaryColor,R=t.hasHalfHour,L=void 0!==R&&R,W=function(e){e&&!e.target.dataset.hour&&o(!1)},T=function(e){e.target.dataset.hour},P=function(e){var t=e.clientX,r=e.clientY,a=e.layerX,n=e.layerY,i=e.iden,u=e.tdIndex;f(0),g(0),o(!0),x=t,H=a-16*u-60,S=16*u+60,k=20*~~i+40,l((N=r)-(w=n-20*i-40)),d(x-H)},_=function(e){var t=e.isDrag,r=e.layerX,a=e.layerY,n=e.tempWidth,o=e.tempHeight;if(e.iden,e.hour,e.value,t){var i=r-S,u=a-k;o=u>0?u:20-u;var c=(n=i>0?i:16-i)%20==0&&i>0?16*Math.ceil(n/16)+1:16*Math.ceil(n/16),s=o%20==0&&u>0?20*Math.ceil(o/20)+20:20*Math.ceil(o/20);f(c),g(s),d(i<0?x-H-h+25:x-H),l(u<0?N-w-y+10:N-w)}};return r.default.createElement("div",{className:"week-time-range-picker",style:L?{maxWidth:"830px"}:{maxWidth:"450px"}},n?r.default.createElement("div",{className:"wtrp-schedule",style:{left:"".concat(s,"px"),top:"".concat(u,"px"),width:"".concat(h,"px"),height:"".concat(y,"px")}}):null,r.default.createElement("table",{className:"wtrp-table"},r.default.createElement(b,{hasHalfHour:L,outerCellColor:D,fontColor:O}),r.default.createElement(C,{hasHalfHour:L,checkedDatas:E,handleDrag:function(e){var t=e.type,r=e.clientX,a=e.clientY,n=e.layerX,i=e.layerY,u=e.iden,l=e.hour,c=e.value,s=e.isDrag;if("up"!==t){var d=L?2:1,m=l.split(":"),h=~~m[1]?~~m[0]*d+1:~~m[0]*d;"down"===t?P({clientX:r,clientY:a,layerX:n,layerY:i,iden:u,tdIndex:h}):_({isDrag:s,layerX:n,layerY:i,tempWidth:undefined,tempHeight:undefined,iden:u,hour:l,value:c})}else o(!1)},handleSelect:function(e){X(e),Y&&Y(e)},handleMoveOut:function(e){},outerCellColor:D,innerCellColor:M,summaryColor:I,fontColor:O})))};
***************************************************************************** */
function a(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}r(".week-time-range-picker,\n.week-time-range-picker :after,\n.week-time-range-picker :before {\n -webkit-box-sizing: border-box;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n.week-time-range-picker .wtrp-table tr,\n.week-time-range-picker .wtrp-table td,\n.week-time-range-picker .wtrp-table th {\n border: 1px solid #DDDEE1;\n font-size: 12px;\n text-align: center;\n -webkit-transition: background 0.2s ease;\n -moz-transition: background 0.2s ease;\n -ms-transition: background 0.2s ease;\n transition: background 0.2s ease;\n user-select: none;\n margin: 0;\n padding: 0;\n min-width: 35px;\n width: 16px;\n height: 20px;\n box-sizing: border-box;\n}\n.week-time-range-picker .wtrp-table tr .week-td,\n.week-time-range-picker .wtrp-table td .week-td,\n.week-time-range-picker .wtrp-table th .week-td {\n width: 60px;\n}\n");const o=[{hour:0,time:"00:00"},{hour:30,time:"00:30"},{hour:1,time:"01:00"},{hour:30,time:"01:30"},{hour:2,time:"02:00"},{hour:30,time:"02:30"},{hour:3,time:"03:00"},{hour:30,time:"03:30"},{hour:4,time:"04:00"},{hour:30,time:"04:30"},{hour:5,time:"05:00"},{hour:30,time:"05:30"},{hour:6,time:"06:00"},{hour:30,time:"06:30"},{hour:7,time:"07:00"},{hour:30,time:"07:30"},{hour:8,time:"08:00"},{hour:30,time:"08:30"},{hour:9,time:"09:00"},{hour:30,time:"09:30"},{hour:10,time:"10:00"},{hour:30,time:"10:30"},{hour:11,time:"11:00"},{hour:30,time:"11:30"},{hour:12,time:"12:00"},{hour:30,time:"12:30"},{hour:13,time:"13:00"},{hour:30,time:"13:30"},{hour:14,time:"14:00"},{hour:30,time:"14:30"},{hour:15,time:"15:00"},{hour:30,time:"15:30"},{hour:16,time:"16:00"},{hour:30,time:"16:30"},{hour:17,time:"17:00"},{hour:30,time:"17:30"},{hour:18,time:"18:00"},{hour:30,time:"18:30"},{hour:19,time:"19:00"},{hour:30,time:"19:30"},{hour:20,time:"20:00"},{hour:30,time:"20:30"},{hour:21,time:"21:00"},{hour:30,time:"21:30"},{hour:22,time:"22:00"},{hour:30,time:"22:30"},{hour:23,time:"23:00"},{hour:30,time:"23:30"}],i=[{hour:0,time:"00:00"},{hour:1,time:"01:00"},{hour:2,time:"02:00"},{hour:3,time:"03:00"},{hour:4,time:"04:00"},{hour:5,time:"05:00"},{hour:6,time:"06:00"},{hour:7,time:"07:00"},{hour:8,time:"08:00"},{hour:9,time:"09:00"},{hour:10,time:"10:00"},{hour:11,time:"11:00"},{hour:12,time:"12:00"},{hour:13,time:"13:00"},{hour:14,time:"14:00"},{hour:15,time:"15:00"},{hour:16,time:"16:00"},{hour:17,time:"17:00"},{hour:18,time:"18:00"},{hour:19,time:"19:00"},{hour:20,time:"20:00"},{hour:21,time:"21:00"},{hour:22,time:"22:00"},{hour:23,time:"23:00"}],l=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],c=["00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00","05:30","06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00","23:30"],s=[{iden:"1",dayName:"Monday"},{iden:"2",dayName:"Tuesday"},{iden:"3",dayName:"Wednesday"},{iden:"4",dayName:"Thursday"},{iden:"5",dayName:"Friday"},{iden:"6",dayName:"Saturday"},{iden:"7",dayName:"Sunday"}],u=new Map;s.forEach((e=>{u.set(e.iden,e.dayName)}));const d=(e,t)=>e-t,p=(e,t)=>e.substring(0,2)-t.substring(0,2),m=({cacheChecked:e,hasStart:t,has:n,idenIndex:r,iden:a,timeRange:o})=>{let i={iden:a,times:[]},l=-1;t||n||e.push(i);for(let a of o)if(l=n?e[r].times.indexOf(a):-1,t&&n){if(l>=0&&e[r].times.splice(l,1),0===e[r].times.length){e.splice(r,1);break}}else if(!t){if(-1===l&&r>=0){e[r].times.push(a);continue}i.times.push(a)}};r(".wtrp-tbody-tr > td + td {\n cursor: pointer;\n}\n.wtrp-freeze-td {\n background: #f5f5f5;\n}\n.wtrp-active-td {\n background-color: #0590FF;\n}\n");r('.wtrp-selected-td {\n padding: 0 10px!important;\n}\n.wtrp-selected-td .tip-text {\n color: #999;\n}\n.wtrp-selected-td .wtrp-clearfix:before {\n content: " ";\n display: table;\n}\n.wtrp-selected-td .wtrp-clearfix:after {\n content: " ";\n display: table;\n clear: both;\n}\n.wtrp-selected-td .wtrp-selected-td__selected-time {\n text-align: left;\n line-height: 1;\n}\n.wtrp-selected-td .wtrp-selected-td__selected-time .wtrp-selected-text {\n padding-right: 5px;\n}\n.wtrp-selected-td a {\n cursor: pointer;\n color: #598fe6;\n}\n');var h=function(e,t){return e.iden?e.iden-t.iden:e.substring(0,2)===t.substring(0,2)?e.substring(3)-t.substring(3):e.substring(0,2)-t.substring(0,2)},f=function(e,t){e.forEach((function(n){var r=t.slice(-1)[0],a=n.substring(0,2)-r.slice(-1)[0].substring(0,2)==1;a&&r.push(n),a||n===e[0]||t.push([n])}))},g=function(e,t){e.forEach((function(n){var r=t.slice(-1)[0],a=r.slice(-1)[0],o=100*n.substring(0,2)+("30"===n.substring(3)?50:0)-(100*a.substring(0,2)+("30"===a.substring(3)?50:0))==50;o&&r.push(n),o||n===e[0]||t.push([n])})),t.forEach((function(e){var t=+e.slice(-1)[0].substring(0,2);"30"===e.slice(-1)[0].substring(3)?t>8?e.push("".concat(t+1,":00")):e.push("0".concat(t+1,":00")):t>8?e.push("".concat(t,":30")):e.push("0".concat(t,":30"))}))},b=function(e){var t=e.hasHalfHour,r=e.checkedDatas,a=e.handleEmpty,o=e.summaryColor,i=e.fontColor,l=r.filter((function(e){return""!==e.iden}))||[];l.sort(h),l.forEach((function(e,n){l[n].dayName=u.get(e.iden),e.times.sort(h),l[n].timeRanges=function(e,t){var n=[[t[0]]];return e?g(t,n):f(t,n),n}(t,e.times)}));return n.default.createElement("tr",{className:"wtrp-time-range-selected",style:{backgroundColor:o}},n.default.createElement("td",{colSpan:49,className:"wtrp-selected-td"},n.default.createElement("div",{className:"wtrp-clearfix"},0===r.length?n.default.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Drag the mouse to select the time period"):n.default.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Time period selected"),n.default.createElement("a",{className:"wtrp-fr",onClick:function(){a()},style:{color:i}},"clear selection")),l.map((function(e,t){return n.default.createElement("div",{className:"wtrp-selected-td__selected-time",key:t},n.default.createElement("p",{className:"wtrp-flex wtrp-break"},n.default.createElement("span",{className:"tip-text",style:{color:i}},e.dayName,":"),n.default.createElement("span",{className:"wtrp-flex-1"},e.timeRanges.map((function(e,t){return console.log(e),n.default.createElement("span",{className:"wtrp-selected-text",key:t,style:{color:i}},"".concat(e[0],"~").concat(e[e.length-1]))})))))}))))},w=!1,y=!1,v={cacheStart:{iden:"",hour:"",group:""},cacheEnd:{iden:"",hour:"",group:""}},k=function(t){var r=e.useState(t.checkedDatas),u=r[0],h=r[1];e.useEffect((function(){return document.body.addEventListener("mouseup",S),function(){return document.body.removeEventListener("mouseup",S)}}));var f=t.hasHalfHour,g=t.handleDrag,k=t.handleSelect,x=t.handleMoveOut,E=t.fontColor,C=f?o:i,N=f?1:2,S=function(e){e&&!e.target.dataset.hour&&(y=!1)},D=function(e,t){if(e.target.dataset.hour){var n=e.target.dataset.iden,r=e.target.dataset.hour;return v[t].iden=n,v[t].hour=r,v[t].group=n+r,"cacheStart"===t&&X(n,r),"cacheEnd"===t&&v[t].group===v.cacheStart.group&&function(e,t){var n=u,r=X(e,t),o=r.has,i=r.idenIndex,l=r.index;o?w?(1===n[i].times.length?n.splice(i,1):n[i].times.splice(l,1),h(a([],n,!0))):(n[i].times.push(t),h(a([],n,!0))):(n.push({iden:e,times:[t]}),h(a([],n,!0)))}(n,r),"cacheEnd"===t&&v[t].group!==v.cacheStart.group&&Y(),!0}return!1},H=function(e){v[e].iden="",v[e].hour="",v[e].group=""},X=function(e,t){w=!1;for(var n,r,a=u,o=a.length,i=!1,l=0;l<o;l++)if(a[l].iden===e){r=l,n=a[l].times.indexOf(t),i=!0,w=-1!==n;break}return{has:i,idenIndex:r,index:n}},Y=function(){var e=[v.cacheStart.iden,v.cacheEnd.iden],t=[v.cacheStart.hour,v.cacheEnd.hour],n=w,r=JSON.parse(JSON.stringify(u));e.sort(d),t.sort(p);for(var a=(e=>{let t=[];for(let n=e[0];n<=e[1];n++)t.push(String(n));return t})(e),o=((e,t)=>{let n,r;return e?(n=c.indexOf(t[0]),r=c.indexOf(t[1]),c.slice(n,r+1)):(n=l.indexOf(t[0]),r=l.indexOf(t[1]),l.slice(n,r+1))})(f,t),i=0,s=a;i<s.length;i++){var g=s[i],b=X(g),y=b.has,k=b.idenIndex;m({cacheChecked:r,hasStart:n,has:y,idenIndex:k,iden:g,timeRange:o})}h(r)};return n.default.createElement("tbody",{className:"wtrp-tbody",onMouseDown:function(e){if(e.preventDefault(),e.stopPropagation(),y=!0,D(e,"cacheStart")){var t={type:"down",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:v.cacheStart.iden,hour:v.cacheStart.hour};g(t)}X(v.cacheStart.iden,v.cacheStart.hour)},onMouseUp:function(e){e.preventDefault(),e.stopPropagation(),y=!1,D(e,"cacheEnd"),H("cacheStart"),H("cacheEnd"),g({type:"up"}),k(u)},onMouseMove:function(e){if(e.target.dataset.hour){x(!1);var t={type:"move",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:e.target.dataset.iden,hour:e.target.dataset.hour,value:e.target.dataset.value,isDrag:y};g(t)}}},s.map((function(e,r){return n.default.createElement("tr",{className:"wtrp-tbody-tr",key:r},n.default.createElement("td",{className:"week-td",style:{backgroundColor:t.outerCellColor,color:E}},e.dayName),C.map((function(r,a){var o=u.some((function(t){return t.iden===e.iden&&-1!==t.times.indexOf(r.time)}));return n.default.createElement("td",{colSpan:N,style:o?null:{backgroundColor:t.innerCellColor},className:o?"wtrp-active-td":"wtrp-freeze-td",key:a,"data-hour":r.time,"data-iden":e.iden,"data-value":"".concat(e.dayName," ").concat(r.time)})})))})),n.default.createElement(b,{hasHalfHour:f,checkedDatas:u,handleEmpty:function(){w=!1,H("cacheStart"),H("cacheEnd"),h([])},summaryColor:t.summaryColor,fontColor:t.fontColor}))},x=function(e){var t=e.hasHalfHour?o:i,r=e.hasHalfHour?1:2;return n.default.createElement("thead",null,n.default.createElement("tr",null,n.default.createElement("th",{rowSpan:8,className:"week-td",style:{backgroundColor:e.outerCellColor,color:e.fontColor}},"day/hour"),t.map((function(t,a){return n.default.createElement("td",{colSpan:r,style:{backgroundColor:e.outerCellColor,color:e.fontColor},key:a},t.time)}))))},E=0,C=0,N=0,S=0,D=0,H=0;exports.ReactWeekTimeRangePicker=function(t){var r=e.useState(!1),a=r[0],o=r[1],i=e.useState(0),l=i[0],c=i[1],s=e.useState(0),u=s[0],d=s[1],p=e.useState(0),m=p[0],h=p[1],f=e.useState(0),g=f[0],b=f[1],w=e.useState(t.selectedData||[]),y=w[0],v=w[1];e.useEffect((function(){return document.body.addEventListener("mouseup",_),document.body.addEventListener("mousemove",R),function(){document.body.removeEventListener("mouseup",_),document.body.removeEventListener("mousemove",R)}}));var X=t.selectTimeRange,Y=t.outerCellColor,O=t.innerCellColor,z=t.fontColor,M=t.summaryColor,T=t.hasHalfHour,I=void 0!==T&&T,_=function(e){e&&!e.target.dataset.hour&&o(!1)},R=function(e){e.target.dataset.hour},L=function(e){var t=e.clientX,n=e.clientY,r=e.layerX,a=e.layerY,i=e.iden,l=e.tdIndex;h(0),b(0),o(!0),E=t,H=r-16*l-60,N=16*l+60,S=20*~~i+40,c((C=n)-(D=a-20*i-40)),d(E-H)},W=function(e){var t=e.isDrag,n=e.layerX,r=e.layerY,a=e.tempWidth,o=e.tempHeight;if(e.iden,e.hour,e.value,t){var i=n-N,l=r-S;o=l>0?l:20-l;var s=(a=i>0?i:16-i)%20==0&&i>0?16*Math.ceil(a/16)+1:16*Math.ceil(a/16),u=o%20==0&&l>0?20*Math.ceil(o/20)+20:20*Math.ceil(o/20);h(s),b(u),d(i<0?E-H-m+25:E-H),c(l<0?C-D-g+10:C-D)}};return n.default.createElement("div",{className:"week-time-range-picker",style:I?{maxWidth:"830px"}:{maxWidth:"450px"}},a?n.default.createElement("div",{className:"wtrp-schedule",style:{left:"".concat(u,"px"),top:"".concat(l,"px"),width:"".concat(m,"px"),height:"".concat(g,"px")}}):null,n.default.createElement("table",{className:"wtrp-table"},n.default.createElement(x,{hasHalfHour:I,outerCellColor:Y,fontColor:z}),n.default.createElement(k,{hasHalfHour:I,checkedDatas:y,handleDrag:function(e){var t=e.type,n=e.clientX,r=e.clientY,a=e.layerX,i=e.layerY,l=e.iden,c=e.hour,s=e.value,u=e.isDrag;if("up"!==t){var d=I?2:1,p=c.split(":"),m=~~p[1]?~~p[0]*d+1:~~p[0]*d;"down"===t?L({clientX:n,clientY:r,layerX:a,layerY:i,iden:l,tdIndex:m}):W({isDrag:u,layerX:a,layerY:i,tempWidth:undefined,tempHeight:undefined,iden:l,hour:c,value:s})}else o(!1)},handleSelect:function(e){v(e),X&&X(e)},handleMoveOut:function(e){},outerCellColor:Y,innerCellColor:O,summaryColor:M,fontColor:z})))};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import e,{useState as t,useEffect as r}from"react";
import e,{useState as t,useEffect as n}from"react";function r(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}r(".wtrp-fl {\n float: left;\n}\n.wtrp-fr {\n float: right;\n}\n.wtrp-flex {\n display: flex;\n}\n.wtrp-flex-1 {\n flex: 1;\n}\n.wtrp-break {\n word-break: break-all;\n}\n");r(".week-time-range-picker {\n position: relative;\n display: inline-block;\n}\n.week-time-range-picker .wtrp-schedule {\n background: #598fe6;\n width: 0;\n height: 0;\n position: fixed;\n opacity: 0.6;\n top: 0;\n left: 0;\n pointer-events: none;\n -webkit-transition: all 0.4s ease;\n -moz-transition: all 0.4s ease;\n -ms-transition: all 0.4s ease;\n transition: all 0.4s ease;\n}\n.week-time-range-picker .wtrp-table {\n background-color: transparent;\n border-collapse: collapse;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper {\n text-align: left;\n display: inline-block;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .transition-popover-enter-active,\n.week-time-range-picker .wtrp-byted-popover-wrapper .transition-popover-appear {\n opacity: 0;\n animation: popoverTransitionIn 0.5s;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .transition-drop-leave-active {\n animation: popoverTransitionOut 0.5s;\n}\n@keyframes popoverTransitionIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n@keyframes popoverTransitionOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n color: rgba(0, 0, 0, 0.65);\n font-size: 14px;\n font-variant: tabular-nums;\n line-height: 1.5;\n list-style: none;\n font-feature-settings: 'tnum';\n position: absolute;\n z-index: 1060;\n display: block;\n max-width: 250px;\n visibility: visible;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip-placement-top .ant-tooltip-arrow {\n left: 50%;\n transform: translateX(-50%);\n position: absolute;\n display: block;\n width: 13.07106781px;\n height: 13.07106781px;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n bottom: -12.07106781px;\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip-placement-top .ant-tooltip-arrow::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: 5px;\n height: 5px;\n margin: auto;\n background-color: rgba(0, 0, 0, 0.75);\n content: '';\n pointer-events: auto;\n box-shadow: 3px 3px 7px rgba(0, 0, 0, 0.07);\n transform: translateY(-6.53553391px) rotate(45deg);\n}\n.week-time-range-picker .wtrp-byted-popover-wrapper .ant-tooltip-placement-top .ant-tooltip-inner {\n min-width: 30px;\n min-height: 32px;\n padding: 6px 8px;\n color: #fff;\n text-align: left;\n text-decoration: none;\n word-wrap: break-word;\n background-color: rgba(0, 0, 0, 0.75);\n border-radius: 4px;\n -webkit-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n}\n");
/*! *****************************************************************************

@@ -15,3 +15,4 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function a(e,t,r){if(r||2===arguments.length)for(var a,n=0,o=t.length;n<o;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}const n=[{hour:0,time:"00:00"},{hour:30,time:"00:30"},{hour:1,time:"01:00"},{hour:30,time:"01:30"},{hour:2,time:"02:00"},{hour:30,time:"02:30"},{hour:3,time:"03:00"},{hour:30,time:"03:30"},{hour:4,time:"04:00"},{hour:30,time:"04:30"},{hour:5,time:"05:00"},{hour:30,time:"05:30"},{hour:6,time:"06:00"},{hour:30,time:"06:30"},{hour:7,time:"07:00"},{hour:30,time:"07:30"},{hour:8,time:"08:00"},{hour:30,time:"08:30"},{hour:9,time:"09:00"},{hour:30,time:"09:30"},{hour:10,time:"10:00"},{hour:30,time:"10:30"},{hour:11,time:"11:00"},{hour:30,time:"11:30"},{hour:12,time:"12:00"},{hour:30,time:"12:30"},{hour:13,time:"13:00"},{hour:30,time:"13:30"},{hour:14,time:"14:00"},{hour:30,time:"14:30"},{hour:15,time:"15:00"},{hour:30,time:"15:30"},{hour:16,time:"16:00"},{hour:30,time:"16:30"},{hour:17,time:"17:00"},{hour:30,time:"17:30"},{hour:18,time:"18:00"},{hour:30,time:"18:30"},{hour:19,time:"19:00"},{hour:30,time:"19:30"},{hour:20,time:"20:00"},{hour:30,time:"20:30"},{hour:21,time:"21:00"},{hour:30,time:"21:30"},{hour:22,time:"22:00"},{hour:30,time:"22:30"},{hour:23,time:"23:00"},{hour:30,time:"23:30"}],o=[{hour:0,time:"00:00"},{hour:1,time:"01:00"},{hour:2,time:"02:00"},{hour:3,time:"03:00"},{hour:4,time:"04:00"},{hour:5,time:"05:00"},{hour:6,time:"06:00"},{hour:7,time:"07:00"},{hour:8,time:"08:00"},{hour:9,time:"09:00"},{hour:10,time:"10:00"},{hour:11,time:"11:00"},{hour:12,time:"12:00"},{hour:13,time:"13:00"},{hour:14,time:"14:00"},{hour:15,time:"15:00"},{hour:16,time:"16:00"},{hour:17,time:"17:00"},{hour:18,time:"18:00"},{hour:19,time:"19:00"},{hour:20,time:"20:00"},{hour:21,time:"21:00"},{hour:22,time:"22:00"},{hour:23,time:"23:00"}],i=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],u=["00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00","05:30","06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00","23:30"],c=[{iden:"1",dayName:"Monday"},{iden:"2",dayName:"Tuesday"},{iden:"3",dayName:"Wednesday"},{iden:"4",dayName:"Thursday"},{iden:"5",dayName:"Friday"},{iden:"6",dayName:"Saturday"},{iden:"7",dayName:"Sunday"}],l=new Map;c.forEach((e=>{l.set(e.iden,e.dayName)}));const s=(e,t)=>e-t,m=(e,t)=>e.substring(0,2)-t.substring(0,2),h=({cacheChecked:e,hasStart:t,has:r,idenIndex:a,iden:n,timeRange:o})=>{let i={iden:n,times:[]},u=-1;t||r||e.push(i);for(let n of o)if(u=r?e[a].times.indexOf(n):-1,t&&r){if(u>=0&&e[a].times.splice(u,1),0===e[a].times.length){e.splice(a,1);break}}else if(!t){if(-1===u&&a>=0){e[a].times.push(n);continue}i.times.push(n)}};var d=function(e,t){return e.iden?e.iden-t.iden:e.substring(0,2)===t.substring(0,2)?e.substring(3)-t.substring(3):e.substring(0,2)-t.substring(0,2)},f=function(e,t){e.forEach((function(r){var a=t.slice(-1)[0],n=r.substring(0,2)-a.slice(-1)[0].substring(0,2)==1;n&&a.push(r),n||r===e[0]||t.push([r])}))},p=function(e,t){e.forEach((function(r){var a=t.slice(-1)[0],n=a.slice(-1)[0],o=100*r.substring(0,2)+("30"===r.substring(3)?50:0)-(100*n.substring(0,2)+("30"===n.substring(3)?50:0))==50;o&&a.push(r),o||r===e[0]||t.push([r])})),t.forEach((function(e){var t=+e.slice(-1)[0].substring(0,2);"30"===e.slice(-1)[0].substring(3)?t>8?e.push("".concat(t+1,":00")):e.push("0".concat(t+1,":00")):t>8?e.push("".concat(t,":30")):e.push("0".concat(t,":30"))}))},y=function(t){var r=t.hasHalfHour,a=t.checkedDatas,n=t.handleEmpty,o=t.summaryColor,i=t.fontColor,u=a.filter((function(e){return""!==e.iden}))||[];u.sort(d),u.forEach((function(e,t){u[t].dayName=l.get(e.iden),e.times.sort(d),u[t].timeRanges=function(e,t){var r=[[t[0]]];return e?p(t,r):f(t,r),r}(r,e.times)}));return e.createElement("tr",{className:"wtrp-time-range-selected",style:{backgroundColor:o}},e.createElement("td",{colSpan:49,className:"wtrp-selected-td"},e.createElement("div",{className:"wtrp-clearfix"},0===a.length?e.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Drag the mouse to select the time period"):e.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Time period selected"),e.createElement("a",{className:"wtrp-fr",onClick:function(){n()},style:{color:i}},"clear selection")),u.map((function(t,r){return e.createElement("div",{className:"wtrp-selected-td__selected-time",key:r},e.createElement("p",{className:"wtrp-flex wtrp-break"},e.createElement("span",{className:"tip-text",style:{color:i}},t.dayName,":"),e.createElement("span",{className:"wtrp-flex-1"},t.timeRanges.map((function(t,r){return console.log(t),e.createElement("span",{className:"wtrp-selected-text",key:r,style:{color:i}},"".concat(t[0],"~").concat(t[t.length-1]))})))))}))))},g=!1,v=!1,E={cacheStart:{iden:"",hour:"",group:""},cacheEnd:{iden:"",hour:"",group:""}},C=function(l){var d=t(l.checkedDatas),f=d[0],p=d[1];r((function(){return document.body.addEventListener("mouseup",H),function(){return document.body.removeEventListener("mouseup",H)}}));var C=l.hasHalfHour,b=l.handleDrag,N=l.handleSelect,x=l.handleMoveOut,w=l.fontColor,S=C?n:o,k=C?1:2,H=function(e){e&&!e.target.dataset.hour&&(v=!1)},X=function(e,t){if(e.target.dataset.hour){var r=e.target.dataset.iden,n=e.target.dataset.hour;return E[t].iden=r,E[t].hour=n,E[t].group=r+n,"cacheStart"===t&&D(r,n),"cacheEnd"===t&&E[t].group===E.cacheStart.group&&function(e,t){var r=f,n=D(e,t),o=n.has,i=n.idenIndex,u=n.index;o?g?(1===r[i].times.length?r.splice(i,1):r[i].times.splice(u,1),p(a([],r,!0))):(r[i].times.push(t),p(a([],r,!0))):(r.push({iden:e,times:[t]}),p(a([],r,!0)))}(r,n),"cacheEnd"===t&&E[t].group!==E.cacheStart.group&&M(),!0}return!1},Y=function(e){E[e].iden="",E[e].hour="",E[e].group=""},D=function(e,t){g=!1;for(var r,a,n=f,o=n.length,i=!1,u=0;u<o;u++)if(n[u].iden===e){a=u,r=n[u].times.indexOf(t),i=!0,g=-1!==r;break}return{has:i,idenIndex:a,index:r}},M=function(){var e=[E.cacheStart.iden,E.cacheEnd.iden],t=[E.cacheStart.hour,E.cacheEnd.hour],r=g,a=JSON.parse(JSON.stringify(f));e.sort(s),t.sort(m);for(var n=(e=>{let t=[];for(let r=e[0];r<=e[1];r++)t.push(String(r));return t})(e),o=((e,t)=>{let r,a;return e?(r=u.indexOf(t[0]),a=u.indexOf(t[1]),u.slice(r,a+1)):(r=i.indexOf(t[0]),a=i.indexOf(t[1]),i.slice(r,a+1))})(C,t),c=0,l=n;c<l.length;c++){var d=l[c],y=D(d),v=y.has,b=y.idenIndex;h({cacheChecked:a,hasStart:r,has:v,idenIndex:b,iden:d,timeRange:o})}p(a)};return e.createElement("tbody",{className:"wtrp-tbody",onMouseDown:function(e){if(e.preventDefault(),e.stopPropagation(),v=!0,X(e,"cacheStart")){var t={type:"down",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:E.cacheStart.iden,hour:E.cacheStart.hour};b(t)}D(E.cacheStart.iden,E.cacheStart.hour)},onMouseUp:function(e){e.preventDefault(),e.stopPropagation(),v=!1,X(e,"cacheEnd"),Y("cacheStart"),Y("cacheEnd"),b({type:"up"}),N(f)},onMouseMove:function(e){if(e.target.dataset.hour){x(!1);var t={type:"move",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:e.target.dataset.iden,hour:e.target.dataset.hour,value:e.target.dataset.value,isDrag:v};b(t)}}},c.map((function(t,r){return e.createElement("tr",{className:"wtrp-tbody-tr",key:r},e.createElement("td",{className:"week-td",style:{backgroundColor:l.outerCellColor,color:w}},t.dayName),S.map((function(r,a){var n=f.some((function(e){return e.iden===t.iden&&-1!==e.times.indexOf(r.time)}));return e.createElement("td",{colSpan:k,style:n?null:{backgroundColor:l.innerCellColor},className:n?"wtrp-active-td":"wtrp-freeze-td",key:a,"data-hour":r.time,"data-iden":t.iden,"data-value":"".concat(t.dayName," ").concat(r.time)})})))})),e.createElement(y,{hasHalfHour:C,checkedDatas:f,handleEmpty:function(){g=!1,Y("cacheStart"),Y("cacheEnd"),p([])},summaryColor:l.summaryColor,fontColor:l.fontColor}))},b=function(t){var r=t.hasHalfHour?n:o,a=t.hasHalfHour?1:2;return e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",{rowSpan:8,className:"week-td",style:{backgroundColor:t.outerCellColor,color:t.fontColor}},"day/hour"),r.map((function(r,n){return e.createElement("td",{colSpan:a,style:{backgroundColor:t.outerCellColor,color:t.fontColor},key:n},r.time)}))))},N=0,x=0,w=0,S=0,k=0,H=0,X=function(a){var n=t(!1),o=n[0],i=n[1],u=t(0),c=u[0],l=u[1],s=t(0),m=s[0],h=s[1],d=t(0),f=d[0],p=d[1],y=t(0),g=y[0],v=y[1],E=t(a.selectedData||[]),X=E[0],Y=E[1];r((function(){return document.body.addEventListener("mouseup",T),document.body.addEventListener("mousemove",A),function(){document.body.removeEventListener("mouseup",T),document.body.removeEventListener("mousemove",A)}}));var D=a.selectTimeRange,M=a.outerCellColor,O=a.innerCellColor,I=a.fontColor,L=a.summaryColor,R=a.hasHalfHour,W=void 0!==R&&R,T=function(e){e&&!e.target.dataset.hour&&i(!1)},A=function(e){e.target.dataset.hour},J=function(e){var t=e.clientX,r=e.clientY,a=e.layerX,n=e.layerY,o=e.iden,u=e.tdIndex;p(0),v(0),i(!0),N=t,H=a-16*u-60,w=16*u+60,S=20*~~o+40,l((x=r)-(k=n-20*o-40)),h(N-H)},P=function(e){var t=e.isDrag,r=e.layerX,a=e.layerY,n=e.tempWidth,o=e.tempHeight;if(e.iden,e.hour,e.value,t){var i=r-w,u=a-S;o=u>0?u:20-u;var c=(n=i>0?i:16-i)%20==0&&i>0?16*Math.ceil(n/16)+1:16*Math.ceil(n/16),s=o%20==0&&u>0?20*Math.ceil(o/20)+20:20*Math.ceil(o/20);p(c),v(s),h(i<0?N-H-f+25:N-H),l(u<0?x-k-g+10:x-k)}};return e.createElement("div",{className:"week-time-range-picker",style:W?{maxWidth:"830px"}:{maxWidth:"450px"}},o?e.createElement("div",{className:"wtrp-schedule",style:{left:"".concat(m,"px"),top:"".concat(c,"px"),width:"".concat(f,"px"),height:"".concat(g,"px")}}):null,e.createElement("table",{className:"wtrp-table"},e.createElement(b,{hasHalfHour:W,outerCellColor:M,fontColor:I}),e.createElement(C,{hasHalfHour:W,checkedDatas:X,handleDrag:function(e){var t=e.type,r=e.clientX,a=e.clientY,n=e.layerX,o=e.layerY,u=e.iden,c=e.hour,l=e.value,s=e.isDrag;if("up"!==t){var m=W?2:1,h=c.split(":"),d=~~h[1]?~~h[0]*m+1:~~h[0]*m;"down"===t?J({clientX:r,clientY:a,layerX:n,layerY:o,iden:u,tdIndex:d}):P({isDrag:s,layerX:n,layerY:o,tempWidth:undefined,tempHeight:undefined,iden:u,hour:c,value:l})}else i(!1)},handleSelect:function(e){Y(e),D&&D(e)},handleMoveOut:function(e){},outerCellColor:M,innerCellColor:O,summaryColor:L,fontColor:I})))};export{X as ReactWeekTimeRangePicker};
***************************************************************************** */
function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}r(".week-time-range-picker,\n.week-time-range-picker :after,\n.week-time-range-picker :before {\n -webkit-box-sizing: border-box;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n.week-time-range-picker .wtrp-table tr,\n.week-time-range-picker .wtrp-table td,\n.week-time-range-picker .wtrp-table th {\n border: 1px solid #DDDEE1;\n font-size: 12px;\n text-align: center;\n -webkit-transition: background 0.2s ease;\n -moz-transition: background 0.2s ease;\n -ms-transition: background 0.2s ease;\n transition: background 0.2s ease;\n user-select: none;\n margin: 0;\n padding: 0;\n min-width: 35px;\n width: 16px;\n height: 20px;\n box-sizing: border-box;\n}\n.week-time-range-picker .wtrp-table tr .week-td,\n.week-time-range-picker .wtrp-table td .week-td,\n.week-time-range-picker .wtrp-table th .week-td {\n width: 60px;\n}\n");const a=[{hour:0,time:"00:00"},{hour:30,time:"00:30"},{hour:1,time:"01:00"},{hour:30,time:"01:30"},{hour:2,time:"02:00"},{hour:30,time:"02:30"},{hour:3,time:"03:00"},{hour:30,time:"03:30"},{hour:4,time:"04:00"},{hour:30,time:"04:30"},{hour:5,time:"05:00"},{hour:30,time:"05:30"},{hour:6,time:"06:00"},{hour:30,time:"06:30"},{hour:7,time:"07:00"},{hour:30,time:"07:30"},{hour:8,time:"08:00"},{hour:30,time:"08:30"},{hour:9,time:"09:00"},{hour:30,time:"09:30"},{hour:10,time:"10:00"},{hour:30,time:"10:30"},{hour:11,time:"11:00"},{hour:30,time:"11:30"},{hour:12,time:"12:00"},{hour:30,time:"12:30"},{hour:13,time:"13:00"},{hour:30,time:"13:30"},{hour:14,time:"14:00"},{hour:30,time:"14:30"},{hour:15,time:"15:00"},{hour:30,time:"15:30"},{hour:16,time:"16:00"},{hour:30,time:"16:30"},{hour:17,time:"17:00"},{hour:30,time:"17:30"},{hour:18,time:"18:00"},{hour:30,time:"18:30"},{hour:19,time:"19:00"},{hour:30,time:"19:30"},{hour:20,time:"20:00"},{hour:30,time:"20:30"},{hour:21,time:"21:00"},{hour:30,time:"21:30"},{hour:22,time:"22:00"},{hour:30,time:"22:30"},{hour:23,time:"23:00"},{hour:30,time:"23:30"}],i=[{hour:0,time:"00:00"},{hour:1,time:"01:00"},{hour:2,time:"02:00"},{hour:3,time:"03:00"},{hour:4,time:"04:00"},{hour:5,time:"05:00"},{hour:6,time:"06:00"},{hour:7,time:"07:00"},{hour:8,time:"08:00"},{hour:9,time:"09:00"},{hour:10,time:"10:00"},{hour:11,time:"11:00"},{hour:12,time:"12:00"},{hour:13,time:"13:00"},{hour:14,time:"14:00"},{hour:15,time:"15:00"},{hour:16,time:"16:00"},{hour:17,time:"17:00"},{hour:18,time:"18:00"},{hour:19,time:"19:00"},{hour:20,time:"20:00"},{hour:21,time:"21:00"},{hour:22,time:"22:00"},{hour:23,time:"23:00"}],l=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"],c=["00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00","05:30","06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00","23:30"],s=[{iden:"1",dayName:"Monday"},{iden:"2",dayName:"Tuesday"},{iden:"3",dayName:"Wednesday"},{iden:"4",dayName:"Thursday"},{iden:"5",dayName:"Friday"},{iden:"6",dayName:"Saturday"},{iden:"7",dayName:"Sunday"}],d=new Map;s.forEach((e=>{d.set(e.iden,e.dayName)}));const u=(e,t)=>e-t,p=(e,t)=>e.substring(0,2)-t.substring(0,2),m=({cacheChecked:e,hasStart:t,has:n,idenIndex:r,iden:o,timeRange:a})=>{let i={iden:o,times:[]},l=-1;t||n||e.push(i);for(let o of a)if(l=n?e[r].times.indexOf(o):-1,t&&n){if(l>=0&&e[r].times.splice(l,1),0===e[r].times.length){e.splice(r,1);break}}else if(!t){if(-1===l&&r>=0){e[r].times.push(o);continue}i.times.push(o)}};r(".wtrp-tbody-tr > td + td {\n cursor: pointer;\n}\n.wtrp-freeze-td {\n background: #f5f5f5;\n}\n.wtrp-active-td {\n background-color: #0590FF;\n}\n");r('.wtrp-selected-td {\n padding: 0 10px!important;\n}\n.wtrp-selected-td .tip-text {\n color: #999;\n}\n.wtrp-selected-td .wtrp-clearfix:before {\n content: " ";\n display: table;\n}\n.wtrp-selected-td .wtrp-clearfix:after {\n content: " ";\n display: table;\n clear: both;\n}\n.wtrp-selected-td .wtrp-selected-td__selected-time {\n text-align: left;\n line-height: 1;\n}\n.wtrp-selected-td .wtrp-selected-td__selected-time .wtrp-selected-text {\n padding-right: 5px;\n}\n.wtrp-selected-td a {\n cursor: pointer;\n color: #598fe6;\n}\n');var h=function(e,t){return e.iden?e.iden-t.iden:e.substring(0,2)===t.substring(0,2)?e.substring(3)-t.substring(3):e.substring(0,2)-t.substring(0,2)},f=function(e,t){e.forEach((function(n){var r=t.slice(-1)[0],o=n.substring(0,2)-r.slice(-1)[0].substring(0,2)==1;o&&r.push(n),o||n===e[0]||t.push([n])}))},g=function(e,t){e.forEach((function(n){var r=t.slice(-1)[0],o=r.slice(-1)[0],a=100*n.substring(0,2)+("30"===n.substring(3)?50:0)-(100*o.substring(0,2)+("30"===o.substring(3)?50:0))==50;a&&r.push(n),a||n===e[0]||t.push([n])})),t.forEach((function(e){var t=+e.slice(-1)[0].substring(0,2);"30"===e.slice(-1)[0].substring(3)?t>8?e.push("".concat(t+1,":00")):e.push("0".concat(t+1,":00")):t>8?e.push("".concat(t,":30")):e.push("0".concat(t,":30"))}))},b=function(t){var n=t.hasHalfHour,r=t.checkedDatas,o=t.handleEmpty,a=t.summaryColor,i=t.fontColor,l=r.filter((function(e){return""!==e.iden}))||[];l.sort(h),l.forEach((function(e,t){l[t].dayName=d.get(e.iden),e.times.sort(h),l[t].timeRanges=function(e,t){var n=[[t[0]]];return e?g(t,n):f(t,n),n}(n,e.times)}));return e.createElement("tr",{className:"wtrp-time-range-selected",style:{backgroundColor:a}},e.createElement("td",{colSpan:49,className:"wtrp-selected-td"},e.createElement("div",{className:"wtrp-clearfix"},0===r.length?e.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Drag the mouse to select the time period"):e.createElement("span",{className:"wtrp-fl tip-text",style:{color:i}},"Time period selected"),e.createElement("a",{className:"wtrp-fr",onClick:function(){o()},style:{color:i}},"clear selection")),l.map((function(t,n){return e.createElement("div",{className:"wtrp-selected-td__selected-time",key:n},e.createElement("p",{className:"wtrp-flex wtrp-break"},e.createElement("span",{className:"tip-text",style:{color:i}},t.dayName,":"),e.createElement("span",{className:"wtrp-flex-1"},t.timeRanges.map((function(t,n){return console.log(t),e.createElement("span",{className:"wtrp-selected-text",key:n,style:{color:i}},"".concat(t[0],"~").concat(t[t.length-1]))})))))}))))},w=!1,y=!1,k={cacheStart:{iden:"",hour:"",group:""},cacheEnd:{iden:"",hour:"",group:""}},v=function(r){var d=t(r.checkedDatas),h=d[0],f=d[1];n((function(){return document.body.addEventListener("mouseup",D),function(){return document.body.removeEventListener("mouseup",D)}}));var g=r.hasHalfHour,v=r.handleDrag,x=r.handleSelect,E=r.handleMoveOut,C=r.fontColor,N=g?a:i,S=g?1:2,D=function(e){e&&!e.target.dataset.hour&&(y=!1)},H=function(e,t){if(e.target.dataset.hour){var n=e.target.dataset.iden,r=e.target.dataset.hour;return k[t].iden=n,k[t].hour=r,k[t].group=n+r,"cacheStart"===t&&Y(n,r),"cacheEnd"===t&&k[t].group===k.cacheStart.group&&function(e,t){var n=h,r=Y(e,t),a=r.has,i=r.idenIndex,l=r.index;a?w?(1===n[i].times.length?n.splice(i,1):n[i].times.splice(l,1),f(o([],n,!0))):(n[i].times.push(t),f(o([],n,!0))):(n.push({iden:e,times:[t]}),f(o([],n,!0)))}(n,r),"cacheEnd"===t&&k[t].group!==k.cacheStart.group&&z(),!0}return!1},X=function(e){k[e].iden="",k[e].hour="",k[e].group=""},Y=function(e,t){w=!1;for(var n,r,o=h,a=o.length,i=!1,l=0;l<a;l++)if(o[l].iden===e){r=l,n=o[l].times.indexOf(t),i=!0,w=-1!==n;break}return{has:i,idenIndex:r,index:n}},z=function(){var e=[k.cacheStart.iden,k.cacheEnd.iden],t=[k.cacheStart.hour,k.cacheEnd.hour],n=w,r=JSON.parse(JSON.stringify(h));e.sort(u),t.sort(p);for(var o=(e=>{let t=[];for(let n=e[0];n<=e[1];n++)t.push(String(n));return t})(e),a=((e,t)=>{let n,r;return e?(n=c.indexOf(t[0]),r=c.indexOf(t[1]),c.slice(n,r+1)):(n=l.indexOf(t[0]),r=l.indexOf(t[1]),l.slice(n,r+1))})(g,t),i=0,s=o;i<s.length;i++){var d=s[i],b=Y(d),y=b.has,v=b.idenIndex;m({cacheChecked:r,hasStart:n,has:y,idenIndex:v,iden:d,timeRange:a})}f(r)};return e.createElement("tbody",{className:"wtrp-tbody",onMouseDown:function(e){if(e.preventDefault(),e.stopPropagation(),y=!0,H(e,"cacheStart")){var t={type:"down",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:k.cacheStart.iden,hour:k.cacheStart.hour};v(t)}Y(k.cacheStart.iden,k.cacheStart.hour)},onMouseUp:function(e){e.preventDefault(),e.stopPropagation(),y=!1,H(e,"cacheEnd"),X("cacheStart"),X("cacheEnd"),v({type:"up"}),x(h)},onMouseMove:function(e){if(e.target.dataset.hour){E(!1);var t={type:"move",clientX:e.clientX,clientY:e.clientY,layerX:e.nativeEvent.layerX,layerY:e.nativeEvent.layerY,iden:e.target.dataset.iden,hour:e.target.dataset.hour,value:e.target.dataset.value,isDrag:y};v(t)}}},s.map((function(t,n){return e.createElement("tr",{className:"wtrp-tbody-tr",key:n},e.createElement("td",{className:"week-td",style:{backgroundColor:r.outerCellColor,color:C}},t.dayName),N.map((function(n,o){var a=h.some((function(e){return e.iden===t.iden&&-1!==e.times.indexOf(n.time)}));return e.createElement("td",{colSpan:S,style:a?null:{backgroundColor:r.innerCellColor},className:a?"wtrp-active-td":"wtrp-freeze-td",key:o,"data-hour":n.time,"data-iden":t.iden,"data-value":"".concat(t.dayName," ").concat(n.time)})})))})),e.createElement(b,{hasHalfHour:g,checkedDatas:h,handleEmpty:function(){w=!1,X("cacheStart"),X("cacheEnd"),f([])},summaryColor:r.summaryColor,fontColor:r.fontColor}))},x=function(t){var n=t.hasHalfHour?a:i,r=t.hasHalfHour?1:2;return e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",{rowSpan:8,className:"week-td",style:{backgroundColor:t.outerCellColor,color:t.fontColor}},"day/hour"),n.map((function(n,o){return e.createElement("td",{colSpan:r,style:{backgroundColor:t.outerCellColor,color:t.fontColor},key:o},n.time)}))))},E=0,C=0,N=0,S=0,D=0,H=0,X=function(r){var o=t(!1),a=o[0],i=o[1],l=t(0),c=l[0],s=l[1],d=t(0),u=d[0],p=d[1],m=t(0),h=m[0],f=m[1],g=t(0),b=g[0],w=g[1],y=t(r.selectedData||[]),k=y[0],X=y[1];n((function(){return document.body.addEventListener("mouseup",_),document.body.addEventListener("mousemove",R),function(){document.body.removeEventListener("mouseup",_),document.body.removeEventListener("mousemove",R)}}));var Y=r.selectTimeRange,z=r.outerCellColor,O=r.innerCellColor,M=r.fontColor,T=r.summaryColor,I=r.hasHalfHour,L=void 0!==I&&I,_=function(e){e&&!e.target.dataset.hour&&i(!1)},R=function(e){e.target.dataset.hour},W=function(e){var t=e.clientX,n=e.clientY,r=e.layerX,o=e.layerY,a=e.iden,l=e.tdIndex;f(0),w(0),i(!0),E=t,H=r-16*l-60,N=16*l+60,S=20*~~a+40,s((C=n)-(D=o-20*a-40)),p(E-H)},A=function(e){var t=e.isDrag,n=e.layerX,r=e.layerY,o=e.tempWidth,a=e.tempHeight;if(e.iden,e.hour,e.value,t){var i=n-N,l=r-S;a=l>0?l:20-l;var c=(o=i>0?i:16-i)%20==0&&i>0?16*Math.ceil(o/16)+1:16*Math.ceil(o/16),d=a%20==0&&l>0?20*Math.ceil(a/20)+20:20*Math.ceil(a/20);f(c),w(d),p(i<0?E-H-h+25:E-H),s(l<0?C-D-b+10:C-D)}};return e.createElement("div",{className:"week-time-range-picker",style:L?{maxWidth:"830px"}:{maxWidth:"450px"}},a?e.createElement("div",{className:"wtrp-schedule",style:{left:"".concat(u,"px"),top:"".concat(c,"px"),width:"".concat(h,"px"),height:"".concat(b,"px")}}):null,e.createElement("table",{className:"wtrp-table"},e.createElement(x,{hasHalfHour:L,outerCellColor:z,fontColor:M}),e.createElement(v,{hasHalfHour:L,checkedDatas:k,handleDrag:function(e){var t=e.type,n=e.clientX,r=e.clientY,o=e.layerX,a=e.layerY,l=e.iden,c=e.hour,s=e.value,d=e.isDrag;if("up"!==t){var u=L?2:1,p=c.split(":"),m=~~p[1]?~~p[0]*u+1:~~p[0]*u;"down"===t?W({clientX:n,clientY:r,layerX:o,layerY:a,iden:l,tdIndex:m}):A({isDrag:d,layerX:o,layerY:a,tempWidth:undefined,tempHeight:undefined,iden:l,hour:c,value:s})}else i(!1)},handleSelect:function(e){X(e),Y&&Y(e)},handleMoveOut:function(e){},outerCellColor:z,innerCellColor:O,summaryColor:T,fontColor:M})))};export{X as ReactWeekTimeRangePicker};
//# sourceMappingURL=index.js.map

2

package.json
{
"name": "@marinos33/react-week-time-range-picker",
"version": "2.0.2",
"version": "2.0.3",
"description": "A React component for selecting a range of hours per day of the week",

@@ -5,0 +5,0 @@ "main": "dist/cjs/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