@wandelbots/wandelbots-js-react-components 2.33.0-pr.feature-robot-precondition-list.372.9858a50 → 2.33.0-pr.feature-robot-precondition-list.372.03b3aa0

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.33.0-pr.feature-robot-precondition-list.372.9858a50",
3
+ "version": "2.33.0-pr.feature-robot-precondition-list.372.03b3aa0",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -17,7 +17,7 @@ import {
17
17
  useGridApiRef,
18
18
  } from "@mui/x-data-grid"
19
19
  import { observer } from "mobx-react-lite"
20
- import { useEffect, useMemo, useState } from "react"
20
+ import { useEffect, useMemo, useRef, useState } from "react"
21
21
  import { externalizeComponent } from "../externalizeComponent"
22
22
 
23
23
  export interface WandelbotsDataGridProps<T = Record<string, unknown>> {
@@ -110,6 +110,7 @@ export const WandelbotsDataGrid = externalizeComponent(
110
110
  }: WandelbotsDataGridProps<T>) => {
111
111
  const theme = useTheme()
112
112
  const apiRef = useGridApiRef()
113
+ const containerRef = useRef<HTMLDivElement>(null)
113
114
 
114
115
  // Internal state for selection when not controlled
115
116
  const [internalSelectedItem, setInternalSelectedItem] =
@@ -130,6 +131,31 @@ export const WandelbotsDataGrid = externalizeComponent(
130
131
  }
131
132
  }, [rows, columns, apiRef])
132
133
 
134
+ // Auto-resize columns when the DataGrid container is resized
135
+ useEffect(() => {
136
+ if (!containerRef.current || !apiRef.current) return
137
+
138
+ const resizeObserver = new ResizeObserver(() => {
139
+ // Use a small timeout to ensure the DataGrid has processed the size change
140
+ setTimeout(() => {
141
+ if (apiRef.current && rows.length > 0) {
142
+ apiRef.current.autosizeColumns({
143
+ includeOutliers: true,
144
+ includeHeaders: true,
145
+ expand: true,
146
+ columns: columns.map((col) => col.field),
147
+ })
148
+ }
149
+ }, 100)
150
+ })
151
+
152
+ resizeObserver.observe(containerRef.current)
153
+
154
+ return () => {
155
+ resizeObserver.disconnect()
156
+ }
157
+ }, [apiRef, rows.length, columns])
158
+
133
159
  // Handle default selection - only use if no selectedItem is explicitly provided
134
160
  const effectiveSelectedItem = useMemo(() => {
135
161
  // If selectedItem is explicitly provided, use it (including null)
@@ -401,6 +427,7 @@ export const WandelbotsDataGrid = externalizeComponent(
401
427
 
402
428
  return (
403
429
  <Box
430
+ ref={containerRef}
404
431
  sx={{
405
432
  height: "100%",
406
433
  display: "flex",
@@ -227,7 +227,7 @@ export const RobotCard = externalizeComponent(
227
227
  // Determine if runtime view should be hidden when height is too low
228
228
  // Runtime should be hidden BEFORE the robot (at higher threshold)
229
229
  const shouldHideRuntime = isLandscape
230
- ? cardSize.height < 350 // Landscape: hide runtime at height < 350px
230
+ ? cardSize.height < 310 // Landscape: hide runtime at height < 350px
231
231
  : cardSize.height < 450 // Portrait: hide runtime at height < 450px
232
232
 
233
233
  return (