publ-echo-test 0.0.332 → 0.0.334
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/external-lib/classnames/index.d.ts +5 -0
- package/dist/external-lib/classnames/index.js +60 -0
- package/dist/external-lib/lodash.isEqual/index.d.ts +30 -0
- package/dist/external-lib/lodash.isEqual/index.js +1661 -0
- package/dist/lib/Draggable/Draggable.d.ts +17 -0
- package/dist/lib/Draggable/Draggable.js +192 -0
- package/dist/lib/Draggable/DraggableCore.d.ts +5 -0
- package/dist/lib/Draggable/DraggableCore.js +267 -0
- package/dist/lib/Draggable/constants.d.ts +12 -0
- package/dist/lib/Draggable/constants.js +12 -0
- package/dist/lib/Draggable/index.d.ts +2 -0
- package/dist/lib/Draggable/index.js +2 -0
- package/dist/lib/Draggable/types.d.ts +55 -0
- package/dist/lib/Draggable/types.js +1 -0
- package/dist/lib/Draggable/utils/domHelpers.d.ts +22 -0
- package/dist/lib/Draggable/utils/domHelpers.js +222 -0
- package/dist/lib/Draggable/utils/getPrefix.d.ts +5 -0
- package/dist/lib/Draggable/utils/getPrefix.js +41 -0
- package/dist/lib/Draggable/utils/positionHelpers.d.ts +7 -0
- package/dist/lib/Draggable/utils/positionHelpers.js +32 -0
- package/dist/lib/Draggable/utils/types.d.ts +30 -0
- package/dist/lib/Draggable/utils/types.js +1 -0
- package/dist/lib/Draggable/utils/validationHelpers.d.ts +4 -0
- package/dist/lib/Draggable/utils/validationHelpers.js +16 -0
- package/dist/lib/GridItem/GridItem.d.ts +5 -0
- package/dist/lib/GridItem/GridItem.js +417 -0
- package/dist/lib/GridItem/GroupItem.d.ts +10 -0
- package/dist/lib/GridItem/GroupItem.js +473 -0
- package/dist/lib/GridItem/OutsideClickHandler.d.ts +7 -0
- package/dist/lib/GridItem/OutsideClickHandler.js +112 -0
- package/dist/lib/GridItem/index.d.ts +1 -0
- package/dist/lib/GridItem/index.js +1 -0
- package/dist/lib/GridItem/types.d.ts +112 -0
- package/dist/lib/GridItem/types.js +1 -0
- package/dist/lib/GridItem/utils/calculateUtils.d.ts +30 -0
- package/dist/lib/GridItem/utils/calculateUtils.js +115 -0
- package/dist/lib/GridLayoutEditor/ReactGridLayout.d.ts +6 -0
- package/dist/lib/GridLayoutEditor/ReactGridLayout.js +747 -0
- package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.d.ts +4 -0
- package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.js +117 -0
- package/dist/lib/GridLayoutEditor/group.d.ts +58 -0
- package/dist/lib/GridLayoutEditor/group.js +341 -0
- package/dist/lib/GridLayoutEditor/index.d.ts +3 -0
- package/dist/lib/GridLayoutEditor/index.js +2 -0
- package/dist/lib/GridLayoutEditor/types.d.ts +170 -0
- package/dist/lib/GridLayoutEditor/types.js +1 -0
- package/dist/lib/GridLayoutEditor/utils/renderHelpers.d.ts +173 -0
- package/dist/lib/GridLayoutEditor/utils/renderHelpers.js +607 -0
- package/dist/lib/GridLayoutEditor/utils/responsiveUtils.d.ts +26 -0
- package/dist/lib/GridLayoutEditor/utils/responsiveUtils.js +77 -0
- package/dist/lib/Resizable/Resizable.d.ts +6 -0
- package/dist/lib/Resizable/Resizable.js +289 -0
- package/dist/lib/Resizable/ResizableBox.d.ts +7 -0
- package/dist/lib/Resizable/ResizableBox.js +57 -0
- package/dist/lib/Resizable/index.d.ts +1 -0
- package/dist/lib/Resizable/index.js +1 -0
- package/dist/lib/Resizable/types.d.ts +69 -0
- package/dist/lib/Resizable/types.js +1 -0
- package/dist/lib/Resizable/utils/cloneElement.d.ts +2 -0
- package/dist/lib/Resizable/utils/cloneElement.js +21 -0
- package/dist/lib/components/WidthProvider.d.ts +9 -0
- package/dist/lib/components/WidthProvider.js +65 -0
- package/dist/lib/components/index.d.ts +1 -0
- package/dist/lib/components/index.js +1 -0
- package/dist/lib/components/types.d.ts +13 -0
- package/dist/lib/components/types.js +1 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/types.d.ts +4 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils/classNames.d.ts +3 -0
- package/dist/lib/utils/classNames.js +10 -0
- package/package.json +1 -1
@@ -0,0 +1,4 @@
|
|
1
|
+
import { ResponsiveGridLayoutProps } from './types';
|
2
|
+
import { PropsWithChildren } from '../types';
|
3
|
+
export declare const ResponsiveGridLayout: ({ children, ...props }: PropsWithChildren<ResponsiveGridLayoutProps>) => React.ReactElement;
|
4
|
+
export default ResponsiveGridLayout;
|
@@ -0,0 +1,117 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
+
var t = {};
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
+
t[p] = s[p];
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
+
t[p[i]] = s[p[i]];
|
20
|
+
}
|
21
|
+
return t;
|
22
|
+
};
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
24
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
25
|
+
import { cloneLayout, noop, synchronizeLayoutWithChildren, } from './utils/renderHelpers';
|
26
|
+
import { findOrGenerateResponsiveLayout, getBreakpointFromWidth, getColsFromBreakpoint, } from './utils/responsiveUtils';
|
27
|
+
import isEqual from '../../external-lib/lodash.isEqual';
|
28
|
+
import ReactGridLayout from './ReactGridLayout';
|
29
|
+
/**
|
30
|
+
* Get a value of margin or containerPadding.
|
31
|
+
*
|
32
|
+
* @param {Array | Object} param Margin | containerPadding, e.g. [10, 10] | {lg: [10, 10], ...}.
|
33
|
+
* @param {String} breakpoint Breakpoint: lg, md, sm, xs and etc.
|
34
|
+
* @return {Array}
|
35
|
+
*/
|
36
|
+
function getIndentationValue(param, breakpoint) {
|
37
|
+
return Array.isArray(param) ? param : param[breakpoint];
|
38
|
+
}
|
39
|
+
export var ResponsiveGridLayout = function (_a) {
|
40
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
41
|
+
var breakpoint = props.breakpoint, compactType = props.compactType, _b = props.breakpoints, breakpoints = _b === void 0 ? { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 } : _b, _c = props.cols, cols = _c === void 0 ? { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 } : _c, _d = props.containerPadding, containerPadding = _d === void 0 ? {} : _d, _e = props.layouts, layouts = _e === void 0 ? {} : _e, _f = props.width, width = _f === void 0 ? 0 : _f, _g = props.margin, margin = _g === void 0 ? [10, 10] : _g, _h = props.onBreakpointChange, onBreakpointChange = _h === void 0 ? noop : _h, _j = props.onLayoutChange, onLayoutChange = _j === void 0 ? noop : _j, _k = props.onWidthChange, onWidthChange = _k === void 0 ? noop : _k, zoom = props.zoom, restProps = __rest(props, ["breakpoint", "compactType", "breakpoints", "cols", "containerPadding", "layouts", "width", "margin", "onBreakpointChange", "onLayoutChange", "onWidthChange", "zoom"]);
|
42
|
+
var _l = useState({ width: width, breakpoints: breakpoints, cols: cols }), prevProps = _l[0], setPrevProps = _l[1];
|
43
|
+
var generateInitialState = function () {
|
44
|
+
var breakpoint = getBreakpointFromWidth(breakpoints, width);
|
45
|
+
var colNo = getColsFromBreakpoint(breakpoint, cols);
|
46
|
+
var compactType = props.compactType;
|
47
|
+
var initialLayout = findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, breakpoint, colNo, compactType || 'vertical', false);
|
48
|
+
return {
|
49
|
+
layout: initialLayout,
|
50
|
+
layouts: layouts,
|
51
|
+
breakpoint: breakpoint,
|
52
|
+
cols: colNo,
|
53
|
+
};
|
54
|
+
};
|
55
|
+
var _m = useState(function () {
|
56
|
+
return generateInitialState();
|
57
|
+
}), state = _m[0], setState = _m[1];
|
58
|
+
var emittedBreakpointChangeOnce = useRef(breakpoint != null);
|
59
|
+
useLayoutEffect(function () {
|
60
|
+
if (!state || !isEqual(state.layouts, layouts)) {
|
61
|
+
setState(generateInitialState());
|
62
|
+
}
|
63
|
+
}, [layouts]);
|
64
|
+
useLayoutEffect(function () {
|
65
|
+
onWidthChangeHandler();
|
66
|
+
}, [width, breakpoint, JSON.stringify(breakpoints), cols]);
|
67
|
+
var onLayoutChangeHandler = function (layout) {
|
68
|
+
var _a;
|
69
|
+
var newLayouts = __assign(__assign({}, layouts), (_a = {}, _a[state.breakpoint] = layout, _a));
|
70
|
+
setState({
|
71
|
+
breakpoint: state.breakpoint,
|
72
|
+
cols: state.cols,
|
73
|
+
layout: layout,
|
74
|
+
layouts: newLayouts,
|
75
|
+
});
|
76
|
+
onLayoutChange({
|
77
|
+
layout: layout,
|
78
|
+
layouts: newLayouts,
|
79
|
+
});
|
80
|
+
};
|
81
|
+
var onWidthChangeHandler = function () {
|
82
|
+
var newBreakpoint = breakpoint || getBreakpointFromWidth(breakpoints, width);
|
83
|
+
var lastBreakpoint = state.breakpoint;
|
84
|
+
var newCols = getColsFromBreakpoint(newBreakpoint, cols);
|
85
|
+
var newLayouts = __assign({}, layouts);
|
86
|
+
if (!emittedBreakpointChangeOnce.current ||
|
87
|
+
lastBreakpoint !== newBreakpoint ||
|
88
|
+
!isEqual(prevProps.breakpoints, breakpoints) ||
|
89
|
+
!isEqual(prevProps.cols, cols)) {
|
90
|
+
emittedBreakpointChangeOnce.current = true;
|
91
|
+
if (!(lastBreakpoint in newLayouts)) {
|
92
|
+
newLayouts[lastBreakpoint] = cloneLayout(state.layout);
|
93
|
+
}
|
94
|
+
var newBreakpointIsBiggerOrEqual = lastBreakpoint === newBreakpoint ||
|
95
|
+
breakpoints[newBreakpoint] > breakpoints[lastBreakpoint];
|
96
|
+
var isNewLayout = layouts[newBreakpoint] == null;
|
97
|
+
var overlap = !!props.allowOverlap && (!isNewLayout || newBreakpointIsBiggerOrEqual); // allow resize overlap only if we are going into a larger screen
|
98
|
+
var layout = findOrGenerateResponsiveLayout(newLayouts, breakpoints, newBreakpoint, lastBreakpoint, newCols, compactType || 'vertical', overlap);
|
99
|
+
layout = synchronizeLayoutWithChildren(layout, children, newCols, compactType || 'vertical', overlap);
|
100
|
+
newLayouts[newBreakpoint] = layout;
|
101
|
+
setState({
|
102
|
+
breakpoint: newBreakpoint,
|
103
|
+
layout: layout,
|
104
|
+
layouts: newLayouts,
|
105
|
+
cols: newCols,
|
106
|
+
});
|
107
|
+
onLayoutChange({ layout: layout, layouts: newLayouts });
|
108
|
+
onBreakpointChange(newBreakpoint, newCols);
|
109
|
+
}
|
110
|
+
setPrevProps({ breakpoints: breakpoints, cols: cols, width: width });
|
111
|
+
var modifiedMargin = getIndentationValue(margin, newBreakpoint);
|
112
|
+
var containerPaddingModified = getIndentationValue(containerPadding, newBreakpoint);
|
113
|
+
onWidthChange(width, modifiedMargin, newCols, containerPaddingModified);
|
114
|
+
};
|
115
|
+
return (_jsx(ReactGridLayout, __assign({}, restProps, { children: children, width: width, margin: getIndentationValue(margin, state.breakpoint), containerPadding: getIndentationValue(containerPadding, state.breakpoint), onLayoutChange: onLayoutChangeHandler, layout: state.layout, cols: state.cols, transformScale: zoom !== null && zoom !== void 0 ? zoom : 1 })));
|
116
|
+
};
|
117
|
+
export default ResponsiveGridLayout;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
export declare const zIndexMap: {
|
2
|
+
ISDRAGGING: number;
|
3
|
+
BULK: number;
|
4
|
+
EDITABLE_GROUP: number;
|
5
|
+
CB_IN_EDITING_GROUP: number;
|
6
|
+
EDITING_GROUP: number;
|
7
|
+
GROUP: number;
|
8
|
+
CB: number;
|
9
|
+
ROOT: number;
|
10
|
+
};
|
11
|
+
export declare function getBlockSpecificType(block: Block): "ROOT" | "BULK" | "COMPONENT_BLOCK" | "GROUP_BLOCK";
|
12
|
+
export type SectionPedigree = RootBlock;
|
13
|
+
export type Block = ComponentBlock | GroupBlock | RootBlock;
|
14
|
+
export type ZOrder = {
|
15
|
+
[platform in "mobile" | "desktop"]: {
|
16
|
+
[componentBlockId: string]: number;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
export type ComponentBlock = {
|
20
|
+
blockId: string;
|
21
|
+
type: "COMPONENT_BLOCK";
|
22
|
+
zOrderDesktopInternal: number | null;
|
23
|
+
zOrderMobileInternal: number | null;
|
24
|
+
componentBlockId: number;
|
25
|
+
};
|
26
|
+
export type GroupBlock = {
|
27
|
+
blockId: string;
|
28
|
+
type: "GROUP_BLOCK";
|
29
|
+
zOrderDesktopInternal: number | null;
|
30
|
+
zOrderMobileInternal: number | null;
|
31
|
+
children: (ComponentBlock | GroupBlock)[];
|
32
|
+
};
|
33
|
+
export type RootBlock = {
|
34
|
+
blockId: "ROOT";
|
35
|
+
type: "GROUP_BLOCK";
|
36
|
+
zOrderDesktopInternal: number | null;
|
37
|
+
zOrderMobileInternal: number | null;
|
38
|
+
children: (ComponentBlock | GroupBlock)[];
|
39
|
+
};
|
40
|
+
export type BulkBlockInternal = {
|
41
|
+
blockId: "BULK";
|
42
|
+
type: "GROUP_BLOCK";
|
43
|
+
zOrderDesktopInternal: number;
|
44
|
+
zOrderMobileInternal: number;
|
45
|
+
children: (ComponentBlock | GroupBlock)[];
|
46
|
+
};
|
47
|
+
export declare const findBlockByBlockId: (block: Block, blockId: string) => Block | null;
|
48
|
+
export declare const findDirectChildrenCbIds: (block: Block, targetId: string) => number[];
|
49
|
+
export declare const findAllChildrenCbIds: (block: Block, targetId: string) => number[];
|
50
|
+
export declare const findAllChildrenBlockIds: (block: Block, targetId: string) => string[];
|
51
|
+
export declare const findDirectChildrenBlockIds: (block: Block, targetId: string) => string[];
|
52
|
+
export declare const findGroupBlocks: (block: Block, targetId: string) => GroupBlock[];
|
53
|
+
export declare const addBulkToTarget: (block: Block, targetId: string, bulkBlockIds: string[]) => Block;
|
54
|
+
export declare function getBlockWorkDirPath(blockStructure: Block, targetBlockId: string): string;
|
55
|
+
export declare function formatBlockIdToCbId(blockId: string): number | null;
|
56
|
+
export declare function formatCbIdToBlockId(cbId: number): string;
|
57
|
+
export declare function findParentGroupBlock(current: Block, targetBlockId: string): GroupBlock | null;
|
58
|
+
export declare function findOneComponentBlock(current: Block, targetBlockId: string): number | null;
|
@@ -0,0 +1,341 @@
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
3
|
+
if (ar || !(i in from)) {
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
5
|
+
ar[i] = from[i];
|
6
|
+
}
|
7
|
+
}
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
9
|
+
};
|
10
|
+
export var zIndexMap = {
|
11
|
+
ISDRAGGING: 999999,
|
12
|
+
BULK: 30000,
|
13
|
+
EDITABLE_GROUP: 20000,
|
14
|
+
CB_IN_EDITING_GROUP: 10000,
|
15
|
+
EDITING_GROUP: 9000,
|
16
|
+
GROUP: 5000,
|
17
|
+
CB: 0,
|
18
|
+
ROOT: 20000, //?
|
19
|
+
};
|
20
|
+
export function getBlockSpecificType(block) {
|
21
|
+
if (block.blockId === "ROOT") {
|
22
|
+
return "ROOT";
|
23
|
+
}
|
24
|
+
if (block.blockId === "BULK") {
|
25
|
+
return "BULK";
|
26
|
+
}
|
27
|
+
return block.type;
|
28
|
+
}
|
29
|
+
var deepClone = function (blocks) { return JSON.parse(JSON.stringify(blocks)); };
|
30
|
+
var collectChildrenCbIds = function (block, depth) {
|
31
|
+
var ids = [];
|
32
|
+
if ("children" in block && block.children) {
|
33
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
34
|
+
var child = _a[_i];
|
35
|
+
if (child.type === "COMPONENT_BLOCK") {
|
36
|
+
ids.push(child.componentBlockId);
|
37
|
+
}
|
38
|
+
if (depth === "deep" && child.type === "GROUP_BLOCK") {
|
39
|
+
ids = ids.concat(collectChildrenCbIds(child, depth));
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
return ids;
|
44
|
+
};
|
45
|
+
var collectChildrenBlockIds = function (block, depth) {
|
46
|
+
var ids = [];
|
47
|
+
if ("children" in block && block.children) {
|
48
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
49
|
+
var child = _a[_i];
|
50
|
+
ids.push(child.blockId);
|
51
|
+
if (depth === "deep") {
|
52
|
+
ids = ids.concat(collectChildrenBlockIds(child, depth));
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
return ids;
|
57
|
+
};
|
58
|
+
export var findBlockByBlockId = function (block, blockId) {
|
59
|
+
if (block.type !== "GROUP_BLOCK" || block.children.length === 0) {
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
if (block.blockId === "ROOT" && blockId === "ROOT") {
|
63
|
+
return block;
|
64
|
+
}
|
65
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
66
|
+
var child = _a[_i];
|
67
|
+
if (child.blockId === blockId) {
|
68
|
+
return child;
|
69
|
+
}
|
70
|
+
if (child.type === "GROUP_BLOCK" && child.children) {
|
71
|
+
var found = findBlockByBlockId(child, blockId);
|
72
|
+
if (found) {
|
73
|
+
return found;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
return null;
|
78
|
+
};
|
79
|
+
export var findDirectChildrenCbIds = function (block, targetId) {
|
80
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
81
|
+
if (!targetBlock || targetBlock.type !== "GROUP_BLOCK") {
|
82
|
+
return [];
|
83
|
+
}
|
84
|
+
return collectChildrenCbIds(targetBlock, "current");
|
85
|
+
};
|
86
|
+
export var findAllChildrenCbIds = function (block, targetId) {
|
87
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
88
|
+
if (!targetBlock || targetBlock.type !== "GROUP_BLOCK") {
|
89
|
+
return [];
|
90
|
+
}
|
91
|
+
return collectChildrenCbIds(targetBlock, "deep");
|
92
|
+
};
|
93
|
+
export var findAllChildrenBlockIds = function (block, targetId) {
|
94
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
95
|
+
if (!targetBlock || targetBlock.type !== "GROUP_BLOCK") {
|
96
|
+
return [];
|
97
|
+
}
|
98
|
+
return collectChildrenBlockIds(targetBlock, "deep");
|
99
|
+
};
|
100
|
+
export var findDirectChildrenBlockIds = function (block, targetId) {
|
101
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
102
|
+
if (!targetBlock || targetBlock.type !== "GROUP_BLOCK") {
|
103
|
+
return [];
|
104
|
+
}
|
105
|
+
return collectChildrenBlockIds(targetBlock, "current");
|
106
|
+
};
|
107
|
+
// NOTE: 타겟과 하위 모두.
|
108
|
+
export var findGroupBlocks = function (block, targetId) {
|
109
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
110
|
+
if (!targetBlock) {
|
111
|
+
return [];
|
112
|
+
}
|
113
|
+
if (targetBlock.type !== "GROUP_BLOCK") {
|
114
|
+
return [];
|
115
|
+
}
|
116
|
+
var groupBlocks = targetBlock.children.filter(function (child) { return child.type === "GROUP_BLOCK"; });
|
117
|
+
var bulkInTarget = targetBlock.children.find(function (block) { return block.blockId === "BULK"; });
|
118
|
+
if (bulkInTarget && bulkInTarget.type === "GROUP_BLOCK") {
|
119
|
+
var groupInBulk = bulkInTarget.children.filter(function (child) { return child.type === "GROUP_BLOCK"; });
|
120
|
+
if (targetBlock.blockId === "ROOT") {
|
121
|
+
return groupBlocks.concat(groupInBulk);
|
122
|
+
}
|
123
|
+
if (groupInBulk && groupInBulk.length > 0) {
|
124
|
+
return [targetBlock].concat(groupBlocks).concat(groupInBulk);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
if (targetBlock.blockId === "ROOT") {
|
128
|
+
return groupBlocks;
|
129
|
+
}
|
130
|
+
return [targetBlock].concat(groupBlocks);
|
131
|
+
};
|
132
|
+
// export const findAllComponentBlockIds = (blockStructure: Block[]): number[] => {
|
133
|
+
// const collectComponentBlockIds = (blocks: Block[]): number[] => {
|
134
|
+
// let ids: number[] = [];
|
135
|
+
// for (const block of blocks) {
|
136
|
+
// if (block.type === 'COMPONENT_BLOCK') {
|
137
|
+
// ids.push(block.componentBlockId);
|
138
|
+
// }
|
139
|
+
// if ('children' in block && block.children) {
|
140
|
+
// ids = ids.concat(collectComponentBlockIds(block.children));
|
141
|
+
// }
|
142
|
+
// }
|
143
|
+
// return ids;
|
144
|
+
// };
|
145
|
+
// return collectComponentBlockIds(blockStructure);
|
146
|
+
// };
|
147
|
+
// export const findParentGroupByGroupId = (blockStructure: Block[], targetId: string): string | null => {
|
148
|
+
// const findParentGroup = (
|
149
|
+
// blocks: Block[],
|
150
|
+
// id: string,
|
151
|
+
// parent: GroupBlock | null = null
|
152
|
+
// ): string | null => {
|
153
|
+
// for (const block of blocks) {
|
154
|
+
// if (block.blockId === id && block.type === 'GROUP_BLOCK') {
|
155
|
+
// return parent ? parent.blockId : null;
|
156
|
+
// }
|
157
|
+
// if ('children' in block && block.children) {
|
158
|
+
// const result = findParentGroup(block.children, id, block.type === 'GROUP_BLOCK' ? block : parent);
|
159
|
+
// if (result) {
|
160
|
+
// return result;
|
161
|
+
// }
|
162
|
+
// }
|
163
|
+
// }
|
164
|
+
// return null;
|
165
|
+
// };
|
166
|
+
// return findParentGroup(blockStructure, targetId);
|
167
|
+
// };
|
168
|
+
// export const addBlockToRoot = (block: RootBlock, newBlock: Block): Block[] => {
|
169
|
+
// return block.map(block => {
|
170
|
+
// if (block.blockId === 'ROOT' && block.type === 'GROUP_BLOCK') {
|
171
|
+
// return {
|
172
|
+
// ...block,
|
173
|
+
// children: block.children ? [...block.children, newBlock] : [newBlock]
|
174
|
+
// };
|
175
|
+
// }
|
176
|
+
// return block;
|
177
|
+
// });
|
178
|
+
// };
|
179
|
+
export var addBulkToTarget = function (block, targetId, bulkBlockIds) {
|
180
|
+
var blockCopy = deepClone(block);
|
181
|
+
var targetBlock = findBlockByBlockId(blockCopy, targetId);
|
182
|
+
if (!targetBlock ||
|
183
|
+
targetBlock.type !== "GROUP_BLOCK" ||
|
184
|
+
!targetBlock.children) {
|
185
|
+
return block;
|
186
|
+
}
|
187
|
+
var bulkBlocks = targetBlock.children.filter(function (child) {
|
188
|
+
if (child.type === "COMPONENT_BLOCK" &&
|
189
|
+
bulkBlockIds.includes(child.blockId.toString())) {
|
190
|
+
return true;
|
191
|
+
}
|
192
|
+
if (child.type === "GROUP_BLOCK" && bulkBlockIds.includes(child.blockId)) {
|
193
|
+
return true;
|
194
|
+
}
|
195
|
+
return false;
|
196
|
+
});
|
197
|
+
if (bulkBlocks.length !== bulkBlockIds.length) {
|
198
|
+
return block;
|
199
|
+
}
|
200
|
+
if (bulkBlocks.length === 0) {
|
201
|
+
return block;
|
202
|
+
}
|
203
|
+
// Remove bulk blocks from target's children
|
204
|
+
targetBlock.children = targetBlock.children.filter(function (child) { return !bulkBlockIds.includes(child.blockId); });
|
205
|
+
var zOrdersDesktop = bulkBlocks
|
206
|
+
.map(function (block) { return block.zOrderDesktopInternal; })
|
207
|
+
.filter(function (each) { return each !== null; });
|
208
|
+
var zOrdersMobile = bulkBlocks
|
209
|
+
.map(function (block) { return block.zOrderMobileInternal; })
|
210
|
+
.filter(function (each) { return each !== null; });
|
211
|
+
var zOrderDesktopInternal = Math.max.apply(Math, zOrdersDesktop);
|
212
|
+
var zOrderMobileInternal = Math.max.apply(Math, zOrdersMobile);
|
213
|
+
// Create the new bulkBlock
|
214
|
+
var bulkBlock = {
|
215
|
+
blockId: "BULK",
|
216
|
+
type: "GROUP_BLOCK",
|
217
|
+
zOrderDesktopInternal: zOrderDesktopInternal,
|
218
|
+
zOrderMobileInternal: zOrderMobileInternal,
|
219
|
+
children: bulkBlocks,
|
220
|
+
};
|
221
|
+
// Add the bulkBlock to the target's children
|
222
|
+
targetBlock.children.push(bulkBlock);
|
223
|
+
return blockCopy;
|
224
|
+
};
|
225
|
+
function findPathHelper(current, targetBlockId) {
|
226
|
+
if (current.blockId === targetBlockId) {
|
227
|
+
return [current.blockId];
|
228
|
+
}
|
229
|
+
if ("children" in current && Array.isArray(current.children)) {
|
230
|
+
for (var _i = 0, _a = current.children; _i < _a.length; _i++) {
|
231
|
+
var child = _a[_i];
|
232
|
+
var result = findPathHelper(child, targetBlockId);
|
233
|
+
if (result !== null) {
|
234
|
+
return __spreadArray([current.blockId], result, true);
|
235
|
+
}
|
236
|
+
}
|
237
|
+
}
|
238
|
+
return null;
|
239
|
+
}
|
240
|
+
export function getBlockWorkDirPath(blockStructure, targetBlockId) {
|
241
|
+
var path = findPathHelper(blockStructure, targetBlockId);
|
242
|
+
return path ? "/" + path.join("/") : "";
|
243
|
+
}
|
244
|
+
export function formatBlockIdToCbId(blockId) {
|
245
|
+
var match = blockId.match(/^CB_(\d+)$/);
|
246
|
+
return match ? parseInt(match[1], 10) : null;
|
247
|
+
}
|
248
|
+
export function formatCbIdToBlockId(cbId) {
|
249
|
+
return "CB_".concat(cbId);
|
250
|
+
}
|
251
|
+
// export const findAccessibleChildrenBlocks = (
|
252
|
+
// block: Block,
|
253
|
+
// targetGroupId: string,
|
254
|
+
// blockIds: string[]
|
255
|
+
// ): string[] => {
|
256
|
+
// const targetBlock = findBlockByBlockId(block, targetGroupId);
|
257
|
+
// if (!targetBlock || !('children' in targetBlock) || !targetBlock.children) {
|
258
|
+
// return [];
|
259
|
+
// }
|
260
|
+
// const result = new Set<string>();
|
261
|
+
// const traverse = (block: Block, rootId: string): boolean => {
|
262
|
+
// if ('children' in block && block.children) {
|
263
|
+
// for (const child of block.children) {
|
264
|
+
// if (blockIds.includes(child.blockId)) {
|
265
|
+
// result.add(rootId);
|
266
|
+
// return true; // Stop traversal for this branch
|
267
|
+
// }
|
268
|
+
// if (traverse(child, rootId)) {
|
269
|
+
// result.add(rootId);
|
270
|
+
// return true; // Stop traversal for this branch
|
271
|
+
// }
|
272
|
+
// }
|
273
|
+
// }
|
274
|
+
// return false;
|
275
|
+
// };
|
276
|
+
// for (const child of targetBlock.children) {
|
277
|
+
// if (blockIds.includes(child.blockId)) {
|
278
|
+
// result.add(child.blockId);
|
279
|
+
// } else {
|
280
|
+
// traverse(child, child.blockId);
|
281
|
+
// }
|
282
|
+
// }
|
283
|
+
// return Array.from(result);
|
284
|
+
// };
|
285
|
+
export function findParentGroupBlock(current, targetBlockId) {
|
286
|
+
// 현재 블록이 그룹(또는 루트) 블록이고, 자식이 있다면 탐색합니다.
|
287
|
+
if ("children" in current && Array.isArray(current.children)) {
|
288
|
+
for (var _i = 0, _a = current.children; _i < _a.length; _i++) {
|
289
|
+
var child = _a[_i];
|
290
|
+
// 자식 중에 targetBlockId를 가진 블록이 있다면,
|
291
|
+
if (child.blockId === targetBlockId) {
|
292
|
+
// 현재 블록이 ROOT라면 부모가 ROOT이므로 null 반환
|
293
|
+
if (current.blockId === "ROOT") {
|
294
|
+
return null;
|
295
|
+
}
|
296
|
+
// 그렇지 않다면 현재 블록이 부모 그룹 블록이므로 반환
|
297
|
+
if (current.type === "GROUP_BLOCK") {
|
298
|
+
return current;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
// 만약 자식이 그룹 블록이라면 재귀적으로 탐색
|
302
|
+
if (child.type === "GROUP_BLOCK") {
|
303
|
+
var found = findParentGroupBlock(child, targetBlockId);
|
304
|
+
if (found !== null) {
|
305
|
+
return found;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
// 찾지 못하면 null 반환
|
311
|
+
return null;
|
312
|
+
}
|
313
|
+
export function findOneComponentBlock(current, targetBlockId) {
|
314
|
+
var targetBlock = findBlockByBlockId(current, targetBlockId);
|
315
|
+
if (!targetBlock) {
|
316
|
+
console.error("Target block not found");
|
317
|
+
return null;
|
318
|
+
}
|
319
|
+
if (targetBlock.type !== "GROUP_BLOCK") {
|
320
|
+
console.error("Target block is not a group block");
|
321
|
+
return null;
|
322
|
+
}
|
323
|
+
// 직속 하위에서 먼저 찾기
|
324
|
+
for (var _i = 0, _a = targetBlock.children; _i < _a.length; _i++) {
|
325
|
+
var child = _a[_i];
|
326
|
+
if (child.type === "COMPONENT_BLOCK") {
|
327
|
+
return child.componentBlockId;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
// 직속 하위에 없다면 재귀적으로 찾기
|
331
|
+
for (var _b = 0, _c = targetBlock.children; _b < _c.length; _b++) {
|
332
|
+
var child = _c[_b];
|
333
|
+
if (child.type === "GROUP_BLOCK") {
|
334
|
+
var found = findOneComponentBlock(child, child.blockId);
|
335
|
+
if (found !== null) {
|
336
|
+
return found;
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
return null;
|
341
|
+
}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
export { ResponsiveGridLayout as ResponsiveGridEditor } from "./ResponsiveGridLayout";
|
2
|
+
export { default as GridEditor } from "./ReactGridLayout";
|
3
|
+
export type { Breakpoint, Breakpoints, DefaultBreakpoints, OnLayoutChangeCallback, ResponsiveLayout, Layout, LayoutItem, } from "./types";
|