Skip to content

feat(joint-react): add new set hooks and better ts support #2947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

samuelgja
Copy link
Contributor

@samuelgja samuelgja commented Apr 30, 2025

Description

https://github.com/orgs/clientIO/projects/6/views/13?pane=issue&itemId=107895468
This PR addresses several improvements and fixes related to TypeScript support in @joint/react, particularly focusing on method visibility and the addition of new functions. Below are the key changes introduced:

@joint/react Changes:

  1. New set hooks:

    • New useAddLink and useAddElement hooks for adding (pushing) new data to the state
    • New useRemoveCell hook, for remove cell or link based on dia.cell.id
  2. Minor Adjustments in React Components:

    • The component rendering logic has been fine-tuned in various places, including the handling of SVG elements and dynamic updates.

Motivation and Context

The main motivation for this update is to improve the accessibility and flexibility of the cache-clearing functionality by making the clearNodeCache and clearNodesCache methods publicly available. The new set methods for @joint/react - we had been missing adding and removing elements.

Plus generate new autogerated docs.


These changes ensure better performance and usability for users who interact with the JointJS API, making it easier to manage elements and their cached states within a graph.

@samuelgja samuelgja requested a review from Copilot April 30, 2025 02:54
@samuelgja samuelgja self-assigned this Apr 30, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates and refines the documentation for the @joint/react package. Changes include numerous “Defined in:” reference adjustments across interfaces, functions, and classes; type improvements such as using explicit literal types (e.g. "react") in union definitions; and updates to layout dimensions in Storybook decorators for improved UI display.

Reviewed Changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated no comments.

File Description
packages/joint-react/docs/interfaces/* Updated “Defined in:” references and union type order for improved clarity and consistency.
packages/joint-react/docs/functions/* Revised function documentation text to use precise language (e.g. “Set the element attribute in the graph”) and updated type defaults.
packages/joint-react/.storybook/decorators/with-simple-data.tsx Adjusted element dimensions (width increased from 100 to 150; Paper height increased from 350 to 450) for better visual layout.
Other files Minor documentation updates ensuring consistency across all hooks, interfaces, and class definitions.
Comments suppressed due to low confidence (4)

packages/joint-react/docs/interfaces/GraphProps.md:60

  • [nitpick] The union ordering for 'defaultElements' has been updated; please verify that the new order and type annotations are consistently applied across similar interfaces.
> `readonly` `optional` **defaultElements**: (`Element`<`Attributes`, `ModelSetOptions`> | [`GraphElementBase`](GraphElementBase.md)<`string`>)

packages/joint-react/.storybook/decorators/with-simple-data.tsx:21

  • The element width was increased from 100 to 150; please ensure this change aligns with your design guidelines and overall UI consistency.
-    width: 100,
+    width: 150,

packages/joint-react/.storybook/decorators/with-simple-data.tsx:71

  • The Paper component height has been updated from 350 to 450; please confirm that this layout revision is intentional and consistent with other story dimensions.
-          height={350}
+          height={450}

packages/joint-react/docs/functions/createElements.md:20

  • The default element type has been set to the literal "react"; please verify that this explicit default value is consistent with the expected API design and usage throughout the codebase.
> `Type` *extends* `string` = "react"

@samuelgja samuelgja requested a review from kumilingus April 30, 2025 02:55
@samuelgja samuelgja changed the title feat(joint-react): add custom hooks for element and link management i… feat(joint-react): add new set hooks and better ts support Apr 30, 2025
@samuelgja samuelgja force-pushed the chore/joint-react-new-set-hooks-better-ts-support branch from 8c48dbd to 620fd2a Compare April 30, 2025 06:18
@samuelgja samuelgja marked this pull request as draft April 30, 2025 06:26
@samuelgja samuelgja marked this pull request as ready for review April 30, 2025 09:39
@clientIO clientIO deleted a comment from samuelgja May 3, 2025
@kumilingus kumilingus merged commit f7dc7f5 into clientIO:dev May 3, 2025
1 check passed
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.

2 participants