refactor(joint-react): unified ElementRecord / LinkRecord with portMap, labelMap, style#3253
Open
kumilingus wants to merge 11 commits intoclientIO:devfrom
Open
refactor(joint-react): unified ElementRecord / LinkRecord with portMap, labelMap, style#3253kumilingus wants to merge 11 commits intoclientIO:devfrom
kumilingus wants to merge 11 commits intoclientIO:devfrom
Conversation
…rd types - Split ElementRecord/LinkRecord into portal vs native discriminated unions - Rename FlatElementPort → ElementRecordPort, FlatLinkLabel → LinkRecordLabel, FlatLinkPresentationData → LinkRecordPresentation - Rename MixedElementRecord → AnyElementRecord, MixedLinkRecord → AnyLinkRecord - Convert NativeElementRecord/NativeLinkRecord to interfaces (extends dia.*.Attributes) - Simplify generics: remove conditional types, use simple interfaces with data?: D - Make data required in ElementWithLayout and ResolvedLink (always present at runtime) - Fix joint.d.ts: Link.Attributes extends GenericAttributes (not Cell.GenericAttributes) - Update all stories/demos to use specific types (ElementRecord, LinkRecord, NativeElementRecord) - Rename test files to match hook names (use-element-defaults, use-link-defaults) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the multi-type system (
PortalElementRecord,NativeElementRecord,AnyElementRecord, etc.) with a singleElementRecordandLinkRecordthat support both declarative and native JointJS formats.New API
Elements —
ElementRecord<D>extendsdia.Element.Attributes:portMap?: Record<string, ElementPort>— declarative ports (converted to nativeportsby mapper)portStyle?: Partial<ElementPort>— default style for all ports inportMapports— native JointJS format, passed through as-isdata?: D— custom user dataLinks —
LinkRecord<D>extendsdia.Link.Attributes:style?: LinkStyle— declarative link presentation (color,width,markers, etc.)labelMap?: Record<string, LinkLabel>— declarative labels (converted to nativelabelsarray by mapper)labelStyle?: Partial<LinkLabel>— default style for all labels inlabelMaplabels— native JointJS Label[] format, passed through as-isdata?: D— custom user dataWhat changed
ElementRecordandLinkRecordreplace 6 types (Portal*,Native*,Any*)portMap/labelMap: declarative (Record-keyed) ports and labels use new field names, avoiding collision with nativeports/labelsstyle: link presentation fields (color,width,sourceMarker, etc.) moved from top-level intostyle: { ... }objectdia.*.Attributes— all native properties pass throughdata?: Dis always optional (no conditional types), interfaces are extensible viaextendsdatarequired in hooks:ElementWithLayoutandResolvedLinkguaranteedata: D(always present at runtime)ElementRecordPort→ElementPort,LinkRecordStyle→LinkStyle,LinkRecordLabel→LinkLabelportMap/labelMappresence (notypefield discriminant needed). Throws if both declarative and native formats are provided.isShallowEqual: widened toobject | undefined(generic utility)use-flat-element-data.test.ts→use-element-defaults.test.ts,use-flat-link-data.test.ts→use-link-defaults.test.tsRemoved from public API
PortalElementRecord,NativeElementRecord,AnyElementRecordPortalLinkRecord,NativeLinkRecord,AnyLinkRecordMixedElementRecord,MixedLinkRecordFlatElementPort,FlatLinkLabel,FlatLinkPresentationDataTest plan
npx tsc --noEmit— 0 new errorsyarn jest— 533 pass, pre-existing failures onlyportMaprender portsportspass throughstylerender correctlylabelMaprender labelslabelsarray pass through🤖 Generated with Claude Code