Skip to content

Commit 5311d16

Browse files
committed
feat(joint-react): sync with react plus and general fixes + remove paperProvider
1 parent 6141307 commit 5311d16

File tree

211 files changed

+8817
-7162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+8817
-7162
lines changed

examples/joint-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"devDependencies": {
1818
"@eslint/js": "^9.25.0",
19-
"@types/react": "^19.1.2",
19+
"@types/react": "^19.1.10",
2020
"@types/react-dom": "^19.1.2",
2121
"@vitejs/plugin-react": "^4.4.1",
2222
"eslint": "^9.25.0",

packages/joint-core/types/joint.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,17 +2323,17 @@ export namespace dia {
23232323

23242324
export namespace highlighters {
23252325

2326-
import HighlighterView = dia.HighlighterView;
2326+
type HighlighterView = dia.HighlighterView;
23272327

2328-
interface AddClassHighlighterArguments extends HighlighterView.Options {
2328+
interface AddClassHighlighterArguments extends dia.HighlighterView.Options {
23292329
className?: string;
23302330
}
23312331

2332-
interface OpacityHighlighterArguments extends HighlighterView.Options {
2332+
interface OpacityHighlighterArguments extends dia.HighlighterView.Options {
23332333
alphaValue?: number;
23342334
}
23352335

2336-
interface StrokeHighlighterArguments extends HighlighterView.Options {
2336+
interface StrokeHighlighterArguments extends dia.HighlighterView.Options {
23372337
padding?: number;
23382338
rx?: number;
23392339
ry?: number;
@@ -2342,7 +2342,7 @@ export namespace highlighters {
23422342
attrs?: attributes.NativeSVGAttributes;
23432343
}
23442344

2345-
interface MaskHighlighterArguments extends HighlighterView.Options {
2345+
interface MaskHighlighterArguments extends dia.HighlighterView.Options {
23462346
padding?: number;
23472347
maskClip?: number;
23482348
deep?: boolean;
@@ -4281,8 +4281,8 @@ export namespace attributes {
42814281
filter?: string | dia.SVGFilterJSON;
42824282
fill?: string | dia.SVGPatternJSON | dia.SVGGradientJSON;
42834283
stroke?: string | dia.SVGPatternJSON | dia.SVGGradientJSON;
4284-
sourceMarker?: dia.SVGMarkerJSON;
4285-
targetMarker?: dia.SVGMarkerJSON;
4284+
sourceMarker?: dia.SVGMarkerJSON | null;
4285+
targetMarker?: dia.SVGMarkerJSON | null;
42864286
vertexMarker?: dia.SVGMarkerJSON;
42874287
props?: SVGAttributeProps;
42884288
text?: string;

packages/joint-react-eslint/eslint.config.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const tsConfigPath = path.resolve("./", "tsconfig.json");
2121
const config = [
2222
// Global ignores
2323
{
24-
ignores: ["node_modules", "dist", "tsconfig.json"],
24+
ignores: ["node_modules", "dist", "bundle-dist", "tsconfig.json"],
2525
},
2626

2727
// Base recommended configs
@@ -124,7 +124,7 @@ const config = [
124124
"react-hooks/exhaustive-deps": [
125125
"error",
126126
{
127-
additionalHooks: "useInitAndSync",
127+
additionalHooks: "",
128128
},
129129
],
130130

@@ -139,6 +139,9 @@ const config = [
139139
"sonarjs/cognitive-complexity": "error",
140140
"sonarjs/prefer-immediate-return": "off",
141141
"sonarjs/todo-tag": "warn",
142+
// We do not switch to 19 yet! Remove in major React upgrade (with not support for lower version than react 19!)
143+
"@eslint-react/no-use-context": "off",
144+
"@eslint-react/no-forward-ref": "off",
142145

143146
// JSDoc
144147
"jsdoc/require-description": "error",

packages/joint-react-eslint/package.json

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,31 @@
66
"module": "./eslint.config.mjs",
77
"sideEffects": false,
88
"devDependencies": {
9-
"@eslint-react/eslint-plugin": "^1.28.0",
10-
"@eslint/compat": "^1.1.1",
11-
"@eslint/js": "9.24.0",
12-
"@stylistic/eslint-plugin": "4.2.0",
13-
"@stylistic/eslint-plugin-jsx": "4.2.0",
14-
"@stylistic/eslint-plugin-ts": "4.2.0",
15-
"@typescript-eslint/eslint-plugin": "8.29.0",
16-
"@typescript-eslint/parser": "8.29.0",
17-
"eslint": "9.24.0",
18-
"eslint-plugin-depend": "0.12.0",
19-
"eslint-plugin-jest": "^28.8.3",
20-
"eslint-plugin-jsdoc": "^50.6.9",
21-
"eslint-plugin-react": "^7.37.4",
22-
"eslint-plugin-react-hooks": "5.1.0",
9+
"@eslint-react/eslint-plugin": "1.52.4",
10+
"@eslint/compat": "^1.3.2",
11+
"@eslint/js": "9.33.0",
12+
"@stylistic/eslint-plugin": "5.2.3",
13+
"@stylistic/eslint-plugin-jsx": "4.4.1",
14+
"@stylistic/eslint-plugin-ts": "4.4.1",
15+
"@typescript-eslint/eslint-plugin": "8.39.1",
16+
"@typescript-eslint/parser": "8.39.1",
17+
"eslint": "9.33.0",
18+
"eslint-plugin-depend": "1.2.0",
19+
"eslint-plugin-jest": "29.0.1",
20+
"eslint-plugin-jsdoc": "54.0.0",
21+
"eslint-plugin-react": "7.37.5",
22+
"eslint-plugin-react-hooks": "5.2.0",
2323
"eslint-plugin-react-perf": "^3.3.3",
2424
"eslint-plugin-security": "3.0.1",
25-
"eslint-plugin-sonarjs": "3.0.2",
26-
"eslint-plugin-unicorn": "58.0.0",
27-
"typescript-eslint": "8.29.0"
25+
"eslint-plugin-sonarjs": "3.0.4",
26+
"eslint-plugin-unicorn": "60.0.0",
27+
"typescript-eslint": "8.39.1"
2828
},
2929
"peerDependencies": {
30-
"eslint": "9.24.0",
31-
"typescript": "^5.0.0"
30+
"eslint": "9.33.0",
31+
"typescript": "^5.9.2"
32+
},
33+
"scripts": {
34+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
3235
}
3336
}

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
/* eslint-disable react-perf/jsx-no-new-object-as-prop */
3-
//@ts-expect-error its js package without types
4-
import JsonViewer from '@andypf/json-viewer/dist/esm/react/JsonViewer';
53

6-
import type { HTMLProps, JSX, PropsWithChildren } from 'react';
7-
import type { InferElement } from '@joint/react';
4+
// @ts-expect-error do not provide typings.
5+
import JsonViewer from '@andypf/json-viewer/dist/esm/react/JsonViewer';
6+
import { useCallback, type HTMLProps, type JSX, type PropsWithChildren } from 'react';
87
import {
98
createElements,
109
createLinks,
1110
GraphProvider,
1211
MeasuredNode,
13-
Paper,
1412
useElement,
13+
type InferElement,
1514
} from '@joint/react';
1615
import { PAPER_CLASSNAME, PRIMARY } from '../theme';
16+
import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
17+
import { Paper } from '../../src/components/paper/paper';
18+
19+
export type StoryFunction = PartialStoryFn<any, any>;
20+
export type StoryCtx = StoryContext<any, any>;
1721

18-
const initialElements = createElements([
22+
export const testElements = createElements([
1923
{
2024
id: '1',
2125
label: 'Node 1',
@@ -36,8 +40,8 @@ const initialElements = createElements([
3640
},
3741
]);
3842

39-
export type SimpleElement = InferElement<typeof initialElements>;
40-
const initialLinks = createLinks([
43+
export type SimpleElement = InferElement<typeof testElements>;
44+
export const testLinks = createLinks([
4145
{
4246
id: 'l-1',
4347
source: '1',
@@ -52,16 +56,16 @@ const initialLinks = createLinks([
5256

5357
export function SimpleGraphProviderDecorator({ children }: Readonly<PropsWithChildren>) {
5458
return (
55-
<GraphProvider initialElements={initialElements} initialLinks={initialLinks}>
59+
<GraphProvider elements={testElements} links={testLinks}>
5660
{children}
5761
</GraphProvider>
5862
);
5963
}
6064

61-
export function SimpleGraphDecorator(Story: any) {
65+
export function SimpleGraphDecorator(Story: StoryFunction, { args }: StoryCtx) {
6266
return (
6367
<SimpleGraphProviderDecorator>
64-
<Story />
68+
<Story {...args} />
6569
</SimpleGraphProviderDecorator>
6670
);
6771
}
@@ -91,7 +95,7 @@ function RenderSimpleRectElement(properties: SimpleElement) {
9195
return <rect width={width} height={height} fill={color} />;
9296
}
9397

94-
export function RenderPaperWithChildren(properties: Readonly<{ children: JSX.Element }>) {
98+
export function RenderGraphViewWithChildren(properties: Readonly<{ children: JSX.Element }>) {
9599
return (
96100
<div style={{ width: '100%', height: 350 }}>
97101
<SimpleGraphProviderDecorator>
@@ -108,12 +112,12 @@ export function RenderPaperWithChildren(properties: Readonly<{ children: JSX.Ele
108112
);
109113
}
110114

111-
export function SimpleRenderItemDecorator(Story: any) {
112-
return <RenderItemDecorator renderElement={Story} />;
113-
}
114-
115-
export function SimpleRenderPaperDecorator(Story: any) {
116-
return <RenderPaperWithChildren>{Story}</RenderPaperWithChildren>;
115+
export function SimpleRenderItemDecorator(Story: StoryFunction, { args }: StoryCtx) {
116+
const component = useCallback(
117+
(element: SimpleElement) => <Story {...element} {...args} />,
118+
[Story, args]
119+
);
120+
return <RenderItemDecorator renderElement={component} />;
117121
}
118122

119123
export function HTMLNode(props: PropsWithChildren<HTMLProps<HTMLDivElement>>) {

packages/joint-react/.storybook/main.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-shadow */
2+
/* eslint-disable no-shadow */
13
import type { StorybookConfig } from '@storybook/react-vite';
4+
import path from 'node:path';
25
import { configureSort } from 'storybook-multilevel-sort';
36

47
configureSort({
@@ -23,8 +26,6 @@ const config: StorybookConfig = {
2326
'@storybook/addon-interactions',
2427
'@storybook/addon-docs',
2528
'@storybook/addon-a11y',
26-
// TODO: this library is not compatible with Vite storybook, so we will wait to fix it and then we can again enable.
27-
// '@storybook/addon-storysource',
2829
'@storybook/addon-links',
2930
'storybook-addon-performance',
3031
'@codesandbox/storybook-addon',
@@ -37,5 +38,16 @@ const config: StorybookConfig = {
3738
docs: {
3839
autodocs: true,
3940
},
41+
42+
// 👇 extend Vite config here to resolve libraries properly (in storybook)
43+
viteFinal: async (config) => {
44+
config.resolve = config.resolve || {};
45+
config.resolve.alias = {
46+
...config.resolve.alias,
47+
'@joint/react': path.resolve(__dirname, '../src/index.ts'),
48+
'@joint/react/src/*': path.resolve(__dirname, '../src/*'),
49+
};
50+
return config;
51+
},
4052
};
4153
export default config;

0 commit comments

Comments
 (0)