@knotx/react 0.0.3 → 0.0.5

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
@@ -2,6 +2,7 @@
2
2
 
3
3
  const jsxRuntime = require('react/jsx-runtime');
4
4
  const core = require('@knotx/core');
5
+ const pluginsBaseRender = require('@knotx/plugins-base-render');
5
6
  const react = require('react');
6
7
  const rxjs = require('rxjs');
7
8
  const operators = require('rxjs/operators');
@@ -45,11 +46,17 @@ const Knotx = react.memo(react.forwardRef(({
45
46
  style,
46
47
  nodes,
47
48
  edges,
48
- plugins
49
+ plugins,
50
+ disablePresetPlugins = false
49
51
  }, ref) => {
50
52
  const [container, setContainer] = react.useState();
51
53
  const [_, setSize] = react.useState();
52
54
  const engineRef = react.useRef();
55
+ const enabledPlugins = react.useMemo(() => {
56
+ if (disablePresetPlugins)
57
+ return plugins;
58
+ return [pluginsBaseRender.BaseRender, ...plugins || []];
59
+ }, [disablePresetPlugins, plugins]);
53
60
  react.useLayoutEffect(() => {
54
61
  if (!container)
55
62
  return;
@@ -58,7 +65,7 @@ const Knotx = react.memo(react.forwardRef(({
58
65
  if (engineRef.current) {
59
66
  engineRef.current.container = { width, height };
60
67
  } else {
61
- engineRef.current = initReactEngine({ width, height }, nodes, edges, plugins);
68
+ engineRef.current = initReactEngine({ width, height }, nodes, edges, enabledPlugins);
62
69
  }
63
70
  setSize({ width, height });
64
71
  });
package/dist/index.d.cts CHANGED
@@ -8,6 +8,13 @@ interface KnotxProps {
8
8
  nodes?: NodeData[];
9
9
  edges?: EdgeData[];
10
10
  plugins?: PluginDefinition[];
11
+ /**
12
+ * Disable preset plugins
13
+ * preset plugin includes:
14
+ * - base-render (@knotx/plugins-base-render)
15
+ * @default false
16
+ */
17
+ disablePresetPlugins?: boolean;
11
18
  }
12
19
 
13
20
  declare const Knotx: ForwardRefRenderFunction<ReactEngine, KnotxProps>;
package/dist/index.d.mts CHANGED
@@ -8,6 +8,13 @@ interface KnotxProps {
8
8
  nodes?: NodeData[];
9
9
  edges?: EdgeData[];
10
10
  plugins?: PluginDefinition[];
11
+ /**
12
+ * Disable preset plugins
13
+ * preset plugin includes:
14
+ * - base-render (@knotx/plugins-base-render)
15
+ * @default false
16
+ */
17
+ disablePresetPlugins?: boolean;
11
18
  }
12
19
 
13
20
  declare const Knotx: ForwardRefRenderFunction<ReactEngine, KnotxProps>;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,13 @@ interface KnotxProps {
8
8
  nodes?: NodeData[];
9
9
  edges?: EdgeData[];
10
10
  plugins?: PluginDefinition[];
11
+ /**
12
+ * Disable preset plugins
13
+ * preset plugin includes:
14
+ * - base-render (@knotx/plugins-base-render)
15
+ * @default false
16
+ */
17
+ disablePresetPlugins?: boolean;
11
18
  }
12
19
 
13
20
  declare const Knotx: ForwardRefRenderFunction<ReactEngine, KnotxProps>;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { Layer, Engine } from '@knotx/core';
3
- import { memo, forwardRef, useState, useRef, useLayoutEffect, useEffect, useImperativeHandle, useMemo } from 'react';
3
+ import { BaseRender } from '@knotx/plugins-base-render';
4
+ import { memo, forwardRef, useState, useRef, useMemo, useLayoutEffect, useEffect, useImperativeHandle } from 'react';
4
5
  import { BehaviorSubject } from 'rxjs';
5
6
  import { map, distinctUntilChanged } from 'rxjs/operators';
6
7
 
@@ -43,11 +44,17 @@ const Knotx = memo(forwardRef(({
43
44
  style,
44
45
  nodes,
45
46
  edges,
46
- plugins
47
+ plugins,
48
+ disablePresetPlugins = false
47
49
  }, ref) => {
48
50
  const [container, setContainer] = useState();
49
51
  const [_, setSize] = useState();
50
52
  const engineRef = useRef();
53
+ const enabledPlugins = useMemo(() => {
54
+ if (disablePresetPlugins)
55
+ return plugins;
56
+ return [BaseRender, ...plugins || []];
57
+ }, [disablePresetPlugins, plugins]);
51
58
  useLayoutEffect(() => {
52
59
  if (!container)
53
60
  return;
@@ -56,7 +63,7 @@ const Knotx = memo(forwardRef(({
56
63
  if (engineRef.current) {
57
64
  engineRef.current.container = { width, height };
58
65
  } else {
59
- engineRef.current = initReactEngine({ width, height }, nodes, edges, plugins);
66
+ engineRef.current = initReactEngine({ width, height }, nodes, edges, enabledPlugins);
60
67
  }
61
68
  setSize({ width, height });
62
69
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knotx/react",
3
3
  "type": "module",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "description": "React for Knotx",
6
6
  "author": "boenfu",
7
7
  "license": "MIT",
@@ -12,8 +12,7 @@
12
12
  "directory": "packages/react"
13
13
  },
14
14
  "publishConfig": {
15
- "access": "public",
16
- "registry": "https://registry.npmjs.org/"
15
+ "access": "public"
17
16
  },
18
17
  "sideEffects": false,
19
18
  "exports": {
@@ -35,18 +34,19 @@
35
34
  },
36
35
  "dependencies": {
37
36
  "rxjs": "^7.8.1",
38
- "@knotx/core": "0.0.3",
39
- "@knotx/jsx": "0.0.3"
37
+ "@knotx/core": "0.0.5",
38
+ "@knotx/jsx": "0.0.5",
39
+ "@knotx/plugins-base-render": "0.0.5"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "^17.0.0",
43
43
  "@types/react-dom": "^17.0.0",
44
44
  "react": "^17.0.0",
45
45
  "react-dom": "^17.0.0",
46
- "@knotx/build-config": "0.0.3",
47
- "@knotx/eslint-config": "0.0.3",
48
- "@knotx/typescript-config": "0.0.3",
49
- "@knotx/jsx": "0.0.3"
46
+ "@knotx/eslint-config": "0.0.5",
47
+ "@knotx/jsx": "0.0.5",
48
+ "@knotx/typescript-config": "0.0.5",
49
+ "@knotx/build-config": "0.0.5"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "unbuild --failOnWarn=false",