labellife-design-tool 1.1.5 → 1.1.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/README.md CHANGED
@@ -146,7 +146,59 @@ interface CustomPanelDefinition {
146
146
 
147
147
  #### Add Elements from a Custom Panel
148
148
 
149
- **Option 1: Use the `useCanvasStore` hook (recommended)**
149
+ **Option 1: Use standalone store (Polotno-like - recommended)**
150
+
151
+ Create a standalone store that you can use anywhere:
152
+
153
+ ```tsx
154
+ import { createSimpleStore } from 'labellife-design-tool';
155
+
156
+ // Create store instance
157
+ const store = createSimpleStore({
158
+ name: "My Design",
159
+ width: 800,
160
+ height: 600,
161
+ });
162
+
163
+ // Use store anywhere
164
+ store.addPage();
165
+ store.activePage.addElement({
166
+ type: "image",
167
+ src: "https://example.com/img.jpg",
168
+ x: 100,
169
+ y: 100,
170
+ width: 200,
171
+ height: 200,
172
+ });
173
+
174
+ // Load templates
175
+ await store.loadJSON(templateData);
176
+
177
+ // Export to blob
178
+ const pngBlob = await store.toBlob('png');
179
+ const jpgBlob = await store.toBlob('jpg');
180
+
181
+ // Download the blob
182
+ const downloadBlob = (blob: Blob, filename: string) => {
183
+ const url = URL.createObjectURL(blob);
184
+ const a = document.createElement('a');
185
+ a.href = url;
186
+ a.download = filename;
187
+ a.click();
188
+ URL.revokeObjectURL(url);
189
+ };
190
+
191
+ downloadBlob(pngBlob, 'design.png');
192
+ downloadBlob(jpgBlob, 'design.jpg');
193
+
194
+ // Use with CanvasEditor (optional)
195
+ <CanvasEditor name="Editor" config={{ panels: ["text", "elements"] }} />
196
+
197
+ // Export store for use across your app
198
+ export const store = createSimpleStore();
199
+ ```
200
+
201
+ **Option 2: Use the `useCanvasStore` hook (inside CanvasEditor only)**
150
202
 
151
203
  Any component inside `CanvasEditor` can access the store using the hook:
152
204
 
@@ -251,26 +303,42 @@ const MyImagesPanel = ({ store }) => {
251
303
  />
252
304
  ```
253
305
 
254
- **CanvasStore interface**
306
+ **SimpleStore interface (Standalone)**
255
307
 
256
308
  ```typescript
257
- interface CanvasStore {
258
- activePage: {
259
- id: string;
260
- addElement: (element: {
261
- type: string;
262
- src?: string;
263
- x: number;
264
- y: number;
265
- width: number;
266
- height: number;
267
- }) => void;
268
- };
309
+ interface SimpleStore {
310
+ // Design properties
311
+ design: CanvasDesign;
269
312
  width: number;
270
313
  height: number;
271
- openSidePanel: (panelId: string | null) => void;
272
- deletePages: (pageIds: string[]) => void;
273
- loadJSON: (jsonData: any) => Promise<void>;
314
+
315
+ // Page operations
316
+ activePage: Page | null;
317
+ activePageId: string;
318
+ addPage(page?: Partial<Page>): string;
319
+ deletePages(pageIds: string[]): void;
320
+ setActivePage(pageId: string): void;
321
+
322
+ // Element operations
323
+ addElement(element: Partial<CanvasElement>): void;
324
+ updateElement(elementId: string, updates: Partial<CanvasElement>): void;
325
+ deleteElement(elementId: string): void;
326
+
327
+ // Panel operations
328
+ openSidePanel(panelId: string | null): void;
329
+ activePanelId: string | null;
330
+
331
+ // Design operations
332
+ setDesign(design: CanvasDesign): void;
333
+ updateDesign(updates: Partial<CanvasDesign>): void;
334
+ loadJSON(jsonData: any): Promise<void>;
335
+
336
+ // Export operations
337
+ toBlob(type?: 'png' | 'jpg'): Promise<Blob>;
338
+
339
+ // Events
340
+ on(event: 'designChanged' | 'activePageChanged' | 'activePanelChanged', callback: Function): void;
341
+ off(event: string): void;
274
342
  }
275
343
  ```
276
344
 
@@ -217,12 +217,6 @@
217
217
  .inset-0 {
218
218
  inset: calc(var(--spacing) * 0);
219
219
  }
220
- .-top-1 {
221
- top: calc(var(--spacing) * -1);
222
- }
223
- .-right-1 {
224
- right: calc(var(--spacing) * -1);
225
- }
226
220
  .bottom-4 {
227
221
  bottom: calc(var(--spacing) * 4);
228
222
  }
@@ -265,9 +259,6 @@
265
259
  .mt-2 {
266
260
  margin-top: calc(var(--spacing) * 2);
267
261
  }
268
- .mt-4 {
269
- margin-top: calc(var(--spacing) * 4);
270
- }
271
262
  .mt-6 {
272
263
  margin-top: calc(var(--spacing) * 6);
273
264
  }
@@ -331,9 +322,6 @@
331
322
  .h-12 {
332
323
  height: calc(var(--spacing) * 12);
333
324
  }
334
- .h-64 {
335
- height: calc(var(--spacing) * 64);
336
- }
337
325
  .h-full {
338
326
  height: 100%;
339
327
  }
@@ -343,9 +331,6 @@
343
331
  .max-h-32 {
344
332
  max-height: calc(var(--spacing) * 32);
345
333
  }
346
- .max-h-\[80vh\] {
347
- max-height: 80vh;
348
- }
349
334
  .max-h-\[90vh\] {
350
335
  max-height: 90vh;
351
336
  }
@@ -412,9 +397,6 @@
412
397
  .resize {
413
398
  resize: both;
414
399
  }
415
- .resize-none {
416
- resize: none;
417
- }
418
400
  .grid-cols-2 {
419
401
  grid-template-columns: repeat(2, minmax(0, 1fr));
420
402
  }
@@ -439,9 +421,6 @@
439
421
  .justify-center {
440
422
  justify-content: center;
441
423
  }
442
- .justify-end {
443
- justify-content: flex-end;
444
- }
445
424
  .gap-2 {
446
425
  gap: calc(var(--spacing) * 2);
447
426
  }
@@ -505,9 +484,6 @@
505
484
  text-overflow: ellipsis;
506
485
  white-space: nowrap;
507
486
  }
508
- .overflow-auto {
509
- overflow: auto;
510
- }
511
487
  .overflow-hidden {
512
488
  overflow: hidden;
513
489
  }
@@ -599,9 +575,6 @@
599
575
  .bg-green-600 {
600
576
  background-color: var(--color-green-600);
601
577
  }
602
- .bg-red-500 {
603
- background-color: var(--color-red-500);
604
- }
605
578
  .bg-red-700 {
606
579
  background-color: var(--color-red-700);
607
580
  }
@@ -668,9 +641,6 @@
668
641
  .text-right {
669
642
  text-align: right;
670
643
  }
671
- .font-mono {
672
- font-family: var(--font-mono);
673
- }
674
644
  .text-2xl {
675
645
  font-size: var(--text-2xl);
676
646
  line-height: var(--tw-leading, var(--text-2xl--line-height));