@wandelbots/wandelbots-js-react-components 2.41.0-pr.feature-seperate-timer.383.20b279f → 2.41.0-pr.feature-seperate-timer.383.4d0d430

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "2.41.0-pr.feature-seperate-timer.383.20b279f",
3
+ "version": "2.41.0-pr.feature-seperate-timer.383.4d0d430",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,24 +1,57 @@
1
- import { Stack } from "@mui/material"
1
+ import { Button, Stack, Typography } from "@mui/material"
2
2
  import { poseToWandelscriptString } from "@wandelbots/nova-js"
3
3
  import type { TcpPose } from "@wandelbots/nova-js/v1"
4
4
  import { observer } from "mobx-react-lite"
5
+ import { useState } from "react"
5
6
  import { externalizeComponent } from "../../externalizeComponent"
6
7
  import { CopyableText } from "../CopyableText"
7
8
 
8
9
  export type PoseCartesianValuesProps = {
9
- pose: TcpPose
10
+ tcpPose: TcpPose
11
+ showCopyButton?: boolean
10
12
  }
11
13
 
12
14
  export const PoseCartesianValues = externalizeComponent(
13
- observer(({ pose }: PoseCartesianValuesProps) => {
15
+ observer(({ tcpPose, showCopyButton = false }: PoseCartesianValuesProps) => {
16
+ const [copyMessage, setCopyMessage] = useState("")
17
+ const poseString = poseToWandelscriptString(tcpPose)
18
+
19
+ const handleCopy = async () => {
20
+ try {
21
+ await navigator.clipboard.writeText(poseString)
22
+ setCopyMessage("Copied!")
23
+ setTimeout(() => setCopyMessage(""), 2000)
24
+ } catch {
25
+ setCopyMessage("Copy failed")
26
+ setTimeout(() => setCopyMessage(""), 2000)
27
+ }
28
+ }
29
+
14
30
  return (
15
31
  <Stack
16
- alignItems="left"
17
- spacing={2}
32
+ direction="row"
33
+ alignItems="center"
34
+ spacing={1}
18
35
  sx={{ flexGrow: 1, minWidth: 0, overflow: "hidden" }}
19
36
  data-testid="pose-cartesian-values"
20
37
  >
21
- <CopyableText value={poseToWandelscriptString(pose)} />
38
+ <CopyableText value={poseString} />
39
+ {showCopyButton && (
40
+ <Button
41
+ variant="contained"
42
+ color="secondary"
43
+ size="small"
44
+ onClick={handleCopy}
45
+ sx={{ flexShrink: 0 }}
46
+ >
47
+ Copy
48
+ </Button>
49
+ )}
50
+ {copyMessage && (
51
+ <Typography variant="caption" color="success.main">
52
+ {copyMessage}
53
+ </Typography>
54
+ )}
22
55
  </Stack>
23
56
  )
24
57
  }),
@@ -1,24 +1,56 @@
1
- import { Stack } from "@mui/material"
1
+ import { Button, Stack, Typography } from "@mui/material"
2
+ import type { Joints } from "@wandelbots/nova-api/v1"
2
3
  import { observer } from "mobx-react-lite"
4
+ import { useState } from "react"
3
5
  import { externalizeComponent } from "../../externalizeComponent"
4
6
  import { CopyableText } from "../CopyableText"
5
7
 
6
8
  export type PoseJointValuesProps = {
7
- pose: number[]
9
+ joints: Joints
10
+ showCopyButton?: boolean
8
11
  }
9
12
 
10
13
  export const PoseJointValues = externalizeComponent(
11
- observer(({ pose }: PoseJointValuesProps) => {
12
- const poseString = `[${pose.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
14
+ observer(({ joints, showCopyButton = false }: PoseJointValuesProps) => {
15
+ const [copyMessage, setCopyMessage] = useState("")
16
+ const poseString = `[${joints.joints.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
17
+
18
+ const handleCopy = async () => {
19
+ try {
20
+ await navigator.clipboard.writeText(poseString)
21
+ setCopyMessage("Copied!")
22
+ setTimeout(() => setCopyMessage(""), 2000)
23
+ } catch {
24
+ setCopyMessage("Copy failed")
25
+ setTimeout(() => setCopyMessage(""), 2000)
26
+ }
27
+ }
13
28
 
14
29
  return (
15
30
  <Stack
16
- alignItems="left"
17
- spacing={2}
31
+ direction="row"
32
+ alignItems="center"
33
+ spacing={1}
18
34
  sx={{ flexGrow: 1, minWidth: 0, overflow: "hidden" }}
19
35
  data-testid="pose-joint-values"
20
36
  >
21
37
  <CopyableText value={poseString} />
38
+ {showCopyButton && (
39
+ <Button
40
+ variant="contained"
41
+ color="secondary"
42
+ size="small"
43
+ onClick={handleCopy}
44
+ sx={{ flexShrink: 0 }}
45
+ >
46
+ Copy
47
+ </Button>
48
+ )}
49
+ {copyMessage && (
50
+ <Typography variant="caption" color="success.main">
51
+ {copyMessage}
52
+ </Typography>
53
+ )}
22
54
  </Stack>
23
55
  )
24
56
  }),