@theoremjs/react 0.3.4-next.608.gd007c52 → 0.3.4-next.610.g6ddf39d

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": "@theoremjs/react",
3
- "version": "0.3.4-next.608.gd007c52",
3
+ "version": "0.3.4-next.610.g6ddf39d",
4
4
  "description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -60,8 +60,8 @@
60
60
  "@stylexjs/stylex": "0.19.0",
61
61
  "react": "^19.0.0",
62
62
  "react-dom": "^19.0.0",
63
- "@theoremjs/agents": "^0.3.4-next.608.gd007c52",
64
- "@theoremjs/web": "^0.3.4-next.608.gd007c52"
63
+ "@theoremjs/agents": "^0.3.4-next.610.g6ddf39d",
64
+ "@theoremjs/web": "^0.3.4-next.610.g6ddf39d"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
package/ui/CardWall.js CHANGED
@@ -22,6 +22,21 @@ export function CardWall({ minWidth, children }) {
22
22
  const wallRef = useRef(null);
23
23
  const slots = useRef([]);
24
24
  const observer = useRef(null);
25
+ const slotRefs = useRef([]);
26
+ // why: One callback per place, so a re-render does not detach and watch every slot again.
27
+ const slotRef = (at) => {
28
+ slotRefs.current[at] ??= (slot) => {
29
+ slots.current[at] = slot;
30
+ // why: A card that mounts later is measured once it is watched.
31
+ if (slot)
32
+ observer.current?.observe(slot);
33
+ return () => {
34
+ if (slot)
35
+ observer.current?.unobserve(slot);
36
+ };
37
+ };
38
+ return slotRefs.current[at];
39
+ };
25
40
  const [wall, setWall] = useState({ width: 0, gap: 0, heights: [] });
26
41
  const count = columnCount(wall.width, minWidth, wall.gap);
27
42
  const columnWidth = (wall.width - wall.gap * (count - 1)) / count;
@@ -55,16 +70,7 @@ export function CardWall({ minWidth, children }) {
55
70
  }, []);
56
71
  return (_jsx(VStack, { ref: wallRef, gap: 3, style: isPlaced ? { position: 'relative', height } : undefined, children: cards.map((card, at) => {
57
72
  const place = places[at];
58
- return (_jsx("div", { ref: (slot) => {
59
- slots.current[at] = slot;
60
- // why: A card that mounts later is measured once it is watched.
61
- if (slot)
62
- observer.current?.observe(slot);
63
- return () => {
64
- if (slot)
65
- observer.current?.unobserve(slot);
66
- };
67
- }, style: isPlaced && place
73
+ return (_jsx("div", { ref: slotRef(at), style: isPlaced && place
68
74
  ? {
69
75
  position: 'absolute',
70
76
  top: place.top,
package/ui/ToolResult.js CHANGED
@@ -32,7 +32,7 @@ function ResultLead({ layout, parts = [], }) {
32
32
  if (!hasLead(layout, media))
33
33
  return null;
34
34
  const { images, audio } = media;
35
- return (_jsxs(VStack, { gap: 3, children: [_jsxs(CardWall, { minWidth: CARD_PX, children: [layout.figures.map((figure) => (_jsx(Arrive, { children: _jsx(ChartCard, { title: figure.label, value: withUnit(decimal.format(figure.value), figure.unit) }) }, `figure:${figure.key}`))), layout.charts.map((chart) => (_jsx(Arrive, { children: _jsx(Suspense, { fallback: _jsx(Skeleton, { height: CHART_CARD_PX }), children: _jsx(ToolResultChart, { chart: chart }) }) }, `chart:${chart.key}`))), images.map((image, index) => (_jsx(Arrive, { children: _jsx(ClickableCard, { label: image.alt || 'Open image', padding: 0, onClick: () => setOpen(index), children: _jsx(AspectRatio, { ratio: 4 / 3, fit: "cover", children: _jsx("img", { src: image.src, alt: image.alt, loading: "lazy" }) }) }) }, `image:${image.src}`)))] }), images.length > 0 ? (_jsx(Lightbox, { isOpen: open !== null, onOpenChange: (isOpen) => {
35
+ return (_jsxs(VStack, { gap: 3, children: [_jsxs(CardWall, { minWidth: CARD_PX, children: [layout.figures.map((figure) => (_jsx(Arrive, { children: _jsx(ChartCard, { title: figure.label, value: withUnit(decimal.format(figure.value), figure.unit) }) }, `figure:${figure.key}`))), layout.charts.map((chart) => (_jsx(Suspense, { fallback: _jsx(Arrive, { children: _jsx(Skeleton, { height: CHART_CARD_PX }) }), children: _jsx(Arrive, { children: _jsx(ToolResultChart, { chart: chart }) }) }, `chart:${chart.key}`))), images.map((image, index) => (_jsx(Arrive, { children: _jsx(ClickableCard, { label: image.alt || 'Open image', padding: 0, onClick: () => setOpen(index), children: _jsx(AspectRatio, { ratio: 4 / 3, fit: "cover", children: _jsx("img", { src: image.src, alt: image.alt, loading: "lazy" }) }) }) }, `image:${image.src}`)))] }), images.length > 0 ? (_jsx(Lightbox, { isOpen: open !== null, onOpenChange: (isOpen) => {
36
36
  if (!isOpen)
37
37
  setOpen(null);
38
38
  }, media: images.map((image) => ({ src: image.src, alt: image.alt })), index: open ?? 0, onIndexChange: setOpen })) : null, keyedByContent(audio, (clip) => clip.src).map(({ item: clip, key }) => (_jsx(Arrive, { children: _jsx(VoiceNote, { src: clip.src, mimeType: clip.mimeType }) }, key)))] }));