@wandelbots/wandelbots-js-react-components 2.42.0-pr.feat-add-universalrobots-ur12e.387.df3cdf0 → 2.42.0-pr.feature-seperate-timer.383.2e9936e

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.
Files changed (54) hide show
  1. package/dist/components/CycleTimer/DefaultVariant.d.ts.map +1 -1
  2. package/dist/components/CycleTimer/SmallVariant.d.ts.map +1 -1
  3. package/dist/components/CycleTimer/index.d.ts +4 -5
  4. package/dist/components/CycleTimer/index.d.ts.map +1 -1
  5. package/dist/components/CycleTimer/types.d.ts +2 -3
  6. package/dist/components/CycleTimer/types.d.ts.map +1 -1
  7. package/dist/components/CycleTimer/useTimerLogic.d.ts +1 -2
  8. package/dist/components/CycleTimer/useTimerLogic.d.ts.map +1 -1
  9. package/dist/components/Timer/Timer.d.ts +3 -0
  10. package/dist/components/Timer/Timer.d.ts.map +1 -0
  11. package/dist/components/Timer/TimerDefaultVariant.d.ts +10 -0
  12. package/dist/components/Timer/TimerDefaultVariant.d.ts.map +1 -0
  13. package/dist/components/Timer/TimerSmallVariant.d.ts +11 -0
  14. package/dist/components/Timer/TimerSmallVariant.d.ts.map +1 -0
  15. package/dist/components/Timer/index.d.ts +19 -0
  16. package/dist/components/Timer/index.d.ts.map +1 -0
  17. package/dist/components/Timer/types.d.ts +36 -0
  18. package/dist/components/Timer/types.d.ts.map +1 -0
  19. package/dist/components/Timer/useTimerAnimations.d.ts +11 -0
  20. package/dist/components/Timer/useTimerAnimations.d.ts.map +1 -0
  21. package/dist/components/Timer/useTimerLogic.d.ts +20 -0
  22. package/dist/components/Timer/useTimerLogic.d.ts.map +1 -0
  23. package/dist/components/Timer/utils.d.ts +9 -0
  24. package/dist/components/Timer/utils.d.ts.map +1 -0
  25. package/dist/components/jogging/PoseCartesianValues.d.ts +3 -5
  26. package/dist/components/jogging/PoseCartesianValues.d.ts.map +1 -1
  27. package/dist/components/jogging/PoseJointValues.d.ts +3 -5
  28. package/dist/components/jogging/PoseJointValues.d.ts.map +1 -1
  29. package/dist/index.cjs +47 -47
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5947 -5589
  34. package/dist/index.js.map +1 -1
  35. package/package.json +5 -5
  36. package/src/components/CycleTimer/DefaultVariant.tsx +0 -2
  37. package/src/components/CycleTimer/SmallVariant.tsx +2 -5
  38. package/src/components/CycleTimer/index.tsx +4 -5
  39. package/src/components/CycleTimer/types.ts +1 -3
  40. package/src/components/CycleTimer/useTimerLogic.ts +40 -96
  41. package/src/components/CycleTimer/utils.ts +3 -3
  42. package/src/components/Timer/Timer.ts +2 -0
  43. package/src/components/Timer/TimerDefaultVariant.tsx +140 -0
  44. package/src/components/Timer/TimerSmallVariant.tsx +140 -0
  45. package/src/components/Timer/index.tsx +101 -0
  46. package/src/components/Timer/types.ts +38 -0
  47. package/src/components/Timer/useTimerAnimations.ts +94 -0
  48. package/src/components/Timer/useTimerLogic.ts +214 -0
  49. package/src/components/Timer/utils.ts +15 -0
  50. package/src/components/jogging/PoseCartesianValues.tsx +16 -82
  51. package/src/components/jogging/PoseJointValues.tsx +16 -82
  52. package/src/i18n/locales/de/translations.json +1 -0
  53. package/src/i18n/locales/en/translations.json +1 -0
  54. package/src/index.ts +1 -0
@@ -1,101 +1,40 @@
1
- import { Button, Stack, Typography } from "@mui/material"
2
- import type {
3
- ConnectedMotionGroup,
4
- MotionGroupStateResponse,
5
- MotionStreamConnection,
6
- } from "@wandelbots/nova-js/v1"
1
+ import { Button, Stack } from "@mui/material"
2
+ import type { Joints } from "@wandelbots/nova-api/v1"
7
3
  import { observer } from "mobx-react-lite"
8
- import { useRef, useState } from "react"
4
+ import { useState } from "react"
5
+ import { externalizeComponent } from "../../externalizeComponent"
9
6
  import { CopyableText } from "../CopyableText"
10
- import { useAnimationFrame } from "../utils/hooks"
11
-
12
- /** Minimal interface for what PoseJointValues needs from motion stream */
13
- type MotionStateProvider = {
14
- rapidlyChangingMotionState: MotionGroupStateResponse
15
- }
16
-
17
- /** Creates a motion state provider from either a MotionStreamConnection or ConnectedMotionGroup */
18
- function createMotionStateProvider(
19
- motionStream?: MotionStreamConnection,
20
- connectedMotionGroup?: ConnectedMotionGroup,
21
- ): MotionStateProvider | undefined {
22
- if (motionStream) {
23
- return motionStream
24
- }
25
- if (connectedMotionGroup) {
26
- return {
27
- rapidlyChangingMotionState:
28
- connectedMotionGroup.rapidlyChangingMotionState,
29
- }
30
- }
31
- return undefined
32
- }
33
7
 
34
8
  export type PoseJointValuesProps = {
35
- /** Either a MotionStreamConnection or ConnectedMotionGroup */
36
- motionStream?: MotionStreamConnection
37
- connectedMotionGroup?: ConnectedMotionGroup
9
+ joints: Joints
38
10
  showCopyButton?: boolean
39
11
  }
40
12
 
41
- export const PoseJointValues = observer(
42
- ({
43
- motionStream,
44
- connectedMotionGroup,
45
- showCopyButton = false,
46
- }: PoseJointValuesProps) => {
47
- const poseHolderRef = useRef<HTMLDivElement>(null)
48
- const [copyMessage, setCopyMessage] = useState("")
49
-
50
- const activeMotionStream = createMotionStateProvider(
51
- motionStream,
52
- connectedMotionGroup,
53
- )
54
-
55
- if (!activeMotionStream) {
56
- throw new Error(
57
- "PoseJointValues requires either motionStream or connectedMotionGroup prop",
58
- )
59
- }
60
-
61
- function getCurrentPoseString() {
62
- if (!activeMotionStream) return ""
63
- const { joints } =
64
- activeMotionStream.rapidlyChangingMotionState.state.joint_position
65
- return `[${joints.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
66
- }
13
+ export const PoseJointValues = externalizeComponent(
14
+ observer(({ joints, showCopyButton = false }: PoseJointValuesProps) => {
15
+ const [copyMessage, setCopyMessage] = useState<string | null>(null)
16
+ const poseString = `[${joints.joints.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
67
17
 
68
18
  const handleCopy = async () => {
69
19
  try {
70
- await navigator.clipboard.writeText(getCurrentPoseString())
20
+ await navigator.clipboard.writeText(poseString)
71
21
  setCopyMessage("Copied!")
72
- setTimeout(() => setCopyMessage(""), 2000)
22
+ setTimeout(() => setCopyMessage(null), 2000)
73
23
  } catch {
74
24
  setCopyMessage("Copy failed")
75
- setTimeout(() => setCopyMessage(""), 2000)
25
+ setTimeout(() => setCopyMessage(null), 2000)
76
26
  }
77
27
  }
78
28
 
79
- useAnimationFrame(() => {
80
- if (!poseHolderRef.current) {
81
- return
82
- }
83
-
84
- const newPoseContent = getCurrentPoseString()
85
- if (poseHolderRef.current.textContent === newPoseContent) {
86
- return
87
- }
88
- poseHolderRef.current.textContent = newPoseContent
89
- })
90
-
91
29
  return (
92
30
  <Stack
93
31
  direction="row"
94
32
  alignItems="center"
95
33
  spacing={1}
96
34
  sx={{ flexGrow: 1, minWidth: 0, overflow: "hidden" }}
35
+ data-testid="pose-joint-values"
97
36
  >
98
- <CopyableText value={getCurrentPoseString()} ref={poseHolderRef} />
37
+ <CopyableText value={poseString} />
99
38
  {showCopyButton && (
100
39
  <Button
101
40
  variant="contained"
@@ -104,15 +43,10 @@ export const PoseJointValues = observer(
104
43
  onClick={handleCopy}
105
44
  sx={{ flexShrink: 0 }}
106
45
  >
107
- Copy
46
+ { copyMessage ? copyMessage : "Copy"}
108
47
  </Button>
109
48
  )}
110
- {copyMessage && (
111
- <Typography variant="caption" color="success.main">
112
- {copyMessage}
113
- </Typography>
114
- )}
115
49
  </Stack>
116
50
  )
117
- },
51
+ }),
118
52
  )
@@ -52,6 +52,7 @@
52
52
  "CycleTimer.CycleTime.lb": "Zykluszeit",
53
53
  "CycleTimer.Measuring.lb": "wird gemessen...",
54
54
  "CycleTimer.Determined.lb": "bestimmt",
55
+ "Timer.error": "Fehler",
55
56
  "ProgramControl.Start.bt": "Start",
56
57
  "ProgramControl.Resume.bt": "Weiter",
57
58
  "ProgramControl.Retry.bt": "Wiederholen",
@@ -53,6 +53,7 @@
53
53
  "CycleTimer.CycleTime.lb": "Cycle Time",
54
54
  "CycleTimer.Measuring.lb": "measuring...",
55
55
  "CycleTimer.Determined.lb": "determined",
56
+ "Timer.error": "Error",
56
57
  "ProgramControl.Start.bt": "Start",
57
58
  "ProgramControl.Resume.bt": "Resume",
58
59
  "ProgramControl.Retry.bt": "Retry",
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./components/3d-viewport/SafetyZonesRenderer"
4
4
  export * from "./components/3d-viewport/TrajectoryRenderer"
5
5
  export * from "./components/AppHeader"
6
6
  export * from "./components/CycleTimer"
7
+ export * from "./components/Timer"
7
8
  export * from "./components/DataGrid"
8
9
  export * from "./components/jogging/JoggingCartesianAxisControl"
9
10
  export * from "./components/jogging/JoggingJointRotationControl"