An open source design system that's fully customizable and agent ready
TypeScript
architecture(public-component-api): four API-shape principles (INV18–INV21) (#8459)
Cindy Zhang5b691cda7132
diff --git a/docs/architecture/public-component-api.md b/docs/architecture/public-component-api.mdindex db632a68de..c84890ad9f 100644--- a/docs/architecture/public-component-api.md+++ b/docs/architecture/public-component-api.md@@ -172,6 +172,26 @@ guidance owns the process used to propose and test APIs.platform (`spec:AST-012` FR9). It keeps no compact numbers of its own, asINV14 keeps no parallel breakpoint table. A layout width the caller picks,such as AppShell's `mobileNav.breakpoint`, follows INV14 instead.+- **INV18 — Compose along the anatomy.** Avoid props that reach deep into a component's anatomy (e.g.+ picking a specific prop or label of a subcomponent). Build compositions+ instead. Compositions must follow the component's anatomy; never expose a way+ to compose or render a slot not described in the anatomy; and slots must have+ components. Config objects are fine: plain data that describes actions or options (for example `swipeActions`' array of `{label, icon, onActivate}`) is not a slot. 'Slots must have components' applies to rendered content slots, places that accept arbitrary nodes; such a slot must be a part named in the component's anatomy, and the caller fills it with a component. This extends INV3's rule that a parent does not duplicate a+ composed child's state; a slot's styling follows INV15 and+ `architecture:component-theming-surface`. See+ [Slots and composition](../contributing/api-conventions.md#slots-and-composition).+- **INV19 — Resource cost is weighed against the feature.** Balance resource load against feature+ functionality and cross-platform concerns. If a feature has a large resource+ cost, consider plugging the behavior in. Named props for features are also+ fine (like `collapsible`).+- **INV20 — Variants, not visual booleans.** Avoid boolean flags that only swap visuals; prefer variants. This+ applies INV2's naming and INV4's caller-owned intent to visual choices; see+ [Open visual vocabularies and closed axes](../contributing/api-conventions.md#open-visual-vocabularies-and-closed-axes).+- **INV21 — One API per job.** No new+ API that shares a job with existing API, unless the existing API is being+ deprecated in favor of it. INV3 keeps one prop to one concept and INV16 keeps+ one `presentation` prop for a surface choice; INV21 applies the same rule+ across props, components, hooks, and factories. A deprecation follows INV9.This record applies to stable public packages. Lab components are not stablepublic promises until promotion.@@ -256,6 +276,10 @@ copy the component matrix.| INV15 | Public-API review of the generated declaration inventory | A part or StyleX-typed styling prop ships without class-name and inline-style counterparts on the same element || INV16 | Public-API review of touch presentations plus coarse- and fine-pointer runtime tests | A stable component that presents a different surface or switches an open surface's input mode under a coarse pointer and has no `presentation` value that keeps its fine-pointer surface and mode; such a touch mode callers cannot reach; a default that overrides an explicit caller choice || INV17 | Resolver tests at the compact edges plus public-API review | A component that chooses a presentation by screen size with its own numbers, or disagrees with the theme compact definition at width 768 or height 500 |+| INV18 | Public-API review against the component's anatomy table | A prop that selects or configures a subcomponent's prop or label, a composition that renders a slot the anatomy does not describe, or a rendered content slot that is not a part named in the anatomy |+| INV19 | Public-API review with a bundle and runtime cost note for a costly feature | A feature with a large resource cost that every caller pays with no plug-in path or named feature prop |+| INV20 | Public-API review of new boolean props | A boolean whose only effect is a visual swap where a variant fits |+| INV21 | Public-API review against existing props, components, hooks, and factories | A new API that shares a job with an existing one that is not being deprecated in its favor || Consumer-doc projection | `docPropReferences.test.ts` and `docPropLiterals.test.ts` | Docs name a nonexistent prop or omit public literal choices |Known verification gaps:@@ -267,5 +291,13 @@ Known verification gaps:delta across supporting types, context members, hook returns, utility signatures,defaults, CLI schemas, and observable behavior for both the branch and syntheticmerge. Reviews must build that inventory explicitly until enforcement exists.+- INV18: shipped content slots that their anatomy does not name yet include+ PowerSearch's `startIcon` and `endContent`, SideNav's `topContent`,+ `footer`, and `footerIcons`, Tokenizer's `startIcon`, DropdownMenu's+ `header` and `footer`, and the picker option's `action`; no full inventory+ exists yet. Each conforms by naming the part, with no API change.+- INV18: shipped props that configure a subcomponent's label or target, such+ as TopNavMegaMenuFeaturedCard's `linkLabel` and `linkHref` and+ TopNavHeading's `logoLabel`, conform only through replacement under INV9.These gaps are named here rather than treating partial checks as complete proof.diff --git a/docs/contributing/api-conventions.md b/docs/contributing/api-conventions.mdindex 33e32de602..23a122b261 100644--- a/docs/contributing/api-conventions.md+++ b/docs/contributing/api-conventions.md@@ -433,6 +433,14 @@ out of architecture records.- `xstyle`, `className`, `style`, a ref, or an event handler is dropped orclobbered by spread order.- A parent wraps slot content or mirrors props that belong to the slotted child.+- A prop reaches into a subcomponent's anatomy, a composition renders a slot+ the anatomy does not describe, or a rendered content slot is not a part named in the anatomy+ ([INV18](../architecture/public-component-api.md#boundaries-and-invariants)).+- A feature with a large resource cost loads for every caller, with no plug-in+ path or named feature prop (INV19).+- A boolean prop only swaps visuals where a variant fits (INV20).+- A new API shares a job with an existing one that is not being deprecated in+ its favor (INV21).- A proposal invents a nested `theme.components.button.variants` layer instead ofusing the current component target and style-key contract.- A green docs parser is treated as full API proof. Parsing and selected drift