@corva/ui 0.87.0-11 → 0.87.0-12

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/slicedToArray"),t=require("@babel/runtime/helpers/defineProperty"),i=require("react"),n=require("re-resizable"),a=require("react-sizeme"),r=require("classnames"),o=require("lodash"),l=require("../shared/useThrottledCallback.js"),d=require("./Handle.js"),s=require("./icons/HandleIcon.js"),u=require("./utils.js"),h=require("./styles/sliderStyles.js");require("./styles/handleStyles.js");var c=require("./constants.js"),m=require("react/jsx-runtime");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=f(e),p=f(t),b=f(r);function g(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function y(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?g(Object(i),!0).forEach((function(t){p.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):g(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var w="twoValuesSliderDefault",O=function(e){var t,a,r=e.min,o=e.max,f=e.value,g=e.size,O=e.orientation,j=e.valueFormatter,I=e.displayFormatter,R=e.editableHandles,x=e.onChange,H=e.onStop,A=e.reversed,N=e.handlePosition,T=e.handleClasses,_=e.minimal,P=e.dimension,M=h.useSliderStyles(),z=i.useRef(null),C=i.useRef(null),E=O===c.HORIZONTAL_ORIENTATION,S=O===c.VERTICAL_ORIENTATION,q=_?g:y(y({},g),{},{width:E?g.width-2*c.INPUT_WIDTH:g.width,height:S?g.height-2*c.INPUT_HEIGHT:g.height}),L=i.useState([j(null==f?void 0:f.at(0)),j(null==f?void 0:f.at(1))]),W=v.default(L,2),k=W[0],G=W[1],D=i.useRef(null),B=i.useState(!1),F=v.default(B,2),V=F[0],X=F[1],Y=v.default(k,2),Z=Y[0],U=Y[1],J=u.getSizedControls({isHorizontalOrientation:E,size:q,max:o,min:r,tail:U,head:Z}),K=J.headMaxWidth,Q=J.tailMaxWidth,$=J.headMaxHeight,ee=J.tailMaxHeight;i.useEffect((function(){if(!D.current){var e=[j(null==f?void 0:f.at(0)),j(null==f?void 0:f.at(1))],t=Math.min.apply(Math,e),i=Math.max.apply(Math,e);G([t,i])}}),[null==f?void 0:f.at(0),null==f?void 0:f.at(1)]),i.useEffect((function(){if(E){var e=q.width/(o-r)*(Z-r),t=q.width/(o-r)*(o-U);z.current.updateSize({width:A?t:e,height:q.height}),C.current.updateSize({width:A?e:t,height:q.height})}else if(S){var i=q.height/(o-r)*(Z-r),n=q.height/(o-r)*(o-U);z.current.updateSize({width:q.width,height:A?n:i}),C.current.updateSize({width:q.width,height:A?i:n})}}),[r,o,Z,U,q.width,q.height,O]),i.useEffect((function(){var e=function(){document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",oe),document.removeEventListener("touchmove",le),document.removeEventListener("touchend",de)};return V?(document.addEventListener("mousemove",re),document.addEventListener("mouseup",oe),document.addEventListener("touchmove",le),document.addEventListener("touchend",de)):(e(),H()),function(){e()}}),[V]);var te=l.useThrottledCallback((function(e,t,i){D.current="onResize Event";var n=i.clientWidth,a=i.clientHeight,l=Z,d=U;"right"===t?A?d=j(o-n/q.width*(o-r)):l=j(r+n/q.width*(o-r)):"left"===t?A?l=j(r+n/q.width*(o-r)):d=j(o-n/q.width*(o-r)):"bottom"===t?A?d=j(o-a/q.height*(o-r)):l=j(r+a/q.height*(o-r)):"top"===t&&(A?l=j(r+a/q.height*(o-r)):d=j(o-a/q.height*(o-r))),l=Math.min(l,U),d=Math.max(d,Z),G([l,d]),x([l,d])})),ie=l.useThrottledCallback((function(){D.current=null,H()})),ne=function(e,t){D.current={xPos:e,yPos:t,head:Z,tail:U}},ae=function(e,t){if(D.current){var i;E?i=(D.current.xPos-e)/q.width*(o-r):S&&(i=(D.current.yPos-t)/q.height*(o-r));var n,a,l=D.current.head-i*(A?-1:1),d=D.current.tail-i*(A?-1:1),s=D.current.tail-D.current.head;l<=r?(n=r,a=r+s):d>=o?(n=o-s,a=o):(n=l,a=d),n=j(n),a=j(a),G([n,a]),x([n,a])}},re=l.useThrottledCallback((function(e){ae(e.clientX,e.clientY)})),oe=l.useThrottledCallback((function(){D.current=null,X(!1)})),le=l.useThrottledCallback((function(e){ae(e.touches[0].pageX,e.touches[0].pageY)})),de=l.useThrottledCallback((function(){D.current=null,X(!1)})),se=l.useThrottledCallback((function(e){G([e,U]),x([e,U])})),ue=l.useThrottledCallback((function(e){G([Z,e]),x([Z,e])})),he=i.useMemo((function(){return(U-Z)/(o-r)*(S?q.height:q.width)<30}),[r,o,Z,U]),ce=i.useMemo((function(){return(U-Z)/(o-r)*(S?q.height:q.width)<c.INNER_GAP}),[r,o,Z,U]),me=function(e,t){return e/t*(S?q.height:q.width)},fe=i.useMemo((function(){if(_)return{};var e=E?c.HORIZONTAL_MIN_GAP:c.VERTICAL_MIN_GAP;return A?{isRightArrowInvisible:me(Z,o)<c.MIN_ARROW_GAP,isLeftArrowInvisible:me(o-U,o)<c.MIN_ARROW_GAP,distance:(U-Z)/(o-r)*(S?q.height:q.width)-e}:{isRightArrowInvisible:me(o-U,o)<c.MIN_ARROW_GAP,isLeftArrowInvisible:me(Z,o)<c.MIN_ARROW_GAP,distance:(U-Z)/(o-r)*(S?q.height:q.width)-e}}),[r,o,Z,U,A]),ve=function(e){var t={min:r,max:U,value:Z,onChange:se},i={min:Z,max:o,value:U,onChange:ue};return"head"===e?m.jsx(d.Handle,y({"data-testid":"".concat(w,"_handle_top"),placement:"head",readOnly:!R,isInsideArrowsVisible:ce,arrowsOutsideConfig:fe,displayFormatter:I,orientation:O,classes:T,minimal:_},A?i:t)):"tail"===e?m.jsx(d.Handle,y({"data-testid":"".concat(w,"_handle_bottom"),placement:"tail",readOnly:!R,isInsideArrowsVisible:ce,arrowsOutsideConfig:fe,displayFormatter:I,orientation:O,classes:T,minimal:_},A?t:i)):null};return m.jsx("div",{className:b.default(M.rootWrapper,M["".concat(O,"-").concat(P)],p.default({},M.rootMinimal,_)),children:m.jsxs("div",{className:b.default(M.root,(t={},p.default(t,M.horizontalRoot,E),p.default(t,M.verticalRoot,S),p.default(t,M.minimal,_),t)),children:[m.jsx(n.Resizable,{className:M.resizable,ref:z,minHeight:0,minWidth:0,maxWidth:A?Q:K,maxHeight:A?ee:$,enable:{right:E,bottom:S},handleComponent:{right:ve("head"),bottom:ve("head")},onResize:te,onResizeStop:ie}),m.jsx("div",{className:M.body,"data-testid":"slider-body",onMouseDown:function(e){ne(e.clientX,e.clientY),X(!0)},onTouchStart:function(e){ne(e.touches[0].pageX,e.touches[0].pageY),X(!0)},children:he?m.jsx("div",{className:b.default((a={},p.default(a,M.horizontalBodyHandle,E),p.default(a,M.verticalBodyHandle,S),p.default(a,M.leftBodyHandle,"left"===N),p.default(a,M.rightBodyHandle,"right"===N),p.default(a,M.topBodyHandle,"top"===N),p.default(a,M.bottomBodyHandle,"bottom"===N),a)),children:m.jsx("div",{className:M.bodyHandle,"data-testid":"".concat(w,"_handle"),children:m.jsx(s.HandleIcon,{orientation:"vertical",minimal:_})})}):m.jsx("div",{className:M.bodyHandleIcon,"data-testid":"".concat(w,"_handle"),children:m.jsx(s.HandleIcon,{orientation:O,minimal:_})})}),m.jsx(n.Resizable,{className:M.resizable,ref:C,minHeight:0,minWidth:0,enable:{left:E,top:S},handleComponent:{left:ve("tail"),top:ve("tail")},onResize:te,onResizeStop:ie})]})})};O.defaultProps={orientation:c.HORIZONTAL_ORIENTATION,valueFormatter:Math.floor,displayFormatter:function(e){return e},onChange:o.noop,onStop:o.noop,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1,dimension:"small"};var j=a.withSize({monitorWidth:!0,monitorHeight:!0})(O);exports.AdvancedSlider=O,exports.default=j;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/defineProperty"),i=require("react"),n=require("re-resizable"),a=require("react-sizeme"),r=require("classnames"),o=require("lodash"),l=require("../shared/useThrottledCallback.js"),d=require("./Handle.js"),s=require("./icons/HandleIcon.js"),u=require("./utils.js"),h=require("./styles/sliderStyles.js");require("./styles/handleStyles.js");var c=require("./constants.js"),m=require("react/jsx-runtime");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=f(e),p=f(t),b=f(r);function g(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function y(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?g(Object(i),!0).forEach((function(t){p.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):g(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var w="twoValuesSliderDefault",O=function(e){var t,a,r=e.min,o=e.max,f=e.value,g=e.size,O=e.orientation,j=e.valueFormatter,I=e.displayFormatter,R=e.editableHandles,x=e.onChange,H=e.onStop,A=e.reversed,N=e.handlePosition,T=e.handleClasses,_=e.minimal,P=e.dimension,M=h.useSliderStyles(),z=i.useRef(null),C=i.useRef(null),E=O===c.HORIZONTAL_ORIENTATION,S=O===c.VERTICAL_ORIENTATION,q=_?g:y(y({},g),{},{width:E?g.width-2*c.INPUT_WIDTH:g.width,height:S?g.height-2*c.INPUT_HEIGHT:g.height}),L=i.useState([j(null==f?void 0:f.at(0)),j(null==f?void 0:f.at(1))]),W=v.default(L,2),k=W[0],G=W[1],D=i.useRef(null),B=i.useState(!1),F=v.default(B,2),V=F[0],X=F[1],Y=v.default(k,2),Z=Y[0],U=Y[1],J=u.getSizedControls({isHorizontalOrientation:E,size:q,max:o,min:r,tail:U,head:Z}),K=J.headMaxWidth,Q=J.tailMaxWidth,$=J.headMaxHeight,ee=J.tailMaxHeight;i.useEffect((function(){if(!D.current){var e=[j(null==f?void 0:f.at(0)),j(null==f?void 0:f.at(1))],t=Math.min.apply(Math,e),i=Math.max.apply(Math,e);G([t,i])}}),[null==f?void 0:f.at(0),null==f?void 0:f.at(1)]),i.useEffect((function(){if(E){var e=q.width/(o-r)*(Z-r),t=q.width/(o-r)*(o-U);z.current.updateSize({width:A?t:e,height:q.height}),C.current.updateSize({width:A?e:t,height:q.height})}else if(S){var i=q.height/(o-r)*(Z-r),n=q.height/(o-r)*(o-U);z.current.updateSize({width:q.width,height:A?n:i}),C.current.updateSize({width:q.width,height:A?i:n})}}),[r,o,Z,U,q.width,q.height,O]),i.useEffect((function(){var e=function(){document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",oe),document.removeEventListener("touchmove",le),document.removeEventListener("touchend",de)};return V?(document.addEventListener("mousemove",re),document.addEventListener("mouseup",oe),document.addEventListener("touchmove",le),document.addEventListener("touchend",de)):(e(),H()),function(){e()}}),[V]);var te=l.useThrottledCallback((function(e,t,i){D.current="onResize Event";var n=i.clientWidth,a=i.clientHeight,l=Z,d=U;"right"===t?A?d=j(o-n/q.width*(o-r)):l=j(r+n/q.width*(o-r)):"left"===t?A?l=j(r+n/q.width*(o-r)):d=j(o-n/q.width*(o-r)):"bottom"===t?A?d=j(o-a/q.height*(o-r)):l=j(r+a/q.height*(o-r)):"top"===t&&(A?l=j(r+a/q.height*(o-r)):d=j(o-a/q.height*(o-r))),l=Math.min(l,U),d=Math.max(d,Z),G([l,d]),x([l,d])})),ie=l.useThrottledCallback((function(){D.current=null,H()})),ne=function(e,t){D.current={xPos:e,yPos:t,head:Z,tail:U}},ae=function(e,t){if(D.current){var i;E?i=(D.current.xPos-e)/q.width*(o-r):S&&(i=(D.current.yPos-t)/q.height*(o-r));var n,a,l=D.current.head-i*(A?-1:1),d=D.current.tail-i*(A?-1:1),s=D.current.tail-D.current.head;l<=r?(n=r,a=r+s):d>=o?(n=o-s,a=o):(n=l,a=d),n=j(n),a=j(a),G([n,a]),x([n,a])}},re=l.useThrottledCallback((function(e){ae(e.clientX,e.clientY)})),oe=l.useThrottledCallback((function(){D.current=null,X(!1)})),le=l.useThrottledCallback((function(e){ae(e.touches[0].pageX,e.touches[0].pageY)})),de=l.useThrottledCallback((function(){D.current=null,X(!1)})),se=l.useThrottledCallback((function(e){G([e,U]),x([e,U]),H()})),ue=l.useThrottledCallback((function(e){G([Z,e]),x([Z,e]),H()})),he=i.useMemo((function(){return(U-Z)/(o-r)*(S?q.height:q.width)<30}),[r,o,Z,U]),ce=i.useMemo((function(){return(U-Z)/(o-r)*(S?q.height:q.width)<c.INNER_GAP}),[r,o,Z,U]),me=function(e,t){return e/t*(S?q.height:q.width)},fe=i.useMemo((function(){if(_)return{};var e=E?c.HORIZONTAL_MIN_GAP:c.VERTICAL_MIN_GAP;return A?{isRightArrowInvisible:me(Z,o)<c.MIN_ARROW_GAP,isLeftArrowInvisible:me(o-U,o)<c.MIN_ARROW_GAP,distance:(U-Z)/(o-r)*(S?q.height:q.width)-e}:{isRightArrowInvisible:me(o-U,o)<c.MIN_ARROW_GAP,isLeftArrowInvisible:me(Z,o)<c.MIN_ARROW_GAP,distance:(U-Z)/(o-r)*(S?q.height:q.width)-e}}),[r,o,Z,U,A]),ve=function(e){var t={min:r,max:U,value:Z,onChange:se},i={min:Z,max:o,value:U,onChange:ue};return"head"===e?m.jsx(d.Handle,y({"data-testid":"".concat(w,"_handle_top"),placement:"head",readOnly:!R,isInsideArrowsVisible:ce,arrowsOutsideConfig:fe,displayFormatter:I,orientation:O,classes:T,minimal:_},A?i:t)):"tail"===e?m.jsx(d.Handle,y({"data-testid":"".concat(w,"_handle_bottom"),placement:"tail",readOnly:!R,isInsideArrowsVisible:ce,arrowsOutsideConfig:fe,displayFormatter:I,orientation:O,classes:T,minimal:_},A?t:i)):null};return m.jsx("div",{className:b.default(M.rootWrapper,M["".concat(O,"-").concat(P)],p.default({},M.rootMinimal,_)),children:m.jsxs("div",{className:b.default(M.root,(t={},p.default(t,M.horizontalRoot,E),p.default(t,M.verticalRoot,S),p.default(t,M.minimal,_),t)),children:[m.jsx(n.Resizable,{className:M.resizable,ref:z,minHeight:0,minWidth:0,maxWidth:A?Q:K,maxHeight:A?ee:$,enable:{right:E,bottom:S},handleComponent:{right:ve("head"),bottom:ve("head")},onResize:te,onResizeStop:ie}),m.jsx("div",{className:M.body,"data-testid":"slider-body",onMouseDown:function(e){ne(e.clientX,e.clientY),X(!0)},onTouchStart:function(e){ne(e.touches[0].pageX,e.touches[0].pageY),X(!0)},children:he?m.jsx("div",{className:b.default((a={},p.default(a,M.horizontalBodyHandle,E),p.default(a,M.verticalBodyHandle,S),p.default(a,M.leftBodyHandle,"left"===N),p.default(a,M.rightBodyHandle,"right"===N),p.default(a,M.topBodyHandle,"top"===N),p.default(a,M.bottomBodyHandle,"bottom"===N),a)),children:m.jsx("div",{className:M.bodyHandle,"data-testid":"".concat(w,"_handle"),children:m.jsx(s.HandleIcon,{orientation:"vertical",minimal:_})})}):m.jsx("div",{className:M.bodyHandleIcon,"data-testid":"".concat(w,"_handle"),children:m.jsx(s.HandleIcon,{orientation:O,minimal:_})})}),m.jsx(n.Resizable,{className:M.resizable,ref:C,minHeight:0,minWidth:0,enable:{left:E,top:S},handleComponent:{left:ve("tail"),top:ve("tail")},onResize:te,onResizeStop:ie})]})})};O.defaultProps={orientation:c.HORIZONTAL_ORIENTATION,valueFormatter:Math.floor,displayFormatter:function(e){return e},onChange:o.noop,onStop:o.noop,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1,dimension:"small"};var j=a.withSize({monitorWidth:!0,monitorHeight:!0})(O);exports.AdvancedSlider=O,exports.default=j;
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedSlider.d.ts","sourceRoot":"","sources":["../../../src/components/AdvancedSlider/AdvancedSlider.js"],"names":[],"mappings":"AAyCO,wDAyZN;;;;;QAKmB,kDAAc"}
1
+ {"version":3,"file":"AdvancedSlider.d.ts","sourceRoot":"","sources":["../../../src/components/AdvancedSlider/AdvancedSlider.js"],"names":[],"mappings":"AAyCO,wDA2ZN;;;;;QAKmB,kDAAc"}
@@ -1 +1 @@
1
- import t from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/defineProperty";import{useRef as i,useState as n,useEffect as o,useMemo as r}from"react";import{Resizable as a}from"re-resizable";import{withSize as l}from"react-sizeme";import d from"classnames";import{noop as h}from"lodash";import{useThrottledCallback as s}from"../shared/useThrottledCallback.js";import{Handle as c}from"./Handle.js";import{HandleIcon as m}from"./icons/HandleIcon.js";import{getSizedControls as u}from"./utils.js";import{useSliderStyles as f}from"./styles/sliderStyles.js";import"./styles/handleStyles.js";import{HORIZONTAL_ORIENTATION as p,INPUT_WIDTH as v,INPUT_HEIGHT as g,INNER_GAP as b,MIN_ARROW_GAP as w,VERTICAL_ORIENTATION as y,HORIZONTAL_MIN_GAP as O,VERTICAL_MIN_GAP as H}from"./constants.js";import{jsx as j,jsxs as z}from"react/jsx-runtime";function x(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function P(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?x(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var S="twoValuesSliderDefault",M=function(l){var h,x,M=l.min,C=l.max,E=l.value,L=l.size,R=l.orientation,I=l.valueFormatter,N=l.displayFormatter,W=l.editableHandles,A=l.onChange,B=l.onStop,D=l.reversed,F=l.handlePosition,_=l.handleClasses,X=l.minimal,Y=l.dimension,T=f(),V=i(null),k=i(null),q=R===p,G=R===y,J=X?L:P(P({},L),{},{width:q?L.width-2*v:L.width,height:G?L.height-2*g:L.height}),K=n([I(null==E?void 0:E.at(0)),I(null==E?void 0:E.at(1))]),Q=t(K,2),U=Q[0],Z=Q[1],$=i(null),tt=n(!1),et=t(tt,2),it=et[0],nt=et[1],ot=t(U,2),rt=ot[0],at=ot[1],lt=u({isHorizontalOrientation:q,size:J,max:C,min:M,tail:at,head:rt}),dt=lt.headMaxWidth,ht=lt.tailMaxWidth,st=lt.headMaxHeight,ct=lt.tailMaxHeight;o((function(){if(!$.current){var t=[I(null==E?void 0:E.at(0)),I(null==E?void 0:E.at(1))],e=Math.min.apply(Math,t),i=Math.max.apply(Math,t);Z([e,i])}}),[null==E?void 0:E.at(0),null==E?void 0:E.at(1)]),o((function(){if(q){var t=J.width/(C-M)*(rt-M),e=J.width/(C-M)*(C-at);V.current.updateSize({width:D?e:t,height:J.height}),k.current.updateSize({width:D?t:e,height:J.height})}else if(G){var i=J.height/(C-M)*(rt-M),n=J.height/(C-M)*(C-at);V.current.updateSize({width:J.width,height:D?n:i}),k.current.updateSize({width:J.width,height:D?i:n})}}),[M,C,rt,at,J.width,J.height,R]),o((function(){var t=function(){document.removeEventListener("mousemove",vt),document.removeEventListener("mouseup",gt),document.removeEventListener("touchmove",bt),document.removeEventListener("touchend",wt)};return it?(document.addEventListener("mousemove",vt),document.addEventListener("mouseup",gt),document.addEventListener("touchmove",bt),document.addEventListener("touchend",wt)):(t(),B()),function(){t()}}),[it]);var mt=s((function(t,e,i){$.current="onResize Event";var n=i.clientWidth,o=i.clientHeight,r=rt,a=at;"right"===e?D?a=I(C-n/J.width*(C-M)):r=I(M+n/J.width*(C-M)):"left"===e?D?r=I(M+n/J.width*(C-M)):a=I(C-n/J.width*(C-M)):"bottom"===e?D?a=I(C-o/J.height*(C-M)):r=I(M+o/J.height*(C-M)):"top"===e&&(D?r=I(M+o/J.height*(C-M)):a=I(C-o/J.height*(C-M))),r=Math.min(r,at),a=Math.max(a,rt),Z([r,a]),A([r,a])})),ut=s((function(){$.current=null,B()})),ft=function(t,e){$.current={xPos:t,yPos:e,head:rt,tail:at}},pt=function(t,e){if($.current){var i;q?i=($.current.xPos-t)/J.width*(C-M):G&&(i=($.current.yPos-e)/J.height*(C-M));var n,o,r=$.current.head-i*(D?-1:1),a=$.current.tail-i*(D?-1:1),l=$.current.tail-$.current.head;r<=M?(n=M,o=M+l):a>=C?(n=C-l,o=C):(n=r,o=a),n=I(n),o=I(o),Z([n,o]),A([n,o])}},vt=s((function(t){pt(t.clientX,t.clientY)})),gt=s((function(){$.current=null,nt(!1)})),bt=s((function(t){pt(t.touches[0].pageX,t.touches[0].pageY)})),wt=s((function(){$.current=null,nt(!1)})),yt=s((function(t){Z([t,at]),A([t,at])})),Ot=s((function(t){Z([rt,t]),A([rt,t])})),Ht=r((function(){return(at-rt)/(C-M)*(G?J.height:J.width)<30}),[M,C,rt,at]),jt=r((function(){return(at-rt)/(C-M)*(G?J.height:J.width)<b}),[M,C,rt,at]),zt=function(t,e){return t/e*(G?J.height:J.width)},xt=r((function(){if(X)return{};var t=q?O:H;return D?{isRightArrowInvisible:zt(rt,C)<w,isLeftArrowInvisible:zt(C-at,C)<w,distance:(at-rt)/(C-M)*(G?J.height:J.width)-t}:{isRightArrowInvisible:zt(C-at,C)<w,isLeftArrowInvisible:zt(rt,C)<w,distance:(at-rt)/(C-M)*(G?J.height:J.width)-t}}),[M,C,rt,at,D]),Pt=function(t){var e={min:M,max:at,value:rt,onChange:yt},i={min:rt,max:C,value:at,onChange:Ot};return"head"===t?j(c,P({"data-testid":"".concat(S,"_handle_top"),placement:"head",readOnly:!W,isInsideArrowsVisible:jt,arrowsOutsideConfig:xt,displayFormatter:N,orientation:R,classes:_,minimal:X},D?i:e)):"tail"===t?j(c,P({"data-testid":"".concat(S,"_handle_bottom"),placement:"tail",readOnly:!W,isInsideArrowsVisible:jt,arrowsOutsideConfig:xt,displayFormatter:N,orientation:R,classes:_,minimal:X},D?e:i)):null};return j("div",{className:d(T.rootWrapper,T["".concat(R,"-").concat(Y)],e({},T.rootMinimal,X)),children:z("div",{className:d(T.root,(h={},e(h,T.horizontalRoot,q),e(h,T.verticalRoot,G),e(h,T.minimal,X),h)),children:[j(a,{className:T.resizable,ref:V,minHeight:0,minWidth:0,maxWidth:D?ht:dt,maxHeight:D?ct:st,enable:{right:q,bottom:G},handleComponent:{right:Pt("head"),bottom:Pt("head")},onResize:mt,onResizeStop:ut}),j("div",{className:T.body,"data-testid":"slider-body",onMouseDown:function(t){ft(t.clientX,t.clientY),nt(!0)},onTouchStart:function(t){ft(t.touches[0].pageX,t.touches[0].pageY),nt(!0)},children:j("div",Ht?{className:d((x={},e(x,T.horizontalBodyHandle,q),e(x,T.verticalBodyHandle,G),e(x,T.leftBodyHandle,"left"===F),e(x,T.rightBodyHandle,"right"===F),e(x,T.topBodyHandle,"top"===F),e(x,T.bottomBodyHandle,"bottom"===F),x)),children:j("div",{className:T.bodyHandle,"data-testid":"".concat(S,"_handle"),children:j(m,{orientation:"vertical",minimal:X})})}:{className:T.bodyHandleIcon,"data-testid":"".concat(S,"_handle"),children:j(m,{orientation:R,minimal:X})})}),j(a,{className:T.resizable,ref:k,minHeight:0,minWidth:0,enable:{left:q,top:G},handleComponent:{left:Pt("tail"),top:Pt("tail")},onResize:mt,onResizeStop:ut})]})})};M.defaultProps={orientation:p,valueFormatter:Math.floor,displayFormatter:function(t){return t},onChange:h,onStop:h,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1,dimension:"small"};var C=l({monitorWidth:!0,monitorHeight:!0})(M);export{M as AdvancedSlider,C as default};
1
+ import t from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/defineProperty";import{useRef as i,useState as n,useEffect as o,useMemo as r}from"react";import{Resizable as a}from"re-resizable";import{withSize as l}from"react-sizeme";import d from"classnames";import{noop as h}from"lodash";import{useThrottledCallback as s}from"../shared/useThrottledCallback.js";import{Handle as c}from"./Handle.js";import{HandleIcon as m}from"./icons/HandleIcon.js";import{getSizedControls as u}from"./utils.js";import{useSliderStyles as f}from"./styles/sliderStyles.js";import"./styles/handleStyles.js";import{HORIZONTAL_ORIENTATION as p,INPUT_WIDTH as v,INPUT_HEIGHT as g,INNER_GAP as b,MIN_ARROW_GAP as w,VERTICAL_ORIENTATION as y,HORIZONTAL_MIN_GAP as O,VERTICAL_MIN_GAP as H}from"./constants.js";import{jsx as j,jsxs as z}from"react/jsx-runtime";function x(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function P(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?x(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var S="twoValuesSliderDefault",M=function(l){var h,x,M=l.min,C=l.max,E=l.value,L=l.size,R=l.orientation,I=l.valueFormatter,N=l.displayFormatter,W=l.editableHandles,A=l.onChange,B=l.onStop,D=l.reversed,F=l.handlePosition,_=l.handleClasses,X=l.minimal,Y=l.dimension,T=f(),V=i(null),k=i(null),q=R===p,G=R===y,J=X?L:P(P({},L),{},{width:q?L.width-2*v:L.width,height:G?L.height-2*g:L.height}),K=n([I(null==E?void 0:E.at(0)),I(null==E?void 0:E.at(1))]),Q=t(K,2),U=Q[0],Z=Q[1],$=i(null),tt=n(!1),et=t(tt,2),it=et[0],nt=et[1],ot=t(U,2),rt=ot[0],at=ot[1],lt=u({isHorizontalOrientation:q,size:J,max:C,min:M,tail:at,head:rt}),dt=lt.headMaxWidth,ht=lt.tailMaxWidth,st=lt.headMaxHeight,ct=lt.tailMaxHeight;o((function(){if(!$.current){var t=[I(null==E?void 0:E.at(0)),I(null==E?void 0:E.at(1))],e=Math.min.apply(Math,t),i=Math.max.apply(Math,t);Z([e,i])}}),[null==E?void 0:E.at(0),null==E?void 0:E.at(1)]),o((function(){if(q){var t=J.width/(C-M)*(rt-M),e=J.width/(C-M)*(C-at);V.current.updateSize({width:D?e:t,height:J.height}),k.current.updateSize({width:D?t:e,height:J.height})}else if(G){var i=J.height/(C-M)*(rt-M),n=J.height/(C-M)*(C-at);V.current.updateSize({width:J.width,height:D?n:i}),k.current.updateSize({width:J.width,height:D?i:n})}}),[M,C,rt,at,J.width,J.height,R]),o((function(){var t=function(){document.removeEventListener("mousemove",vt),document.removeEventListener("mouseup",gt),document.removeEventListener("touchmove",bt),document.removeEventListener("touchend",wt)};return it?(document.addEventListener("mousemove",vt),document.addEventListener("mouseup",gt),document.addEventListener("touchmove",bt),document.addEventListener("touchend",wt)):(t(),B()),function(){t()}}),[it]);var mt=s((function(t,e,i){$.current="onResize Event";var n=i.clientWidth,o=i.clientHeight,r=rt,a=at;"right"===e?D?a=I(C-n/J.width*(C-M)):r=I(M+n/J.width*(C-M)):"left"===e?D?r=I(M+n/J.width*(C-M)):a=I(C-n/J.width*(C-M)):"bottom"===e?D?a=I(C-o/J.height*(C-M)):r=I(M+o/J.height*(C-M)):"top"===e&&(D?r=I(M+o/J.height*(C-M)):a=I(C-o/J.height*(C-M))),r=Math.min(r,at),a=Math.max(a,rt),Z([r,a]),A([r,a])})),ut=s((function(){$.current=null,B()})),ft=function(t,e){$.current={xPos:t,yPos:e,head:rt,tail:at}},pt=function(t,e){if($.current){var i;q?i=($.current.xPos-t)/J.width*(C-M):G&&(i=($.current.yPos-e)/J.height*(C-M));var n,o,r=$.current.head-i*(D?-1:1),a=$.current.tail-i*(D?-1:1),l=$.current.tail-$.current.head;r<=M?(n=M,o=M+l):a>=C?(n=C-l,o=C):(n=r,o=a),n=I(n),o=I(o),Z([n,o]),A([n,o])}},vt=s((function(t){pt(t.clientX,t.clientY)})),gt=s((function(){$.current=null,nt(!1)})),bt=s((function(t){pt(t.touches[0].pageX,t.touches[0].pageY)})),wt=s((function(){$.current=null,nt(!1)})),yt=s((function(t){Z([t,at]),A([t,at]),B()})),Ot=s((function(t){Z([rt,t]),A([rt,t]),B()})),Ht=r((function(){return(at-rt)/(C-M)*(G?J.height:J.width)<30}),[M,C,rt,at]),jt=r((function(){return(at-rt)/(C-M)*(G?J.height:J.width)<b}),[M,C,rt,at]),zt=function(t,e){return t/e*(G?J.height:J.width)},xt=r((function(){if(X)return{};var t=q?O:H;return D?{isRightArrowInvisible:zt(rt,C)<w,isLeftArrowInvisible:zt(C-at,C)<w,distance:(at-rt)/(C-M)*(G?J.height:J.width)-t}:{isRightArrowInvisible:zt(C-at,C)<w,isLeftArrowInvisible:zt(rt,C)<w,distance:(at-rt)/(C-M)*(G?J.height:J.width)-t}}),[M,C,rt,at,D]),Pt=function(t){var e={min:M,max:at,value:rt,onChange:yt},i={min:rt,max:C,value:at,onChange:Ot};return"head"===t?j(c,P({"data-testid":"".concat(S,"_handle_top"),placement:"head",readOnly:!W,isInsideArrowsVisible:jt,arrowsOutsideConfig:xt,displayFormatter:N,orientation:R,classes:_,minimal:X},D?i:e)):"tail"===t?j(c,P({"data-testid":"".concat(S,"_handle_bottom"),placement:"tail",readOnly:!W,isInsideArrowsVisible:jt,arrowsOutsideConfig:xt,displayFormatter:N,orientation:R,classes:_,minimal:X},D?e:i)):null};return j("div",{className:d(T.rootWrapper,T["".concat(R,"-").concat(Y)],e({},T.rootMinimal,X)),children:z("div",{className:d(T.root,(h={},e(h,T.horizontalRoot,q),e(h,T.verticalRoot,G),e(h,T.minimal,X),h)),children:[j(a,{className:T.resizable,ref:V,minHeight:0,minWidth:0,maxWidth:D?ht:dt,maxHeight:D?ct:st,enable:{right:q,bottom:G},handleComponent:{right:Pt("head"),bottom:Pt("head")},onResize:mt,onResizeStop:ut}),j("div",{className:T.body,"data-testid":"slider-body",onMouseDown:function(t){ft(t.clientX,t.clientY),nt(!0)},onTouchStart:function(t){ft(t.touches[0].pageX,t.touches[0].pageY),nt(!0)},children:j("div",Ht?{className:d((x={},e(x,T.horizontalBodyHandle,q),e(x,T.verticalBodyHandle,G),e(x,T.leftBodyHandle,"left"===F),e(x,T.rightBodyHandle,"right"===F),e(x,T.topBodyHandle,"top"===F),e(x,T.bottomBodyHandle,"bottom"===F),x)),children:j("div",{className:T.bodyHandle,"data-testid":"".concat(S,"_handle"),children:j(m,{orientation:"vertical",minimal:X})})}:{className:T.bodyHandleIcon,"data-testid":"".concat(S,"_handle"),children:j(m,{orientation:R,minimal:X})})}),j(a,{className:T.resizable,ref:k,minHeight:0,minWidth:0,enable:{left:q,top:G},handleComponent:{left:Pt("tail"),top:Pt("tail")},onResize:mt,onResizeStop:ut})]})})};M.defaultProps={orientation:p,valueFormatter:Math.floor,displayFormatter:function(t){return t},onChange:h,onStop:h,reversed:!1,editableHandles:!0,handleClasses:{},minimal:!1,dimension:"small"};var C=l({monitorWidth:!0,monitorHeight:!0})(M);export{M as AdvancedSlider,C as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.87.0-11",
3
+ "version": "0.87.0-12",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"