@knotx/plugins-canvas 0.4.5 → 0.4.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 +15 -4
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +15 -4
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const jsxRuntime = require('@knotx/jsx/jsx-runtime');
|
|
4
4
|
const core = require('@knotx/core');
|
|
5
5
|
const decorators = require('@knotx/decorators');
|
|
6
|
+
const reactZoomPanPinch = require('@knotx/react-zoom-pan-pinch');
|
|
6
7
|
const lodashEs = require('lodash-es');
|
|
7
8
|
const react = require('react');
|
|
8
|
-
const reactZoomPanPinch = require('react-zoom-pan-pinch');
|
|
9
9
|
|
|
10
10
|
function calculateTransform({
|
|
11
11
|
node,
|
|
@@ -235,7 +235,9 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
|
|
|
235
235
|
__publicField(this, "interaction", __runInitializers(_init, 36, this)), __runInitializers(_init, 39, this);
|
|
236
236
|
__publicField(this, "listeners", {
|
|
237
237
|
click: /* @__PURE__ */ new Set(),
|
|
238
|
-
contextmenu: /* @__PURE__ */ new Set()
|
|
238
|
+
contextmenu: /* @__PURE__ */ new Set(),
|
|
239
|
+
mouseenter: /* @__PURE__ */ new Set(),
|
|
240
|
+
mouseleave: /* @__PURE__ */ new Set()
|
|
239
241
|
});
|
|
240
242
|
__publicField(this, "edgeScrollAnimationFrame", null);
|
|
241
243
|
__publicField(this, "mousePosition", null);
|
|
@@ -279,12 +281,20 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
|
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
283
|
});
|
|
282
|
-
__publicField(this, "onMouseLeave", () => {
|
|
284
|
+
__publicField(this, "onMouseLeave", (e) => {
|
|
283
285
|
this.mousePosition = null;
|
|
284
286
|
if (this.edgeScrollAnimationFrame !== null) {
|
|
285
287
|
cancelAnimationFrame(this.edgeScrollAnimationFrame);
|
|
286
288
|
this.edgeScrollAnimationFrame = null;
|
|
287
289
|
}
|
|
290
|
+
this.listeners.mouseleave.forEach((listener) => {
|
|
291
|
+
listener(e);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
__publicField(this, "onMouseEnter", (e) => {
|
|
295
|
+
this.listeners.mouseenter.forEach((listener) => {
|
|
296
|
+
listener(e);
|
|
297
|
+
});
|
|
288
298
|
});
|
|
289
299
|
__publicField(this, "handleEdgeScroll", () => {
|
|
290
300
|
if (!this.edgeScroll.config.enabled || !this.mousePosition || !this.ref) {
|
|
@@ -441,7 +451,8 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
|
|
|
441
451
|
onClick: this.onClick,
|
|
442
452
|
onContextMenu: this.onContextMenu,
|
|
443
453
|
onMouseMove: this.onMouseMove,
|
|
444
|
-
onMouseLeave: this.onMouseLeave
|
|
454
|
+
onMouseLeave: this.onMouseLeave,
|
|
455
|
+
onMouseEnter: this.onMouseEnter
|
|
445
456
|
},
|
|
446
457
|
contentClass: core.bem(this.name, "content"),
|
|
447
458
|
contentStyle: {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Element, BasePlugin, DOMElement, Engine } from '@knotx/core';
|
|
2
2
|
import { InferParamsFromSchema } from '@knotx/decorators';
|
|
3
|
+
import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from '@knotx/react-zoom-pan-pinch';
|
|
3
4
|
import { MouseEvent, ReactNode } from 'react';
|
|
4
|
-
import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from 'react-zoom-pan-pinch';
|
|
5
5
|
|
|
6
6
|
interface CanvasTransformState {
|
|
7
7
|
previousScale: number;
|
|
@@ -76,7 +76,7 @@ declare module '@knotx/core' {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
type CanvasEventType = 'click' | 'contextmenu';
|
|
79
|
+
type CanvasEventType = 'click' | 'contextmenu' | 'mouseenter' | 'mouseleave';
|
|
80
80
|
type CanvasEventListener = (event: MouseEvent<HTMLElement>) => void;
|
|
81
81
|
declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
|
|
82
82
|
private config;
|
|
@@ -189,6 +189,7 @@ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
|
|
|
189
189
|
private onContextMenu;
|
|
190
190
|
private onMouseMove;
|
|
191
191
|
private onMouseLeave;
|
|
192
|
+
private onMouseEnter;
|
|
192
193
|
private handleEdgeScroll;
|
|
193
194
|
private isCanvasEvent;
|
|
194
195
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Element, BasePlugin, DOMElement, Engine } from '@knotx/core';
|
|
2
2
|
import { InferParamsFromSchema } from '@knotx/decorators';
|
|
3
|
+
import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from '@knotx/react-zoom-pan-pinch';
|
|
3
4
|
import { MouseEvent, ReactNode } from 'react';
|
|
4
|
-
import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from 'react-zoom-pan-pinch';
|
|
5
5
|
|
|
6
6
|
interface CanvasTransformState {
|
|
7
7
|
previousScale: number;
|
|
@@ -76,7 +76,7 @@ declare module '@knotx/core' {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
type CanvasEventType = 'click' | 'contextmenu';
|
|
79
|
+
type CanvasEventType = 'click' | 'contextmenu' | 'mouseenter' | 'mouseleave';
|
|
80
80
|
type CanvasEventListener = (event: MouseEvent<HTMLElement>) => void;
|
|
81
81
|
declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
|
|
82
82
|
private config;
|
|
@@ -189,6 +189,7 @@ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
|
|
|
189
189
|
private onContextMenu;
|
|
190
190
|
private onMouseMove;
|
|
191
191
|
private onMouseLeave;
|
|
192
|
+
private onMouseEnter;
|
|
192
193
|
private handleEdgeScroll;
|
|
193
194
|
private isCanvasEvent;
|
|
194
195
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Element, BasePlugin, DOMElement, Engine } from '@knotx/core';
|
|
2
2
|
import { InferParamsFromSchema } from '@knotx/decorators';
|
|
3
|
+
import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from '@knotx/react-zoom-pan-pinch';
|
|
3
4
|
import { MouseEvent, ReactNode } from 'react';
|
|
4
|
-
import { ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from 'react-zoom-pan-pinch';
|
|
5
5
|
|
|
6
6
|
interface CanvasTransformState {
|
|
7
7
|
previousScale: number;
|
|
@@ -76,7 +76,7 @@ declare module '@knotx/core' {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
type CanvasEventType = 'click' | 'contextmenu';
|
|
79
|
+
type CanvasEventType = 'click' | 'contextmenu' | 'mouseenter' | 'mouseleave';
|
|
80
80
|
type CanvasEventListener = (event: MouseEvent<HTMLElement>) => void;
|
|
81
81
|
declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
|
|
82
82
|
private config;
|
|
@@ -189,6 +189,7 @@ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
|
|
|
189
189
|
private onContextMenu;
|
|
190
190
|
private onMouseMove;
|
|
191
191
|
private onMouseLeave;
|
|
192
|
+
private onMouseEnter;
|
|
192
193
|
private handleEdgeScroll;
|
|
193
194
|
private isCanvasEvent;
|
|
194
195
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from '@knotx/jsx/jsx-runtime';
|
|
2
2
|
import { Layer, DOMElement, bem, BasePlugin, InteractionPriority } from '@knotx/core';
|
|
3
3
|
import { register, inject, tool, layer, OnInit } from '@knotx/decorators';
|
|
4
|
+
import { TransformWrapper, TransformComponent } from '@knotx/react-zoom-pan-pinch';
|
|
4
5
|
import { isEqual, merge } from 'lodash-es';
|
|
5
6
|
import { useMemo, useReducer, useLayoutEffect, Fragment } from 'react';
|
|
6
|
-
import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch';
|
|
7
7
|
|
|
8
8
|
function calculateTransform({
|
|
9
9
|
node,
|
|
@@ -233,7 +233,9 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
|
|
|
233
233
|
__publicField(this, "interaction", __runInitializers(_init, 36, this)), __runInitializers(_init, 39, this);
|
|
234
234
|
__publicField(this, "listeners", {
|
|
235
235
|
click: /* @__PURE__ */ new Set(),
|
|
236
|
-
contextmenu: /* @__PURE__ */ new Set()
|
|
236
|
+
contextmenu: /* @__PURE__ */ new Set(),
|
|
237
|
+
mouseenter: /* @__PURE__ */ new Set(),
|
|
238
|
+
mouseleave: /* @__PURE__ */ new Set()
|
|
237
239
|
});
|
|
238
240
|
__publicField(this, "edgeScrollAnimationFrame", null);
|
|
239
241
|
__publicField(this, "mousePosition", null);
|
|
@@ -277,12 +279,20 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
|
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
281
|
});
|
|
280
|
-
__publicField(this, "onMouseLeave", () => {
|
|
282
|
+
__publicField(this, "onMouseLeave", (e) => {
|
|
281
283
|
this.mousePosition = null;
|
|
282
284
|
if (this.edgeScrollAnimationFrame !== null) {
|
|
283
285
|
cancelAnimationFrame(this.edgeScrollAnimationFrame);
|
|
284
286
|
this.edgeScrollAnimationFrame = null;
|
|
285
287
|
}
|
|
288
|
+
this.listeners.mouseleave.forEach((listener) => {
|
|
289
|
+
listener(e);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
__publicField(this, "onMouseEnter", (e) => {
|
|
293
|
+
this.listeners.mouseenter.forEach((listener) => {
|
|
294
|
+
listener(e);
|
|
295
|
+
});
|
|
286
296
|
});
|
|
287
297
|
__publicField(this, "handleEdgeScroll", () => {
|
|
288
298
|
if (!this.edgeScroll.config.enabled || !this.mousePosition || !this.ref) {
|
|
@@ -439,7 +449,8 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
|
|
|
439
449
|
onClick: this.onClick,
|
|
440
450
|
onContextMenu: this.onContextMenu,
|
|
441
451
|
onMouseMove: this.onMouseMove,
|
|
442
|
-
onMouseLeave: this.onMouseLeave
|
|
452
|
+
onMouseLeave: this.onMouseLeave,
|
|
453
|
+
onMouseEnter: this.onMouseEnter
|
|
443
454
|
},
|
|
444
455
|
contentClass: bem(this.name, "content"),
|
|
445
456
|
contentStyle: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/plugins-canvas",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Canvas Plugin for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=17.0.0",
|
|
32
|
-
"@knotx/jsx": "0.4.
|
|
32
|
+
"@knotx/jsx": "0.4.7"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@knotx/react-zoom-pan-pinch": "^3.9.9",
|
|
35
36
|
"lodash-es": "^4.17.21",
|
|
36
|
-
"react-zoom-pan-pinch": "^3.7.0",
|
|
37
37
|
"rxjs": "^7.8.1",
|
|
38
|
-
"@knotx/core": "0.4.
|
|
39
|
-
"@knotx/decorators": "0.4.
|
|
38
|
+
"@knotx/core": "0.4.7",
|
|
39
|
+
"@knotx/decorators": "0.4.7"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/lodash-es": "^4.17.12",
|
|
43
43
|
"@types/react": "^17.0.0",
|
|
44
44
|
"react": "^17.0.0",
|
|
45
|
-
"@knotx/build-config": "0.4.
|
|
46
|
-
"@knotx/eslint-config": "0.4.
|
|
47
|
-
"@knotx/jsx": "0.4.
|
|
48
|
-
"@knotx/typescript-config": "0.4.
|
|
45
|
+
"@knotx/build-config": "0.4.7",
|
|
46
|
+
"@knotx/eslint-config": "0.4.7",
|
|
47
|
+
"@knotx/jsx": "0.4.7",
|
|
48
|
+
"@knotx/typescript-config": "0.4.7"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "unbuild",
|