@knotx/react 0.0.10 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +7 -3
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +2 -2
- package/package.json +8 -9
package/dist/index.cjs
CHANGED
|
@@ -62,7 +62,7 @@ function useLayerContent(engineRef) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function useEngineRef() {
|
|
65
|
-
const engineRef = react.useRef();
|
|
65
|
+
const engineRef = react.useRef(null);
|
|
66
66
|
react.useEffect(() => () => {
|
|
67
67
|
var _a;
|
|
68
68
|
return (_a = engineRef.current) == null ? void 0 : _a.destroy();
|
|
@@ -128,7 +128,7 @@ const Knotx = react.memo(react.forwardRef(({
|
|
|
128
128
|
engineRef.current = initReactEngine({ container: containerSize, nodes, edges, plugins, pluginConfig });
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
|
-
react.useImperativeHandle(ref, () => engineRef
|
|
131
|
+
react.useImperativeHandle(ref, () => ({ engineRef }));
|
|
132
132
|
usePluginConfigUpdate(engineRef, pluginConfig);
|
|
133
133
|
const content = useLayerContent(engineRef);
|
|
134
134
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Engine, Plugin, NodeData, EdgeData } from '@knotx/core';
|
|
2
|
-
import { FC,
|
|
2
|
+
import { FC, MutableRefObject, Ref, CSSProperties, ForwardedRef, ReactElement } from 'react';
|
|
3
3
|
|
|
4
4
|
type ReactEngine = Engine<FC<any>>;
|
|
5
|
+
interface KnotxInstance {
|
|
6
|
+
engineRef: MutableRefObject<ReactEngine | null>;
|
|
7
|
+
}
|
|
5
8
|
type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
9
|
+
ref?: Ref<KnotxInstance> | undefined;
|
|
6
10
|
className?: string;
|
|
7
11
|
style?: CSSProperties;
|
|
8
12
|
nodes?: NodeData[];
|
|
@@ -24,8 +28,8 @@ type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
|
24
28
|
} : {});
|
|
25
29
|
|
|
26
30
|
declare const Knotx: {
|
|
27
|
-
<TPlugins extends Plugin[]>(props:
|
|
31
|
+
<TPlugins extends Plugin[]>(props: KnotxProps<TPlugins>, ref: ForwardedRef<KnotxInstance>): ReactElement | null;
|
|
28
32
|
displayName?: string | undefined;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
export { Knotx, type KnotxProps, type ReactEngine };
|
|
35
|
+
export { Knotx, type KnotxInstance, type KnotxProps, type ReactEngine };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Engine, Plugin, NodeData, EdgeData } from '@knotx/core';
|
|
2
|
-
import { FC,
|
|
2
|
+
import { FC, MutableRefObject, Ref, CSSProperties, ForwardedRef, ReactElement } from 'react';
|
|
3
3
|
|
|
4
4
|
type ReactEngine = Engine<FC<any>>;
|
|
5
|
+
interface KnotxInstance {
|
|
6
|
+
engineRef: MutableRefObject<ReactEngine | null>;
|
|
7
|
+
}
|
|
5
8
|
type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
9
|
+
ref?: Ref<KnotxInstance> | undefined;
|
|
6
10
|
className?: string;
|
|
7
11
|
style?: CSSProperties;
|
|
8
12
|
nodes?: NodeData[];
|
|
@@ -24,8 +28,8 @@ type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
|
24
28
|
} : {});
|
|
25
29
|
|
|
26
30
|
declare const Knotx: {
|
|
27
|
-
<TPlugins extends Plugin[]>(props:
|
|
31
|
+
<TPlugins extends Plugin[]>(props: KnotxProps<TPlugins>, ref: ForwardedRef<KnotxInstance>): ReactElement | null;
|
|
28
32
|
displayName?: string | undefined;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
export { Knotx, type KnotxProps, type ReactEngine };
|
|
35
|
+
export { Knotx, type KnotxInstance, type KnotxProps, type ReactEngine };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Engine, Plugin, NodeData, EdgeData } from '@knotx/core';
|
|
2
|
-
import { FC,
|
|
2
|
+
import { FC, MutableRefObject, Ref, CSSProperties, ForwardedRef, ReactElement } from 'react';
|
|
3
3
|
|
|
4
4
|
type ReactEngine = Engine<FC<any>>;
|
|
5
|
+
interface KnotxInstance {
|
|
6
|
+
engineRef: MutableRefObject<ReactEngine | null>;
|
|
7
|
+
}
|
|
5
8
|
type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
9
|
+
ref?: Ref<KnotxInstance> | undefined;
|
|
6
10
|
className?: string;
|
|
7
11
|
style?: CSSProperties;
|
|
8
12
|
nodes?: NodeData[];
|
|
@@ -24,8 +28,8 @@ type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
|
24
28
|
} : {});
|
|
25
29
|
|
|
26
30
|
declare const Knotx: {
|
|
27
|
-
<TPlugins extends Plugin[]>(props:
|
|
31
|
+
<TPlugins extends Plugin[]>(props: KnotxProps<TPlugins>, ref: ForwardedRef<KnotxInstance>): ReactElement | null;
|
|
28
32
|
displayName?: string | undefined;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
export { Knotx, type KnotxProps, type ReactEngine };
|
|
35
|
+
export { Knotx, type KnotxInstance, type KnotxProps, type ReactEngine };
|
package/dist/index.mjs
CHANGED
|
@@ -60,7 +60,7 @@ function useLayerContent(engineRef) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function useEngineRef() {
|
|
63
|
-
const engineRef = useRef();
|
|
63
|
+
const engineRef = useRef(null);
|
|
64
64
|
useEffect(() => () => {
|
|
65
65
|
var _a;
|
|
66
66
|
return (_a = engineRef.current) == null ? void 0 : _a.destroy();
|
|
@@ -126,7 +126,7 @@ const Knotx = memo(forwardRef(({
|
|
|
126
126
|
engineRef.current = initReactEngine({ container: containerSize, nodes, edges, plugins, pluginConfig });
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
|
-
useImperativeHandle(ref, () => engineRef
|
|
129
|
+
useImperativeHandle(ref, () => ({ engineRef }));
|
|
130
130
|
usePluginConfigUpdate(engineRef, pluginConfig);
|
|
131
131
|
const content = useLayerContent(engineRef);
|
|
132
132
|
return /* @__PURE__ */ jsx(
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/react",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.0.10",
|
|
3
|
+
"version": "0.2.1",
|
|
5
4
|
"description": "React for Knotx",
|
|
6
5
|
"author": "boenfu",
|
|
7
6
|
"license": "MIT",
|
|
@@ -34,19 +33,19 @@
|
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"rxjs": "^7.8.1",
|
|
37
|
-
"@knotx/
|
|
38
|
-
"@knotx/
|
|
39
|
-
"@knotx/
|
|
36
|
+
"@knotx/core": "0.2.1",
|
|
37
|
+
"@knotx/jsx": "0.2.1",
|
|
38
|
+
"@knotx/plugins-base-render": "0.2.1"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@types/react": "^17.0.0",
|
|
43
42
|
"@types/react-dom": "^17.0.0",
|
|
44
43
|
"react": "^17.0.0",
|
|
45
44
|
"react-dom": "^17.0.0",
|
|
46
|
-
"@knotx/build-config": "0.
|
|
47
|
-
"@knotx/eslint-config": "0.
|
|
48
|
-
"@knotx/jsx": "0.
|
|
49
|
-
"@knotx/typescript-config": "0.
|
|
45
|
+
"@knotx/build-config": "0.2.1",
|
|
46
|
+
"@knotx/eslint-config": "0.2.1",
|
|
47
|
+
"@knotx/jsx": "0.2.1",
|
|
48
|
+
"@knotx/typescript-config": "0.2.1"
|
|
50
49
|
},
|
|
51
50
|
"scripts": {
|
|
52
51
|
"build": "unbuild --failOnWarn=false",
|