Skip to content

refactor(joint-react): coherent event-related public type names#3347

Open
kumilingus wants to merge 10 commits into
clientIO:devfrom
kumilingus:refactor/joint-react-rename-event-context-params
Open

refactor(joint-react): coherent event-related public type names#3347
kumilingus wants to merge 10 commits into
clientIO:devfrom
kumilingus:refactor/joint-react-rename-event-context-params

Conversation

@kumilingus
Copy link
Copy Markdown
Contributor

@kumilingus kumilingus commented Jun 4, 2026

Summary

Tightens the joint-react public type surface around paper / graph events and other callback argument types, expands the main @joint/react barrel so stories no longer need deep @joint/react/presets imports, and drops the misleading "normalized" terminology from internal naming.

Breaking changes (public API)

Paper events — typed on* interface + helper

Old New
NormalizedPaperHandlers PaperEventHandlers
(new) PaperEventHandler<K extends keyof PaperEventHandlers>

Coherent triple:

  • PaperEventMap — full handlers map you subscribe with (raw native + on*). Mirrors dia.Paper.EventMap lineage from joint-core.
  • PaperEventHandlers — typed on* subset interface (mixed into PaperProps).
  • PaperEventHandler<K> — single handler fn for key K. Matches mvc.EventHandler precedent.

Event payload args (callback first parameter)

Old New
Pointer{Cell,Element,Link,Blank}EventContext Pointer*EventParams
Hover{Cell,Element,Link,Blank}EventContext Hover*EventParams
Wheel{Cell,Element,Link,Blank}EventContext Wheel*EventParams
MagnetEventContext MagnetEventParams
LinkConnectEventContext LinkConnectEventParams
Paper{Hover,Pan,Pinch}EventContext Paper*EventParams
Translate/Scale/Resize/TransformEventContext *EventParams

Three internal composition helpers (CellEventContext, ElementEventContext, LinkEventContext) renamed for in-file consistency. Not exported.

Validator / utility callback args

Old New
ValidateConnectionContext ValidateConnectionParams
ValidateEmbeddingContext ValidateEmbeddingParams
ValidateUnembeddingContext ValidateUnembeddingParams
CellVisibilityContext CellVisibilityParams
ConnectionStrategyContext ConnectionStrategyParams
InteractiveContext InteractiveParams
DefaultLinkContext DefaultLinkParams
PortalSelectorContext PortalSelectorParams

Misc renames

Old New
TransformMeasurement TransformElementLayout
PortShape ElementPortShape

Main barrel expansion

@joint/react now re-exports the full set of preset utilities that stories were reaching for via @joint/react/presets:

  • linkRoutingStraight, linkRoutingOrthogonal, linkRoutingSmooth + their option types and LinkMode
  • All 16 linkMarker* symbols
  • elementAttributes, linkAttributes
  • elementPort, elementPorts, ElementPortShape

All in-repo stories migrated to the main-barrel import. The @joint/react/presets alias is removed from .storybook/main.ts, tsconfig.json, and tsconfig.types.json so stories can no longer reach into the deep path. The published @joint/react/presets subpath export in package.json is unchanged — external consumers can still use the deep import.

Non-API changes

  • Drops the misleading "Normalized" terminology in paper-events.ts and paper.types.ts JSDoc / section headings — the camelCase on* shape is just a typed convenience layer over native event names, not a normalization step.
  • Renames the internal NORMALIZED_KEYS constant → PAPER_EVENT_KEYS.
  • Tightens stale JSDoc references to pre-rename type names.

Test plan

  • yarn typecheck — exit 0
  • yarn lint — 0 errors
  • yarn jest — pass
  • yarn builddist/types contains the new names

Notes

🤖 Generated with Claude Code

kumilingus and others added 3 commits June 4, 2026 12:37
…entParams

Companion to the validator callback rename (PR clientIO#3346). Renames all 21
exported event payload types and the three internal composition helpers
(CellEventContext, ElementEventContext, LinkEventContext) so the suffix
is uniform across joint-react's public callback-arg surface.

Renames (public, breaking):
- Pointer{Cell,Element,Link,Blank}EventContext -> *EventParams
- Hover{Cell,Element,Link,Blank}EventContext   -> *EventParams
- Wheel{Cell,Element,Link,Blank}EventContext   -> *EventParams
- MagnetEventContext, LinkConnectEventContext  -> *EventParams
- Paper{Hover,Pan,Pinch}EventContext           -> *EventParams
- Translate/Scale/Resize/TransformEventContext -> *EventParams

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tLayout

Companion in-flight cleanup bundled with the *EventContext rename:
- TransformMeasurement -> TransformElementLayout (callback type)
- MeasurementContext -> TransformElementLayoutParams (callback arg)
- HTMLBoxProps now sourced from ./components/html-box (was aliased
  HTMLHostProps); HTMLBox component carries its own props type
- Story consumers (card, list-node, markup-selectors, svg-node, flowchart)
  updated to import the new type names

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…..Params

Renames callback argument types whose names collide with React's Context concept.
These objects are plain parameter bags, not contexts.

Public API breaking change:
- ValidateConnectionContext   -> ValidateConnectionParams
- ValidateEmbeddingContext    -> ValidateEmbeddingParams
- ValidateUnembeddingContext  -> ValidateUnembeddingParams
- CellVisibilityContext       -> CellVisibilityParams
- ConnectionStrategyContext   -> ConnectionStrategyParams
- InteractiveContext          -> InteractiveParams
- DefaultLinkContext          -> DefaultLinkParams
- PortalSelectorContext       -> PortalSelectorParams

EventContext types (PointerCellEventContext, etc.) are unchanged.

Also fixes a broken import in presets/index.ts that referenced
ValidateConnectionParams before it existed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kumilingus kumilingus changed the title refactor(joint-react): rename *EventContext callback arg types to *EventParams refactor(joint-react): rename callback arg types from ...Context to ...Params Jun 4, 2026
kumilingus and others added 4 commits June 4, 2026 14:33
…events

Rename `NORMALIZED_KEYS` → `PAPER_EVENT_KEYS` (internal constant; not
exported). Reword section headings and JSDoc that called the camelCase
`on*` handler shape "normalized" — it isn't normalization in any meaningful
sense, just a typed convenience layer over native event names. Replace with
concrete language ("camelCase `on*`", "params-object", "`on*` handler keys").
Also fixes one stale JSDoc reference to the pre-rename `PaperEventCallback`.

No runtime change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…Map → GraphEvents

Drops the "Map" suffix on the two public event-handler-map types. The
shape is already a map by construction (event name → handler); the suffix
was noise and shadowed `dia.Paper.EventMap` / `dia.Graph.EventMap` from
core. Coherent triple now:

  PaperEvents          — full handlers map you subscribe with (raw + on*)
  PaperEventHandlers   — typed `on*` subset interface
  PaperEventHandler<K> — one handler fn for key K

`GraphEvents` follows the same pattern (raw only — no `on*` layer today).
Also tightens JSDoc that called the camelCase `on*` form "normalized",
matching the previous commit's terminology cleanup.

Internal `isPaperEventMap` type guard becomes `isPaperEvents`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kumilingus kumilingus changed the title refactor(joint-react): rename callback arg types from ...Context to ...Params refactor(joint-react): coherent event-related public type names Jun 4, 2026
kumilingus and others added 3 commits June 4, 2026 18:03
…onsolidate story imports

`linkRoutingStraight` / `linkRoutingOrthogonal` / `linkRoutingSmooth` are
the recommended public API for Paper `linkRouting` — they now ship from
`@joint/react` directly instead of requiring a deep `@joint/react/presets`
import. All stories, demos, tutorials, and JSDoc examples switched to the
main-barrel import and consolidated into existing `@joint/react` import
blocks where they were already imported from there.

Presets re-export still works; this is purely additive on the public API
side and a cleanup on the consumer side.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… drop @joint/react/presets alias for stories

Adds link markers, link/element attributes, link routing option types, and
`LinkMode` to the `@joint/react` main-barrel export. Migrates the last 5
stories that still imported from `@joint/react/presets` to use the main
barrel and removes the `@joint/react/presets` alias from the storybook
vite resolver and the workspace tsconfig path mappings so stories can no
longer reach into the presets subpath.

The published `@joint/react/presets` subpath export in `package.json`
stays — only the internal alias is dropped. External consumers can still
use the deep import; this is purely a story-side enforcement.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kumilingus kumilingus requested a review from samuelgja June 4, 2026 17:28
@kumilingus kumilingus marked this pull request as ready for review June 4, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant