orbital-list
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -384,3 +384,4 @@ 'use strict'; | ||
transform: 'translate(-50%, -50%)', | ||
borderRadius: '50%' | ||
borderRadius: '50%', | ||
cursor: 'move' | ||
}, | ||
@@ -387,0 +388,0 @@ ref: ref |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,r,n){t.useEffect((function(){var t=n?n.current:window;if(t){if(!t.addEventListener)throw new Error("event listener not supported");return t.addEventListener(e,r),function(){t.removeEventListener(e,r)}}console.warn("ref current not set!")}),[e,n,r])}var o=t.createContext(null),i=function(e){var n,i=e.children,s=t.useRef(),u=t.useState({width:0,height:0,squareSize:0}),l=u[0],c=u[1],d=t.useCallback((function(){if(s.current){var e=s.current.offsetWidth,t=s.current.offsetHeight,r=Math.min(e,t);c({width:e,height:t,squareSize:r})}}),[s,c]);a("resize",d),n=d,"undefined"!=typeof window&&t.useLayoutEffect(n,[n]);var f=l.squareSize;return r.createElement("div",{style:{width:"100%",height:"100%"},ref:s},r.createElement("div",{style:{width:l.squareSize+"px",height:l.squareSize+"px",margin:"auto",position:"relative",overflow:"hidden"}},r.createElement("div",{style:{width:"100%",height:"100%",overflow:"visible",transform:"translate(50%, 50%)"}},r.createElement(o.Provider,{value:{radius:f/2,centerX:f/2,centerY:f/2}},i))))},s=function(e){var a=e.angle,i=e.children,s=e.distance,u=e.style,l=e.className,c=e.onHover,d=e.onClick,f=t.useContext(o);if(!f)throw new Error("invalid context");var h=a*(Math.PI/180),p=(s||0)*f.radius,v=p*Math.cos(h),x=p*Math.sin(h),g=l?{className:l}:{},m=t.useCallback((function(){c&&c(!0)}),[c]),w=t.useCallback((function(){c&&c(!1)}),[c]);return r.createElement("div",Object.assign({},g,{onMouseEnter:m,onMouseLeave:w,style:n({},u,{position:"absolute",left:v,top:x,transform:"translate(-50%, -50%)"}),onClick:d}),i)},u=function(e){var a=e.angle,i=e.children,u=e.distance,l=e.radius,c=e.color,d=e.className,f=e.onHover,h=e.onClick,p=t.useContext(o);if(!p)throw new Error("invalid context");var v=p.radius*l*2+"px",x=n({width:v,height:v,borderRadius:"50%"},c?{backgroundColor:c}:{},e.style);return r.createElement(s,Object.assign({},d?{className:d}:{},{angle:a,distance:u||0,style:x,onHover:f,onClick:h}),i)},l=function(e,t,r){var n=t.getBoundingClientRect(),a=e.changedTouches?e.changedTouches[0]:e;return{x:a.clientX-n.left-r,y:a.clientY-n.top-r}};exports.Dial=function(e){var t=e.style,a=e.className,o=e.color,i=e.radius,s=n({},t?{style:t}:{},a?{className:a}:{},o?{color:o}:{});return r.createElement(u,Object.assign({distance:0,angle:0,radius:i||1},s))},exports.DragRegion=function(e){var i=e.onDrag,s=t.useContext(o),u=t.useRef(null);if(!s)throw new Error("invalid context");var c=t.useCallback((function(e){return i(e),e}),[i]),d=t.useState({start:null,current:null,last:null}),f=d[0],h=d[1],p=t.useCallback((function(e){e.preventDefault();var t=l(e,u.current,s.radius);h(c({start:t,current:t,last:null}))}),[h,s.radius,c]),v=t.useCallback((function(e){null!==f.start&&(e.preventDefault(),h((function(t){return c(n({},t,{current:l(e,u.current,s.radius)}))})))}),[h,f,s.radius,c]),x=t.useCallback((function(e){null!==f.start&&null!==f.current&&(e.preventDefault(),h((function(t){return c(n({},t,{start:null,current:null,last:l(e,u.current,s.radius)}))})))}),[f,h,s.radius,c]);if(a("mousedown",p,u),a("mouseup",x),a("mousemove",v),a("touchstart",p,u),a("touchend",x),a("touchmove",v),!s)throw new Error("invalid context");return r.createElement("div",{style:{width:"100%",height:"100%",position:"absolute",left:0,top:0,transform:"translate(-50%, -50%)",borderRadius:"50%"},ref:u})},exports.Hand=function(e){var a=t.useContext(o);if(!a)throw new Error("invalid context");var i=e.children,s=e.color,u=a.radius,l=1,c=0;if(void 0!==e.start||void 0!==e.end){var d=e.start||0;l=u*((e.end||1)-d),c=u*d}else l=u*(e.length||1),c=0;var f=n({},s?{backgroundColor:s}:{},e.style,{position:"absolute",transform:"rotate("+e.angle+"deg) translate("+c+"px, 0)",transformOrigin:"center left",left:0,top:0,width:l,height:e.width||1});return r.createElement("div",{className:(e.className||"")+" Hand",style:n({},f)},i)},exports.Label=function(e){var t=e.distance,a=e.angle,o=e.children,i=e.color,u=n({},e.style,i?{color:i}:{});return r.createElement(s,{angle:a,distance:t||1,className:"Label",style:u},o)},exports.Orbit=function(e){return r.createElement(u,{angle:0,distance:0,radius:e.radius||1,className:"Orbit",style:n({border:(e.width||1)+"px solid "+e.color},e.style)})},exports.OrbitalList=function(e){return r.createElement(i,null,e.children)},exports.Place=s,exports.Planet=u,exports.Slice=function(e){var a=t.useContext(o);if(!a)throw new Error("invalid context");var i=e.children,s=e.color,u=e.angleStart%360,l=e.angleEnd%360-u,c=l*(Math.PI/180),d=(e.length||1)*a.radius,f=2*d,h=f/2+"px",p=f+"px",v=f+"px",x=function(e,t){return e+" "+t},g=[x(h,h),x(p,h),x(p,v)];l>90&&g.push(x("0px",v)),l>180&&g.push(x("0px","0px")),l>270&&g.push(x(p,"0px"));var m=d+d*Math.cos(c),w=d+d*Math.sin(c);g.push(x(m+"px",w+"px"));var b="polygon("+g.join(",")+")",y=n({},s?{backgroundColor:s}:{},e.style,{position:"absolute",transform:"translate(-"+d+"px, -"+d+"px) rotate("+u+"deg)",clipPath:b,WebkitClipPath:b,left:0,top:0,width:f+"px",height:f+"px",borderRadius:"50%"});return r.createElement("div",{className:(e.className||"")+" Slice",style:n({},y)},i)},exports.lpad=function(e,t){return void 0===t&&(t=2),(""+e).padStart(t,"0")},exports.range=function(e,t){return void 0===t&&(t=0),Array.from(Array(e).keys()).map((function(e){return e+t}))},exports.toDeg=function(e){return e*(180/Math.PI)},exports.toRadians=function(e){return e*(Math.PI/180)},exports.uniq=function(e){var t=new Set(e),r=[];return t.forEach((function(e){return r.push(e)})),r},exports.useDatetime=function(){var e=t.useRef(),r=t.useState(new Date),n=r[0],a=r[1],o=t.useCallback((function(){return setInterval((function(){a(new Date)}),1e3)}),[]);return t.useEffect((function(){return e.current||(e.current=o()),function(){return clearInterval(e.current)}}),[o]),t.useLayoutEffect((function(){a(new Date)}),[]),n},exports.useEventListener=a; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,r,n){t.useEffect((function(){var t=n?n.current:window;if(t){if(!t.addEventListener)throw new Error("event listener not supported");return t.addEventListener(e,r),function(){t.removeEventListener(e,r)}}console.warn("ref current not set!")}),[e,n,r])}var o=t.createContext(null),i=function(e){var n,i=e.children,s=t.useRef(),u=t.useState({width:0,height:0,squareSize:0}),l=u[0],c=u[1],d=t.useCallback((function(){if(s.current){var e=s.current.offsetWidth,t=s.current.offsetHeight,r=Math.min(e,t);c({width:e,height:t,squareSize:r})}}),[s,c]);a("resize",d),n=d,"undefined"!=typeof window&&t.useLayoutEffect(n,[n]);var f=l.squareSize;return r.createElement("div",{style:{width:"100%",height:"100%"},ref:s},r.createElement("div",{style:{width:l.squareSize+"px",height:l.squareSize+"px",margin:"auto",position:"relative",overflow:"hidden"}},r.createElement("div",{style:{width:"100%",height:"100%",overflow:"visible",transform:"translate(50%, 50%)"}},r.createElement(o.Provider,{value:{radius:f/2,centerX:f/2,centerY:f/2}},i))))},s=function(e){var a=e.angle,i=e.children,s=e.distance,u=e.style,l=e.className,c=e.onHover,d=e.onClick,f=t.useContext(o);if(!f)throw new Error("invalid context");var h=a*(Math.PI/180),v=(s||0)*f.radius,p=v*Math.cos(h),x=v*Math.sin(h),g=l?{className:l}:{},m=t.useCallback((function(){c&&c(!0)}),[c]),w=t.useCallback((function(){c&&c(!1)}),[c]);return r.createElement("div",Object.assign({},g,{onMouseEnter:m,onMouseLeave:w,style:n({},u,{position:"absolute",left:p,top:x,transform:"translate(-50%, -50%)"}),onClick:d}),i)},u=function(e){var a=e.angle,i=e.children,u=e.distance,l=e.radius,c=e.color,d=e.className,f=e.onHover,h=e.onClick,v=t.useContext(o);if(!v)throw new Error("invalid context");var p=v.radius*l*2+"px",x=n({width:p,height:p,borderRadius:"50%"},c?{backgroundColor:c}:{},e.style);return r.createElement(s,Object.assign({},d?{className:d}:{},{angle:a,distance:u||0,style:x,onHover:f,onClick:h}),i)},l=function(e,t,r){var n=t.getBoundingClientRect(),a=e.changedTouches?e.changedTouches[0]:e;return{x:a.clientX-n.left-r,y:a.clientY-n.top-r}};exports.Dial=function(e){var t=e.style,a=e.className,o=e.color,i=e.radius,s=n({},t?{style:t}:{},a?{className:a}:{},o?{color:o}:{});return r.createElement(u,Object.assign({distance:0,angle:0,radius:i||1},s))},exports.DragRegion=function(e){var i=e.onDrag,s=t.useContext(o),u=t.useRef(null);if(!s)throw new Error("invalid context");var c=t.useCallback((function(e){return i(e),e}),[i]),d=t.useState({start:null,current:null,last:null}),f=d[0],h=d[1],v=t.useCallback((function(e){e.preventDefault();var t=l(e,u.current,s.radius);h(c({start:t,current:t,last:null}))}),[h,s.radius,c]),p=t.useCallback((function(e){null!==f.start&&(e.preventDefault(),h((function(t){return c(n({},t,{current:l(e,u.current,s.radius)}))})))}),[h,f,s.radius,c]),x=t.useCallback((function(e){null!==f.start&&null!==f.current&&(e.preventDefault(),h((function(t){return c(n({},t,{start:null,current:null,last:l(e,u.current,s.radius)}))})))}),[f,h,s.radius,c]);if(a("mousedown",v,u),a("mouseup",x),a("mousemove",p),a("touchstart",v,u),a("touchend",x),a("touchmove",p),!s)throw new Error("invalid context");return r.createElement("div",{style:{width:"100%",height:"100%",position:"absolute",left:0,top:0,transform:"translate(-50%, -50%)",borderRadius:"50%",cursor:"move"},ref:u})},exports.Hand=function(e){var a=t.useContext(o);if(!a)throw new Error("invalid context");var i=e.children,s=e.color,u=a.radius,l=1,c=0;if(void 0!==e.start||void 0!==e.end){var d=e.start||0;l=u*((e.end||1)-d),c=u*d}else l=u*(e.length||1),c=0;var f=n({},s?{backgroundColor:s}:{},e.style,{position:"absolute",transform:"rotate("+e.angle+"deg) translate("+c+"px, 0)",transformOrigin:"center left",left:0,top:0,width:l,height:e.width||1});return r.createElement("div",{className:(e.className||"")+" Hand",style:n({},f)},i)},exports.Label=function(e){var t=e.distance,a=e.angle,o=e.children,i=e.color,u=n({},e.style,i?{color:i}:{});return r.createElement(s,{angle:a,distance:t||1,className:"Label",style:u},o)},exports.Orbit=function(e){return r.createElement(u,{angle:0,distance:0,radius:e.radius||1,className:"Orbit",style:n({border:(e.width||1)+"px solid "+e.color},e.style)})},exports.OrbitalList=function(e){return r.createElement(i,null,e.children)},exports.Place=s,exports.Planet=u,exports.Slice=function(e){var a=t.useContext(o);if(!a)throw new Error("invalid context");var i=e.children,s=e.color,u=e.angleStart%360,l=e.angleEnd%360-u,c=l*(Math.PI/180),d=(e.length||1)*a.radius,f=2*d,h=f/2+"px",v=f+"px",p=f+"px",x=function(e,t){return e+" "+t},g=[x(h,h),x(v,h),x(v,p)];l>90&&g.push(x("0px",p)),l>180&&g.push(x("0px","0px")),l>270&&g.push(x(v,"0px"));var m=d+d*Math.cos(c),w=d+d*Math.sin(c);g.push(x(m+"px",w+"px"));var b="polygon("+g.join(",")+")",y=n({},s?{backgroundColor:s}:{},e.style,{position:"absolute",transform:"translate(-"+d+"px, -"+d+"px) rotate("+u+"deg)",clipPath:b,WebkitClipPath:b,left:0,top:0,width:f+"px",height:f+"px",borderRadius:"50%"});return r.createElement("div",{className:(e.className||"")+" Slice",style:n({},y)},i)},exports.lpad=function(e,t){return void 0===t&&(t=2),(""+e).padStart(t,"0")},exports.range=function(e,t){return void 0===t&&(t=0),Array.from(Array(e).keys()).map((function(e){return e+t}))},exports.toDeg=function(e){return e*(180/Math.PI)},exports.toRadians=function(e){return e*(Math.PI/180)},exports.uniq=function(e){var t=new Set(e),r=[];return t.forEach((function(e){return r.push(e)})),r},exports.useDatetime=function(){var e=t.useRef(),r=t.useState(new Date),n=r[0],a=r[1],o=t.useCallback((function(){return setInterval((function(){a(new Date)}),1e3)}),[]);return t.useEffect((function(){return e.current||(e.current=o()),function(){return clearInterval(e.current)}}),[o]),t.useLayoutEffect((function(){a(new Date)}),[]),n},exports.useEventListener=a; | ||
//# sourceMappingURL=orbital-list.cjs.production.min.js.map |
@@ -377,3 +377,4 @@ import React, { useRef, useState, useCallback, useEffect, useLayoutEffect, createContext, useContext } from 'react'; | ||
transform: 'translate(-50%, -50%)', | ||
borderRadius: '50%' | ||
borderRadius: '50%', | ||
cursor: 'move' | ||
}, | ||
@@ -380,0 +381,0 @@ ref: ref |
{ | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
152087
1854
0