@knotx/react 0.0.10 → 0.0.11

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 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.current);
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, CSSProperties, PropsWithoutRef, ForwardedRef, ReactElement } from 'react';
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: PropsWithoutRef<KnotxProps<TPlugins>>, ref: ForwardedRef<ReactEngine>): ReactElement | null;
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, CSSProperties, PropsWithoutRef, ForwardedRef, ReactElement } from 'react';
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: PropsWithoutRef<KnotxProps<TPlugins>>, ref: ForwardedRef<ReactEngine>): ReactElement | null;
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, CSSProperties, PropsWithoutRef, ForwardedRef, ReactElement } from 'react';
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: PropsWithoutRef<KnotxProps<TPlugins>>, ref: ForwardedRef<ReactEngine>): ReactElement | null;
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.current);
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,7 @@
1
1
  {
2
2
  "name": "@knotx/react",
3
3
  "type": "module",
4
- "version": "0.0.10",
4
+ "version": "0.0.11",
5
5
  "description": "React for Knotx",
6
6
  "author": "boenfu",
7
7
  "license": "MIT",
@@ -34,9 +34,9 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "rxjs": "^7.8.1",
37
+ "@knotx/core": "0.0.7",
37
38
  "@knotx/jsx": "0.0.7",
38
- "@knotx/plugins-base-render": "0.0.9",
39
- "@knotx/core": "0.0.7"
39
+ "@knotx/plugins-base-render": "0.0.9"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "^17.0.0",