@corva/ui 0.72.0-4 → 0.72.0-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),i=require("react"),o=require("@material-ui/core"),n=require("re-resizable"),r=require("react-sizeme"),a=require("classnames"),l=require("lodash"),d=require("../shared/useThrottledCallback.js"),h=require("./Handle.js"),s=require("react/jsx-runtime");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e),m=u(t),f=u(a);function v(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)}return i}function p(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?v(Object(i),!0).forEach((function(t){c.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):v(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var g=function(e){var t,o,r=e.min,a=e.max,l=e.value,u=e.size,v=e.orientation,g=e.valueFormatter,b=e.displayFormatter,x=e.editableHandles,j=e.onChange,z=e.onStop,H=e.reversed,B=e.handlePosition,C=e.handleClasses,L=e.minimal,O=w(),k=i.useRef(null),R=i.useRef(null),F=i.useState([g(null==l?void 0:l.at(0)),g(null==l?void 0:l.at(1))]),S=m.default(F,2),P=S[0],E=S[1],M=i.useRef(null),q=i.useState(!1),T=m.default(q,2),D=T[0],I=T[1];i.useEffect((function(){if(!M.current){var e=[g(null==l?void 0:l.at(0)),g(null==l?void 0:l.at(1))],t=Math.min.apply(Math,e),i=Math.max.apply(Math,e);E([t,i])}}),[null==l?void 0:l.at(0),null==l?void 0:l.at(1)]);var N=m.default(P,2),W=N[0],A=N[1];i.useEffect((function(){if("horizontal"===v){var e=u.width/(a-r)*(W-r),t=u.width/(a-r)*(a-A);k.current.updateSize({width:H?t:e,height:u.height}),R.current.updateSize({width:H?e:t,height:u.height})}else if("vertical"===v){var i=u.height/(a-r)*(W-r),o=u.height/(a-r)*(a-A);k.current.updateSize({width:u.width,height:H?o:i}),R.current.updateSize({width:u.width,height:H?i:o})}}),[r,a,W,A,u.width,u.height,v]),i.useEffect((function(){var e=function(){document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",G),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",K)};return D?(document.addEventListener("mousemove",_),document.addEventListener("mouseup",G),document.addEventListener("touchmove",J),document.addEventListener("touchend",K)):(e(),z()),function(){e()}}),[D]);var $=d.useThrottledCallback((function(e,t,i){M.current="onResize Event";var o=i.clientWidth,n=i.clientHeight,l=W,d=A;"right"===t?H?d=g(a-o/u.width*(a-r)):l=g(r+o/u.width*(a-r)):"left"===t?H?l=g(r+o/u.width*(a-r)):d=g(a-o/u.width*(a-r)):"bottom"===t?H?d=g(a-n/u.height*(a-r)):l=g(r+n/u.height*(a-r)):"top"===t&&(H?l=g(r+n/u.height*(a-r)):d=g(a-n/u.height*(a-r))),l=Math.min(l,A),d=Math.max(d,W),E([l,d]),j([l,d])})),X=d.useThrottledCallback((function(){M.current=null,z()})),Y=function(e,t){M.current={xPos:e,yPos:t,head:W,tail:A}},Z=function(e,t){if(M.current){var i;"horizontal"===v?i=(M.current.xPos-e)/u.width*(a-r):"vertical"===v&&(i=(M.current.yPos-t)/u.height*(a-r));var o,n,l=M.current.head-i*(H?-1:1),d=M.current.tail-i*(H?-1:1),h=M.current.tail-M.current.head;l<=r?(o=r,n=r+h):d>=a?(o=a-h,n=a):(o=l,n=d),o=g(o),n=g(n),E([o,n]),j([o,n])}},_=d.useThrottledCallback((function(e){Z(e.clientX,e.clientY)})),G=d.useThrottledCallback((function(){M.current=null,I(!1)})),J=d.useThrottledCallback((function(e){Z(e.touches[0].pageX,e.touches[0].pageY)})),K=d.useThrottledCallback((function(){M.current=null,I(!1)})),Q=d.useThrottledCallback((function(e){E([e,A]),j([e,A])})),U=d.useThrottledCallback((function(e){E([W,e]),j([W,e])})),V=i.useMemo((function(){return(A-W)/(a-r)*("vertical"===v?u.height:u.width)<30}),[r,a,W,A]),ee=function(e){var t={min:r,max:A,value:W,onChange:Q},i={min:W,max:a,value:A,onChange:U};return"head"===e?s.jsx(h.Handle,p({placement:"head",readOnly:!x,displayFormatter:b,orientation:v,classes:C,minimal:L},H?i:t)):"tail"===e?s.jsx(h.Handle,p({placement:"tail",readOnly:!x,displayFormatter:b,orientation:v,classes:C,minimal:L},H?t:i)):null};return s.jsx("div",{className:O.rootWrapper,children:s.jsxs("div",{className:f.default(O.root,(t={},c.default(t,O.horizontalRoot,"horizontal"===v),c.default(t,O.verticalRoot,"vertical"===v),c.default(t,O.minimal,L),t)),children:[s.jsx(n.Resizable,{ref:k,minHeight:0,minWidth:0,enable:{right:"horizontal"===v,bottom:"vertical"===v},handleComponent:{right:ee("head"),bottom:ee("head")},onResize:$,onResizeStop:X}),s.jsx("div",{className:O.body,"data-testid":"slider-body",onMouseDown:function(e){Y(e.clientX,e.clientY),I(!0)},onTouchStart:function(e){Y(e.touches[0].pageX,e.touches[0].pageY),I(!0)},children:V?s.jsx("div",{className:f.default((o={},c.default(o,O.horizontalBodyHandle,"horizontal"===v),c.default(o,O.verticalBodyHandle,"vertical"===v),c.default(o,O.leftBodyHandle,"left"===B),c.default(o,O.rightBodyHandle,"right"===B),c.default(o,O.topBodyHandle,"top"===B),c.default(o,O.bottomBodyHandle,"bottom"===B),o)),children:s.jsx("div",{className:O.bodyHandle,children:s.jsx(y,{orientation:"vertical",minimal:L})})}):s.jsx("div",{className:O.bodyHandleIcon,children:s.jsx(y,{orientation:v,minimal:L})})}),s.jsx(n.Resizable,{ref:R,minHeight:0,minWidth:0,enable:{left:"horizontal"===v,top:"vertical"===v},handleComponent:{left:ee("tail"),top:ee("tail")},onResize:$,onResizeStop:X})]})})};g.defaultProps={orientation:"horizontal",valueFormatter:Math.floor,displayFormatter:function(e){return e},onChange:l.noop,onStop:l.noop,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1};var b=r.withSize({monitorWidth:!0,monitorHeight:!0})(g),y=function(e){var t=e.orientation;return e.minimal?"horizontal"===t?s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"20",viewBox:"0 -2 16 16",fill:"none",children:s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.33333 4L4 4L4 12L5.33333 12L5.33333 4ZM8.66659 4L8.66659 12L7.33325 12L7.33325 4L8.66659 4ZM12.0001 4L12.0001 12L10.6667 12L10.6667 4L12.0001 4Z",fill:"white"})}):s.jsxs("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{width:"12",height:"1"}),s.jsx("rect",{y:"3",width:"12",height:"1"}),s.jsx("rect",{y:"6",width:"12",height:"1"})]}):"horizontal"===t?s.jsxs("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"7.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 7.5 0.5)"}),s.jsx("rect",{x:"4.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 4.5 0.5)"}),s.jsx("rect",{x:"1.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 1.5 0.5)"})]}):s.jsxs("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{width:"12",height:"1"}),s.jsx("rect",{y:"3",width:"12",height:"1"}),s.jsx("rect",{y:"6",width:"12",height:"1"})]})},w=o.makeStyles((function(e){return{rootWrapper:{position:"relative",width:"100%",height:"100%",zIndex:100},root:{position:"absolute",width:"100%",height:"100%",zIndex:100,"&:hover:not($minimal) $body":{background:"#008BA366"},"&:hover $bodyHandle":{visibility:"visible"}},horizontalRoot:{display:"flex",alignItems:"center"},verticalRoot:{display:"flex",alignItems:"center",flexDirection:"column"},body:{position:"relative",flex:1,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",background:"#3B3B3B66",color:"#BDBDBD","& svg":{fill:"currentColor"},"&:hover":{cursor:"grab",background:"#008BA366",color:"#FFFFFF"},"&:active":{cursor:"grabbing"},"&:hover $bodyHandleIcon":{visibility:"visible"}},horizontalBodyHandle:{position:"absolute",bottom:-24},verticalBodyHandle:{position:"absolute",left:-24},leftBodyHandle:{position:"absolute",left:-24,right:"auto"},rightBodyHandle:{position:"absolute",right:-24,left:"auto"},topBodyHandle:{position:"absolute",top:-24,bottom:"auto"},bottomBodyHandle:{position:"absolute",bottom:-24,top:"auto"},bodyHandle:{width:24,height:24,borderRadius:"50%",background:"#03BCD4",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",visibility:"hidden"},bodyHandleIcon:{visibility:"hidden"},minimal:{border:"1px solid ".concat(e.palette.background.b9),borderRadius:4,"& $body":{"&:hover":{background:"#008BA366"},margin:-1,width:"calc(100% + 2px)",height:"calc(100% + 2px)",backgroundColor:o.fade(e.palette.background.b7,.1),border:"1px solid ".concat(e.palette.primary.text9),borderRadius:4}}}}));exports.AdvancedSlider=g,exports.default=b;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),i=require("react"),o=require("@material-ui/core"),n=require("re-resizable"),r=require("react-sizeme"),a=require("classnames"),l=require("lodash"),d=require("../shared/useThrottledCallback.js"),s=require("./Handle.js"),h=require("react/jsx-runtime");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e),m=u(t),f=u(a);function v(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)}return i}function p(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?v(Object(i),!0).forEach((function(t){c.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):v(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var g="twoValuesSliderDefault",b=function(e){var t,o,r=e.min,a=e.max,l=e.value,u=e.size,v=e.orientation,b=e.valueFormatter,y=e.displayFormatter,j=e.editableHandles,z=e.onChange,H=e.onStop,B=e.reversed,C=e.handlePosition,L=e.handleClasses,O=e.minimal,k=x(),R=i.useRef(null),F=i.useRef(null),S=i.useState([b(null==l?void 0:l.at(0)),b(null==l?void 0:l.at(1))]),P=m.default(S,2),E=P[0],M=P[1],q=i.useRef(null),D=i.useState(!1),T=m.default(D,2),I=T[0],_=T[1];i.useEffect((function(){if(!q.current){var e=[b(null==l?void 0:l.at(0)),b(null==l?void 0:l.at(1))],t=Math.min.apply(Math,e),i=Math.max.apply(Math,e);M([t,i])}}),[null==l?void 0:l.at(0),null==l?void 0:l.at(1)]);var N=m.default(E,2),W=N[0],A=N[1];i.useEffect((function(){if("horizontal"===v){var e=u.width/(a-r)*(W-r),t=u.width/(a-r)*(a-A);R.current.updateSize({width:B?t:e,height:u.height}),F.current.updateSize({width:B?e:t,height:u.height})}else if("vertical"===v){var i=u.height/(a-r)*(W-r),o=u.height/(a-r)*(a-A);R.current.updateSize({width:u.width,height:B?o:i}),F.current.updateSize({width:u.width,height:B?i:o})}}),[r,a,W,A,u.width,u.height,v]),i.useEffect((function(){var e=function(){document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",G),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",K)};return I?(document.addEventListener("mousemove",V),document.addEventListener("mouseup",G),document.addEventListener("touchmove",J),document.addEventListener("touchend",K)):(e(),H()),function(){e()}}),[I]);var $=d.useThrottledCallback((function(e,t,i){q.current="onResize Event";var o=i.clientWidth,n=i.clientHeight,l=W,d=A;"right"===t?B?d=b(a-o/u.width*(a-r)):l=b(r+o/u.width*(a-r)):"left"===t?B?l=b(r+o/u.width*(a-r)):d=b(a-o/u.width*(a-r)):"bottom"===t?B?d=b(a-n/u.height*(a-r)):l=b(r+n/u.height*(a-r)):"top"===t&&(B?l=b(r+n/u.height*(a-r)):d=b(a-n/u.height*(a-r))),l=Math.min(l,A),d=Math.max(d,W),M([l,d]),z([l,d])})),X=d.useThrottledCallback((function(){q.current=null,H()})),Y=function(e,t){q.current={xPos:e,yPos:t,head:W,tail:A}},Z=function(e,t){if(q.current){var i;"horizontal"===v?i=(q.current.xPos-e)/u.width*(a-r):"vertical"===v&&(i=(q.current.yPos-t)/u.height*(a-r));var o,n,l=q.current.head-i*(B?-1:1),d=q.current.tail-i*(B?-1:1),s=q.current.tail-q.current.head;l<=r?(o=r,n=r+s):d>=a?(o=a-s,n=a):(o=l,n=d),o=b(o),n=b(n),M([o,n]),z([o,n])}},V=d.useThrottledCallback((function(e){Z(e.clientX,e.clientY)})),G=d.useThrottledCallback((function(){q.current=null,_(!1)})),J=d.useThrottledCallback((function(e){Z(e.touches[0].pageX,e.touches[0].pageY)})),K=d.useThrottledCallback((function(){q.current=null,_(!1)})),Q=d.useThrottledCallback((function(e){M([e,A]),z([e,A])})),U=d.useThrottledCallback((function(e){M([W,e]),z([W,e])})),ee=i.useMemo((function(){return(A-W)/(a-r)*("vertical"===v?u.height:u.width)<30}),[r,a,W,A]),te=function(e){var t={min:r,max:A,value:W,onChange:Q},i={min:W,max:a,value:A,onChange:U};return"head"===e?h.jsx(s.Handle,p({"data-testid":"".concat(g,"_handle_top"),placement:"head",readOnly:!j,displayFormatter:y,orientation:v,classes:L,minimal:O},B?i:t)):"tail"===e?h.jsx(s.Handle,p({"data-testid":"".concat(g,"_handle_bottom"),placement:"tail",readOnly:!j,displayFormatter:y,orientation:v,classes:L,minimal:O},B?t:i)):null};return h.jsx("div",{className:k.rootWrapper,children:h.jsxs("div",{className:f.default(k.root,(t={},c.default(t,k.horizontalRoot,"horizontal"===v),c.default(t,k.verticalRoot,"vertical"===v),c.default(t,k.minimal,O),t)),children:[h.jsx(n.Resizable,{ref:R,minHeight:0,minWidth:0,enable:{right:"horizontal"===v,bottom:"vertical"===v},handleComponent:{right:te("head"),bottom:te("head")},onResize:$,onResizeStop:X}),h.jsx("div",{className:k.body,"data-testid":"slider-body",onMouseDown:function(e){Y(e.clientX,e.clientY),_(!0)},onTouchStart:function(e){Y(e.touches[0].pageX,e.touches[0].pageY),_(!0)},children:ee?h.jsx("div",{className:f.default((o={},c.default(o,k.horizontalBodyHandle,"horizontal"===v),c.default(o,k.verticalBodyHandle,"vertical"===v),c.default(o,k.leftBodyHandle,"left"===C),c.default(o,k.rightBodyHandle,"right"===C),c.default(o,k.topBodyHandle,"top"===C),c.default(o,k.bottomBodyHandle,"bottom"===C),o)),children:h.jsx("div",{className:k.bodyHandle,"data-testid":"".concat(g,"_handle"),children:h.jsx(w,{orientation:"vertical",minimal:O})})}):h.jsx("div",{className:k.bodyHandleIcon,"data-testid":"".concat(g,"_handle"),children:h.jsx(w,{orientation:v,minimal:O})})}),h.jsx(n.Resizable,{ref:F,minHeight:0,minWidth:0,enable:{left:"horizontal"===v,top:"vertical"===v},handleComponent:{left:te("tail"),top:te("tail")},onResize:$,onResizeStop:X})]})})};b.defaultProps={orientation:"horizontal",valueFormatter:Math.floor,displayFormatter:function(e){return e},onChange:l.noop,onStop:l.noop,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1};var y=r.withSize({monitorWidth:!0,monitorHeight:!0})(b),w=function(e){var t=e.orientation;return e.minimal?"horizontal"===t?h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"20",viewBox:"0 -2 16 16",fill:"none",children:h.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.33333 4L4 4L4 12L5.33333 12L5.33333 4ZM8.66659 4L8.66659 12L7.33325 12L7.33325 4L8.66659 4ZM12.0001 4L12.0001 12L10.6667 12L10.6667 4L12.0001 4Z",fill:"white"})}):h.jsxs("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("rect",{width:"12",height:"1"}),h.jsx("rect",{y:"3",width:"12",height:"1"}),h.jsx("rect",{y:"6",width:"12",height:"1"})]}):"horizontal"===t?h.jsxs("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("rect",{x:"7.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 7.5 0.5)"}),h.jsx("rect",{x:"4.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 4.5 0.5)"}),h.jsx("rect",{x:"1.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 1.5 0.5)"})]}):h.jsxs("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("rect",{width:"12",height:"1"}),h.jsx("rect",{y:"3",width:"12",height:"1"}),h.jsx("rect",{y:"6",width:"12",height:"1"})]})},x=o.makeStyles((function(e){return{rootWrapper:{position:"relative",width:"100%",height:"100%",zIndex:100},root:{position:"absolute",width:"100%",height:"100%",zIndex:100,"&:hover:not($minimal) $body":{background:"#008BA366"},"&:hover $bodyHandle":{visibility:"visible"}},horizontalRoot:{display:"flex",alignItems:"center"},verticalRoot:{display:"flex",alignItems:"center",flexDirection:"column"},body:{position:"relative",flex:1,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",background:"#3B3B3B66",color:"#BDBDBD","& svg":{fill:"currentColor"},"&:hover":{cursor:"grab",background:"#008BA366",color:"#FFFFFF"},"&:active":{cursor:"grabbing"},"&:hover $bodyHandleIcon":{visibility:"visible"}},horizontalBodyHandle:{position:"absolute",bottom:-24},verticalBodyHandle:{position:"absolute",left:-24},leftBodyHandle:{position:"absolute",left:-24,right:"auto"},rightBodyHandle:{position:"absolute",right:-24,left:"auto"},topBodyHandle:{position:"absolute",top:-24,bottom:"auto"},bottomBodyHandle:{position:"absolute",bottom:-24,top:"auto"},bodyHandle:{width:24,height:24,borderRadius:"50%",background:"#03BCD4",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",visibility:"hidden"},bodyHandleIcon:{visibility:"hidden"},minimal:{border:"1px solid ".concat(e.palette.background.b9),borderRadius:4,"& $body":{"&:hover":{background:"#008BA366"},margin:-1,width:"calc(100% + 2px)",height:"calc(100% + 2px)",backgroundColor:o.fade(e.palette.background.b7,.1),border:"1px solid ".concat(e.palette.primary.text9),borderRadius:4}}}}));exports.AdvancedSlider=b,exports.default=y;
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedSlider.d.ts","sourceRoot":"","sources":["../../../src/components/AdvancedSlider/AdvancedSlider.js"],"names":[],"mappings":"AA0BO,wDA0VN;;;;;QAKmB,kDAAc"}
1
+ {"version":3,"file":"AdvancedSlider.d.ts","sourceRoot":"","sources":["../../../src/components/AdvancedSlider/AdvancedSlider.js"],"names":[],"mappings":"AA2BO,wDA4VN;;;;;QAKmB,kDAAc"}
@@ -1 +1 @@
1
- import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import{useRef as i,useState as o,useEffect as n,useMemo as r}from"react";import{makeStyles as a,fade as l}from"@material-ui/core";import{Resizable as h}from"re-resizable";import{withSize as d}from"react-sizeme";import c from"classnames";import{noop as s}from"lodash";import{useThrottledCallback as u}from"../shared/useThrottledCallback.js";import{Handle as m}from"./Handle.js";import{jsx as p,jsxs as v}from"react/jsx-runtime";function g(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,o)}return i}function f(e){for(var i=1;i<arguments.length;i++){var o=null!=arguments[i]?arguments[i]:{};i%2?g(Object(o),!0).forEach((function(i){t(e,i,o[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):g(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var b=function(a){var l,d,s=a.min,g=a.max,b=a.value,y=a.size,z=a.orientation,B=a.valueFormatter,H=a.displayFormatter,L=a.editableHandles,O=a.onChange,F=a.onStop,j=a.reversed,P=a.handlePosition,C=a.handleClasses,R=a.minimal,S=x(),E=i(null),M=i(null),k=o([B(null==b?void 0:b.at(0)),B(null==b?void 0:b.at(1))]),D=e(k,2),I=D[0],N=D[1],W=i(null),$=o(!1),A=e($,2),X=A[0],Y=A[1];n((function(){if(!W.current){var t=[B(null==b?void 0:b.at(0)),B(null==b?void 0:b.at(1))],e=Math.min.apply(Math,t),i=Math.max.apply(Math,t);N([e,i])}}),[null==b?void 0:b.at(0),null==b?void 0:b.at(1)]);var T=e(I,2),Z=T[0],q=T[1];n((function(){if("horizontal"===z){var t=y.width/(g-s)*(Z-s),e=y.width/(g-s)*(g-q);E.current.updateSize({width:j?e:t,height:y.height}),M.current.updateSize({width:j?t:e,height:y.height})}else if("vertical"===z){var i=y.height/(g-s)*(Z-s),o=y.height/(g-s)*(g-q);E.current.updateSize({width:y.width,height:j?o:i}),M.current.updateSize({width:y.width,height:j?i:o})}}),[s,g,Z,q,y.width,y.height,z]),n((function(){var t=function(){document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",V),document.removeEventListener("touchmove",_),document.removeEventListener("touchend",tt)};return X?(document.addEventListener("mousemove",U),document.addEventListener("mouseup",V),document.addEventListener("touchmove",_),document.addEventListener("touchend",tt)):(t(),F()),function(){t()}}),[X]);var G=u((function(t,e,i){W.current="onResize Event";var o=i.clientWidth,n=i.clientHeight,r=Z,a=q;"right"===e?j?a=B(g-o/y.width*(g-s)):r=B(s+o/y.width*(g-s)):"left"===e?j?r=B(s+o/y.width*(g-s)):a=B(g-o/y.width*(g-s)):"bottom"===e?j?a=B(g-n/y.height*(g-s)):r=B(s+n/y.height*(g-s)):"top"===e&&(j?r=B(s+n/y.height*(g-s)):a=B(g-n/y.height*(g-s))),r=Math.min(r,q),a=Math.max(a,Z),N([r,a]),O([r,a])})),J=u((function(){W.current=null,F()})),K=function(t,e){W.current={xPos:t,yPos:e,head:Z,tail:q}},Q=function(t,e){if(W.current){var i;"horizontal"===z?i=(W.current.xPos-t)/y.width*(g-s):"vertical"===z&&(i=(W.current.yPos-e)/y.height*(g-s));var o,n,r=W.current.head-i*(j?-1:1),a=W.current.tail-i*(j?-1:1),l=W.current.tail-W.current.head;r<=s?(o=s,n=s+l):a>=g?(o=g-l,n=g):(o=r,n=a),o=B(o),n=B(n),N([o,n]),O([o,n])}},U=u((function(t){Q(t.clientX,t.clientY)})),V=u((function(){W.current=null,Y(!1)})),_=u((function(t){Q(t.touches[0].pageX,t.touches[0].pageY)})),tt=u((function(){W.current=null,Y(!1)})),et=u((function(t){N([t,q]),O([t,q])})),it=u((function(t){N([Z,t]),O([Z,t])})),ot=r((function(){return(q-Z)/(g-s)*("vertical"===z?y.height:y.width)<30}),[s,g,Z,q]),nt=function(t){var e={min:s,max:q,value:Z,onChange:et},i={min:Z,max:g,value:q,onChange:it};return"head"===t?p(m,f({placement:"head",readOnly:!L,displayFormatter:H,orientation:z,classes:C,minimal:R},j?i:e)):"tail"===t?p(m,f({placement:"tail",readOnly:!L,displayFormatter:H,orientation:z,classes:C,minimal:R},j?e:i)):null};return p("div",{className:S.rootWrapper,children:v("div",{className:c(S.root,(l={},t(l,S.horizontalRoot,"horizontal"===z),t(l,S.verticalRoot,"vertical"===z),t(l,S.minimal,R),l)),children:[p(h,{ref:E,minHeight:0,minWidth:0,enable:{right:"horizontal"===z,bottom:"vertical"===z},handleComponent:{right:nt("head"),bottom:nt("head")},onResize:G,onResizeStop:J}),p("div",{className:S.body,"data-testid":"slider-body",onMouseDown:function(t){K(t.clientX,t.clientY),Y(!0)},onTouchStart:function(t){K(t.touches[0].pageX,t.touches[0].pageY),Y(!0)},children:p("div",ot?{className:c((d={},t(d,S.horizontalBodyHandle,"horizontal"===z),t(d,S.verticalBodyHandle,"vertical"===z),t(d,S.leftBodyHandle,"left"===P),t(d,S.rightBodyHandle,"right"===P),t(d,S.topBodyHandle,"top"===P),t(d,S.bottomBodyHandle,"bottom"===P),d)),children:p("div",{className:S.bodyHandle,children:p(w,{orientation:"vertical",minimal:R})})}:{className:S.bodyHandleIcon,children:p(w,{orientation:z,minimal:R})})}),p(h,{ref:M,minHeight:0,minWidth:0,enable:{left:"horizontal"===z,top:"vertical"===z},handleComponent:{left:nt("tail"),top:nt("tail")},onResize:G,onResizeStop:J})]})})};b.defaultProps={orientation:"horizontal",valueFormatter:Math.floor,displayFormatter:function(t){return t},onChange:s,onStop:s,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1};var y=d({monitorWidth:!0,monitorHeight:!0})(b),w=function(t){var e=t.orientation;return t.minimal?"horizontal"===e?p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"20",viewBox:"0 -2 16 16",fill:"none",children:p("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.33333 4L4 4L4 12L5.33333 12L5.33333 4ZM8.66659 4L8.66659 12L7.33325 12L7.33325 4L8.66659 4ZM12.0001 4L12.0001 12L10.6667 12L10.6667 4L12.0001 4Z",fill:"white"})}):v("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("rect",{width:"12",height:"1"}),p("rect",{y:"3",width:"12",height:"1"}),p("rect",{y:"6",width:"12",height:"1"})]}):v("svg","horizontal"===e?{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("rect",{x:"7.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 7.5 0.5)"}),p("rect",{x:"4.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 4.5 0.5)"}),p("rect",{x:"1.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 1.5 0.5)"})]}:{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("rect",{width:"12",height:"1"}),p("rect",{y:"3",width:"12",height:"1"}),p("rect",{y:"6",width:"12",height:"1"})]})},x=a((function(t){return{rootWrapper:{position:"relative",width:"100%",height:"100%",zIndex:100},root:{position:"absolute",width:"100%",height:"100%",zIndex:100,"&:hover:not($minimal) $body":{background:"#008BA366"},"&:hover $bodyHandle":{visibility:"visible"}},horizontalRoot:{display:"flex",alignItems:"center"},verticalRoot:{display:"flex",alignItems:"center",flexDirection:"column"},body:{position:"relative",flex:1,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",background:"#3B3B3B66",color:"#BDBDBD","& svg":{fill:"currentColor"},"&:hover":{cursor:"grab",background:"#008BA366",color:"#FFFFFF"},"&:active":{cursor:"grabbing"},"&:hover $bodyHandleIcon":{visibility:"visible"}},horizontalBodyHandle:{position:"absolute",bottom:-24},verticalBodyHandle:{position:"absolute",left:-24},leftBodyHandle:{position:"absolute",left:-24,right:"auto"},rightBodyHandle:{position:"absolute",right:-24,left:"auto"},topBodyHandle:{position:"absolute",top:-24,bottom:"auto"},bottomBodyHandle:{position:"absolute",bottom:-24,top:"auto"},bodyHandle:{width:24,height:24,borderRadius:"50%",background:"#03BCD4",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",visibility:"hidden"},bodyHandleIcon:{visibility:"hidden"},minimal:{border:"1px solid ".concat(t.palette.background.b9),borderRadius:4,"& $body":{"&:hover":{background:"#008BA366"},margin:-1,width:"calc(100% + 2px)",height:"calc(100% + 2px)",backgroundColor:l(t.palette.background.b7,.1),border:"1px solid ".concat(t.palette.primary.text9),borderRadius:4}}}}));export{b as AdvancedSlider,y as default};
1
+ import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import{useRef as i,useState as o,useEffect as n,useMemo as r}from"react";import{makeStyles as a,fade as l}from"@material-ui/core";import{Resizable as d}from"re-resizable";import{withSize as h}from"react-sizeme";import c from"classnames";import{noop as s}from"lodash";import{useThrottledCallback as u}from"../shared/useThrottledCallback.js";import{Handle as m}from"./Handle.js";import{jsx as p,jsxs as v}from"react/jsx-runtime";function g(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,o)}return i}function f(e){for(var i=1;i<arguments.length;i++){var o=null!=arguments[i]?arguments[i]:{};i%2?g(Object(o),!0).forEach((function(i){t(e,i,o[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):g(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var b="twoValuesSliderDefault",y=function(a){var l,h,s=a.min,g=a.max,y=a.value,w=a.size,B=a.orientation,H=a.valueFormatter,L=a.displayFormatter,O=a.editableHandles,F=a.onChange,j=a.onStop,P=a.reversed,C=a.handlePosition,R=a.handleClasses,S=a.minimal,D=z(),E=i(null),M=i(null),k=o([H(null==y?void 0:y.at(0)),H(null==y?void 0:y.at(1))]),I=e(k,2),N=I[0],W=I[1],_=i(null),$=o(!1),A=e($,2),X=A[0],Y=A[1];n((function(){if(!_.current){var t=[H(null==y?void 0:y.at(0)),H(null==y?void 0:y.at(1))],e=Math.min.apply(Math,t),i=Math.max.apply(Math,t);W([e,i])}}),[null==y?void 0:y.at(0),null==y?void 0:y.at(1)]);var T=e(N,2),Z=T[0],V=T[1];n((function(){if("horizontal"===B){var t=w.width/(g-s)*(Z-s),e=w.width/(g-s)*(g-V);E.current.updateSize({width:P?e:t,height:w.height}),M.current.updateSize({width:P?t:e,height:w.height})}else if("vertical"===B){var i=w.height/(g-s)*(Z-s),o=w.height/(g-s)*(g-V);E.current.updateSize({width:w.width,height:P?o:i}),M.current.updateSize({width:w.width,height:P?i:o})}}),[s,g,Z,V,w.width,w.height,B]),n((function(){var t=function(){document.removeEventListener("mousemove",Q),document.removeEventListener("mouseup",U),document.removeEventListener("touchmove",tt),document.removeEventListener("touchend",et)};return X?(document.addEventListener("mousemove",Q),document.addEventListener("mouseup",U),document.addEventListener("touchmove",tt),document.addEventListener("touchend",et)):(t(),j()),function(){t()}}),[X]);var q=u((function(t,e,i){_.current="onResize Event";var o=i.clientWidth,n=i.clientHeight,r=Z,a=V;"right"===e?P?a=H(g-o/w.width*(g-s)):r=H(s+o/w.width*(g-s)):"left"===e?P?r=H(s+o/w.width*(g-s)):a=H(g-o/w.width*(g-s)):"bottom"===e?P?a=H(g-n/w.height*(g-s)):r=H(s+n/w.height*(g-s)):"top"===e&&(P?r=H(s+n/w.height*(g-s)):a=H(g-n/w.height*(g-s))),r=Math.min(r,V),a=Math.max(a,Z),W([r,a]),F([r,a])})),G=u((function(){_.current=null,j()})),J=function(t,e){_.current={xPos:t,yPos:e,head:Z,tail:V}},K=function(t,e){if(_.current){var i;"horizontal"===B?i=(_.current.xPos-t)/w.width*(g-s):"vertical"===B&&(i=(_.current.yPos-e)/w.height*(g-s));var o,n,r=_.current.head-i*(P?-1:1),a=_.current.tail-i*(P?-1:1),l=_.current.tail-_.current.head;r<=s?(o=s,n=s+l):a>=g?(o=g-l,n=g):(o=r,n=a),o=H(o),n=H(n),W([o,n]),F([o,n])}},Q=u((function(t){K(t.clientX,t.clientY)})),U=u((function(){_.current=null,Y(!1)})),tt=u((function(t){K(t.touches[0].pageX,t.touches[0].pageY)})),et=u((function(){_.current=null,Y(!1)})),it=u((function(t){W([t,V]),F([t,V])})),ot=u((function(t){W([Z,t]),F([Z,t])})),nt=r((function(){return(V-Z)/(g-s)*("vertical"===B?w.height:w.width)<30}),[s,g,Z,V]),rt=function(t){var e={min:s,max:V,value:Z,onChange:it},i={min:Z,max:g,value:V,onChange:ot};return"head"===t?p(m,f({"data-testid":"".concat(b,"_handle_top"),placement:"head",readOnly:!O,displayFormatter:L,orientation:B,classes:R,minimal:S},P?i:e)):"tail"===t?p(m,f({"data-testid":"".concat(b,"_handle_bottom"),placement:"tail",readOnly:!O,displayFormatter:L,orientation:B,classes:R,minimal:S},P?e:i)):null};return p("div",{className:D.rootWrapper,children:v("div",{className:c(D.root,(l={},t(l,D.horizontalRoot,"horizontal"===B),t(l,D.verticalRoot,"vertical"===B),t(l,D.minimal,S),l)),children:[p(d,{ref:E,minHeight:0,minWidth:0,enable:{right:"horizontal"===B,bottom:"vertical"===B},handleComponent:{right:rt("head"),bottom:rt("head")},onResize:q,onResizeStop:G}),p("div",{className:D.body,"data-testid":"slider-body",onMouseDown:function(t){J(t.clientX,t.clientY),Y(!0)},onTouchStart:function(t){J(t.touches[0].pageX,t.touches[0].pageY),Y(!0)},children:p("div",nt?{className:c((h={},t(h,D.horizontalBodyHandle,"horizontal"===B),t(h,D.verticalBodyHandle,"vertical"===B),t(h,D.leftBodyHandle,"left"===C),t(h,D.rightBodyHandle,"right"===C),t(h,D.topBodyHandle,"top"===C),t(h,D.bottomBodyHandle,"bottom"===C),h)),children:p("div",{className:D.bodyHandle,"data-testid":"".concat(b,"_handle"),children:p(x,{orientation:"vertical",minimal:S})})}:{className:D.bodyHandleIcon,"data-testid":"".concat(b,"_handle"),children:p(x,{orientation:B,minimal:S})})}),p(d,{ref:M,minHeight:0,minWidth:0,enable:{left:"horizontal"===B,top:"vertical"===B},handleComponent:{left:rt("tail"),top:rt("tail")},onResize:q,onResizeStop:G})]})})};y.defaultProps={orientation:"horizontal",valueFormatter:Math.floor,displayFormatter:function(t){return t},onChange:s,onStop:s,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1};var w=h({monitorWidth:!0,monitorHeight:!0})(y),x=function(t){var e=t.orientation;return t.minimal?"horizontal"===e?p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"20",viewBox:"0 -2 16 16",fill:"none",children:p("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.33333 4L4 4L4 12L5.33333 12L5.33333 4ZM8.66659 4L8.66659 12L7.33325 12L7.33325 4L8.66659 4ZM12.0001 4L12.0001 12L10.6667 12L10.6667 4L12.0001 4Z",fill:"white"})}):v("svg",{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("rect",{width:"12",height:"1"}),p("rect",{y:"3",width:"12",height:"1"}),p("rect",{y:"6",width:"12",height:"1"})]}):v("svg","horizontal"===e?{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("rect",{x:"7.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 7.5 0.5)"}),p("rect",{x:"4.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 4.5 0.5)"}),p("rect",{x:"1.5",y:"0.5",width:"12",height:"1",transform:"rotate(90 1.5 0.5)"})]}:{width:"12",height:"7",viewBox:"0 0 12 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("rect",{width:"12",height:"1"}),p("rect",{y:"3",width:"12",height:"1"}),p("rect",{y:"6",width:"12",height:"1"})]})},z=a((function(t){return{rootWrapper:{position:"relative",width:"100%",height:"100%",zIndex:100},root:{position:"absolute",width:"100%",height:"100%",zIndex:100,"&:hover:not($minimal) $body":{background:"#008BA366"},"&:hover $bodyHandle":{visibility:"visible"}},horizontalRoot:{display:"flex",alignItems:"center"},verticalRoot:{display:"flex",alignItems:"center",flexDirection:"column"},body:{position:"relative",flex:1,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",background:"#3B3B3B66",color:"#BDBDBD","& svg":{fill:"currentColor"},"&:hover":{cursor:"grab",background:"#008BA366",color:"#FFFFFF"},"&:active":{cursor:"grabbing"},"&:hover $bodyHandleIcon":{visibility:"visible"}},horizontalBodyHandle:{position:"absolute",bottom:-24},verticalBodyHandle:{position:"absolute",left:-24},leftBodyHandle:{position:"absolute",left:-24,right:"auto"},rightBodyHandle:{position:"absolute",right:-24,left:"auto"},topBodyHandle:{position:"absolute",top:-24,bottom:"auto"},bottomBodyHandle:{position:"absolute",bottom:-24,top:"auto"},bodyHandle:{width:24,height:24,borderRadius:"50%",background:"#03BCD4",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",visibility:"hidden"},bodyHandleIcon:{visibility:"hidden"},minimal:{border:"1px solid ".concat(t.palette.background.b9),borderRadius:4,"& $body":{"&:hover":{background:"#008BA366"},margin:-1,width:"calc(100% + 2px)",height:"calc(100% + 2px)",backgroundColor:l(t.palette.background.b7,.1),border:"1px solid ".concat(t.palette.primary.text9),borderRadius:4}}}}));export{y as AdvancedSlider,w as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.72.0-4",
3
+ "version": "0.72.0-5",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"