Skip to content

Commit a1a6151

Browse files
authored
docs(public-component-api): interaction utilities have matching non-React equivalents; shipped APIs are grandfathered (#9973)
* docs(public-component-api): public interaction hooks take one config object; the element ref is a named field * docs(public-component-api): INV22 asks only that a hook and its twin match; one-config and grandfather rules stand alone * docs(public-component-api): the slot-hook example and an owner-added twin * docs(public-component-api): INV22 is only non-React equivalents that match their hooks * docs(public-component-api): INV22 keeps main's exempt hooks in the no-equivalent case * docs(public-component-api): a neutral slot-hook illustration; shipped ref names in INV2
1 parent 048476f commit a1a6151

1 file changed

Lines changed: 37 additions & 31 deletions

File tree

‎docs/architecture/public-component-api.md‎

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ guidance owns the process used to propose and test APIs.
117117
`elevation`, which takes values from `Elevation`, as Card, Button, and Banner
118118
take it. `lift` names motion under a press, such as
119119
Switch's thumb lift, Slider's `springs.sliderLift`, and ContextMenu's
120-
`springs.contextMenuLift`, so it does not name a layout distance.
120+
`springs.contextMenuLift`, so it does not name a layout distance. An element
121+
ref a hook takes is named for the element's job, as `containerRef`,
122+
`scrollRef`, `menuRef`, `triggerRef`, and `inputRef` are, or `ref` when the element has
123+
no narrower job.
121124
- **INV3 — One prop controls one independent concept.** A prop does not silently
122125
suppress an unrelated prop. A parent does not duplicate state already owned by
123126
a composed child. One interaction behavior is one prop, never parallel touch,
@@ -220,26 +223,29 @@ guidance owns the process used to propose and test APIs.
220223
- **INV20 — Variants, not visual booleans.** Avoid boolean flags that only swap visuals; prefer variants. This
221224
applies INV2's naming and INV4's caller-owned intent to visual choices; see
222225
[Open visual vocabularies and closed axes](../contributing/api-conventions.md#open-visual-vocabularies-and-closed-axes).
223-
- **INV21 — One API per job.** No new
224-
API that shares a job with existing API, unless the existing API is being
225-
deprecated in favor of it. INV3 keeps one prop to one concept and INV16 keeps
226-
one `presentation` prop for a surface choice; INV21 applies the same rule
227-
across props, components, hooks, and factories. A hook that delegates
228-
entirely to a public factory, with no behavior of its own, and a component
229-
built entirely on a public factory are one API with that factory, not a
230-
second one (`spec:AST-107` FR6, FR8). A deprecation follows
231-
INV9.
232-
- **INV22 — Every interaction hook has a non-React path.** A public hook that
233-
attaches gesture, press, drag, or motion behavior to an element delegates
234-
entirely to a public `create…(element, options)` factory that takes the same
235-
options, with React content taken as a render callback (`spec:AST-107` FR8),
236-
and returns a handle with `destroy()` (`spec:AST-107` FR6), except a
237-
hook whose result only an Astryx React component or StyleX can use, such as
238-
`useAnimatedLayout`, `useEntryAnimation`, `useContainerReveal`,
239-
`useTouchTrigger`, `useTableRowExpansion`, and `useTableColumnResize`. A hook
240-
whose current signature cannot delegate gains a ref-taking signature beside
241-
it; the old signature is deprecated under INV9. A factory's announced and shown
242-
strings follow `architecture:internationalization` INV3a's options.
226+
- **INV21 — One API per job.** No new API that shares a job with existing API,
227+
unless the existing API is being deprecated in favor of it. INV3 keeps one
228+
prop to one concept and INV16 keeps one `presentation` prop for a surface
229+
choice; INV21 applies the same rule across props, components, hooks, and
230+
factories. A hook that delegates entirely to a public factory, with no
231+
behavior of its own, and a component built entirely on a public factory are
232+
one API with that factory, not a second one (`spec:AST-107` FR6, FR8). A
233+
deprecation follows INV9. A hook whose value a component takes through one
234+
slot prop is one API with that component, not a second one, as in `const value
235+
= useX(…); <Component x={value} />` (owner decision, 2026-11-04).
236+
- **INV21a — Shipped APIs change only for user value.** A breaking or
237+
deprecating change to a shipped public API needs user value; conformance to a
238+
system rule alone does not justify it. New APIs follow the current rules;
239+
shipped APIs are grandfathered until a real need arises (owner decision,
240+
2026-11-04). Each component API change still needs its own owner approval.
241+
- **INV22 — Interaction utilities have non-React equivalents.** Interaction
242+
utilities have non-React equivalents (`create…`) that closely match their
243+
hooks (the same option names and meanings, events and return concepts). A hook
244+
whose result only an Astryx component or StyleX can use (a slot hook, whose
245+
output feeds one Astryx component prop, or `useAnimatedLayout`,
246+
`useEntryAnimation`, `useContainerReveal`, `useTouchTrigger`,
247+
`useTableRowExpansion`, `useTableColumnResize`) has none by default; the owner
248+
may add one (owner decision, 2026-11-04).
243249
- **INV23 — Each private data attribute has one owner module.** A
244250
`data-astryx-*` attribute is private unless this invariant names it public.
245251
Each private attribute has one internal owner module in the package that
@@ -405,8 +411,9 @@ Rejected: component-local names for shared concepts.
405411
| 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 |
406412
| 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 |
407413
| INV20 | Public-API review of new boolean props | A boolean whose only effect is a visual swap where a variant fits |
408-
| 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 |
409-
| 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 |
414+
| 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; a hook fed to one component slot prop counted as a second API |
415+
| INV21a | Public-API review of each breaking or deprecating change to a shipped API | A breaking or deprecating change to a shipped public API justified only by conformance to a system rule |
416+
| INV22 | Public-API review of each public interaction utility hook against its `create…` equivalent | An interaction utility hook with no `create…` equivalent, outside hooks whose result only an Astryx component or StyleX can use, or an equivalent whose option names and meanings, events, or return concepts differ from its hook |
410417
| INV23 | `@astryx/no-raw-private-attribute` lint with its baseline (test files exempt), plus public-API review of the public list | A `data-astryx-*` name or selector written outside its owner module, a test, or the public list; a `dataAttr()` call that names a private attribute; an owner module that exports its raw name or a selector; a package that imports another package's owner module; a caller that sets a property an owner style it spreads also sets; a private attribute in a public export, `.doc.mjs`, or Changeset; a baseline entry added; a public data attribute changed without INV9 evidence |
411418
| INV24 | API report generator tests over representative entry points, plus the pull-request report's API changes | A promised export, prop, hook, type, custom property, theme target, or public attribute is missing from a report; a reachable internal-tagged member is missing; an `./internal/*` or Lab member appears; a stale committed report is not flagged, or its rows are listed as the pull request's API changes; the check fails a pull request |
412419
| INV25 | Public-API review routing against the pull request's API changes | A row that no current record decides does not reach human review; a row a current record decides is held for a human; an undeclared row alone draws a request for changes |
@@ -435,14 +442,13 @@ Known verification gaps:
435442
another keeps its name until a minor renames it under INV9. Outline's
436443
`offset` is the distance below the top of its scroll root
437444
(`component:Outline` FR4), not a gap from an anchor.
438-
- INV22: known gaps include `useLongPress`, `useMenuPress`,
439-
`usePressFeedback`, `useClickableContainer`, `useInputContainer`,
440-
`useOverlay`, `useCombobox`, `useMultiCombobox`, `useResizable`,
441-
`useTooltip`, `useHoverCard`, and `useChatStreamScroll`: each attaches
442-
gesture, press, drag, or motion behavior and has no `create…` factory yet;
443-
no full inventory exists yet. Each conforms by adding its factory and, where
444-
its signature cannot delegate, a ref-taking signature beside the deprecated
445-
one.
445+
- INV22: known gaps include `useLongPress`, `useMenuPress`, `usePressFeedback`,
446+
`useClickableContainer`, `useInputContainer`, `useOverlay`, `useCombobox`,
447+
`useMultiCombobox`, `useResizable`, `useTooltip`, `useHoverCard`, and
448+
`useChatStreamScroll`: each attaches gesture, press, drag, or motion behavior
449+
and has no `create…` factory yet; no full inventory exists yet. Each conforms
450+
by adding its factory; a shipped hook's signature changes only when a real
451+
need arises (INV21a).
446452
- The passthrough lint is warning-only while known violations remain.
447453
- The current source-to-doc completeness matcher still looks for old prefixed
448454
props interfaces, so it does not yet prove full prop coverage.

0 commit comments

Comments
 (0)