labellife-design-tool 1.3.1 → 1.3.3

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.
@@ -547,7 +547,7 @@ function initJsxCompat() {
547
547
  }
548
548
 
549
549
  // src/CanvasEditor.tsx
550
- import React17, { useRef as useRef4, useEffect as useEffect4, useMemo, useCallback as useCallback4 } from "react";
550
+ import React17, { useRef as useRef4, useEffect as useEffect4, useMemo, useCallback as useCallback4, forwardRef, useImperativeHandle } from "react";
551
551
  import { Stage, Layer, Rect as Rect2 } from "react-konva";
552
552
 
553
553
  // src/elements/EditableTextElement.tsx
@@ -2716,16 +2716,16 @@ var RightSidebar = ({
2716
2716
  var RightSidebar_default = RightSidebar;
2717
2717
 
2718
2718
  // src/CanvasEditor.tsx
2719
- var CanvasEditor = ({
2720
- name,
2721
- config,
2722
- store
2723
- }) => {
2719
+ var CanvasEditor = forwardRef(({ name, config, store }, ref) => {
2720
+ if (!store) {
2721
+ console.error("CanvasEditor: store prop is required but was not provided");
2722
+ return /* @__PURE__ */ React17.createElement("div", null, "Error: Store is required");
2723
+ }
2724
2724
  const stageRef = useRef4(null);
2725
2725
  const fileInputRef = useRef4(null);
2726
2726
  const jsonInputRef = useRef4(null);
2727
2727
  const containerRef = useRef4(null);
2728
- const currentPage = store.design.pages.find((p) => p.id === store.activePageId) || store.design.pages[0] || null;
2728
+ const currentPage = store.design?.pages.find((p) => p.id === store.activePageId) || store.design?.pages[0] || null;
2729
2729
  const selectedElement = currentPage?.elements.find((el) => el.id === store.selectedId) || null;
2730
2730
  useEffect4(() => {
2731
2731
  const handleDesignChange = (newDesign) => {};
@@ -2763,25 +2763,25 @@ var CanvasEditor = ({
2763
2763
  }
2764
2764
  }, [store]);
2765
2765
  const addText = useCallback4(() => {
2766
- if (!store.activePage)
2766
+ if (!store?.activePage)
2767
2767
  return;
2768
2768
  store.activePage.addElement({
2769
2769
  type: "text",
2770
2770
  text: "Edit this text",
2771
- x: store.design.width / 2 - 50,
2772
- y: store.design.height / 2 - 15,
2771
+ x: (store.design?.width || 800) / 2 - 50,
2772
+ y: (store.design?.height || 600) / 2 - 15,
2773
2773
  width: 100,
2774
2774
  height: 30
2775
2775
  });
2776
2776
  }, [store]);
2777
2777
  const addShape = useCallback4((shapeType) => {
2778
- if (!store.activePage)
2778
+ if (!store?.activePage)
2779
2779
  return;
2780
2780
  store.activePage.addElement({
2781
2781
  type: "shape",
2782
2782
  shapeType,
2783
- x: store.design.width / 2 - 50,
2784
- y: store.design.height / 2 - 50,
2783
+ x: (store.design?.width || 800) / 2 - 50,
2784
+ y: (store.design?.height || 600) / 2 - 50,
2785
2785
  width: 100,
2786
2786
  height: 100
2787
2787
  });
@@ -2812,15 +2812,45 @@ var CanvasEditor = ({
2812
2812
  }, [selectedElement, store]);
2813
2813
  const moveElementUp = useCallback4((id) => {}, [store]);
2814
2814
  const moveElementDown = useCallback4((id) => {}, [store]);
2815
+ const handleExportPNG = useCallback4(() => {
2816
+ exportToPNG(stageRef.current, store.design);
2817
+ }, [store.design]);
2818
+ const handleExportJPG = useCallback4(() => {
2819
+ exportToJPG(stageRef.current, store.design);
2820
+ }, [store.design]);
2821
+ const handleExportJSON = useCallback4(() => {
2822
+ exportToJSON(store.design);
2823
+ }, [store.design]);
2824
+ const handleImportJSON = useCallback4((e) => {
2825
+ const file = e.target.files?.[0];
2826
+ if (file) {
2827
+ const reader = new FileReader;
2828
+ reader.onload = (event) => {
2829
+ try {
2830
+ const jsonData = JSON.parse(event.target?.result);
2831
+ importFromJSON(jsonData, (loadedDesign) => {
2832
+ store.setDesign(loadedDesign);
2833
+ }, (errorMessage) => {
2834
+ console.error("Import error:", errorMessage);
2835
+ }, () => {
2836
+ console.log("Import requires user inputs - not implemented");
2837
+ });
2838
+ } catch (error) {
2839
+ console.error("Invalid JSON file:", error);
2840
+ }
2841
+ };
2842
+ reader.readAsText(file);
2843
+ }
2844
+ }, [store]);
2815
2845
  const panelConfigs = useMemo(() => {
2816
2846
  const builtInConfigs = {
2817
2847
  elements: { id: "elements", title: "Elements", component: ElementPanel_default, props: { onAddShape: addShape, store } },
2818
2848
  text: { id: "text", title: "Text", component: TextPanel_default, props: { selectedElement, updateElement, onAddText: addText, store } },
2819
2849
  image: { id: "image", title: "Image", component: ImagePanel_default, props: { selectedElement, updateElement, store } },
2820
- background: { id: "background", title: "Background", component: BackgroundPanel_default, props: { store } },
2821
- design: { id: "design", title: "Design", component: DesignPanel_default, props: { store } },
2822
- variables: { id: "variables", title: "Variables", component: VariablesPanel_default, props: { store } },
2823
- export: { id: "export", title: "Export", component: ExportPanel_default, props: { store } }
2850
+ background: { id: "background", title: "Background", component: BackgroundPanel_default, props: { design: store.design, currentPage: currentPage || null, setDesign: (design) => store.setDesign(design), onSetUnsplashBackground: () => {} } },
2851
+ design: { id: "design", title: "Design", component: DesignPanel_default, props: { design: store.design, currentPage: currentPage || null, selectedElement, setDesign: (design) => store.setDesign(design), updateElement, onSetUnsplashBackground: () => {}, config: config || {} } },
2852
+ variables: { id: "variables", title: "Variables", component: VariablesPanel_default, props: { config: config || {}, design: store.design, setDesign: (design) => store.setDesign(design) } },
2853
+ export: { id: "export", title: "Export", component: ExportPanel_default, props: { onExportToPNG: handleExportPNG, onExportToJPG: handleExportJPG, onExportToJSON: handleExportJSON, onImportJSON: handleImportJSON } }
2824
2854
  };
2825
2855
  const mergedConfigs = { ...builtInConfigs };
2826
2856
  if (config?.panels) {
@@ -2852,47 +2882,23 @@ var CanvasEditor = ({
2852
2882
  });
2853
2883
  }
2854
2884
  return orderedConfigs.length > 0 ? orderedConfigs : Object.values(builtInConfigs);
2855
- }, [addShape, addText, config, selectedElement, updateElement, store]);
2885
+ }, [addShape, addText, config, selectedElement, updateElement, store, currentPage, handleExportPNG, handleExportJPG, handleExportJSON, handleImportJSON]);
2856
2886
  const DynamicPanelRenderer = useMemo(() => {
2857
2887
  const activePanel = panelConfigs.find((panel) => panel.id === store.activePanelId);
2858
2888
  if (!activePanel)
2859
- return null;
2889
+ return /* @__PURE__ */ React17.createElement("div", {
2890
+ className: "text-gray-400 text-center p-4"
2891
+ }, "No panel selected");
2860
2892
  const PanelComponent = activePanel.component;
2893
+ if (!PanelComponent)
2894
+ return /* @__PURE__ */ React17.createElement("div", {
2895
+ className: "text-red-400 text-center p-4"
2896
+ }, "Panel component not found");
2861
2897
  return /* @__PURE__ */ React17.createElement(PanelComponent, {
2862
2898
  key: activePanel.id,
2863
2899
  ...activePanel.props
2864
2900
  });
2865
2901
  }, [panelConfigs, store.activePanelId]);
2866
- const handleExportPNG = useCallback4(() => {
2867
- exportToPNG(stageRef.current, store.design);
2868
- }, [store.design]);
2869
- const handleExportJPG = useCallback4(() => {
2870
- exportToJPG(stageRef.current, store.design);
2871
- }, [store.design]);
2872
- const handleExportJSON = useCallback4(() => {
2873
- exportToJSON(store.design);
2874
- }, [store.design]);
2875
- const handleImportJSON = useCallback4((e) => {
2876
- const file = e.target.files?.[0];
2877
- if (file) {
2878
- const reader = new FileReader;
2879
- reader.onload = (event) => {
2880
- try {
2881
- const jsonData = JSON.parse(event.target?.result);
2882
- importFromJSON(jsonData, (loadedDesign) => {
2883
- store.setDesign(loadedDesign);
2884
- }, (errorMessage) => {
2885
- console.error("Import error:", errorMessage);
2886
- }, () => {
2887
- console.log("Import requires user inputs - not implemented");
2888
- });
2889
- } catch (error) {
2890
- console.error("Invalid JSON file:", error);
2891
- }
2892
- };
2893
- reader.readAsText(file);
2894
- }
2895
- }, [store]);
2896
2902
  const handleImageUpload = useCallback4((e) => {
2897
2903
  const file = e.target.files?.[0];
2898
2904
  if (file) {
@@ -2900,12 +2906,12 @@ var CanvasEditor = ({
2900
2906
  reader.onload = (event) => {
2901
2907
  const img = new window.Image;
2902
2908
  img.onload = () => {
2903
- if (store.activePage) {
2909
+ if (store?.activePage) {
2904
2910
  store.activePage.addElement({
2905
2911
  type: "image",
2906
2912
  src: event.target?.result,
2907
- x: store.design.width / 2 - img.width / 2,
2908
- y: store.design.height / 2 - img.height / 2,
2913
+ x: (store.design?.width || 800) / 2 - img.width / 2,
2914
+ y: (store.design?.height || 600) / 2 - img.height / 2,
2909
2915
  width: img.width,
2910
2916
  height: img.height
2911
2917
  });
@@ -2916,6 +2922,31 @@ var CanvasEditor = ({
2916
2922
  reader.readAsDataURL(file);
2917
2923
  }
2918
2924
  }, [store]);
2925
+ useImperativeHandle(ref, () => ({
2926
+ stage: stageRef.current,
2927
+ exportToPNG: () => {
2928
+ Promise.resolve().then(() => exports_exportImportUtils).then(({ exportToPNG: exportToPNG2 }) => {
2929
+ exportToPNG2(stageRef.current, store.design);
2930
+ });
2931
+ },
2932
+ exportToJPG: () => {
2933
+ Promise.resolve().then(() => exports_exportImportUtils).then(({ exportToJPG: exportToJPG2 }) => {
2934
+ exportToJPG2(stageRef.current, store.design);
2935
+ });
2936
+ },
2937
+ exportToJSON: () => {
2938
+ Promise.resolve().then(() => exports_exportImportUtils).then(({ exportToJSON: exportToJSON2 }) => {
2939
+ exportToJSON2(store.design);
2940
+ });
2941
+ },
2942
+ getDesign: () => store.design,
2943
+ setCanvasSize: (width, height) => {
2944
+ store.updateDesign({ width, height });
2945
+ },
2946
+ loadDesign: async (jsonData) => {
2947
+ await store.loadJSON(jsonData);
2948
+ }
2949
+ }), [stageRef.current, store.design]);
2919
2950
  return /* @__PURE__ */ React17.createElement("div", {
2920
2951
  className: "w-full h-full flex flex-col bg-gray-900"
2921
2952
  }, /* @__PURE__ */ React17.createElement(Header_default, {
@@ -2962,15 +2993,15 @@ var CanvasEditor = ({
2962
2993
  }
2963
2994
  }, /* @__PURE__ */ React17.createElement(Stage, {
2964
2995
  ref: stageRef,
2965
- width: store.design.width,
2966
- height: store.design.height,
2996
+ width: store.design?.width || 800,
2997
+ height: store.design?.height || 600,
2967
2998
  onClick: handleStageClick,
2968
2999
  onTap: handleStageClick
2969
3000
  }, /* @__PURE__ */ React17.createElement(Layer, null, /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(Rect2, {
2970
3001
  x: 0,
2971
3002
  y: 0,
2972
- width: store.design.width,
2973
- height: store.design.height,
3003
+ width: store.design?.width || 800,
3004
+ height: store.design?.height || 600,
2974
3005
  fill: currentPage.backgroundImageObject ? undefined : currentPage.background,
2975
3006
  fillPatternImage: currentPage.backgroundImageObject,
2976
3007
  fillPatternRepeat: "no-repeat"
@@ -3014,7 +3045,7 @@ var CanvasEditor = ({
3014
3045
  }
3015
3046
  })))))), config?.multiPage && /* @__PURE__ */ React17.createElement("div", {
3016
3047
  className: "absolute bottom-4 left-4 flex items-center space-x-2"
3017
- }, store.design.pages.map((page, index) => /* @__PURE__ */ React17.createElement("button", {
3048
+ }, (store.design?.pages || []).map((page, index) => /* @__PURE__ */ React17.createElement("button", {
3018
3049
  key: page.id,
3019
3050
  onClick: () => store.setActivePage(page.id),
3020
3051
  className: `px-3 py-1 rounded text-sm ${page.id === store.activePageId ? "bg-blue-600 text-white" : "bg-gray-800 text-gray-300 hover:bg-gray-700"}`
@@ -3041,7 +3072,8 @@ var CanvasEditor = ({
3041
3072
  onChange: handleImportJSON,
3042
3073
  style: { display: "none" }
3043
3074
  }));
3044
- };
3075
+ });
3076
+ CanvasEditor.displayName = "CanvasEditor";
3045
3077
  var CanvasEditor_default = CanvasEditor;
3046
3078
  // src/store/simpleStore.ts
3047
3079
  class SimpleCanvasStore {
@@ -547,7 +547,7 @@ function initJsxCompat() {
547
547
  }
548
548
 
549
549
  // src/CanvasEditor.tsx
550
- import React17, { useRef as useRef4, useEffect as useEffect4, useMemo, useCallback as useCallback4 } from "react";
550
+ import React17, { useRef as useRef4, useEffect as useEffect4, useMemo, useCallback as useCallback4, forwardRef, useImperativeHandle } from "react";
551
551
  import { Stage, Layer, Rect as Rect2 } from "react-konva";
552
552
 
553
553
  // src/elements/EditableTextElement.tsx
@@ -2716,16 +2716,16 @@ var RightSidebar = ({
2716
2716
  var RightSidebar_default = RightSidebar;
2717
2717
 
2718
2718
  // src/CanvasEditor.tsx
2719
- var CanvasEditor = ({
2720
- name,
2721
- config,
2722
- store
2723
- }) => {
2719
+ var CanvasEditor = forwardRef(({ name, config, store }, ref) => {
2720
+ if (!store) {
2721
+ console.error("CanvasEditor: store prop is required but was not provided");
2722
+ return /* @__PURE__ */ React17.createElement("div", null, "Error: Store is required");
2723
+ }
2724
2724
  const stageRef = useRef4(null);
2725
2725
  const fileInputRef = useRef4(null);
2726
2726
  const jsonInputRef = useRef4(null);
2727
2727
  const containerRef = useRef4(null);
2728
- const currentPage = store.design.pages.find((p) => p.id === store.activePageId) || store.design.pages[0] || null;
2728
+ const currentPage = store.design?.pages.find((p) => p.id === store.activePageId) || store.design?.pages[0] || null;
2729
2729
  const selectedElement = currentPage?.elements.find((el) => el.id === store.selectedId) || null;
2730
2730
  useEffect4(() => {
2731
2731
  const handleDesignChange = (newDesign) => {};
@@ -2763,25 +2763,25 @@ var CanvasEditor = ({
2763
2763
  }
2764
2764
  }, [store]);
2765
2765
  const addText = useCallback4(() => {
2766
- if (!store.activePage)
2766
+ if (!store?.activePage)
2767
2767
  return;
2768
2768
  store.activePage.addElement({
2769
2769
  type: "text",
2770
2770
  text: "Edit this text",
2771
- x: store.design.width / 2 - 50,
2772
- y: store.design.height / 2 - 15,
2771
+ x: (store.design?.width || 800) / 2 - 50,
2772
+ y: (store.design?.height || 600) / 2 - 15,
2773
2773
  width: 100,
2774
2774
  height: 30
2775
2775
  });
2776
2776
  }, [store]);
2777
2777
  const addShape = useCallback4((shapeType) => {
2778
- if (!store.activePage)
2778
+ if (!store?.activePage)
2779
2779
  return;
2780
2780
  store.activePage.addElement({
2781
2781
  type: "shape",
2782
2782
  shapeType,
2783
- x: store.design.width / 2 - 50,
2784
- y: store.design.height / 2 - 50,
2783
+ x: (store.design?.width || 800) / 2 - 50,
2784
+ y: (store.design?.height || 600) / 2 - 50,
2785
2785
  width: 100,
2786
2786
  height: 100
2787
2787
  });
@@ -2812,15 +2812,45 @@ var CanvasEditor = ({
2812
2812
  }, [selectedElement, store]);
2813
2813
  const moveElementUp = useCallback4((id) => {}, [store]);
2814
2814
  const moveElementDown = useCallback4((id) => {}, [store]);
2815
+ const handleExportPNG = useCallback4(() => {
2816
+ exportToPNG(stageRef.current, store.design);
2817
+ }, [store.design]);
2818
+ const handleExportJPG = useCallback4(() => {
2819
+ exportToJPG(stageRef.current, store.design);
2820
+ }, [store.design]);
2821
+ const handleExportJSON = useCallback4(() => {
2822
+ exportToJSON(store.design);
2823
+ }, [store.design]);
2824
+ const handleImportJSON = useCallback4((e) => {
2825
+ const file = e.target.files?.[0];
2826
+ if (file) {
2827
+ const reader = new FileReader;
2828
+ reader.onload = (event) => {
2829
+ try {
2830
+ const jsonData = JSON.parse(event.target?.result);
2831
+ importFromJSON(jsonData, (loadedDesign) => {
2832
+ store.setDesign(loadedDesign);
2833
+ }, (errorMessage) => {
2834
+ console.error("Import error:", errorMessage);
2835
+ }, () => {
2836
+ console.log("Import requires user inputs - not implemented");
2837
+ });
2838
+ } catch (error) {
2839
+ console.error("Invalid JSON file:", error);
2840
+ }
2841
+ };
2842
+ reader.readAsText(file);
2843
+ }
2844
+ }, [store]);
2815
2845
  const panelConfigs = useMemo(() => {
2816
2846
  const builtInConfigs = {
2817
2847
  elements: { id: "elements", title: "Elements", component: ElementPanel_default, props: { onAddShape: addShape, store } },
2818
2848
  text: { id: "text", title: "Text", component: TextPanel_default, props: { selectedElement, updateElement, onAddText: addText, store } },
2819
2849
  image: { id: "image", title: "Image", component: ImagePanel_default, props: { selectedElement, updateElement, store } },
2820
- background: { id: "background", title: "Background", component: BackgroundPanel_default, props: { store } },
2821
- design: { id: "design", title: "Design", component: DesignPanel_default, props: { store } },
2822
- variables: { id: "variables", title: "Variables", component: VariablesPanel_default, props: { store } },
2823
- export: { id: "export", title: "Export", component: ExportPanel_default, props: { store } }
2850
+ background: { id: "background", title: "Background", component: BackgroundPanel_default, props: { design: store.design, currentPage: currentPage || null, setDesign: (design) => store.setDesign(design), onSetUnsplashBackground: () => {} } },
2851
+ design: { id: "design", title: "Design", component: DesignPanel_default, props: { design: store.design, currentPage: currentPage || null, selectedElement, setDesign: (design) => store.setDesign(design), updateElement, onSetUnsplashBackground: () => {}, config: config || {} } },
2852
+ variables: { id: "variables", title: "Variables", component: VariablesPanel_default, props: { config: config || {}, design: store.design, setDesign: (design) => store.setDesign(design) } },
2853
+ export: { id: "export", title: "Export", component: ExportPanel_default, props: { onExportToPNG: handleExportPNG, onExportToJPG: handleExportJPG, onExportToJSON: handleExportJSON, onImportJSON: handleImportJSON } }
2824
2854
  };
2825
2855
  const mergedConfigs = { ...builtInConfigs };
2826
2856
  if (config?.panels) {
@@ -2852,47 +2882,23 @@ var CanvasEditor = ({
2852
2882
  });
2853
2883
  }
2854
2884
  return orderedConfigs.length > 0 ? orderedConfigs : Object.values(builtInConfigs);
2855
- }, [addShape, addText, config, selectedElement, updateElement, store]);
2885
+ }, [addShape, addText, config, selectedElement, updateElement, store, currentPage, handleExportPNG, handleExportJPG, handleExportJSON, handleImportJSON]);
2856
2886
  const DynamicPanelRenderer = useMemo(() => {
2857
2887
  const activePanel = panelConfigs.find((panel) => panel.id === store.activePanelId);
2858
2888
  if (!activePanel)
2859
- return null;
2889
+ return /* @__PURE__ */ React17.createElement("div", {
2890
+ className: "text-gray-400 text-center p-4"
2891
+ }, "No panel selected");
2860
2892
  const PanelComponent = activePanel.component;
2893
+ if (!PanelComponent)
2894
+ return /* @__PURE__ */ React17.createElement("div", {
2895
+ className: "text-red-400 text-center p-4"
2896
+ }, "Panel component not found");
2861
2897
  return /* @__PURE__ */ React17.createElement(PanelComponent, {
2862
2898
  key: activePanel.id,
2863
2899
  ...activePanel.props
2864
2900
  });
2865
2901
  }, [panelConfigs, store.activePanelId]);
2866
- const handleExportPNG = useCallback4(() => {
2867
- exportToPNG(stageRef.current, store.design);
2868
- }, [store.design]);
2869
- const handleExportJPG = useCallback4(() => {
2870
- exportToJPG(stageRef.current, store.design);
2871
- }, [store.design]);
2872
- const handleExportJSON = useCallback4(() => {
2873
- exportToJSON(store.design);
2874
- }, [store.design]);
2875
- const handleImportJSON = useCallback4((e) => {
2876
- const file = e.target.files?.[0];
2877
- if (file) {
2878
- const reader = new FileReader;
2879
- reader.onload = (event) => {
2880
- try {
2881
- const jsonData = JSON.parse(event.target?.result);
2882
- importFromJSON(jsonData, (loadedDesign) => {
2883
- store.setDesign(loadedDesign);
2884
- }, (errorMessage) => {
2885
- console.error("Import error:", errorMessage);
2886
- }, () => {
2887
- console.log("Import requires user inputs - not implemented");
2888
- });
2889
- } catch (error) {
2890
- console.error("Invalid JSON file:", error);
2891
- }
2892
- };
2893
- reader.readAsText(file);
2894
- }
2895
- }, [store]);
2896
2902
  const handleImageUpload = useCallback4((e) => {
2897
2903
  const file = e.target.files?.[0];
2898
2904
  if (file) {
@@ -2900,12 +2906,12 @@ var CanvasEditor = ({
2900
2906
  reader.onload = (event) => {
2901
2907
  const img = new window.Image;
2902
2908
  img.onload = () => {
2903
- if (store.activePage) {
2909
+ if (store?.activePage) {
2904
2910
  store.activePage.addElement({
2905
2911
  type: "image",
2906
2912
  src: event.target?.result,
2907
- x: store.design.width / 2 - img.width / 2,
2908
- y: store.design.height / 2 - img.height / 2,
2913
+ x: (store.design?.width || 800) / 2 - img.width / 2,
2914
+ y: (store.design?.height || 600) / 2 - img.height / 2,
2909
2915
  width: img.width,
2910
2916
  height: img.height
2911
2917
  });
@@ -2916,6 +2922,31 @@ var CanvasEditor = ({
2916
2922
  reader.readAsDataURL(file);
2917
2923
  }
2918
2924
  }, [store]);
2925
+ useImperativeHandle(ref, () => ({
2926
+ stage: stageRef.current,
2927
+ exportToPNG: () => {
2928
+ Promise.resolve().then(() => exports_exportImportUtils).then(({ exportToPNG: exportToPNG2 }) => {
2929
+ exportToPNG2(stageRef.current, store.design);
2930
+ });
2931
+ },
2932
+ exportToJPG: () => {
2933
+ Promise.resolve().then(() => exports_exportImportUtils).then(({ exportToJPG: exportToJPG2 }) => {
2934
+ exportToJPG2(stageRef.current, store.design);
2935
+ });
2936
+ },
2937
+ exportToJSON: () => {
2938
+ Promise.resolve().then(() => exports_exportImportUtils).then(({ exportToJSON: exportToJSON2 }) => {
2939
+ exportToJSON2(store.design);
2940
+ });
2941
+ },
2942
+ getDesign: () => store.design,
2943
+ setCanvasSize: (width, height) => {
2944
+ store.updateDesign({ width, height });
2945
+ },
2946
+ loadDesign: async (jsonData) => {
2947
+ await store.loadJSON(jsonData);
2948
+ }
2949
+ }), [stageRef.current, store.design]);
2919
2950
  return /* @__PURE__ */ React17.createElement("div", {
2920
2951
  className: "w-full h-full flex flex-col bg-gray-900"
2921
2952
  }, /* @__PURE__ */ React17.createElement(Header_default, {
@@ -2962,15 +2993,15 @@ var CanvasEditor = ({
2962
2993
  }
2963
2994
  }, /* @__PURE__ */ React17.createElement(Stage, {
2964
2995
  ref: stageRef,
2965
- width: store.design.width,
2966
- height: store.design.height,
2996
+ width: store.design?.width || 800,
2997
+ height: store.design?.height || 600,
2967
2998
  onClick: handleStageClick,
2968
2999
  onTap: handleStageClick
2969
3000
  }, /* @__PURE__ */ React17.createElement(Layer, null, /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(Rect2, {
2970
3001
  x: 0,
2971
3002
  y: 0,
2972
- width: store.design.width,
2973
- height: store.design.height,
3003
+ width: store.design?.width || 800,
3004
+ height: store.design?.height || 600,
2974
3005
  fill: currentPage.backgroundImageObject ? undefined : currentPage.background,
2975
3006
  fillPatternImage: currentPage.backgroundImageObject,
2976
3007
  fillPatternRepeat: "no-repeat"
@@ -3014,7 +3045,7 @@ var CanvasEditor = ({
3014
3045
  }
3015
3046
  })))))), config?.multiPage && /* @__PURE__ */ React17.createElement("div", {
3016
3047
  className: "absolute bottom-4 left-4 flex items-center space-x-2"
3017
- }, store.design.pages.map((page, index) => /* @__PURE__ */ React17.createElement("button", {
3048
+ }, (store.design?.pages || []).map((page, index) => /* @__PURE__ */ React17.createElement("button", {
3018
3049
  key: page.id,
3019
3050
  onClick: () => store.setActivePage(page.id),
3020
3051
  className: `px-3 py-1 rounded text-sm ${page.id === store.activePageId ? "bg-blue-600 text-white" : "bg-gray-800 text-gray-300 hover:bg-gray-700"}`
@@ -3041,7 +3072,8 @@ var CanvasEditor = ({
3041
3072
  onChange: handleImportJSON,
3042
3073
  style: { display: "none" }
3043
3074
  }));
3044
- };
3075
+ });
3076
+ CanvasEditor.displayName = "CanvasEditor";
3045
3077
  var CanvasEditor_default = CanvasEditor;
3046
3078
  // src/store/simpleStore.ts
3047
3079
  class SimpleCanvasStore {
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  import { Config } from "./types/Config";
3
3
  import { SimpleCanvasStore } from "./store/simpleStore";
4
- declare const CanvasEditor: React.FC<{
4
+ import type { CanvasEditorRef } from "./lib/index";
5
+ declare const CanvasEditor: React.ForwardRefExoticComponent<{
5
6
  name: string;
6
7
  config?: Config;
7
8
  store: SimpleCanvasStore;
8
- }>;
9
+ } & React.RefAttributes<CanvasEditorRef>>;
9
10
  export default CanvasEditor;
10
11
  //# sourceMappingURL=CanvasEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasEditor.d.ts","sourceRoot":"","sources":["../../src/CanvasEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmF,MAAM,OAAO,CAAC;AA4ExG,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,CA0cvF,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"CanvasEditor.d.ts","sourceRoot":"","sources":["../../src/CanvasEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmF,MAAM,OAAO,CAAC;AA4ExG,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,QAAA,MAAM,YAAY;UAAuC,MAAM;aAAW,MAAM;WAAS,iBAAiB;yCA+exG,CAAC;AAIH,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labellife-design-tool",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Professional canvas editor built with React, TypeScript, and Konva",
5
5
  "main": "./dist/lib/lib/index.js",
6
6
  "module": "./dist/lib/lib/index.js",