@yorab/react-paint 0.10.0 → 0.10.1

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 CHANGED
@@ -1 +1 @@
1
- # React Paint V0.9.3
1
+ # React Paint V0.10.1
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import { type GridFormatType } from '../constants/app';
2
+ import { UtilsSettings } from '../constants/app';
3
3
  import type { SelectionModeData } from '../types/Mode';
4
4
  import type { Point, ShapeEntity } from '../types/Shapes';
5
5
  import type { ToolsType } from '../types/tools';
6
6
  import './Canvas.css';
7
7
  type DrawerType = {
8
- gridFormat: GridFormatType;
9
8
  disabled?: boolean;
10
9
  canGrow?: boolean;
11
10
  canvasSize: {
@@ -15,7 +14,7 @@ type DrawerType = {
15
14
  };
16
15
  selectionColor: string;
17
16
  selectionWidth: number;
18
- selectionPadding: number;
17
+ settings: UtilsSettings;
19
18
  isEditMode: boolean;
20
19
  shapes: ShapeEntity[];
21
20
  saveShapes: () => void;
@@ -26,13 +25,12 @@ type DrawerType = {
26
25
  setSelectionFrame: React.Dispatch<React.SetStateAction<[Point, Point] | undefined>>;
27
26
  hoveredShape: ShapeEntity | undefined;
28
27
  selectionFrame: [Point, Point] | undefined;
29
- refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, canvasOffset: Point, currentScale: number) => void;
30
- refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, canvasOffset: Point, currentScale: number) => void;
28
+ refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
29
+ refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
31
30
  activeTool: ToolsType;
32
31
  setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
33
32
  canvasOffsetStartPosition: Point | undefined;
34
33
  setCanvasOffsetStartPosition: React.Dispatch<React.SetStateAction<Point | undefined>>;
35
- canvasOffset: Point;
36
34
  setCanvasOffset: React.Dispatch<React.SetStateAction<Point>>;
37
35
  isInsideComponent: boolean;
38
36
  selectionMode: SelectionModeData<number | Point>;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { ShapeEntity } from '../../types/Shapes';
3
3
  import type { CustomTool, ToolsType } from '../../types/tools';
4
4
  import './SettingsBar.css';
5
+ import { UtilsSettings } from 'src/constants/app';
5
6
  type SettingsBoxType = {
6
7
  width: number;
7
8
  disabled?: boolean;
@@ -11,11 +12,10 @@ type SettingsBoxType = {
11
12
  activeTool: ToolsType;
12
13
  selectedShape: ShapeEntity | undefined;
13
14
  canvas: HTMLCanvasElement | null;
14
- currentScale: number;
15
- selectionPadding: number;
15
+ settings: UtilsSettings;
16
16
  updateShape: (shape: ShapeEntity, withSave?: boolean) => void;
17
17
  removeShape: (shape: ShapeEntity) => void;
18
18
  toggleLayoutPanel: () => void;
19
19
  };
20
- declare const SettingsBar: ({ width, disabled, availableTools, updateToolSettings, layersManipulation, toggleLayoutPanel, activeTool, selectedShape, canvas, currentScale, selectionPadding, updateShape, removeShape }: SettingsBoxType) => React.JSX.Element;
20
+ declare const SettingsBar: ({ width, disabled, availableTools, updateToolSettings, layersManipulation, toggleLayoutPanel, activeTool, selectedShape, canvas, settings, updateShape, removeShape }: SettingsBoxType) => React.JSX.Element;
21
21
  export default SettingsBar;
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import type { DrawableShape } from '../../types/Shapes';
3
3
  import './EditTextBox.css';
4
+ import { UtilsSettings } from 'src/constants/app';
4
5
  type EditTextBoxType = {
5
6
  scaleRatio: number;
6
7
  disabled?: boolean;
7
8
  shape: DrawableShape<'text'>;
8
9
  defaultValue: string[];
9
- selectionPadding: number;
10
+ settings: UtilsSettings;
10
11
  updateValue: (newValue: string[]) => void;
11
12
  saveShapes: () => void;
12
13
  };
13
- declare const EditTextBox: ({ disabled, scaleRatio, shape, defaultValue, updateValue, saveShapes, selectionPadding }: EditTextBoxType) => React.JSX.Element;
14
+ declare const EditTextBox: ({ disabled, scaleRatio, shape, defaultValue, updateValue, saveShapes, settings }: EditTextBoxType) => React.JSX.Element;
14
15
  export default EditTextBox;
@@ -1,4 +1,4 @@
1
- import type { DrawableShapeJson } from '../types/Shapes';
1
+ import type { DrawableShapeJson, Point } from '../types/Shapes';
2
2
  import type { CustomToolInput } from '../types/tools';
3
3
  import type { RecursivePartial } from '../types/utils';
4
4
  export declare const APP_NAME = "react_paint";
@@ -9,6 +9,18 @@ export declare const GRID_SMALL = 1;
9
9
  export declare const GRID_MEDIUM = 2;
10
10
  export declare const GRID_LARGE = 3;
11
11
  export type GridFormatType = typeof GRID_NONE | typeof GRID_SMALL | typeof GRID_MEDIUM | typeof GRID_LARGE;
12
+ export type BrushAlgo = 'simple' | 'quadratic';
13
+ export type UtilsSettings = {
14
+ brushAlgo: BrushAlgo;
15
+ gridFormat: GridFormatType;
16
+ canvasOffset: Point;
17
+ canvasSize: {
18
+ width: number;
19
+ height: number;
20
+ scaleRatio: number;
21
+ };
22
+ selectionPadding: number;
23
+ };
12
24
  type AppOptionsType = {
13
25
  layersManipulation: boolean;
14
26
  grid: GridFormatType;
@@ -22,6 +34,7 @@ type AppOptionsType = {
22
34
  withFrameSelection: boolean;
23
35
  withSkeleton: boolean;
24
36
  clearCallback: 'empty' | 'defaultShapes' | (() => DrawableShapeJson[]);
37
+ brushAlgo: BrushAlgo;
25
38
  uiStyle: {
26
39
  toolbarBackgroundColor: string;
27
40
  dividerColor: string;
@@ -1,15 +1,10 @@
1
1
  import React from 'react';
2
- import type { GridFormatType } from '../constants/app';
2
+ import type { UtilsSettings } from '../constants/app';
3
3
  import type { HoverModeData, SelectionModeData } from '../types/Mode';
4
4
  import type { Point, ShapeEntity } from '../types/Shapes';
5
5
  import type { ToolsType } from '../types/tools';
6
6
  type UseCanvasType = {
7
7
  disabled?: boolean;
8
- canvasSize: {
9
- width: number;
10
- height: number;
11
- scaleRatio: number;
12
- };
13
8
  shapes: ShapeEntity[];
14
9
  saveShapes: () => void;
15
10
  addShape: (newShape: ShapeEntity) => void;
@@ -18,12 +13,10 @@ type UseCanvasType = {
18
13
  setSelectedShape: React.Dispatch<React.SetStateAction<ShapeEntity | undefined>>;
19
14
  activeTool: ToolsType;
20
15
  setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
21
- refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, canvasOffset: Point, currentScale: number) => void;
22
- refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, canvasOffset: Point, currentScale: number) => void;
16
+ refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
17
+ refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
23
18
  canvasOffsetStartPosition: Point | undefined;
24
19
  setCanvasOffsetStartPosition: React.Dispatch<React.SetStateAction<Point | undefined>>;
25
- gridFormat: GridFormatType;
26
- canvasOffset: Point;
27
20
  setCanvasOffset: React.Dispatch<React.SetStateAction<Point>>;
28
21
  isInsideComponent: boolean;
29
22
  selectionMode: SelectionModeData<number | Point>;
@@ -31,11 +24,11 @@ type UseCanvasType = {
31
24
  setSelectionFrame: React.Dispatch<React.SetStateAction<[Point, Point] | undefined>>;
32
25
  drawCanvasRef: React.MutableRefObject<HTMLCanvasElement | null>;
33
26
  selectionCanvasRef: React.MutableRefObject<HTMLCanvasElement | null>;
34
- selectionPadding: number;
35
27
  isShiftPressed: boolean;
36
28
  withFrameSelection: boolean;
29
+ settings: UtilsSettings;
37
30
  };
38
- declare const useDrawableCanvas: ({ disabled, addShape, canvasSize, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, selectionCanvasRef, canvasOffsetStartPosition, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartPosition, updateSingleShape, gridFormat, canvasOffset, saveShapes, setSelectionMode, selectionPadding, isShiftPressed, withFrameSelection }: UseCanvasType) => {
31
+ declare const useDrawableCanvas: ({ disabled, addShape, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, selectionCanvasRef, canvasOffsetStartPosition, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartPosition, updateSingleShape, saveShapes, setSelectionMode, settings, isShiftPressed, withFrameSelection }: UseCanvasType) => {
39
32
  hoverMode: HoverModeData;
40
33
  };
41
34
  export default useDrawableCanvas;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { GridFormatType } from '../constants/app';
2
+ import type { UtilsSettings } from '../constants/app';
3
3
  import type { ShapeEntity } from '../types/Shapes';
4
4
  type UseKeyboardType = {
5
5
  isInsideComponent: boolean;
@@ -12,9 +12,7 @@ type UseKeyboardType = {
12
12
  forwardShape: () => void;
13
13
  setShiftPressed: (value: React.SetStateAction<boolean>) => void;
14
14
  isEditingText: boolean;
15
- gridFormat: GridFormatType;
16
- currentScale: number;
17
- selectionPadding: number;
15
+ settings: UtilsSettings;
18
16
  };
19
- declare const useKeyboard: ({ gridFormat, isInsideComponent, selectedShape, isEditingText, currentScale, selectionPadding, setSelectedShape, removeShape, pasteShape, updateShape, backwardShape, forwardShape, setShiftPressed }: UseKeyboardType) => {};
17
+ declare const useKeyboard: ({ isInsideComponent, selectedShape, isEditingText, settings, setSelectedShape, removeShape, pasteShape, updateShape, backwardShape, forwardShape, setShiftPressed }: UseKeyboardType) => {};
20
18
  export default useKeyboard;
@@ -1,22 +1,19 @@
1
1
  /// <reference types="react" />
2
+ import { UtilsSettings } from 'src/constants/app';
2
3
  import type { Point, ShapeEntity } from '../types/Shapes';
3
- declare const useShapes: (onDataChanged: (() => void) | undefined, selectionPadding: number, canvasSize: {
4
- width: number;
5
- height: number;
6
- scaleRatio: number;
7
- }) => {
4
+ declare const useShapes: (onDataChanged: (() => void) | undefined, settings: UtilsSettings) => {
8
5
  shapesRef: import("react").MutableRefObject<ShapeEntity[]>;
9
6
  selectedShape: ShapeEntity | undefined;
10
7
  hoveredShape: ShapeEntity | undefined;
11
8
  selectionFrame: [Point, Point] | undefined;
12
9
  setSelectionFrame: import("react").Dispatch<import("react").SetStateAction<[Point, Point] | undefined>>;
13
- refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, canvasOffset: Point, currentScale: number) => void;
10
+ refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
14
11
  addShape: (newShape: ShapeEntity) => void;
15
12
  addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
16
13
  moveShapes: (firstShapeId: string, lastShapeId: string) => void;
17
14
  saveShapes: () => void;
18
15
  setSelectedShape: import("react").Dispatch<import("react").SetStateAction<ShapeEntity | undefined>>;
19
- refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, canvasOffset: Point, currentScale: number) => void;
16
+ refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
20
17
  toggleShapeVisibility: (shape: ShapeEntity) => void;
21
18
  toggleShapeLock: (shape: ShapeEntity) => void;
22
19
  removeShape: (shape: ShapeEntity) => void;