zuljaman-banner-components 1.0.22 → 1.0.24
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 +228 -131
- package/dist/components/BannerRenderer/BannerRenderer.d.ts +8 -0
- package/dist/components/BannerRenderer/BannerRenderer.d.ts.map +1 -0
- package/dist/components/BannerRenderer/BannerRenderer.js +325 -0
- package/dist/components/BannerRenderer/components/CopyElement.d.ts +62 -0
- package/dist/components/BannerRenderer/components/CopyElement.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/CopyElement.js +220 -0
- package/dist/components/BannerRenderer/components/InteractiveLines.d.ts +26 -0
- package/dist/components/BannerRenderer/components/InteractiveLines.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/InteractiveLines.js +172 -0
- package/dist/components/BannerRenderer/components/LogoElement.d.ts +55 -0
- package/dist/components/BannerRenderer/components/LogoElement.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/LogoElement.js +53 -0
- package/dist/components/BannerRenderer/components/VisualGuides.d.ts +43 -0
- package/dist/components/BannerRenderer/components/VisualGuides.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/VisualGuides.js +110 -0
- package/dist/components/BannerRenderer/components/index.d.ts +12 -0
- package/dist/components/BannerRenderer/components/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/components/index.js +14 -0
- package/dist/components/BannerRenderer/constants.d.ts +15 -0
- package/dist/components/BannerRenderer/constants.d.ts.map +1 -0
- package/dist/components/BannerRenderer/constants.js +36 -0
- package/dist/components/BannerRenderer/hooks/index.d.ts +14 -0
- package/dist/components/BannerRenderer/hooks/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/index.js +16 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.d.ts +30 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.js +87 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.d.ts +13 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.js +21 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.d.ts +71 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.js +151 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.d.ts +66 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.js +332 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.d.ts +61 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.js +180 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.d.ts +60 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.js +178 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning.d.ts +8 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useAutoPositioning.js +12 -0
- package/dist/components/BannerRenderer/hooks/useDragSnap.d.ts +30 -0
- package/dist/components/BannerRenderer/hooks/useDragSnap.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useDragSnap.js +90 -0
- package/dist/components/BannerRenderer/hooks/useElementRefs.d.ts +22 -0
- package/dist/components/BannerRenderer/hooks/useElementRefs.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useElementRefs.js +70 -0
- package/dist/components/BannerRenderer/hooks/useLineDrawing.d.ts +40 -0
- package/dist/components/BannerRenderer/hooks/useLineDrawing.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useLineDrawing.js +198 -0
- package/dist/components/BannerRenderer/hooks/useProximityDetection.d.ts +43 -0
- package/dist/components/BannerRenderer/hooks/useProximityDetection.d.ts.map +1 -0
- package/dist/components/BannerRenderer/hooks/useProximityDetection.js +491 -0
- package/dist/components/BannerRenderer/index.d.ts +6 -0
- package/dist/components/BannerRenderer/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/index.js +8 -0
- package/dist/components/{BannerRenderer.d.ts → BannerRenderer/types.d.ts} +29 -8
- package/dist/components/BannerRenderer/types.d.ts.map +1 -0
- package/dist/components/BannerRenderer/types.js +5 -0
- package/dist/components/BannerRenderer/utils/alignmentUtils.d.ts +38 -0
- package/dist/components/BannerRenderer/utils/alignmentUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/alignmentUtils.js +138 -0
- package/dist/components/BannerRenderer/utils/elementCheckUtils.d.ts +22 -0
- package/dist/components/BannerRenderer/utils/elementCheckUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/elementCheckUtils.js +37 -0
- package/dist/components/BannerRenderer/utils/elementIdUtils.d.ts +25 -0
- package/dist/components/BannerRenderer/utils/elementIdUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/elementIdUtils.js +56 -0
- package/dist/components/BannerRenderer/utils/fontUtils.d.ts +12 -0
- package/dist/components/BannerRenderer/utils/fontUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/fontUtils.js +26 -0
- package/dist/components/BannerRenderer/utils/graphUtils.d.ts +54 -0
- package/dist/components/BannerRenderer/utils/graphUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/graphUtils.js +138 -0
- package/dist/components/BannerRenderer/utils/index.d.ts +12 -0
- package/dist/components/BannerRenderer/utils/index.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/index.js +27 -0
- package/dist/components/BannerRenderer/utils/snapUtils.d.ts +38 -0
- package/dist/components/BannerRenderer/utils/snapUtils.d.ts.map +1 -0
- package/dist/components/BannerRenderer/utils/snapUtils.js +109 -0
- package/dist/components/BannerVisor.d.ts.map +1 -1
- package/dist/components/BannerVisor.js +8 -1
- package/dist/components/index.js +1 -1
- package/dist/components/shared/DraggableElement.d.ts +11 -0
- package/dist/components/shared/DraggableElement.d.ts.map +1 -1
- package/dist/components/shared/DraggableElement.js +51 -51
- package/dist/components/styles/Style1/substyleConfig.d.ts.map +1 -1
- package/dist/components/styles/Style1/substyleConfig.js +53 -54
- package/dist/components/styles/Style2/substyleConfig.js +78 -78
- package/dist/components/styles/Style3/substyleConfig.d.ts.map +1 -1
- package/dist/components/styles/Style3/substyleConfig.js +40 -37
- package/dist/components/styles/Style4/substyleConfig.js +57 -57
- package/dist/components/styles/types/substyleTypes.d.ts +32 -15
- package/dist/components/styles/types/substyleTypes.d.ts.map +1 -1
- package/dist/components/styles/utils/chainValidation.d.ts +41 -0
- package/dist/components/styles/utils/chainValidation.d.ts.map +1 -0
- package/dist/components/styles/utils/chainValidation.js +148 -0
- package/dist/components/styles/utils/positioningUtils.d.ts +207 -11
- package/dist/components/styles/utils/positioningUtils.d.ts.map +1 -1
- package/dist/components/styles/utils/positioningUtils.js +520 -19
- package/dist/constants/characterLimits.d.ts +4 -16
- package/dist/constants/characterLimits.d.ts.map +1 -1
- package/dist/constants/characterLimits.js +28 -26
- package/dist/constants/styleConfigs.js +6 -6
- package/dist/styleConfig.d.ts +4 -4
- package/dist/styleConfig.d.ts.map +1 -1
- package/dist/styleConfig.js +8 -16
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/components/BannerRenderer.d.ts.map +0 -1
- package/dist/components/BannerRenderer.js +0 -559
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Snap utility functions for BannerRenderer
|
|
4
|
+
* Pure functions for snapping positions and rotations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.snapRotation = snapRotation;
|
|
8
|
+
exports.toRelativeBounds = toRelativeBounds;
|
|
9
|
+
exports.calculateSnapDelta = calculateSnapDelta;
|
|
10
|
+
/**
|
|
11
|
+
* Snap angle to nearest cardinal direction (0°, 90°, 180°, 270°)
|
|
12
|
+
* @param angle - Input angle in degrees
|
|
13
|
+
* @param snapThreshold - Degrees threshold for snapping (default: 3)
|
|
14
|
+
* @returns Snapped angle or normalized input angle
|
|
15
|
+
*/
|
|
16
|
+
function snapRotation(angle, snapThreshold = 3) {
|
|
17
|
+
const snapAngles = [0, 90, 180, 270, -90, -180, -270];
|
|
18
|
+
// Normalize angle to -180 to 180 range
|
|
19
|
+
let normalized = angle % 360;
|
|
20
|
+
if (normalized > 180)
|
|
21
|
+
normalized -= 360;
|
|
22
|
+
if (normalized < -180)
|
|
23
|
+
normalized += 360;
|
|
24
|
+
// Check if close to any snap angle
|
|
25
|
+
for (const snapAngle of snapAngles) {
|
|
26
|
+
if (Math.abs(normalized - snapAngle) < snapThreshold) {
|
|
27
|
+
return snapAngle;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert DOMRect to relative bounds (relative to container center)
|
|
34
|
+
*/
|
|
35
|
+
function toRelativeBounds(bounds, containerBounds, sizeMultiplier) {
|
|
36
|
+
return {
|
|
37
|
+
left: (bounds.left - containerBounds.left - containerBounds.width / 2) / sizeMultiplier,
|
|
38
|
+
centerX: (bounds.left + bounds.width / 2 - containerBounds.left - containerBounds.width / 2) / sizeMultiplier,
|
|
39
|
+
right: (bounds.right - containerBounds.left - containerBounds.width / 2) / sizeMultiplier,
|
|
40
|
+
top: (bounds.top - containerBounds.top - containerBounds.height / 2) / sizeMultiplier,
|
|
41
|
+
centerY: (bounds.top + bounds.height / 2 - containerBounds.top - containerBounds.height / 2) / sizeMultiplier,
|
|
42
|
+
bottom: (bounds.bottom - containerBounds.top - containerBounds.height / 2) / sizeMultiplier,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Calculate snap delta for position alignment
|
|
47
|
+
* @param draggedBounds - Bounds of the element being dragged
|
|
48
|
+
* @param otherBoundsArray - Array of other elements' bounds to snap to
|
|
49
|
+
* @param snapThreshold - Pixel threshold for snapping (default: 5)
|
|
50
|
+
* @returns Delta to apply to position for snapping
|
|
51
|
+
*/
|
|
52
|
+
function calculateSnapDelta(draggedBounds, otherBoundsArray, snapThreshold = 5) {
|
|
53
|
+
let snapDeltaX = 0;
|
|
54
|
+
let snapDeltaY = 0;
|
|
55
|
+
let hasSnappedX = false;
|
|
56
|
+
let hasSnappedY = false;
|
|
57
|
+
for (const other of otherBoundsArray) {
|
|
58
|
+
// Horizontal snapping (X axis) - only snap to closest alignment
|
|
59
|
+
if (!hasSnappedX) {
|
|
60
|
+
if (Math.abs(draggedBounds.left - other.left) < snapThreshold) {
|
|
61
|
+
snapDeltaX = other.left - draggedBounds.left;
|
|
62
|
+
hasSnappedX = true;
|
|
63
|
+
}
|
|
64
|
+
else if (Math.abs(draggedBounds.centerX - other.centerX) < snapThreshold) {
|
|
65
|
+
snapDeltaX = other.centerX - draggedBounds.centerX;
|
|
66
|
+
hasSnappedX = true;
|
|
67
|
+
}
|
|
68
|
+
else if (Math.abs(draggedBounds.right - other.right) < snapThreshold) {
|
|
69
|
+
snapDeltaX = other.right - draggedBounds.right;
|
|
70
|
+
hasSnappedX = true;
|
|
71
|
+
}
|
|
72
|
+
else if (Math.abs(draggedBounds.right - other.left) < snapThreshold) {
|
|
73
|
+
snapDeltaX = other.left - draggedBounds.right;
|
|
74
|
+
hasSnappedX = true;
|
|
75
|
+
}
|
|
76
|
+
else if (Math.abs(draggedBounds.left - other.right) < snapThreshold) {
|
|
77
|
+
snapDeltaX = other.right - draggedBounds.left;
|
|
78
|
+
hasSnappedX = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Vertical snapping (Y axis) - only snap to closest alignment
|
|
82
|
+
if (!hasSnappedY) {
|
|
83
|
+
if (Math.abs(draggedBounds.top - other.top) < snapThreshold) {
|
|
84
|
+
snapDeltaY = other.top - draggedBounds.top;
|
|
85
|
+
hasSnappedY = true;
|
|
86
|
+
}
|
|
87
|
+
else if (Math.abs(draggedBounds.centerY - other.centerY) < snapThreshold) {
|
|
88
|
+
snapDeltaY = other.centerY - draggedBounds.centerY;
|
|
89
|
+
hasSnappedY = true;
|
|
90
|
+
}
|
|
91
|
+
else if (Math.abs(draggedBounds.bottom - other.bottom) < snapThreshold) {
|
|
92
|
+
snapDeltaY = other.bottom - draggedBounds.bottom;
|
|
93
|
+
hasSnappedY = true;
|
|
94
|
+
}
|
|
95
|
+
else if (Math.abs(draggedBounds.bottom - other.top) < snapThreshold) {
|
|
96
|
+
snapDeltaY = other.top - draggedBounds.bottom;
|
|
97
|
+
hasSnappedY = true;
|
|
98
|
+
}
|
|
99
|
+
else if (Math.abs(draggedBounds.top - other.bottom) < snapThreshold) {
|
|
100
|
+
snapDeltaY = other.bottom - draggedBounds.top;
|
|
101
|
+
hasSnappedY = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Early exit if both axes have snapped
|
|
105
|
+
if (hasSnappedX && hasSnappedY)
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return { deltaX: snapDeltaX, deltaY: snapDeltaY };
|
|
109
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerVisor.d.ts","sourceRoot":"","sources":["../../src/components/BannerVisor.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAA+C,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAYzE,UAAU,yBAA0B,SAAQ,gBAAgB;IAC1D,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;CACjD;AAUD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,
|
|
1
|
+
{"version":3,"file":"BannerVisor.d.ts","sourceRoot":"","sources":["../../src/components/BannerVisor.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAA+C,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAc,MAAM,UAAU,CAAC;AAYzE,UAAU,yBAA0B,SAAQ,gBAAgB;IAC1D,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;CACjD;AAUD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAgV3D,CAAC"}
|
|
@@ -19,7 +19,7 @@ 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 = ({ 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, }) => {
|
|
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, creationMode = false, linkingModeActive = false, onDebugPositions, onApplyAutoPositioning, onConnectionsDeleted, onLineGapsChange, autoPositioningOverride, 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
23
|
var _a;
|
|
24
24
|
const [internalSizeMultiplier, setInternalSizeMultiplier] = (0, react_1.useState)(1);
|
|
25
25
|
const containerRef = (0, react_1.useRef)(null);
|
|
@@ -139,6 +139,13 @@ const BannerVisor = ({ backgroundImageUrl, copies, copy1, copy2, bannerStyle = 1
|
|
|
139
139
|
logoTranslateX,
|
|
140
140
|
logoTranslateY,
|
|
141
141
|
draggableMode,
|
|
142
|
+
creationMode,
|
|
143
|
+
linkingModeActive,
|
|
144
|
+
onDebugPositions,
|
|
145
|
+
onApplyAutoPositioning,
|
|
146
|
+
onConnectionsDeleted,
|
|
147
|
+
onLineGapsChange,
|
|
148
|
+
autoPositioningOverride,
|
|
142
149
|
onLogoPositionChange,
|
|
143
150
|
onCopyPositionChange: handleCopyPositionChange,
|
|
144
151
|
onCopyRotationChange: handleCopyRotationChange,
|
package/dist/components/index.js
CHANGED
|
@@ -18,7 +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("./BannerRenderer"), exports);
|
|
21
|
+
__exportStar(require("./BannerRenderer"), exports); // Now exports from BannerRenderer/index.ts
|
|
22
22
|
// Note: BannerRenderer is a generic component that handles all banner styles
|
|
23
23
|
// Use bannerStyle prop (1, 2, 3, etc.) to select the style
|
|
24
24
|
// Use bannerSubstyle prop (0 for logo only, 1, 2, or 3) to select the substyle
|
|
@@ -23,8 +23,19 @@ export interface DraggableElementProps {
|
|
|
23
23
|
onSelect: (id: string) => void;
|
|
24
24
|
onDeselect: () => void;
|
|
25
25
|
onRotationSnap?: (angle: number) => number;
|
|
26
|
+
onPositionSnap?: (bounds: DOMRect, position: {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
}) => {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
26
33
|
onDragMove?: (elementId: string, bounds: DOMRect) => void;
|
|
27
34
|
centerOrigin?: boolean;
|
|
35
|
+
creationMode?: boolean;
|
|
36
|
+
linkingModeActive?: boolean;
|
|
37
|
+
onStartLinking?: () => void;
|
|
38
|
+
onElementClickWhileDrawing?: (targetId: string) => void;
|
|
28
39
|
children: React.ReactNode;
|
|
29
40
|
}
|
|
30
41
|
export declare const DraggableElement: React.FC<DraggableElementProps>;
|
|
@@ -1 +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;AAE1B,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;
|
|
1
|
+
{"version":3,"file":"DraggableElement.d.ts","sourceRoot":"","sources":["../../../src/components/shared/DraggableElement.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,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,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnG,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAG1D,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,0BAA0B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAExD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAuoB5D,CAAC"}
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.DraggableElement = void 0;
|
|
12
12
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
13
|
const react_1 = __importDefault(require("react"));
|
|
14
|
-
const DraggableElement = ({ enabled, position, rotation, width, scale, elementId, isSelected, onPositionChange, onRotationChange, onWidthChange, onSelect, onDeselect, onRotationSnap, onDragMove, centerOrigin = false, children, }) => {
|
|
14
|
+
const DraggableElement = ({ enabled, position, rotation, width, scale, elementId, isSelected, onPositionChange, onRotationChange, onWidthChange, onSelect, onDeselect, onRotationSnap, onPositionSnap, onDragMove, centerOrigin = false, creationMode = false, linkingModeActive = false, onStartLinking, onElementClickWhileDrawing, children, }) => {
|
|
15
15
|
const [isDragging, setIsDragging] = react_1.default.useState(false);
|
|
16
16
|
const [isRotating, setIsRotating] = react_1.default.useState(false);
|
|
17
17
|
const [isResizing, setIsResizing] = react_1.default.useState(false);
|
|
@@ -203,10 +203,15 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
203
203
|
hasDraggedRef.current = true;
|
|
204
204
|
const deltaX = (e.clientX - dragStartPosRef.current.x) / scaleRef.current;
|
|
205
205
|
const deltaY = (e.clientY - dragStartPosRef.current.y) / scaleRef.current;
|
|
206
|
-
|
|
206
|
+
let newPosition = {
|
|
207
207
|
x: startPositionRef.current.x + deltaX,
|
|
208
208
|
y: startPositionRef.current.y + deltaY,
|
|
209
209
|
};
|
|
210
|
+
// Apply position snap if callback provided
|
|
211
|
+
if (onPositionSnap && contentOnlyRef.current) {
|
|
212
|
+
const elementBounds = contentOnlyRef.current.getBoundingClientRect();
|
|
213
|
+
newPosition = onPositionSnap(elementBounds, newPosition);
|
|
214
|
+
}
|
|
210
215
|
setCurrentPosition(newPosition);
|
|
211
216
|
if (contentOnlyRef.current && onDragMoveRef.current) {
|
|
212
217
|
const elementBounds = contentOnlyRef.current.getBoundingClientRect();
|
|
@@ -261,6 +266,10 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
261
266
|
const deltaY = Math.abs(moveEvent.clientY - startY);
|
|
262
267
|
// If mouse moved more than threshold, activate drag (increased to 8px to prevent accidental drags on click)
|
|
263
268
|
if (deltaX > 8 || deltaY > 8) {
|
|
269
|
+
// Select element if not already selected before starting drag
|
|
270
|
+
if (!isSelected) {
|
|
271
|
+
onSelect(elementId);
|
|
272
|
+
}
|
|
264
273
|
setIsDragging(true);
|
|
265
274
|
// Remove temporary listeners
|
|
266
275
|
cleanup();
|
|
@@ -363,6 +372,19 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
363
372
|
if (deltaX < 5 && deltaY < 5) {
|
|
364
373
|
e.preventDefault();
|
|
365
374
|
e.stopPropagation();
|
|
375
|
+
// If linking mode is active, handle linking instead of normal selection
|
|
376
|
+
if (linkingModeActive) {
|
|
377
|
+
// If another element is drawing, complete the link to this element
|
|
378
|
+
if (onElementClickWhileDrawing) {
|
|
379
|
+
onElementClickWhileDrawing(elementId);
|
|
380
|
+
return; // Don't perform normal selection
|
|
381
|
+
}
|
|
382
|
+
// If no one is drawing, start linking from this element
|
|
383
|
+
if (onStartLinking) {
|
|
384
|
+
onStartLinking();
|
|
385
|
+
return; // Don't perform normal selection
|
|
386
|
+
}
|
|
387
|
+
}
|
|
366
388
|
if (!isSelected) {
|
|
367
389
|
onSelect(elementId);
|
|
368
390
|
}
|
|
@@ -390,18 +412,20 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
390
412
|
border: "2px dashed rgba(59, 130, 246, 0.5)",
|
|
391
413
|
zIndex: 0,
|
|
392
414
|
pointerEvents: "none",
|
|
393
|
-
} })), (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: {
|
|
415
|
+
} })), (0, jsx_runtime_1.jsxs)("div", { ref: rotatingContentRef, style: { transform: `rotate(${rotation}deg)`, position: "relative", display: "inline-block" }, children: [(isSelected || creationMode) && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
394
416
|
position: "absolute",
|
|
395
417
|
inset: 0,
|
|
396
|
-
border:
|
|
418
|
+
border: creationMode
|
|
419
|
+
? "4px solid rgba(0, 255, 0, 1)" // Green phosphorescent solid in creation mode
|
|
420
|
+
: "4px dotted rgba(59, 130, 246, 1)", // Blue dotted when selected
|
|
397
421
|
zIndex: 1,
|
|
398
422
|
pointerEvents: "none",
|
|
399
|
-
} })), onRotationChange && isSelected && ((0, jsx_runtime_1.jsx)("div", { ref: blueHandleRef, className: "rotation-handle", onMouseDown: handleRotationStart, style: {
|
|
423
|
+
} })), onRotationChange && (isSelected || creationMode) && ((0, jsx_runtime_1.jsx)("div", { ref: blueHandleRef, className: "rotation-handle", onMouseDown: handleRotationStart, style: {
|
|
400
424
|
position: "absolute",
|
|
401
|
-
top: "-
|
|
402
|
-
right: "-
|
|
403
|
-
width: "
|
|
404
|
-
height: "
|
|
425
|
+
top: "-20px",
|
|
426
|
+
right: "-20px",
|
|
427
|
+
width: "40px",
|
|
428
|
+
height: "40px",
|
|
405
429
|
borderRadius: "50%",
|
|
406
430
|
backgroundColor: "rgba(59, 130, 246, 0.9)",
|
|
407
431
|
border: "2px solid white",
|
|
@@ -409,72 +433,48 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
409
433
|
display: "flex",
|
|
410
434
|
alignItems: "center",
|
|
411
435
|
justifyContent: "center",
|
|
412
|
-
fontSize: "
|
|
436
|
+
fontSize: "20px",
|
|
413
437
|
lineHeight: "1",
|
|
414
438
|
color: "white",
|
|
415
439
|
zIndex: 1000,
|
|
416
440
|
boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
|
|
417
441
|
transform: `rotate(${-rotation}deg)`,
|
|
418
442
|
transformOrigin: "center center",
|
|
419
|
-
}, title: "Drag to rotate", children: "\u21BB" })), onRotationChange && isSelected && ((0, jsx_runtime_1.jsx)("div", { ref: purpleIndicatorRef, style: {
|
|
443
|
+
}, title: "Drag to rotate", children: "\u21BB" })), onRotationChange && (isSelected || creationMode) && ((0, jsx_runtime_1.jsx)("div", { ref: purpleIndicatorRef, style: {
|
|
420
444
|
position: "absolute",
|
|
421
|
-
top: "-
|
|
422
|
-
right: "-
|
|
423
|
-
width: "
|
|
424
|
-
height: "
|
|
445
|
+
top: "-20px",
|
|
446
|
+
right: "-20px",
|
|
447
|
+
width: "40px",
|
|
448
|
+
height: "40px",
|
|
425
449
|
borderRadius: "50%",
|
|
426
450
|
backgroundColor: "rgba(139, 92, 246, 0.9)",
|
|
427
451
|
border: "2px solid white",
|
|
428
452
|
display: "flex",
|
|
429
453
|
alignItems: "center",
|
|
430
454
|
justifyContent: "center",
|
|
431
|
-
fontSize: "
|
|
455
|
+
fontSize: "20px",
|
|
432
456
|
lineHeight: "1",
|
|
433
457
|
color: "white",
|
|
434
458
|
zIndex: 999,
|
|
435
459
|
boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
|
|
436
460
|
pointerEvents: "none",
|
|
437
|
-
}, title: "Rotation indicator", children: "\u21BB" })), isSelected && ((0, jsx_runtime_1.jsx)("div", { className: "width-handle width-handle-left", onMouseDown: (e) => handleResizeStart(e, 'left'), style: {
|
|
461
|
+
}, title: "Rotation indicator", children: "\u21BB" })), (isSelected || creationMode) && ((0, jsx_runtime_1.jsx)("div", { className: "width-handle width-handle-left", onMouseDown: (e) => handleResizeStart(e, 'left'), style: {
|
|
438
462
|
position: "absolute",
|
|
439
|
-
left: "-
|
|
440
|
-
top: "
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
width: "32px",
|
|
444
|
-
height: "32px",
|
|
445
|
-
borderRadius: "50%",
|
|
446
|
-
backgroundColor: "rgba(16, 185, 129, 0.9)",
|
|
447
|
-
border: "2px solid white",
|
|
463
|
+
left: "-6px",
|
|
464
|
+
top: "0",
|
|
465
|
+
width: "12px",
|
|
466
|
+
height: "100%",
|
|
448
467
|
cursor: "ew-resize",
|
|
449
|
-
display: "flex",
|
|
450
|
-
alignItems: "center",
|
|
451
|
-
justifyContent: "center",
|
|
452
|
-
fontSize: "16px",
|
|
453
|
-
lineHeight: "1",
|
|
454
|
-
color: "white",
|
|
455
468
|
zIndex: 1000,
|
|
456
|
-
|
|
457
|
-
}, 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: {
|
|
469
|
+
}, title: "Drag to resize width" })), (isSelected || creationMode) && ((0, jsx_runtime_1.jsx)("div", { className: "width-handle width-handle-right", onMouseDown: (e) => handleResizeStart(e, 'right'), style: {
|
|
458
470
|
position: "absolute",
|
|
459
|
-
right: "-
|
|
460
|
-
top: "
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
width: "32px",
|
|
464
|
-
height: "32px",
|
|
465
|
-
borderRadius: "50%",
|
|
466
|
-
backgroundColor: "rgba(16, 185, 129, 0.9)",
|
|
467
|
-
border: "2px solid white",
|
|
471
|
+
right: "-6px",
|
|
472
|
+
top: "0",
|
|
473
|
+
width: "12px",
|
|
474
|
+
height: "100%",
|
|
468
475
|
cursor: "ew-resize",
|
|
469
|
-
display: "flex",
|
|
470
|
-
alignItems: "center",
|
|
471
|
-
justifyContent: "center",
|
|
472
|
-
fontSize: "16px",
|
|
473
|
-
lineHeight: "1",
|
|
474
|
-
color: "white",
|
|
475
476
|
zIndex: 1000,
|
|
476
|
-
|
|
477
|
-
}, title: "Drag to resize width", children: "\u27F7" })), (0, jsx_runtime_1.jsx)("div", { ref: contentOnlyRef, style: {
|
|
477
|
+
}, title: "Drag to resize width" })), (0, jsx_runtime_1.jsx)("div", { ref: contentOnlyRef, style: {
|
|
478
478
|
position: "relative",
|
|
479
479
|
zIndex: 1,
|
|
480
480
|
width: width ? `${width}px` : undefined,
|
|
@@ -1 +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,
|
|
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,CAgFlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,KAAG,cAEpD,CAAC"}
|
|
@@ -18,80 +18,79 @@ exports.STYLE1_SUBSTYLE_CONFIGS = {
|
|
|
18
18
|
x: -475, // 6% from left (65px) = -475px from center
|
|
19
19
|
y: -486, // 5% from top (54px) = -486px from center
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
copies: [
|
|
22
|
+
{
|
|
23
|
+
x: 0, // Centered horizontally (copy-0)
|
|
24
|
+
y: 432, // 10% from bottom (108px) = 432px from center
|
|
25
|
+
width: 950, // 88% of 1080px
|
|
26
|
+
alignment: 'center',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
x: 0, // Centered horizontally (copy-1)
|
|
30
|
+
y: 432, // Same Y as copy-0, auto-positioning calculates offset
|
|
31
|
+
width: 950, // 88% of 1080px
|
|
32
|
+
alignment: 'center',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
33
35
|
autoPositioning: true,
|
|
34
36
|
autoPositioningConfig: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
enabled: true,
|
|
38
|
+
links: [
|
|
39
|
+
{ fromElement: 'copy-0', toElement: 'copy-1', direction: 'up' },
|
|
40
|
+
],
|
|
38
41
|
},
|
|
39
42
|
gapRem: 1.5,
|
|
40
|
-
|
|
41
|
-
copy1: 1.0,
|
|
42
|
-
copy2: 0.80,
|
|
43
|
-
},
|
|
43
|
+
fontSizes: [1.0, 0.80],
|
|
44
44
|
},
|
|
45
45
|
2: {
|
|
46
46
|
logo: {
|
|
47
47
|
x: -475,
|
|
48
48
|
y: -486,
|
|
49
49
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
copies: [
|
|
51
|
+
{
|
|
52
|
+
x: 0,
|
|
53
|
+
y: 432,
|
|
54
|
+
width: 950,
|
|
55
|
+
alignment: 'center',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
x: -259, // 6% from left (65px), centered within 40% width (432px) = -259px from center
|
|
59
|
+
y: -486, // Same Y as logo, auto-positioning calculates offset
|
|
60
|
+
width: 432, // 40% of 1080px
|
|
61
|
+
alignment: 'left',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
62
64
|
autoPositioning: true,
|
|
63
65
|
autoPositioningConfig: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
enabled: true,
|
|
67
|
+
links: [
|
|
68
|
+
{ fromElement: 'logo', toElement: 'copy-1', direction: 'down' },
|
|
69
|
+
],
|
|
67
70
|
},
|
|
68
71
|
gapRem: 1.5,
|
|
69
|
-
|
|
70
|
-
copy1: 1.0,
|
|
71
|
-
copy2: 0.80,
|
|
72
|
-
},
|
|
72
|
+
fontSizes: [1.0, 0.80],
|
|
73
73
|
},
|
|
74
74
|
3: {
|
|
75
75
|
logo: {
|
|
76
76
|
x: -475,
|
|
77
77
|
y: -486,
|
|
78
78
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
79
|
+
copies: [
|
|
80
|
+
{
|
|
81
|
+
x: 0,
|
|
82
|
+
y: 432,
|
|
83
|
+
width: 950,
|
|
84
|
+
alignment: 'center',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
x: 259, // 6% from right (65px), centered within 40% width (432px) = 259px from center
|
|
88
|
+
y: -350, // Moved down from -432 to -350
|
|
89
|
+
width: 432, // 40% of 1080px
|
|
90
|
+
alignment: 'right',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
fontSizes: [1.0, 0.80],
|
|
95
94
|
},
|
|
96
95
|
};
|
|
97
96
|
/**
|