zuljaman-banner-components 1.0.8 → 1.0.9

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":"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;IAEvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqhB5D,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,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,CAyhB5D,CAAC"}
@@ -170,47 +170,49 @@ const DraggableElement = ({ enabled, position, rotation, width, scale, elementId
170
170
  startPositionRef.current = { x: currentPosition.x, y: currentPosition.y };
171
171
  setIsDragging(true);
172
172
  };
173
- const handleDragMove = (e) => {
173
+ react_1.default.useEffect(() => {
174
174
  if (!isDragging)
175
175
  return;
176
- hasDraggedRef.current = true;
177
- const deltaX = (e.clientX - dragStartPosRef.current.x) / scale;
178
- const deltaY = (e.clientY - dragStartPosRef.current.y) / scale;
179
- const newPosition = {
180
- x: startPositionRef.current.x + deltaX,
181
- y: startPositionRef.current.y + deltaY,
176
+ const handleDragMove = (e) => {
177
+ hasDraggedRef.current = true;
178
+ const deltaX = (e.clientX - dragStartPosRef.current.x) / scale;
179
+ const deltaY = (e.clientY - dragStartPosRef.current.y) / scale;
180
+ const newPosition = {
181
+ x: startPositionRef.current.x + deltaX,
182
+ y: startPositionRef.current.y + deltaY,
183
+ };
184
+ setCurrentPosition(newPosition);
185
+ if (contentOnlyRef.current && onDragMove) {
186
+ const elementBounds = contentOnlyRef.current.getBoundingClientRect();
187
+ onDragMove(elementId, elementBounds);
188
+ }
182
189
  };
183
- setCurrentPosition(newPosition);
184
- if (contentOnlyRef.current && onDragMove) {
185
- const elementBounds = contentOnlyRef.current.getBoundingClientRect();
186
- onDragMove(elementId, elementBounds);
187
- }
188
- };
189
- const handleDragEnd = () => {
190
- // If we didn't actually drag, set flag to prevent onClick from toggling
191
- if (!hasDraggedRef.current) {
192
- justStoppedWithoutDragRef.current = true;
193
- }
194
- setIsDragging(false);
195
- onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(currentPosition);
196
- // Auto-capture width if not explicitly set
197
- if (width === undefined && contentOnlyRef.current && onWidthChange) {
198
- const currentWidth = contentOnlyRef.current.offsetWidth;
199
- if (currentWidth > 0) {
200
- onWidthChange(Math.round(currentWidth));
190
+ const handleDragEnd = () => {
191
+ // If we didn't actually drag, set flag to prevent onClick from toggling
192
+ if (!hasDraggedRef.current) {
193
+ justStoppedWithoutDragRef.current = true;
201
194
  }
202
- }
203
- };
204
- react_1.default.useEffect(() => {
205
- if (isDragging) {
206
- window.addEventListener('mousemove', handleDragMove);
207
- window.addEventListener('mouseup', handleDragEnd);
208
- return () => {
209
- window.removeEventListener('mousemove', handleDragMove);
210
- window.removeEventListener('mouseup', handleDragEnd);
211
- };
212
- }
213
- }, [isDragging, currentPosition, scale]);
195
+ setIsDragging(false);
196
+ // Use callback form to get latest position
197
+ setCurrentPosition((pos) => {
198
+ onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(pos);
199
+ return pos;
200
+ });
201
+ // Auto-capture width if not explicitly set
202
+ if (width === undefined && contentOnlyRef.current && onWidthChange) {
203
+ const currentWidth = contentOnlyRef.current.offsetWidth;
204
+ if (currentWidth > 0) {
205
+ onWidthChange(Math.round(currentWidth));
206
+ }
207
+ }
208
+ };
209
+ window.addEventListener('mousemove', handleDragMove);
210
+ window.addEventListener('mouseup', handleDragEnd);
211
+ return () => {
212
+ window.removeEventListener('mousemove', handleDragMove);
213
+ window.removeEventListener('mouseup', handleDragEnd);
214
+ };
215
+ }, [isDragging, scale, onDragMove, onPositionChange, onWidthChange, width, elementId]);
214
216
  // Selection handlers
215
217
  const handleElementClick = (e) => {
216
218
  // Don't toggle selection if clicking rotation or width handles
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zuljaman-banner-components",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Shared banner components package for Next.js and AWS Lambda platforms",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",