You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(core): support nested repeats with item paths (#319)
Resolve nested repeat state paths consistently across every renderer, validator, schema, prompt, and documentation surface.
Fixes#252
Co-authored-by: Trevin Chow <trevin@trevinchow.com>
Copy file name to clipboardExpand all lines: apps/web/app/(main)/docs/data-binding/page.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,7 +126,7 @@ The `repeat` field on an element renders its children once per item in a state a
126
126
}
127
127
```
128
128
129
-
-`repeat.statePath` — JSON Pointer to the state array
129
+
-`repeat.statePath`: root JSON Pointer to the state array, or `{ "$item": "field" }` for an array on the enclosing repeat item
130
130
-`repeat.key` — field name on each item to use as a stable key for rendering
131
131
132
132
Inside `todo-item`, `{ "$item": "title" }` reads the `title` field from whichever array item is currently being rendered. `{ "$index": true }` would return `0` for the first item, `1` for the second, and so on.
`validateSpec` checks structure beyond the catalog schema: missing or dangling `children` references, malformed `visible` conditions (anything outside the documented forms evaluates to hidden at runtime, so it is rejected with code `invalid_visible`), `repeat` containers with no children (`repeat_without_children`), and `repeat.statePath` values that do not reference an array in the spec's own `state` (`repeat_state_mismatch`).
559
+
`validateSpec` checks structure beyond the catalog schema: missing or dangling `children` references, malformed `visible` conditions (anything outside the documented forms evaluates to hidden at runtime, so it is rejected with code `invalid_visible`), `repeat` containers with no children (`repeat_without_children`), relative repeat paths outside an enclosing repeat (`repeat_item_outside_scope`), and `repeat.statePath` values that do not reference an array in the spec's own `state` (`repeat_state_mismatch`).
560
560
561
561
`autoFixSpec` distinguishes lossless fixes (relocating `visible`/`on`/`repeat`/`watch` out of `props`) from lossy ones (pruning `children` references to elements that were never defined). Each entry in `fixDetails` carries `{ message, lossy }`. Callers with a repair loop should apply lossless fixes immediately and prefer re-prompting over lossy fixes, passing `{ lossy: false }` to withhold pruning until retries are exhausted:
Copy file name to clipboardExpand all lines: packages/core/src/schema.ts
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -762,6 +762,9 @@ Note: state patches appear right after the elements that use them, so the UI fil
762
762
lines.push(
763
763
'The element itself renders once (as the container), and its children are expanded once per array item. "statePath" is the state array path. "key" is an optional field name on each item for stable React keys.',
764
764
);
765
+
lines.push(
766
+
'For nested lists, an inner repeat can read an array from the enclosing item with { "statePath": { "$item": "field" } }. This form is valid only inside another repeat. Use an empty field to repeat over the enclosing item itself.',
0 commit comments