zuljaman-banner-components 1.0.14 → 1.0.16
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerRenderer.d.ts","sourceRoot":"","sources":["../../src/components/BannerRenderer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAgE,MAAM,OAAO,CAAC;AAGrF,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAUvD,UAAU,mBAAmB;IAE3B,WAAW,EAAE,MAAM,CAAC;IAGpB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IAEtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAGhD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAG7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAA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AM,KAAK,IAAI,CAAC;IACrE,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAChE;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAukBxD,CAAC"}
|
|
@@ -102,17 +102,6 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
102
102
|
(0, react_1.useEffect)(() => {
|
|
103
103
|
setAutoOffsets({});
|
|
104
104
|
}, [config]);
|
|
105
|
-
// Memoize copies without rotation to prevent auto-positioning recalc on rotation changes
|
|
106
|
-
const copiesWithoutRotation = (0, react_1.useMemo)(() => {
|
|
107
|
-
return copies.map(copy => ({
|
|
108
|
-
text: copy.text,
|
|
109
|
-
styleSlot: copy.styleSlot,
|
|
110
|
-
translateX: copy.translateX,
|
|
111
|
-
translateY: copy.translateY,
|
|
112
|
-
width: copy.width,
|
|
113
|
-
// Exclude rotation from memoization
|
|
114
|
-
}));
|
|
115
|
-
}, [copies.map(c => `${c.text}-${c.styleSlot}-${c.translateX || 0}-${c.translateY || 0}-${c.width || 'auto'}`).join(',')]);
|
|
116
105
|
// Auto-positioning calculation
|
|
117
106
|
(0, react_1.useLayoutEffect)(() => {
|
|
118
107
|
// Only calculate if auto-positioning is enabled
|
|
@@ -120,20 +109,36 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
120
109
|
return;
|
|
121
110
|
}
|
|
122
111
|
const { anchorElement, targetElement } = config.autoPositioningConfig;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
// Get anchor copy object to check if it's been dragged
|
|
113
|
+
let anchorCopy;
|
|
114
|
+
if (anchorElement === 'copy1') {
|
|
115
|
+
anchorCopy = copies.find(c => c.styleSlot === 0);
|
|
116
|
+
}
|
|
117
|
+
else if (anchorElement === 'copy2') {
|
|
118
|
+
anchorCopy = copies.find(c => c.styleSlot === 1);
|
|
119
|
+
}
|
|
120
|
+
// Get target copy object to check if it's been dragged
|
|
121
|
+
let targetCopy;
|
|
122
|
+
if (targetElement === 'copy1') {
|
|
123
|
+
targetCopy = copies.find(c => c.styleSlot === 0);
|
|
124
|
+
}
|
|
125
|
+
else if (targetElement === 'copy2') {
|
|
126
|
+
targetCopy = copies.find(c => c.styleSlot === 1);
|
|
127
|
+
}
|
|
128
|
+
// Check if anchor has been manually dragged
|
|
129
|
+
const anchorHasBeenDragged = anchorCopy && ((anchorCopy.translateX !== undefined && anchorCopy.translateX !== 0) ||
|
|
130
|
+
(anchorCopy.translateY !== undefined && anchorCopy.translateY !== 0));
|
|
131
|
+
// Check if target has been manually dragged
|
|
132
|
+
const targetHasBeenDragged = targetCopy && ((targetCopy.translateX !== undefined && targetCopy.translateX !== 0) ||
|
|
133
|
+
(targetCopy.translateY !== undefined && targetCopy.translateY !== 0));
|
|
134
|
+
// Skip auto-positioning if either anchor or target has been manually positioned
|
|
135
|
+
if (anchorHasBeenDragged || targetHasBeenDragged) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
129
138
|
// Get anchor element ref
|
|
130
139
|
let anchorRef = null;
|
|
131
140
|
if (anchorElement === 'logo') {
|
|
132
141
|
anchorRef = logoRef.current;
|
|
133
|
-
console.log('📍 Logo anchor:', {
|
|
134
|
-
exists: !!anchorRef,
|
|
135
|
-
height: anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.getBoundingClientRect().height,
|
|
136
|
-
});
|
|
137
142
|
}
|
|
138
143
|
else if (anchorElement === 'copy1') {
|
|
139
144
|
// Find copy with styleSlot 0 (copy1)
|
|
@@ -141,10 +146,6 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
141
146
|
if (copy1Index !== -1) {
|
|
142
147
|
anchorRef = copyRefs.current[copy1Index];
|
|
143
148
|
}
|
|
144
|
-
console.log('📍 Copy1 anchor:', {
|
|
145
|
-
exists: !!anchorRef,
|
|
146
|
-
height: anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.getBoundingClientRect().height,
|
|
147
|
-
});
|
|
148
149
|
}
|
|
149
150
|
else if (anchorElement === 'copy2') {
|
|
150
151
|
// Find copy with styleSlot 1 (copy2)
|
|
@@ -152,14 +153,9 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
152
153
|
if (copy2Index !== -1) {
|
|
153
154
|
anchorRef = copyRefs.current[copy2Index];
|
|
154
155
|
}
|
|
155
|
-
console.log('📍 Copy2 anchor:', {
|
|
156
|
-
exists: !!anchorRef,
|
|
157
|
-
height: anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.getBoundingClientRect().height,
|
|
158
|
-
});
|
|
159
156
|
}
|
|
160
157
|
// If anchor element doesn't exist, can't calculate
|
|
161
158
|
if (!anchorRef) {
|
|
162
|
-
console.log('❌ NO ANCHOR REF - Skipping calculation');
|
|
163
159
|
return;
|
|
164
160
|
}
|
|
165
161
|
// Get target element ref
|
|
@@ -178,7 +174,6 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
178
174
|
}
|
|
179
175
|
// If target element doesn't exist, can't calculate
|
|
180
176
|
if (!targetRef) {
|
|
181
|
-
console.log('❌ NO TARGET REF - Skipping calculation');
|
|
182
177
|
return;
|
|
183
178
|
}
|
|
184
179
|
// Measure anchor and target heights
|
|
@@ -186,10 +181,8 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
186
181
|
const targetHeight = targetRef.getBoundingClientRect().height / sizeMultiplier;
|
|
187
182
|
// Determine if anchor has centerOrigin (logo doesn't, copies do)
|
|
188
183
|
const anchorHasCenterOrigin = anchorElement !== 'logo';
|
|
189
|
-
console.log('📏 Heights:', { anchorHeight, targetHeight, anchorHasCenterOrigin });
|
|
190
184
|
// Calculate offset
|
|
191
185
|
const offset = (0, positioningUtils_1.calculateAutoPositionOffset)(config, config.autoPositioningConfig, anchorHeight, targetHeight, anchorHasCenterOrigin);
|
|
192
|
-
console.log('✨ Calculated offset:', offset);
|
|
193
186
|
// Find target styleSlot
|
|
194
187
|
let targetStyleSlot;
|
|
195
188
|
if (targetElement === 'copy1') {
|
|
@@ -198,27 +191,23 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
198
191
|
else if (targetElement === 'copy2') {
|
|
199
192
|
targetStyleSlot = 1;
|
|
200
193
|
}
|
|
201
|
-
console.log('🎪 Target styleSlot:', targetStyleSlot);
|
|
202
194
|
// Update offsets only if changed
|
|
203
195
|
if (targetStyleSlot !== undefined) {
|
|
204
196
|
setAutoOffsets(prev => {
|
|
205
197
|
// Only update if offset has changed significantly (to prevent infinite loops from floating point precision)
|
|
206
198
|
const prevOffset = prev[targetStyleSlot] || 0;
|
|
207
199
|
const EPSILON = 0.1; // 0.1px tolerance
|
|
208
|
-
console.log('🔄 Offset comparison:', { prevOffset, newOffset: offset, willUpdate: Math.abs(prevOffset - offset) > EPSILON });
|
|
209
200
|
if (Math.abs(prevOffset - offset) > EPSILON) {
|
|
210
201
|
const newOffsets = {
|
|
211
202
|
...prev,
|
|
212
203
|
[targetStyleSlot]: offset,
|
|
213
204
|
};
|
|
214
|
-
console.log('✅ UPDATING OFFSETS:', newOffsets);
|
|
215
205
|
return newOffsets;
|
|
216
206
|
}
|
|
217
|
-
console.log('⏭️ SKIPPING - no significant change');
|
|
218
207
|
return prev; // No significant change, return same object to prevent re-render
|
|
219
208
|
});
|
|
220
209
|
}
|
|
221
|
-
}, [config,
|
|
210
|
+
}, [config, recalcTrigger, copies]); // Recalculate on style/substyle change and when copy text changes (if not dragged)
|
|
222
211
|
// Rotation snap function - snaps to 0°, 90°, 180°, 270°
|
|
223
212
|
const handleRotationSnap = react_1.default.useCallback((angle) => {
|
|
224
213
|
const snapAngles = [0, 90, 180, 270, -90, -180, -270];
|
|
@@ -372,18 +361,6 @@ const BannerRenderer = ({ bannerStyle, copies = [], bannerSubstyle = 1, logoUrl,
|
|
|
372
361
|
const finalY = baseY + (copy.translateY || 0);
|
|
373
362
|
const finalWidth = copy.width || configWidth;
|
|
374
363
|
const finalRotation = (_c = copy.rotation) !== null && _c !== void 0 ? _c : (isStyled ? ((_d = copyConfig === null || copyConfig === void 0 ? void 0 : copyConfig.rotation) !== null && _d !== void 0 ? _d : 0) : 0);
|
|
375
|
-
console.log(`📦 DRAGGABLE POSITION (styleSlot ${styleSlot}):`, {
|
|
376
|
-
configX,
|
|
377
|
-
configY,
|
|
378
|
-
autoOffset,
|
|
379
|
-
baseX,
|
|
380
|
-
baseY,
|
|
381
|
-
'copy.translateX': copy.translateX,
|
|
382
|
-
'copy.translateY': copy.translateY,
|
|
383
|
-
finalX,
|
|
384
|
-
finalY,
|
|
385
|
-
finalWidth,
|
|
386
|
-
});
|
|
387
364
|
return ((0, jsx_runtime_1.jsx)(shared_1.DraggableElement, { enabled: draggableMode, position: { x: finalX, y: finalY }, rotation: finalRotation, width: finalWidth, scale: sizeMultiplier, elementId: `copy-${copy.id}`, isSelected: selectedElement === `copy-${copy.id}`, centerOrigin: true, onPositionChange: (pos) => {
|
|
388
365
|
// Subtract base position to get only user adjustment
|
|
389
366
|
const adjustedPos = {
|
|
@@ -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,KA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AAE,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,CAgnB5D,CAAC"}
|
|
@@ -47,10 +47,8 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
47
47
|
react_1.default.useEffect(() => {
|
|
48
48
|
// Don't update position from props if we're currently dragging or in pre-drag phase
|
|
49
49
|
if (isDraggingRef.current || preDragCleanupRef.current) {
|
|
50
|
-
console.log('[DraggableElement] Position prop changed but BLOCKED - currently dragging/pre-drag');
|
|
51
50
|
return;
|
|
52
51
|
}
|
|
53
|
-
console.log('[DraggableElement] Position prop changed, updating currentPosition:', position);
|
|
54
52
|
setCurrentPosition(position);
|
|
55
53
|
}, [position]);
|
|
56
54
|
react_1.default.useEffect(() => {
|
|
@@ -193,7 +191,6 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
193
191
|
return;
|
|
194
192
|
}
|
|
195
193
|
isDraggingRef.current = true;
|
|
196
|
-
console.log('[DraggableElement] DRAG ACTIVATED - adding drag listeners');
|
|
197
194
|
const handleDragMove = (e) => {
|
|
198
195
|
hasDraggedRef.current = true;
|
|
199
196
|
const deltaX = (e.clientX - dragStartPosRef.current.x) / scaleRef.current;
|
|
@@ -210,7 +207,6 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
210
207
|
};
|
|
211
208
|
const handleDragEnd = () => {
|
|
212
209
|
var _a;
|
|
213
|
-
console.log('[DraggableElement] Drag mouseup - ending drag');
|
|
214
210
|
// If we didn't actually drag, set flag to prevent onClick from toggling
|
|
215
211
|
if (!hasDraggedRef.current) {
|
|
216
212
|
justStoppedWithoutDragRef.current = true;
|
|
@@ -230,7 +226,6 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
230
226
|
window.addEventListener('mousemove', handleDragMove);
|
|
231
227
|
window.addEventListener('mouseup', handleDragEnd);
|
|
232
228
|
return () => {
|
|
233
|
-
console.log('[DraggableElement] Removing drag listeners');
|
|
234
229
|
window.removeEventListener('mousemove', handleDragMove);
|
|
235
230
|
window.removeEventListener('mouseup', handleDragEnd);
|
|
236
231
|
};
|
|
@@ -243,12 +238,10 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
243
238
|
}
|
|
244
239
|
// Prevent multiple executions if already dragging or pre-drag listeners are active
|
|
245
240
|
if (isDraggingRef.current || preDragCleanupRef.current) {
|
|
246
|
-
console.log('[DraggableElement] MouseDown - BLOCKED (already dragging or pre-drag active)');
|
|
247
241
|
e.preventDefault();
|
|
248
242
|
e.stopPropagation();
|
|
249
243
|
return;
|
|
250
244
|
}
|
|
251
|
-
console.log('[DraggableElement] MouseDown - starting pre-drag phase');
|
|
252
245
|
hasDraggedRef.current = false;
|
|
253
246
|
const startX = e.clientX;
|
|
254
247
|
const startY = e.clientY;
|
|
@@ -258,27 +251,22 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
258
251
|
const handlePreDragMove = (moveEvent) => {
|
|
259
252
|
const deltaX = Math.abs(moveEvent.clientX - startX);
|
|
260
253
|
const deltaY = Math.abs(moveEvent.clientY - startY);
|
|
261
|
-
console.log('[DraggableElement] PreDrag mousemove - delta:', { deltaX, deltaY });
|
|
262
254
|
// If mouse moved more than threshold, activate drag (increased to 8px to prevent accidental drags on click)
|
|
263
255
|
if (deltaX > 8 || deltaY > 8) {
|
|
264
|
-
console.log('[DraggableElement] Threshold exceeded - activating drag');
|
|
265
256
|
setIsDragging(true);
|
|
266
257
|
// Remove temporary listeners
|
|
267
258
|
cleanup();
|
|
268
259
|
}
|
|
269
260
|
};
|
|
270
261
|
const handlePreDragEnd = () => {
|
|
271
|
-
console.log('[DraggableElement] PreDrag mouseup - click without drag');
|
|
272
262
|
// Mouse up without moving = click, not drag
|
|
273
263
|
cleanup();
|
|
274
264
|
};
|
|
275
265
|
const cleanup = () => {
|
|
276
|
-
console.log('[DraggableElement] Cleaning up pre-drag listeners');
|
|
277
266
|
window.removeEventListener('mousemove', handlePreDragMove);
|
|
278
267
|
window.removeEventListener('mouseup', handlePreDragEnd);
|
|
279
268
|
preDragCleanupRef.current = null;
|
|
280
269
|
};
|
|
281
|
-
console.log('[DraggableElement] Adding pre-drag listeners');
|
|
282
270
|
window.addEventListener('mousemove', handlePreDragMove);
|
|
283
271
|
window.addEventListener('mouseup', handlePreDragEnd);
|
|
284
272
|
// Store cleanup function for external cleanup if needed
|
|
@@ -358,7 +346,6 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
|
|
|
358
346
|
}
|
|
359
347
|
// Clean up pre-drag listeners if active (important: do this BEFORE stopPropagation)
|
|
360
348
|
if (preDragCleanupRef.current) {
|
|
361
|
-
console.log('[DraggableElement] onMouseUp - cleaning up pre-drag listeners');
|
|
362
349
|
preDragCleanupRef.current();
|
|
363
350
|
}
|
|
364
351
|
if (mouseDownPosRef.current) {
|