zuljaman-banner-components 1.0.6 → 1.0.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.
Files changed (98) hide show
  1. package/dist/components/BannerRenderer.d.ts +48 -0
  2. package/dist/components/BannerRenderer.d.ts.map +1 -0
  3. package/dist/components/BannerRenderer.js +449 -0
  4. package/dist/components/BannerVisor.d.ts.map +1 -1
  5. package/dist/components/BannerVisor.js +132 -18
  6. package/dist/components/index.d.ts +1 -2
  7. package/dist/components/index.d.ts.map +1 -1
  8. package/dist/components/index.js +4 -2
  9. package/dist/components/shared/DraggableElement.d.ts +31 -0
  10. package/dist/components/shared/DraggableElement.d.ts.map +1 -0
  11. package/dist/components/shared/DraggableElement.js +367 -0
  12. package/dist/components/shared/index.d.ts +7 -0
  13. package/dist/components/shared/index.d.ts.map +1 -0
  14. package/dist/components/shared/index.js +9 -0
  15. package/dist/components/styles/Style1/substyleConfig.d.ts +20 -0
  16. package/dist/components/styles/Style1/substyleConfig.d.ts.map +1 -0
  17. package/dist/components/styles/Style1/substyleConfig.js +105 -0
  18. package/dist/components/styles/Style2/substyleConfig.d.ts +20 -0
  19. package/dist/components/styles/Style2/substyleConfig.d.ts.map +1 -0
  20. package/dist/components/styles/Style2/substyleConfig.js +133 -0
  21. package/dist/components/styles/Style3/substyleConfig.d.ts +20 -0
  22. package/dist/components/styles/Style3/substyleConfig.d.ts.map +1 -0
  23. package/dist/components/styles/Style3/substyleConfig.js +91 -0
  24. package/dist/components/styles/Style4/substyleConfig.d.ts +20 -0
  25. package/dist/components/styles/Style4/substyleConfig.d.ts.map +1 -0
  26. package/dist/components/styles/Style4/substyleConfig.js +112 -0
  27. package/dist/components/styles/types/substyleTypes.d.ts +68 -0
  28. package/dist/components/styles/types/substyleTypes.d.ts.map +1 -0
  29. package/dist/components/styles/types/substyleTypes.js +6 -0
  30. package/dist/components/styles/utils/calculations.d.ts +47 -0
  31. package/dist/components/styles/utils/calculations.d.ts.map +1 -0
  32. package/dist/components/styles/utils/calculations.js +69 -0
  33. package/dist/components/styles/utils/defaultsUtils.d.ts +54 -0
  34. package/dist/components/styles/utils/defaultsUtils.d.ts.map +1 -0
  35. package/dist/components/styles/utils/defaultsUtils.js +83 -0
  36. package/dist/components/styles/utils/fontSizeUtils.d.ts +32 -0
  37. package/dist/components/styles/utils/fontSizeUtils.d.ts.map +1 -0
  38. package/dist/components/styles/utils/fontSizeUtils.js +52 -0
  39. package/dist/components/styles/utils/positioningUtils.d.ts +38 -0
  40. package/dist/components/styles/utils/positioningUtils.d.ts.map +1 -0
  41. package/dist/components/styles/utils/positioningUtils.js +79 -0
  42. package/dist/components/styles/utils/substyleUtils.d.ts +14 -0
  43. package/dist/components/styles/utils/substyleUtils.d.ts.map +1 -0
  44. package/dist/components/styles/utils/substyleUtils.js +18 -0
  45. package/dist/components/styles/utils/transformUtils.d.ts +36 -0
  46. package/dist/components/styles/utils/transformUtils.d.ts.map +1 -0
  47. package/dist/components/styles/utils/transformUtils.js +53 -0
  48. package/dist/constants/characterLimits.d.ts +97 -0
  49. package/dist/constants/characterLimits.d.ts.map +1 -0
  50. package/dist/constants/characterLimits.js +144 -0
  51. package/dist/constants/defaults.d.ts +19 -0
  52. package/dist/constants/defaults.d.ts.map +1 -0
  53. package/dist/constants/defaults.js +27 -0
  54. package/dist/constants/index.d.ts +2 -0
  55. package/dist/constants/index.d.ts.map +1 -1
  56. package/dist/constants/index.js +2 -0
  57. package/dist/constants/styleConfigs.d.ts.map +1 -1
  58. package/dist/constants/styleConfigs.js +13 -7
  59. package/dist/index.d.ts +8 -0
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +12 -0
  62. package/dist/styleConfig.d.ts +40 -0
  63. package/dist/styleConfig.d.ts.map +1 -0
  64. package/dist/styleConfig.js +115 -0
  65. package/dist/styles/shadowUtils.js +4 -4
  66. package/dist/types.d.ts +149 -1
  67. package/dist/types.d.ts.map +1 -1
  68. package/package.json +10 -9
  69. package/dist/components/Style1/BannerStyle1.d.ts +0 -19
  70. package/dist/components/Style1/BannerStyle1.d.ts.map +0 -1
  71. package/dist/components/Style1/BannerStyle1.js +0 -27
  72. package/dist/components/Style1/substyles/BannerSubstyle1.d.ts +0 -12
  73. package/dist/components/Style1/substyles/BannerSubstyle1.d.ts.map +0 -1
  74. package/dist/components/Style1/substyles/BannerSubstyle1.js +0 -52
  75. package/dist/components/Style1/substyles/BannerSubstyle2.d.ts +0 -12
  76. package/dist/components/Style1/substyles/BannerSubstyle2.d.ts.map +0 -1
  77. package/dist/components/Style1/substyles/BannerSubstyle2.js +0 -52
  78. package/dist/components/Style1/substyles/BannerSubstyle3.d.ts +0 -12
  79. package/dist/components/Style1/substyles/BannerSubstyle3.d.ts.map +0 -1
  80. package/dist/components/Style1/substyles/BannerSubstyle3.js +0 -61
  81. package/dist/components/Style1/substyles/index.d.ts +0 -7
  82. package/dist/components/Style1/substyles/index.d.ts.map +0 -1
  83. package/dist/components/Style1/substyles/index.js +0 -22
  84. package/dist/components/Style2/BannerStyle2.d.ts +0 -19
  85. package/dist/components/Style2/BannerStyle2.d.ts.map +0 -1
  86. package/dist/components/Style2/BannerStyle2.js +0 -32
  87. package/dist/components/Style2/substyles/BannerSubstyle1.d.ts +0 -12
  88. package/dist/components/Style2/substyles/BannerSubstyle1.d.ts.map +0 -1
  89. package/dist/components/Style2/substyles/BannerSubstyle1.js +0 -35
  90. package/dist/components/Style2/substyles/BannerSubstyle2.d.ts +0 -12
  91. package/dist/components/Style2/substyles/BannerSubstyle2.d.ts.map +0 -1
  92. package/dist/components/Style2/substyles/BannerSubstyle2.js +0 -35
  93. package/dist/components/Style2/substyles/BannerSubstyle3.d.ts +0 -12
  94. package/dist/components/Style2/substyles/BannerSubstyle3.d.ts.map +0 -1
  95. package/dist/components/Style2/substyles/BannerSubstyle3.js +0 -35
  96. package/dist/components/Style2/substyles/index.d.ts +0 -7
  97. package/dist/components/Style2/substyles/index.d.ts.map +0 -1
  98. package/dist/components/Style2/substyles/index.js +0 -22
@@ -13,43 +13,157 @@ const jsx_runtime_1 = require("react/jsx-runtime");
13
13
  const react_1 = require("react");
14
14
  const clsx_1 = __importDefault(require("clsx"));
15
15
  const constants_1 = require("../constants");
16
- // Import style components (will be created next)
17
- const BannerStyle1_1 = require("./Style1/BannerStyle1");
18
- const BannerStyle2_1 = require("./Style2/BannerStyle2");
16
+ const styleConfig_1 = require("../styleConfig");
17
+ // Import generic renderer
18
+ const BannerRenderer_1 = require("./BannerRenderer");
19
19
  const NoImageComponent = () => {
20
20
  return ((0, jsx_runtime_1.jsx)("div", { className: "w-full grow flex items-center justify-center text-neutral-500", children: (0, jsx_runtime_1.jsx)("p", { children: "No image selected" }) }));
21
21
  };
22
- const BannerVisor = ({ bannerStyle = 1, // Default to style 1 if undefined
23
- backgroundImageUrl, copy1, copy2, bannerSubstyle, logoUrl, postType, sizeMultiplier: externalSizeMultiplier, ImageComponent, }) => {
22
+ const BannerVisor = ({ backgroundImageUrl, copies, copy1, copy2, bannerStyle = 1, bannerSubstyle, bannerSubSubstyle: _bannerSubSubstyle, logoUrl, postType, sizeMultiplier: externalSizeMultiplier, fontSizeMultiplier = 1.0, copy1FontSizeMultiplier, copy2FontSizeMultiplier, logoSizeMultiplier = 1.0, overlayIntensityMultiplier = 1.0, shadowIntensityMultiplier = 1.0, ImageComponent, logoTranslateX = 0, logoTranslateY = 0, copy1TranslateX = 0, copy1TranslateY = 0, copy2TranslateX = 0, copy2TranslateY = 0, draggableMode = false, onLogoPositionChange, onCopyPositionChange, onCopy1PositionChange, onCopy2PositionChange, onLogoRotationChange, onCopyRotationChange, onCopy1RotationChange, onCopy2RotationChange, logoRotation = 0, copy1Rotation = 0, copy2Rotation = 0, logoWidth, copy1Width, copy2Width, onLogoWidthChange, onCopyWidthChange, onCopy1WidthChange, onCopy2WidthChange, copy1Align = 'left', copy2Align = 'center', copy1FontWeight = 'normal', copy2FontWeight = 'normal', textShadowEnabled, textShadowSize, textShadowIntensity, logoShadowEnabled, logoShadowSize, logoShadowIntensity, noiseEnabled, noiseIntensity, fontFamily, }) => {
23
+ var _a;
24
24
  const [internalSizeMultiplier, setInternalSizeMultiplier] = (0, react_1.useState)(1);
25
25
  const containerRef = (0, react_1.useRef)(null);
26
+ // Get style configuration for centralized settings
27
+ const styleConfig = (0, styleConfig_1.getStyleConfig)(bannerStyle);
26
28
  // Use external size multiplier if provided, otherwise use internal
27
29
  const sizeMultiplier = externalSizeMultiplier !== null && externalSizeMultiplier !== void 0 ? externalSizeMultiplier : internalSizeMultiplier;
28
- const bannerContentProps = {
30
+ // Use individual font size multipliers if provided, otherwise fall back to fontSizeMultiplier
31
+ const effectiveCopy1FontSize = copy1FontSizeMultiplier !== null && copy1FontSizeMultiplier !== void 0 ? copy1FontSizeMultiplier : fontSizeMultiplier;
32
+ const effectiveCopy2FontSize = copy2FontSizeMultiplier !== null && copy2FontSizeMultiplier !== void 0 ? copy2FontSizeMultiplier : fontSizeMultiplier;
33
+ // Use noiseEnabled from styleConfig if not provided as prop (centralized configuration)
34
+ const effectiveNoiseEnabled = (_a = noiseEnabled !== null && noiseEnabled !== void 0 ? noiseEnabled : styleConfig.noiseEnabled) !== null && _a !== void 0 ? _a : true;
35
+ // Convert legacy props to copies array for backward compatibility
36
+ const effectiveCopies = (0, react_1.useMemo)(() => {
37
+ if (copies && copies.length > 0) {
38
+ // Use new copies array
39
+ return copies;
40
+ }
41
+ // Convert legacy props to copies array
42
+ const legacyCopies = [];
43
+ if (copy1) {
44
+ legacyCopies.push({
45
+ id: `legacy-copy1-${Date.now()}`,
46
+ styleSlot: 0, // Legacy copy1 gets styleSlot 0
47
+ text: copy1,
48
+ fontSize: effectiveCopy1FontSize,
49
+ align: copy1Align,
50
+ fontWeight: copy1FontWeight,
51
+ translateX: copy1TranslateX,
52
+ translateY: copy1TranslateY,
53
+ rotation: copy1Rotation,
54
+ width: copy1Width,
55
+ });
56
+ }
57
+ if (copy2) {
58
+ legacyCopies.push({
59
+ id: `legacy-copy2-${Date.now()}`,
60
+ styleSlot: 1, // Legacy copy2 gets styleSlot 1
61
+ text: copy2,
62
+ fontSize: effectiveCopy2FontSize,
63
+ align: copy2Align,
64
+ fontWeight: copy2FontWeight,
65
+ translateX: copy2TranslateX,
66
+ translateY: copy2TranslateY,
67
+ rotation: copy2Rotation,
68
+ width: copy2Width,
69
+ });
70
+ }
71
+ return legacyCopies;
72
+ }, [
73
+ copies,
29
74
  copy1,
30
75
  copy2,
76
+ effectiveCopy1FontSize,
77
+ effectiveCopy2FontSize,
78
+ copy1Align,
79
+ copy2Align,
80
+ copy1FontWeight,
81
+ copy2FontWeight,
82
+ copy1TranslateX,
83
+ copy1TranslateY,
84
+ copy2TranslateX,
85
+ copy2TranslateY,
86
+ copy1Rotation,
87
+ copy2Rotation,
88
+ copy1Width,
89
+ copy2Width,
90
+ ]);
91
+ // Wrapper functions for legacy callbacks
92
+ const handleCopyPositionChange = (copyIndex, position) => {
93
+ if (onCopyPositionChange) {
94
+ onCopyPositionChange(copyIndex, position);
95
+ }
96
+ // Also call legacy callbacks for backward compatibility
97
+ if (copyIndex === 0 && onCopy1PositionChange) {
98
+ onCopy1PositionChange(position);
99
+ }
100
+ if (copyIndex === 1 && onCopy2PositionChange) {
101
+ onCopy2PositionChange(position);
102
+ }
103
+ };
104
+ const handleCopyRotationChange = (copyIndex, rotation) => {
105
+ if (onCopyRotationChange) {
106
+ onCopyRotationChange(copyIndex, rotation);
107
+ }
108
+ // Also call legacy callbacks for backward compatibility
109
+ if (copyIndex === 0 && onCopy1RotationChange) {
110
+ onCopy1RotationChange(rotation);
111
+ }
112
+ if (copyIndex === 1 && onCopy2RotationChange) {
113
+ onCopy2RotationChange(rotation);
114
+ }
115
+ };
116
+ const handleCopyWidthChange = (copyIndex, width) => {
117
+ if (onCopyWidthChange) {
118
+ onCopyWidthChange(copyIndex, width);
119
+ }
120
+ // Also call legacy callbacks for backward compatibility
121
+ if (copyIndex === 0 && onCopy1WidthChange) {
122
+ onCopy1WidthChange(width);
123
+ }
124
+ if (copyIndex === 1 && onCopy2WidthChange) {
125
+ onCopy2WidthChange(width);
126
+ }
127
+ };
128
+ const bannerContentProps = {
129
+ copies: effectiveCopies,
31
130
  bannerSubstyle,
32
131
  logoUrl,
33
132
  backgroundImageUrl,
34
133
  sizeMultiplier,
134
+ logoSizeMultiplier,
135
+ overlayIntensityMultiplier,
136
+ shadowIntensityMultiplier,
35
137
  postType,
36
138
  ImageComponent,
139
+ logoTranslateX,
140
+ logoTranslateY,
141
+ draggableMode,
142
+ onLogoPositionChange,
143
+ onCopyPositionChange: handleCopyPositionChange,
144
+ onCopyRotationChange: handleCopyRotationChange,
145
+ onCopyWidthChange: handleCopyWidthChange,
146
+ logoRotation,
147
+ logoWidth,
148
+ onLogoRotationChange,
149
+ onLogoWidthChange,
150
+ textShadowEnabled,
151
+ textShadowSize,
152
+ textShadowIntensity,
153
+ logoShadowEnabled,
154
+ logoShadowSize,
155
+ logoShadowIntensity,
156
+ noiseEnabled: effectiveNoiseEnabled,
157
+ noiseIntensity,
158
+ fontFamily,
37
159
  };
38
- const hasBannerContent = copy1 || copy2 || logoUrl;
160
+ const hasBannerContent = effectiveCopies.length > 0 || logoUrl;
39
161
  const renderBannerStyle = () => {
40
162
  if (!hasBannerContent)
41
163
  return null;
42
- // Determine the style ID, defaulting to 1 if null or invalid
43
- const effectiveBannerStyle = bannerStyle === null ? 1 : bannerStyle;
44
- switch (effectiveBannerStyle) {
45
- case 1:
46
- return (0, jsx_runtime_1.jsx)(BannerStyle1_1.BannerStyle1, { ...bannerContentProps });
47
- case 2:
48
- return (0, jsx_runtime_1.jsx)(BannerStyle2_1.BannerStyle2, { ...bannerContentProps });
49
- default:
50
- // Default to BannerStyle1
51
- return (0, jsx_runtime_1.jsx)(BannerStyle1_1.BannerStyle1, { ...bannerContentProps });
52
- }
164
+ // Render the generic BannerRenderer with bannerStyle prop
165
+ // bannerSubstyle determines which substyle (0 for logo only, 1-3 for different layouts)
166
+ return (0, jsx_runtime_1.jsx)(BannerRenderer_1.BannerRenderer, { ...bannerContentProps, bannerStyle: bannerStyle });
53
167
  };
54
168
  (0, react_1.useEffect)(() => {
55
169
  // Only use internal size calculation if no external multiplier is provided
@@ -2,6 +2,5 @@
2
2
  * Banner components exports
3
3
  */
4
4
  export * from './BannerVisor';
5
- export * from './Style1/BannerStyle1';
6
- export * from './Style2/BannerStyle2';
5
+ export * from './BannerRenderer';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
@@ -18,5 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./BannerVisor"), exports);
21
- __exportStar(require("./Style1/BannerStyle1"), exports);
22
- __exportStar(require("./Style2/BannerStyle2"), exports);
21
+ __exportStar(require("./BannerRenderer"), exports);
22
+ // Note: BannerRenderer is a generic component that handles all banner styles
23
+ // Use bannerStyle prop (1, 2, 3, etc.) to select the style
24
+ // Use bannerSubstyle prop (0 for logo only, 1, 2, or 3) to select the substyle
@@ -0,0 +1,31 @@
1
+ /**
2
+ * DraggableElement - Reusable component for draggable/rotatable/resizable elements
3
+ * Used across all banner styles to provide consistent interaction behavior
4
+ */
5
+ import React from "react";
6
+ export interface DraggableElementProps {
7
+ enabled: boolean;
8
+ position: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ rotation: number;
13
+ width?: number;
14
+ scale: number;
15
+ elementId: string;
16
+ isSelected: boolean;
17
+ onPositionChange?: (pos: {
18
+ x: number;
19
+ y: number;
20
+ }) => void;
21
+ onRotationChange?: (rotation: number) => void;
22
+ onWidthChange?: (width: number) => void;
23
+ onSelect: (id: string) => void;
24
+ onDeselect: () => void;
25
+ onRotationSnap?: (angle: number) => number;
26
+ onDragMove?: (elementId: string, bounds: DOMRect) => void;
27
+ centerOrigin?: boolean;
28
+ children: React.ReactNode;
29
+ }
30
+ export declare const DraggableElement: React.FC<DraggableElementProps>;
31
+ //# sourceMappingURL=DraggableElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DraggableElement.d.ts","sourceRoot":"","sources":["../../../src/components/shared/DraggableElement.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IAGpB,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3D,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,IAAI,CAAC;IAGvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAG1D,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqf5D,CAAC"}
@@ -0,0 +1,367 @@
1
+ "use strict";
2
+ /**
3
+ * DraggableElement - Reusable component for draggable/rotatable/resizable elements
4
+ * Used across all banner styles to provide consistent interaction behavior
5
+ */
6
+ "use client";
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.DraggableElement = void 0;
12
+ const jsx_runtime_1 = require("react/jsx-runtime");
13
+ const react_1 = __importDefault(require("react"));
14
+ const react_draggable_1 = __importDefault(require("react-draggable"));
15
+ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId, isSelected, onPositionChange, onRotationChange, onWidthChange, onSelect, onDeselect, onRotationSnap, onDragMove, centerOrigin = false, children, }) => {
16
+ const [isDragging, setIsDragging] = react_1.default.useState(false);
17
+ const [isRotating, setIsRotating] = react_1.default.useState(false);
18
+ const [isResizing, setIsResizing] = react_1.default.useState(false);
19
+ const [resizeSide, setResizeSide] = react_1.default.useState(null);
20
+ const elementRef = react_1.default.useRef(null);
21
+ const rotatingContentRef = react_1.default.useRef(null);
22
+ const contentOnlyRef = react_1.default.useRef(null);
23
+ const blueHandleRef = react_1.default.useRef(null);
24
+ const purpleIndicatorRef = react_1.default.useRef(null);
25
+ const startAngleRef = react_1.default.useRef(0);
26
+ const currentRotationRef = react_1.default.useRef(rotation);
27
+ const hasDraggedRef = react_1.default.useRef(false);
28
+ const startWidthRef = react_1.default.useRef(0);
29
+ const startMouseXRef = react_1.default.useRef(0);
30
+ const startMouseYRef = react_1.default.useRef(0);
31
+ const startPositionRef = react_1.default.useRef({ x: 0, y: 0 });
32
+ const mouseDownPosRef = react_1.default.useRef(null);
33
+ const justSelectedRef = react_1.default.useRef(false);
34
+ const justStoppedWithoutDragRef = react_1.default.useRef(false);
35
+ react_1.default.useEffect(() => {
36
+ currentRotationRef.current = rotation;
37
+ }, [rotation]);
38
+ if (!enabled) {
39
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
40
+ }
41
+ // Rotation handlers
42
+ const handleRotationStart = (e) => {
43
+ e.preventDefault();
44
+ e.stopPropagation();
45
+ if (!contentOnlyRef.current)
46
+ return;
47
+ // Use contentOnlyRef to get the actual content center, not the bounding box with handles
48
+ const rect = contentOnlyRef.current.getBoundingClientRect();
49
+ const centerX = rect.left + rect.width / 2;
50
+ const centerY = rect.top + rect.height / 2;
51
+ const angle = Math.atan2(e.clientY - centerY, e.clientX - centerX) * (180 / Math.PI);
52
+ startAngleRef.current = angle - currentRotationRef.current;
53
+ setIsRotating(true);
54
+ };
55
+ const handleRotationMove = (e) => {
56
+ if (!isRotating || !contentOnlyRef.current)
57
+ return;
58
+ // Use contentOnlyRef for consistent center calculation regardless of rotation
59
+ const rect = contentOnlyRef.current.getBoundingClientRect();
60
+ const centerX = rect.left + rect.width / 2;
61
+ const centerY = rect.top + rect.height / 2;
62
+ const angle = Math.atan2(e.clientY - centerY, e.clientX - centerX) * (180 / Math.PI);
63
+ let newRotation = angle - startAngleRef.current;
64
+ // Apply snap callback if provided
65
+ if (onRotationSnap) {
66
+ newRotation = onRotationSnap(newRotation);
67
+ }
68
+ onRotationChange === null || onRotationChange === void 0 ? void 0 : onRotationChange(Math.round(newRotation));
69
+ };
70
+ const handleRotationEnd = () => {
71
+ setIsRotating(false);
72
+ hasDraggedRef.current = true;
73
+ };
74
+ react_1.default.useEffect(() => {
75
+ if (isRotating) {
76
+ window.addEventListener('mousemove', handleRotationMove);
77
+ window.addEventListener('mouseup', handleRotationEnd);
78
+ return () => {
79
+ window.removeEventListener('mousemove', handleRotationMove);
80
+ window.removeEventListener('mouseup', handleRotationEnd);
81
+ };
82
+ }
83
+ }, [isRotating]);
84
+ // Width resize handlers
85
+ const handleResizeStart = (e, side) => {
86
+ e.preventDefault();
87
+ e.stopPropagation();
88
+ if (!contentOnlyRef.current)
89
+ return;
90
+ const currentWidth = contentOnlyRef.current.offsetWidth;
91
+ startWidthRef.current = currentWidth;
92
+ startMouseXRef.current = e.clientX;
93
+ startMouseYRef.current = e.clientY;
94
+ startPositionRef.current = { x: position.x, y: position.y };
95
+ setResizeSide(side);
96
+ setIsResizing(true);
97
+ };
98
+ const handleResizeMove = (e) => {
99
+ if (!isResizing || !resizeSide)
100
+ return;
101
+ // Calculate mouse delta in viewport coordinates
102
+ const mouseDeltaX = e.clientX - startMouseXRef.current;
103
+ const mouseDeltaY = e.clientY - startMouseYRef.current;
104
+ // Convert rotation to radians
105
+ const rotationRad = (currentRotationRef.current * Math.PI) / 180;
106
+ // Project mouse movement onto the element's rotated X-axis
107
+ // This gives us the actual width change in the element's coordinate system
108
+ const deltaXRotated = mouseDeltaX * Math.cos(rotationRad) + mouseDeltaY * Math.sin(rotationRad);
109
+ let newWidth = startWidthRef.current;
110
+ if (resizeSide === 'right') {
111
+ // Dragging right handle: increase width (left side stays fixed)
112
+ newWidth = startWidthRef.current + deltaXRotated;
113
+ }
114
+ else {
115
+ // Dragging left handle: decrease width (right side should stay fixed)
116
+ newWidth = startWidthRef.current - deltaXRotated;
117
+ }
118
+ // Apply minimum width constraint
119
+ const minWidth = 100;
120
+ newWidth = Math.max(minWidth, newWidth);
121
+ // Adjust position to compensate for rotation effects
122
+ // Both handles experience the same center shift when width changes
123
+ // The rotation happens around the center, so when width changes by ΔW,
124
+ // the center shifts by ΔW/2 in element coordinates
125
+ // We need to move position in the opposite direction to keep visual position stable
126
+ const widthDiff = newWidth - startWidthRef.current;
127
+ const centerShift = widthDiff / 2;
128
+ // Convert center shift to viewport coordinates using rotation
129
+ // In element coords: width change shifts center along X-axis
130
+ // At rotation θ, element's X-axis points at angle θ in viewport
131
+ const offsetXRotated = centerShift * Math.cos(rotationRad);
132
+ const offsetYRotated = centerShift * Math.sin(rotationRad);
133
+ // Subtract offset to compensate (move position opposite to center shift)
134
+ const newX = startPositionRef.current.x - offsetXRotated;
135
+ const newY = startPositionRef.current.y - offsetYRotated;
136
+ onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange({ x: newX, y: newY });
137
+ onWidthChange === null || onWidthChange === void 0 ? void 0 : onWidthChange(Math.round(newWidth));
138
+ };
139
+ const handleResizeEnd = () => {
140
+ setIsResizing(false);
141
+ setResizeSide(null);
142
+ hasDraggedRef.current = true;
143
+ };
144
+ react_1.default.useEffect(() => {
145
+ if (isResizing) {
146
+ window.addEventListener('mousemove', handleResizeMove);
147
+ window.addEventListener('mouseup', handleResizeEnd);
148
+ return () => {
149
+ window.removeEventListener('mousemove', handleResizeMove);
150
+ window.removeEventListener('mouseup', handleResizeEnd);
151
+ };
152
+ }
153
+ }, [isResizing, resizeSide]);
154
+ // Selection handlers
155
+ const handleElementClick = (e) => {
156
+ // Don't toggle selection if clicking rotation or width handles
157
+ const target = e.target;
158
+ if (target.closest('.rotation-handle') || target.closest('.width-handle')) {
159
+ return;
160
+ }
161
+ // If we just finished dragging, don't toggle
162
+ if (hasDraggedRef.current) {
163
+ hasDraggedRef.current = false;
164
+ return;
165
+ }
166
+ // If we just stopped without dragging (click), don't toggle
167
+ if (justStoppedWithoutDragRef.current) {
168
+ justStoppedWithoutDragRef.current = false;
169
+ return;
170
+ }
171
+ // If we just selected via mouseUp, don't toggle
172
+ if (justSelectedRef.current) {
173
+ justSelectedRef.current = false;
174
+ return;
175
+ }
176
+ e.stopPropagation();
177
+ // Toggle selection
178
+ if (isSelected) {
179
+ onDeselect();
180
+ }
181
+ else {
182
+ onSelect(elementId);
183
+ }
184
+ };
185
+ // Listen for clicks outside to deselect
186
+ react_1.default.useEffect(() => {
187
+ if (!isSelected)
188
+ return;
189
+ const handleClickOutside = (e) => {
190
+ if (elementRef.current && !elementRef.current.contains(e.target)) {
191
+ onDeselect();
192
+ }
193
+ };
194
+ document.addEventListener('click', handleClickOutside);
195
+ return () => {
196
+ document.removeEventListener('click', handleClickOutside);
197
+ };
198
+ }, [isSelected, onDeselect]);
199
+ return ((0, jsx_runtime_1.jsx)(react_draggable_1.default, { position: position, disabled: false, onStart: (e) => {
200
+ const target = e.target;
201
+ if (target.closest('.rotation-handle') || target.closest('.width-handle')) {
202
+ return false;
203
+ }
204
+ // Auto-select element when starting to drag
205
+ if (!isSelected) {
206
+ onSelect(elementId);
207
+ }
208
+ hasDraggedRef.current = false;
209
+ setIsDragging(true);
210
+ }, onDrag: (_e, _data) => {
211
+ hasDraggedRef.current = true;
212
+ if (contentOnlyRef.current && onDragMove) {
213
+ const elementBounds = contentOnlyRef.current.getBoundingClientRect();
214
+ onDragMove(elementId, elementBounds);
215
+ }
216
+ }, onStop: (_e, data) => {
217
+ // If we didn't actually drag, set flag to prevent onClick from toggling
218
+ if (!hasDraggedRef.current) {
219
+ justStoppedWithoutDragRef.current = true;
220
+ }
221
+ setIsDragging(false);
222
+ onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange({ x: data.x, y: data.y });
223
+ // Auto-capture width if not explicitly set
224
+ if (width === undefined && contentOnlyRef.current && onWidthChange) {
225
+ const currentWidth = contentOnlyRef.current.offsetWidth;
226
+ if (currentWidth > 0) {
227
+ onWidthChange(Math.round(currentWidth));
228
+ }
229
+ }
230
+ }, scale: scale, cancel: ".rotation-handle, .width-handle", children: (0, jsx_runtime_1.jsx)("div", { ref: elementRef, onClick: handleElementClick, onMouseDown: (e) => {
231
+ // Track mouse down position for click detection
232
+ const target = e.target;
233
+ if (target.closest('.rotation-handle') || target.closest('.width-handle')) {
234
+ mouseDownPosRef.current = null;
235
+ return;
236
+ }
237
+ mouseDownPosRef.current = { x: e.clientX, y: e.clientY };
238
+ }, onMouseUp: (e) => {
239
+ // Detect click (mouse up at same position as mouse down)
240
+ const target = e.target;
241
+ if (target.closest('.rotation-handle') || target.closest('.width-handle')) {
242
+ return;
243
+ }
244
+ if (mouseDownPosRef.current) {
245
+ const deltaX = Math.abs(e.clientX - mouseDownPosRef.current.x);
246
+ const deltaY = Math.abs(e.clientY - mouseDownPosRef.current.y);
247
+ // If mouse hasn't moved much (less than 5px), treat as click
248
+ if (deltaX < 5 && deltaY < 5) {
249
+ e.preventDefault();
250
+ e.stopPropagation();
251
+ if (!isSelected) {
252
+ onSelect(elementId);
253
+ }
254
+ else {
255
+ // Toggle off if already selected
256
+ onDeselect();
257
+ }
258
+ justSelectedRef.current = true; // Mark that we just selected
259
+ }
260
+ mouseDownPosRef.current = null;
261
+ }
262
+ }, style: {
263
+ cursor: isDragging ? "move" : "grab",
264
+ opacity: isDragging || isRotating || isResizing ? 0.8 : 1,
265
+ transition: isDragging || isRotating || isResizing ? "none" : "opacity 0.2s ease",
266
+ display: "inline-block",
267
+ position: "relative",
268
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
269
+ transform: centerOrigin ? 'translate(-50%, -50%)' : undefined,
270
+ position: "relative"
271
+ }, children: [(isDragging || isRotating || isResizing) && ((0, jsx_runtime_1.jsx)("div", { style: {
272
+ position: "absolute",
273
+ inset: "-8px",
274
+ border: "2px dashed rgba(59, 130, 246, 0.5)",
275
+ zIndex: 0,
276
+ pointerEvents: "none",
277
+ } })), (0, jsx_runtime_1.jsxs)("div", { ref: rotatingContentRef, style: { transform: `rotate(${rotation}deg)`, position: "relative", display: "inline-block" }, children: [isSelected && ((0, jsx_runtime_1.jsx)("div", { style: {
278
+ position: "absolute",
279
+ inset: 0,
280
+ border: "4px dotted rgba(59, 130, 246, 1)",
281
+ zIndex: 1,
282
+ pointerEvents: "none",
283
+ } })), onRotationChange && isSelected && ((0, jsx_runtime_1.jsx)("div", { ref: blueHandleRef, className: "rotation-handle", onMouseDown: handleRotationStart, style: {
284
+ position: "absolute",
285
+ top: "-16px",
286
+ right: "-16px",
287
+ width: "32px",
288
+ height: "32px",
289
+ borderRadius: "50%",
290
+ backgroundColor: "rgba(59, 130, 246, 0.9)",
291
+ border: "2px solid white",
292
+ cursor: "grab",
293
+ display: "flex",
294
+ alignItems: "center",
295
+ justifyContent: "center",
296
+ fontSize: "16px",
297
+ lineHeight: "1",
298
+ color: "white",
299
+ zIndex: 1000,
300
+ boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
301
+ transform: `rotate(${-rotation}deg)`,
302
+ transformOrigin: "center center",
303
+ }, title: "Drag to rotate", children: "\u21BB" })), onRotationChange && isSelected && ((0, jsx_runtime_1.jsx)("div", { ref: purpleIndicatorRef, style: {
304
+ position: "absolute",
305
+ top: "-16px",
306
+ right: "-16px",
307
+ width: "32px",
308
+ height: "32px",
309
+ borderRadius: "50%",
310
+ backgroundColor: "rgba(139, 92, 246, 0.9)",
311
+ border: "2px solid white",
312
+ display: "flex",
313
+ alignItems: "center",
314
+ justifyContent: "center",
315
+ fontSize: "16px",
316
+ lineHeight: "1",
317
+ color: "white",
318
+ zIndex: 999,
319
+ boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
320
+ pointerEvents: "none",
321
+ }, title: "Rotation indicator", children: "\u21BB" })), isSelected && ((0, jsx_runtime_1.jsx)("div", { className: "width-handle width-handle-left", onMouseDown: (e) => handleResizeStart(e, 'left'), style: {
322
+ position: "absolute",
323
+ left: "-16px",
324
+ top: "50%",
325
+ transform: `translateY(-50%) rotate(${-rotation}deg)`,
326
+ transformOrigin: "center center",
327
+ width: "32px",
328
+ height: "32px",
329
+ borderRadius: "50%",
330
+ backgroundColor: "rgba(16, 185, 129, 0.9)",
331
+ border: "2px solid white",
332
+ cursor: "ew-resize",
333
+ display: "flex",
334
+ alignItems: "center",
335
+ justifyContent: "center",
336
+ fontSize: "16px",
337
+ lineHeight: "1",
338
+ color: "white",
339
+ zIndex: 1000,
340
+ boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
341
+ }, title: "Drag to resize width", children: "\u27F7" })), isSelected && ((0, jsx_runtime_1.jsx)("div", { className: "width-handle width-handle-right", onMouseDown: (e) => handleResizeStart(e, 'right'), style: {
342
+ position: "absolute",
343
+ right: "-16px",
344
+ top: "50%",
345
+ transform: `translateY(-50%) rotate(${-rotation}deg)`,
346
+ transformOrigin: "center center",
347
+ width: "32px",
348
+ height: "32px",
349
+ borderRadius: "50%",
350
+ backgroundColor: "rgba(16, 185, 129, 0.9)",
351
+ border: "2px solid white",
352
+ cursor: "ew-resize",
353
+ display: "flex",
354
+ alignItems: "center",
355
+ justifyContent: "center",
356
+ fontSize: "16px",
357
+ lineHeight: "1",
358
+ color: "white",
359
+ zIndex: 1000,
360
+ boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
361
+ }, title: "Drag to resize width", children: "\u27F7" })), (0, jsx_runtime_1.jsx)("div", { ref: contentOnlyRef, style: {
362
+ position: "relative",
363
+ zIndex: 1,
364
+ width: width ? `${width}px` : undefined,
365
+ }, children: children })] })] }) }) }));
366
+ };
367
+ exports.DraggableElement = DraggableElement;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared components barrel export
3
+ * Reusable components used across all banner styles
4
+ */
5
+ export { DraggableElement } from './DraggableElement';
6
+ export type { DraggableElementProps } from './DraggableElement';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/shared/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Shared components barrel export
4
+ * Reusable components used across all banner styles
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DraggableElement = void 0;
8
+ var DraggableElement_1 = require("./DraggableElement");
9
+ Object.defineProperty(exports, "DraggableElement", { enumerable: true, get: function () { return DraggableElement_1.DraggableElement; } });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Centralized configuration for Style1 substyles
3
+ * Defines positioning, sizing, and behavior for logo and copies in each substyle
4
+ */
5
+ import { SubstyleConfig } from '../types/substyleTypes';
6
+ export type { SubstyleConfig };
7
+ /**
8
+ * Style1 substyle configurations
9
+ * All coordinates are in pixels from center (540, 540) of a 1080x1080 banner
10
+ * x: negative = left, positive = right
11
+ * y: negative = up, positive = down
12
+ */
13
+ export declare const STYLE1_SUBSTYLE_CONFIGS: Record<number, SubstyleConfig>;
14
+ /**
15
+ * Get configuration for a specific substyle
16
+ * @param substyle - Substyle number (1, 2, or 3)
17
+ * @returns SubstyleConfig for the specified substyle
18
+ */
19
+ export declare const getSubstyleConfig: (substyle: number) => SubstyleConfig;
20
+ //# sourceMappingURL=substyleConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"substyleConfig.d.ts","sourceRoot":"","sources":["../../../../src/components/styles/Style1/substyleConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAiFlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,cAEpD,CAAC"}