@contentful/experiences-visual-editor-react 0.0.1-alpha.2 → 0.0.1-alpha.4

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/dist/renderApp.js CHANGED
@@ -37,7 +37,7 @@ function styleInject(css, ref) {
37
37
  }
38
38
  }
39
39
 
40
- var css_248z$7 = "html,\nbody {\n margin: 0;\n padding: 0;\n}\n\n\n/*\n * All of these variables are tokens from Forma-36 and should not be adjusted as these\n * are global variables that may affect multiple places.\n * As our customers may use other design libraries, we try to avoid overlapping global\n * variables by always using the prefix `--exp-builder-` inside this SDK.\n */\n\n\n:root {\n /* Color tokens from Forma 36: https://f36.contentful.com/tokens/color-system */\n --exp-builder-blue100: #e8f5ff;\n --exp-builder-blue200: #ceecff;\n --exp-builder-blue300: #98cbff;\n --exp-builder-blue400: #40a0ff;\n --exp-builder-blue500: #036fe3;\n --exp-builder-blue600: #0059c8;\n --exp-builder-blue700: #0041ab;\n --exp-builder-blue800: #003298;\n --exp-builder-blue900: #002a8e;\n --exp-builder-gray100: #f7f9fa;\n --exp-builder-gray200: #e7ebee;\n --exp-builder-gray300: #cfd9e0;\n --exp-builder-gray400: #aec1cc;\n --exp-builder-gray500: #67728a;\n --exp-builder-gray600: #5a657c;\n --exp-builder-gray700: #414d63;\n --exp-builder-gray800: #1b273a;\n --exp-builder-gray900: #111b2b;\n --exp-builder-purple600: #6c3ecf;\n --exp-builder-red200: #ffe0e0;\n --exp-builder-red800: #7f0010;\n --exp-builder-color-white: #ffffff;\n --exp-builder-glow-primary: 0px 0px 0px 3px #e8f5ff;\n\n /* RGB colors for applying opacity */\n --exp-builder-blue100-rgb: 232, 245, 255;\n --exp-builder-blue300-rgb: 152, 203, 255;\n\n /* Spacing tokens from Forma 36: https://f36.contentful.com/tokens/spacing */\n --exp-builder-spacing-s: 0.75rem;\n --exp-builder-spacing-2xs: 0.25rem;\n\n /* Typography tokens from Forma 36: https://f36.contentful.com/tokens/typography */\n --exp-builder-font-size-l: 1rem;\n --exp-builder-font-size-m: 0.875rem;\n --exp-builder-font-stack-primary: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,\n sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;\n --exp-builder-line-height-condensed: 1.25;\n}\n";
40
+ var css_248z$7 = "html,\nbody {\n margin: 0;\n padding: 0;\n}\n\n/*\n * All of these variables are tokens from Forma-36 and should not be adjusted as these\n * are global variables that may affect multiple places.\n * As our customers may use other design libraries, we try to avoid overlapping global\n * variables by always using the prefix `--exp-builder-` inside this SDK.\n */\n\n:root {\n /* Color tokens from Forma 36: https://f36.contentful.com/tokens/color-system */\n --exp-builder-blue100: #e8f5ff;\n --exp-builder-blue200: #ceecff;\n --exp-builder-blue300: #98cbff;\n --exp-builder-blue400: #40a0ff;\n --exp-builder-blue500: #036fe3;\n --exp-builder-blue600: #0059c8;\n --exp-builder-blue700: #0041ab;\n --exp-builder-blue800: #003298;\n --exp-builder-blue900: #002a8e;\n --exp-builder-gray100: #f7f9fa;\n --exp-builder-gray200: #e7ebee;\n --exp-builder-gray300: #cfd9e0;\n --exp-builder-gray400: #aec1cc;\n --exp-builder-gray500: #67728a;\n --exp-builder-gray600: #5a657c;\n --exp-builder-gray700: #414d63;\n --exp-builder-gray800: #1b273a;\n --exp-builder-gray900: #111b2b;\n --exp-builder-purple600: #6c3ecf;\n --exp-builder-red200: #ffe0e0;\n --exp-builder-red800: #7f0010;\n --exp-builder-color-white: #ffffff;\n --exp-builder-glow-primary: 0px 0px 0px 3px #e8f5ff;\n\n /* RGB colors for applying opacity */\n --exp-builder-blue100-rgb: 232, 245, 255;\n --exp-builder-blue300-rgb: 152, 203, 255;\n\n /* Spacing tokens from Forma 36: https://f36.contentful.com/tokens/spacing */\n --exp-builder-spacing-s: 0.75rem;\n --exp-builder-spacing-2xs: 0.25rem;\n\n /* Typography tokens from Forma 36: https://f36.contentful.com/tokens/typography */\n --exp-builder-font-size-l: 1rem;\n --exp-builder-font-size-m: 0.875rem;\n --exp-builder-font-stack-primary: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,\n sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;\n --exp-builder-line-height-condensed: 1.25;\n}\n";
41
41
  styleInject(css_248z$7);
42
42
 
43
43
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -34360,28 +34360,20 @@ helpers.isText = isText;
34360
34360
 
34361
34361
  const INCOMING_EVENTS$1 = {
34362
34362
  RequestEditorMode: 'requestEditorMode',
34363
- CompositionUpdated: 'componentTreeUpdated',
34363
+ ExperienceUpdated: 'componentTreeUpdated',
34364
34364
  ComponentDraggingChanged: 'componentDraggingChanged',
34365
34365
  ComponentDragCanceled: 'componentDragCanceled',
34366
34366
  ComponentDragStarted: 'componentDragStarted',
34367
34367
  ComponentDragEnded: 'componentDragEnded',
34368
+ ComponentMoveEnded: 'componentMoveEnded',
34368
34369
  CanvasResized: 'canvasResized',
34369
34370
  SelectComponent: 'selectComponent',
34370
34371
  HoverComponent: 'hoverComponent',
34371
34372
  UpdatedEntity: 'updatedEntity',
34372
- /**
34373
- * @deprecated use `AssembliesAdded` instead. This will be removed in version 5.
34374
- * In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
34375
- */
34376
- DesignComponentsAdded: 'designComponentsAdded',
34377
- /**
34378
- * @deprecated use `AssembliesRegistered` instead. This will be removed in version 5.
34379
- * In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
34380
- */
34381
- DesignComponentsRegistered: 'designComponentsRegistered',
34382
34373
  AssembliesAdded: 'assembliesAdded',
34383
34374
  AssembliesRegistered: 'assembliesRegistered',
34384
34375
  InitEditor: 'initEditor',
34376
+ MouseMove: 'mouseMove',
34385
34377
  };
34386
34378
  const CONTENTFUL_COMPONENTS$1 = {
34387
34379
  section: {
@@ -35539,6 +35531,13 @@ class EntityStoreBase {
35539
35531
  }
35540
35532
  return this.entryMap.get(id);
35541
35533
  }
35534
+ toJSON() {
35535
+ return {
35536
+ entryMap: Object.fromEntries(this.entryMap),
35537
+ assetMap: Object.fromEntries(this.assetMap),
35538
+ locale: this.locale,
35539
+ };
35540
+ }
35542
35541
  }
35543
35542
 
35544
35543
  /**
@@ -35787,30 +35786,6 @@ function gatherDeepReferencesFromTree(startingNode, dataSource) {
35787
35786
  return deepReferences;
35788
35787
  }
35789
35788
 
35790
- class DragState {
35791
- constructor() {
35792
- this.isDragStartedOnParent = false;
35793
- this.isDraggingItem = false;
35794
- }
35795
- get isDragging() {
35796
- return this.isDraggingItem;
35797
- }
35798
- get isDragStart() {
35799
- return this.isDragStartedOnParent;
35800
- }
35801
- updateIsDragging(isDraggingItem) {
35802
- this.isDraggingItem = isDraggingItem;
35803
- }
35804
- updateIsDragStartedOnParent(isDragStartedOnParent) {
35805
- this.isDragStartedOnParent = isDragStartedOnParent;
35806
- }
35807
- reset() {
35808
- this.isDraggingItem = false;
35809
- this.isDragStartedOnParent = false;
35810
- }
35811
- }
35812
- var dragState = new DragState();
35813
-
35814
35789
  function _typeof(o) {
35815
35790
  "@babel/helpers - typeof";
35816
35791
 
@@ -46193,8 +46168,8 @@ var classnames = {exports: {}};
46193
46168
  var classnamesExports = classnames.exports;
46194
46169
  var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
46195
46170
 
46196
- var css_248z$6 = ".styles-module_DraggableComponent__m5-dA {\n pointer-events: all;\n position: relative;\n transition: outline 0.2s;\n cursor: grab;\n outline-offset: -2px;\n outline: 2px solid transparent;\n box-sizing: border-box;\n display: flex;\n}\n\n.styles-module_DraggableComponent__m5-dA > * {\n pointer-events: none;\n}\n\n.styles-module_isDragging__WHjPU {\n overflow: hidden;\n}\n\n.styles-module_isDragging__WHjPU * {\n pointer-events: none !important;\n}\n\n.styles-module_isSelected__BzICQ {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_overlay__r4th9 {\n position: absolute;\n display: flex;\n align-items: center;\n min-width: max-content;\n height: 24px;\n z-index: 1;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 14px;\n font-weight: 500;\n background-color: var(--exp-builder-gray500);\n color: var(--exp-builder-color-white);\n border-radius: 0 0 2px 0;\n padding: 4px 12px 4px 12px;\n transition: opacity 0.2s;\n opacity: 0;\n text-wrap: nowrap;\n}\n\n.styles-module_overlayContainer__eiX-5 {\n opacity: 0;\n}\n\n.styles-module_overlayAssembly__tOzZU {\n background-color: var(--exp-builder-purple600);\n}\n\n/* .DraggableComponent:hover .overlay {\n opacity: 1;\n} */\n\n.styles-module_userIsDragging__lqbjG > .styles-module_overlay__r4th9,\n.styles-module_userIsDragging__lqbjG > .styles-module_overlayContainer__eiX-5 {\n opacity: 0 !important;\n}\n\n.styles-module_userIsDragging__lqbjG {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)) > .styles-module_overlay__r4th9 {\n opacity: 1;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover,\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id] {\n outline: 2px dashed var(--exp-builder-gray500);\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)) {\n outline: 2px solid var(--exp-builder-gray500);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover,\n.styles-module_isAssemblyBlock__Y3Avk:hover div[data-rfd-draggable-id],\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id][data-cf-node-block-type^='assembly'] {\n outline: 2px dashed var(--exp-builder-purple600) !important;\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:not(:has(div[data-rfd-draggable-id]:hover)) {\n outline: 2px solid var(--exp-builder-purple600) !important;\n}\n";
46197
- var styles$3 = {"DraggableComponent":"styles-module_DraggableComponent__m5-dA","isDragging":"styles-module_isDragging__WHjPU","isSelected":"styles-module_isSelected__BzICQ","overlay":"styles-module_overlay__r4th9","overlayContainer":"styles-module_overlayContainer__eiX-5","overlayAssembly":"styles-module_overlayAssembly__tOzZU","userIsDragging":"styles-module_userIsDragging__lqbjG","isAssemblyBlock":"styles-module_isAssemblyBlock__Y3Avk"};
46171
+ var css_248z$6 = ".styles-module_DraggableComponent__m5-dA {\n pointer-events: all;\n position: relative;\n transition: outline 0.2s;\n cursor: grab;\n outline-offset: -2px;\n outline: 2px solid transparent;\n box-sizing: border-box;\n display: flex;\n}\n\n.styles-module_DraggableClone__X8zTA {\n outline: 2px solid var(--exp-builder-blue500);\n}\n\n.styles-module_DraggableComponent__m5-dA > * {\n pointer-events: none;\n}\n\n.styles-module_isDragging__WHjPU {\n overflow: hidden;\n}\n\n.styles-module_isDragging__WHjPU * {\n pointer-events: none !important;\n}\n\n.styles-module_isSelected__BzICQ {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_overlay__r4th9 {\n position: absolute;\n display: flex;\n align-items: center;\n min-width: max-content;\n height: 24px;\n z-index: 1;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 14px;\n font-weight: 500;\n background-color: var(--exp-builder-gray500);\n color: var(--exp-builder-color-white);\n border-radius: 0 0 2px 0;\n padding: 4px 12px 4px 12px;\n transition: opacity 0.2s;\n opacity: 0;\n text-wrap: nowrap;\n}\n\n.styles-module_overlayContainer__eiX-5 {\n opacity: 0;\n}\n\n.styles-module_overlayAssembly__tOzZU {\n background-color: var(--exp-builder-purple600);\n}\n\n.styles-module_userIsDragging__lqbjG > .styles-module_overlay__r4th9,\n.styles-module_userIsDragging__lqbjG > .styles-module_overlayContainer__eiX-5 {\n opacity: 0 !important;\n}\n\n.styles-module_userIsDragging__lqbjG {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)) > .styles-module_overlay__r4th9 {\n opacity: 1;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover,\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id] {\n outline: 2px dashed var(--exp-builder-gray500);\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)) {\n outline: 2px solid var(--exp-builder-gray500);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover,\n.styles-module_isAssemblyBlock__Y3Avk:hover div[data-rfd-draggable-id],\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id][data-cf-node-block-type^='assembly'] {\n outline: 2px dashed var(--exp-builder-purple600);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:not(:has(div[data-rfd-draggable-id]:hover)) {\n outline: 2px solid var(--exp-builder-purple600);\n}\n";
46172
+ var styles$3 = {"DraggableComponent":"styles-module_DraggableComponent__m5-dA","DraggableClone":"styles-module_DraggableClone__X8zTA","isDragging":"styles-module_isDragging__WHjPU","isSelected":"styles-module_isSelected__BzICQ","overlay":"styles-module_overlay__r4th9","overlayContainer":"styles-module_overlayContainer__eiX-5","overlayAssembly":"styles-module_overlayAssembly__tOzZU","userIsDragging":"styles-module_userIsDragging__lqbjG","isAssemblyBlock":"styles-module_isAssemblyBlock__Y3Avk"};
46198
46173
  styleInject(css_248z$6);
46199
46174
 
46200
46175
  const SCROLL_STATES = {
@@ -46219,32 +46194,26 @@ const OUTGOING_EVENTS = {
46219
46194
  UpdateHoveredComponentCoordinates: 'updateHoveredComponentCoordinates',
46220
46195
  CanvasScroll: 'canvasScrolling',
46221
46196
  CanvasError: 'canvasError',
46197
+ ComponentMoveStarted: 'componentMoveStarted',
46198
+ ComponentMoveEnded: 'componentMoveEnded',
46222
46199
  OutsideCanvasClick: 'outsideCanvasClick',
46223
46200
  };
46224
46201
  const INCOMING_EVENTS = {
46225
46202
  RequestEditorMode: 'requestEditorMode',
46226
- CompositionUpdated: 'componentTreeUpdated',
46203
+ ExperienceUpdated: 'componentTreeUpdated',
46227
46204
  ComponentDraggingChanged: 'componentDraggingChanged',
46228
46205
  ComponentDragCanceled: 'componentDragCanceled',
46229
46206
  ComponentDragStarted: 'componentDragStarted',
46230
46207
  ComponentDragEnded: 'componentDragEnded',
46208
+ ComponentMoveEnded: 'componentMoveEnded',
46231
46209
  CanvasResized: 'canvasResized',
46232
46210
  SelectComponent: 'selectComponent',
46233
46211
  HoverComponent: 'hoverComponent',
46234
46212
  UpdatedEntity: 'updatedEntity',
46235
- /**
46236
- * @deprecated use `AssembliesAdded` instead. This will be removed in version 5.
46237
- * In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
46238
- */
46239
- DesignComponentsAdded: 'designComponentsAdded',
46240
- /**
46241
- * @deprecated use `AssembliesRegistered` instead. This will be removed in version 5.
46242
- * In the meanwhile, the experience builder will send the old and the new event to support multiple SDK versions.
46243
- */
46244
- DesignComponentsRegistered: 'designComponentsRegistered',
46245
46213
  AssembliesAdded: 'assembliesAdded',
46246
46214
  AssembliesRegistered: 'assembliesRegistered',
46247
46215
  InitEditor: 'initEditor',
46216
+ MouseMove: 'mouseMove',
46248
46217
  };
46249
46218
  const INTERNAL_EVENTS = {
46250
46219
  ComponentsRegistered: 'cfComponentsRegistered',
@@ -46296,15 +46265,6 @@ const ASSEMBLY_NODE_TYPE = 'assembly';
46296
46265
  const ASSEMBLY_DEFAULT_CATEGORY = 'Assemblies';
46297
46266
  const ASSEMBLY_BLOCK_NODE_TYPE = 'assemblyBlock';
46298
46267
  const ASSEMBLY_NODE_TYPES = [ASSEMBLY_NODE_TYPE, ASSEMBLY_BLOCK_NODE_TYPE];
46299
- /** @deprecated use `ASSEMBLY_NODE_TYPE` instead. This will be removed in version 5. */
46300
- const DESIGN_COMPONENT_NODE_TYPE = 'designComponent';
46301
- /** @deprecated use `ASSEMBLY_BLOCK_NODE_TYPE` instead. This will be removed in version 5. */
46302
- const DESIGN_COMPONENT_BLOCK_NODE_TYPE = 'designComponentBlock';
46303
- /** @deprecated use `ASSEMBLY_NODE_TYPES` instead. This will be removed in version 5. */
46304
- const DESIGN_COMPONENT_NODE_TYPES = [
46305
- DESIGN_COMPONENT_NODE_TYPE,
46306
- DESIGN_COMPONENT_BLOCK_NODE_TYPE,
46307
- ];
46308
46268
  const CF_STYLE_ATTRIBUTES = [
46309
46269
  'cfHorizontalAlignment',
46310
46270
  'cfVerticalAlignment',
@@ -46496,8 +46456,13 @@ const create = (createState) => createState ? createImpl(createState) : createIm
46496
46456
 
46497
46457
  const useDraggedItemStore = create((set) => ({
46498
46458
  draggedItem: undefined,
46459
+ domRect: undefined,
46499
46460
  componentId: '',
46500
46461
  isDraggingOnCanvas: false,
46462
+ onBeforeCaptureId: '',
46463
+ mouseX: 0,
46464
+ mouseY: 0,
46465
+ scrollY: 0,
46501
46466
  setComponentId(id) {
46502
46467
  set({ componentId: id });
46503
46468
  },
@@ -46507,6 +46472,18 @@ const useDraggedItemStore = create((set) => ({
46507
46472
  setDraggingOnCanvas: (isDraggingOnCanvas) => {
46508
46473
  set({ isDraggingOnCanvas });
46509
46474
  },
46475
+ setOnBeforeCaptureId: (onBeforeCaptureId) => {
46476
+ set({ onBeforeCaptureId });
46477
+ },
46478
+ setMousePosition(x, y) {
46479
+ set({ mouseX: x, mouseY: y });
46480
+ },
46481
+ setDomRect(domRect) {
46482
+ set({ domRect });
46483
+ },
46484
+ setScrollY(y) {
46485
+ set({ scrollY: y });
46486
+ },
46510
46487
  }));
46511
46488
 
46512
46489
  const DRAGGABLE_HEIGHT = 30;
@@ -46514,7 +46491,9 @@ const DRAGGABLE_WIDTH = 50;
46514
46491
  const DRAG_PADDING = 4;
46515
46492
  const ROOT_ID = 'root';
46516
46493
  const COMPONENT_LIST_ID = 'component-list';
46494
+ const NEW_COMPONENT_ID = 'ctfl-new-draggable';
46517
46495
  const CTFL_ZONE_ID = 'data-ctfl-zone-id';
46496
+ const CTFL_DRAGGING_ELEMENT = 'data-ctfl-dragging-element';
46518
46497
  const HITBOX = {
46519
46498
  WIDTH: 80,
46520
46499
  HEIGHT: 20,
@@ -46548,6 +46527,11 @@ var HitboxDirection;
46548
46527
  HitboxDirection[HitboxDirection["SELF_VERTICAL"] = 4] = "SELF_VERTICAL";
46549
46528
  HitboxDirection[HitboxDirection["SELF_HORIZONTAL"] = 5] = "SELF_HORIZONTAL";
46550
46529
  })(HitboxDirection || (HitboxDirection = {}));
46530
+ var DraggablePosition;
46531
+ (function (DraggablePosition) {
46532
+ DraggablePosition[DraggablePosition["CENTERED"] = 0] = "CENTERED";
46533
+ DraggablePosition[DraggablePosition["MOUSE_POSITION"] = 1] = "MOUSE_POSITION";
46534
+ })(DraggablePosition || (DraggablePosition = {}));
46551
46535
 
46552
46536
  /**
46553
46537
  * Calculate the size and position of the dropzone indicator
@@ -46651,6 +46635,28 @@ const Placeholder = (props) => {
46651
46635
  } })));
46652
46636
  };
46653
46637
 
46638
+ function useDraggablePosition({ draggableId, draggableRef, position }) {
46639
+ const isDraggingOnCanvas = useDraggedItemStore((state) => state.isDraggingOnCanvas);
46640
+ const draggingId = useDraggedItemStore((state) => state.onBeforeCaptureId);
46641
+ const preDragDomRect = useDraggedItemStore((state) => state.domRect);
46642
+ reactExports.useEffect(() => {
46643
+ const el = draggableRef?.current;
46644
+ if (!isDraggingOnCanvas || draggingId !== draggableId || !el) {
46645
+ return;
46646
+ }
46647
+ const isCentered = position === DraggablePosition.CENTERED || !preDragDomRect;
46648
+ const domRect = isCentered ? el.getBoundingClientRect() : preDragDomRect;
46649
+ const { mouseX, mouseY } = useDraggedItemStore.getState();
46650
+ const top = isCentered ? mouseY - domRect.height / 2 : domRect.top;
46651
+ const left = isCentered ? mouseX - domRect.width / 2 : domRect.left;
46652
+ el.style.position = 'fixed';
46653
+ el.style.left = `${left}px`;
46654
+ el.style.top = `${top}px`;
46655
+ el.style.width = `${domRect.width}px`;
46656
+ el.style.height = `${domRect.height}px`;
46657
+ }, [draggableRef, draggableId, isDraggingOnCanvas, draggingId, position, preDragDomRect]);
46658
+ }
46659
+
46654
46660
  function getStyle$2(style, snapshot) {
46655
46661
  if (!snapshot.isDropAnimating) {
46656
46662
  return style;
@@ -46661,8 +46667,18 @@ function getStyle$2(style, snapshot) {
46661
46667
  transitionDuration: `0.001s`,
46662
46668
  };
46663
46669
  }
46664
- const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, label, coordinates, userIsDragging, style, wrapperProps, isContainer, blockId, isDragDisabled = false, placeholder, ...rest }) => {
46665
- return (React.createElement(PublicDraggable, { key: id, draggableId: id, index: index, isDragDisabled: isDragDisabled }, (provided, snapshot) => (React.createElement("div", { "data-ctfl-draggable-id": id, "data-test-id": `draggable-${blockId ?? 'node'}`, ref: provided.innerRef, ...wrapperProps, ...provided.draggableProps, ...provided.dragHandleProps, ...rest, className: classNames(styles$3.DraggableComponent, wrapperProps.className, {
46670
+ const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, coordinates, userIsDragging, style, wrapperProps, isContainer, blockId, isDragDisabled = false, placeholder, definition, ...rest }) => {
46671
+ const ref = reactExports.useRef(null);
46672
+ const setDomRect = useDraggedItemStore((state) => state.setDomRect);
46673
+ useDraggablePosition({
46674
+ draggableId: id,
46675
+ draggableRef: ref,
46676
+ position: DraggablePosition.MOUSE_POSITION,
46677
+ });
46678
+ return (React.createElement(PublicDraggable, { key: id, draggableId: id, index: index, isDragDisabled: isDragDisabled }, (provided, snapshot) => (React.createElement("div", { "data-ctfl-draggable-id": id, "data-test-id": `draggable-${blockId ?? 'node'}`, ref: (refNode) => {
46679
+ provided?.innerRef(refNode);
46680
+ ref.current = refNode;
46681
+ }, ...wrapperProps, ...provided.draggableProps, ...provided.dragHandleProps, ...rest, className: classNames(styles$3.DraggableComponent, wrapperProps.className, {
46666
46682
  [styles$3.isAssemblyBlock]: isAssemblyBlock,
46667
46683
  [styles$3.isDragging]: snapshot.isDragging,
46668
46684
  [styles$3.isSelected]: isSelected,
@@ -46670,8 +46686,14 @@ const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSe
46670
46686
  }), style: {
46671
46687
  ...style,
46672
46688
  ...getStyle$2(provided.draggableProps.style, snapshot),
46689
+ }, onMouseDown: (e) => {
46690
+ if (isDragDisabled) {
46691
+ return;
46692
+ }
46693
+ e.stopPropagation();
46694
+ setDomRect(e.currentTarget.getBoundingClientRect());
46673
46695
  }, onClick: onClick },
46674
- React.createElement(Tooltip, { id: id, coordinates: coordinates, isAssemblyBlock: isAssemblyBlock, isContainer: isContainer, label: label }),
46696
+ React.createElement(Tooltip, { id: id, coordinates: coordinates, isAssemblyBlock: isAssemblyBlock, isContainer: isContainer, label: definition.name || 'No label specified' }),
46675
46697
  React.createElement(Placeholder, { ...placeholder, id: id }),
46676
46698
  children))));
46677
46699
  };
@@ -50375,14 +50397,10 @@ const useEntityStore = create((set) => ({
50375
50397
  const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, renderDropzone, definition, userIsDragging, }) => {
50376
50398
  const unboundValues = useEditorStore((state) => state.unboundValues);
50377
50399
  const dataSource = useEditorStore((state) => state.dataSource);
50378
- const newComponentId = useDraggedItemStore((state) => state.componentId);
50379
- const isDraggingNewCompont = !!newComponentId;
50380
50400
  const entityStore = useEntityStore((state) => state.entityStore);
50381
50401
  const props = reactExports.useMemo(() => {
50382
50402
  // Don't enrich the assembly wrapper node with props
50383
- if (!definition ||
50384
- node.type === DESIGN_COMPONENT_NODE_TYPE ||
50385
- node.type === ASSEMBLY_NODE_TYPE) {
50403
+ if (!definition || node.type === ASSEMBLY_NODE_TYPE) {
50386
50404
  return {};
50387
50405
  }
50388
50406
  return Object.entries(definition.variables).reduce((acc, [variableName, variableDefinition]) => {
@@ -50509,7 +50527,6 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
50509
50527
  minHeight: EMPTY_CONTAINER_HEIGHT,
50510
50528
  }),
50511
50529
  ...(userIsDragging &&
50512
- isDraggingNewCompont &&
50513
50530
  isContentfulStructureComponent(node?.data.blockId) &&
50514
50531
  node?.data.blockId !== CONTENTFUL_COMPONENTS.columns.id && {
50515
50532
  padding: addExtraDropzonePadding(componentStyles.padding?.toString() || '0 0 0 0'),
@@ -51224,7 +51241,7 @@ const deserializeAssemblyNode = ({ node, nodeId, nodeLocation, parentId, assembl
51224
51241
  };
51225
51242
  };
51226
51243
  const resolveAssembly = ({ node, entityStore, }) => {
51227
- if (node.type !== DESIGN_COMPONENT_NODE_TYPE && node.type !== ASSEMBLY_NODE_TYPE) {
51244
+ if (node.type !== ASSEMBLY_NODE_TYPE) {
51228
51245
  return node;
51229
51246
  }
51230
51247
  const componentId = node.data.blockId;
@@ -51235,7 +51252,9 @@ const resolveAssembly = ({ node, entityStore, }) => {
51235
51252
  });
51236
51253
  return node;
51237
51254
  }
51238
- const componentFields = entityStore?.getValue(assembly, ['fields']);
51255
+ const componentFields = entityStore?.getValue(assembly, [
51256
+ 'fields',
51257
+ ]);
51239
51258
  if (!componentFields) {
51240
51259
  console.warn(`Entry for assembly with ID '${componentId}' not found`, { entityStore });
51241
51260
  return node;
@@ -51269,8 +51288,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
51269
51288
  const areEntitiesFetched = useEntityStore((state) => state.areEntitiesFetched);
51270
51289
  const entityStore = useEntityStore((state) => state.entityStore);
51271
51290
  const node = reactExports.useMemo(() => {
51272
- if ((rawNode.type === DESIGN_COMPONENT_NODE_TYPE || rawNode.type === ASSEMBLY_NODE_TYPE) &&
51273
- areEntitiesFetched) {
51291
+ if (rawNode.type === ASSEMBLY_NODE_TYPE && areEntitiesFetched) {
51274
51292
  return resolveAssembly({
51275
51293
  node: rawNode,
51276
51294
  entityStore,
@@ -51280,8 +51298,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
51280
51298
  }, [areEntitiesFetched, rawNode, entityStore]);
51281
51299
  const componentRegistration = reactExports.useMemo(() => {
51282
51300
  const registration = componentRegistry.get(node.data.blockId);
51283
- if ((node.type === DESIGN_COMPONENT_NODE_TYPE || node.type === ASSEMBLY_NODE_TYPE) &&
51284
- !registration) {
51301
+ if (node.type === ASSEMBLY_NODE_TYPE && !registration) {
51285
51302
  return createAssemblyRegistration({
51286
51303
  definitionId: node.data.blockId,
51287
51304
  component: Assembly,
@@ -51305,7 +51322,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
51305
51322
  const { editorMode, renderDropzone: _renderDropzone, ...otherComponentProps } = componentProps;
51306
51323
  const elementToRender = builtInComponents.includes(node.data.blockId || '')
51307
51324
  ? (dragProps) => React.createElement(componentRegistration.component, { ...dragProps, ...componentProps })
51308
- : node.type === DESIGN_COMPONENT_NODE_TYPE || node.type === ASSEMBLY_NODE_TYPE
51325
+ : node.type === ASSEMBLY_NODE_TYPE
51309
51326
  ? // Assembly.tsx requires renderDropzone and editorMode as well
51310
51327
  () => React.createElement(componentRegistration.component, componentProps)
51311
51328
  : () => React.createElement(componentRegistration.component, otherComponentProps);
@@ -51314,7 +51331,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
51314
51331
  componentId,
51315
51332
  elementToRender,
51316
51333
  wrapperProps,
51317
- label: componentRegistration.definition.name,
51334
+ definition: componentRegistration.definition,
51318
51335
  };
51319
51336
  };
51320
51337
 
@@ -51328,7 +51345,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
51328
51345
  * component.
51329
51346
  */
51330
51347
  const DraggableChildComponent = (props) => {
51331
- const { elementToRender, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, label, coordinates, userIsDragging, style, isContainer, blockId, isDragDisabled = false, wrapperProps, } = props;
51348
+ const { elementToRender, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, coordinates, userIsDragging, style, isContainer, blockId, isDragDisabled = false, wrapperProps, definition, } = props;
51332
51349
  return (React.createElement(PublicDraggable, { key: id, draggableId: id, index: index, isDragDisabled: isDragDisabled }, (provided, snapshot) => elementToRender({
51333
51350
  ['data-ctfl-draggable-id']: id,
51334
51351
  ['data-test-id']: `draggable-${blockId}`,
@@ -51347,11 +51364,11 @@ const DraggableChildComponent = (props) => {
51347
51364
  ...provided.draggableProps.style,
51348
51365
  },
51349
51366
  onClick,
51350
- Tooltip: (React.createElement(Tooltip, { id: id, coordinates: coordinates, isAssemblyBlock: isAssemblyBlock, isContainer: isContainer, label: label })),
51367
+ Tooltip: (React.createElement(Tooltip, { id: id, coordinates: coordinates, isAssemblyBlock: isAssemblyBlock, isContainer: isContainer, label: definition.name || 'No label specified' })),
51351
51368
  })));
51352
51369
  };
51353
51370
 
51354
- var css_248z$2 = ".styles-module_container__te-1H {\n margin-left: auto;\n margin-right: auto;\n position: relative;\n height: 100%;\n outline-offset: -2px;\n outline: 2px solid transparent;\n width: 100%;\n transition: outline 0.2s;\n pointer-events: all;\n}\n\n.styles-module_container__te-1H:not(.styles-module_isRoot__5cn-i) {\n outline-offset: -1px;\n}\n\n.styles-module_isRoot__5cn-i,\n.styles-module_isEmptyCanvas__0XHZR {\n flex: 1;\n}\n\n.styles-module_isEmptyZone__zVpnZ {\n min-height: 80px;\n}\n\n.styles-module_isDragging__Gm8v5:not(.styles-module_isRoot__5cn-i) {\n outline: 2px dashed var(--exp-builder-blue500);\n}\n\n.styles-module_isDestination__5sCQx:not(.styles-module_isRoot__5cn-i) {\n outline: 2px dashed var(--exp-builder-blue500);\n background-color: rgba(var(--exp-builder-blue100-rgb), 0.5);\n}\n\n.styles-module_hitbox__YQ-1Z {\n position: fixed;\n pointer-events: all !important;\n}\n";
51371
+ var css_248z$2 = ".styles-module_container__te-1H {\n margin-left: auto;\n margin-right: auto;\n position: relative;\n height: 100%;\n outline-offset: -2px;\n outline: 2px solid transparent;\n width: 100%;\n background-color: transparent;\n transition:\n outline 0.2s,\n background-color 0.2s;\n pointer-events: all;\n}\n\n.styles-module_container__te-1H:not(.styles-module_isRoot__5cn-i) {\n outline-offset: -1px;\n}\n\n.styles-module_isRoot__5cn-i,\n.styles-module_isEmptyCanvas__0XHZR {\n flex: 1;\n}\n\n.styles-module_isEmptyZone__zVpnZ {\n min-height: 80px;\n}\n\n.styles-module_isDragging__Gm8v5:not(.styles-module_isRoot__5cn-i) {\n outline: 2px dashed var(--exp-builder-gray300);\n}\n\n.styles-module_isDestination__5sCQx:not(.styles-module_isRoot__5cn-i) {\n outline: 2px dashed var(--exp-builder-blue400);\n background-color: rgba(var(--exp-builder-blue100-rgb), 0.5);\n z-index: 100;\n}\n\n.styles-module_hitbox__YQ-1Z {\n position: fixed;\n pointer-events: all !important;\n}\n";
51355
51372
  var styles$2 = {"container":"styles-module_container__te-1H","isRoot":"styles-module_isRoot__5cn-i","isEmptyCanvas":"styles-module_isEmptyCanvas__0XHZR","isEmptyZone":"styles-module_isEmptyZone__zVpnZ","isDragging":"styles-module_isDragging__Gm8v5","isDestination":"styles-module_isDestination__5sCQx","hitbox":"styles-module_hitbox__YQ-1Z"};
51356
51373
  styleInject(css_248z$2);
51357
51374
 
@@ -52314,7 +52331,7 @@ function treeVisit(initialNode, onNode) {
52314
52331
  }
52315
52332
 
52316
52333
  const isAssemblyNode = (node) => {
52317
- return node.type === DESIGN_COMPONENT_NODE_TYPE || node.type === ASSEMBLY_NODE_TYPE;
52334
+ return node.type === ASSEMBLY_NODE_TYPE;
52318
52335
  };
52319
52336
  const useTreeStore = create((set, get) => ({
52320
52337
  tree: {
@@ -52460,7 +52477,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52460
52477
  return {
52461
52478
  width,
52462
52479
  height: HEIGHT,
52463
- top: top - calcOffsetDepth(zoneDepth),
52480
+ top: top - calcOffsetDepth(zoneDepth) - scrollY,
52464
52481
  left,
52465
52482
  zIndex: 100 + zoneDepth,
52466
52483
  };
@@ -52468,7 +52485,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52468
52485
  return {
52469
52486
  width,
52470
52487
  height: HEIGHT,
52471
- top: bottom + calcOffsetDepth(zoneDepth),
52488
+ top: bottom + calcOffsetDepth(zoneDepth) - scrollY,
52472
52489
  left,
52473
52490
  zIndex: 100 + zoneDepth,
52474
52491
  };
@@ -52477,7 +52494,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52477
52494
  width: WIDTH,
52478
52495
  height: height - HEIGHT,
52479
52496
  left: left - calcOffsetDepth(zoneDepth) - WIDTH / 2,
52480
- top: top + HEIGHT / 2,
52497
+ top: top + HEIGHT / 2 - scrollY,
52481
52498
  zIndex: 100 + zoneDepth,
52482
52499
  };
52483
52500
  case HitboxDirection.RIGHT:
@@ -52485,7 +52502,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52485
52502
  width: WIDTH,
52486
52503
  height: height - HEIGHT,
52487
52504
  left: right - calcOffsetDepth(zoneDepth) - WIDTH / 2,
52488
- top: top + HEIGHT / 2,
52505
+ top: top + HEIGHT / 2 - scrollY,
52489
52506
  zIndex: 100 + zoneDepth,
52490
52507
  };
52491
52508
  case HitboxDirection.SELF_VERTICAL: {
@@ -52497,7 +52514,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52497
52514
  width,
52498
52515
  height: selfHeight,
52499
52516
  left,
52500
- top: top + height / 2 - selfHeight / 2,
52517
+ top: top + height / 2 - selfHeight / 2 - scrollY,
52501
52518
  zIndex: 1000 + zoneDepth,
52502
52519
  };
52503
52520
  }
@@ -52509,7 +52526,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52509
52526
  width: width - DRAGGABLE_WIDTH * 2,
52510
52527
  height,
52511
52528
  left: left + (DRAGGABLE_WIDTH * 2) / 2,
52512
- top,
52529
+ top: top - scrollY,
52513
52530
  zIndex: 1000 + zoneDepth,
52514
52531
  };
52515
52532
  }
@@ -52521,6 +52538,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect }) => {
52521
52538
  const Hitboxes = ({ zoneId, parentZoneId, enableRootHitboxes }) => {
52522
52539
  const tree = useTreeStore((state) => state.tree);
52523
52540
  const isDraggingOnCanvas = useDraggedItemStore((state) => state.isDraggingOnCanvas);
52541
+ const scrollY = useDraggedItemStore((state) => state.scrollY);
52524
52542
  const zoneDepth = reactExports.useMemo(() => getItemDepthFromNode({ id: parentZoneId }, tree.root), [tree, parentZoneId]);
52525
52543
  const [fetchDomRect, setFetchDomRect] = reactExports.useState(Date.now());
52526
52544
  reactExports.useEffect(() => {
@@ -52546,10 +52564,11 @@ const Hitboxes = ({ zoneId, parentZoneId, enableRootHitboxes }) => {
52546
52564
  const isVertical = zoneDirection === 'vertical';
52547
52565
  const isRoot = parentZoneId === ROOT_ID;
52548
52566
  const showRootHitboxes = isRoot && enableRootHitboxes;
52549
- const getStyles = reactExports.useCallback((direction) => getHitboxStyles({ direction, zoneDepth, domRect }), [zoneDepth, domRect]);
52567
+ const getStyles = reactExports.useCallback((direction) => getHitboxStyles({ direction, zoneDepth, domRect, scrollY }), [zoneDepth, domRect, scrollY]);
52550
52568
  const ActiveHitboxes = (React.createElement(React.Fragment, null,
52551
52569
  React.createElement("div", { "data-ctfl-zone-id": zoneId, className: styles$2.hitbox, style: getStyles(isVertical ? HitboxDirection.SELF_VERTICAL : HitboxDirection.SELF_HORIZONTAL) }),
52552
- showRootHitboxes ? (React.createElement("div", { "data-ctfl-zone-id": parentZoneId, className: styles$2.hitbox, style: getStyles(HitboxDirection.BOTTOM) })) : (React.createElement(React.Fragment, null,
52570
+ showRootHitboxes && (React.createElement("div", { "data-ctfl-zone-id": parentZoneId, className: styles$2.hitbox, style: getStyles(HitboxDirection.BOTTOM) })),
52571
+ !isRoot && (React.createElement(React.Fragment, null,
52553
52572
  React.createElement("div", { "data-ctfl-zone-id": parentZoneId, className: styles$2.hitbox, style: getStyles(isVertical ? HitboxDirection.TOP : HitboxDirection.LEFT) }),
52554
52573
  React.createElement("div", { "data-ctfl-zone-id": parentZoneId, className: styles$2.hitbox, style: getStyles(isVertical ? HitboxDirection.BOTTOM : HitboxDirection.RIGHT) })))));
52555
52574
  if (!hitboxContainer) {
@@ -52561,7 +52580,7 @@ const Hitboxes = ({ zoneId, parentZoneId, enableRootHitboxes }) => {
52561
52580
  const EditorBlock = ({ node: rawNode, resolveDesignValue, renderDropzone, draggingNewComponent, index, zoneId, userIsDragging, placeholder, }) => {
52562
52581
  const setSelectedNodeId = useEditorStore((state) => state.setSelectedNodeId);
52563
52582
  const selectedNodeId = useEditorStore((state) => state.selectedNodeId);
52564
- const { node, componentId, wrapperProps, label, elementToRender } = useComponent({
52583
+ const { node, componentId, wrapperProps, definition, elementToRender } = useComponent({
52565
52584
  node: rawNode,
52566
52585
  resolveDesignValue,
52567
52586
  renderDropzone,
@@ -52574,7 +52593,7 @@ const EditorBlock = ({ node: rawNode, resolveDesignValue, renderDropzone, draggi
52574
52593
  const isAssembly = node.type === ASSEMBLY_NODE_TYPE;
52575
52594
  const isStructureComponent = isContentfulStructureComponent(node.data.blockId);
52576
52595
  const isRootComponent = zoneId === ROOT_ID;
52577
- const enableRootHitboxes = isRootComponent && !draggingNewComponent;
52596
+ const enableRootHitboxes = isRootComponent && !!draggingNewComponent;
52578
52597
  const onClick = (e) => {
52579
52598
  e.stopPropagation();
52580
52599
  if (!userIsDragging) {
@@ -52594,10 +52613,10 @@ const EditorBlock = ({ node: rawNode, resolveDesignValue, renderDropzone, draggi
52594
52613
  };
52595
52614
  if (node.data.blockId === CONTENTFUL_COMPONENTS.singleColumn.id) {
52596
52615
  return (React.createElement(React.Fragment, null,
52597
- React.createElement(DraggableChildComponent, { elementToRender: elementToRender, label: label || 'No Label Specified', id: componentId, index: index, isAssemblyBlock: isAssemblyBlock, isDragDisabled: isSingleColumn, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick }),
52616
+ React.createElement(DraggableChildComponent, { elementToRender: elementToRender, id: componentId, index: index, isAssemblyBlock: isAssemblyBlock, isDragDisabled: isSingleColumn, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick, definition: definition }),
52598
52617
  isStructureComponent && userIsDragging && (React.createElement(Hitboxes, { parentZoneId: zoneId, zoneId: componentId, enableRootHitboxes: enableRootHitboxes }))));
52599
52618
  }
52600
- return (React.createElement(DraggableComponent, { placeholder: placeholder, label: label || 'No Label Specified', id: componentId, index: index, isAssemblyBlock: isAssemblyBlock, isDragDisabled: isAssemblyBlock, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick },
52619
+ return (React.createElement(DraggableComponent, { placeholder: placeholder, definition: definition, id: componentId, index: index, isAssemblyBlock: isAssemblyBlock, isDragDisabled: isAssemblyBlock, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick },
52601
52620
  elementToRender(),
52602
52621
  isStructureComponent && userIsDragging && (React.createElement(Hitboxes, { parentZoneId: zoneId, zoneId: componentId, enableRootHitboxes: enableRootHitboxes }))));
52603
52622
  };
@@ -52616,7 +52635,7 @@ const EmptyContainer = ({ isDragging }) => {
52616
52635
  React.createElement("rect", { width: "11.676", height: "11.676", x: "18.011", y: "18.625", rx: "1.621", transform: "rotate(45 18.01 18.625)" }),
52617
52636
  React.createElement("rect", { width: "11.676", height: "11.676", x: "30.557", y: "10.131", rx: "1.621", transform: "rotate(60 30.557 10.13)" }),
52618
52637
  React.createElement("path", { fill: "#fff", stroke: "#fff", strokeWidth: ".243", d: "M31.113 17.038a.463.463 0 0 0-.683-.517l-1.763 1.032-1.033-1.763a.464.464 0 0 0-.8.469l1.034 1.763-1.763 1.033a.463.463 0 1 0 .468.8l1.763-1.033 1.033 1.763a.463.463 0 1 0 .8-.469l-1.033-1.763 1.763-1.033a.463.463 0 0 0 .214-.282Z" })),
52619
- React.createElement("span", { className: styles$1.label }, "Add elements to begin")));
52638
+ React.createElement("span", { className: styles$1.label }, "Add components to begin")));
52620
52639
  };
52621
52640
 
52622
52641
  const getZoneParents = (zoneId) => {
@@ -52692,7 +52711,7 @@ const EditorBlockClone = ({ node: rawNode, resolveDesignValue, snapshot, provide
52692
52711
  if (isSingleColumn) {
52693
52712
  return elementToRender();
52694
52713
  }
52695
- return (React.createElement("div", { ref: provided?.innerRef, ...wrapperProps, ...provided?.draggableProps, ...provided?.dragHandleProps, className: classNames(styles$3.DraggableComponent, wrapperProps.className, {
52714
+ return (React.createElement("div", { ref: provided?.innerRef, "data-ctfl-dragging-element": true, ...wrapperProps, ...provided?.draggableProps, ...provided?.dragHandleProps, className: classNames(styles$3.DraggableComponent, wrapperProps.className, styles$3.DraggableClone, {
52696
52715
  [styles$3.isAssemblyBlock]: isAssemblyBlock,
52697
52716
  [styles$3.isDragging]: snapshot?.isDragging,
52698
52717
  }), style: getStyle$1(provided?.draggableProps.style, snapshot) }, elementToRender()));
@@ -52729,8 +52748,7 @@ function Dropzone({ node, zoneId, resolveDesignValue, className, WrapperComponen
52729
52748
  const isRootZone = zoneId === ROOT_ID;
52730
52749
  const isDestination = draggedDestinationId === zoneId;
52731
52750
  const isEmptyCanvas = isRootZone && !content.length;
52732
- const isAssembly = DESIGN_COMPONENT_NODE_TYPES.includes(node?.type || '') ||
52733
- ASSEMBLY_NODE_TYPES.includes(node?.type || '');
52751
+ const isAssembly = ASSEMBLY_NODE_TYPES.includes(node?.type || '');
52734
52752
  // To avoid a circular dependency, we create the recursive rendering function here and trickle it down
52735
52753
  const renderDropzone = reactExports.useCallback((node, props) => {
52736
52754
  return (React.createElement(Dropzone, { zoneId: node.data.id, node: node, resolveDesignValue: resolveDesignValue, ...props }));
@@ -52741,13 +52759,30 @@ function Dropzone({ node, zoneId, resolveDesignValue, className, WrapperComponen
52741
52759
  if (!resolveDesignValue) {
52742
52760
  return null;
52743
52761
  }
52744
- // Don't trigger the dropzone when it's the root because then the only hit boxes that show up will be root level zones
52745
- // Exception 1: If it comes from the component list (because we want the component list components to work for all zones
52746
- // Exception 2: If it's a child of a root level zone (because we want to be able to re-order root level containers)
52762
+ /**
52763
+ * The Rules of Dropzones
52764
+ *
52765
+ * 1. A dropzone is disabled unless the mouse is hovering over it
52766
+ *
52767
+ * 2. Dragging a new component onto the canvas has no addtional rules
52768
+ * besides rule #1
52769
+ *
52770
+ * 3. Dragging a component that is a direct descendant of the root
52771
+ * (parentId === ROOT_ID) then only the Root Dropzone is enabled
52772
+ *
52773
+ * 4. Dragging a nested component (parentId !== ROOT_ID) then the Root
52774
+ * Dropzone is disabled, all other Dropzones follow rule #1
52775
+ *
52776
+ * 5. Assemblies and the SingleColumn component are always disabled
52777
+ *
52778
+ */
52747
52779
  const isDropzoneEnabled = () => {
52748
52780
  if (node?.data.blockId === CONTENTFUL_COMPONENTS.columns.id) {
52749
52781
  return false;
52750
52782
  }
52783
+ if (isAssembly) {
52784
+ return false;
52785
+ }
52751
52786
  if (isDraggingNewComponent) {
52752
52787
  return isHoveringZone;
52753
52788
  }
@@ -52790,6 +52825,12 @@ function getStyle(style, snapshot) {
52790
52825
  };
52791
52826
  }
52792
52827
  const DraggableContainer = ({ id }) => {
52828
+ const ref = reactExports.useRef(null);
52829
+ useDraggablePosition({
52830
+ draggableId: id,
52831
+ draggableRef: ref,
52832
+ position: DraggablePosition.CENTERED,
52833
+ });
52793
52834
  return (React.createElement("div", { id: COMPONENT_LIST_ID, style: {
52794
52835
  position: 'absolute',
52795
52836
  top: 0,
@@ -52798,7 +52839,10 @@ const DraggableContainer = ({ id }) => {
52798
52839
  zIndex: -1,
52799
52840
  } },
52800
52841
  React.createElement(ConnectedDroppable$1, { droppableId: COMPONENT_LIST_ID, isDropDisabled: true }, (provided) => (React.createElement("div", { ...provided.droppableProps, ref: provided.innerRef },
52801
- React.createElement(PublicDraggable, { draggableId: id, key: id, index: 0 }, (provided, snapshot) => (React.createElement("div", { id: "item", ref: provided.innerRef, ...provided.draggableProps, ...provided.dragHandleProps, style: {
52842
+ React.createElement(PublicDraggable, { draggableId: id, key: id, index: 0 }, (provided, snapshot) => (React.createElement("div", { id: NEW_COMPONENT_ID, "data-ctfl-dragging-element": true, ref: (node) => {
52843
+ provided.innerRef(node);
52844
+ ref.current = node;
52845
+ }, ...provided.draggableProps, ...provided.dragHandleProps, style: {
52802
52846
  ...getStyle(provided.draggableProps.style, snapshot),
52803
52847
  width: DRAGGABLE_WIDTH,
52804
52848
  height: DRAGGABLE_HEIGHT,
@@ -52966,8 +53010,7 @@ class MouseOverHandler {
52966
53010
  };
52967
53011
  }
52968
53012
  getBoundingClientRect(element) {
52969
- const isAssembly = element.getAttribute('data-cf-node-block-type') === DESIGN_COMPONENT_NODE_TYPE ||
52970
- element.getAttribute('data-cf-node-block-type') === ASSEMBLY_NODE_TYPE;
53013
+ const isAssembly = element.getAttribute('data-cf-node-block-type') === ASSEMBLY_NODE_TYPE;
52971
53014
  if (!isAssembly) {
52972
53015
  return element.getBoundingClientRect();
52973
53016
  }
@@ -53018,39 +53061,74 @@ const sendHoveredComponentCoordinates = (instanceId) => {
53018
53061
  mouseOverHandler.handleMouseMove(selectedElement || null);
53019
53062
  };
53020
53063
 
53021
- function updateDraggableElement(x, y) {
53022
- const container = document.querySelector('#component-list');
53023
- if (!container) {
53024
- return;
53064
+ class DragState {
53065
+ constructor() {
53066
+ this.isDragStartedOnParent = false;
53067
+ this.isDraggingItem = false;
53068
+ }
53069
+ get isDragging() {
53070
+ return this.isDraggingItem;
53071
+ }
53072
+ get isDraggingOnParent() {
53073
+ return this.isDragStartedOnParent;
53074
+ }
53075
+ updateIsDragging(isDraggingItem) {
53076
+ this.isDraggingItem = isDraggingItem;
53077
+ }
53078
+ updateIsDragStartedOnParent(isDragStartedOnParent) {
53079
+ this.isDragStartedOnParent = isDragStartedOnParent;
53080
+ }
53081
+ resetState() {
53082
+ this.isDraggingItem = false;
53083
+ this.isDragStartedOnParent = false;
53025
53084
  }
53026
- container.style.setProperty('top', `${y}px`);
53027
- container.style.setProperty('left', `${x}px`);
53028
53085
  }
53029
- function simulateMouseEvent(coordX, coordY, eventName = 'mousemove') {
53030
- const element = document.querySelector('#item');
53031
- if (!dragState.isDragStart) {
53032
- return;
53086
+
53087
+ class SimulateDnD extends DragState {
53088
+ constructor() {
53089
+ super();
53090
+ this.draggingElement = null;
53033
53091
  }
53034
- if (!dragState.isDragging) {
53035
- updateDraggableElement(coordX, coordY);
53036
- eventName = 'mousedown';
53037
- dragState.updateIsDragging(true);
53092
+ setupDrag() {
53093
+ this.updateIsDragStartedOnParent(true);
53038
53094
  }
53039
- const options = {
53040
- bubbles: true,
53041
- cancelable: true,
53042
- view: window,
53043
- pageX: 0,
53044
- pageY: 0,
53045
- clientX: coordX - DRAGGABLE_WIDTH / 2,
53046
- clientY: coordY - DRAGGABLE_HEIGHT / 2 - window.scrollY,
53047
- };
53048
- if (!element) {
53049
- return;
53095
+ startDrag(coordX, coordY) {
53096
+ this.draggingElement = document.getElementById(NEW_COMPONENT_ID);
53097
+ this.updateIsDragging(true);
53098
+ this.simulateMouseEvent(coordX, coordY, 'mousedown');
53099
+ }
53100
+ updateDrag(coordX, coordY) {
53101
+ if (!this.draggingElement) {
53102
+ this.draggingElement = document.querySelector(`[${CTFL_DRAGGING_ELEMENT}]`);
53103
+ }
53104
+ this.simulateMouseEvent(coordX, coordY);
53105
+ }
53106
+ endDrag(coordX, coordY) {
53107
+ this.simulateMouseEvent(coordX, coordY, 'mouseup');
53108
+ this.reset();
53109
+ }
53110
+ reset() {
53111
+ this.draggingElement = null;
53112
+ this.resetState();
53113
+ }
53114
+ simulateMouseEvent(coordX, coordY, eventName = 'mousemove') {
53115
+ if (!this.draggingElement) {
53116
+ return;
53117
+ }
53118
+ const options = {
53119
+ bubbles: true,
53120
+ cancelable: true,
53121
+ view: window,
53122
+ pageX: 0,
53123
+ pageY: 0,
53124
+ clientX: coordX,
53125
+ clientY: coordY,
53126
+ };
53127
+ const event = new MouseEvent(eventName, options);
53128
+ this.draggingElement.dispatchEvent(event);
53050
53129
  }
53051
- const event = new MouseEvent(eventName, options);
53052
- element.dispatchEvent(event);
53053
53130
  }
53131
+ var SimulateDnD$1 = new SimulateDnD();
53054
53132
 
53055
53133
  function useEditorSubscriber() {
53056
53134
  const entityStore = useEntityStore((state) => state.entityStore);
@@ -53069,6 +53147,8 @@ function useEditorSubscriber() {
53069
53147
  const selectedNodeId = useEditorStore((state) => state.selectedNodeId);
53070
53148
  const setComponentId = useDraggedItemStore((state) => state.setComponentId);
53071
53149
  const setDraggingOnCanvas = useDraggedItemStore((state) => state.setDraggingOnCanvas);
53150
+ const setMousePosition = useDraggedItemStore((state) => state.setMousePosition);
53151
+ const setScrollY = useDraggedItemStore((state) => state.setScrollY);
53072
53152
  // TODO: As we have disabled the useEffect, we can remove these states
53073
53153
  const [, /* isFetchingEntities */ setFetchingEntities] = reactExports.useState(false);
53074
53154
  const reloadApp = () => {
@@ -53182,7 +53262,7 @@ function useEditorSubscriber() {
53182
53262
  console.debug(`[experiences-sdk-react::onMessage] Received message [${eventData.eventType}]`, eventData);
53183
53263
  const { payload } = eventData;
53184
53264
  switch (eventData.eventType) {
53185
- case INCOMING_EVENTS.CompositionUpdated: {
53265
+ case INCOMING_EVENTS.ExperienceUpdated: {
53186
53266
  const { tree, locale, changedNode, changedValueType, assemblies, } = payload;
53187
53267
  // Make sure to first store the assemblies before setting the tree and thus triggering a rerender
53188
53268
  if (assemblies) {
@@ -53225,9 +53305,6 @@ function useEditorSubscriber() {
53225
53305
  }
53226
53306
  break;
53227
53307
  }
53228
- case INCOMING_EVENTS.DesignComponentsRegistered:
53229
- // Event was deprecated and support will be discontinued with version 5
53230
- break;
53231
53308
  case INCOMING_EVENTS.AssembliesRegistered: {
53232
53309
  const { assemblies } = payload;
53233
53310
  assemblies.forEach((definition) => {
@@ -53238,9 +53315,6 @@ function useEditorSubscriber() {
53238
53315
  });
53239
53316
  break;
53240
53317
  }
53241
- case INCOMING_EVENTS.DesignComponentsAdded:
53242
- // Event was deprecated and support will be discontinued with version 5
53243
- break;
53244
53318
  case INCOMING_EVENTS.AssembliesAdded: {
53245
53319
  const { assembly, assemblyDefinition, } = payload;
53246
53320
  entityStore.updateEntity(assembly);
@@ -53259,6 +53333,10 @@ function useEditorSubscriber() {
53259
53333
  break;
53260
53334
  }
53261
53335
  case INCOMING_EVENTS.CanvasResized: {
53336
+ const { selectedNodeId } = payload;
53337
+ if (selectedNodeId) {
53338
+ sendSelectedComponentCoordinates(selectedNodeId);
53339
+ }
53262
53340
  break;
53263
53341
  }
53264
53342
  case INCOMING_EVENTS.HoverComponent: {
@@ -53271,7 +53349,7 @@ function useEditorSubscriber() {
53271
53349
  if (!isDragging) {
53272
53350
  setComponentId('');
53273
53351
  setDraggingOnCanvas(false);
53274
- dragState.reset();
53352
+ SimulateDnD$1.reset();
53275
53353
  }
53276
53354
  break;
53277
53355
  }
@@ -53292,23 +53370,23 @@ function useEditorSubscriber() {
53292
53370
  break;
53293
53371
  }
53294
53372
  case INCOMING_EVENTS.ComponentDragCanceled: {
53295
- if (dragState.isDragging) {
53373
+ if (SimulateDnD$1.isDragging) {
53296
53374
  //simulate a mouseup event to cancel the drag
53297
- simulateMouseEvent(0, 0, 'mouseup');
53375
+ SimulateDnD$1.endDrag(0, 0);
53298
53376
  }
53299
53377
  break;
53300
53378
  }
53301
53379
  case INCOMING_EVENTS.ComponentDragStarted: {
53302
- dragState.updateIsDragStartedOnParent(true);
53303
- setDraggingOnCanvas(true);
53380
+ SimulateDnD$1.setupDrag();
53304
53381
  setComponentId(payload.id || '');
53382
+ setDraggingOnCanvas(true);
53305
53383
  sendMessage(OUTGOING_EVENTS.ComponentSelected, {
53306
53384
  nodeId: '',
53307
53385
  });
53308
53386
  break;
53309
53387
  }
53310
53388
  case INCOMING_EVENTS.ComponentDragEnded: {
53311
- dragState.reset();
53389
+ SimulateDnD$1.reset();
53312
53390
  setComponentId('');
53313
53391
  setDraggingOnCanvas(false);
53314
53392
  break;
@@ -53319,6 +53397,22 @@ function useEditorSubscriber() {
53319
53397
  sendSelectedComponentCoordinates(nodeId);
53320
53398
  break;
53321
53399
  }
53400
+ case INCOMING_EVENTS.MouseMove: {
53401
+ const { mouseX, mouseY } = payload;
53402
+ setMousePosition(mouseX, mouseY);
53403
+ if (SimulateDnD$1.isDraggingOnParent && !SimulateDnD$1.isDragging) {
53404
+ SimulateDnD$1.startDrag(mouseX, mouseY);
53405
+ }
53406
+ else {
53407
+ SimulateDnD$1.updateDrag(mouseX, mouseY);
53408
+ }
53409
+ break;
53410
+ }
53411
+ case INCOMING_EVENTS.ComponentMoveEnded: {
53412
+ const { mouseX, mouseY } = payload;
53413
+ SimulateDnD$1.endDrag(mouseX, mouseY);
53414
+ break;
53415
+ }
53322
53416
  default:
53323
53417
  console.error(`[experiences-sdk-react::onMessage] Logic error, unsupported eventType: [${eventData.eventType}]`);
53324
53418
  }
@@ -53341,6 +53435,7 @@ function useEditorSubscriber() {
53341
53435
  unboundValues,
53342
53436
  updateTree,
53343
53437
  updateNodesByUpdatedEntity,
53438
+ setMousePosition,
53344
53439
  ]);
53345
53440
  /*
53346
53441
  * Handles on scroll business
@@ -53349,6 +53444,7 @@ function useEditorSubscriber() {
53349
53444
  let timeoutId = 0;
53350
53445
  let isScrolling = false;
53351
53446
  const onScroll = () => {
53447
+ setScrollY(window.scrollY);
53352
53448
  if (isScrolling === false) {
53353
53449
  sendMessage(OUTGOING_EVENTS.CanvasScroll, SCROLL_STATES.Start);
53354
53450
  }
@@ -53374,7 +53470,7 @@ function useEditorSubscriber() {
53374
53470
  window.removeEventListener('scroll', onScroll, { capture: true });
53375
53471
  clearTimeout(timeoutId);
53376
53472
  };
53377
- }, [selectedNodeId]);
53473
+ }, [selectedNodeId, setScrollY]);
53378
53474
  }
53379
53475
 
53380
53476
  const onComponentMoved = (options) => {
@@ -53602,30 +53698,36 @@ const TestDNDContainer = ({ onDragEnd, onBeforeDragStart, onDragUpdate, children
53602
53698
  const DNDProvider = ({ children }) => {
53603
53699
  const setSelectedNodeId = useEditorStore((state) => state.setSelectedNodeId);
53604
53700
  const draggedItem = useDraggedItemStore((state) => state.draggedItem);
53701
+ const setOnBeforeCaptureId = useDraggedItemStore((state) => state.setOnBeforeCaptureId);
53605
53702
  const setDraggingOnCanvas = useDraggedItemStore((state) => state.setDraggingOnCanvas);
53606
53703
  const updateItem = useDraggedItemStore((state) => state.updateItem);
53607
53704
  const { onAddComponent, onMoveComponent } = useCanvasInteractions();
53608
53705
  const selectedNodeId = useEditorStore((state) => state.selectedNodeId);
53609
53706
  const prevSelectedNodeId = reactExports.useRef(null);
53610
53707
  const isTestRun = typeof window !== 'undefined' && Object.prototype.hasOwnProperty.call(window, 'Cypress');
53611
- const dragStart = () => {
53708
+ const dragStart = ({ source }) => {
53612
53709
  prevSelectedNodeId.current = selectedNodeId;
53613
53710
  //Unselect the current node when dragging and remove the outline
53614
53711
  setSelectedNodeId('');
53615
53712
  sendMessage(OUTGOING_EVENTS.ComponentSelected, {
53616
53713
  nodeId: '',
53617
53714
  });
53715
+ if (source.droppableId !== COMPONENT_LIST_ID) {
53716
+ sendMessage(OUTGOING_EVENTS.ComponentMoveStarted);
53717
+ }
53618
53718
  };
53619
- const beforeCapture = () => {
53719
+ const beforeCapture = ({ draggableId }) => {
53620
53720
  setDraggingOnCanvas(true);
53721
+ setOnBeforeCaptureId(draggableId);
53621
53722
  };
53622
53723
  const dragUpdate = (update) => {
53623
53724
  updateItem(update);
53624
53725
  };
53625
53726
  const dragEnd = (dropResult) => {
53626
53727
  setDraggingOnCanvas(false);
53728
+ setOnBeforeCaptureId('');
53627
53729
  updateItem(undefined);
53628
- dragState.reset();
53730
+ SimulateDnD$1.reset();
53629
53731
  if (!dropResult.destination) {
53630
53732
  if (!draggedItem?.destination) {
53631
53733
  // User cancel drag
@@ -53652,6 +53754,7 @@ const DNDProvider = ({ children }) => {
53652
53754
  }
53653
53755
  // If a node was previously selected prior to dragging, re-select it
53654
53756
  setSelectedNodeId(dropResult.draggableId);
53757
+ sendMessage(OUTGOING_EVENTS.ComponentMoveEnded);
53655
53758
  sendMessage(OUTGOING_EVENTS.ComponentSelected, {
53656
53759
  nodeId: dropResult.draggableId,
53657
53760
  });
@@ -53778,6 +53881,7 @@ const findNearestDropzone = (element) => {
53778
53881
  const VisualEditorRoot = () => {
53779
53882
  const initialized = useInitializeEditor();
53780
53883
  const locale = useEditorStore((state) => state.locale);
53884
+ const setMousePosition = useDraggedItemStore((state) => state.setMousePosition);
53781
53885
  const entityStore = useEntityStore((state) => state.entityStore);
53782
53886
  const setHoveringZone = useZoneStore((state) => state.setHoveringZone);
53783
53887
  const resetEntityStore = useEntityStore((state) => state.resetEntityStore);
@@ -53792,18 +53896,19 @@ const VisualEditorRoot = () => {
53792
53896
  }, [locale, resetEntityStore, entityStore.locale]);
53793
53897
  reactExports.useEffect(() => {
53794
53898
  const onMouseMove = (e) => {
53899
+ setMousePosition(e.clientX, e.clientY);
53795
53900
  const target = e.target;
53796
53901
  const zoneId = findNearestDropzone(target);
53797
53902
  if (zoneId) {
53798
53903
  setHoveringZone(zoneId);
53799
53904
  }
53800
- if (e.target?.id === 'item') {
53905
+ if (!SimulateDnD$1.isDragging) {
53801
53906
  return;
53802
53907
  }
53803
- if (!dragState.isDragStart) {
53908
+ if (target.id === NEW_COMPONENT_ID) {
53804
53909
  return;
53805
53910
  }
53806
- simulateMouseEvent(e.pageX, e.pageY);
53911
+ SimulateDnD$1.updateDrag(e.clientX, e.clientY);
53807
53912
  sendMessage(OUTGOING_EVENTS.MouseMove, {
53808
53913
  clientX: e.pageX,
53809
53914
  clientY: e.pageY - window.scrollY,