UNPKG

react-week-time-range-picker

Version:
2 lines 20.8 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.React);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(t,n){t.exports=e},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",r=e[3];if(!r)return n;if(t&&"function"==typeof btoa){var a=(o=r,s=btoa(unescape(encodeURIComponent(JSON.stringify(o)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(c," */")),i=r.sources.map((function(e){return"/*# sourceURL=".concat(r.sourceRoot).concat(e," */")}));return[n].concat(i).concat([a]).join("\n")}var o,s,c;return[n].join("\n")}(t,e);return t[2]?"@media ".concat(t[2],"{").concat(n,"}"):n})).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},a=0;a<this.length;a++){var i=this[a][0];null!=i&&(r[i]=!0)}for(var o=0;o<e.length;o++){var s=e[o];null!=s[0]&&r[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="(".concat(s[2],") and (").concat(n,")")),t.push(s))}},t}},function(e,t,n){"use strict";var r,a={},i=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},o=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}();function s(e,t){for(var n=[],r={},a=0;a<e.length;a++){var i=e[a],o=t.base?i[0]+t.base:i[0],s={css:i[1],media:i[2],sourceMap:i[3]};r[o]?r[o].parts.push(s):n.push(r[o]={id:o,parts:[s]})}return n}function c(e,t){for(var n=0;n<e.length;n++){var r=e[n],i=a[r.id],o=0;if(i){for(i.refs++;o<i.parts.length;o++)i.parts[o](r.parts[o]);for(;o<r.parts.length;o++)i.parts.push(g(r.parts[o],t))}else{for(var s=[];o<r.parts.length;o++)s.push(g(r.parts[o],t));a[r.id]={id:r.id,refs:1,parts:s}}}}function u(e){var t=document.createElement("style");if(void 0===e.attributes.nonce){var r=n.nc;r&&(e.attributes.nonce=r)}if(Object.keys(e.attributes).forEach((function(n){t.setAttribute(n,e.attributes[n])})),"function"==typeof e.insert)e.insert(t);else{var a=o(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var l,p=(l=[],function(e,t){return l[e]=t,l.filter(Boolean).join("\n")});function d(e,t,n,r){var a=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=p(t,a);else{var i=document.createTextNode(a),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(i,o[t]):e.appendChild(i)}}function h(e,t,n){var r=n.css,a=n.media,i=n.sourceMap;if(a&&e.setAttribute("media",a),i&&btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}var f=null,m=0;function g(e,t){var n,r,a;if(t.singleton){var i=m++;n=f||(f=u(t)),r=d.bind(null,n,i,!1),a=d.bind(null,n,i,!0)}else n=u(t),r=h.bind(null,n,t),a=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else a()}}e.exports=function(e,t){(t=t||{}).attributes="object"==typeof t.attributes?t.attributes:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=i());var n=s(e,t);return c(n,t),function(e){for(var r=[],i=0;i<n.length;i++){var o=n[i],u=a[o.id];u&&(u.refs--,r.push(u))}e&&c(s(e,t),t);for(var l=0;l<r.length;l++){var p=r[l];if(0===p.refs){for(var d=0;d<p.parts.length;d++)p.parts[d]();delete a[p.id]}}}}},function(e,t,n){var r=n(4);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(2)(r,a);r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,".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",""])},function(e,t,n){var r=n(6);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(2)(r,a);r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,".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",""])},function(e,t,n){var r=n(8);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(2)(r,a);r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,".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: 16px;\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",""])},function(e,t,n){var r=n(10);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(2)(r,a);r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,".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",""])},function(e,t,n){var r=n(12);"string"==typeof r&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};n(2)(r,a);r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,'.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',""])},function(e,t,n){"use strict";n.r(t);var r=n(0),a=n.n(r),i=(n(3),n(5),n(7),["00:00 - 12:00","12:00 - 24:00"]),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"}],s=[{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"}],c=["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=function(e){var t=e.hasHalfHour?o:s,n=e.hasHalfHour?1:2;return a.a.createElement("thead",null,a.a.createElement("tr",null,a.a.createElement("th",{rowSpan:8,className:"week-td"},"星期/时间"),i.map((function(e,t){return a.a.createElement("th",{colSpan:24,key:t},e)}))),a.a.createElement("tr",null,t.map((function(e,t){return a.a.createElement("td",{colSpan:n,key:t},e.hour)}))))},p=[{iden:"0",week:"星期一"},{iden:"1",week:"星期二"},{iden:"2",week:"星期三"},{iden:"3",week:"星期四"},{iden:"4",week:"星期五"},{iden:"5",week:"星期六"},{iden:"6",week:"星期日"}],d=new Map;p.forEach((function(e){d.set(e.iden,e.week)}));var h=function(e,t){return e-t},f=function(e,t){return e.substring(0,2)-t.substring(0,2)},m=function(e){var t=e.cacheChecked,n=e.hasStart,r=e.has,a=e.idenIndex,i=e.iden,o=e.timeRange,s={iden:i,times:[]},c=-1;n||r||t.push(s);for(var u=0;u<o.length;u++)if(c=r?t[a].times.indexOf(o[u]):-1,n&&r){if(c>=0&&t[a].times.splice(c,1),0===t[a].times.length){t.splice(a,1);break}}else if(!n){if(-1===c&&a>=0){t[a].times.push(o[u]);continue}s.times.push(o[u])}},g=(n(9),n(11),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)}),b=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])}))},v=function(e,t){e.forEach((function(n){var r=t.slice(-1)[0],a=r.slice(-1)[0],i=100*n.substring(0,2)+("30"===n.substring(3)?50:0)-(100*a.substring(0,2)+("30"===a.substring(3)?50:0))==50;i&&r.push(n),i||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(t+1+":00"):e.push("0"+(t+1)+":00"):t>8?e.push(t+":30"):e.push("0"+t+":30")}))},w=function(e){var t=e.hasHalfHour,n=e.checkedDatas,r=e.handleEmpty,i=n||[];i.sort(g).map((function(e,n){i[n].week=d.get(e.iden),i[n].mergeTimes=function(e,t){var n=[[t[0]]];return e?v(t,n):b(t,n),n}(t,e.times.sort(g))}));return a.a.createElement("tr",{className:"wtrp-time-range-selected"},a.a.createElement("td",{colSpan:49,className:"wtrp-selected-td"},a.a.createElement("div",{className:"wtrp-clearfix"},0===n.length?a.a.createElement("span",{className:"wtrp-fl tip-text"},"可拖动鼠标选择时间段"):a.a.createElement("span",{className:"wtrp-fl tip-text"},"已选择时间段"),a.a.createElement("a",{className:"wtrp-fr",onClick:function(){r()}},"清空选择")),i.map((function(e,n){return a.a.createElement("div",{className:"wtrp-selected-td__selected-time",key:n},a.a.createElement("p",{className:"wtrp-flex wtrp-break"},a.a.createElement("span",{className:"tip-text"},e.week,":"),a.a.createElement("span",{className:"wtrp-flex-1"},e.mergeTimes.map((function(e,n){return a.a.createElement("span",{className:"wtrp-selected-text",key:n},t?e[0]+"~"+e[e.length-1]:e[0]+"~"+(r=e[e.length-1],(i=1+~~r.substring(0,2))>9?i+":00":"0"+i+":00"));var r,i})))))}))))},x=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),a=0;for(t=0;t<n;t++)for(var i=arguments[t],o=0,s=i.length;o<s;o++,a++)r[a]=i[o];return r},y=!1,k=!1,E={cacheStart:{iden:"",hour:"",group:""},cacheEnd:{iden:"",hour:"",group:""}},S=function(e){var t=Object(r.useState)(e.checkedDatas),n=t[0],i=t[1];Object(r.useEffect)((function(){return document.body.addEventListener("mouseup",O),function(){return document.body.removeEventListener("mouseup",O)}}));var l=e.hasHalfHour,d=e.handleDrag,g=e.handleSelect,b=e.handleMoveout,v=l?o:s,S=l?1:2,O=function(e){e&&!e.target.dataset.hour&&(k=!1)},j=function(e,t){if(e.target.dataset.hour){var r=e.target.dataset.iden,a=e.target.dataset.hour;return E[t].iden=r,E[t].hour=a,E[t].group=r+a,"cacheStart"===t&&M(r,a),"cacheEnd"===t&&E[t].group===E.cacheStart.group&&function(e,t){var r=n,a=M(e,t),o=a.has,s=a.idenIndex,c=a.index;o?y?(1===r[s].times.length?r.splice(s,1):r[s].times.splice(c,1),i(x(r))):(r[s].times.push(t),i(x(r))):(r.push({iden:e,times:[t]}),i(x(r)))}(r,a),"cacheEnd"===t&&E[t].group!==E.cacheStart.group&&H(),!0}return!1},N=function(e){E[e].iden="",E[e].hour="",E[e].group=""},M=function(e,t){y=!1;for(var r,a,i=n,o=i.length,s=!1,c=0;c<o;c++)if(i[c].iden===e){a=c,r=i[c].times.indexOf(t),s=!0,y=-1!==r;break}return{has:s,idenIndex:a,index:r}},H=function(){for(var e=[E.cacheStart.iden,E.cacheEnd.iden],t=[E.cacheStart.hour,E.cacheEnd.hour],r=y,a=JSON.parse(JSON.stringify(n)),o=function(e){for(var t=[],n=e[0];n<=e[1];n++)t.push(String(n));return t}(e.sort(h)),s=function(e,t){var n,r;return e?(n=u.indexOf(t[0]),r=u.indexOf(t[1]),u.slice(n,r+1)):(n=c.indexOf(t[0]),r=c.indexOf(t[1]),c.slice(n,r+1))}(l,t.sort(f)),p=0;p<o.length;p++){var d=M(o[p]),g=d.has,b=d.idenIndex;m({cacheChecked:a,hasStart:r,has:g,idenIndex:b,iden:o[p],timeRange:s})}i(a)};return a.a.createElement("tbody",{className:"wtrp-tbody",onMouseDown:function(e){if(e.preventDefault(),e.stopPropagation(),k=!0,j(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};d(t)}M(E.cacheStart.iden,E.cacheStart.hour)},onMouseUp:function(e){e.preventDefault(),e.stopPropagation(),k=!1,j(e,"cacheEnd"),N("cacheStart"),N("cacheEnd"),d({type:"up"}),g(n)},onMouseMove:function(e){if(e.target.dataset.hour){b(!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:k};d(t)}}},p.map((function(e,t){return a.a.createElement("tr",{className:"wtrp-tbody-tr",key:t},a.a.createElement("td",{className:"week-td"},e.week),v.map((function(t,r){return a.a.createElement("td",{colSpan:S,className:n.some((function(n){return n.iden===e.iden&&-1!==n.times.indexOf(t.time)}))?"wtrp-active-td":"wtrp-freeze-td",key:r,"data-hour":t.time,"data-iden":e.iden,"data-value":e.week+" "+t.time})})))})),a.a.createElement(w,{hasHalfHour:l,checkedDatas:n,handleEmpty:function(){y=!1,N("cacheStart"),N("cacheEnd"),i([])}}))},O=0,j=0,N=0,M=0,H=0,D=0;t.default=function(e){var t=Object(r.useState)(!1),n=t[0],i=t[1],o=Object(r.useState)(0),s=o[0],c=o[1],u=Object(r.useState)(0),p=u[0],d=u[1],h=Object(r.useState)(0),f=h[0],m=h[1],g=Object(r.useState)(0),b=g[0],v=g[1],w=Object(r.useState)(e.selectedData||[]),x=w[0],y=w[1];Object(r.useEffect)((function(){return document.body.addEventListener("mouseup",X),document.body.addEventListener("mousemove",Y),function(){document.body.removeEventListener("mouseup",X),document.body.removeEventListener("mousemove",Y)}}));var k=e.hasHalfHour,E=e.selectTimeRange,X=function(e){e&&!e.target.dataset.hour&&i(!1)},Y=function(e){e.target.dataset.hour||!0},T=function(e){var t=e.clientX,n=e.clientY,r=e.layerX,a=e.layerY,o=e.iden,s=e.tdIndex;m(0),v(0),i(!0),O=t,D=r-16*s-60,N=16*s+60,M=20*~~o+40,!1,c((j=n)-(H=a-20*o-40)),d(O-D)},C=function(e){var t=e.isDrag,n=e.layerX,r=e.layerY,a=e.tempWidth,i=e.tempHeight;e.iden,e.hour,e.value;if(t){var o=n-N,s=r-M;i=s>0?s:20-s;var u=(a=o>0?o:16-o)%20==0&&o>0?16*Math.ceil(a/16)+1:16*Math.ceil(a/16),l=i%20==0&&s>0?20*Math.ceil(i/20)+20:20*Math.ceil(i/20);m(u),v(l),d(o<0?O-D-f+16:O-D),c(s<0?j-H-b+20:j-H)}!0};return a.a.createElement("div",{className:"week-time-range-picker",style:k?{maxWidth:"830px"}:{maxWidth:"450px"}},n?a.a.createElement("div",{className:"wtrp-schedule",style:{left:p+"px",top:s+"px",width:f+"px",height:b+"px"}}):null,a.a.createElement("table",{className:"wtrp-table"},a.a.createElement(l,{hasHalfHour:k}),a.a.createElement(S,{hasHalfHour:k,checkedDatas:x,handleDrag:function(e){var t=e.type,n=e.clientX,r=e.clientY,a=e.layerX,o=e.layerY,s=e.iden,c=e.hour,u=e.value,l=e.isDrag;if("up"===t)return i(!1),void!1;var p=k?2:1,d=c.split(":"),h=~~d[1]?~~d[0]*p+1:~~d[0]*p;"down"===t?T({clientX:n,clientY:r,layerX:a,layerY:o,iden:s,tdIndex:h}):C({isDrag:l,layerX:a,layerY:o,tempWidth:void 0,tempHeight:void 0,iden:s,hour:c,value:u})},handleSelect:function(e){y(e),E&&E(e)},handleMoveout:function(e){e}})))}}])})); //# sourceMappingURL=react-week-time-range-picker.js.map