react-lasso-select 1.2.1 → 2.0.0
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/LICENSE.md +1 -1
- package/README.md +7 -12
- package/dist/index.d.ts +179 -0
- package/dist/index.js +631 -0
- package/package.json +56 -49
- package/lib/SVGHelpers.d.ts +0 -15
- package/lib/SVGPoint.d.ts +0 -76
- package/lib/SVGPolygon.d.ts +0 -6
- package/lib/SVGPolyline.d.ts +0 -76
- package/lib/helpers.d.ts +0 -32
- package/lib/index.d.ts +0 -102
- package/lib/index.esm.js +0 -882
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -894
- package/lib/index.js.map +0 -1
- package/lib/pathReducer.d.ts +0 -34
- package/lib/withDraggable.d.ts +0 -78
package/package.json
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lasso-select",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A responsive react tool for marking irregular areas in images (lasso / free select)",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"style": "lib/index.css",
|
|
8
|
-
"files": [
|
|
9
|
-
"lib"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "rollup -c",
|
|
13
|
-
"lint": "eslint src/**/*.{ts,tsx}",
|
|
14
|
-
"test": "jest --verbose"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/akcyp/react-lasso-select.git"
|
|
19
|
-
},
|
|
5
|
+
"author": "akcyp",
|
|
6
|
+
"license": "ISC",
|
|
20
7
|
"keywords": [
|
|
21
8
|
"lasso",
|
|
22
9
|
"free-select",
|
|
@@ -26,40 +13,53 @@
|
|
|
26
13
|
"reactjs",
|
|
27
14
|
"crop"
|
|
28
15
|
],
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"url": "https://github.com/akcyp/react-lasso-select/issues"
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/akcyp/react-lasso-select.git"
|
|
33
19
|
},
|
|
34
20
|
"homepage": "https://github.com/akcyp/react-lasso-select#readme",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"@types/react": "^17.0.24",
|
|
38
|
-
"@types/react-dom": "^17.0.9",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
40
|
-
"@typescript-eslint/parser": "^4.31.2",
|
|
41
|
-
"eslint": "^7.32.0",
|
|
42
|
-
"eslint-config-prettier": "^8.3.0",
|
|
43
|
-
"eslint-plugin-jest": "^24.4.2",
|
|
44
|
-
"eslint-plugin-react": "^7.26.0",
|
|
45
|
-
"husky": "^4.3.8",
|
|
46
|
-
"jest": "^27.2.1",
|
|
47
|
-
"lint-staged": "^11.1.2",
|
|
48
|
-
"prettier": "2.4.1",
|
|
49
|
-
"react": "^17.0.1",
|
|
50
|
-
"react-dom": "^17.0.1",
|
|
51
|
-
"rollup": "^2.57.0",
|
|
52
|
-
"rollup-plugin-typescript2": "^0.30.0",
|
|
53
|
-
"ts-jest": "^27.0.5",
|
|
54
|
-
"tslib": "^2.3.1",
|
|
55
|
-
"typescript": "^4.4.3"
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/akcyp/react-lasso-select/issues"
|
|
56
23
|
},
|
|
57
|
-
"
|
|
58
|
-
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"module": "dist/index.js",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
59
32
|
},
|
|
33
|
+
"style": "dist/index.css",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"type": "module",
|
|
60
38
|
"peerDependencies": {
|
|
61
|
-
"
|
|
62
|
-
"react
|
|
39
|
+
"prop-types": "^15.8.1",
|
|
40
|
+
"react": "^18.3.1",
|
|
41
|
+
"react-dom": "^18.3.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/js": "^9.17.0",
|
|
45
|
+
"@types/node": "^22.10.6",
|
|
46
|
+
"@types/prop-types": "^15.7.14",
|
|
47
|
+
"@types/react": "^18.3.18",
|
|
48
|
+
"@types/react-dom": "^18.3.5",
|
|
49
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
50
|
+
"eslint": "^9.17.0",
|
|
51
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
52
|
+
"eslint-plugin-react-refresh": "^0.4.16",
|
|
53
|
+
"globals": "^15.14.0",
|
|
54
|
+
"husky": "^9.1.7",
|
|
55
|
+
"lint-staged": "^15.3.0",
|
|
56
|
+
"prettier": "^3.4.2",
|
|
57
|
+
"typescript": "~5.6.2",
|
|
58
|
+
"typescript-eslint": "^8.18.2",
|
|
59
|
+
"vite": "^6.0.5",
|
|
60
|
+
"vite-plugin-dts": "^4.5.0",
|
|
61
|
+
"vite-plugin-eslint2": "^5.0.3",
|
|
62
|
+
"vitest": "^2.1.8"
|
|
63
63
|
},
|
|
64
64
|
"husky": {
|
|
65
65
|
"hooks": {
|
|
@@ -67,8 +67,15 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"lint-staged": {
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
70
|
+
"*.{ts,tsx}": "eslint --fix",
|
|
71
|
+
"*.{js,jsx,ts,tsx,md,html,css}": "prettier --write"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"dev": "vite",
|
|
75
|
+
"build": "tsc -b && vite build",
|
|
76
|
+
"lint": "eslint .",
|
|
77
|
+
"format": "prettier -c .",
|
|
78
|
+
"test": "vitest",
|
|
79
|
+
"preview": "vite preview"
|
|
73
80
|
}
|
|
74
|
-
}
|
|
81
|
+
}
|
package/lib/SVGHelpers.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Point, Size, touchOrMouseEvent } from './helpers';
|
|
2
|
-
export declare class SVGHelper {
|
|
3
|
-
getSvgElement: () => SVGSVGElement | null | undefined;
|
|
4
|
-
constructor(getSvgElement: () => SVGSVGElement | null | undefined);
|
|
5
|
-
getSvg(): SVGSVGElement;
|
|
6
|
-
getCTM(): DOMMatrix;
|
|
7
|
-
getViewboxSize(): DOMRect;
|
|
8
|
-
getRealSize(): Size;
|
|
9
|
-
getViewboxOffset(): Point;
|
|
10
|
-
convertViewboxPointsToReal(points: Point[]): Point[];
|
|
11
|
-
convertRealPointsToViewbox(points: Point[]): Point[];
|
|
12
|
-
getBorderPoints(repeatFirst?: boolean): Point[];
|
|
13
|
-
isAboveTheBorder({ x, y }: Point): boolean;
|
|
14
|
-
getMouseCoordinates(event: touchOrMouseEvent<SVGSVGElement>): Point;
|
|
15
|
-
}
|
package/lib/SVGPoint.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Point } from './helpers';
|
|
3
|
-
export interface SVGPointProps extends Point {
|
|
4
|
-
style: React.CSSProperties;
|
|
5
|
-
draggable: boolean;
|
|
6
|
-
onClickTouchEvent: (e: React.MouseEvent | React.TouchEvent) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare const SVGPoint: {
|
|
9
|
-
new (props: (SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps) | Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>): {
|
|
10
|
-
ref: React.RefObject<SVGSVGElement>;
|
|
11
|
-
svg: import("./SVGHelpers").SVGHelper;
|
|
12
|
-
dragLastPosition: Point | null;
|
|
13
|
-
wasMoved: boolean;
|
|
14
|
-
render(): JSX.Element;
|
|
15
|
-
componentDidUpdate(prevProps: import("./withDraggable").WithDraggableProps): void;
|
|
16
|
-
componentDidMount(): void;
|
|
17
|
-
componentWillUnmount(): void;
|
|
18
|
-
getMousePosition(ev: MouseEvent | TouchEvent): Point;
|
|
19
|
-
onMouseTouchDown: (e: MouseEvent | TouchEvent) => void;
|
|
20
|
-
onMouseTouchMove: (e: MouseEvent | TouchEvent) => void;
|
|
21
|
-
onMouseTouchUp: (e: MouseEvent | TouchEvent) => void;
|
|
22
|
-
context: any;
|
|
23
|
-
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
24
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
25
|
-
readonly props: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps> & Readonly<{
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
}>;
|
|
28
|
-
state: Readonly<{}>;
|
|
29
|
-
refs: {
|
|
30
|
-
[key: string]: React.ReactInstance;
|
|
31
|
-
};
|
|
32
|
-
shouldComponentUpdate?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
33
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
34
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, prevState: Readonly<{}>): any;
|
|
35
|
-
componentWillMount?(): void;
|
|
36
|
-
UNSAFE_componentWillMount?(): void;
|
|
37
|
-
componentWillReceiveProps?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
38
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
39
|
-
componentWillUpdate?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
40
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
41
|
-
};
|
|
42
|
-
new (props: SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps, context: any): {
|
|
43
|
-
ref: React.RefObject<SVGSVGElement>;
|
|
44
|
-
svg: import("./SVGHelpers").SVGHelper;
|
|
45
|
-
dragLastPosition: Point | null;
|
|
46
|
-
wasMoved: boolean;
|
|
47
|
-
render(): JSX.Element;
|
|
48
|
-
componentDidUpdate(prevProps: import("./withDraggable").WithDraggableProps): void;
|
|
49
|
-
componentDidMount(): void;
|
|
50
|
-
componentWillUnmount(): void;
|
|
51
|
-
getMousePosition(ev: MouseEvent | TouchEvent): Point;
|
|
52
|
-
onMouseTouchDown: (e: MouseEvent | TouchEvent) => void;
|
|
53
|
-
onMouseTouchMove: (e: MouseEvent | TouchEvent) => void;
|
|
54
|
-
onMouseTouchUp: (e: MouseEvent | TouchEvent) => void;
|
|
55
|
-
context: any;
|
|
56
|
-
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
57
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
58
|
-
readonly props: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps> & Readonly<{
|
|
59
|
-
children?: React.ReactNode;
|
|
60
|
-
}>;
|
|
61
|
-
state: Readonly<{}>;
|
|
62
|
-
refs: {
|
|
63
|
-
[key: string]: React.ReactInstance;
|
|
64
|
-
};
|
|
65
|
-
shouldComponentUpdate?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
66
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
67
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, prevState: Readonly<{}>): any;
|
|
68
|
-
componentWillMount?(): void;
|
|
69
|
-
UNSAFE_componentWillMount?(): void;
|
|
70
|
-
componentWillReceiveProps?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
71
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
72
|
-
componentWillUpdate?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
73
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<SVGPointProps & React.RefAttributes<SVGRectElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
74
|
-
};
|
|
75
|
-
contextType?: React.Context<any> | undefined;
|
|
76
|
-
};
|
package/lib/SVGPolygon.d.ts
DELETED
package/lib/SVGPolyline.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Point } from './helpers';
|
|
3
|
-
export interface SVGPolylineProps {
|
|
4
|
-
path: Point[];
|
|
5
|
-
animate: boolean;
|
|
6
|
-
draggable: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const SVGPolyline: {
|
|
9
|
-
new (props: (SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps) | Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>): {
|
|
10
|
-
ref: React.RefObject<SVGSVGElement>;
|
|
11
|
-
svg: import("./SVGHelpers").SVGHelper;
|
|
12
|
-
dragLastPosition: Point | null;
|
|
13
|
-
wasMoved: boolean;
|
|
14
|
-
render(): JSX.Element;
|
|
15
|
-
componentDidUpdate(prevProps: import("./withDraggable").WithDraggableProps): void;
|
|
16
|
-
componentDidMount(): void;
|
|
17
|
-
componentWillUnmount(): void;
|
|
18
|
-
getMousePosition(ev: TouchEvent | MouseEvent): Point;
|
|
19
|
-
onMouseTouchDown: (e: TouchEvent | MouseEvent) => void;
|
|
20
|
-
onMouseTouchMove: (e: TouchEvent | MouseEvent) => void;
|
|
21
|
-
onMouseTouchUp: (e: TouchEvent | MouseEvent) => void;
|
|
22
|
-
context: any;
|
|
23
|
-
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
24
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
25
|
-
readonly props: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps> & Readonly<{
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
}>;
|
|
28
|
-
state: Readonly<{}>;
|
|
29
|
-
refs: {
|
|
30
|
-
[key: string]: React.ReactInstance;
|
|
31
|
-
};
|
|
32
|
-
shouldComponentUpdate?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
33
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
34
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, prevState: Readonly<{}>): any;
|
|
35
|
-
componentWillMount?(): void;
|
|
36
|
-
UNSAFE_componentWillMount?(): void;
|
|
37
|
-
componentWillReceiveProps?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
38
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
39
|
-
componentWillUpdate?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
40
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
41
|
-
};
|
|
42
|
-
new (props: SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps, context: any): {
|
|
43
|
-
ref: React.RefObject<SVGSVGElement>;
|
|
44
|
-
svg: import("./SVGHelpers").SVGHelper;
|
|
45
|
-
dragLastPosition: Point | null;
|
|
46
|
-
wasMoved: boolean;
|
|
47
|
-
render(): JSX.Element;
|
|
48
|
-
componentDidUpdate(prevProps: import("./withDraggable").WithDraggableProps): void;
|
|
49
|
-
componentDidMount(): void;
|
|
50
|
-
componentWillUnmount(): void;
|
|
51
|
-
getMousePosition(ev: TouchEvent | MouseEvent): Point;
|
|
52
|
-
onMouseTouchDown: (e: TouchEvent | MouseEvent) => void;
|
|
53
|
-
onMouseTouchMove: (e: TouchEvent | MouseEvent) => void;
|
|
54
|
-
onMouseTouchUp: (e: TouchEvent | MouseEvent) => void;
|
|
55
|
-
context: any;
|
|
56
|
-
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
57
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
58
|
-
readonly props: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps> & Readonly<{
|
|
59
|
-
children?: React.ReactNode;
|
|
60
|
-
}>;
|
|
61
|
-
state: Readonly<{}>;
|
|
62
|
-
refs: {
|
|
63
|
-
[key: string]: React.ReactInstance;
|
|
64
|
-
};
|
|
65
|
-
shouldComponentUpdate?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
66
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
67
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, prevState: Readonly<{}>): any;
|
|
68
|
-
componentWillMount?(): void;
|
|
69
|
-
UNSAFE_componentWillMount?(): void;
|
|
70
|
-
componentWillReceiveProps?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
71
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextContext: any): void;
|
|
72
|
-
componentWillUpdate?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
73
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<SVGPolylineProps & React.RefAttributes<SVGPolylineElement> & import("./withDraggable").WithDraggableProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
74
|
-
};
|
|
75
|
-
contextType?: React.Context<any> | undefined;
|
|
76
|
-
};
|
package/lib/helpers.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface Point {
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
}
|
|
6
|
-
export interface Vector {
|
|
7
|
-
dx: number;
|
|
8
|
-
dy: number;
|
|
9
|
-
}
|
|
10
|
-
export interface Size {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}
|
|
14
|
-
export interface Dictionary<T> {
|
|
15
|
-
[key: string]: T;
|
|
16
|
-
}
|
|
17
|
-
export declare type touchOrMouseEvent<T> = React.MouseEvent<T, MouseEvent> | React.TouchEvent<T>;
|
|
18
|
-
export declare type touchAndMouseEvent<T> = React.MouseEvent<T, MouseEvent> & React.TouchEvent<T>;
|
|
19
|
-
export declare const objectToClassName: (obj: Dictionary<boolean>) => string;
|
|
20
|
-
export declare const arePointsEqual: (p1: Point, p2: Point) => boolean;
|
|
21
|
-
export declare const arePointListEqual: (arr1: Point[], arr2: Point[]) => boolean;
|
|
22
|
-
export declare const roundPointCoordinates: ({ x, y }: Point, p?: number) => Point;
|
|
23
|
-
export declare const findPointByPosition: (points: Point[], position: Point, r?: number) => {
|
|
24
|
-
point: Point;
|
|
25
|
-
index: number;
|
|
26
|
-
};
|
|
27
|
-
export declare const getDistance: (p1: Point, p2: Point) => number;
|
|
28
|
-
export declare const getAngle: (p1: Point, p2: Point) => number;
|
|
29
|
-
export declare const approximateToAnAngleMultiplicity: (startPoint: Point, endPoint: Point, minAngle: number) => Point;
|
|
30
|
-
export declare const approximateToAngles: (startPoint: Point, endPoint: Point, angles: number[]) => Point;
|
|
31
|
-
export declare const calculateAnglesBeetwenPoints: (points: Point[]) => number[];
|
|
32
|
-
export declare function getClippedImageCanvas(src: string, path: Point[], callback: (err: Error | null, canvas: HTMLCanvasElement) => void, crop?: boolean): void;
|
package/lib/index.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { SVGHelper } from './SVGHelpers';
|
|
4
|
-
import { getClippedImageCanvas, Point, Vector, touchOrMouseEvent, Size } from './helpers';
|
|
5
|
-
import { pathReducerAction, PathState } from './pathReducer';
|
|
6
|
-
export interface ReactLassoProps {
|
|
7
|
-
src: string;
|
|
8
|
-
value: Point[];
|
|
9
|
-
style: React.CSSProperties;
|
|
10
|
-
viewBox: Size;
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
imageStyle: React.CSSProperties;
|
|
13
|
-
onImageLoad: (e: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
14
|
-
onImageError: (e: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
15
|
-
onChange?: (path: Point[]) => void;
|
|
16
|
-
onComplete?: (path: Point[]) => void;
|
|
17
|
-
imageAlt?: string;
|
|
18
|
-
crossOrigin?: 'anonymous' | 'use-credentials' | '';
|
|
19
|
-
}
|
|
20
|
-
export interface ReactLassoState {
|
|
21
|
-
path: PathState;
|
|
22
|
-
pointer: Point;
|
|
23
|
-
}
|
|
24
|
-
export declare class ReactLasso extends React.Component<ReactLassoProps, ReactLassoState> {
|
|
25
|
-
state: ReactLassoState;
|
|
26
|
-
imageRef: React.RefObject<HTMLImageElement>;
|
|
27
|
-
svgRef: React.RefObject<SVGSVGElement>;
|
|
28
|
-
svg: SVGHelper;
|
|
29
|
-
angles: number[];
|
|
30
|
-
path: PathState;
|
|
31
|
-
lastEmittedPoints: Point[];
|
|
32
|
-
lastUpdatedPoints: Point[];
|
|
33
|
-
imgError: boolean;
|
|
34
|
-
setPathFromPropsOnMediaLoad: boolean;
|
|
35
|
-
constructor(props: ReactLassoProps);
|
|
36
|
-
render(): JSX.Element;
|
|
37
|
-
componentDidUpdate(prevProps: ReactLassoProps): void;
|
|
38
|
-
convertPoints(points: Point[]): Point[];
|
|
39
|
-
checkIfPathUpdated(wasClosedBefore: boolean): void;
|
|
40
|
-
emitOnChange({ points }: PathState): void;
|
|
41
|
-
emitOnComplete(convertedPoints: Point[]): void;
|
|
42
|
-
setPointer({ x, y }: Point, force?: boolean): void;
|
|
43
|
-
hidePointer: () => void;
|
|
44
|
-
dispatchPathAction(action: pathReducerAction & {
|
|
45
|
-
pointer?: Point;
|
|
46
|
-
}): void;
|
|
47
|
-
isLoaded(): boolean;
|
|
48
|
-
getAspectRatio(): Point;
|
|
49
|
-
setPathStateFromProps(): void;
|
|
50
|
-
getRoundedPoints(): Point[];
|
|
51
|
-
getBorder(): Point[];
|
|
52
|
-
getPolygonPoints(): Point[];
|
|
53
|
-
getPolylinePoints(): Point[];
|
|
54
|
-
getMousePosition(e: touchOrMouseEvent<SVGSVGElement>, lookupForNearlyPoints?: boolean, lookupForApproximation?: boolean): [Point, {
|
|
55
|
-
point: Point;
|
|
56
|
-
index: number;
|
|
57
|
-
}];
|
|
58
|
-
onShapeDrag: ({ dx, dy }: Vector) => void;
|
|
59
|
-
onPointDrag: (idx: number, { dx, dy }: Vector) => void;
|
|
60
|
-
onPointClick: (idx: number) => void;
|
|
61
|
-
onDragEnd: () => void;
|
|
62
|
-
onMediaLoaded: (e: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
63
|
-
onMediaError: (e: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
64
|
-
onClickTouchEvent: (e: touchOrMouseEvent<SVGSVGElement>) => void;
|
|
65
|
-
onClick: (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => void;
|
|
66
|
-
onTouchEnd: (e: React.TouchEvent<SVGSVGElement>) => void;
|
|
67
|
-
onMouseTouchMove: (e: touchOrMouseEvent<SVGSVGElement>) => void;
|
|
68
|
-
onContextMenu: (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => void;
|
|
69
|
-
static propTypes: {
|
|
70
|
-
value: PropTypes.Requireable<(Required<PropTypes.InferProps<{
|
|
71
|
-
x: PropTypes.Validator<number>;
|
|
72
|
-
y: PropTypes.Validator<number>;
|
|
73
|
-
}>> | null | undefined)[]>;
|
|
74
|
-
style: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
75
|
-
viewBox: PropTypes.Requireable<Required<PropTypes.InferProps<{
|
|
76
|
-
width: PropTypes.Validator<number>;
|
|
77
|
-
height: PropTypes.Validator<number>;
|
|
78
|
-
}>>>;
|
|
79
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
80
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
81
|
-
onComplete: PropTypes.Requireable<(...args: any[]) => any>;
|
|
82
|
-
src: PropTypes.Validator<string>;
|
|
83
|
-
imageAlt: PropTypes.Requireable<string>;
|
|
84
|
-
crossOrigin: PropTypes.Requireable<string>;
|
|
85
|
-
imageStyle: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
86
|
-
onImageLoad: PropTypes.Requireable<(...args: any[]) => any>;
|
|
87
|
-
onImageError: PropTypes.Requireable<(...args: any[]) => any>;
|
|
88
|
-
};
|
|
89
|
-
static defaultProps: {
|
|
90
|
-
value: never[];
|
|
91
|
-
style: {};
|
|
92
|
-
imageStyle: {};
|
|
93
|
-
viewBox: {
|
|
94
|
-
width: number;
|
|
95
|
-
height: number;
|
|
96
|
-
};
|
|
97
|
-
disabled: boolean;
|
|
98
|
-
onImageError: Function;
|
|
99
|
-
onImageLoad: Function;
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export { ReactLasso as default, ReactLasso as Component, getClippedImageCanvas as getCanvas };
|