@godxjp/ui 20.2.0 → 21.0.0

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.
Files changed (60) hide show
  1. package/dist/components/data-display/chat-bubble.d.ts +30 -0
  2. package/dist/components/data-display/chat-bubble.js +229 -0
  3. package/dist/components/data-display/descriptions.js +4 -1
  4. package/dist/components/data-display/index.d.ts +4 -2
  5. package/dist/components/data-display/index.js +5 -2
  6. package/dist/components/data-display/popover.js +3 -2
  7. package/dist/components/data-display/scroll-area.js +26 -1
  8. package/dist/components/data-display/tree.d.ts +8 -0
  9. package/dist/components/data-display/tree.js +426 -0
  10. package/dist/components/data-entry/chat-composer.d.ts +50 -0
  11. package/dist/components/data-entry/chat-composer.js +163 -0
  12. package/dist/components/data-entry/chat-suggestion.d.ts +28 -0
  13. package/dist/components/data-entry/chat-suggestion.js +285 -0
  14. package/dist/components/data-entry/index.d.ts +4 -0
  15. package/dist/components/data-entry/index.js +4 -0
  16. package/dist/components/data-entry/textarea.js +3 -1
  17. package/dist/components/data-entry/tree-utils.d.ts +10 -48
  18. package/dist/components/data-entry/tree-utils.js +1 -154
  19. package/dist/components/layout/org-switcher.js +22 -2
  20. package/dist/i18n/messages/en.json +50 -0
  21. package/dist/i18n/messages/ja.json +48 -0
  22. package/dist/i18n/messages/vi.json +49 -0
  23. package/dist/lib/tree.d.ts +53 -0
  24. package/dist/lib/tree.js +155 -0
  25. package/dist/props/components/data-display.prop.d.ts +187 -1
  26. package/dist/props/components/data-entry.prop.d.ts +127 -0
  27. package/dist/props/registry.d.ts +140 -3
  28. package/dist/props/registry.js +202 -3
  29. package/dist/styles/control.css +7 -0
  30. package/dist/styles/data-display-layout.css +309 -55
  31. package/dist/styles/data-entry-layout.css +64 -0
  32. package/dist/styles/shell-layout.css +41 -11
  33. package/dist/tokens/base.css +3 -0
  34. package/dist/tokens/components/chat-bubble.css +36 -0
  35. package/dist/tokens/components/chat-composer.css +19 -0
  36. package/dist/tokens/components/data-display.css +0 -6
  37. package/dist/tokens/components/descriptions.css +4 -0
  38. package/dist/tokens/components/shell.css +13 -3
  39. package/dist/tokens/components/tree.css +27 -0
  40. package/docs/FRAME-COVERAGE-LEDGER.md +1 -1
  41. package/docs/FRAME-COVERAGE-REPORT.md +8 -3
  42. package/docs/data-display/chat-bubble.tsx +397 -0
  43. package/docs/data-display/timeline.tsx +46 -0
  44. package/docs/data-display/tree.tsx +394 -0
  45. package/docs/data-entry/chat-composer.tsx +464 -0
  46. package/docs/data-entry/chat-suggestion.tsx +301 -0
  47. package/docs/roadmap/ai-chat-components.md +207 -0
  48. package/docs/roadmap/antd-parity.md +154 -0
  49. package/docs/roadmap/badge-tag-chip-count.md +172 -0
  50. package/docs/roadmap/list-masonry.md +159 -0
  51. package/docs/roadmap/parity-audit-data-display-feedback.md +567 -0
  52. package/docs/roadmap/parity-audit-data-entry.md +344 -0
  53. package/docs/roadmap/parity-audit-layout-navigation-general.md +464 -0
  54. package/docs/roadmap/parity-backlog.md +79 -0
  55. package/docs/roadmap/tree-components.md +151 -0
  56. package/docs/showcase/table-tree-rows.tsx +4 -4
  57. package/package.json +5 -3
  58. package/dist/components/data-display/tree-list.d.ts +0 -13
  59. package/dist/components/data-display/tree-list.js +0 -26
  60. package/docs/data-display/tree-list.tsx +0 -107
@@ -0,0 +1,172 @@
1
+ # Badge / Tag / Chip / Pill / Count — audit + normalized spec
2
+
3
+ > **Canonical taxonomy:** <https://namethatui.com/web/badge-chip-pill?part=badge-count>
4
+ > **Capability reference:** Ant Design `Badge` + `Tag` (never their prop spellings where they
5
+ > conflict with `docs/PROPS-VOCABULARY.md`).
6
+ > **Contract:** `.claude/skills/godxjp-ui-component/SKILL.md` is the hard gate.
7
+
8
+ ## 1. The canonical taxonomy — five different things, routinely confused
9
+
10
+ | Term | Canonical definition | Interactive? |
11
+ | --- | --- | --- |
12
+ | **Badge** | A tiny count or status marker **attached to another object**. Parts: the *badge anchor* (the icon/avatar it attaches to) and the *badge count* (the number in the bubble). | No |
13
+ | **Tag** | Non-interactive **category metadata** on a card or row. | No |
14
+ | **Pill** | A **shape**, not a component — a capsule-shaped status label. | No |
15
+ | **Chip** | A compact **interactive token** that can be selected, edited or removed. Parts: a *remove button* (a real `<button>` with an `aria-label`) and a *selected state* (`aria-pressed`). | Yes |
16
+ | **Label** | The text naming a form field (`<label for>`). | No |
17
+
18
+ ## 2. What the library actually has, mapped onto that taxonomy
19
+
20
+ | Repo component | What it really is | Verdict |
21
+ | --- | --- | --- |
22
+ | `Badge` (`src/components/data-display/badge.tsx`) | A **Tag / Pill** — a standalone non-interactive chip with `variant` (structure), `tone` (meaning), `color` (data), `shape`, `status`→tone+icon+i18n. Nothing is attached to an anchor and there is no count. | **Misnamed, but keep the name** — see §5. Capability-wise it is *richer* than Ant's `Tag` (the `color` wash carries a real WCAG argument: 8.52:1 worst case across the sRGB cube). |
23
+ | `Toggle` / `ToggleGroupItem` | The **selectable Chip** — `pressed`/`onPressedChange` (= `aria-pressed`) plus the `count`/`overflowCount`/`showZero`/`countLabel` counter-pill vocabulary. Its own catalog entry already says a faceted filter chip ("Open 42") and a reaction chip are this, and explicitly forbids nesting a `Badge` inside it. | **Already correct.** Do **not** build a second selectable chip. |
24
+ | `TagInput` | The **chip field** — Ant-aligned (`tagRender`, `status`, `readOnly`, overflow, Backspace-removes-last). Its removable chips are **private markup** (`.ui-tag-input-chip` + a `<button aria-label>`). | Chip rendering is trapped inside it — see §4.2. |
25
+ | `Label` | A real `<label>` on `react-aria-components`. | **Correct.** Not part of this family. |
26
+ | `Button` | Also carries `count`/`overflowCount`/`showZero`/`countLabel`. | Source of the count vocabulary to reuse. |
27
+
28
+ ## 3. The gap — what Ant Design has and this library does not
29
+
30
+ Verified: `count` / `overflowCount` appear **only** in `Button`, `Toggle`, `ToggleGroup` and their
31
+ props. `Badge` has no `count` at all, and nothing anywhere renders a bubble attached to a child.
32
+
33
+ | Ant Design | Missing here | Consequence today |
34
+ | --- | --- | --- |
35
+ | antd `Badge` with `count` wrapping an `Avatar` — the count bubble on an anchor | **Entirely** | No way to put an unread count on an avatar, a nav icon, a Topbar bell or a tab. `Sidebar`/`NavList` take a `badge` prop, but that renders the Tag-style pill *inline*, not an attached marker. |
36
+ | antd `Badge` with `dot` — the bare dot marker | **Entirely** | No "there is something new" affordance. |
37
+ | `overflowCount` → `99+` on a marker | **Entirely** | (The cap exists on `Button`/`Toggle`; it never reaches a marker.) |
38
+ | `<Tag closable onClose>` — the removable chip | **Not public** | Only exists privately inside `TagInput`; a filter-summary row or a recipient list has to hand-roll a ✕ button, which is how `aria-label`-less removers get shipped. |
39
+ | `<Badge.Ribbon>` | Entirely | Composition — see §4.4. |
40
+ | `<CheckableTag>` | — | **Already covered by `Toggle`.** No action. |
41
+
42
+ ## 4. The fix — one new component, one extension, two documentation fixes
43
+
44
+ This deliberately adds the **minimum**. Three of the five gaps close by extending what exists;
45
+ building a `Chip` component would duplicate `Toggle` and is an instant reject.
46
+
47
+ ### 4.1 NEW — `CountBadge` (group: `data-display`)
48
+
49
+ The attached count/status marker. Ant's `Badge`; NameThatUI's *badge* proper.
50
+
51
+ **GATE 0 ledger**
52
+
53
+ | # | Criterion | Verdict | Why |
54
+ | --- | --- | --- | --- |
55
+ | C1 | Universal | **PASS** | Unread counts on avatars, nav icons, bells, tabs, inbox rows — every app. |
56
+ | C2 | Reusable behavior | **PASS** | Overflow capping, zero suppression, dot mode, anchor-relative placement that survives RTL, and folding the count into the anchor's accessible name / announcing changes politely. |
57
+ | C3 | Not composable | **PASS** | Requires an absolutely-positioned marker measured against an arbitrary child plus a live-region contract. A `Badge` in a `<div className="relative">` is exactly the hand-rolled version this replaces. |
58
+ | C4 | Single responsibility + vocabulary | **PASS** | One job; reuses the count vocabulary already defined by `Button`. |
59
+ | C5 | Token-themeable | **PASS** | Size, offset, surface, ring are `--count-badge-*` tokens. |
60
+ | C6 | Earns the i18n/a11y contract | **PASS** | `Intl.NumberFormat` for the number *and* the cap (vi renders `1.000+`), and the count must be announced, not merely drawn. |
61
+ | C7 | Earns bundle cost | **PASS** | Used by nav chrome in every consumer. |
62
+
63
+ **ALL PASS → framework component.**
64
+
65
+ **API — reuse the EXISTING count vocabulary verbatim.** `Button` and `Toggle` already define
66
+ `count` / `overflowCount` / `showZero` / `countLabel`. Do not invent a second spelling; a third
67
+ dialect of the same idea is the defect this repo keeps fixing.
68
+
69
+ | Ant Design | **godx `CountBadge`** |
70
+ | --- | --- |
71
+ | `count` | `count: number` |
72
+ | `overflowCount` | `overflowCount: number` (default `99`) |
73
+ | `showZero` | `showZero: boolean` (default `false`) |
74
+ | `dot` | `dot: boolean` — a marker with no number |
75
+ | `children` | `children` — the **anchor**; omit it for a standalone inline marker |
76
+ | `status` + `text` | *dropped* — that is `Badge status=…`, which already exists |
77
+ | `color` | `tone` (semantic) — the free-form data colour stays `Badge`'s job |
78
+ | `offset` | *dropped* — placement is `placement` + tokens, never a caller-supplied pixel pair |
79
+ | `size: 'default' \| 'small'` | `size: 'xs' \| 'sm' \| 'md' \| 'lg'` (never `"default"`) |
80
+ | `title` | `countLabel` — same name `Button` uses |
81
+ | — | `placement: 'start' \| 'end'` (logical; flips under RTL) |
82
+
83
+ **Required semantics**
84
+ - The number and the cap both go through `Intl.NumberFormat` on the active locale — never
85
+ `String(n)`, never a hand-rolled thousands separator. Above the cap render `{overflowCount}+`.
86
+ - `count={0}` renders nothing unless `showZero`.
87
+ - The marker is **not** an accessible name of its own floating next to the anchor: fold it into the
88
+ anchor's name via a visually-hidden text node (`t()`-driven, e.g. "Notifications, 5 unread"), or
89
+ expose `countLabel`. A bare "5" read out of context is a bug.
90
+ - A changing count updates a single `aria-live="polite"` region — not one per marker.
91
+ - `dot` mode still needs a text alternative; **never colour-or-shape-only** (WCAG 1.4.1).
92
+ - Placement uses logical offsets (`inset-inline-end`), so it flips under `dir="rtl"`.
93
+ - The marker must not clip: it overflows the anchor box deliberately, and the anchor keeps its own
94
+ hit area ≥24×24px (WCAG 2.5.8).
95
+
96
+ **Tokens** — `src/tokens/components/count-badge.css`, `@import`ed from `src/tokens/base.css`,
97
+ names passing `check:token-tiers`: `--count-badge-size`, `--count-badge-dot-size`,
98
+ `--count-badge-inset-block`, `--count-badge-inset-inline`, `--count-badge-background`,
99
+ `--count-badge-foreground`, `--count-badge-ring-color`, `--count-badge-ring-width`,
100
+ `--count-badge-font-size`. No literal heights.
101
+
102
+ **i18n** — `countBadge.unreadCount` (a CLDR `{one, other}` plural selected by `Intl.PluralRules`,
103
+ in en/vi/ja), `countBadge.new` for `dot`.
104
+
105
+ ### 4.2 EXTEND — `Badge` gains `onRemove` (this *is* the removable Chip)
106
+
107
+ Rather than a new `Chip` component that would collide with `Toggle`:
108
+
109
+ - Add `onRemove?: () => void` and `removeLabel?: string` to `Badge`. When `onRemove` is present the
110
+ badge renders a trailing `<button type="button">` with a `t()`-driven `aria-label` naming the
111
+ item it removes ("Remove {tag}"), a ≥24×24px target, and `Backspace`/`Delete` support when the
112
+ badge itself is focused. `Badge` renders a `<div>`/`<span>`, so this is **not** a button-in-button.
113
+ - Then **fix it upstream, not at the call site**: refactor `TagInput` to render its chips as
114
+ `Badge onRemove=…` instead of the private `.ui-tag-input-chip` markup, so there is exactly one
115
+ removable-chip implementation and one remover `aria-label` in the system. `TagInput`'s public API
116
+ and its existing tests must not change — prove it by running them.
117
+ - Selection is **not** added to `Badge`. A selectable chip is `Toggle` (`pressed` + `count`), and
118
+ the catalog must keep saying so.
119
+
120
+ ### 4.3 DOCUMENT — the routing rules, so consumers stop guessing
121
+
122
+ The real reason this family "doesn't look like Ant Design" is that the map is unwritten. Add to
123
+ `mcp/src/data/components.ts`, on **both** sides of each pair (a one-sided claim is the mistake
124
+ commit `8365bf05` fixed):
125
+
126
+ - `Badge` tagline: state that in the canonical taxonomy this is the **Tag / Pill** — non-interactive
127
+ category or status metadata — and that a count marker attached to an anchor is `CountBadge`.
128
+ - `Badge.related`: → `CountBadge` (counts on an anchor), `Toggle` (selectable chip),
129
+ `TagInput` (an editable set of chips), `Label` (naming a form field).
130
+ - `CountBadge.related`: → `Badge`, `Toggle`, `Sidebar`/`NavList` `badge` props.
131
+ - New rules: *DON'T hand-roll a `<span>` counter or an absolutely positioned `Badge` to mark an
132
+ anchor — use `CountBadge`.* *DON'T nest a `Badge` inside a `Toggle` for a count — `Toggle` owns
133
+ `count`.* *DON'T build a selectable chip out of `Badge` + `onClick` — use `Toggle`.*
134
+
135
+ ### 4.4 COMPOSITION — not framework components
136
+
137
+ - **Ribbon** (Ant `Badge.Ribbon`): C2 and C3 fail — it is a `Card` plus an absolutely positioned
138
+ `Badge` plus a corner token. Ship it as a `docs/` showcase, never in `src/components/`.
139
+ - **Status dot + text** (Ant `Badge status text`): already `Badge status=…`, which maps the key to
140
+ tone + icon + an i18n label. No new API.
141
+
142
+ ## 5. Explicitly NOT doing: renaming `Badge`
143
+
144
+ `Badge` is used across the entire library and every consumer. Renaming it to `Tag` to satisfy the
145
+ taxonomy would be a breaking change that buys nothing a catalog tagline cannot. **Keep the name;
146
+ document the meaning.** No agent may rename, alias or deprecate `Badge` under this work.
147
+
148
+ ## 6. Definition of done
149
+
150
+ 1. `src/components/data-display/count-badge.tsx`, exported from that group's `index.ts`
151
+ 2. `CountBadgeProp` (+ `as CountBadgeProps`) in `src/props/components/data-display.prop.ts`,
152
+ **registered in `src/props/registry.ts`**; `Badge`'s `onRemove`/`removeLabel` added to its prop type
153
+ 3. `src/tokens/components/count-badge.css` + `@import` in `src/tokens/base.css`
154
+ 4. i18n keys in **all three** of `en.json`, `vi.json`, `ja.json`
155
+ 5. Tests in `src/components/data-display/__tests__/`: `count-badge.test.tsx` (Intl formatting in
156
+ en/vi/ja, cap → `99+`, `showZero`, `dot`, RTL placement, live-region announcement, accessible
157
+ name folding), `badge-remove.test.tsx` (remove button name, keyboard, ≥24px), and
158
+ `count-badge.a11y.test.tsx` at **0 axe violations**
159
+ 6. `mcp/src/data/components.ts`: a `CountBadge` entry, `Badge`'s new props, and the §4.3 routing
160
+ rules on both sides
161
+ 7. A real-screen docs page `docs/data-display/count-badge.tsx`
162
+ 8. `TagInput` refactored onto `Badge onRemove`, with its existing tests still green
163
+
164
+ Gates, then only the touched test files:
165
+
166
+ ```
167
+ pnpm typecheck && pnpm lint && pnpm run audit \
168
+ && pnpm check:prop-vocabulary && pnpm check:mcp-sync && pnpm check:mcp-orphans \
169
+ && pnpm check:token-tiers && pnpm check:control-sizing && pnpm check:example-imports
170
+ ```
171
+
172
+ `pnpm test` and a bare `pnpm vitest run` are **forbidden** — the full suite is CI's job.
@@ -0,0 +1,159 @@
1
+ # `List` (Ant `Listy`) + `Masonry` — normalized spec
2
+
3
+ > **Capability reference:** <https://ant.design/components/listy> and
4
+ > <https://ant.design/components/masonry>. **Canonical definition:**
5
+ > <https://namethatui.com/web/masonry>.
6
+ > **Contract:** `.claude/skills/godxjp-ui-component/SKILL.md`.
7
+
8
+ Measured facts this spec rests on: the library has **no virtualization anywhere**
9
+ (no `react-window` / `@tanstack/react-virtual` / any `virtual` code path in `src/`), and **no
10
+ masonry** (every `grid-template-columns` in `src/styles/` is a fixed uniform grid; `ResponsiveGrid`
11
+ is a uniform-row card grid). Both are genuine holes, not restyling jobs.
12
+
13
+ ---
14
+
15
+ ## 1. `List` — port of Ant Design `Listy` (group: `data-display`)
16
+
17
+ Ant's old `List` is **deprecated** and `Listy` replaces it. Port `Listy`, not `List`: it is the
18
+ narrower, performance-shaped component (virtual scrolling + grouping), which is exactly the part
19
+ that cannot be composed here.
20
+
21
+ ### GATE 0 ledger
22
+
23
+ | # | Criterion | Verdict | Why |
24
+ | --- | --- | --- | --- |
25
+ | C1 | Universal | **PASS** | Long feeds, activity streams, message lists, pickers, log views. |
26
+ | C2 | Reusable behavior | **PASS** | Windowed rendering, measured row heights, sticky group headers, an imperative `scrollTo` that resolves an item key or a group key to an offset. |
27
+ | C3 | Not composable | **PASS** | Nothing in the library virtualizes. `ScrollArea` + `.map()` renders every row. |
28
+ | C4 | Single responsibility + vocabulary | **PASS** | One job; maps onto `items` / `getRowId` / `size`. |
29
+ | C5 | Token-themeable | **PASS** | Row height, group-header surface, divider are `--list-*` tokens. |
30
+ | C6 | Earns the contract | **PASS** | A virtual list is where `role`/`aria-setsize`/`aria-posinset` are *mandatory* — the DOM no longer contains the whole set. |
31
+ | C7 | Earns bundle cost | **PASS** | Every consumer has at least one long list. |
32
+
33
+ **ALL PASS → framework component.**
34
+
35
+ ### API — Ant `Listy` → godx `List`
36
+
37
+ | Ant `Listy` | **godx `List`** | Note |
38
+ | --- | --- | --- |
39
+ | `items` | `items: T[]` | |
40
+ | `itemRender(item, index)` | `itemRender(item, index)` | |
41
+ | `rowKey` | **`getRowId: (item: T) => string`** | The house spelling — `DataTable` already uses `getRowId`. Do not introduce `rowKey` as a second dialect. |
42
+ | `height` | `height?: number` | Scroll container height; content scrolls past it. |
43
+ | `virtual` | `virtual?: boolean` (default `false`) | |
44
+ | `group: { key, title }` | `group?: { key: (item) => K; title: (key, items) => ReactNode }` | |
45
+ | `sticky` | `sticky?: boolean` (default `false`) | Group headers stick. |
46
+ | `onScroll` | `onScroll?: React.UIEventHandler<HTMLElement>` | |
47
+ | `classNames` / `styles` | `classNames?: { root?; item?; groupHeader? }` | Keep the semantic-slot shape; skip the `styles` twin (inline style is not how this system themes). |
48
+ | ref `scrollTo(config)` | ref `scrollTo(config)` | Accepts a pixel offset, `{ top }`, `{ key, align?, offset? }`, or `{ groupKey, align?, offset? }`. |
49
+ | — | `size: 'xs' \| 'sm' \| 'md' \| 'lg'` | House requirement. |
50
+ | — | `loading?: boolean`, `empty?: ReactNode` | Compose the real `Skeleton` / `EmptyState`; do not hand-roll either. |
51
+
52
+ **Deliberately NOT ported** (and say so in the catalog entry, so nobody re-adds them): `bordered`,
53
+ `split`, `header`, `footer`, `size: 'large'`, `pagination`, `loadMore`, `itemLayout`. `Listy`
54
+ dropped them, and here they are already covered — the frame is `Card` + `CardContent flush`,
55
+ dividers are `Separator`, paging is `Pagination`. Re-adding them would rebuild a second `Card`.
56
+
57
+ ### Required semantics
58
+ - `role="list"` with `role="listitem"` rows; when `virtual`, every row **must** carry `aria-setsize`
59
+ (the full count) and `aria-posinset` — otherwise a screen reader reports the window, not the list.
60
+ This is the single most-skipped part of a virtual list and it is not optional.
61
+ - Grouping renders `role="group"` with the header as its `aria-label`/`aria-labelledby`.
62
+ - Keyboard: the scroll container is focusable; `PageUp`/`PageDown`/`Home`/`End` work. Rows are not
63
+ a roving-tabindex widget — interactive controls inside a row keep normal tab order.
64
+ - `sticky` headers use `position: sticky` with logical insets and must not cover the focused row
65
+ (`scroll-margin-block-start`).
66
+ - Row heights are measured, not assumed; a row whose content grows must not desynchronise the
67
+ window. Reserve image dimensions.
68
+ - `prefers-reduced-motion: reduce` disables any smooth-scroll in `scrollTo`.
69
+
70
+ ### Tokens
71
+ `src/tokens/components/list.css` (`@import` from `src/tokens/base.css`): `--list-row-min-height`
72
+ (from the `--control-height` tier), `--list-divider-color`,
73
+ `--list-group-header-background`, `--list-group-header-foreground`, `--list-group-header-height`.
74
+
75
+ ### Spacing — the list does NOT own its inline inset
76
+
77
+ Read `docs/SPACING.md` before writing a single spacing declaration. A row inside a
78
+ `Card` + `CardContent flush` takes its inline inset from the public class **`ui-card-inset-x`**
79
+ (which reads `--card-space-inset`), so the row lines up with the card shell and follows the card's
80
+ `density`. **Do not invent a `--list-row-padding-inline`** — a parallel spacing knob drifts away
81
+ from the Card that contains it, and the block axis is owned by `--list-row-min-height`.
82
+
83
+ Macro rhythm is never the component's: no Tailwind `p-*` / `m-*` / `gap-*` (the audit rejects them
84
+ as `no-utility-spacing`), no hand-rolled `flex`/`grid` (`no-utility-layout`). Vertical rhythm comes
85
+ from `Flex gap` on the φ scale (`xs`/`sm` = 4px grid, `md` = φ⁰, `lg` = φ¹, `xl` = φ²) — this repo
86
+ does **not** use the 8pt grid.
87
+
88
+ ### i18n
89
+ `list.empty`, `list.loading`, `list.group` (group-header accessible name), and any count through
90
+ `Intl.NumberFormat` + `Intl.PluralRules`.
91
+
92
+ ---
93
+
94
+ ## 2. `Masonry` (group: `layout`)
95
+
96
+ **Canonical definition** (NameThatUI): *a layout where each new item joins the shortest column,
97
+ creating a staggered bottom edge with no row lines and cards keeping their individual heights.*
98
+ The named part is the **packed column** — each column flows straight down, nothing lines up
99
+ sideways. Aliases: Pinterest grid, waterfall, brick layout.
100
+
101
+ ### GATE 0 ledger
102
+
103
+ | # | Criterion | Verdict | Why |
104
+ | --- | --- | --- | --- |
105
+ | C1 | Universal | **PASS** | Media galleries, card boards, dashboards with variable-height cards. |
106
+ | C2 | Reusable behavior | **PASS** | Shortest-column packing, re-packing on resize/content change (`ResizeObserver`), and keeping DOM reading order row-major while the visual flow is column-major. Native `grid-template-rows: masonry` covers the paint but not the ordering or the fallback. |
107
+ | C3 | Not composable | **PASS** | `ResponsiveGrid` is a uniform grid; nothing packs by column height. |
108
+ | C4 | Single responsibility + vocabulary | **PASS** | One job; `columns`/`gap` reuse `ResponsiveGrid`'s exact spellings. |
109
+ | C5 | Token-themeable | **PASS** | Gaps come from the spacing scale. |
110
+ | C6 | Earns the contract | **PASS** | Reading order vs visual order is an accessibility decision, not a style one. |
111
+ | C7 | Earns bundle cost | **PASS** | Small; broadly useful. |
112
+
113
+ **ALL PASS → framework component.**
114
+
115
+ ### API — Ant `Masonry` → godx `Masonry`
116
+
117
+ | Ant Design | **godx `Masonry`** | Note |
118
+ | --- | --- | --- |
119
+ | `columns: number \| { xs, sm, md }` | `columns: number \| { base?, sm?, md?, lg? }` (default `3`) | **Use `ResponsiveGrid`'s existing breakpoint shape** (`base/sm/md/lg`), not antd's `xs/…/xxl`. One breakpoint dialect in this library. |
120
+ | `gutter: Gap \| [Gap, Gap]` | `gap: 'none' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` (default `'md'`) | Token scale, exactly as `ResponsiveGrid`. A caller-supplied pixel pair is not how this system spaces. |
121
+ | `items: MasonryItem[]` | `items: MasonryItemProp[]` — `{ key, children?, data?, column? }` | Drop antd's `height`: heights are measured, never declared. |
122
+ | `itemRender(item)` | `itemRender(item, index)` | `item.children` still wins. |
123
+ | `fresh` | `observeItems?: boolean` (default `true`) | Keep watching child sizes via `ResizeObserver`; the antd name says nothing. |
124
+ | `onLayoutChange` | `onLayoutChange?: (placements: { key: Key; column: number }[]) => void` | |
125
+ | `classNames` / `styles` | `classNames?: { root?; item? }` | Skip the `styles` twin. |
126
+ | — | `sequential?: boolean` | Fill columns left-to-right in order instead of shortest-first, for a strict reading order. |
127
+
128
+ ### Required semantics
129
+ - **Reading order is DOM order.** Whatever the visual packing, the DOM stays in `items` order so
130
+ keyboard and screen-reader traversal match the source sequence. This is the reason the CSS
131
+ `columns` fallback alone is not acceptable — it flows column-major.
132
+ - Prefer native `@supports (grid-template-rows: masonry)`; fall back to measured absolute/transform
133
+ packing. Never ship the bare `columns:` fallback as the only path.
134
+ - The container is a plain grouping element with no invented role. If the content is a list, the
135
+ **caller** supplies the semantics; `Masonry` must not silently impose `role="list"`.
136
+ - Re-pack on container resize and on item resize (`ResizeObserver`), debounced to a frame.
137
+ - Reserve media dimensions (`AspectRatio`) so image loads do not cause layout shift — call this out
138
+ in the docs page.
139
+ - Logical CSS only; column order flips under `dir="rtl"`.
140
+
141
+ ### Tokens
142
+ `src/tokens/components/masonry.css`: `--masonry-gap-inline`, `--masonry-gap-block`,
143
+ `--masonry-column-min-inline-size`.
144
+
145
+ ---
146
+
147
+ ## 3. Definition of done (both)
148
+
149
+ Per component: source + group `index.ts` export · `XProp` (+ `as XProps`) in the group's
150
+ `*.prop.ts` **and `src/props/registry.ts`** · tokens file + `@import` in `src/tokens/base.css` ·
151
+ i18n keys in **en/vi/ja** · `@testing-library/user-event` behaviour tests + a `*.a11y.test.tsx` at
152
+ **0 axe violations** · an `mcp/src/data/components.ts` entry (including the "deliberately not
153
+ ported" list for `List`) · a real-screen docs page.
154
+
155
+ For `List`, the virtual-mode test must assert `aria-setsize`/`aria-posinset` reflect the **full**
156
+ item count while only a window is in the DOM. For `Masonry`, a test must assert DOM order equals
157
+ `items` order under every `columns` value.
158
+
159
+ Gates, then only the touched test files. `pnpm test` and a bare `pnpm vitest run` are **forbidden**.