Skip to content

Commit 1db960c

Browse files
committed
docs,changeset: the stack, flex and grid gap sets on their reference pages; one minor changeset
Claude-Session: https://claude.ai/code/session_01XvhGmGAP79ZB8swnkapxPC Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7cf1c8b commit 1db960c

4 files changed

Lines changed: 62 additions & 3 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
'@object-ui/types': minor
3+
'@object-ui/components': minor
4+
'@object-ui/core': minor
5+
---
6+
7+
The `gap` of a `stack`, a `flex` and a `grid` node is one of the steps its renderer maps.
8+
Any other number is refused at validation, with the set named (objectui#11474).
9+
10+
| node | accepted `gap` steps | default |
11+
|---|---|---|
12+
| `stack` | 0, 1, 2, 3, 4, 5, 6, 8, 10 | 2 |
13+
| `flex` | 0, 1, 2, 3, 4, 5, 6, 7, 8 | 2 |
14+
| `grid` | 0, 1, 2, 3, 4, 5, 6, 8, 10, 12 | 4 |
15+
16+
**Breaking for a `stack`, `flex` or `grid` that carries any other `gap` number.** The key
17+
was declared as any number, and the `flex` and `grid` descriptions advertised "Tailwind
18+
scale 0-8". But each renderer has one gap class per step and nothing for the rest:
19+
`{ "type": "stack", "gap": 7 }` and `{ "type": "flex", "properties": { "gap": 9 } }` parsed
20+
clean and rendered with no gap class at all, not even the default, because the default
21+
applies only when the key is absent. A `grid` built a gap class at runtime for such a
22+
number, and no compiled stylesheet defines a class built that way, so it rendered with no
23+
gap either.
24+
25+
- `@object-ui/types`: `StackSchema.gap`, `FlexLayoutProps.gap` (which `FlexSchema` and the
26+
authored `flex` bag share) and `GridSchema.gap` are literal unions of the steps above on
27+
the TypeScript face, so `tsc` refuses any other number. The zod mirrors refuse one at the
28+
key (`invalid_value`, with the steps in the issue), with a message that lists the set. For
29+
`flex` that is `properties.gap`, and the flat spelling stays refused by name.
30+
`safeValidateSchema` (what `objectui validate` runs) and the strict authoring face both
31+
give that refusal. A `gap` that is not a number at all is now reported as `invalid_value`
32+
rather than `invalid_type`.
33+
- `@object-ui/components`: the `gap` input of the `stack`, `flex` and `grid` registrations
34+
changes from `type: 'number'` to a closed `enum` of the same steps, in the object form the
35+
`container` registration's `padding` already uses. In the SDUI manifest, `validateTree`
36+
now answers an unlisted number with `invalid-enum`. The renderers are unchanged: they do
37+
not round or clamp, and an absent key still renders the default step.
38+
- `@object-ui/core`: `GridBuilder.gap()` and `FlexBuilder.gap()` take the declared steps
39+
instead of any number.
40+
41+
Migration: replace the number with the step you meant from that node's set. `0` means no
42+
gap.

‎content/docs/components/layout/flex.mdx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface FlexNode {
4040
className?: string;
4141
properties?: {
4242
direction?: 'row' | 'col' | 'row-reverse' | 'col-reverse';
43-
gap?: number;
43+
gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; // default: 2
4444
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
4545
justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly';
4646
wrap?: boolean;
@@ -52,3 +52,8 @@ interface FlexNode {
5252
Nothing changes at render time: `SchemaRenderer` hoists every `properties` key onto the node
5353
before the `flex` renderer reads it, so a stored node that still writes these props flat keeps
5454
rendering.
55+
56+
`gap` is a step on the flex spacing scale, 0 to 8, and `0` means none. Those are the steps the
57+
renderer maps to a gap class, so they are the only values validation accepts:
58+
`"properties": { "gap": 9 }` is refused with the set named (objectui#11474). Such a number
59+
used to pass validation and then render with no gap at all, not even the default.

‎content/docs/components/layout/grid.mdx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ import type { SchemaNode } from '@object-ui/types';
1515
interface GridSchema {
1616
type: 'grid';
1717
columns?: number;
18-
gap?: number;
18+
gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12; // default: 4
1919
children: SchemaNode[];
2020
className?: string;
2121
}
2222
```
23+
24+
`gap` is a step on the grid's spacing scale, and `0` means none. The ten steps are the ones
25+
the renderer maps to a gap class, so they are the only values validation accepts: `"gap": 9`
26+
or `"gap": 16` is refused with the set named (objectui#11474). For such a number the renderer
27+
used to build a gap class at runtime that no compiled stylesheet defines, so the grid rendered
28+
with no gap at all.

‎content/docs/components/layout/stack.mdx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ import type { SchemaNode } from '@object-ui/types';
1414

1515
interface StackSchema {
1616
type: 'stack';
17-
gap?: number;
17+
gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10; // default: 2
1818
children: SchemaNode[];
1919
className?: string;
2020
}
2121
```
22+
23+
`gap` is a step on the stack's spacing scale, and `0` means none. The nine steps are the
24+
ones the renderer maps to a gap class, so they are the only values validation accepts:
25+
`"gap": 7` or `"gap": 9` is refused with the set named (objectui#11474). Such a number used
26+
to pass validation and then render with no gap at all, not even the default. A `flex` maps a
27+
different set: it has `7` and no `10`.

0 commit comments

Comments
 (0)