@wandelbots/wandelbots-js-react-components 2.32.0-pr.feature-robot-precondition-list.372.5d8a86e → 2.32.0-pr.feature-robot-precondition-list.372.5bce944
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/dist/components/RobotCard.d.ts +12 -1
- package/dist/components/RobotCard.d.ts.map +1 -1
- package/dist/index.cjs +29 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3601 -3602
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/RobotCard.tsx +39 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "2.32.0-pr.feature-robot-precondition-list.372.
|
|
3
|
+
"version": "2.32.0-pr.feature-robot-precondition-list.372.5bce944",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Button,
|
|
4
|
-
Card,
|
|
5
|
-
Divider,
|
|
6
|
-
Typography,
|
|
7
|
-
useMediaQuery,
|
|
8
|
-
useTheme,
|
|
9
|
-
} from "@mui/material"
|
|
1
|
+
import { Box, Button, Card, Divider, Typography, useTheme } from "@mui/material"
|
|
10
2
|
import { Bounds, useBounds } from "@react-three/drei"
|
|
11
3
|
import { Canvas } from "@react-three/fiber"
|
|
12
4
|
import type {
|
|
@@ -29,24 +21,17 @@ import { Robot } from "./robots/Robot"
|
|
|
29
21
|
function BoundsRefresher({
|
|
30
22
|
modelRenderTrigger,
|
|
31
23
|
children,
|
|
32
|
-
isPortrait = false,
|
|
33
24
|
}: {
|
|
34
25
|
modelRenderTrigger: number
|
|
35
26
|
children: React.ReactNode
|
|
36
|
-
isPortrait?: boolean
|
|
37
27
|
}) {
|
|
38
28
|
const bounds = useBounds()
|
|
39
29
|
|
|
40
30
|
useEffect(() => {
|
|
41
31
|
if (modelRenderTrigger > 0) {
|
|
42
|
-
|
|
43
|
-
if (isPortrait) {
|
|
44
|
-
bounds.refresh().clip().fit()
|
|
45
|
-
} else {
|
|
46
|
-
bounds.refresh().clip().fit()
|
|
47
|
-
}
|
|
32
|
+
bounds.refresh().clip().fit()
|
|
48
33
|
}
|
|
49
|
-
}, [modelRenderTrigger, bounds
|
|
34
|
+
}, [modelRenderTrigger, bounds])
|
|
50
35
|
|
|
51
36
|
return <>{children}</>
|
|
52
37
|
}
|
|
@@ -90,6 +75,17 @@ export interface RobotCardProps {
|
|
|
90
75
|
autoStart?: boolean
|
|
91
76
|
className?: string
|
|
92
77
|
}>
|
|
78
|
+
/** Callback to receive cycle timer controls for external timer management */
|
|
79
|
+
onCycleTimerReady?: (controls: {
|
|
80
|
+
startNewCycle: (maxTimeSeconds: number, elapsedSeconds?: number) => void
|
|
81
|
+
pause: () => void
|
|
82
|
+
resume: () => void
|
|
83
|
+
isPaused: () => boolean
|
|
84
|
+
}) => void
|
|
85
|
+
/** Callback fired when a cycle completes (reaches zero) */
|
|
86
|
+
onCycleEnd?: () => void
|
|
87
|
+
/** Whether the cycle timer should auto-start when a new cycle is set */
|
|
88
|
+
cycleTimerAutoStart?: boolean
|
|
93
89
|
/** Additional CSS class name */
|
|
94
90
|
className?: string
|
|
95
91
|
}
|
|
@@ -131,6 +127,9 @@ export const RobotCard = externalizeComponent(
|
|
|
131
127
|
connectedMotionGroup,
|
|
132
128
|
robotComponent: RobotComponent = Robot,
|
|
133
129
|
cycleTimerComponent: CycleTimerComponent = CycleTimer,
|
|
130
|
+
onCycleTimerReady,
|
|
131
|
+
onCycleEnd,
|
|
132
|
+
cycleTimerAutoStart = true,
|
|
134
133
|
className,
|
|
135
134
|
}: RobotCardProps) => {
|
|
136
135
|
const theme = useTheme()
|
|
@@ -146,9 +145,13 @@ export const RobotCard = externalizeComponent(
|
|
|
146
145
|
}>({ width: 400, height: 600 })
|
|
147
146
|
const [modelRenderTrigger, setModelRenderTrigger] = useState(0)
|
|
148
147
|
|
|
149
|
-
//
|
|
150
|
-
const
|
|
151
|
-
|
|
148
|
+
// Store cycle timer controls for external control
|
|
149
|
+
const cycleControlsRef = useRef<{
|
|
150
|
+
startNewCycle: (maxTimeSeconds: number, elapsedSeconds?: number) => void
|
|
151
|
+
pause: () => void
|
|
152
|
+
resume: () => void
|
|
153
|
+
isPaused: () => boolean
|
|
154
|
+
} | null>(null)
|
|
152
155
|
|
|
153
156
|
// Hook to detect aspect ratio and size changes
|
|
154
157
|
useEffect(() => {
|
|
@@ -198,9 +201,9 @@ export const RobotCard = externalizeComponent(
|
|
|
198
201
|
}
|
|
199
202
|
}, [isDriveToHomePressed, onDriveToHomeRelease])
|
|
200
203
|
|
|
201
|
-
//
|
|
204
|
+
// Store and provide cycle timer controls for external use
|
|
202
205
|
const handleCycleComplete = useCallback(
|
|
203
|
-
(
|
|
206
|
+
(controls: {
|
|
204
207
|
startNewCycle: (
|
|
205
208
|
maxTimeSeconds: number,
|
|
206
209
|
elapsedSeconds?: number,
|
|
@@ -209,10 +212,15 @@ export const RobotCard = externalizeComponent(
|
|
|
209
212
|
resume: () => void
|
|
210
213
|
isPaused: () => boolean
|
|
211
214
|
}) => {
|
|
212
|
-
//
|
|
213
|
-
|
|
215
|
+
// Store the controls for potential future use
|
|
216
|
+
cycleControlsRef.current = controls
|
|
217
|
+
|
|
218
|
+
// Notify parent component that timer controls are ready
|
|
219
|
+
if (onCycleTimerReady) {
|
|
220
|
+
onCycleTimerReady(controls)
|
|
221
|
+
}
|
|
214
222
|
},
|
|
215
|
-
[],
|
|
223
|
+
[onCycleTimerReady],
|
|
216
224
|
)
|
|
217
225
|
|
|
218
226
|
// Determine if robot should be hidden at small sizes to save space
|
|
@@ -301,10 +309,7 @@ export const RobotCard = externalizeComponent(
|
|
|
301
309
|
>
|
|
302
310
|
<PresetEnvironment />
|
|
303
311
|
<Bounds fit clip observe margin={1}>
|
|
304
|
-
<BoundsRefresher
|
|
305
|
-
modelRenderTrigger={modelRenderTrigger}
|
|
306
|
-
isPortrait={false}
|
|
307
|
-
>
|
|
312
|
+
<BoundsRefresher modelRenderTrigger={modelRenderTrigger}>
|
|
308
313
|
<group ref={robotRef} scale={robotScale}>
|
|
309
314
|
<RobotComponent
|
|
310
315
|
connectedMotionGroup={connectedMotionGroup}
|
|
@@ -375,6 +380,8 @@ export const RobotCard = externalizeComponent(
|
|
|
375
380
|
variant="small"
|
|
376
381
|
compact
|
|
377
382
|
onCycleComplete={handleCycleComplete}
|
|
383
|
+
onCycleEnd={onCycleEnd}
|
|
384
|
+
autoStart={cycleTimerAutoStart}
|
|
378
385
|
/>
|
|
379
386
|
</Box>
|
|
380
387
|
|
|
@@ -484,7 +491,6 @@ export const RobotCard = externalizeComponent(
|
|
|
484
491
|
<Bounds fit observe margin={1}>
|
|
485
492
|
<BoundsRefresher
|
|
486
493
|
modelRenderTrigger={modelRenderTrigger}
|
|
487
|
-
isPortrait={true}
|
|
488
494
|
>
|
|
489
495
|
<group ref={robotRef} scale={robotScale}>
|
|
490
496
|
<RobotComponent
|
|
@@ -516,6 +522,8 @@ export const RobotCard = externalizeComponent(
|
|
|
516
522
|
variant="small"
|
|
517
523
|
compact
|
|
518
524
|
onCycleComplete={handleCycleComplete}
|
|
525
|
+
onCycleEnd={onCycleEnd}
|
|
526
|
+
autoStart={cycleTimerAutoStart}
|
|
519
527
|
/>
|
|
520
528
|
|
|
521
529
|
{/* Divider */}
|