An open source design system that's fully customizable and agent ready
TypeScript
spec(public-component-api): every interaction hook has a non-React path (INV22) (#9141)
Cindy Zhang2c32c719d0e2
diff --git a/docs/architecture/public-component-api.md b/docs/architecture/public-component-api.mdindex aabe3004ba..f90096f904 100644--- a/docs/architecture/public-component-api.md+++ b/docs/architecture/public-component-api.md@@ -201,6 +201,16 @@ guidance owns the process used to propose and test APIs.built entirely on a public factory are one API with that factory, not asecond one (`spec:AST-107` FR6, FR8). A deprecation followsINV9.+- **INV22 — Every interaction hook has a non-React path.** A public hook that+ attaches gesture, press, drag, or motion behavior to an element delegates+ entirely to a public `create…(element, options)` factory that takes the same+ options, with React content taken as a render callback (`spec:AST-107` FR8),+ and returns a handle with `destroy()` (`spec:AST-107` FR6), except a+ hook whose result only an Astryx React component or StyleX can use, such as+ `useAnimatedLayout`, `useEntryAnimation`, `useContainerReveal`,+ `useTouchTrigger`, `useTableRowExpansion`, and `useTableColumnResize`. A hook+ whose current signature cannot delegate gains a ref-taking signature beside+ it; the old signature is deprecated under INV9.This record applies to stable public packages. Lab components are not stablepublic promises until promotion.@@ -274,27 +284,36 @@ copy the component matrix.## Verification-| Invariant | Evidence | Failure signal |-| ----------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| INV1, INV8 | Export, public-subpath, prop, and ref checks | A promised component/type cannot be imported or its ref cannot reach the contract element |-| INV2 | Naming and logical-direction lint/tests | Equivalent concepts use conflicting names or physical direction leaks into public API |-| INV3, INV4 | Historical API review benchmark and `spec:AST-002` evidence | A prop combines unrelated axes or exposes a derivable implementation choice |-| INV5, INV6, INV7 | BaseProps/passthrough lint and representative runtime tests | Consumer ARIA/data/style/events are dropped, clobber component semantics, or fail to compose |-| INV9 | Published-surface, Changeset, migration, and public-type checks | A released API changes without explicit compatibility evidence |-| INV11 | Public-API admission review plus owning theming/component tests | A public semantic custom property exposes derivable or unsupported implementation detail |-| INV12, INV13 | Generated declaration/export/behavior inventory plus canonical-owner mapping | A reachable supporting type or behavior outside `./internal/*` is called internal, or mechanical evidence is treated as permission to accept it |-| INV14 | `AppShell.test.tsx` | A component hardcodes a divergent point or treats equality as below |-| 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 |+| Invariant | Evidence | Failure signal |+| ----------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| INV1, INV8 | Export, public-subpath, prop, and ref checks | A promised component/type cannot be imported or its ref cannot reach the contract element |+| INV2 | Naming and logical-direction lint/tests | Equivalent concepts use conflicting names or physical direction leaks into public API |+| INV3, INV4 | Historical API review benchmark and `spec:AST-002` evidence | A prop combines unrelated axes or exposes a derivable implementation choice |+| INV5, INV6, INV7 | BaseProps/passthrough lint and representative runtime tests | Consumer ARIA/data/style/events are dropped, clobber component semantics, or fail to compose |+| INV9 | Published-surface, Changeset, migration, and public-type checks | A released API changes without explicit compatibility evidence |+| INV11 | Public-API admission review plus owning theming/component tests | A public semantic custom property exposes derivable or unsupported implementation detail |+| INV12, INV13 | Generated declaration/export/behavior inventory plus canonical-owner mapping | A reachable supporting type or behavior outside `./internal/*` is called internal, or mechanical evidence is treated as permission to accept it |+| INV14 | `AppShell.test.tsx` | A component hardcodes a divergent point or treats equality as below |+| 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 |+| INV22 | Public-API review of each public gesture, press, drag, or motion hook against its `create…` factory | A public interaction hook with no public factory taking the same options and returning `destroy()`, outside the listed exemptions |+| Consumer-doc projection | `docPropReferences.test.ts` and `docPropLiterals.test.ts` | Docs name a nonexistent prop or omit public literal choices |Known verification gaps:+- INV22: known gaps include `useLongPress`, `useMenuPress`,+ `usePressFeedback`, `useClickableContainer`, `useInputContainer`,+ `useOverlay`, `useCombobox`, `useMultiCombobox`, `useResizable`,+ `useTooltip`, `useHoverCard`, and `useChatStreamScroll`: each attaches+ gesture, press, drag, or motion behavior and has no `create…` factory yet;+ no full inventory exists yet. Each conforms by adding its factory and, where+ its signature cannot delegate, a ref-taking signature beside the deprecated+ one.- The passthrough lint is warning-only while known violations remain.- The current source-to-doc completeness matcher still looks for old prefixedprops interfaces, so it does not yet prove full prop coverage.