@wandelbots/wandelbots-js-react-components 2.43.0 → 2.44.0-pr.feature-seperate-timer.383.076b2df

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 (59) 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/ProgramControl.d.ts +4 -1
  10. package/dist/components/ProgramControl.d.ts.map +1 -1
  11. package/dist/components/ProgramStateIndicator.d.ts.map +1 -1
  12. package/dist/components/Timer/Timer.d.ts +3 -0
  13. package/dist/components/Timer/Timer.d.ts.map +1 -0
  14. package/dist/components/Timer/TimerDefaultVariant.d.ts +10 -0
  15. package/dist/components/Timer/TimerDefaultVariant.d.ts.map +1 -0
  16. package/dist/components/Timer/TimerSmallVariant.d.ts +11 -0
  17. package/dist/components/Timer/TimerSmallVariant.d.ts.map +1 -0
  18. package/dist/components/Timer/index.d.ts +19 -0
  19. package/dist/components/Timer/index.d.ts.map +1 -0
  20. package/dist/components/Timer/types.d.ts +36 -0
  21. package/dist/components/Timer/types.d.ts.map +1 -0
  22. package/dist/components/Timer/useTimerAnimations.d.ts +11 -0
  23. package/dist/components/Timer/useTimerAnimations.d.ts.map +1 -0
  24. package/dist/components/Timer/useTimerLogic.d.ts +20 -0
  25. package/dist/components/Timer/useTimerLogic.d.ts.map +1 -0
  26. package/dist/components/Timer/utils.d.ts +9 -0
  27. package/dist/components/Timer/utils.d.ts.map +1 -0
  28. package/dist/components/jogging/PoseCartesianValues.d.ts +3 -5
  29. package/dist/components/jogging/PoseCartesianValues.d.ts.map +1 -1
  30. package/dist/components/jogging/PoseJointValues.d.ts +3 -5
  31. package/dist/components/jogging/PoseJointValues.d.ts.map +1 -1
  32. package/dist/index.cjs +48 -48
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +6203 -5824
  37. package/dist/index.js.map +1 -1
  38. package/package.json +5 -5
  39. package/src/components/CycleTimer/DefaultVariant.tsx +0 -2
  40. package/src/components/CycleTimer/SmallVariant.tsx +2 -5
  41. package/src/components/CycleTimer/index.tsx +4 -5
  42. package/src/components/CycleTimer/types.ts +1 -3
  43. package/src/components/CycleTimer/useTimerLogic.ts +40 -96
  44. package/src/components/CycleTimer/utils.ts +3 -3
  45. package/src/components/ProgramControl.tsx +19 -2
  46. package/src/components/ProgramStateIndicator.tsx +16 -1
  47. package/src/components/Timer/Timer.ts +2 -0
  48. package/src/components/Timer/TimerDefaultVariant.tsx +140 -0
  49. package/src/components/Timer/TimerSmallVariant.tsx +140 -0
  50. package/src/components/Timer/index.tsx +101 -0
  51. package/src/components/Timer/types.ts +38 -0
  52. package/src/components/Timer/useTimerAnimations.ts +94 -0
  53. package/src/components/Timer/useTimerLogic.ts +214 -0
  54. package/src/components/Timer/utils.ts +15 -0
  55. package/src/components/jogging/PoseCartesianValues.tsx +16 -82
  56. package/src/components/jogging/PoseJointValues.tsx +16 -82
  57. package/src/i18n/locales/de/translations.json +4 -0
  58. package/src/i18n/locales/en/translations.json +4 -0
  59. package/src/index.ts +1 -0
@@ -1,102 +1,41 @@
1
- import { Button, Stack, Typography } from "@mui/material"
1
+ import { Button, Stack } from "@mui/material"
2
2
  import { poseToWandelscriptString } from "@wandelbots/nova-js"
3
- import type {
4
- ConnectedMotionGroup,
5
- MotionGroupStateResponse,
6
- MotionStreamConnection,
7
- } from "@wandelbots/nova-js/v1"
3
+ import type { TcpPose } from "@wandelbots/nova-js/v1"
8
4
  import { observer } from "mobx-react-lite"
9
- import { useRef, useState } from "react"
5
+ import { useState } from "react"
6
+ import { externalizeComponent } from "../../externalizeComponent"
10
7
  import { CopyableText } from "../CopyableText"
11
- import { useAnimationFrame } from "../utils/hooks"
12
-
13
- /** Minimal interface for what PoseCartesianValues needs from motion stream */
14
- type MotionStateProvider = {
15
- rapidlyChangingMotionState: MotionGroupStateResponse
16
- }
17
-
18
- /** Creates a motion state provider from either a MotionStreamConnection or ConnectedMotionGroup */
19
- function createMotionStateProvider(
20
- motionStream?: MotionStreamConnection,
21
- connectedMotionGroup?: ConnectedMotionGroup,
22
- ): MotionStateProvider | undefined {
23
- if (motionStream) {
24
- return motionStream
25
- }
26
- if (connectedMotionGroup) {
27
- return {
28
- rapidlyChangingMotionState:
29
- connectedMotionGroup.rapidlyChangingMotionState,
30
- }
31
- }
32
- return undefined
33
- }
34
8
 
35
9
  export type PoseCartesianValuesProps = {
36
- /** Either a MotionStreamConnection or ConnectedMotionGroup */
37
- motionStream?: MotionStreamConnection
38
- connectedMotionGroup?: ConnectedMotionGroup
10
+ tcpPose: TcpPose
39
11
  showCopyButton?: boolean
40
12
  }
41
13
 
42
- export const PoseCartesianValues = observer(
43
- ({
44
- motionStream,
45
- connectedMotionGroup,
46
- showCopyButton = false,
47
- }: PoseCartesianValuesProps) => {
48
- const poseHolderRef = useRef<HTMLDivElement>(null)
49
- const [copyMessage, setCopyMessage] = useState("")
50
-
51
- const activeMotionStream = createMotionStateProvider(
52
- motionStream,
53
- connectedMotionGroup,
54
- )
55
-
56
- if (!activeMotionStream) {
57
- throw new Error(
58
- "PoseCartesianValues requires either motionStream or connectedMotionGroup prop",
59
- )
60
- }
61
-
62
- function getCurrentPoseString() {
63
- if (!activeMotionStream) return ""
64
- const tcpPose = activeMotionStream.rapidlyChangingMotionState.tcp_pose
65
- if (!tcpPose) return ""
66
- return poseToWandelscriptString(tcpPose)
67
- }
14
+ export const PoseCartesianValues = externalizeComponent(
15
+ observer(({ tcpPose, showCopyButton = false }: PoseCartesianValuesProps) => {
16
+ const [copyMessage, setCopyMessage] = useState<string | null>(null)
17
+ const poseString = poseToWandelscriptString(tcpPose)
68
18
 
69
19
  const handleCopy = async () => {
70
20
  try {
71
- await navigator.clipboard.writeText(getCurrentPoseString())
21
+ await navigator.clipboard.writeText(poseString)
72
22
  setCopyMessage("Copied!")
73
- setTimeout(() => setCopyMessage(""), 2000)
23
+ setTimeout(() => setCopyMessage(null), 2000)
74
24
  } catch {
75
25
  setCopyMessage("Copy failed")
76
- setTimeout(() => setCopyMessage(""), 2000)
26
+ setTimeout(() => setCopyMessage(null), 2000)
77
27
  }
78
28
  }
79
29
 
80
- useAnimationFrame(() => {
81
- if (!poseHolderRef.current) {
82
- return
83
- }
84
- const newPoseContent = getCurrentPoseString()
85
- if (poseHolderRef.current.textContent === newPoseContent) {
86
- return
87
- }
88
-
89
- poseHolderRef.current.textContent = newPoseContent
90
- })
91
-
92
30
  return (
93
31
  <Stack
94
32
  direction="row"
95
33
  alignItems="center"
96
34
  spacing={1}
97
35
  sx={{ flexGrow: 1, minWidth: 0, overflow: "hidden" }}
36
+ data-testid="pose-cartesian-values"
98
37
  >
99
- <CopyableText value={getCurrentPoseString()} ref={poseHolderRef} />
38
+ <CopyableText value={poseString} />
100
39
  {showCopyButton && (
101
40
  <Button
102
41
  variant="contained"
@@ -105,15 +44,10 @@ export const PoseCartesianValues = observer(
105
44
  onClick={handleCopy}
106
45
  sx={{ flexShrink: 0 }}
107
46
  >
108
- Copy
47
+ { copyMessage ? copyMessage : "Copy"}
109
48
  </Button>
110
49
  )}
111
- {copyMessage && (
112
- <Typography variant="caption" color="success.main">
113
- {copyMessage}
114
- </Typography>
115
- )}
116
50
  </Stack>
117
51
  )
118
- },
52
+ }),
119
53
  )
@@ -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,12 +52,16 @@
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",
58
59
  "ProgramControl.Pause.bt": "Pause",
59
60
  "ProgramControl.Stop.bt": "Stopp",
61
+ "ProgramStateIndicator.Starting.lb": "Startet",
60
62
  "ProgramStateIndicator.Running.lb": "In Betrieb",
63
+ "ProgramStateIndicator.Pausing.lb": "Pausiert",
64
+ "ProgramStateIndicator.Stopping.lb": "Stoppt",
61
65
  "ProgramStateIndicator.Error.lb": "Fehler",
62
66
  "ProgramStateIndicator.EStop.lb": "Not-Aus",
63
67
  "ProgramStateIndicator.Idle.lb": "Leerlauf",
@@ -53,12 +53,16 @@
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",
59
60
  "ProgramControl.Pause.bt": "Pause",
60
61
  "ProgramControl.Stop.bt": "Stop",
62
+ "ProgramStateIndicator.Starting.lb": "Starting",
61
63
  "ProgramStateIndicator.Running.lb": "Running",
64
+ "ProgramStateIndicator.Pausing.lb": "Pausing",
65
+ "ProgramStateIndicator.Stopping.lb": "Stopping",
62
66
  "ProgramStateIndicator.Error.lb": "Error",
63
67
  "ProgramStateIndicator.EStop.lb": "E-Stop",
64
68
  "ProgramStateIndicator.Idle.lb": "Idle",
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"