@godxjp/ui 31.11.1 → 31.12.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.
@@ -3,7 +3,7 @@
3
3
  You are about to write code against a design system you did not author. This file is the whole
4
4
  contract. Read it before you write JSX.
5
5
 
6
- **This catalog describes `@godxjp/ui` 31.11.1.** If the project you are editing has a different
6
+ **This catalog describes `@godxjp/ui` 31.12.0.** If the project you are editing has a different
7
7
  version in its `package.json`, read the pinned catalog for THAT version instead
8
8
  (`…/v<their-version>/agent/…`). A catalog newer than the installed package describes props that do
9
9
  not exist yet; older, and it hides props that do. Neither failure announces itself.
package/agent/index.json CHANGED
@@ -48,7 +48,7 @@
48
48
  "note": "Pin to the tag that matches the @godxjp/ui version you installed. A catalog newer than your package describes props you do not have; older, and it hides props you do.",
49
49
  "read": {
50
50
  "live": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/index.json",
51
- "pinned": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/v31.11.1/agent/index.json"
51
+ "pinned": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/v31.12.0/agent/index.json"
52
52
  },
53
53
  "source": "mcp/src/data — the same data @godxjp/ui-mcp serves — plus the foundation and semantic token tiers, read from src/tokens/*.css",
54
54
  "start": "https://raw.githubusercontent.com/godx-jp/godxjp-ui/main/agent/START-HERE.md",
@@ -62,5 +62,5 @@
62
62
  "foundation": "the seeds a consumer is invited to set — --primary, --background, --radius",
63
63
  "semantic": "named roles that follow the seeds — --ring, --text-link, --overlay-background"
64
64
  },
65
- "version": "31.11.1"
65
+ "version": "31.12.0"
66
66
  }
package/agent/llms.txt CHANGED
@@ -1,10 +1,10 @@
1
1
  # @godxjp/ui
2
2
 
3
3
  > A Japanese-enterprise React design system: 178 components, 2116 design tokens,
4
- > 50 cardinal rules. This file is the entry point for AI agents. Catalog version 31.11.1.
4
+ > 50 cardinal rules. This file is the entry point for AI agents. Catalog version 31.12.0.
5
5
 
6
6
  If your client can run a process, do not read these files — run the MCP server instead
7
- (`npx @godxjp/ui-mcp@31.11.1`). It is searchable and version-locked. These files exist for agents
7
+ (`npx @godxjp/ui-mcp@31.12.0`). It is searchable and version-locked. These files exist for agents
8
8
  that can only fetch URLs.
9
9
 
10
10
  ## Start
@@ -26,7 +26,7 @@ that can only fetch URLs.
26
26
  ## Pinning
27
27
 
28
28
  Every URL above tracks `main`. To pin to the release a project actually installed, swap `main` for
29
- the tag: `.../godx-jp/godxjp-ui/v31.11.1/agent/...`. A catalog that does not match the installed
29
+ the tag: `.../godx-jp/godxjp-ui/v31.12.0/agent/...`. A catalog that does not match the installed
30
30
  package describes props that are absent, or hides props that are present, and says nothing either way.
31
31
 
32
32
  Pinned catalogs only exist for releases whose tag actually contains `agent/`. If `…/v<version>/agent/index.json` returns 404, that release predates this catalog: read `…/main/…` instead and compare `index.json` → `version` against the package you have, so you at least know which way it drifted.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "AUTO-GENERATED by scripts/gen-measurement-contract.mjs — do not edit. Read this instead of guessing: docs/MEASUREMENT-CONTRACT.md.",
3
- "version": "31.11.1",
3
+ "version": "31.12.0",
4
4
  "targetSize": {
5
5
  "standard": "WCAG 2.2 SC 2.5.8 Target Size (Minimum), level AA — 24×24 CSS px",
6
6
  "min": 24,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "31.11.1",
2
+ "version": "31.12.0",
3
3
  "generatedBy": "scripts/gen-style-layers.mjs — do not edit by hand; run `pnpm gen:style-layers`",
4
4
  "base": "base.css",
5
5
  "fonts": "fonts.css",
@@ -6,7 +6,7 @@ Read this once; the audit enforces it. Everything else in `docs/` is for contrib
6
6
  2. **Mount `<AppProvider defaultLocale="…">` once, at the root.** Without it the kit's OWN strings (dialog close/cancel/delete, counters, picker labels) fall to the resting locale `vi` and pickers to UTC — measured in a Japanese app as Vietnamese buttons, silently (gh#1005). A development build now warns once when a kit component renders outside it; `syncI18nLocale(locale, fallback)` is the escape for an app that truly cannot mount the provider. Every page is `<PageContainer title subtitle extra footer>`; its sections are spaced by the page. Group items inside a section with `<Flex direction="col" gap>` or `<ResponsiveGrid>`.
7
7
  3. No Tailwind layout on your own elements: no `flex`, `grid`, `gap-*`, `p-*`, `m-*`, `space-*`. Rows are `<Flex>` (default row), stacks are `<Flex direction="col">`, grids are `<ResponsiveGrid>`.
8
8
  4. No hand-rolled surfaces: no `rounded-* border bg-*` divs. A box is `Card`, a pill is `Badge`, a person is `Avatar`, a row is `ListRow`, a label/value pair is `Descriptions`, an empty area is `EmptyState`, a read-only sample of a colour the USER chose is `Swatch`. A LIST of those rows is `<Flex as="ul" marker="none" direction="col" gap="none">` with `<ListRow as="li">` children — `marker="none"` keeps the `<ul>`, the `<li>` semantics and the gap token while dropping the bullet and the indent. Never a raw `<ul>`/`<ol>` (it carries no gap token), never `<div role="list">` + `<div role="listitem">`, and never a wrapper around each row: the divider is `:not(:last-child)` among siblings, so a row alone in its own wrapper is always the last one and EVERY divider disappears silently. A bulleted prose list is the same `<Flex as="ul">` without `marker`.
9
- 5. Real controls only: `Button`, `Input`, `Select`, `Textarea`, `Checkbox`… never raw `<button>`/`<input>`; a labelled control lives in `<FormField label>`. A Select outside a form takes `width="auto"`. **A disabled control's reason is visible text, never a tooltip** — see below. **Fields live in a `<Form layout="horizontal" labelWidth controlWidth>`** — never a group of `FormField`s without one, never a hand-rolled `<Flex>` row of fields (a row that belongs together is `<SpaceCompact>` or `<Form columns>`); size each control for its content with `controlWidth` (GOV.UK text-input width: a port ~7rem, a short enum ~10rem); three or more fields is a page, not a Dialog. The audit rules are `formfield-needs-form`, `dialog-form-too-big` and `select-width-hint`. **A case the kit cannot express is an issue, not a hand-roll:** open it on godx-jp/godxjp-ui, use the nearest valid composition, and mark it `// TODO(godxjp-ui#<n>)` (gh#998).
9
+ 5. Real controls only: `Button`, `Input`, `Select`, `Textarea`, `Checkbox`… never raw `<button>`/`<input>`; a labelled control lives in `<FormField label>`. A Select outside a form takes `width="auto"`. **A disabled control's reason is visible text, never a tooltip** — see below. **Fields live in a `<Form layout="horizontal" labelWidth controlWidth>`** — never a group of `FormField`s without one, never a hand-rolled `<Flex>` row of fields (a row that belongs together is `<SpaceCompact>` or `<Form columns>`); size each control for its content with `controlWidth` (GOV.UK text-input width: a port ~7rem, a short enum ~10rem); three or more fields is a page, not a Dialog. The audit rules are `formfield-needs-form`, `dialog-form-too-big` and `select-width-hint`. **A case the kit cannot express is an issue, not a hand-roll:** open it on godx-jp/godxjp-ui, use the nearest valid composition, and mark it `// TODO(godxjp-ui#<n>)` (gh#998). **One action row, one Button size:** every `Button` under one parent takes the same `size` — a missing size is `default`, and `icon-sm` pairs with `sm`, `icon-xs` with `xs`, `icon` with default. Never `size="sm"` beside a default Button. The audit rules are `mixed-button-size` (static) and `mixed-button-height` (visual-audit, within 0.5px) (gh#1084).
10
10
  6. Text is `<Text>` / `<Heading>` with `tone`, `size`, `weight`, `truncate`, `mono` — not `className="text-muted-foreground font-semibold"`. A STANDALONE glyph is `<Icon as={Lock} size="sm" tone="muted" />` from `@godxjp/ui/general`: a bare lucide icon carries its own `width="24" height="24"` and only four places re-size it for you (`Button`, a `DropdownMenuItem`, a `TopbarItem`, a `ListRow` leading slot), so everywhere else — in a `Text`, a table cell, an `<a>` — it draws at 24px beside 14px type. `size-4` and `w-[16px]` are closed to you by rules 3 and 8, and `size={16}` hard-codes a number the theme owns; `Icon` puts the glyph on the `--icon-size-*` scale (`2xs…4xl`) instead, and is `aria-hidden` unless you give it a `label` (then it is `role="img"` with that name). The audit rule is `lucide-icon-needs-size`.
11
11
  7. Colours are semantic tokens (`tone="destructive"`, `bg-primary`), never palette names, hex, or `bg-black` / `text-white`.
12
12
  8. Sizes come from props (`size`, `width`, `columns`), never `w-[240px]` / `max-h-[420px]`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@godxjp/ui",
3
- "version": "31.11.1",
4
- "godxUiMcp": "31.11.1",
3
+ "version": "31.12.0",
4
+ "godxUiMcp": "31.12.0",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -891,6 +891,30 @@ const RULES = [
891
891
  message:
892
892
  'Hand-rolled overflow-wrap:anywhere ([overflow-wrap:anywhere] / wrap-anywhere) — use <Text break="anywhere"> for an email, code or id in a table cell or Descriptions value. It also releases the cell\'s inherited nowrap, so drop the break-words / whitespace-normal that came with it. Not whitespace="pre-wrap": its break-word does not shrink a table column (gh#927).',
893
893
  },
894
+ {
895
+ id: "mixed-button-size",
896
+ replacement: "one Button size per row",
897
+ scope: "consumer",
898
+ severity: "error",
899
+ /*
900
+ * ONE ROW, ONE BUTTON SIZE. A consumer shipped 「AIスコアを編集」 at `size="sm"` beside 裁定する at
901
+ * the default size in one action row: two heights, two paddings, two type sizes side by side,
902
+ * and the owner saw it before any audit did. Sibling <Button>s under one JSX parent must share
903
+ * a size. A missing `size` is `default`; an `icon-*` size belongs to its text size's family
904
+ * (`icon-sm` = `sm`, `icon-xs` = `xs`, `icon` = default), so `xs` beside `icon-sm` still fails.
905
+ *
906
+ * "Siblings" looks through what renders no box of its own: fragments, `{cond && …}`,
907
+ * ternaries, `.map(…)` and a Tooltip / TooltipTrigger around a button. Any other element is a
908
+ * new parent — FormActions, CardFooter, ModalFooter, Space, Flex, PageHeader `actions={…}` are
909
+ * all just parents here. A `size={expr}` that is not a string literal is unknown and skipped;
910
+ * a button kept in a variable (`{editButton}`) is invisible to a static scan — the runtime
911
+ * `mixed-button-height` check in visual-audit.mjs catches that one.
912
+ */
913
+ spansElement: true,
914
+ matches: mixedButtonSizeMatches,
915
+ message:
916
+ "Buttons in one row mix sizes — every Button under one parent takes the same `size` (a missing size is `default`; `icon-sm` pairs with `sm`, `icon-xs` with `xs`, `icon` with default). Pick the row's size and apply it to every button in it (docs/CONSUMER-RULES.md §5).",
917
+ },
894
918
  ];
895
919
 
896
920
  /**
@@ -1518,6 +1542,111 @@ function jsxOpeningEnd(source, start) {
1518
1542
  return source.length;
1519
1543
  }
1520
1544
 
1545
+ /** Transparent wrappers: they render no row of their own, so the buttons inside stay siblings. */
1546
+ const BUTTON_ROW_TRANSPARENT = new Set([
1547
+ "",
1548
+ "Fragment",
1549
+ "React.Fragment",
1550
+ "Tooltip",
1551
+ "TooltipTrigger",
1552
+ ]);
1553
+
1554
+ /** A Button's `size` literal from its OPENING tag's own attributes (not a nested element's). */
1555
+ function buttonSizeOf(openTag) {
1556
+ // Blank every `{…}` body so `icon={<Plus size="sm" />}` cannot answer for the Button.
1557
+ let top = "";
1558
+ let depth = 0;
1559
+ let quote = "";
1560
+ for (let i = 0; i < openTag.length; i++) {
1561
+ const ch = openTag[i];
1562
+ if (quote) {
1563
+ if (ch === "\\") i++;
1564
+ else if (ch === quote) quote = "";
1565
+ top += depth ? " " : ch;
1566
+ continue;
1567
+ }
1568
+ if (ch === '"' || ch === "'" || ch === "`") quote = ch;
1569
+ if (ch === "{") depth++;
1570
+ top += depth ? (ch === "{" && depth === 1 ? "{" : " ") : ch;
1571
+ if (ch === "}") depth--;
1572
+ }
1573
+ const at = /\bsize\s*=\s*/.exec(top);
1574
+ if (!at) return "default";
1575
+ const rest = openTag.slice(at.index + at[0].length);
1576
+ const lit = /^(?:"([^"]*)"|'([^']*)'|\{\s*(?:"([^"]*)"|'([^']*)'|`([^`$]*)`)\s*\})/.exec(rest);
1577
+ return lit ? (lit[1] ?? lit[2] ?? lit[3] ?? lit[4] ?? lit[5]) : null;
1578
+ }
1579
+
1580
+ /** `icon-sm` → `sm`, `icon` → `default`, `md` → `default` (Button maps md to the default size). */
1581
+ const buttonSizeFamily = (size) => {
1582
+ const bare = size.replace(/^icon-?/, "");
1583
+ return bare === "" || bare === "md" ? "default" : bare;
1584
+ };
1585
+
1586
+ /**
1587
+ * `mixed-button-size`: group every <Button> by its nearest non-transparent JSX parent and yield
1588
+ * one match per group whose size families differ. A tag stack over the whole file; an element in
1589
+ * an attribute (`actions={<>…</>}`) gets the attribute's owner as its parent, kept apart from the
1590
+ * owner's children. A `<` glued to an identifier outside JSX children is a TS generic.
1591
+ */
1592
+ function* mixedButtonSizeMatches(source) {
1593
+ const stack = []; // { tag, id, attr }
1594
+ const pending = []; // opening tags whose attributes are still being scanned
1595
+ const groups = new Map();
1596
+ let nextId = 0;
1597
+ const settle = (upTo) => {
1598
+ while (pending.length && pending.at(-1).end < upTo) {
1599
+ const p = pending.pop();
1600
+ const i = stack.lastIndexOf(p.frame);
1601
+ if (i >= 0) stack.length = i;
1602
+ if (!p.selfClose) stack.push({ tag: p.frame.tag, id: nextId++, attr: false });
1603
+ }
1604
+ };
1605
+ const tagRe = /<(\/?)(?:([A-Za-z][\w.]*)(?=[\s/>])|(?=>))/g;
1606
+ for (const m of source.matchAll(tagRe)) {
1607
+ settle(m.index);
1608
+ const [, close, tag = ""] = m;
1609
+ // `useState<Issue>(` — a `<` glued to an identifier, `)` or `]` is a generic, unless it sits
1610
+ // in JSX children, where `Total<b>` is text followed by a tag.
1611
+ const glued = /[\w$)\].]/.test(source[m.index - 1] ?? "");
1612
+ if (!close && glued && (stack.length === 0 || stack.at(-1).attr)) continue;
1613
+ if (close) {
1614
+ for (let i = stack.length - 1; i >= 0; i--) {
1615
+ if (!stack[i].attr && stack[i].tag === tag) {
1616
+ stack.length = i;
1617
+ break;
1618
+ }
1619
+ }
1620
+ continue;
1621
+ }
1622
+ const end = jsxOpeningEnd(source, m.index);
1623
+ if (end >= source.length) continue;
1624
+ const openTag = source.slice(m.index, end + 1);
1625
+ if (tag === "Button") {
1626
+ const parent = stack.findLast((f) => f.attr || !BUTTON_ROW_TRANSPARENT.has(f.tag));
1627
+ const size = buttonSizeOf(openTag);
1628
+ if (parent && size !== null) {
1629
+ (groups.get(parent.id) ?? groups.set(parent.id, []).get(parent.id)).push({
1630
+ size,
1631
+ index: m.index,
1632
+ openTag,
1633
+ });
1634
+ }
1635
+ }
1636
+ const frame = { tag, id: nextId++, attr: true };
1637
+ stack.push(frame);
1638
+ pending.push({ end, frame, selfClose: /\/\s*>$/.test(openTag) });
1639
+ }
1640
+ for (const group of groups.values()) {
1641
+ const families = new Set(group.map((b) => buttonSizeFamily(b.size)));
1642
+ if (group.length < 2 || families.size < 2) continue;
1643
+ yield {
1644
+ 0: `sizes ${group.map((b) => b.size).join(" + ")}: ${group[0].openTag}`,
1645
+ index: group[0].index,
1646
+ };
1647
+ }
1648
+ }
1649
+
1521
1650
  // Structural: a <Card> (without p-0) whose first child is body content rather than a Card
1522
1651
  // sub-component sits FLUSH (no padding). Per-line regexes can't see across lines, so this is a
1523
1652
  // whole-file pass. The body must be wrapped in <CardContent> (titles in <CardHeader>).
@@ -43,6 +43,13 @@ export const VISUAL_RULES = [
43
43
  standard: "@godxjp/ui control tier (--control-height) · Nielsen consistency heuristic",
44
44
  fix: "Every control in one row (Flex row, PageContainer extra, footer) must share --control-height. Replace the odd one with the real primitive (Avatar/Button/Badge) instead of a hand-rolled pill; never restyle a control's height.",
45
45
  },
46
+ {
47
+ id: "mixed-button-height",
48
+ severity: "error",
49
+ category: "layout",
50
+ standard: "@godxjp/ui Button size (one size per row) · Nielsen consistency heuristic",
51
+ fix: "Every Button in one flex row renders at one height (within 0.5px): give them all the same `size` (icon-sm pairs with sm, icon-xs with xs, icon with default). This is the runtime twin of the static `mixed-button-size` rule and catches rows assembled from variables.",
52
+ },
46
53
  {
47
54
  id: "sibling-card-gap",
48
55
  severity: "error",
@@ -185,6 +192,16 @@ export function controlHeightMismatches(rows) {
185
192
  return rows.filter((r) => new Set(r.heights).size > 1);
186
193
  }
187
194
 
195
+ /**
196
+ * Flex rows whose Buttons render at different heights (spread > 0.5px). Heights are NOT rounded:
197
+ * 28 vs 28.4 is the same size, 24 vs 28 is `xs` beside `sm`. @param {{name:string, heights:number[]}[]} rows
198
+ */
199
+ export function mixedButtonHeights(rows, tolerance = 0.5) {
200
+ return rows.filter(
201
+ (r) => r.heights.length > 1 && Math.max(...r.heights) - Math.min(...r.heights) > tolerance,
202
+ );
203
+ }
204
+
188
205
  /** Adjacent card pairs closer than the minimum gap. @param {{gap:number}[]} pairs */
189
206
  export function tightCardPairs(pairs, min = 8) {
190
207
  return pairs.filter((p) => p.gap < min);
@@ -13,6 +13,7 @@ import {
13
13
  alertControlIssues,
14
14
  missingCssLayers,
15
15
  controlHeightMismatches,
16
+ mixedButtonHeights,
16
17
  tightCardPairs,
17
18
  starvedRowTexts,
18
19
  } from "./visual-audit-rules.mjs";
@@ -261,6 +262,27 @@ function collectInPage() {
261
262
  heights: controls.map((c) => Math.round(c.getBoundingClientRect().height)),
262
263
  });
263
264
  }
265
+ // Button rows — every flex row (any container, not only .ui-flex: CardFooter, a dialog footer,
266
+ // PageHeader actions) whose Buttons render at more than one height. A child counts when it IS a
267
+ // Button or directly wraps one (a Tooltip trigger span). `h-auto` opts a Button out of the
268
+ // control tier on purpose (a two-line list item), so it is not a row member.
269
+ const buttonRows = [];
270
+ const isRowButton = (el) => el.matches("[data-slot=button]") && !el.classList.contains("h-auto");
271
+ for (const row of document.querySelectorAll("body *")) {
272
+ const cs = getComputedStyle(row);
273
+ if (!cs.display.includes("flex") || !cs.flexDirection.startsWith("row") || !visible(row))
274
+ continue;
275
+ const buttons = [...row.children]
276
+ .filter(visible)
277
+ .map((c) => (isRowButton(c) ? c : c.querySelector(":scope > [data-slot=button]")))
278
+ .filter((b) => b && isRowButton(b) && visible(b));
279
+ if (buttons.length < 2) continue;
280
+ buttonRows.push({
281
+ name: (row.className || row.tagName).toString().slice(0, 40),
282
+ heights: buttons.map((b) => b.getBoundingClientRect().height),
283
+ sizes: buttons.map((b) => b.getAttribute("data-size") || "?"),
284
+ });
285
+ }
264
286
  // Sibling cards — the gap between consecutive cards in one parent.
265
287
  const cardPairs = [];
266
288
  const seen = new Set();
@@ -295,7 +317,7 @@ function collectInPage() {
295
317
  });
296
318
  }
297
319
  }
298
- return { accents, targets, text, alerts, layers, rows, cardPairs, rowTexts };
320
+ return { accents, targets, text, alerts, layers, rows, buttonRows, cardPairs, rowTexts };
299
321
  }
300
322
  /* c8 ignore stop */
301
323
 
@@ -395,6 +417,14 @@ async function audit(targets, { chromium }) {
395
417
  `row "${r.name}" mixes control heights ${[...new Set(r.heights)].join("/")}px`,
396
418
  ),
397
419
  );
420
+ for (const r of mixedButtonHeights(m.buttonRows || []))
421
+ findings.push(
422
+ buildFinding(
423
+ "mixed-button-height",
424
+ url,
425
+ `row "${r.name}" mixes Button heights ${r.heights.map((h) => +h.toFixed(1)).join("/")}px (sizes ${r.sizes.join("/")})`,
426
+ ),
427
+ );
398
428
  const tight = tightCardPairs(m.cardPairs || []);
399
429
  if (tight.length)
400
430
  findings.push(