publ-echo-test 0.0.396 → 0.0.398

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.
@@ -603,6 +603,7 @@ var GridItem = function (_a) {
603
603
  "data-grid-id": i,
604
604
  "data-z-index": z,
605
605
  "data-z-order": zOrder,
606
+ "data-parent-group-id": props.parentGroupId,
606
607
  "data-is-height-variable": props.isheightVariable,
607
608
  "data-height-fit-content": heightFitContent,
608
609
  "data-z-order-internal": zOrderInternal,
@@ -1,7 +1,9 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  type OutsideClickHandlerProps = {
3
3
  children: React.ReactNode;
4
4
  onOutsideClick: () => void;
5
+ onMouseEnter: () => void;
6
+ onMouseLeave: () => void;
5
7
  };
6
8
  declare const OutsideClickHandler: React.FC<OutsideClickHandlerProps>;
7
9
  export default OutsideClickHandler;
@@ -1,22 +1,21 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from 'react';
3
- import { zIndexMap } from '../GridLayoutEditor/group';
2
+ import { useEffect, useRef, useState } from "react";
4
3
  var OutsideClickHandler = function (_a) {
5
- var children = _a.children, onOutsideClick = _a.onOutsideClick;
4
+ var children = _a.children, onOutsideClick = _a.onOutsideClick, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave;
6
5
  var wrapperRef = useRef(null);
7
6
  var _b = useState({
8
- transform: '',
9
- width: '0',
10
- height: '0',
7
+ transform: "",
8
+ width: "0",
9
+ height: "0",
11
10
  }), childDimensions = _b[0], setChildDimensions = _b[1];
12
11
  var _c = useState(0), zIndex = _c[0], setZIndex = _c[1];
13
12
  useEffect(function () {
14
13
  var handleClickOutside = function (e) {
15
14
  var target = e.target;
16
- if (target.closest('.editable-grid-item') ||
17
- target.closest('.group') ||
18
- target.closest('.placeholder') ||
19
- target.closest('.react-group-block')) {
15
+ if (target.closest(".editable-grid-item") ||
16
+ target.closest(".group") ||
17
+ target.closest(".placeholder") ||
18
+ target.closest(".react-group-block")) {
20
19
  return;
21
20
  }
22
21
  if (wrapperRef.current &&
@@ -24,14 +23,14 @@ var OutsideClickHandler = function (_a) {
24
23
  onOutsideClick();
25
24
  }
26
25
  };
27
- var selectedSection = document.querySelector('.editor-canvas');
26
+ var selectedSection = document.querySelector(".editor-canvas");
28
27
  // const selectedSection = document;
29
28
  if (selectedSection) {
30
- selectedSection.addEventListener('dblclick', handleClickOutside);
29
+ selectedSection.addEventListener("dblclick", handleClickOutside);
31
30
  }
32
31
  return function () {
33
32
  if (selectedSection) {
34
- selectedSection.removeEventListener('dblclick', handleClickOutside);
33
+ selectedSection.removeEventListener("dblclick", handleClickOutside);
35
34
  }
36
35
  };
37
36
  }, [onOutsideClick]);
@@ -41,7 +40,7 @@ var OutsideClickHandler = function (_a) {
41
40
  var childElement = wrapperRef.current.children[0];
42
41
  // Get computed style of the child element
43
42
  var computedStyle = window.getComputedStyle(childElement);
44
- if (childElement.dataset['groupBlockId'] !== 'BULK') {
43
+ if (childElement.dataset["groupBlockId"] !== "BULK") {
45
44
  return;
46
45
  }
47
46
  setChildDimensions({
@@ -49,15 +48,15 @@ var OutsideClickHandler = function (_a) {
49
48
  width: computedStyle.width,
50
49
  height: computedStyle.height,
51
50
  });
52
- if (childElement.dataset['minZ']) {
53
- setZIndex(Number(childElement.dataset['minZ']));
51
+ if (childElement.dataset["minZ"]) {
52
+ setZIndex(Number(childElement.dataset["minZ"]));
54
53
  }
55
54
  }
56
55
  return function () {
57
56
  setChildDimensions({
58
- transform: '',
59
- width: '0',
60
- height: '0',
57
+ transform: "",
58
+ width: "0",
59
+ height: "0",
61
60
  });
62
61
  setZIndex(0);
63
62
  };
@@ -67,46 +66,47 @@ var OutsideClickHandler = function (_a) {
67
66
  var height = parseFloat(childDimensions.height) || 0;
68
67
  var borderThickness = 3; // 3px border thickness
69
68
  var shadowOffset = 3; // Match the child's shadow (0 0 0 3px #027aff)
70
- return (_jsxs(_Fragment, { children: [_jsx("div", { ref: wrapperRef, className: 'outside-click-wrapper', children: children }), width > 0 && height > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: 'border-top', style: {
71
- position: 'absolute',
69
+ return (_jsxs(_Fragment, { children: [_jsx("div", { ref: wrapperRef, className: "outside-click-wrapper", onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: children }), width > 0 && height > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-top", style: {
70
+ position: "absolute",
72
71
  transform: childDimensions.transform,
73
72
  width: "".concat(width + shadowOffset * 2, "px"),
74
73
  height: "".concat(borderThickness, "px"),
75
- backgroundColor: '#027aff',
74
+ backgroundColor: "#027aff",
76
75
  marginLeft: "-".concat(shadowOffset, "px"),
77
76
  marginTop: "-".concat(shadowOffset, "px"),
78
- pointerEvents: 'none',
79
- zIndex: zIndexMap.EDITING_GROUP + zIndex,
80
- } }), _jsx("div", { className: 'border-right', style: {
81
- position: 'absolute',
77
+ pointerEvents: "none",
78
+ // zIndex: zIndexMap.EDITING_GROUP + zIndex,
79
+ zIndex: 0,
80
+ } }), _jsx("div", { className: "border-right", style: {
81
+ position: "absolute",
82
82
  transform: childDimensions.transform,
83
83
  width: "".concat(borderThickness, "px"),
84
84
  height: "".concat(height + shadowOffset * 2, "px"),
85
- backgroundColor: '#027aff',
85
+ backgroundColor: "#027aff",
86
86
  marginLeft: "".concat(width + shadowOffset - borderThickness, "px"),
87
87
  marginTop: "-".concat(shadowOffset, "px"),
88
- pointerEvents: 'none',
89
- zIndex: zIndexMap.EDITING_GROUP + zIndex,
90
- } }), _jsx("div", { className: 'border-bottom', style: {
91
- position: 'absolute',
88
+ pointerEvents: "none",
89
+ zIndex: 0,
90
+ } }), _jsx("div", { className: "border-bottom", style: {
91
+ position: "absolute",
92
92
  transform: childDimensions.transform,
93
93
  width: "".concat(width + shadowOffset * 2, "px"),
94
94
  height: "".concat(borderThickness, "px"),
95
- backgroundColor: '#027aff',
95
+ backgroundColor: "#027aff",
96
96
  marginLeft: "-".concat(shadowOffset, "px"),
97
97
  marginTop: "".concat(height + shadowOffset - borderThickness, "px"),
98
- pointerEvents: 'none',
99
- zIndex: zIndexMap.EDITING_GROUP + zIndex,
100
- } }), _jsx("div", { className: 'border-left', style: {
101
- position: 'absolute',
98
+ pointerEvents: "none",
99
+ zIndex: 0,
100
+ } }), _jsx("div", { className: "border-left", style: {
101
+ position: "absolute",
102
102
  transform: childDimensions.transform,
103
103
  width: "".concat(borderThickness, "px"),
104
104
  height: "".concat(height + shadowOffset * 2, "px"),
105
- backgroundColor: '#027aff',
105
+ backgroundColor: "#027aff",
106
106
  marginLeft: "-".concat(shadowOffset, "px"),
107
107
  marginTop: "-".concat(shadowOffset, "px"),
108
- pointerEvents: 'none',
109
- zIndex: zIndexMap.EDITING_GROUP + zIndex,
108
+ pointerEvents: "none",
109
+ zIndex: 0,
110
110
  } })] }))] }));
111
111
  };
112
112
  export default OutsideClickHandler;
@@ -86,6 +86,7 @@ export type GridItemProps = {
86
86
  isheightVariable: boolean;
87
87
  heightFitContent: boolean;
88
88
  isGroupChild?: boolean;
89
+ parentGroupId?: string;
89
90
  };
90
91
  export type GridItemDefaultProps = {
91
92
  className: string;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getIsHeightVariable } from "./ReactGridLayout";
2
3
  import { getLayoutItem } from "./utils/renderHelpers";
3
4
  export function GridBackgroundPlaceholder(_a) {
4
5
  // 활성화된 행(row) 인덱스 배열
@@ -19,10 +20,11 @@ export function GridBackgroundPlaceholder(_a) {
19
20
  // 패턴은 colWidth + margin[0] 단위로 반복되므로, 마지막 열에서는 margin[0]이 필요 없습니다.
20
21
  // 또는, 마지막 요소에는 margin[0]이 없다고 가정하고 계산합니다.
21
22
  var gridContentWidth = totalCols * (colWidth + margin[0]) - margin[0];
22
- var isHeightVariable = device === "DESKTOP"
23
- ? !!(activeBlock === null || activeBlock === void 0 ? void 0 : activeBlock.isHeightVariableDesktop)
24
- : !!(activeBlock === null || activeBlock === void 0 ? void 0 : activeBlock.isHeightVariableMobile);
25
- // const showActiveRows = !!activeDrag.heightFitContent || isHeightVariable;
23
+ var isHeightVariable = activeBlock
24
+ ? getIsHeightVariable(activeBlock, device)
25
+ : false;
26
+ console.log("activeBlock", activeBlock);
27
+ console.log("isHeightVariable", isHeightVariable);
26
28
  var showActiveRows = activeBlock && activeBlock.type === "GROUP_BLOCK"
27
29
  ? getShowActiveRows(activeBlock, layout)
28
30
  : !!activeDrag.heightFitContent || isHeightVariable;
@@ -2,5 +2,7 @@ import * as React from "react";
2
2
  import type { ReactElement } from "react";
3
3
  import { PropsWithChildren } from "../types";
4
4
  import { ReactGridLayoutProps } from "./types";
5
+ import { Block } from "./group";
5
6
  declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps>) => React.ReactElement;
7
+ export declare function getIsHeightVariable(block: Block, device: "DESKTOP" | "MOBILE"): boolean;
6
8
  export default ReactGridLayout;
@@ -60,6 +60,7 @@ var ReactGridLayout = function (_a) {
60
60
  var _6 = useState(), droppingDOMNode = _6[0], setDroppingDOMNode = _6[1];
61
61
  var _7 = useState(), droppingPosition = _7[0], setDroppingPosition = _7[1];
62
62
  var _8 = useState(false), isMounted = _8[0], setIsMounted = _8[1];
63
+ var _9 = useState(null), hoveredGroupId = _9[0], setHoveredGroupId = _9[1];
63
64
  var editorMode = props.isDraggable && props.isResizable ? "EDIT" : "VIEW";
64
65
  var editableBlockIds = blockStructure
65
66
  ? findDirectChildrenCbIds(blockStructure, editingGroupBlock)
@@ -69,10 +70,10 @@ var ReactGridLayout = function (_a) {
69
70
  return i.toString();
70
71
  })
71
72
  : [];
72
- var _9 = useState([]), oldGroupChildren = _9[0], setOldGroupChildren = _9[1];
73
- var _10 = useState(function () {
73
+ var _10 = useState([]), oldGroupChildren = _10[0], setOldGroupChildren = _10[1];
74
+ var _11 = useState(function () {
74
75
  return synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap);
75
- }), layout = _10[0], setLayout = _10[1];
76
+ }), layout = _11[0], setLayout = _11[1];
76
77
  var dragEnterCounter = useRef(0);
77
78
  useLayoutEffect(function () {
78
79
  setIsMounted(true);
@@ -556,7 +557,7 @@ var ReactGridLayout = function (_a) {
556
557
  var isInsideOfEditingGroup = editingGroupAllChildren.includes(l.i);
557
558
  var editorZIndex = (function () {
558
559
  if (isRoot && isInBulk) {
559
- return z;
560
+ return zIndexMap.ROOT + z;
560
561
  }
561
562
  if (!isRoot && isInsideOfEditingGroup) {
562
563
  return zIndexMap.CB_IN_EDITING_GROUP + z;
@@ -607,15 +608,15 @@ var ReactGridLayout = function (_a) {
607
608
  i: l.i,
608
609
  });
609
610
  var showBlockData = editable && !isInBulk && overlapsActiveRows;
610
- return (_jsx(GridItem, { heightFitContent: !!(l === null || l === void 0 ? void 0 : l.heightFitContent), isheightVariable: device === "DESKTOP"
611
- ? !!block.isHeightVariableDesktop
612
- : !!block.isHeightVariableMobile, className: classNames({
611
+ return (_jsx(GridItem, { heightFitContent: !!(l === null || l === void 0 ? void 0 : l.heightFitContent), isheightVariable: getIsHeightVariable(block, device), parentGroupId: parent ? parent.blockId : undefined, className: classNames({
613
612
  "editable-grid-item": !isRoot && editable,
614
613
  "not-editable-grid-item": !isRoot && !editable,
615
614
  "bulk-child-item": isInBulk,
616
615
  "outside-of-editing-group": !isInsideOfEditingGroup,
617
- "show-block-data": showBlockData,
616
+ // "show-block-data": showBlockData,
617
+ "show-block-data": true,
618
618
  "is-in-group": isInGroup,
619
+ "is-hovered-group-child": hoveredGroupId === (parent ? parent.blockId : undefined),
619
620
  }), z: zIndex, zOrder: l.z, zOrderInternal: parent
620
621
  ? "".concat(parent[device === "DESKTOP"
621
622
  ? "zOrderDesktopInternal"
@@ -740,13 +741,50 @@ var ReactGridLayout = function (_a) {
740
741
  var parent = blockStructure
741
742
  ? findParentGroupBlock(blockStructure, block.blockId)
742
743
  : null;
743
- return (_jsx(OutsideClickHandler, { onOutsideClick: onDoubleClickOutsideGroup, children: _jsx(GroupItem, { heightFitContent: false, isheightVariable: device === "DESKTOP"
744
- ? !!block.isHeightVariableDesktop
745
- : !!block.isHeightVariableMobile, className: classNames({
744
+ // Check if a layout item overlaps any of the activeRows (vertical overlap)
745
+ var isOverlappingActiveRows = function (item) {
746
+ if ((activeBlock === null || activeBlock === void 0 ? void 0 : activeBlock.type) === "COMPONENT_BLOCK") {
747
+ if ((parsedSelectedBlockId === null || parsedSelectedBlockId === void 0 ? void 0 : parsedSelectedBlockId.cbId) === item.i) {
748
+ return false;
749
+ }
750
+ if (!(activeDragItemOrSelectedItem === null || activeDragItemOrSelectedItem === void 0 ? void 0 : activeDragItemOrSelectedItem.heightFitContent)) {
751
+ return false;
752
+ }
753
+ }
754
+ if ((activeBlock === null || activeBlock === void 0 ? void 0 : activeBlock.type) === "GROUP_BLOCK") {
755
+ var hasFitContentCB = getShowActiveRows(activeBlock, layout);
756
+ if (!hasFitContentCB) {
757
+ return false;
758
+ }
759
+ }
760
+ if (!activeRows || activeRows.length === 0) {
761
+ return false;
762
+ }
763
+ var minActive = Math.min.apply(Math, activeRows);
764
+ var maxActive = Math.max.apply(Math, activeRows);
765
+ var itemTop = item.y;
766
+ var itemBottom = item.y + item.h - 1;
767
+ // overlap if ranges [itemTop, itemBottom] and [minActive, maxActive] intersect
768
+ return !(itemBottom < minActive || itemTop > maxActive);
769
+ };
770
+ var overlapsActiveRows = isOverlappingActiveRows({
771
+ w: groupItem.w,
772
+ h: groupItem.h,
773
+ x: groupItem.x,
774
+ y: groupItem.y,
775
+ i: block.blockId,
776
+ });
777
+ var showBlockData = !isInBulk && overlapsActiveRows;
778
+ return (_jsx(OutsideClickHandler, { onOutsideClick: onDoubleClickOutsideGroup, onMouseEnter: function () {
779
+ setHoveredGroupId(block.blockId);
780
+ }, onMouseLeave: function () {
781
+ setHoveredGroupId(null);
782
+ }, children: _jsx(GroupItem, { heightFitContent: false, isheightVariable: getIsHeightVariable(block, device), className: classNames({
746
783
  "bulk-child-item": isInBulk,
747
784
  "grid-bulk-block": block.blockId === "BULK",
748
785
  editing: editingGroupBlock === block.blockId,
749
786
  selected: selectedGroupBlock === block.blockId,
787
+ "show-block-data": showBlockData,
750
788
  }), z: zIndex, minZ: groupItem.minZ, zOrder: internalZOrder, zOrderInternal: parent
751
789
  ? "".concat(parent[device === "DESKTOP"
752
790
  ? "zOrderDesktopInternal"
@@ -782,6 +820,7 @@ var ReactGridLayout = function (_a) {
782
820
  ? generateGrouplayout(parsedSelectedBlockId.blockId)
783
821
  : null;
784
822
  var activeDragItemOrSelectedItem = activeDrag || selectedLayoutItem;
823
+ console.log("activeDragItemOrSelectedItem", parsedSelectedBlockId);
785
824
  var activeBlock = activeDragItemOrSelectedItem && parsedSelectedBlockId
786
825
  ? blockStructure
787
826
  ? findBlockByBlockId(blockStructure, parsedSelectedBlockId.blockId)
@@ -790,9 +829,7 @@ var ReactGridLayout = function (_a) {
790
829
  var activeRows = activeDragItemOrSelectedItem &&
791
830
  Array.from({ length: activeDragItemOrSelectedItem.h }, function (_, i) { return activeDragItemOrSelectedItem.y + i; });
792
831
  var heightVariableRows = getRowsForHeightFitContentItems(layout);
793
- var shouldShowAllHeightVariableRows = device === "DESKTOP"
794
- ? activeBlock === null || activeBlock === void 0 ? void 0 : activeBlock.isHeightVariableDesktop
795
- : activeBlock === null || activeBlock === void 0 ? void 0 : activeBlock.isHeightVariableMobile;
832
+ var shouldShowAllHeightVariableRows = getIsHeightVariable(activeBlock, device);
796
833
  var activeRowsFiltered = shouldShowAllHeightVariableRows
797
834
  ? heightVariableRows
798
835
  : activeRows;
@@ -800,4 +837,13 @@ var ReactGridLayout = function (_a) {
800
837
  // width={width}
801
838
  rowHeight: rowHeight, activeRows: activeRowsFiltered !== null && activeRowsFiltered !== void 0 ? activeRowsFiltered : [], colWidth: colWidth, activeDrag: activeDragItemOrSelectedItem, activeBlock: activeBlock, selectedBlockId: selectedBlockId, totalCols: cols, layout: layout }))] }));
802
839
  };
840
+ export function getIsHeightVariable(block, device) {
841
+ var heightVariable = device === "DESKTOP"
842
+ ? block === null || block === void 0 ? void 0 : block.isHeightVariableDesktop
843
+ : block === null || block === void 0 ? void 0 : block.isHeightVariableMobile;
844
+ if (heightVariable === undefined || heightVariable === null) {
845
+ return true;
846
+ }
847
+ return heightVariable;
848
+ }
803
849
  export default ReactGridLayout;
@@ -22,8 +22,8 @@ export type ComponentBlock = {
22
22
  zOrderDesktopInternal: number | null;
23
23
  zOrderMobileInternal: number | null;
24
24
  componentBlockId: number;
25
- isHeightVariableDesktop: boolean;
26
- isHeightVariableMobile: boolean;
25
+ isHeightVariableDesktop: boolean | null;
26
+ isHeightVariableMobile: boolean | null;
27
27
  };
28
28
  export type GroupBlock = {
29
29
  blockId: string;
@@ -31,8 +31,8 @@ export type GroupBlock = {
31
31
  zOrderDesktopInternal: number | null;
32
32
  zOrderMobileInternal: number | null;
33
33
  children: (ComponentBlock | GroupBlock)[];
34
- isHeightVariableDesktop: boolean;
35
- isHeightVariableMobile: boolean;
34
+ isHeightVariableDesktop: boolean | null;
35
+ isHeightVariableMobile: boolean | null;
36
36
  };
37
37
  export type RootBlock = {
38
38
  blockId: "ROOT";
@@ -40,8 +40,8 @@ export type RootBlock = {
40
40
  zOrderDesktopInternal: number | null;
41
41
  zOrderMobileInternal: number | null;
42
42
  children: (ComponentBlock | GroupBlock)[];
43
- isHeightVariableDesktop: boolean;
44
- isHeightVariableMobile: boolean;
43
+ isHeightVariableDesktop: boolean | null;
44
+ isHeightVariableMobile: boolean | null;
45
45
  };
46
46
  export type BulkBlockInternal = {
47
47
  blockId: "BULK";
@@ -49,8 +49,8 @@ export type BulkBlockInternal = {
49
49
  zOrderDesktopInternal: number;
50
50
  zOrderMobileInternal: number;
51
51
  children: (ComponentBlock | GroupBlock)[];
52
- isHeightVariableDesktop: boolean;
53
- isHeightVariableMobile: boolean;
52
+ isHeightVariableDesktop: boolean | null;
53
+ isHeightVariableMobile: boolean | null;
54
54
  };
55
55
  export declare const findBlockByBlockId: (block: Block, blockId: string) => Block | null;
56
56
  export declare const findDirectChildrenCbIds: (block: Block, targetId: string) => number[];
@@ -265,6 +265,13 @@ export function getBlockIdKind(blockId) {
265
265
  blockId: blockId,
266
266
  };
267
267
  }
268
+ if (Number.isInteger(Number(blockId))) {
269
+ return {
270
+ type: "CB",
271
+ cbId: Number(blockId).toString(),
272
+ blockId: formatCbIdToBlockId(Number(blockId)),
273
+ };
274
+ }
268
275
  return null;
269
276
  }
270
277
  // export const findAccessibleChildrenBlocks = (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.396",
3
+ "version": "0.0.398",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",