Skip to content

feat(joint-react): make element/link data types unconstrained#3197

Draft
kumilingus wants to merge 6 commits intoclientIO:devfrom
kumilingus:feat/joint-react-unconstrained-data-types
Draft

feat(joint-react): make element/link data types unconstrained#3197
kumilingus wants to merge 6 commits intoclientIO:devfrom
kumilingus:feat/joint-react-unconstrained-data-types

Conversation

@kumilingus
Copy link
Contributor

@kumilingus kumilingus commented Mar 2, 2026

Summary

Unconstrained data types

  • Remove extends constraints from all framework generics so custom mapper users can use any data shape without extending FlatElementData/FlatLinkData
  • Rename types: GraphElementFlatElementData, GraphLinkFlatLinkData, GraphElementPortFlatElementPort, GraphLinkEndFlatLinkEnd, GraphLinkLabelFlatLinkLabel
  • Generic parameters renamed from <Element extends GraphElement = GraphElement> to <ElementData = FlatElementData> (unconstrained with defaults)
  • Default mappers retain extends constraints since they destructure known properties
  • Remove unused GraphCell type and isGraphCell function

Introduce CellId type alias

  • Introduce CellId = string type alias and replace all dia.Cell.ID and bare string (when used as cell identifiers) with CellId across the package (~35 files)
  • Add as CellId casts at JointJS boundary points where dia.Cell.ID (string | number) narrows to CellId (string)
  • Export CellId from the public API

Simplify hook signatures

  • Replace unnecessary generic + conditional return types on useNodeLayout and useLinkLayout with clean function overloads
  • Fix useLinkLayout context return type (was LinkLayout | undefined, now correctly LinkLayout)

Remove dead code (15 functions, 3 files deleted)

  • is.ts: Setter, isSetter, isDefined, isAttribute, isDiaId, isLinkInstance, isCellInstance, assertGraph; make hasChildren non-exported
  • object-utilities.ts: makeOptions
  • link-utilities.ts: getLinkPortId, getLinkMagnet
  • fast-equality.ts: shallowArrayEqual
  • scheduler.ts: createScheduler
  • Delete entire files: is-react-element.ts, noop-selector.ts, utils/clear-view.ts

Storybook

  • Add with-render-link example with docs and toggle to switch renderLink on/off
  • Simplify stress example: remove renderLink / custom mapper, use default JointJS link rendering

Test plan

  • TypeScript typecheck passes
  • All Jest tests pass (40 suites, 399 tests)
  • ESLint passes (no new errors)
  • Verify Storybook renders correctly
  • Verify custom mapper example still works

🤖 Generated with Claude Code

kumilingus and others added 6 commits March 2, 2026 16:49
…tom mappers

Remove `extends` constraints from framework generics so custom mapper users
can use any data shape without extending FlatElementData/FlatLinkData.
Rename GraphElement → FlatElementData, GraphLink → FlatLinkData, and related
types (GraphElementPort → FlatElementPort, GraphLinkEnd → FlatLinkEnd,
GraphLinkLabel → FlatLinkLabel). Remove unused GraphCell type and isGraphCell.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kumilingus kumilingus requested a review from samuelgja March 2, 2026 23:06
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