@wandelbots/wandelbots-js-react-components 2.32.0 → 2.33.0-pr.feature-robot-precondition-list.372.3ad6c62

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 (45) hide show
  1. package/dist/components/CycleTimer.d.ts.map +1 -1
  2. package/dist/components/DataGrid.d.ts +61 -0
  3. package/dist/components/DataGrid.d.ts.map +1 -0
  4. package/dist/components/LogPanel.d.ts +38 -0
  5. package/dist/components/LogPanel.d.ts.map +1 -0
  6. package/dist/components/LogStore.d.ts +11 -0
  7. package/dist/components/LogStore.d.ts.map +1 -0
  8. package/dist/components/LogViewer.d.ts +26 -0
  9. package/dist/components/LogViewer.d.ts.map +1 -0
  10. package/dist/components/ProgramControl.d.ts +6 -1
  11. package/dist/components/ProgramControl.d.ts.map +1 -1
  12. package/dist/components/ProgramStateIndicator.d.ts +1 -1
  13. package/dist/components/ProgramStateIndicator.d.ts.map +1 -1
  14. package/dist/components/RobotCard.d.ts +84 -0
  15. package/dist/components/RobotCard.d.ts.map +1 -0
  16. package/dist/components/RobotListItem.d.ts +34 -0
  17. package/dist/components/RobotListItem.d.ts.map +1 -0
  18. package/dist/components/RobotSetupReadinessIndicator.d.ts +31 -0
  19. package/dist/components/RobotSetupReadinessIndicator.d.ts.map +1 -0
  20. package/dist/components/RobotSetupReadinessIndicator.test.d.ts +2 -0
  21. package/dist/components/RobotSetupReadinessIndicator.test.d.ts.map +1 -0
  22. package/dist/components/robots/Robot.d.ts +3 -2
  23. package/dist/components/robots/Robot.d.ts.map +1 -1
  24. package/dist/index.cjs +49 -49
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +8288 -7119
  29. package/dist/index.js.map +1 -1
  30. package/package.json +2 -1
  31. package/src/components/CycleTimer.tsx +43 -64
  32. package/src/components/DataGrid.tsx +454 -0
  33. package/src/components/LogPanel.tsx +69 -0
  34. package/src/components/LogStore.ts +40 -0
  35. package/src/components/LogViewer.tsx +311 -0
  36. package/src/components/ProgramControl.tsx +20 -10
  37. package/src/components/ProgramStateIndicator.tsx +20 -8
  38. package/src/components/RobotCard.tsx +576 -0
  39. package/src/components/RobotListItem.tsx +152 -0
  40. package/src/components/RobotSetupReadinessIndicator.test.tsx +60 -0
  41. package/src/components/RobotSetupReadinessIndicator.tsx +124 -0
  42. package/src/components/robots/Robot.tsx +5 -2
  43. package/src/i18n/locales/de/translations.json +6 -1
  44. package/src/i18n/locales/en/translations.json +6 -1
  45. package/src/index.ts +7 -0
@@ -0,0 +1,152 @@
1
+ import ErrorIcon from "@mui/icons-material/Error"
2
+ import { Box, Divider, Typography, useTheme } from "@mui/material"
3
+ import { observer } from "mobx-react-lite"
4
+ import type { ComponentType } from "react"
5
+ import { externalizeComponent } from "../externalizeComponent"
6
+ import { RobotIcon } from "../icons"
7
+ import {
8
+ RobotSetupReadinessIndicator,
9
+ RobotSetupReadinessState,
10
+ } from "./RobotSetupReadinessIndicator"
11
+
12
+ export interface RobotListItemProps {
13
+ /** The name of the robot */
14
+ robotName: string
15
+ /** The type/model of the robot (will try to derive from nova if not provided) */
16
+ robotType?: string
17
+ /** The current setup readiness state of the robot */
18
+ setupState: RobotSetupReadinessState
19
+ /**
20
+ * Component to render for the precondition indicator.
21
+ * Defaults to RobotSetupReadinessIndicator.
22
+ * Pass null or undefined to hide the indicator.
23
+ */
24
+ PreconditionComponent?: ComponentType<{
25
+ setupState: RobotSetupReadinessState
26
+ }> | null
27
+ /** Additional CSS class name */
28
+ className?: string
29
+ }
30
+
31
+ /**
32
+ * A list item component that displays robot information and setup readiness state.
33
+ *
34
+ * Features:
35
+ * - Shows robot name, type, and customizable precondition component
36
+ * - Color-coded icon based on readiness state (robot icon for ready, warning for issues)
37
+ * - Styled with consistent border, background, and spacing
38
+ * - Responsive layout with proper spacing and alignment
39
+ * - Flexible precondition component that can be customized or hidden
40
+ */
41
+ export const RobotListItem = externalizeComponent(
42
+ observer(
43
+ ({
44
+ robotName,
45
+ robotType,
46
+ setupState,
47
+ PreconditionComponent = RobotSetupReadinessIndicator,
48
+ className,
49
+ }: RobotListItemProps) => {
50
+ const theme = useTheme()
51
+
52
+ // Use provided robot type or default
53
+ const displayRobotType = robotType || "Robot"
54
+
55
+ const isReady = setupState === RobotSetupReadinessState.READY
56
+
57
+ return (
58
+ <Box
59
+ className={className}
60
+ sx={{
61
+ border:
62
+ "1px solid var(--secondary-_states-outlinedBorder, #FFFFFF1F)",
63
+ background: "var(--background-paper-elevation-8, #292B3E)",
64
+ height: 80,
65
+ minHeight: "80px",
66
+ borderRadius: "8px",
67
+ padding: "20px",
68
+ display: "flex",
69
+ alignItems: "center",
70
+ justifyContent: "space-between",
71
+ opacity: 1,
72
+ }}
73
+ >
74
+ <Box
75
+ sx={{
76
+ display: "flex",
77
+ alignItems: "center",
78
+ gap: 2,
79
+ flex: 1,
80
+ }}
81
+ >
82
+ {/* Robot/Warning Icon */}
83
+ {isReady ? (
84
+ <Box
85
+ sx={{
86
+ fontSize: 24,
87
+ display: "flex",
88
+ alignItems: "center",
89
+ justifyContent: "center",
90
+ width: 24,
91
+ height: 24,
92
+ "& svg": {
93
+ fill: "var(--primary-main, #8E56FC) !important",
94
+ },
95
+ "& svg path": {
96
+ fill: "var(--primary-main, #8E56FC) !important",
97
+ },
98
+ }}
99
+ >
100
+ <RobotIcon />
101
+ </Box>
102
+ ) : (
103
+ <ErrorIcon
104
+ sx={{
105
+ color: theme.palette.error.main,
106
+ fontSize: 24,
107
+ }}
108
+ />
109
+ )}
110
+
111
+ {/* Robot Name */}
112
+ <Typography
113
+ variant="body1"
114
+ sx={{
115
+ fontWeight: 500,
116
+ color: theme.palette.text.primary,
117
+ }}
118
+ >
119
+ {robotName}
120
+ </Typography>
121
+
122
+ {/* Divider */}
123
+ <Divider
124
+ orientation="vertical"
125
+ flexItem
126
+ sx={{
127
+ backgroundColor: theme.palette.text.secondary,
128
+ opacity: 0.3,
129
+ width: "1px",
130
+ }}
131
+ />
132
+
133
+ {/* Robot Type */}
134
+ <Typography
135
+ variant="body2"
136
+ sx={{
137
+ color: theme.palette.text.secondary,
138
+ }}
139
+ >
140
+ {displayRobotType}
141
+ </Typography>
142
+ </Box>
143
+
144
+ {/* Setup Readiness Indicator */}
145
+ {PreconditionComponent && (
146
+ <PreconditionComponent setupState={setupState} />
147
+ )}
148
+ </Box>
149
+ )
150
+ },
151
+ ),
152
+ )
@@ -0,0 +1,60 @@
1
+ import { render, screen } from "@testing-library/react"
2
+ import { describe, expect, it } from "vitest"
3
+ import {
4
+ RobotSetupReadinessIndicator,
5
+ RobotSetupReadinessState,
6
+ } from "./RobotSetupReadinessIndicator"
7
+
8
+ describe("RobotSetupReadinessIndicator", () => {
9
+ it("renders ready state correctly", () => {
10
+ render(
11
+ <RobotSetupReadinessIndicator
12
+ setupState={RobotSetupReadinessState.READY}
13
+ />,
14
+ )
15
+
16
+ expect(screen.getByText("Ready")).toBeInTheDocument()
17
+ })
18
+
19
+ it("renders robot disconnected state correctly", () => {
20
+ render(
21
+ <RobotSetupReadinessIndicator
22
+ setupState={RobotSetupReadinessState.ROBOT_DISCONNECTED}
23
+ />,
24
+ )
25
+
26
+ expect(screen.getByText("Robot disconnected")).toBeInTheDocument()
27
+ })
28
+
29
+ it("renders precondition not fulfilled state correctly", () => {
30
+ render(
31
+ <RobotSetupReadinessIndicator
32
+ setupState={RobotSetupReadinessState.PRECONDITION_NOT_FULFILLED}
33
+ />,
34
+ )
35
+
36
+ expect(screen.getByText("Precondition not fulfilled")).toBeInTheDocument()
37
+ })
38
+
39
+ it("applies correct CSS class when provided", () => {
40
+ const { container } = render(
41
+ <RobotSetupReadinessIndicator
42
+ setupState={RobotSetupReadinessState.READY}
43
+ className="test-class"
44
+ />,
45
+ )
46
+
47
+ expect(container.firstChild).toHaveClass("test-class")
48
+ })
49
+
50
+ it("renders indicator circle", () => {
51
+ render(
52
+ <RobotSetupReadinessIndicator
53
+ setupState={RobotSetupReadinessState.READY}
54
+ />,
55
+ )
56
+
57
+ // Check if the component is rendered - it's a chip, not a button
58
+ expect(screen.getByText("Ready")).toBeInTheDocument()
59
+ })
60
+ })
@@ -0,0 +1,124 @@
1
+ import { Box, Chip, Typography, useTheme } from "@mui/material"
2
+ import { observer } from "mobx-react-lite"
3
+ import { useTranslation } from "react-i18next"
4
+ import { externalizeComponent } from "../externalizeComponent"
5
+
6
+ /**
7
+ * Enum representing the robot setup readiness state
8
+ */
9
+ export enum RobotSetupReadinessState {
10
+ /** Preconditions are not fulfilled for robot operation */
11
+ PRECONDITION_NOT_FULFILLED = "PRECONDITION_NOT_FULFILLED",
12
+ /** Robot is disconnected from the system */
13
+ ROBOT_DISCONNECTED = "ROBOT_DISCONNECTED",
14
+ /** Robot is ready for operation */
15
+ READY = "READY",
16
+ }
17
+
18
+ export interface RobotSetupReadinessIndicatorProps {
19
+ /** The current setup readiness state of the robot */
20
+ setupState: RobotSetupReadinessState
21
+ /** Additional CSS class name */
22
+ className?: string
23
+ }
24
+
25
+ /**
26
+ * A state indicator component that displays the current robot setup readiness state.
27
+ *
28
+ * Features:
29
+ * - Shows three states: Precondition not fulfilled, Robot disconnected, Ready
30
+ * - Color-coded based on state (ready: tertiary/main, others: error/main)
31
+ * - Rendered as Material-UI filled chip with paper-elevation-11 background
32
+ * - Includes colored circle indicator (8px width)
33
+ * - Localization support via react-i18next
34
+ */
35
+ export const RobotSetupReadinessIndicator = externalizeComponent(
36
+ observer(({ setupState, className }: RobotSetupReadinessIndicatorProps) => {
37
+ const theme = useTheme()
38
+ const { t } = useTranslation()
39
+
40
+ const getStateInfo = () => {
41
+ switch (setupState) {
42
+ case RobotSetupReadinessState.READY:
43
+ return {
44
+ label: t("RobotSetupReadinessIndicator.Ready.lb"),
45
+ indicatorColor:
46
+ theme.palette.tertiary?.main || theme.palette.primary.main,
47
+ backgroundColor:
48
+ theme.palette.backgroundPaperElevation?.[11] ||
49
+ theme.palette.background.paper,
50
+ textColor: "var(--secondary-contrast, #FFFFFFDE)",
51
+ }
52
+ case RobotSetupReadinessState.ROBOT_DISCONNECTED:
53
+ return {
54
+ label: t("RobotSetupReadinessIndicator.RobotDisconnected.lb"),
55
+ indicatorColor: theme.palette.error.main,
56
+ backgroundColor:
57
+ theme.palette.backgroundPaperElevation?.[11] ||
58
+ theme.palette.background.paper,
59
+ textColor: "var(--secondary-contrast, #FFFFFFDE)",
60
+ }
61
+ case RobotSetupReadinessState.PRECONDITION_NOT_FULFILLED:
62
+ default:
63
+ return {
64
+ label: t(
65
+ "RobotSetupReadinessIndicator.PreconditionNotFulfilled.lb",
66
+ ),
67
+ indicatorColor: theme.palette.error.main,
68
+ backgroundColor:
69
+ theme.palette.backgroundPaperElevation?.[11] ||
70
+ theme.palette.background.paper,
71
+ textColor: "var(--secondary-contrast, #FFFFFFDE)",
72
+ }
73
+ }
74
+ }
75
+
76
+ const { label, indicatorColor, backgroundColor, textColor } = getStateInfo()
77
+
78
+ return (
79
+ <Chip
80
+ className={className}
81
+ label={
82
+ <Box
83
+ sx={{
84
+ display: "flex",
85
+ alignItems: "center",
86
+ gap: 1,
87
+ }}
88
+ >
89
+ <Box
90
+ sx={{
91
+ width: 8,
92
+ height: 8,
93
+ borderRadius: "50%",
94
+ backgroundColor: indicatorColor,
95
+ flexShrink: 0,
96
+ }}
97
+ />
98
+ <Typography
99
+ variant="body2"
100
+ sx={{
101
+ color: textColor,
102
+ fontSize: "0.75rem", // Smaller than body2
103
+ lineHeight: 1.2,
104
+ }}
105
+ >
106
+ {label}
107
+ </Typography>
108
+ </Box>
109
+ }
110
+ variant="filled"
111
+ sx={{
112
+ backgroundColor,
113
+ color: theme.palette.getContrastText(backgroundColor),
114
+ fontWeight: 500,
115
+ height: "auto",
116
+ "& .MuiChip-label": {
117
+ paddingX: 1.5,
118
+ paddingY: 0.5,
119
+ },
120
+ }}
121
+ />
122
+ )
123
+ }),
124
+ )
@@ -1,15 +1,16 @@
1
- import { type ThreeElements } from "@react-three/fiber"
1
+ import type { ThreeElements } from "@react-three/fiber"
2
2
 
3
3
  import type { ConnectedMotionGroup } from "@wandelbots/nova-js/v1"
4
4
  import type { Group } from "three"
5
- import { SupportedRobot } from "./SupportedRobot"
6
5
  import { defaultGetModel } from "./robotModelLogic"
6
+ import { SupportedRobot } from "./SupportedRobot"
7
7
 
8
8
  export type RobotProps = {
9
9
  connectedMotionGroup: ConnectedMotionGroup
10
10
  getModel?: (modelFromController: string) => string
11
11
  flangeRef?: React.Ref<Group>
12
12
  transparentColor?: string
13
+ postModelRender?: () => void
13
14
  } & ThreeElements["group"]
14
15
 
15
16
  /**
@@ -28,6 +29,7 @@ export function Robot({
28
29
  getModel = defaultGetModel,
29
30
  flangeRef,
30
31
  transparentColor,
32
+ postModelRender,
31
33
  ...props
32
34
  }: RobotProps) {
33
35
  if (!connectedMotionGroup.dhParameters) {
@@ -44,6 +46,7 @@ export function Robot({
44
46
  getModel={getModel}
45
47
  flangeRef={flangeRef}
46
48
  transparentColor={transparentColor}
49
+ postModelRender={postModelRender}
47
50
  {...props}
48
51
  />
49
52
  )
@@ -61,5 +61,10 @@
61
61
  "ProgramStateIndicator.Auto.lb": "Auto",
62
62
  "ProgramStateIndicator.Manual.lb": "Manuell",
63
63
  "ProgramStateIndicator.ManualT1.lb": "Manuell T1",
64
- "ProgramStateIndicator.ManualT2.lb": "Manuell T2"
64
+ "ProgramStateIndicator.ManualT2.lb": "Manuell T2",
65
+ "RobotSetupReadinessIndicator.Ready.lb": "Bereit",
66
+ "RobotSetupReadinessIndicator.RobotDisconnected.lb": "Roboter getrennt",
67
+ "RobotSetupReadinessIndicator.PreconditionNotFulfilled.lb": "Voraussetzung nicht erfüllt",
68
+ "RobotCard.Runtime.lb": "Laufzeit",
69
+ "RobotCard.DriveToHome.bt": "Zur Home-Position fahren"
65
70
  }
@@ -62,5 +62,10 @@
62
62
  "ProgramStateIndicator.Auto.lb": "Auto",
63
63
  "ProgramStateIndicator.Manual.lb": "Manual",
64
64
  "ProgramStateIndicator.ManualT1.lb": "Manual T1",
65
- "ProgramStateIndicator.ManualT2.lb": "Manual T2"
65
+ "ProgramStateIndicator.ManualT2.lb": "Manual T2",
66
+ "RobotSetupReadinessIndicator.Ready.lb": "Ready",
67
+ "RobotSetupReadinessIndicator.RobotDisconnected.lb": "Robot disconnected",
68
+ "RobotSetupReadinessIndicator.PreconditionNotFulfilled.lb": "Precondition not fulfilled",
69
+ "RobotCard.Runtime.lb": "Runtime",
70
+ "RobotCard.DriveToHome.bt": "Drive to Home"
66
71
  }
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./components/3d-viewport/PresetEnvironment"
2
2
  export * from "./components/3d-viewport/SafetyZonesRenderer"
3
3
  export * from "./components/3d-viewport/TrajectoryRenderer"
4
4
  export * from "./components/CycleTimer"
5
+ export * from "./components/DataGrid"
5
6
  export * from "./components/jogging/JoggingCartesianAxisControl"
6
7
  export * from "./components/jogging/JoggingJointRotationControl"
7
8
  export * from "./components/jogging/JoggingPanel"
@@ -9,13 +10,19 @@ export { JoggingStore } from "./components/jogging/JoggingStore"
9
10
  export * from "./components/jogging/PoseCartesianValues"
10
11
  export * from "./components/jogging/PoseJointValues"
11
12
  export * from "./components/LoadingCover"
13
+ export * from "./components/LogPanel"
14
+ export { LogStore } from "./components/LogStore"
15
+ export * from "./components/LogViewer"
12
16
  export * from "./components/modal/NoMotionGroupModal"
13
17
  export * from "./components/ProgramControl"
14
18
  export * from "./components/ProgramStateIndicator"
19
+ export * from "./components/RobotCard"
20
+ export * from "./components/RobotListItem"
15
21
  export * from "./components/robots/AxisConfig"
16
22
  export * from "./components/robots/Robot"
17
23
  export { defaultGetModel } from "./components/robots/robotModelLogic"
18
24
  export * from "./components/robots/SupportedRobot"
25
+ export * from "./components/RobotSetupReadinessIndicator"
19
26
  export * from "./components/safetyBar/SafetyBar"
20
27
  export * from "./components/SelectableFab"
21
28
  export * from "./components/utils/hooks"