@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.chore-public-names.673.cb7ee37
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.
- package/README.md +255 -122
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +7 -3
- package/dist/3d.js +20 -20
- package/dist/CurrentPoseBar/index.cjs +1 -0
- package/dist/CurrentPoseBar/index.d.ts +2 -0
- package/dist/CurrentPoseBar/index.js +5 -0
- package/dist/JoggingButtons/index.cjs +1 -0
- package/dist/JoggingButtons/index.d.ts +3 -0
- package/dist/JoggingButtons/index.js +5 -0
- package/dist/JoggingGizmo/index.cjs +1 -0
- package/dist/JoggingGizmo/index.d.ts +5 -0
- package/dist/JoggingGizmo/index.js +6 -0
- package/dist/JoggingJointSlider/index.cjs +1 -0
- package/dist/JoggingJointSlider/index.d.ts +2 -0
- package/dist/JoggingJointSlider/index.js +5 -0
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/ConnectedMotionGroup-D9JJSyXB.js +1822 -0
- package/dist/chunks/ConnectedMotionGroup-ir7Vf690.cjs +3 -0
- package/dist/chunks/CurrentPoseBar-Cbz4AO36.cjs +1 -0
- package/dist/chunks/CurrentPoseBar-CpwvWpEY.js +619 -0
- package/dist/chunks/JoggingButtons-i8FdMpCx.js +108 -0
- package/dist/chunks/JoggingButtons-paQCBXf4.cjs +1 -0
- package/dist/chunks/JoggingGizmoOrientation-CKZeLcMp.js +893 -0
- package/dist/chunks/JoggingGizmoOrientation-EPtBeAun.cjs +1 -0
- package/dist/chunks/JoggingJointSlider-DQhJOmcc.js +378 -0
- package/dist/chunks/JoggingJointSlider-YcEBMgF1.cjs +1 -0
- package/dist/chunks/Pose3-Ci1bxEvz.js +1373 -0
- package/dist/chunks/Pose3-DwMOSTKO.cjs +1 -0
- package/dist/chunks/SafetyBar-Be1c6Vz9.cjs +1 -0
- package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-WXLP3Yi0.js} +34 -32
- package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-7OVHUIUh.js} +84 -134
- package/dist/chunks/externalizeComponent-B0n_tR3v.cjs +2 -0
- package/dist/chunks/holdSafety-Cbej6-Kc.js +62 -0
- package/dist/chunks/holdSafety-TeMXlYQe.cjs +1 -0
- package/dist/chunks/joggingColors-BKRoSGQu.js +132 -0
- package/dist/chunks/joggingColors-BkPm75Hr.cjs +1 -0
- package/dist/chunks/json-3cqBD7UQ.js +18 -0
- package/dist/chunks/json-Bd6uGfgP.cjs +1 -0
- package/dist/chunks/loadRobotSession-Bt1-Brjp.js +3761 -0
- package/dist/chunks/loadRobotSession-DHVuK_pj.cjs +1 -0
- package/dist/chunks/novaConnection-BTSIgWd1.cjs +1 -0
- package/dist/chunks/novaConnection-J6_ohIQ0.js +14 -0
- package/dist/chunks/poseText-BXUaQWnK.cjs +1 -0
- package/dist/chunks/poseText-CtdXIeT_.js +41 -0
- package/dist/chunks/useSmoothedMotionState-C_Vo0py0.js +202 -0
- package/dist/chunks/useSmoothedMotionState-Ce9NjwBu.cjs +1 -0
- package/dist/components/AppHeader.d.ts +1 -1
- package/dist/components/VelocitySlider.d.ts +6 -1
- package/dist/components/currentPoseBar/CurrentPoseBar.d.ts +48 -0
- package/dist/components/currentPoseBar/OrientationFormatPopover.d.ts +19 -0
- package/dist/components/currentPoseBar/StreamStatus.d.ts +10 -0
- package/dist/components/currentPoseBar/orientation.d.ts +34 -0
- package/dist/components/currentPoseBar/poseValues.d.ts +15 -0
- package/dist/components/jogging/JoggingButtons.d.ts +18 -0
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +8 -2
- package/dist/components/jogging/JoggingCartesianTab.d.ts +3 -0
- package/dist/components/jogging/JoggingJointTab.d.ts +4 -1
- package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
- package/dist/components/jogging/JoggingPanel.d.ts +6 -3
- package/dist/components/jogging/JoggingRefusedError.d.ts +24 -0
- package/dist/components/jogging/JoggingStore.d.ts +382 -40
- package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +53 -0
- package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +26 -0
- package/dist/components/jogging/gizmo/RotationHandles.d.ts +7 -0
- package/dist/components/jogging/gizmo/RotationScene.d.ts +6 -0
- package/dist/components/jogging/gizmo/TranslationHandles.d.ts +6 -0
- package/dist/components/jogging/gizmo/TranslationScene.d.ts +6 -0
- package/dist/components/jogging/gizmo/arcGrabAreas.d.ts +58 -0
- package/dist/components/jogging/gizmo/arcs.d.ts +54 -0
- package/dist/components/jogging/gizmo/arrows.d.ts +63 -0
- package/dist/components/jogging/gizmo/gizmoShared.d.ts +135 -0
- package/dist/components/jogging/gizmo/gizmoView.d.ts +42 -0
- package/dist/components/jogging/gizmo/useGizmoTurn.d.ts +11 -0
- package/dist/components/jogging/holdSafety.d.ts +82 -0
- package/dist/components/jogging/jogError.d.ts +9 -0
- package/dist/components/jogging/jogHandle.d.ts +23 -0
- package/dist/components/jogging/joggingColors.d.ts +30 -0
- package/dist/components/jogging/joggingVelocity.d.ts +21 -0
- package/dist/components/jogging/joint/JoggingJointSlider.d.ts +56 -0
- package/dist/components/jogging/joint/JointSliderTrack.d.ts +27 -0
- package/dist/components/jogging/joint/jointJog.d.ts +55 -0
- package/dist/components/jogging/joint/useJointJogHold.d.ts +43 -0
- package/dist/components/jogging/useHold.d.ts +42 -0
- package/dist/components/jogging/useJogControls.d.ts +44 -0
- package/dist/components/robotControl/PanelSelect.d.ts +13 -0
- package/dist/components/robotControl/SmallSelect.d.ts +15 -0
- package/dist/components/robotControl/poseText.d.ts +43 -0
- package/dist/components/robotControl/robotControlTypes.d.ts +36 -0
- package/dist/components/robotControl/useCopyText.d.ts +12 -0
- package/dist/components/robotControl/useEveryFrame.d.ts +6 -0
- package/dist/components/robots/GenericRobot.d.ts +2 -1
- package/dist/components/robots/LinearAxis.d.ts +1 -1
- package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
- package/dist/components/robots/Robot.d.ts +1 -1
- package/dist/components/robots/robotModelLogic.d.ts +11 -9
- package/dist/components/utils/converters.d.ts +0 -2
- package/dist/components/utils/hooks.d.ts +1 -6
- package/dist/components/utils/json.d.ts +4 -0
- package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
- package/dist/components/utils/useWebGLRenderer.d.ts +32 -0
- package/dist/components/utils/webglSupport.d.ts +11 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +28 -20
- package/dist/core.js +57 -54
- package/dist/index.cjs +1 -1
- package/dist/index.js +73 -70
- package/dist/lib/ConnectedMotionGroup.d.ts +9 -8
- package/dist/lib/ControllerStateStream.d.ts +125 -0
- package/dist/lib/JoggerConnection.d.ts +172 -27
- package/dist/lib/MotionStreamConnection.d.ts +16 -6
- package/dist/lib/Pose3.d.ts +22 -0
- package/dist/lib/PoseTransformer.d.ts +44 -0
- package/dist/lib/TrajectoryExecutionStore.d.ts +260 -0
- package/dist/lib/connectionLogger.d.ts +9 -0
- package/dist/lib/controllerStateSource.d.ts +38 -0
- package/dist/lib/incrementalCartesianMotion.d.ts +40 -0
- package/dist/lib/motionGroupModelResources.d.ts +1 -0
- package/dist/lib/motionStateUpdate.d.ts +44 -0
- package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
- package/dist/lib/novaConnection.d.ts +23 -0
- package/dist/lib/planErrorTranslation.d.ts +8 -0
- package/dist/lib/poseMath.d.ts +51 -0
- package/dist/lib/robotSession/RobotActivation.d.ts +90 -0
- package/dist/lib/robotSession/RobotDescription.d.ts +84 -0
- package/dist/lib/robotSession/RobotLiveState.d.ts +65 -0
- package/dist/lib/robotSession/RobotLoadProgress.d.ts +72 -0
- package/dist/lib/robotSession/RobotSafety.d.ts +59 -0
- package/dist/lib/robotSession/RobotSession.d.ts +117 -0
- package/dist/lib/robotSession/RobotTargetPose.d.ts +116 -0
- package/dist/lib/robotSession/loadRobotResources.d.ts +46 -0
- package/dist/lib/robotSession/loadRobotSession.d.ts +81 -0
- package/dist/lib/robotSession/robotPose.d.ts +27 -0
- package/dist/lib/rotation.d.ts +12 -0
- package/dist/nats.cjs +1 -0
- package/dist/nats.d.ts +4 -0
- package/dist/nats.js +131 -0
- package/dist/session.cjs +1 -0
- package/dist/session.d.ts +22 -0
- package/dist/session.js +33 -0
- package/package.json +68 -66
- package/dist/Setup.d.ts +0 -11
- package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
- package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
- package/dist/chunks/SafetyBar-DPrv_OQA.cjs +0 -1
- package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
- package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
- package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
- package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
- package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
- package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
- package/dist/components/AdornedTextField.d.ts +0 -7
- package/dist/components/CopyableText.d.ts +0 -6
- package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
- package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
- package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
- package/dist/components/CycleTimer/index.d.ts +0 -27
- package/dist/components/CycleTimer/types.d.ts +0 -49
- package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
- package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
- package/dist/components/CycleTimer/utils.d.ts +0 -21
- package/dist/components/CycleTimer.d.ts +0 -3
- package/dist/components/DataGrid.d.ts +0 -66
- package/dist/components/LogPanel.d.ts +0 -38
- package/dist/components/LogStore.d.ts +0 -12
- package/dist/components/LogViewer.d.ts +0 -46
- package/dist/components/ProgramControl.d.ts +0 -55
- package/dist/components/ProgramStateIndicator.d.ts +0 -26
- package/dist/components/RobotCard.d.ts +0 -98
- package/dist/components/RobotListItem.d.ts +0 -34
- package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
- package/dist/components/SelectableFab.d.ts +0 -7
- package/dist/components/TabBar.d.ts +0 -45
- package/dist/components/ThemeSelect.d.ts +0 -6
- package/dist/components/Timer/Timer.d.ts +0 -3
- package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
- package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
- package/dist/components/Timer/index.d.ts +0 -19
- package/dist/components/Timer/types.d.ts +0 -35
- package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
- package/dist/components/Timer/useTimerLogic.d.ts +0 -19
- package/dist/components/Timer/utils.d.ts +0 -17
- package/dist/components/Timer.d.ts +0 -3
- package/dist/components/TransparentOverlay.d.ts +0 -4
- package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
- package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
- package/dist/components/jogging/PoseJointValues.d.ts +0 -8
- package/dist/components/robots/AxisConfig.d.ts +0 -2
- package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
- package/dist/icons/DropdownArrowIcon.d.ts +0 -2
- package/dist/icons/index.d.ts +0 -12
- package/dist/lib/novaCompat.d.ts +0 -16
- package/dist/themes/createDarkTheme.d.ts +0 -7
- package/dist/themes/themeTypes.d.ts +0 -40
- package/dist/themes/theming.d.ts +0 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=require("react/jsx-runtime"),v=require("@mui/material/Box"),pe=require("@mui/material/Typography"),V=require("@react-three/fiber"),E=require("react"),de=require("react-i18next"),m=require("three"),fe=require("./externalizeComponent-B0n_tR3v.cjs"),M=require("./joggingColors-BkPm75Hr.cjs"),$=require("@mui/material/styles");function ge(){try{const e=document.createElement("canvas");return(e.getContext("webgl2")||e.getContext("webgl")||e.getContext("experimental-webgl"))!=null}catch{return!1}}function xe({antialias:e=!0,onContextLost:t,onWebGLUnavailable:n}={}){const i=E.useMemo(()=>ge(),[]),[s,r]=E.useState(!1),a=i?s?"renderer":null:"preflight",u=E.useRef({onContextLost:t,onWebGLUnavailable:n});u.current={onContextLost:t,onWebGLUnavailable:n},E.useEffect(()=>{var d,c;a&&((c=(d=u.current).onWebGLUnavailable)==null||c.call(d,a))},[a]);const o=E.useRef(!0);E.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]);const l=E.useCallback(d=>{let c;try{c=new m.WebGLRenderer({...d,antialias:e,alpha:!0})}catch(h){throw console.warn("Failed to create WebGL renderer",h),r(!0),h}return c.domElement.addEventListener("webglcontextlost",h=>{var x,p;h.preventDefault(),o.current&&((p=(x=u.current).onContextLost)==null||p.call(x))}),c},[e]);return{unavailable:a,makeRenderer:l}}const ee=new m.Vector3(0,1,0),G=.26,te=.1,me={x:"X",y:"Y",z:"Z"};function C(e){var t;return((t=M.cartesianAxisColors[me[e]].buttonBackgroundColor)==null?void 0:t.default)??"currentColor"}const ye=200;function N(e){const t=e/ye;return{marginPx:30*t,gripPx:30*t,grab:{innerPx:10*t,beyondTipPx:10*t,minTipPx:16*t},labelFontPx:Math.max(10,13*t)}}function be(e,t,n){return Math.max(1,Math.min(e,t)/2-n)}function Ee(e,t){const{gripPx:n,grab:i}=N(e);return{radiusPx:t,gripPx:n,headLength:G,...i}}function we(e,t){const{gripPx:n,grab:i}=N(e);return{radiusPx:t,gripPx:n,beyondTipPx:i.beyondTipPx,headLength:G}}function I(e,t){return n=>{n?e.current.set(t,n):e.current.delete(t)}}const R=e=>`${e.axis}${e.direction}`,ne=e=>`label:${e}`,q=[0,1],D=(e,t)=>`half:${R(e)}:${t}`,oe=e=>`halo:${R(e)}`,re=e=>`focus:${R(e)}`,J="polygon(0 0, 0 0, 0 0)";function se(e,{isPressed:t,hovered:n,disabled:i}){const s=t(e),r=!i&&(s||M.isSameJogHandle(n,e));return{pressed:s,lit:r}}function ae(e,{pressed:t,lit:n}){return t?$.alpha(e,.25):n?$.alpha(e,.12):"transparent"}function Ae(e,t){return[R(e),...q.map(i=>D(e,i))].flatMap(i=>t.current.get(i)??[])}function ce(e,{onHover:t,handlersFor:n,overlay:i}){const s=n(e,r=>Ae(e,i).some(a=>a.contains(r)));return{...s,onPointerEnter:()=>t(e),onPointerLeave:r=>{t(null),s.onPointerLeave(r)}}}const z=e=>({cursor:e?"default":"pointer",touchAction:"none",userSelect:"none"}),ie=e=>`2px solid ${e.palette.primary.main}`,L={x:new m.Vector3(1,0,0),y:new m.Vector3(0,1,0),z:new m.Vector3(0,0,1)};function Me(e,t,n=new m.Quaternion){return n.copy(e).invert().multiply(t)}const Se=new m.Quaternion().setFromRotationMatrix(new m.Matrix4().makeBasis(new m.Vector3(1,0,0),new m.Vector3(0,0,-1),new m.Vector3(0,1,0))),Q=new m.Quaternion,je=new m.Quaternion;function Re(e){return e.up.z>.5?je:Se}function Oe(e,t=new m.Quaternion){return e.getWorldQuaternion(Q),Me(Q,Re(e),t)}function ve(e,t,n=new m.Quaternion){return n.copy(e).multiply(t)}const _e=1e-8;function B(e,t){return e?Math.abs(e.dot(t))<1-_e:!0}function Te(e){const{disabled:t,label:n,overlay:i,size:s}=e,r=$.useTheme(),{gripPx:a}=N(s);return M.JOG_AXES.flatMap(u=>M.JOG_DIRECTIONS.map(o=>{const l={axis:u,direction:o},d=se(l,e),c=ce(l,e);return f.jsxs(E.Fragment,{children:[f.jsx(v,{component:"span","aria-hidden":!0,ref:I(i,oe(l)),sx:{position:"absolute",inset:0,clipPath:J,pointerEvents:"none",background:ae(C(u),d)}}),q.map(h=>f.jsx(v,{component:"span","aria-hidden":!0,ref:I(i,D(l,h)),...c,sx:{position:"absolute",inset:0,clipPath:J,...z(t)}},h)),f.jsx(v,{component:"button",type:"button",ref:I(i,R(l)),disabled:t,"aria-label":n(l),"aria-pressed":d.pressed,...c,sx:{position:"absolute",width:a,height:a,transform:"translate(-50%, -50%)",padding:0,border:"none",borderRadius:"50%",background:"transparent","&:focus-visible":{outline:ie(r)},"&[data-band='shown']:focus-visible":{outline:"none"},...z(t)}}),f.jsx(v,{component:"svg","aria-hidden":!0,sx:{position:"absolute",left:0,top:0,width:s,height:s,overflow:"visible",pointerEvents:"none",display:"none",zIndex:100,"button[data-band='shown']:focus-visible + &":{display:"block"}},children:f.jsx("path",{ref:I(i,re(l)),fill:"none",stroke:r.palette.primary.main,strokeWidth:2,strokeLinejoin:"round"})})]},R(l))}))}const F=.8,W=.45,le=2.25,ue={x:[new m.Vector3(0,1,0),new m.Vector3(0,0,1)],y:[new m.Vector3(-1,0,0),new m.Vector3(0,0,1)],z:[new m.Vector3(1,0,0),new m.Vector3(0,1,0)]};function H(e){const t=e==="+"?W:W+Math.PI,n=t+le;return{start:t,end:n,head:e==="+"?n:t}}const Ie=new m.Vector3,P=new m.Vector3,Ge=new m.Vector3;function Fe(e,t=24){const n=[];for(const i of M.JOG_AXES){const[s,r]=ue[i],a=o=>Ie.copy(s).multiplyScalar(Math.cos(o)*F).addScaledVector(r,Math.sin(o)*F).applyQuaternion(e),u=Math.abs(Ge.copy(L[i]).applyQuaternion(e).z);for(const o of M.JOG_DIRECTIONS){const{start:l,end:d,head:c}=H(o),h=[];for(let A=0;A<=t;A++){const j=a(l+(d-l)*A/t);h.push({x:j.x+0,y:-j.y+0,depth:j.z})}const x=a(c),p={x:x.x+0,y:-x.y+0,depth:x.z},g=o==="+"?1:-1;P.copy(s).multiplyScalar(-Math.sin(c)*g).addScaledVector(r,Math.cos(c)*g).applyQuaternion(e);const y=Math.hypot(P.x,P.y),b=y>1e-9?P.x/y:0,w=y>1e-9?-P.y/y:0;n.push({axis:i,direction:o,points:h,head:{...p,dx:b+0,dy:w+0},openness:u})}}return n}function Pe(e,t,n){let i={distance:Number.POSITIVE_INFINITY,depth:0};for(let s=1;s<e.length;s++){const r=e[s-1],a=e[s],u=(a.x-r.x)**2+(a.y-r.y)**2,o=u===0?0:Math.min(1,Math.max(0,((t-r.x)*(a.x-r.x)+(n-r.y)*(a.y-r.y))/u)),l=Math.hypot(t-(r.x+o*(a.x-r.x)),n-(r.y+o*(a.y-r.y)));l<i.distance&&(i={distance:l,depth:r.depth+o*(a.depth-r.depth)})}return i}function Ve(e,t){const n=e.length,i=e.map(()=>new Array(n).fill(!1));for(let o=0;o<n;o++)for(let l=o+1;l<n;l++){if(e[o].arc===e[l].arc)continue;let d=0;for(const c of e[o].line){const h=Pe(e[l].line,c.x,c.y);h.distance<t&&(d+=c.depth-h.depth)}d>0?i[o][l]=!0:d<0&&(i[l][o]=!0)}const s=e.map(({line:o})=>o.reduce((l,d)=>l+d.depth,0)/o.length),r=(o,l)=>s[o]-s[l],a=new Array(n).fill(0),u=new Set(e.keys());for(let o=1;u.size>0;o++){const l=[...u],d=l.filter(h=>!l.some(x=>i[h][x])),c=(d.length>0?d:l).sort(r)[0];a[c]=o,u.delete(c)}return a}const U=8;function k(e,t){const n=[...e];if(t>=0){const s=n[n.length-1],r=n[n.length-2],a=Math.hypot(s.x-r.x,s.y-r.y)||1;return n.push({x:s.x+(s.x-r.x)/a*t,y:s.y+(s.y-r.y)/a*t,depth:s.depth}),n}let i=-t;for(;n.length>2;){const s=n[n.length-1],r=n[n.length-2],a=Math.hypot(s.x-r.x,s.y-r.y);if(a>i){const u=i/a;return n[n.length-1]={x:s.x+(r.x-s.x)*u,y:s.y+(r.y-s.y)*u,depth:s.depth+(r.depth-s.depth)*u},n}i-=a,n.pop()}return n}const X=(e,t)=>k([...e].reverse(),t).reverse();function Ce(e,t){const n=t/2,i=[],s=[],r=[];let a={x:0,y:0};for(const[o,l]of e.entries()){const d=e[Math.max(0,o-1)],c=e[Math.min(e.length-1,o+1)],h=c.x-d.x,x=c.y-d.y,p=Math.hypot(h,x);p>1e-9&&(a={x:-x/p,y:h/p}),r.push(a),i.push({x:l.x+a.x*n,y:l.y+a.y*n}),s.push({x:l.x-a.x*n,y:l.y-a.y*n})}const u=(o,l)=>{const d=r[o],c={x:d.y,y:-d.x},h=l?1:-1;return Array.from({length:U-1},(x,p)=>{const g=Math.PI*(p+1)/U,y=Math.cos(g)*h,b=Math.sin(g)*h;return{x:e[o].x+(d.x*y+c.x*b)*n,y:e[o].y+(d.y*y+c.y*b)*n}})};return(o,l)=>[...i.slice(o,l+1),...l===e.length-1?u(l,!0):[],...s.slice(o,l+1).reverse(),...o===0?u(o,!1):[]]}function Ne(e,t){return[{from:0,to:Math.min(e-1,t+1)},{from:Math.max(0,t-1),to:e-1}]}function $e(e,{radiusPx:t,gripPx:n,beyondTipPx:i,headLength:s}){const r=n/2,a=s/2*t+i-r,u=i-r,o=e.map(p=>{const g=p.points.map(w=>({x:w.x*t,y:w.y*t,depth:w.depth})),y=g[g.length>>1],b=p.direction==="+"?X(k(g,a),u):k(X(g,a),u);return{line:b,middle:b.indexOf(y)}}),l=o.map(({line:p})=>p),d=e.map(p=>2*F*t*p.openness>=n),c=l.flatMap((p,g)=>d[g]?Ne(p.length,o[g].middle).map(({from:y,to:b})=>({arc:g,from:y,to:b,line:p.slice(y,b+1)})):[]),h=Ve(c,n),x=e.map((p,g)=>g).sort((p,g)=>e[p].head.depth-e[g].head.depth);return e.map((p,g)=>{if(!d[g])return null;const y=Ce(l[g],n),b=c.flatMap((w,A)=>w.arc===g?[{...w,layer:h[A]}]:[]);return{band:y(0,l[g].length-1),halves:b.map(({from:w,to:A,layer:j})=>({polygon:y(w,A),layer:j})),head:{x:p.head.x*t,y:p.head.y*t},headLayer:c.length+1+x.indexOf(g)}})}function he(e,t,n,i){const s=E.useRef(null),r=V.useThree(a=>a.invalidate);E.useEffect(()=>{s.current=null,r()},[i,r]),E.useEffect(()=>{let a=requestAnimationFrame(function u(){const o=e.current;o&&B(s.current,o)&&r(),a=requestAnimationFrame(u)});return()=>cancelAnimationFrame(a)},[e,r]),V.useFrame(()=>{const a=e.current;!a||!t.current||B(s.current,a)&&(t.current.quaternion.copy(a),n(a)&&(s.current=a.clone()))})}const K=.03;function Je({orientation:e,lit:t,disabled:n,size:i,radius:s,overlay:r}){const a=E.useRef(null),u=i/2,o=c=>`${(u+c).toFixed(2)}px`,l=c=>`polygon(${c.map(h=>`${o(h.x)} ${o(h.y)}`).join(", ")})`,d=c=>`M${c.map(h=>`${(u+h.x).toFixed(2)} ${(u+h.y).toFixed(2)}`).join("L")}Z`;return he(e,a,c=>{let h=!0;const x=Fe(c),p=$e(x,we(i,s));for(const[g,y]of x.entries()){const b=r.current.get(R(y)),w=r.current.get(oe(y)),A=r.current.get(re(y)),j=q.map(_=>r.current.get(D(y,_)));if(!b||!w||!A||j.some(_=>!_)){h=!1;continue}const S=p[g];b.style.left=o(y.head.x*s),b.style.top=o(y.head.y*s),b.style.zIndex=S?String(S.headLayer):"0",b.style.pointerEvents=S?"":"none",b.dataset.band=S?"shown":"none",w.style.clipPath=S?l(S.band):J,A.setAttribute("d",S?d(S.band):"");for(const[_,T]of j.entries()){if(!T)continue;const O=S==null?void 0:S.halves[_];T.style.clipPath=O?l(O.polygon):J,T.style.zIndex=O?String(O.layer):"0",T.style.pointerEvents=O?"":"none"}}return h},`${i}:${s}`),f.jsxs("group",{ref:a,children:[f.jsxs("mesh",{children:[f.jsx("sphereGeometry",{args:[.07,16,16]}),f.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),M.JOG_AXES.map(c=>f.jsx(Le,{axis:c,color:C(c),lit:(t==null?void 0:t.axis)===c?t.direction:null,disabled:n},c))]})}function Le({axis:e,color:t,lit:n,disabled:i}){const s=E.useMemo(()=>{const[r,a]=ue[e];return new m.Quaternion().setFromRotationMatrix(new m.Matrix4().makeBasis(r,a,L[e]))},[e]);return f.jsx("group",{quaternion:s,children:M.JOG_DIRECTIONS.map(r=>{const a=n===r,u=a?1:i?.35:.8,o=a?K*1.5:K;return f.jsxs("group",{children:[f.jsxs("mesh",{rotation:[0,0,H(r).start],children:[f.jsx("torusGeometry",{args:[F,o,12,48,le]}),f.jsx("meshBasicMaterial",{color:t,transparent:!0,opacity:u})]}),f.jsx(ze,{direction:r,color:t,opacity:u,lit:a})]},r)})})}function ze({direction:e,color:t,opacity:n,lit:i}){const{position:s,rotation:r}=E.useMemo(()=>{const{head:a}=H(e),u=e==="+"?1:-1;return{position:new m.Vector3(Math.cos(a)*F,Math.sin(a)*F,0),rotation:new m.Quaternion().setFromUnitVectors(ee,new m.Vector3(-Math.sin(a)*u,Math.cos(a)*u,0))}},[e]);return f.jsxs("mesh",{position:s,quaternion:r,scale:i?1.2:1,children:[f.jsx("coneGeometry",{args:[te,G,20]}),f.jsx("meshBasicMaterial",{color:t,transparent:!0,opacity:n})]})}function ke(e){const{disabled:t,label:n,overlay:i,size:s}=e,r=$.useTheme(),{gripPx:a,labelFontPx:u}=N(s);return f.jsxs(f.Fragment,{children:[M.JOG_AXES.map(o=>f.jsx(v,{component:"span","aria-hidden":!0,ref:I(i,ne(o)),sx:{position:"absolute",transform:"translate(-50%, -50%)",pointerEvents:"none",fontSize:u,color:C(o),opacity:t?.4:1},children:o.toUpperCase()},o)),M.JOG_AXES.flatMap(o=>M.JOG_DIRECTIONS.map(l=>{const d={axis:o,direction:l},c=se(d,e);return f.jsx(v,{component:"button",type:"button",ref:I(i,R(d)),disabled:t,"aria-label":n(d),"aria-pressed":c.pressed,...ce(d,e),sx:{position:"absolute",height:a,transformOrigin:"0 50%",padding:0,borderRadius:`${a/2}px`,border:"none",background:ae(C(o),c),"&:focus-visible":{outline:ie(r)},...z(t)}},R(d))}))]})}function qe(e){const t=[];for(const n of M.JOG_AXES)for(const i of M.JOG_DIRECTIONS){const s=L[n].clone().multiplyScalar(i==="+"?1:-1).applyQuaternion(e);t.push({axis:n,direction:i,x:s.x+0,y:-s.y+0,depth:s.z})}return t}function De(e,t){const{radiusPx:n,gripPx:i,innerPx:s,beyondTipPx:r,minTipPx:a,headLength:u}=t,o=e.map(c=>{const h=Math.hypot(c.x,c.y)*n;return{tip:h,angle:Math.atan2(c.y,c.x),start:s,end:h+r,depth:c.depth,grabbed:h>=a}});for(const[c,h]of o.entries())for(const x of o.slice(c+1)){if(!h.grabbed||!x.grabbed)continue;const[p,g]=h.tip<=x.tip?[h,x]:[x,h],y=h.angle-x.angle,b=p.tip*Math.abs(Math.sin(y));if(Math.cos(y)<=0||b>=i)continue;const w=g.tip*(1-u);if(p.tip>w){const A=h.depth<x.depth?h:x;A.grabbed=!1}else{const A=(p.tip+w)/2;p.end=Math.min(p.end,A),g.start=Math.max(g.start,A)}}const l=o.map((c,h)=>h);l.sort((c,h)=>o[c].depth-o[h].depth);const d=new Map(l.map((c,h)=>[c,h+1]));return o.map((c,h)=>!c.grabbed||c.end<=c.start?null:{x:Math.cos(c.angle)*c.start,y:Math.sin(c.angle)*c.start,length:c.end-c.start,angle:c.angle,layer:d.get(h)??0})}const Y=.035,Z=1.28;function He({orientation:e,lit:t,disabled:n,size:i,radius:s,overlay:r}){const a=E.useRef(null),u=i/2;return he(e,a,o=>{let l=!0;const d=qe(o),c=De(d,Ee(i,s));for(const[h,x]of d.entries()){const p=r.current.get(R(x)),g=c[h];if(p?g?(p.style.left=`${u+g.x}px`,p.style.top=`${u+g.y}px`,p.style.width=`${g.length}px`,p.style.transform=`translateY(-50%) rotate(${g.angle}rad)`,p.style.zIndex=String(g.layer),p.style.pointerEvents=""):p.style.pointerEvents="none":l=!1,x.direction!=="+")continue;const y=r.current.get(ne(x.axis));y?(y.style.left=`${u+x.x*s*Z}px`,y.style.top=`${u+x.y*s*Z}px`):l=!1}return l},`${i}:${s}`),f.jsxs("group",{ref:a,children:[f.jsxs("mesh",{children:[f.jsx("sphereGeometry",{args:[.07,16,16]}),f.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),M.JOG_AXES.map(o=>f.jsx(Qe,{axis:o,color:C(o),lit:(t==null?void 0:t.axis)===o?t.direction:null,disabled:n},o))]})}function Qe({axis:e,color:t,lit:n,disabled:i}){const s=E.useMemo(()=>new m.Quaternion().setFromUnitVectors(ee,L[e]),[e]),r=1-G;return f.jsx("group",{quaternion:s,children:M.JOG_DIRECTIONS.map(a=>{const u=n===a,o=u?1:i?.35:.8,l=u?Y*1.5:Y;return f.jsxs("group",{rotation:[a==="+"?0:Math.PI,0,0],children:[f.jsxs("mesh",{position:[0,r/2,0],children:[f.jsx("cylinderGeometry",{args:[l,l,r,12]}),f.jsx("meshBasicMaterial",{color:t,transparent:!0,opacity:o})]}),f.jsxs("mesh",{position:[0,1-G/2,0],scale:u?1.2:1,children:[f.jsx("coneGeometry",{args:[te,G,20]}),f.jsx("meshBasicMaterial",{color:t,transparent:!0,opacity:o})]})]},a)})})}const Be=new m.Quaternion;function We(e,t=Be){const n=E.useRef(t);return n.current=t,E.useMemo(()=>{const i=new m.Quaternion;return{get current(){const s=e.current;if(!s)return null;const r=n.current;return ve(s,typeof r=="function"?r():r,i)}}},[e])}const Ue=3e3;function Xe(e){const[t,n]=E.useState(()=>e.current!==null);return E.useEffect(()=>{if(t)return;let i=requestAnimationFrame(function r(){e.current!==null?n(!0):i=requestAnimationFrame(r)});const s=setTimeout(()=>{e.current===null&&console.warn("JoggingGizmo has no orientation, so it stays disabled. Put a JoggingGizmoOrientation with the same ref into the app's 3D scene.")},Ue);return()=>{cancelAnimationFrame(i),clearTimeout(s)}},[t,e]),t}const Ke=fe.externalizeComponent(({orientation:e,frameQuaternion:t,motion:n="translate",onJogStart:i,onJogStop:s,activeHandle:r,disabled:a=!1,size:u=200,onWebGLUnavailable:o})=>{const{t:l}=de.useTranslation(),{unavailable:d,makeRenderer:c}=xe({onWebGLUnavailable:o}),h=Xe(e),x=a||!h,p=We(e,t),{held:g,handlersFor:y,label:b,isPressed:w}=M.useJogControls({motion:n,onJogStart:i,onJogStop:s,activeHandle:r,disabled:x}),[A,j]=E.useState(null);E.useEffect(()=>j(null),[n]);const S=n==="rotate"?Je:He,_=n==="rotate"?Te:ke,T=E.useRef(new Map),O=be(u,u,N(u).marginPx);return d?f.jsx(v,{"data-testid":"jogging-gizmo-unavailable",sx:{width:u,height:u,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:f.jsx(pe,{variant:"body2",color:"text.secondary",children:l("JoggingGizmo.WebGLUnavailable.lb")})}):f.jsxs(v,{"data-testid":"jogging-gizmo",sx:{position:"relative",width:u,height:u,flexShrink:0,isolation:"isolate"},children:[f.jsx(V.Canvas,{orthographic:!0,flat:!0,frameloop:"demand",camera:{position:[0,0,10],up:[0,1,0],zoom:O,near:.1,far:100},gl:c,style:{position:"absolute",inset:0,pointerEvents:"none"},children:f.jsx(S,{orientation:p,lit:g??r??A,disabled:x,size:u,radius:O,overlay:T})}),f.jsx(_,{isPressed:w,hovered:A,disabled:x,size:u,onHover:j,handlersFor:y,label:b,overlay:T})]})});function Ye({target:e}){const t=V.useThree(n=>n.camera);return V.useFrame(()=>{e.current=Oe(t,e.current??new m.Quaternion)}),null}exports.JoggingGizmo=Ke;exports.JoggingGizmoOrientation=Ye;
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { jsxs as y, Fragment as Q, jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import b from "@mui/material/Box";
|
|
3
|
+
import v from "@mui/material/Stack";
|
|
4
|
+
import { useTheme as W, alpha as F } from "@mui/material/styles";
|
|
5
|
+
import D from "@mui/material/Typography";
|
|
6
|
+
import { useRef as E, useState as O, useCallback as P, useEffect as Y } from "react";
|
|
7
|
+
import { e as tt } from "./externalizeComponent-7OVHUIUh.js";
|
|
8
|
+
import { r as nt, u as ot, p as rt, s as et, c as it, b as st, a as at } from "./holdSafety-Cbej6-Kc.js";
|
|
9
|
+
const j = 2 * Math.PI;
|
|
10
|
+
function lt({ min: t, max: n, linear: r }, u) {
|
|
11
|
+
const e = t !== void 0, a = n !== void 0;
|
|
12
|
+
if (e && a && n > t) return { min: t, max: n };
|
|
13
|
+
if (r) return null;
|
|
14
|
+
if (e && !a) return { min: t, max: t + j };
|
|
15
|
+
if (a && !e) return { min: n - j, max: n };
|
|
16
|
+
const p = Math.round(u / j) * j;
|
|
17
|
+
return { min: p - Math.PI, max: p + Math.PI };
|
|
18
|
+
}
|
|
19
|
+
function L(t, n) {
|
|
20
|
+
return Math.min(1, Math.max(0, (t - n.min) / (n.max - n.min)));
|
|
21
|
+
}
|
|
22
|
+
function ut(t, n) {
|
|
23
|
+
const r = Math.min(1, Math.max(0, t));
|
|
24
|
+
return n.min + r * (n.max - n.min);
|
|
25
|
+
}
|
|
26
|
+
function ct(t) {
|
|
27
|
+
return t.min > 0 || t.max < 0 ? null : L(0, t);
|
|
28
|
+
}
|
|
29
|
+
function dt(t, n, r) {
|
|
30
|
+
return Math.abs(n - t) <= r ? null : n > t ? "+" : "-";
|
|
31
|
+
}
|
|
32
|
+
function ft(t, n, r) {
|
|
33
|
+
return r === "+" ? t >= n : t <= n;
|
|
34
|
+
}
|
|
35
|
+
function mt(t, n) {
|
|
36
|
+
return t ? "mm" : n;
|
|
37
|
+
}
|
|
38
|
+
const z = {
|
|
39
|
+
deg: {
|
|
40
|
+
shown: (t) => t * 180 / Math.PI,
|
|
41
|
+
decimals: 1,
|
|
42
|
+
limitDecimals: 0,
|
|
43
|
+
suffix: "°"
|
|
44
|
+
},
|
|
45
|
+
rad: { shown: (t) => t, decimals: 3, limitDecimals: 2, suffix: " rad" },
|
|
46
|
+
mm: { shown: (t) => t, decimals: 1, limitDecimals: 0, suffix: " mm" }
|
|
47
|
+
};
|
|
48
|
+
function Z(t, n) {
|
|
49
|
+
const r = t.toFixed(n);
|
|
50
|
+
return Number(r) === 0 ? 0 .toFixed(n) : r;
|
|
51
|
+
}
|
|
52
|
+
function T(t, n) {
|
|
53
|
+
return z[n].shown(t);
|
|
54
|
+
}
|
|
55
|
+
function ht(t, n) {
|
|
56
|
+
const { shown: r, decimals: u, suffix: e } = z[n];
|
|
57
|
+
return `${Z(r(t), u)}${e}`;
|
|
58
|
+
}
|
|
59
|
+
function N(t, n) {
|
|
60
|
+
const { shown: r, limitDecimals: u, suffix: e } = z[n], a = 10 ** u, p = r(t), l = Math.sign(p) * Math.round(Math.abs(p) * a) / a;
|
|
61
|
+
return `${l > 0 ? "+" : ""}${Z(l, u)}${e}`;
|
|
62
|
+
}
|
|
63
|
+
const V = 16, G = 4;
|
|
64
|
+
function _({
|
|
65
|
+
railRef: t,
|
|
66
|
+
at: n,
|
|
67
|
+
goalAt: r,
|
|
68
|
+
held: u,
|
|
69
|
+
zeroAt: e,
|
|
70
|
+
limits: a,
|
|
71
|
+
disabled: p
|
|
72
|
+
}) {
|
|
73
|
+
const l = W(), d = l.palette.primary.main, s = `0 0 0 8px ${F(d, 0.16)}`;
|
|
74
|
+
return /* @__PURE__ */ y(Q, { children: [
|
|
75
|
+
/* @__PURE__ */ y(
|
|
76
|
+
b,
|
|
77
|
+
{
|
|
78
|
+
ref: t,
|
|
79
|
+
sx: {
|
|
80
|
+
position: "absolute",
|
|
81
|
+
left: 0,
|
|
82
|
+
right: 0,
|
|
83
|
+
top: "50%",
|
|
84
|
+
height: G,
|
|
85
|
+
transform: "translateY(-50%)"
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ h(
|
|
89
|
+
b,
|
|
90
|
+
{
|
|
91
|
+
sx: {
|
|
92
|
+
position: "absolute",
|
|
93
|
+
inset: 0,
|
|
94
|
+
borderRadius: G / 2,
|
|
95
|
+
backgroundColor: F(d, 0.38)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
n !== null && r !== null && // The stretch the joint would travel: lighter while only hovered
|
|
100
|
+
/* @__PURE__ */ h(
|
|
101
|
+
b,
|
|
102
|
+
{
|
|
103
|
+
sx: {
|
|
104
|
+
position: "absolute",
|
|
105
|
+
top: 0,
|
|
106
|
+
bottom: 0,
|
|
107
|
+
borderRadius: G / 2,
|
|
108
|
+
backgroundColor: d
|
|
109
|
+
},
|
|
110
|
+
style: {
|
|
111
|
+
left: `${Math.min(n, r) * 100}%`,
|
|
112
|
+
width: `${Math.abs(r - n) * 100}%`,
|
|
113
|
+
opacity: u ? 1 : 0.5
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
e !== null && // The joint's zero
|
|
118
|
+
/* @__PURE__ */ h(
|
|
119
|
+
b,
|
|
120
|
+
{
|
|
121
|
+
"aria-hidden": !0,
|
|
122
|
+
sx: {
|
|
123
|
+
position: "absolute",
|
|
124
|
+
top: "50%",
|
|
125
|
+
width: 2,
|
|
126
|
+
height: 12,
|
|
127
|
+
transform: "translate(-50%, -50%)",
|
|
128
|
+
borderRadius: 1,
|
|
129
|
+
backgroundColor: "text.secondary"
|
|
130
|
+
},
|
|
131
|
+
style: { left: `${e * 100}%` }
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
n !== null && /* @__PURE__ */ h(
|
|
135
|
+
b,
|
|
136
|
+
{
|
|
137
|
+
sx: {
|
|
138
|
+
position: "absolute",
|
|
139
|
+
top: "50%",
|
|
140
|
+
boxSizing: "border-box",
|
|
141
|
+
width: V,
|
|
142
|
+
height: V,
|
|
143
|
+
transform: "translate(-50%, -50%)",
|
|
144
|
+
borderRadius: "50%",
|
|
145
|
+
border: `3px solid ${d}`,
|
|
146
|
+
backgroundColor: "background.paper",
|
|
147
|
+
boxShadow: u ? s : l.shadows[2],
|
|
148
|
+
transition: "box-shadow 150ms",
|
|
149
|
+
"&:hover": p ? {} : { boxShadow: s }
|
|
150
|
+
},
|
|
151
|
+
style: { left: `${n * 100}%` }
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
a && /* @__PURE__ */ h(
|
|
158
|
+
v,
|
|
159
|
+
{
|
|
160
|
+
direction: "row",
|
|
161
|
+
sx: {
|
|
162
|
+
position: "absolute",
|
|
163
|
+
left: 0,
|
|
164
|
+
right: 0,
|
|
165
|
+
top: 30,
|
|
166
|
+
justifyContent: "space-between"
|
|
167
|
+
},
|
|
168
|
+
children: [a.min, a.max].map((R, w) => /* @__PURE__ */ h(
|
|
169
|
+
D,
|
|
170
|
+
{
|
|
171
|
+
variant: "caption",
|
|
172
|
+
color: "text.secondary",
|
|
173
|
+
sx: { fontSize: 10, lineHeight: "14px" },
|
|
174
|
+
children: R
|
|
175
|
+
},
|
|
176
|
+
w
|
|
177
|
+
))
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
function pt({
|
|
183
|
+
value: t,
|
|
184
|
+
onJogStart: n,
|
|
185
|
+
onJogStop: r,
|
|
186
|
+
disabled: u
|
|
187
|
+
}) {
|
|
188
|
+
const e = E(null), [a, p] = O(null), l = P((o) => {
|
|
189
|
+
e.current = o, p(o);
|
|
190
|
+
}, []), d = E({ value: t, onJogStart: n, onJogStop: r });
|
|
191
|
+
d.current = { value: t, onJogStart: n, onJogStop: r };
|
|
192
|
+
const s = P(
|
|
193
|
+
(o, g, c) => {
|
|
194
|
+
const x = dt(d.current.value, g, c);
|
|
195
|
+
l({
|
|
196
|
+
...o,
|
|
197
|
+
goal: g,
|
|
198
|
+
direction: x,
|
|
199
|
+
settledAt: x ? null : o.settledAt
|
|
200
|
+
}), o.direction && o.direction !== x && d.current.onJogStop(), x && x !== o.direction && d.current.onJogStart(x);
|
|
201
|
+
},
|
|
202
|
+
[l]
|
|
203
|
+
), R = P(() => e.current !== null, []), w = P(
|
|
204
|
+
(o, g, c, x) => u || e.current ? !1 : (s({ goal: o, direction: null, settledAt: null, pointer: c, element: x }, o, g), !0),
|
|
205
|
+
[u, s]
|
|
206
|
+
), S = P(
|
|
207
|
+
(o, g) => {
|
|
208
|
+
const c = e.current;
|
|
209
|
+
if (c) {
|
|
210
|
+
if (c.direction === null && c.settledAt !== null && Math.abs(o - c.settledAt) <= g) {
|
|
211
|
+
l({ ...c, goal: o });
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
s(c, o, g);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[s, l]
|
|
218
|
+
), A = P(() => {
|
|
219
|
+
const o = e.current;
|
|
220
|
+
o && (l(null), nt(o.element, o.pointer), o.direction && d.current.onJogStop());
|
|
221
|
+
}, [l]), C = P(() => {
|
|
222
|
+
var o;
|
|
223
|
+
return ((o = e.current) == null ? void 0 : o.pointer) ?? null;
|
|
224
|
+
}, []);
|
|
225
|
+
return Y(() => {
|
|
226
|
+
const o = e.current;
|
|
227
|
+
o != null && o.direction && ft(t, o.goal, o.direction) && (l({ ...o, direction: null, settledAt: o.goal }), d.current.onJogStop());
|
|
228
|
+
}, [t, l]), ot(a !== null, u, A), { hold: a, isHolding: R, holdingPointer: C, begin: w, moveGoal: S, end: A };
|
|
229
|
+
}
|
|
230
|
+
function xt(t) {
|
|
231
|
+
return t === "mouse" || t === "pen" ? 1 : 4;
|
|
232
|
+
}
|
|
233
|
+
const gt = 8, It = tt(
|
|
234
|
+
({
|
|
235
|
+
label: t,
|
|
236
|
+
name: n,
|
|
237
|
+
value: r,
|
|
238
|
+
min: u,
|
|
239
|
+
max: e,
|
|
240
|
+
linear: a = !1,
|
|
241
|
+
angleUnit: p = "deg",
|
|
242
|
+
onJogStart: l,
|
|
243
|
+
onJogStop: d,
|
|
244
|
+
disabled: s = !1
|
|
245
|
+
}) => {
|
|
246
|
+
const R = W(), w = E(null), { hold: S, isHolding: A, holdingPointer: C, begin: o, moveGoal: g, end: c } = pt({ value: r, onJogStart: l, onJogStop: d, disabled: s }), [x, I] = O(null);
|
|
247
|
+
Y(() => {
|
|
248
|
+
s && I(null);
|
|
249
|
+
}, [s]);
|
|
250
|
+
const f = lt({ min: u, max: e, linear: a }, r), $ = mt(a, p), k = (i) => ht(i, $);
|
|
251
|
+
function U({ clientX: i, pointerType: m }) {
|
|
252
|
+
if (!f || !w.current) return null;
|
|
253
|
+
const M = w.current.getBoundingClientRect();
|
|
254
|
+
return M.width <= 0 ? null : {
|
|
255
|
+
goal: ut((i - M.left) / M.width, f),
|
|
256
|
+
deadband: xt(m) / M.width * (f.max - f.min)
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function X(i) {
|
|
260
|
+
if (!et(i) || s || A()) return;
|
|
261
|
+
const m = U(i);
|
|
262
|
+
m && (it(i.currentTarget, i.pointerId), o(m.goal, m.deadband, i.pointerId, i.currentTarget));
|
|
263
|
+
}
|
|
264
|
+
function q(i) {
|
|
265
|
+
const m = U(i), M = C() === i.pointerId;
|
|
266
|
+
if (M && !st(i, gt)) {
|
|
267
|
+
I(null), c();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (I(s ? null : (m == null ? void 0 : m.goal) ?? null), !!M) {
|
|
271
|
+
if (at(i)) {
|
|
272
|
+
c();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
m && g(m.goal, m.deadband);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function H(i) {
|
|
279
|
+
C() === i.pointerId && c();
|
|
280
|
+
}
|
|
281
|
+
const J = (S == null ? void 0 : S.goal) ?? x, K = f && {
|
|
282
|
+
min: N(f.min, $),
|
|
283
|
+
max: N(f.max, $)
|
|
284
|
+
}, B = /* @__PURE__ */ y(
|
|
285
|
+
v,
|
|
286
|
+
{
|
|
287
|
+
direction: "row",
|
|
288
|
+
sx: { justifyContent: "space-between", gap: 1, mb: "-4px" },
|
|
289
|
+
children: [
|
|
290
|
+
/* @__PURE__ */ y(D, { variant: "body2", noWrap: !0, children: [
|
|
291
|
+
t,
|
|
292
|
+
n && /* @__PURE__ */ h(b, { component: "span", sx: { color: "text.secondary" }, children: ` - ${n}` })
|
|
293
|
+
] }),
|
|
294
|
+
/* @__PURE__ */ y(
|
|
295
|
+
D,
|
|
296
|
+
{
|
|
297
|
+
variant: "body2",
|
|
298
|
+
sx: { fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" },
|
|
299
|
+
children: [
|
|
300
|
+
k(r),
|
|
301
|
+
f && J !== null && /* @__PURE__ */ h(b, { component: "span", sx: { color: "text.secondary" }, children: ` / ${k(J)}` })
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
return f ? /* @__PURE__ */ y(v, { "data-testid": "jogging-joint-slider", children: [
|
|
309
|
+
B,
|
|
310
|
+
/* @__PURE__ */ h(
|
|
311
|
+
b,
|
|
312
|
+
{
|
|
313
|
+
role: "slider",
|
|
314
|
+
tabIndex: s ? -1 : 0,
|
|
315
|
+
"aria-label": n ? `${t} ${n}` : t,
|
|
316
|
+
"aria-valuemin": T(f.min, $),
|
|
317
|
+
"aria-valuemax": T(f.max, $),
|
|
318
|
+
"aria-valuenow": T(r, $),
|
|
319
|
+
"aria-valuetext": k(r),
|
|
320
|
+
"aria-disabled": s || void 0,
|
|
321
|
+
onPointerDown: X,
|
|
322
|
+
onPointerMove: q,
|
|
323
|
+
onPointerLeave: (i) => {
|
|
324
|
+
I(null), H(i);
|
|
325
|
+
},
|
|
326
|
+
onPointerUp: H,
|
|
327
|
+
onPointerCancel: H,
|
|
328
|
+
onLostPointerCapture: H,
|
|
329
|
+
onBlur: c,
|
|
330
|
+
onContextMenu: rt,
|
|
331
|
+
sx: {
|
|
332
|
+
position: "relative",
|
|
333
|
+
height: 44,
|
|
334
|
+
borderRadius: 1,
|
|
335
|
+
opacity: s ? 0.5 : 1,
|
|
336
|
+
cursor: s ? "default" : "pointer",
|
|
337
|
+
// A press must stay a press: no scrolling or text selection
|
|
338
|
+
touchAction: "none",
|
|
339
|
+
userSelect: "none",
|
|
340
|
+
outline: "none",
|
|
341
|
+
// The design system's focus mark, as on its buttons
|
|
342
|
+
"&:focus-visible": {
|
|
343
|
+
outline: `2px solid ${R.palette.primary.main}`,
|
|
344
|
+
outlineOffset: "2px"
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
children: /* @__PURE__ */ h(
|
|
348
|
+
_,
|
|
349
|
+
{
|
|
350
|
+
railRef: w,
|
|
351
|
+
at: L(r, f),
|
|
352
|
+
goalAt: J === null ? null : L(J, f),
|
|
353
|
+
held: S !== null,
|
|
354
|
+
zeroAt: ct(f),
|
|
355
|
+
limits: K ?? void 0,
|
|
356
|
+
disabled: s
|
|
357
|
+
}
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
] }) : /* @__PURE__ */ y(v, { "data-testid": "jogging-joint-slider", children: [
|
|
362
|
+
B,
|
|
363
|
+
/* @__PURE__ */ h(b, { "aria-hidden": !0, sx: { position: "relative", height: 44 }, children: /* @__PURE__ */ h(
|
|
364
|
+
_,
|
|
365
|
+
{
|
|
366
|
+
at: null,
|
|
367
|
+
goalAt: null,
|
|
368
|
+
held: !1,
|
|
369
|
+
zeroAt: null,
|
|
370
|
+
disabled: !0
|
|
371
|
+
}
|
|
372
|
+
) })
|
|
373
|
+
] });
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
export {
|
|
377
|
+
It as J
|
|
378
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),j=require("@mui/material/Box"),J=require("@mui/material/Stack"),v=require("@mui/material/styles"),G=require("@mui/material/Typography"),x=require("react"),Y=require("./externalizeComponent-B0n_tR3v.cjs"),y=require("./holdSafety-TeMXlYQe.cjs"),H=2*Math.PI;function Z({min:t,max:n,linear:o},c){const r=t!==void 0,u=n!==void 0;if(r&&u&&n>t)return{min:t,max:n};if(o)return null;if(r&&!u)return{min:t,max:t+H};if(u&&!r)return{min:n-H,max:n};const p=Math.round(c/H)*H;return{min:p-Math.PI,max:p+Math.PI}}function z(t,n){return Math.min(1,Math.max(0,(t-n.min)/(n.max-n.min)))}function X(t,n){const o=Math.min(1,Math.max(0,t));return n.min+o*(n.max-n.min)}function K(t){return t.min>0||t.max<0?null:z(0,t)}function Q(t,n,o){return Math.abs(n-t)<=o?null:n>t?"+":"-"}function tt(t,n,o){return o==="+"?t>=n:t<=n}function nt(t,n){return t?"mm":n}const D={deg:{shown:t=>t*180/Math.PI,decimals:1,limitDecimals:0,suffix:"°"},rad:{shown:t=>t,decimals:3,limitDecimals:2,suffix:" rad"},mm:{shown:t=>t,decimals:1,limitDecimals:0,suffix:" mm"}};function V(t,n){const o=t.toFixed(n);return Number(o)===0?0 .toFixed(n):o}function q(t,n){return D[n].shown(t)}function et(t,n){const{shown:o,decimals:c,suffix:r}=D[n];return`${V(o(t),c)}${r}`}function B(t,n){const{shown:o,limitDecimals:c,suffix:r}=D[n],u=10**c,p=o(t),a=Math.sign(p)*Math.round(Math.abs(p)*u)/u;return`${a>0?"+":""}${V(a,c)}${r}`}const F=16,E=4;function N({railRef:t,at:n,goalAt:o,held:c,zeroAt:r,limits:u,disabled:p}){const a=v.useTheme(),f=a.palette.primary.main,l=`0 0 0 8px ${v.alpha(f,.16)}`;return i.jsxs(i.Fragment,{children:[i.jsxs(j,{ref:t,sx:{position:"absolute",left:0,right:0,top:"50%",height:E,transform:"translateY(-50%)"},children:[i.jsx(j,{sx:{position:"absolute",inset:0,borderRadius:E/2,backgroundColor:v.alpha(f,.38)}}),n!==null&&o!==null&&i.jsx(j,{sx:{position:"absolute",top:0,bottom:0,borderRadius:E/2,backgroundColor:f},style:{left:`${Math.min(n,o)*100}%`,width:`${Math.abs(o-n)*100}%`,opacity:c?1:.5}}),r!==null&&i.jsx(j,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",width:2,height:12,transform:"translate(-50%, -50%)",borderRadius:1,backgroundColor:"text.secondary"},style:{left:`${r*100}%`}}),n!==null&&i.jsx(j,{sx:{position:"absolute",top:"50%",boxSizing:"border-box",width:F,height:F,transform:"translate(-50%, -50%)",borderRadius:"50%",border:`3px solid ${f}`,backgroundColor:"background.paper",boxShadow:c?l:a.shadows[2],transition:"box-shadow 150ms","&:hover":p?{}:{boxShadow:l}},style:{left:`${n*100}%`}})]}),u&&i.jsx(J,{direction:"row",sx:{position:"absolute",left:0,right:0,top:30,justifyContent:"space-between"},children:[u.min,u.max].map((R,w)=>i.jsx(G,{variant:"caption",color:"text.secondary",sx:{fontSize:10,lineHeight:"14px"},children:R},w))})]})}function ot({value:t,onJogStart:n,onJogStop:o,disabled:c}){const r=x.useRef(null),[u,p]=x.useState(null),a=x.useCallback(e=>{r.current=e,p(e)},[]),f=x.useRef({value:t,onJogStart:n,onJogStop:o});f.current={value:t,onJogStart:n,onJogStop:o};const l=x.useCallback((e,b,d)=>{const g=Q(f.current.value,b,d);a({...e,goal:b,direction:g,settledAt:g?null:e.settledAt}),e.direction&&e.direction!==g&&f.current.onJogStop(),g&&g!==e.direction&&f.current.onJogStart(g)},[a]),R=x.useCallback(()=>r.current!==null,[]),w=x.useCallback((e,b,d,g)=>c||r.current?!1:(l({goal:e,direction:null,settledAt:null,pointer:d,element:g},e,b),!0),[c,l]),C=x.useCallback((e,b)=>{const d=r.current;if(d){if(d.direction===null&&d.settledAt!==null&&Math.abs(e-d.settledAt)<=b){a({...d,goal:e});return}l(d,e,b)}},[l,a]),$=x.useCallback(()=>{const e=r.current;e&&(a(null),y.releasePointer(e.element,e.pointer),e.direction&&f.current.onJogStop())},[a]),k=x.useCallback(()=>{var e;return((e=r.current)==null?void 0:e.pointer)??null},[]);return x.useEffect(()=>{const e=r.current;e!=null&&e.direction&&tt(t,e.goal,e.direction)&&(a({...e,direction:null,settledAt:e.goal}),f.current.onJogStop())},[t,a]),y.useEndHoldWhenUnattended(u!==null,c,$),{hold:u,isHolding:R,holdingPointer:k,begin:w,moveGoal:C,end:$}}function rt(t){return t==="mouse"||t==="pen"?1:4}const it=8,st=Y.externalizeComponent(({label:t,name:n,value:o,min:c,max:r,linear:u=!1,angleUnit:p="deg",onJogStart:a,onJogStop:f,disabled:l=!1})=>{const R=v.useTheme(),w=x.useRef(null),{hold:C,isHolding:$,holdingPointer:k,begin:e,moveGoal:b,end:d}=ot({value:o,onJogStart:a,onJogStop:f,disabled:l}),[g,S]=x.useState(null);x.useEffect(()=>{l&&S(null)},[l]);const h=Z({min:c,max:r,linear:u},o),P=nt(u,p),T=s=>et(s,P);function L({clientX:s,pointerType:m}){if(!h||!w.current)return null;const M=w.current.getBoundingClientRect();return M.width<=0?null:{goal:X((s-M.left)/M.width,h),deadband:rt(m)/M.width*(h.max-h.min)}}function _(s){if(!y.startsPointerHold(s)||l||$())return;const m=L(s);m&&(y.capturePointer(s.currentTarget,s.pointerId),e(m.goal,m.deadband,s.pointerId,s.currentTarget))}function W(s){const m=L(s),M=k()===s.pointerId;if(M&&!y.isPointerWithin(s,it)){S(null),d();return}if(S(l?null:(m==null?void 0:m.goal)??null),!!M){if(y.primaryReleased(s)){d();return}m&&b(m.goal,m.deadband)}}function I(s){k()===s.pointerId&&d()}const A=(C==null?void 0:C.goal)??g,O=h&&{min:B(h.min,P),max:B(h.max,P)},U=i.jsxs(J,{direction:"row",sx:{justifyContent:"space-between",gap:1,mb:"-4px"},children:[i.jsxs(G,{variant:"body2",noWrap:!0,children:[t,n&&i.jsx(j,{component:"span",sx:{color:"text.secondary"},children:` - ${n}`})]}),i.jsxs(G,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[T(o),h&&A!==null&&i.jsx(j,{component:"span",sx:{color:"text.secondary"},children:` / ${T(A)}`})]})]});return h?i.jsxs(J,{"data-testid":"jogging-joint-slider",children:[U,i.jsx(j,{role:"slider",tabIndex:l?-1:0,"aria-label":n?`${t} ${n}`:t,"aria-valuemin":q(h.min,P),"aria-valuemax":q(h.max,P),"aria-valuenow":q(o,P),"aria-valuetext":T(o),"aria-disabled":l||void 0,onPointerDown:_,onPointerMove:W,onPointerLeave:s=>{S(null),I(s)},onPointerUp:I,onPointerCancel:I,onLostPointerCapture:I,onBlur:d,onContextMenu:y.preventContextMenu,sx:{position:"relative",height:44,borderRadius:1,opacity:l?.5:1,cursor:l?"default":"pointer",touchAction:"none",userSelect:"none",outline:"none","&:focus-visible":{outline:`2px solid ${R.palette.primary.main}`,outlineOffset:"2px"}},children:i.jsx(N,{railRef:w,at:z(o,h),goalAt:A===null?null:z(A,h),held:C!==null,zeroAt:K(h),limits:O??void 0,disabled:l})})]}):i.jsxs(J,{"data-testid":"jogging-joint-slider",children:[U,i.jsx(j,{"aria-hidden":!0,sx:{position:"relative",height:44},children:i.jsx(N,{at:null,goalAt:null,held:!1,zeroAt:null,disabled:!0})})]})});exports.JoggingJointSlider=st;
|