@yorab/react-paint 0.16.1 → 0.16.2

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.
@@ -31,9 +31,11 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
31
31
  } & import("./../../common/types/Shapes").Line & {
32
32
  type: "line";
33
33
  } & {
34
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
35
+ } & {
36
+ type: "line";
34
37
  selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
35
38
  arrows?: import("./../../common/types/Shapes").TriangleEntity[];
36
- type: "line";
37
39
  }) | ({
38
40
  id: string;
39
41
  computed: {
@@ -52,15 +54,16 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
52
54
  } & import("./../../common/types/Shapes").Rect & {
53
55
  src: string;
54
56
  } & {
57
+ type: "picture";
55
58
  img: HTMLImageElement;
56
59
  flipX?: boolean;
57
60
  flipY?: boolean;
58
61
  ratio?: number;
59
- type: "picture";
60
62
  } & {
61
- img: HTMLImageElement;
63
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
64
+ } & {
65
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
62
66
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
63
- type: "picture";
64
67
  }) | ({
65
68
  id: string;
66
69
  computed: {
@@ -80,13 +83,15 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
80
83
  value: string[];
81
84
  fontSize: number;
82
85
  } & {
86
+ type: "text";
83
87
  flipX?: boolean;
84
88
  flipY?: boolean;
85
89
  ratio?: number;
86
- type: "text";
87
90
  } & {
91
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
92
+ } & {
93
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
88
94
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
89
- type: "text";
90
95
  }) | ({
91
96
  id: string;
92
97
  computed: {
@@ -105,8 +110,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
105
110
  } & import("./../../common/types/Shapes").Rect & {
106
111
  type: "rect";
107
112
  } & {
113
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
114
+ } & {
115
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
108
116
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
109
- type: "rect";
110
117
  }) | ({
111
118
  id: string;
112
119
  computed: {
@@ -125,8 +132,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
125
132
  } & import("./../../common/types/Shapes").Rect & {
126
133
  type: "square";
127
134
  } & {
135
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
136
+ } & {
137
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
128
138
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
129
- type: "square";
130
139
  }) | ({
131
140
  id: string;
132
141
  computed: {
@@ -145,8 +154,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
145
154
  } & import("./../../common/types/Shapes").Circle & {
146
155
  type: "circle";
147
156
  } & {
157
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
158
+ } & {
159
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
148
160
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
149
- type: "circle";
150
161
  }) | ({
151
162
  id: string;
152
163
  computed: {
@@ -165,8 +176,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
165
176
  } & import("./../../common/types/Shapes").Ellipse & {
166
177
  type: "ellipse";
167
178
  } & {
179
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
180
+ } & {
181
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
168
182
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
169
- type: "ellipse";
170
183
  }) | ({
171
184
  id: string;
172
185
  computed: {
@@ -185,8 +198,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
185
198
  } & import("./../../common/types/Shapes").Polygon & {
186
199
  type: "polygon";
187
200
  } & {
201
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
202
+ } & {
203
+ type: "polygon" | "curve";
188
204
  selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
189
- type: "polygon";
190
205
  }) | ({
191
206
  id: string;
192
207
  computed: {
@@ -205,8 +220,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
205
220
  } & import("./../../common/types/Shapes").Curve & {
206
221
  type: "curve";
207
222
  } & {
223
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
224
+ } & {
225
+ type: "polygon" | "curve";
208
226
  selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
209
- type: "curve";
210
227
  }) | ({
211
228
  id: string;
212
229
  computed: {
@@ -227,8 +244,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
227
244
  scaleX?: number;
228
245
  scaleY?: number;
229
246
  } & {
247
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
248
+ } & {
249
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
230
250
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
231
- type: "brush";
232
251
  }) | ({
233
252
  id: string;
234
253
  computed: {
@@ -245,9 +264,11 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
245
264
  locked?: boolean;
246
265
  style?: import("./../../common/types/Shapes").StyleShape | undefined;
247
266
  } & import("./../../common/types/Shapes").Rect & {
248
- shapes: ShapeEntity[];
249
267
  type: "group";
268
+ shapes: ShapeEntity[];
269
+ } & {
270
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
250
271
  } & {
272
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
251
273
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
252
- type: "group";
253
274
  }))[]>;
@@ -10,7 +10,7 @@ export declare const getComputedRect: (rect: DrawableShape<rectish>, settings: U
10
10
  center: Point;
11
11
  boundingBox: Rect;
12
12
  };
13
- export declare const refreshRect: <T extends rectish>(rect: DrawableShape<T> & {
13
+ export declare const refreshRect: <T extends rectish>(rect: DrawableShape<rectish> & {
14
14
  id: string;
15
15
  }, settings: UtilsSettings) => ShapeEntity<T>;
16
16
  export declare const createRectangle: <T extends rectish>(shape: {
@@ -49,6 +49,7 @@ export type StyleShape = {
49
49
  lineWidth?: number;
50
50
  lineDash?: number;
51
51
  lineArrow?: number;
52
+ lineCap?: CanvasLineCap;
52
53
  closedPoints?: number;
53
54
  fontFamily?: string;
54
55
  fontItalic?: boolean;
@@ -65,47 +66,50 @@ export type SelectionLinesType = {
65
66
  shapePath: Path2D | undefined;
66
67
  anchors: Path2D[];
67
68
  };
68
- export type DrawableShape<T extends ShapeType = ShapeType> = {
69
+ type GenericDrawableShape = {
69
70
  rotation?: number;
70
71
  toolId?: string;
71
72
  visible?: boolean;
72
73
  locked?: boolean;
73
74
  style?: StyleShape | undefined;
74
- } & (T extends 'line' ? Line & {
75
+ } & ((Line & {
75
76
  type: 'line';
76
- } : T extends 'picture' ? Picture & {
77
+ }) | (Picture & {
78
+ type: 'picture';
77
79
  img: HTMLImageElement;
78
80
  flipX?: boolean;
79
81
  flipY?: boolean;
80
82
  ratio?: number;
81
- type: 'picture';
82
- } : T extends 'text' ? Text & {
83
+ }) | (Text & {
84
+ type: 'text';
83
85
  flipX?: boolean;
84
86
  flipY?: boolean;
85
87
  ratio?: number;
86
- type: 'text';
87
- } : T extends 'rect' ? Rect & {
88
+ }) | (Rect & {
88
89
  type: 'rect';
89
- } : T extends 'square' ? Rect & {
90
+ }) | (Rect & {
90
91
  type: 'square';
91
- } : T extends 'circle' ? Circle & {
92
+ }) | (Circle & {
92
93
  type: 'circle';
93
- } : T extends 'ellipse' ? Ellipse & {
94
+ }) | (Ellipse & {
94
95
  type: 'ellipse';
95
- } : T extends 'triangle' ? Triangle & {
96
+ }) | (Triangle & {
96
97
  type: 'triangle';
97
- } : T extends 'polygon' ? Polygon & {
98
+ }) | (Polygon & {
98
99
  type: 'polygon';
99
- } : T extends 'curve' ? Curve & {
100
+ }) | (Curve & {
100
101
  type: 'curve';
101
- } : T extends 'brush' ? Brush & {
102
+ }) | (Brush & {
102
103
  type: 'brush';
103
104
  scaleX?: number;
104
105
  scaleY?: number;
105
- } : T extends 'group' ? Rect & {
106
- shapes: ShapeEntity[];
106
+ }) | (Rect & {
107
107
  type: 'group';
108
- } : never);
108
+ shapes: ShapeEntity[];
109
+ }));
110
+ export type DrawableShape<T extends ShapeType = ShapeType> = GenericDrawableShape & {
111
+ type: T;
112
+ };
109
113
  export type ExportedDrawableShape<T extends ShapeType = ShapeType> = T extends 'picture' ? Omit<DrawableShape<'picture'>, 'img'> : DrawableShape<T>;
110
114
  export type TriangleEntity = DrawableShape<'triangle'> & {
111
115
  path: Path2D;
@@ -125,42 +129,17 @@ export type ShapeEntity<T extends Exclude<ShapeType, 'triangle'> = Exclude<Shape
125
129
  boundingBox: Rect;
126
130
  };
127
131
  path?: Path2D | undefined;
128
- } & DrawableShape<T> & (T extends 'line' ? {
129
- selection?: SelectionLinesType | undefined;
130
- arrows?: TriangleEntity[];
132
+ } & DrawableShape<T> & ({
131
133
  type: 'line';
132
- } : T extends 'picture' ? {
133
- img: HTMLImageElement;
134
- selection?: SelectionDefaultType | undefined;
135
- type: 'picture';
136
- } : T extends 'text' ? {
137
- selection?: SelectionDefaultType | undefined;
138
- type: 'text';
139
- } : T extends 'rect' ? {
140
- selection?: SelectionDefaultType | undefined;
141
- type: 'rect';
142
- } : T extends 'square' ? {
143
- selection?: SelectionDefaultType | undefined;
144
- type: 'square';
145
- } : T extends 'circle' ? {
146
- selection?: SelectionDefaultType | undefined;
147
- type: 'circle';
148
- } : T extends 'ellipse' ? {
149
- selection?: SelectionDefaultType | undefined;
150
- type: 'ellipse';
151
- } : T extends 'polygon' ? {
152
134
  selection?: SelectionLinesType | undefined;
153
- type: 'polygon';
154
- } : T extends 'curve' ? {
135
+ arrows?: TriangleEntity[];
136
+ } | {
137
+ type: 'polygon' | 'curve';
155
138
  selection?: SelectionLinesType | undefined;
156
- type: 'curve';
157
- } : T extends 'brush' ? {
139
+ } | {
140
+ type: 'text' | 'picture' | 'rect' | 'square' | 'circle' | 'ellipse' | 'group' | 'brush';
158
141
  selection?: SelectionDefaultType | undefined;
159
- type: 'brush';
160
- } : T extends 'group' ? {
161
- selection?: SelectionDefaultType | undefined;
162
- type: 'group';
163
- } : never);
142
+ });
164
143
  export type StateData = {
165
144
  shapes?: DrawableShape[];
166
145
  config?: {
@@ -169,3 +148,4 @@ export type StateData = {
169
148
  };
170
149
  };
171
150
  export type SelectionType = ShapeEntity;
151
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorab/react-paint",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "type": "module",
5
5
  "keywords": [],
6
6
  "author": "Yohann Rabatel",
@@ -23,26 +23,26 @@
23
23
  "dist/"
24
24
  ],
25
25
  "devDependencies": {
26
- "@biomejs/biome": "2.3.13",
26
+ "@biomejs/biome": "2.4.3",
27
27
  "@rollup/plugin-terser": "0.4.4",
28
- "@storybook/addon-docs": "10.2.3",
29
- "@storybook/addon-links": "10.2.3",
30
- "@storybook/addon-vitest": "10.2.3",
31
- "@storybook/react-vite": "10.2.3",
32
- "@types/node": "25.2.0",
33
- "@types/react": "19.2.10",
28
+ "@storybook/addon-docs": "10.2.10",
29
+ "@storybook/addon-links": "10.2.10",
30
+ "@storybook/addon-vitest": "10.2.10",
31
+ "@storybook/react-vite": "10.2.10",
32
+ "@types/node": "25.3.0",
33
+ "@types/react": "19.2.14",
34
34
  "@types/react-dom": "19.2.3",
35
- "@vitejs/plugin-react": "5.1.3",
36
- "jsdom": "28.0.0",
35
+ "@vitejs/plugin-react": "5.1.4",
36
+ "jsdom": "28.1.0",
37
37
  "lightningcss": "1.31.1",
38
38
  "react": "18.3.1",
39
39
  "react-dom": "18.3.1",
40
- "storybook": "10.2.3",
40
+ "storybook": "10.2.10",
41
41
  "typescript": "5.9.3",
42
42
  "vite": "7.3.1",
43
- "vite-tsconfig-paths": "6.0.5",
43
+ "vite-tsconfig-paths": "6.1.1",
44
44
  "vitest": "4.0.18",
45
- "playwright": "1.58.1",
45
+ "playwright": "1.58.2",
46
46
  "@vitest/browser-playwright": "4.0.18",
47
47
  "@vitest/coverage-v8": "4.0.18"
48
48
  },