@yorab/react-paint 0.7.6 → 0.9.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/README.md +1 -11
- package/dist/components/App.d.ts +20 -0
- package/dist/components/Canvas.d.ts +38 -0
- package/dist/components/common/Button.d.ts +16 -0
- package/dist/components/common/Loading.d.ts +7 -0
- package/dist/components/common/Modal.d.ts +10 -0
- package/dist/components/common/Panel.d.ts +13 -0
- package/dist/components/common/Snackbar.d.ts +8 -0
- package/dist/components/settings/ColorField.d.ts +15 -0
- package/dist/components/settings/DeleteButton.d.ts +9 -0
- package/dist/components/settings/FontFamilyField.d.ts +12 -0
- package/dist/components/settings/LayoutButton.d.ts +8 -0
- package/dist/components/settings/Layouts.d.ts +19 -0
- package/dist/components/settings/LineArrowField.d.ts +12 -0
- package/dist/components/settings/LineTypeField.d.ts +16 -0
- package/dist/components/settings/PointsNumberField.d.ts +13 -0
- package/dist/components/settings/RangeField.d.ts +18 -0
- package/dist/components/settings/SelectField.d.ts +18 -0
- package/dist/components/settings/SettingsBar.d.ts +21 -0
- package/dist/components/settings/ToggleField.d.ts +12 -0
- package/dist/components/toolbox/EditTextBox.d.ts +14 -0
- package/dist/components/toolbox/LoadFileTool.d.ts +12 -0
- package/dist/components/toolbox/MenuGroup.d.ts +35 -0
- package/dist/components/toolbox/PictureUrlInput.d.ts +8 -0
- package/dist/components/toolbox/Tool.d.ts +12 -0
- package/dist/components/toolbox/Toolbar.d.ts +27 -0
- package/dist/components/toolbox/ToolbarGroup.d.ts +18 -0
- package/dist/constants/app.d.ts +41 -0
- package/dist/constants/icons.d.ts +41 -0
- package/dist/constants/loading.d.ts +1 -0
- package/dist/constants/picture.d.ts +1 -0
- package/dist/constants/shapes.d.ts +8 -0
- package/dist/constants/snackbar.d.ts +7 -0
- package/dist/constants/style.d.ts +17 -0
- package/dist/constants/tools.d.ts +32 -0
- package/dist/hooks/useComponent.d.ts +9 -0
- package/dist/hooks/useDoubleClick.d.ts +5 -0
- package/dist/hooks/useDrag.d.ts +15 -0
- package/dist/hooks/useDrawableCanvas.d.ts +37 -0
- package/dist/hooks/useKeyboard.d.ts +20 -0
- package/dist/hooks/useResizeObserver.d.ts +7 -0
- package/dist/hooks/useShapes.d.ts +26 -0
- package/dist/hooks/useSnackbar.d.ts +10 -0
- package/dist/react-paint.css +1 -0
- package/dist/react-paint.js +8887 -0
- package/dist/react-paint.umd.cjs +27 -0
- package/dist/types/Mode.d.ts +43 -0
- package/dist/types/Shapes.d.ts +128 -0
- package/dist/types/react.d.ts +7 -0
- package/dist/types/snackbar.d.ts +7 -0
- package/dist/types/tools.d.ts +125 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/utils/canvas.d.ts +10 -0
- package/dist/utils/data.d.ts +4 -0
- package/dist/utils/dom.d.ts +1 -0
- package/dist/utils/file.d.ts +10 -0
- package/dist/utils/grid.d.ts +3 -0
- package/dist/utils/intersect.d.ts +6 -0
- package/dist/utils/migration.d.ts +147 -0
- package/dist/utils/selection/lineSelection.d.ts +12 -0
- package/dist/utils/selection/rectSelection.d.ts +13 -0
- package/dist/utils/selection.d.ts +7 -0
- package/dist/utils/shapes/brush.d.ts +20 -0
- package/dist/utils/shapes/circle.d.ts +17 -0
- package/dist/utils/shapes/curve.d.ts +16 -0
- package/dist/utils/shapes/ellipse.d.ts +17 -0
- package/dist/utils/shapes/index.d.ts +29 -0
- package/dist/utils/shapes/line.d.ts +17 -0
- package/dist/utils/shapes/path.d.ts +9 -0
- package/dist/utils/shapes/picture.d.ts +12 -0
- package/dist/utils/shapes/polygon.d.ts +17 -0
- package/dist/utils/shapes/rectangle.d.ts +20 -0
- package/dist/utils/shapes/text.d.ts +19 -0
- package/dist/utils/shapes/triangle.d.ts +3 -0
- package/dist/utils/string.d.ts +3 -0
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/toolbar.d.ts +13 -0
- package/dist/utils/transform.d.ts +9 -0
- package/dist/utils/trigo.d.ts +16 -0
- package/package.json +52 -57
- package/dist/components/App.js +0 -496
- package/dist/components/Canvas.js +0 -194
- package/dist/components/common/Button.js +0 -88
- package/dist/components/common/Loading.js +0 -57
- package/dist/components/common/Modal.js +0 -46
- package/dist/components/common/Panel.js +0 -43
- package/dist/components/common/Snackbar.js +0 -68
- package/dist/components/settings/ColorField.js +0 -125
- package/dist/components/settings/DeleteButton.js +0 -37
- package/dist/components/settings/FontFamilyField.js +0 -67
- package/dist/components/settings/LayoutButton.js +0 -39
- package/dist/components/settings/Layouts.js +0 -214
- package/dist/components/settings/LineArrowField.js +0 -67
- package/dist/components/settings/LineTypeField.js +0 -65
- package/dist/components/settings/PointsNumberField.js +0 -45
- package/dist/components/settings/RangeField.js +0 -82
- package/dist/components/settings/SelectField.js +0 -81
- package/dist/components/settings/SettingsBar.js +0 -383
- package/dist/components/settings/ToggleField.js +0 -49
- package/dist/components/toolbox/EditTextBox.js +0 -138
- package/dist/components/toolbox/LoadFileTool.js +0 -58
- package/dist/components/toolbox/MenuGroup.js +0 -173
- package/dist/components/toolbox/PictureUrlInput.js +0 -68
- package/dist/components/toolbox/Tool.js +0 -41
- package/dist/components/toolbox/Toolbar.js +0 -203
- package/dist/components/toolbox/ToolbarGroup.js +0 -134
- package/dist/constants/app.js +0 -51
- package/dist/constants/icons.js +0 -88
- package/dist/constants/loading.js +0 -8
- package/dist/constants/picture.js +0 -8
- package/dist/constants/shapes.js +0 -20
- package/dist/constants/snackbar.js +0 -15
- package/dist/constants/style.js +0 -35
- package/dist/constants/tools.js +0 -424
- package/dist/hooks/useComponent.js +0 -47
- package/dist/hooks/useDoubleClick.js +0 -46
- package/dist/hooks/useDrag.js +0 -92
- package/dist/hooks/useDrawableCanvas.js +0 -230
- package/dist/hooks/useKeyboard.js +0 -142
- package/dist/hooks/useResizeObserver.js +0 -42
- package/dist/hooks/useShapes.js +0 -184
- package/dist/hooks/useSnackbar.js +0 -56
- package/dist/styles.css +0 -91
- package/dist/types/Mode.js +0 -5
- package/dist/types/Shapes.js +0 -5
- package/dist/types/snackbar.js +0 -5
- package/dist/types/tools.js +0 -5
- package/dist/types/utils.js +0 -5
- package/dist/utils/canvas.js +0 -49
- package/dist/utils/data.js +0 -49
- package/dist/utils/dom.js +0 -12
- package/dist/utils/file.js +0 -177
- package/dist/utils/intersect.js +0 -122
- package/dist/utils/migration.js +0 -59
- package/dist/utils/selection.js +0 -86
- package/dist/utils/shapes/brush.js +0 -135
- package/dist/utils/shapes/circle.js +0 -93
- package/dist/utils/shapes/curve.js +0 -55
- package/dist/utils/shapes/default.js +0 -73
- package/dist/utils/shapes/ellipse.js +0 -101
- package/dist/utils/shapes/grid.js +0 -36
- package/dist/utils/shapes/index.js +0 -341
- package/dist/utils/shapes/line.js +0 -179
- package/dist/utils/shapes/picture.js +0 -109
- package/dist/utils/shapes/polygon.js +0 -69
- package/dist/utils/shapes/rectangle.js +0 -100
- package/dist/utils/shapes/text.js +0 -128
- package/dist/utils/shapes/triangle.js +0 -24
- package/dist/utils/string.js +0 -36
- package/dist/utils/style.js +0 -46
- package/dist/utils/toolbar.js +0 -78
- package/dist/utils/transform.js +0 -109
- package/dist/utils/trigo.js +0 -42
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DrawableShape, Picture, Point, Rect, ShapeEntity } from '../../types/Shapes';
|
|
2
|
+
import { SelectionModeResize } from '../../types/Mode';
|
|
3
|
+
import { GridFormatType } from '../../constants/app';
|
|
4
|
+
export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape: T, currentScale: number, selectionPadding: number) => T;
|
|
5
|
+
export declare const createPicture: (fileOrUrl: File | string, maxPictureWidth: number, maxPictureHeight: number, currentScale: number, selectionPadding: number) => Promise<ShapeEntity<"picture">>;
|
|
6
|
+
export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: DrawableShape<'picture'>) => void;
|
|
7
|
+
export declare const getPictureBorder: (picture: Picture, selectionPadding: number) => Rect;
|
|
8
|
+
export declare const translatePicture: <U extends DrawableShape<"picture">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const resizePicture: (cursorPosition: Point, originalShape: DrawableShape<'picture'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio: boolean) => DrawableShape<'picture'>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridFormatType } from '../../constants/app';
|
|
2
|
+
import { SelectionModeResize } from '../../types/Mode';
|
|
3
|
+
import type { Point, DrawableShape, Polygon, Rect, ShapeEntity } from '../../types/Shapes';
|
|
4
|
+
import type { ToolsSettingsType } from '../../types/tools';
|
|
5
|
+
export declare const refreshPolygon: <T extends DrawableShape<"polygon">>(shape: T, currentScale: number, selectionPadding: number) => T;
|
|
6
|
+
export declare const createPolygon: (shape: {
|
|
7
|
+
id: string;
|
|
8
|
+
type: 'polygon';
|
|
9
|
+
settings: ToolsSettingsType<'polygon'>;
|
|
10
|
+
}, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'polygon'>;
|
|
11
|
+
export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: DrawableShape<'polygon'>) => void;
|
|
12
|
+
export declare const getPolygonBorder: (polygon: Polygon, selectionPadding: number) => Rect;
|
|
13
|
+
export declare const translatePolygon: <U extends DrawableShape<"polygon">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
|
|
14
|
+
points: Point[];
|
|
15
|
+
};
|
|
16
|
+
export declare const resizePolygon: (cursorPosition: Point, canvasOffset: Point, originalShape: DrawableShape<'polygon'>, selectionMode: SelectionModeResize<number>, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'polygon'>;
|
|
17
|
+
export declare const updatePolygonLinesCount: <T extends DrawableShape<"polygon">>(shape: T, newPointsCount: number, currentScale: number, selectionPadding: number) => T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GridFormatType } from '../../constants/app';
|
|
2
|
+
import type { SelectionModeResize } from '../../types/Mode';
|
|
3
|
+
import type { Point, DrawableShape, ShapeEntity, Rect } from '../../types/Shapes';
|
|
4
|
+
import type { ToolsSettingsType } from '../../types/tools';
|
|
5
|
+
type rectish = 'text' | 'rect' | 'square' | 'picture';
|
|
6
|
+
export declare const refreshRect: <T extends DrawableShape<rectish>>(rect: T, currentScale: number, selectionPadding: number) => T;
|
|
7
|
+
export declare const createRectangle: <T extends "rect" | "square">(shape: {
|
|
8
|
+
id: string;
|
|
9
|
+
type: T;
|
|
10
|
+
settings: ToolsSettingsType<T>;
|
|
11
|
+
}, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<T>;
|
|
12
|
+
export declare const drawRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'rect' | 'square'>) => void;
|
|
13
|
+
export declare const getRectBorder: (rect: Rect, selectionPadding: number) => Rect;
|
|
14
|
+
export declare const getRectOppositeAnchorAbsolutePosition: <T extends DrawableShape & Rect>(anchor: Point, center: Point, shape: T, canvasOffset: Point, [negW, negH]?: [boolean, boolean]) => Point;
|
|
15
|
+
export declare const translateRect: <T extends "rect" | "square", U extends DrawableShape<T>>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const resizeRect: <T extends rectish>(cursorPosition: Point, originalShape: DrawableShape<T>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio?: boolean) => DrawableShape<T>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Point, DrawableShape, Text, Rect, ShapeEntity } from '../../types/Shapes';
|
|
2
|
+
import type { ToolsSettingsType } from '../../types/tools';
|
|
3
|
+
import { SelectionModeResize } from '../../types/Mode';
|
|
4
|
+
import { GridFormatType } from '../../constants/app';
|
|
5
|
+
export declare const refreshText: <T extends DrawableShape<"text">>(shape: T, currentScale: number, selectionPadding: number) => T;
|
|
6
|
+
export declare const calculateTextFontSize: (ctx: CanvasRenderingContext2D, text: string[], maxWidth: number, fontBold: boolean, fontItalic: boolean, fontFamily?: string | undefined) => number;
|
|
7
|
+
export declare const createText: (ctx: CanvasRenderingContext2D, shape: {
|
|
8
|
+
id: string;
|
|
9
|
+
type: 'text';
|
|
10
|
+
settings: ToolsSettingsType<'text'>;
|
|
11
|
+
}, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'text'>;
|
|
12
|
+
export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<'text'>) => void;
|
|
13
|
+
export declare const getTextBorder: (text: Text, selectionPadding: number) => Rect;
|
|
14
|
+
export declare const translateText: <U extends DrawableShape<"text">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const resizeText: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: DrawableShape<'text'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'text'>;
|
|
19
|
+
export declare const resizeTextShapeWithNewContent: <U extends DrawableShape<"text">>(ctx: CanvasRenderingContext2D, shape: U, newValue: string[], selectionPadding: number, canvasOffset: Point) => U;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { ShapeType } from '../types/Shapes';
|
|
2
|
+
export declare const getShapePicture: (shape: ShapeType) => "" | "<svg><path d=\"M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z\"/></svg>" | "<svg><path d=\"M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z\"/></svg>" | "<svg><path d=\"M10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333ZM10 16.583Q12.75 16.583 14.667 14.667Q16.583 12.75 16.583 10Q16.583 7.25 14.667 5.333Q12.75 3.417 10 3.417Q7.25 3.417 5.333 5.333Q3.417 7.25 3.417 10Q3.417 12.75 5.333 14.667Q7.25 16.583 10 16.583ZM10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Z\"/></svg>" | "<svg><path d=\"M12.25 18.333V16.167L6.833 13.458H2.5V8.208H6.25L8.25 5.917V1.667H13.5V6.917H9.708L7.75 9.146V11.958L12.25 14.208V13.083H17.5V18.333Z\"/></svg>" | "<svg><path d=\"M4.792 15.083 8.333 11.542 9.833 13.021 11.667 10.708 15.167 15.083ZM6.667 8.417Q5.938 8.417 5.427 7.906Q4.917 7.396 4.917 6.667Q4.917 5.938 5.427 5.427Q5.938 4.917 6.667 4.917Q7.396 4.917 7.906 5.427Q8.417 5.938 8.417 6.667Q8.417 7.396 7.906 7.906Q7.396 8.417 6.667 8.417ZM4.167 18.333Q3.125 18.333 2.396 17.604Q1.667 16.875 1.667 15.833V4.167Q1.667 3.125 2.396 2.396Q3.125 1.667 4.167 1.667H15.833Q16.875 1.667 17.604 2.396Q18.333 3.125 18.333 4.167V15.833Q18.333 16.875 17.604 17.604Q16.875 18.333 15.833 18.333ZM4.167 16.583H15.833Q16.146 16.583 16.365 16.365Q16.583 16.146 16.583 15.833V4.167Q16.583 3.854 16.365 3.635Q16.146 3.417 15.833 3.417H4.167Q3.854 3.417 3.635 3.635Q3.417 3.854 3.417 4.167V15.833Q3.417 16.146 3.635 16.365Q3.854 16.583 4.167 16.583Z\"/></svg>" | "<svg><path d=\"M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z\"/></svg>" | "<svg><path d=\"M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z\"/></svg>" | "<svg><path d=\"M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z\"/></svg>";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ShapeType } from '../types/Shapes';
|
|
2
|
+
import type { CustomTool, CustomToolInput } from '../types/tools';
|
|
3
|
+
import type { RecursivePartial } from '../types/utils';
|
|
4
|
+
export declare const getCurrentStructure: (availableTools: CustomTool[], defaultStructure: (ShapeType | {
|
|
5
|
+
title: string;
|
|
6
|
+
toolsType: ShapeType[];
|
|
7
|
+
vertical: boolean;
|
|
8
|
+
})[]) => (CustomTool | {
|
|
9
|
+
title: string;
|
|
10
|
+
toolsType: CustomTool[];
|
|
11
|
+
vertical: boolean;
|
|
12
|
+
})[];
|
|
13
|
+
export declare const sanitizeTools: (tools: RecursivePartial<CustomToolInput>[], withPicture?: boolean) => CustomTool[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SelectionModeData } from '../types/Mode';
|
|
2
|
+
import type { Point, ShapeEntity } from '../types/Shapes';
|
|
3
|
+
import type { GridFormatType } from '../constants/app';
|
|
4
|
+
export declare const getNormalizedSize: (originalWidth: number, originalHeight: number, width: number, height: number) => number[];
|
|
5
|
+
export declare const roundValues: (prop: number, precision?: number) => number;
|
|
6
|
+
export declare const roundForGrid: (value: number, gridFormat: GridFormatType, gridOffset?: number) => number;
|
|
7
|
+
export declare const roundRotationForGrid: (rotation: number, gridFormat: GridFormatType, gridOffset?: number) => number;
|
|
8
|
+
export declare const transformShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, cursorPosition: Point, gridFormat: GridFormatType, canvasOffset: Point, selectionMode: SelectionModeData<Point | number>, selectionPadding: number, isShiftPressed: boolean, currentScale: number) => ShapeEntity;
|
|
9
|
+
export declare const fitContentInsideContainer: (contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number, shouldFillContainer?: boolean) => number[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Point, Rect } from '../types/Shapes';
|
|
2
|
+
type Vector = [Point, Point];
|
|
3
|
+
export declare const degreesToRadians: (degrees: number) => number;
|
|
4
|
+
export declare const radiansToDegrees: (radians: number) => number;
|
|
5
|
+
export declare const isPointInsideRect: (rect: Rect, point: Point) => boolean;
|
|
6
|
+
export declare const rotatePoint: ({ origin, point, rotation }: {
|
|
7
|
+
origin?: Point | undefined;
|
|
8
|
+
point: Point;
|
|
9
|
+
rotation: number;
|
|
10
|
+
}) => Point;
|
|
11
|
+
export declare const getAngleFromVector: ({ targetVector: [point1, point2], radian, originVector }: {
|
|
12
|
+
targetVector: Vector;
|
|
13
|
+
radian?: boolean | undefined;
|
|
14
|
+
originVector?: Vector | undefined;
|
|
15
|
+
}) => number;
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,78 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yorab/react-paint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"keywords": [],
|
|
5
6
|
"author": "Yohann Rabatel",
|
|
6
7
|
"license": "MIT",
|
|
7
|
-
"main": "./dist/
|
|
8
|
+
"main": "./dist/react-paint.js",
|
|
9
|
+
"module": "./dist/react-paint.umd.cjs",
|
|
8
10
|
"types": "./dist/components/App.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/react-paint.js",
|
|
14
|
+
"require": "./dist/react-paint.umd.cjs",
|
|
15
|
+
"types": "./dist/components/App.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./react-paint.css": "./dist/react-paint.css"
|
|
18
|
+
},
|
|
9
19
|
"files": [
|
|
10
20
|
"README.md",
|
|
21
|
+
"LICENSE.txt",
|
|
11
22
|
"package.json",
|
|
12
23
|
"dist/"
|
|
13
24
|
],
|
|
14
25
|
"dependencies": {
|
|
15
|
-
"
|
|
16
|
-
"lodash": "^4.17.20"
|
|
26
|
+
"lodash": "4.17.21"
|
|
17
27
|
},
|
|
18
28
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
|
50
|
-
"html-webpack-plugin": "^5.5.0",
|
|
51
|
-
"mini-css-extract-plugin": "^2.6.0",
|
|
52
|
-
"prettier": "^2.3.2",
|
|
53
|
-
"react": "18.1.0",
|
|
54
|
-
"react-dom": "18.1.0",
|
|
55
|
-
"typescript": "^4.7.2",
|
|
56
|
-
"webpack": "^5.66.0",
|
|
57
|
-
"webpack-cli": "^4.9.1",
|
|
58
|
-
"webpack-dev-server": "^4.7.3"
|
|
29
|
+
"@storybook/addon-essentials": "7.6.3",
|
|
30
|
+
"@storybook/addon-interactions": "7.6.3",
|
|
31
|
+
"@storybook/addon-links": "7.6.3",
|
|
32
|
+
"@storybook/blocks": "7.6.3",
|
|
33
|
+
"@storybook/react": "7.6.3",
|
|
34
|
+
"@storybook/react-vite": "7.6.3",
|
|
35
|
+
"@storybook/test": "^7.6.3",
|
|
36
|
+
"@storybook/testing-library": "0.2.2",
|
|
37
|
+
"@types/lodash": "4.14.196",
|
|
38
|
+
"@types/node": "20.4.5",
|
|
39
|
+
"@types/react": "18.2.17",
|
|
40
|
+
"@types/react-dom": "18.2.7",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "6.0.0",
|
|
42
|
+
"@typescript-eslint/parser": "6.0.0",
|
|
43
|
+
"@vitejs/plugin-react": "4.2.0",
|
|
44
|
+
"eslint": "8.45.0",
|
|
45
|
+
"eslint-config-prettier": "8.9.0",
|
|
46
|
+
"eslint-import-resolver-typescript": "3.5.5",
|
|
47
|
+
"eslint-plugin-import": "2.28.0",
|
|
48
|
+
"eslint-plugin-prettier": "5.0.0",
|
|
49
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
50
|
+
"eslint-plugin-storybook": "0.6.15",
|
|
51
|
+
"lightningcss": "1.21.5",
|
|
52
|
+
"prettier": "3.0.0",
|
|
53
|
+
"react": "18.2.0",
|
|
54
|
+
"react-dom": "18.2.0",
|
|
55
|
+
"storybook": "7.6.3",
|
|
56
|
+
"typescript": "5.3.2",
|
|
57
|
+
"vite": "5.0.2",
|
|
58
|
+
"vite-tsconfig-paths": "4.2.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"react": "
|
|
62
|
-
"react-dom": "
|
|
61
|
+
"react": "18.x",
|
|
62
|
+
"react-dom": "18.x"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
|
-
"declarationfiles": "tsc --project tsconfig.prod.json",
|
|
66
|
-
"start": "
|
|
65
|
+
"declarationfiles": "npx tsc --project tsconfig.prod.json",
|
|
66
|
+
"start": "storybook dev -p 6006",
|
|
67
|
+
"build-storybook": "storybook build",
|
|
67
68
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"publish": "npm run buildwithcss && npm publish --access public"
|
|
72
|
-
},
|
|
73
|
-
"jest": {
|
|
74
|
-
"transform": {
|
|
75
|
-
"^.+\\.[t|j]sx?$": "babel-jest"
|
|
76
|
-
}
|
|
69
|
+
"build": "vite build && npm run declarationfiles",
|
|
70
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
71
|
+
"publishnpm": "npm run build && npm publish --access public"
|
|
77
72
|
}
|
|
78
73
|
}
|