@wandelbots/wandelbots-js-react-components 2.34.1-pr.feature-robot-precondition-list.372.a71f99a → 2.34.1-pr.feature-robot-precondition-list.372.90c151f
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/CycleTimer.d.ts +13 -1
- package/dist/components/CycleTimer.d.ts.map +1 -1
- package/dist/index.cjs +35 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2014 -2004
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CycleTimer.tsx +51 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "2.34.1-pr.feature-robot-precondition-list.372.
|
|
3
|
+
"version": "2.34.1-pr.feature-robot-precondition-list.372.90c151f",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,6 +30,8 @@ export interface CycleTimerProps {
|
|
|
30
30
|
compact?: boolean
|
|
31
31
|
/** Additional CSS classes */
|
|
32
32
|
className?: string
|
|
33
|
+
/** Whether the timer is in an error state (pauses timer and shows error styling) */
|
|
34
|
+
hasError?: boolean
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -44,6 +46,7 @@ export interface CycleTimerProps {
|
|
|
44
46
|
* - Automatically counts down/up and triggers callback when reaching zero (count-down only)
|
|
45
47
|
* - Full timer control: start, pause, resume functionality
|
|
46
48
|
* - Support for starting with elapsed time (resume mid-cycle)
|
|
49
|
+
* - Error state support: pauses timer and shows error styling (red color)
|
|
47
50
|
* - Smooth spring-based progress animations for all state transitions
|
|
48
51
|
* - Fully localized with i18next
|
|
49
52
|
* - Material-UI theming integration
|
|
@@ -55,6 +58,7 @@ export interface CycleTimerProps {
|
|
|
55
58
|
* @param variant - Visual variant: "default" (large gauge) or "small" (animated icon with text)
|
|
56
59
|
* @param compact - For small variant: whether to hide remaining time details
|
|
57
60
|
* @param className - Additional CSS classes
|
|
61
|
+
* @param hasError - Whether the timer is in an error state (pauses timer and shows error styling)
|
|
58
62
|
*
|
|
59
63
|
* Usage:
|
|
60
64
|
* ```tsx
|
|
@@ -80,6 +84,14 @@ export interface CycleTimerProps {
|
|
|
80
84
|
* controls.startNewCycle(undefined, 120)
|
|
81
85
|
* }}
|
|
82
86
|
* />
|
|
87
|
+
*
|
|
88
|
+
* // Timer with error state
|
|
89
|
+
* <CycleTimer
|
|
90
|
+
* hasError={errorCondition}
|
|
91
|
+
* onCycleComplete={(controls) => {
|
|
92
|
+
* controls.startNewCycle(300)
|
|
93
|
+
* }}
|
|
94
|
+
* />
|
|
83
95
|
* ```
|
|
84
96
|
*
|
|
85
97
|
* Control Functions:
|
|
@@ -97,6 +109,7 @@ export const CycleTimer = externalizeComponent(
|
|
|
97
109
|
variant = "default",
|
|
98
110
|
compact = false,
|
|
99
111
|
className,
|
|
112
|
+
hasError = false,
|
|
100
113
|
}: CycleTimerProps) => {
|
|
101
114
|
const theme = useTheme()
|
|
102
115
|
const { t } = useTranslation()
|
|
@@ -108,6 +121,7 @@ export const CycleTimer = externalizeComponent(
|
|
|
108
121
|
const animationRef = useRef<number | null>(null)
|
|
109
122
|
const startTimeRef = useRef<number | null>(null)
|
|
110
123
|
const pausedTimeRef = useRef<number>(0)
|
|
124
|
+
const [wasRunningBeforeError, setWasRunningBeforeError] = useState(false)
|
|
111
125
|
|
|
112
126
|
// Track mode changes for fade transitions
|
|
113
127
|
const [showLabels, setShowLabels] = useState(true)
|
|
@@ -236,6 +250,30 @@ export const CycleTimer = externalizeComponent(
|
|
|
236
250
|
return isPausedState
|
|
237
251
|
}, [isPausedState])
|
|
238
252
|
|
|
253
|
+
// Handle error state changes
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (hasError) {
|
|
256
|
+
// Error occurred - pause timer if running and remember state
|
|
257
|
+
if (isRunning && !isPausedState) {
|
|
258
|
+
setWasRunningBeforeError(true)
|
|
259
|
+
pause()
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
// Error resolved - resume if was running before error
|
|
263
|
+
if (wasRunningBeforeError && isPausedState) {
|
|
264
|
+
setWasRunningBeforeError(false)
|
|
265
|
+
resume()
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}, [
|
|
269
|
+
hasError,
|
|
270
|
+
isRunning,
|
|
271
|
+
isPausedState,
|
|
272
|
+
wasRunningBeforeError,
|
|
273
|
+
pause,
|
|
274
|
+
resume,
|
|
275
|
+
])
|
|
276
|
+
|
|
239
277
|
// Call onCycleComplete immediately to provide the timer control functions
|
|
240
278
|
useEffect(() => {
|
|
241
279
|
let isMounted = true
|
|
@@ -405,7 +443,11 @@ export const CycleTimer = externalizeComponent(
|
|
|
405
443
|
cy="10"
|
|
406
444
|
r="8"
|
|
407
445
|
fill="none"
|
|
408
|
-
stroke={
|
|
446
|
+
stroke={
|
|
447
|
+
hasError
|
|
448
|
+
? theme.palette.error.light
|
|
449
|
+
: theme.palette.success.main
|
|
450
|
+
}
|
|
409
451
|
strokeWidth="2"
|
|
410
452
|
opacity={0.3}
|
|
411
453
|
/>
|
|
@@ -415,7 +457,11 @@ export const CycleTimer = externalizeComponent(
|
|
|
415
457
|
cy="10"
|
|
416
458
|
r="8"
|
|
417
459
|
fill="none"
|
|
418
|
-
stroke={
|
|
460
|
+
stroke={
|
|
461
|
+
hasError
|
|
462
|
+
? theme.palette.error.light
|
|
463
|
+
: theme.palette.success.main
|
|
464
|
+
}
|
|
419
465
|
strokeWidth="2"
|
|
420
466
|
strokeLinecap="round"
|
|
421
467
|
strokeDasharray={`${2 * Math.PI * 8}`}
|
|
@@ -475,7 +521,9 @@ export const CycleTimer = externalizeComponent(
|
|
|
475
521
|
opacity: isPausedState ? 0.6 : 1,
|
|
476
522
|
transition: "opacity 0.2s ease",
|
|
477
523
|
[`& .MuiGauge-valueArc`]: {
|
|
478
|
-
fill:
|
|
524
|
+
fill: hasError
|
|
525
|
+
? theme.palette.error.light
|
|
526
|
+
: theme.palette.success.main,
|
|
479
527
|
},
|
|
480
528
|
[`& .MuiGauge-referenceArc`]: {
|
|
481
529
|
fill: "white",
|