@knotx/plugins-canvas 0.0.6 → 0.0.7

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
@@ -75,26 +75,15 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
75
75
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
76
76
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
77
77
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
78
- var _render_dec, _transform_dec, _ref_dec, _a, _init;
79
- class Canvas extends (_a = core.BasePlugin, _ref_dec = [decorators.register("ref")], _transform_dec = [decorators.register("transform")], _render_dec = [decorators.layer(core.Layer.Canvas)], _a) {
80
- constructor(options) {
81
- super();
78
+ var _init_dec, _render_dec, _transform_dec, _ref_dec, _a, _init;
79
+ class Canvas extends (_a = core.BasePlugin, _ref_dec = [decorators.register("ref")], _transform_dec = [decorators.register("transform")], _render_dec = [decorators.layer(core.Layer.Canvas)], _init_dec = [decorators.OnInit], _a) {
80
+ constructor() {
81
+ super(...arguments);
82
82
  __runInitializers(_init, 5, this);
83
- __publicField(this, "options");
83
+ __publicField(this, "config");
84
84
  __publicField(this, "name", "canvas");
85
85
  __publicField(this, "ref", __runInitializers(_init, 8, this, null)), __runInitializers(_init, 11, this);
86
86
  __publicField(this, "transform", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
87
- this.options = lodashEs.merge({}, options, {
88
- doubleClick: {
89
- excluded: [core.bem("node", "wrapper"), core.bem("edge", "wrapper")]
90
- }
91
- });
92
- this.transform = {
93
- previousScale: options.initialScale || 1,
94
- scale: options.initialScale || 1,
95
- positionX: options.initialPositionX || 0,
96
- positionY: options.initialPositionY || 0
97
- };
98
87
  }
99
88
  get classNames() {
100
89
  return {
@@ -152,7 +141,7 @@ class Canvas extends (_a = core.BasePlugin, _ref_dec = [decorators.register("ref
152
141
  }, [transform]);
153
142
  return /* @__PURE__ */ jsxRuntime.jsxs(
154
143
  reactZoomPanPinch.TransformWrapper,
155
- __spreadProps(__spreadValues({}, this.options), {
144
+ __spreadProps(__spreadValues({}, this.config), {
156
145
  ref: setTransform,
157
146
  children: [
158
147
  /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: fixedLayers }),
@@ -180,9 +169,23 @@ class Canvas extends (_a = core.BasePlugin, _ref_dec = [decorators.register("ref
180
169
  })
181
170
  );
182
171
  }
172
+ init(config) {
173
+ this.config = lodashEs.merge({}, config, {
174
+ doubleClick: {
175
+ excluded: [core.bem("node", "wrapper"), core.bem("edge", "wrapper")]
176
+ }
177
+ });
178
+ this.transform = {
179
+ previousScale: config.initialScale || 1,
180
+ scale: config.initialScale || 1,
181
+ positionX: config.initialPositionX || 0,
182
+ positionY: config.initialPositionY || 0
183
+ };
184
+ }
183
185
  }
184
186
  _init = __decoratorStart(_a);
185
187
  __decorateElement(_init, 1, "render", _render_dec, Canvas);
188
+ __decorateElement(_init, 1, "init", _init_dec, Canvas);
186
189
  __decorateElement(_init, 5, "ref", _ref_dec, Canvas);
187
190
  __decorateElement(_init, 5, "transform", _transform_dec, Canvas);
188
191
  __decoratorMetadata(_init, Canvas);
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { ReactZoomPanPinchContentRef, ReactZoomPanPinchState, ReactZoomPanPinchProps } from 'react-zoom-pan-pinch';
3
3
  import { BasePlugin } from '@knotx/core';
4
4
 
5
- type CanvasProps = ReactZoomPanPinchProps;
5
+ type CanvasConfig = ReactZoomPanPinchProps;
6
6
  type CanvasTransformState = ReactZoomPanPinchState;
7
7
  type CanvasRef = ReactZoomPanPinchContentRef;
8
8
  declare module '@knotx/core' {
@@ -13,12 +13,11 @@ declare module '@knotx/core' {
13
13
  };
14
14
  }
15
15
  }
16
- declare class Canvas extends BasePlugin<'canvas'> {
17
- private options;
16
+ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
17
+ private config;
18
18
  name: "canvas";
19
19
  ref: CanvasRef | null;
20
20
  transform: CanvasTransformState;
21
- constructor(options: CanvasProps);
22
21
  get classNames(): {
23
22
  wrapper: string;
24
23
  content: string;
@@ -26,6 +25,7 @@ declare class Canvas extends BasePlugin<'canvas'> {
26
25
  render({ children }?: {
27
26
  children: ReactNode;
28
27
  }): JSX.Element;
28
+ init(config: CanvasConfig): void;
29
29
  }
30
30
 
31
- export { Canvas, type CanvasProps, type CanvasRef, type CanvasTransformState };
31
+ export { Canvas, type CanvasConfig, type CanvasRef, type CanvasTransformState };
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { ReactZoomPanPinchContentRef, ReactZoomPanPinchState, ReactZoomPanPinchProps } from 'react-zoom-pan-pinch';
3
3
  import { BasePlugin } from '@knotx/core';
4
4
 
5
- type CanvasProps = ReactZoomPanPinchProps;
5
+ type CanvasConfig = ReactZoomPanPinchProps;
6
6
  type CanvasTransformState = ReactZoomPanPinchState;
7
7
  type CanvasRef = ReactZoomPanPinchContentRef;
8
8
  declare module '@knotx/core' {
@@ -13,12 +13,11 @@ declare module '@knotx/core' {
13
13
  };
14
14
  }
15
15
  }
16
- declare class Canvas extends BasePlugin<'canvas'> {
17
- private options;
16
+ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
17
+ private config;
18
18
  name: "canvas";
19
19
  ref: CanvasRef | null;
20
20
  transform: CanvasTransformState;
21
- constructor(options: CanvasProps);
22
21
  get classNames(): {
23
22
  wrapper: string;
24
23
  content: string;
@@ -26,6 +25,7 @@ declare class Canvas extends BasePlugin<'canvas'> {
26
25
  render({ children }?: {
27
26
  children: ReactNode;
28
27
  }): JSX.Element;
28
+ init(config: CanvasConfig): void;
29
29
  }
30
30
 
31
- export { Canvas, type CanvasProps, type CanvasRef, type CanvasTransformState };
31
+ export { Canvas, type CanvasConfig, type CanvasRef, type CanvasTransformState };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { ReactZoomPanPinchContentRef, ReactZoomPanPinchState, ReactZoomPanPinchProps } from 'react-zoom-pan-pinch';
3
3
  import { BasePlugin } from '@knotx/core';
4
4
 
5
- type CanvasProps = ReactZoomPanPinchProps;
5
+ type CanvasConfig = ReactZoomPanPinchProps;
6
6
  type CanvasTransformState = ReactZoomPanPinchState;
7
7
  type CanvasRef = ReactZoomPanPinchContentRef;
8
8
  declare module '@knotx/core' {
@@ -13,12 +13,11 @@ declare module '@knotx/core' {
13
13
  };
14
14
  }
15
15
  }
16
- declare class Canvas extends BasePlugin<'canvas'> {
17
- private options;
16
+ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
17
+ private config;
18
18
  name: "canvas";
19
19
  ref: CanvasRef | null;
20
20
  transform: CanvasTransformState;
21
- constructor(options: CanvasProps);
22
21
  get classNames(): {
23
22
  wrapper: string;
24
23
  content: string;
@@ -26,6 +25,7 @@ declare class Canvas extends BasePlugin<'canvas'> {
26
25
  render({ children }?: {
27
26
  children: ReactNode;
28
27
  }): JSX.Element;
28
+ init(config: CanvasConfig): void;
29
29
  }
30
30
 
31
- export { Canvas, type CanvasProps, type CanvasRef, type CanvasTransformState };
31
+ export { Canvas, type CanvasConfig, type CanvasRef, type CanvasTransformState };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from '@knotx/jsx/jsx-runtime';
2
2
  import { Layer, bem, BasePlugin } from '@knotx/core';
3
- import { register, layer } from '@knotx/decorators';
3
+ import { register, layer, OnInit } from '@knotx/decorators';
4
4
  import { merge } from 'lodash-es';
5
5
  import { useState, useMemo, useEffect, Fragment } from 'react';
6
6
  import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch';
@@ -73,26 +73,15 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
73
73
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
74
74
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
75
75
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
76
- var _render_dec, _transform_dec, _ref_dec, _a, _init;
77
- class Canvas extends (_a = BasePlugin, _ref_dec = [register("ref")], _transform_dec = [register("transform")], _render_dec = [layer(Layer.Canvas)], _a) {
78
- constructor(options) {
79
- super();
76
+ var _init_dec, _render_dec, _transform_dec, _ref_dec, _a, _init;
77
+ class Canvas extends (_a = BasePlugin, _ref_dec = [register("ref")], _transform_dec = [register("transform")], _render_dec = [layer(Layer.Canvas)], _init_dec = [OnInit], _a) {
78
+ constructor() {
79
+ super(...arguments);
80
80
  __runInitializers(_init, 5, this);
81
- __publicField(this, "options");
81
+ __publicField(this, "config");
82
82
  __publicField(this, "name", "canvas");
83
83
  __publicField(this, "ref", __runInitializers(_init, 8, this, null)), __runInitializers(_init, 11, this);
84
84
  __publicField(this, "transform", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
85
- this.options = merge({}, options, {
86
- doubleClick: {
87
- excluded: [bem("node", "wrapper"), bem("edge", "wrapper")]
88
- }
89
- });
90
- this.transform = {
91
- previousScale: options.initialScale || 1,
92
- scale: options.initialScale || 1,
93
- positionX: options.initialPositionX || 0,
94
- positionY: options.initialPositionY || 0
95
- };
96
85
  }
97
86
  get classNames() {
98
87
  return {
@@ -150,7 +139,7 @@ class Canvas extends (_a = BasePlugin, _ref_dec = [register("ref")], _transform_
150
139
  }, [transform]);
151
140
  return /* @__PURE__ */ jsxs(
152
141
  TransformWrapper,
153
- __spreadProps(__spreadValues({}, this.options), {
142
+ __spreadProps(__spreadValues({}, this.config), {
154
143
  ref: setTransform,
155
144
  children: [
156
145
  /* @__PURE__ */ jsx(Fragment, { children: fixedLayers }),
@@ -178,9 +167,23 @@ class Canvas extends (_a = BasePlugin, _ref_dec = [register("ref")], _transform_
178
167
  })
179
168
  );
180
169
  }
170
+ init(config) {
171
+ this.config = merge({}, config, {
172
+ doubleClick: {
173
+ excluded: [bem("node", "wrapper"), bem("edge", "wrapper")]
174
+ }
175
+ });
176
+ this.transform = {
177
+ previousScale: config.initialScale || 1,
178
+ scale: config.initialScale || 1,
179
+ positionX: config.initialPositionX || 0,
180
+ positionY: config.initialPositionY || 0
181
+ };
182
+ }
181
183
  }
182
184
  _init = __decoratorStart(_a);
183
185
  __decorateElement(_init, 1, "render", _render_dec, Canvas);
186
+ __decorateElement(_init, 1, "init", _init_dec, Canvas);
184
187
  __decorateElement(_init, 5, "ref", _ref_dec, Canvas);
185
188
  __decorateElement(_init, 5, "transform", _transform_dec, Canvas);
186
189
  __decoratorMetadata(_init, Canvas);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knotx/plugins-canvas",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "Canvas Plugin for Knotx",
6
6
  "author": "boenfu",
7
7
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  "lodash-es": "^4.17.21",
37
37
  "react-zoom-pan-pinch": "^3.7.0",
38
38
  "rxjs": "^7.8.1",
39
- "@knotx/core": "0.0.6",
40
- "@knotx/decorators": "0.0.6"
39
+ "@knotx/core": "0.0.7",
40
+ "@knotx/decorators": "0.0.7"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/lodash-es": "^4.17.12",
@@ -45,10 +45,10 @@
45
45
  "@types/react-dom": "^17.0.0",
46
46
  "react": "^17.0.0",
47
47
  "react-dom": "^17.0.0",
48
- "@knotx/build-config": "0.0.6",
49
- "@knotx/eslint-config": "0.0.6",
50
- "@knotx/jsx": "0.0.6",
51
- "@knotx/typescript-config": "0.0.6"
48
+ "@knotx/build-config": "0.0.7",
49
+ "@knotx/eslint-config": "0.0.7",
50
+ "@knotx/jsx": "0.0.7",
51
+ "@knotx/typescript-config": "0.0.7"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "unbuild --failOnWarn=false",