pds-dev-kit-web-test 2.7.105 → 2.7.109
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/src/sub/DynamicLayout/GridAutoRowEditor/GridAutoRowEditor.js +25 -20
- package/dist/src/sub/DynamicLayout/sections/CustomSectionWithGroup.d.ts +9 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSectionWithGroup.js +213 -0
- package/dist/src/sub/DynamicLayout/sections/FlexGridCustomSection.js +54 -12
- package/dist/src/sub/DynamicLayout/utils/groupUtils.d.ts +5 -1
- package/dist/src/sub/DynamicLayout/utils/groupUtils.js +28 -13
- package/package.json +1 -1
@@ -52,11 +52,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
53
53
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
54
54
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
55
|
-
require("events");
|
56
55
|
var group_1 = require("publ-echo-test/dist/lib/GridLayoutEditor/group");
|
57
56
|
var renderHelpers_1 = require("publ-echo-test/dist/lib/GridLayoutEditor/utils/renderHelpers");
|
58
57
|
require("publ-echo/dist/lib/GridItem/OutsideClickHandler");
|
59
|
-
var group_2 = require("publ-echo/dist/lib/GridLayoutEditor/group");
|
60
58
|
var react_1 = __importStar(require("react"));
|
61
59
|
var ErrorBoundary_1 = require("../../DynamicLayout/components/Section/ErrorBoundary");
|
62
60
|
var dynamicLayoutContext_1 = require("../../DynamicLayout/dynamicLayoutContext");
|
@@ -79,16 +77,15 @@ var GLE_MIN_WIDTH_MOBILE_PX = "".concat(GRID_CELL_MIN * MOBILE_GRID_COLS, "px");
|
|
79
77
|
// queryData: QueryData;
|
80
78
|
// };
|
81
79
|
var GridAutoRowEditor = (0, react_1.forwardRef)(function CustomSection(props, ref) {
|
82
|
-
var _a,
|
83
|
-
var _c = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext), device = _c.device, editingSectionId = _c.editingSectionId, mode = _c.mode, shortcutKeyMode = _c.shortcutKeyMode, sectionActionHandler = _c.sectionActionHandler, queryData = _c.queryData;
|
80
|
+
var _a = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext), device = _a.device, editingSectionId = _a.editingSectionId, mode = _a.mode, shortcutKeyMode = _a.shortcutKeyMode, sectionActionHandler = _a.sectionActionHandler, queryData = _a.queryData;
|
84
81
|
var componentBlocks = props.componentBlocks, jsonProperties = props.jsonProperties;
|
85
|
-
var
|
82
|
+
var _b = jsonProperties, _c = _b.data, CB_PLACEMENT_PROP_SECTION = _c.CB_PLACEMENT_PROP_SECTION, CB_LAYOUT_PROP_PADDING = _c.CB_LAYOUT_PROP_PADDING, zOrders = _b.zOrders;
|
86
83
|
var layouts = (0, util_1.parsePlacement)(componentBlocks !== null && componentBlocks !== void 0 ? componentBlocks : [], zOrders);
|
87
84
|
var containerRef = (0, react_1.useRef)(null);
|
88
85
|
var size = (0, useResizableObserver_1.useResizeObserver)({ ref: containerRef, box: 'border-box' });
|
89
|
-
var
|
86
|
+
var _d = (0, react_1.useState)(null), selectedCB = _d[0], setSelectedCB = _d[1];
|
90
87
|
var gleRef = (0, react_1.useRef)(null);
|
91
|
-
var
|
88
|
+
var _e = (0, react_1.useState)([]), selectedRows = _e[0], setSelectedRows = _e[1]; // 빈 배열로 초기화
|
92
89
|
var isMobile = device === 'MOBILE';
|
93
90
|
var isEditMode = mode === 'EDIT';
|
94
91
|
// const layoutByDevice = device === 'DESKTOP' ? 'lg' : 'sm';
|
@@ -146,10 +143,10 @@ var GridAutoRowEditor = (0, react_1.forwardRef)(function CustomSection(props, re
|
|
146
143
|
setSelectedCB('BULK');
|
147
144
|
}
|
148
145
|
}, [selectedCB, shortcutKeyMode, sectionActionHandler, setSelectedCB]);
|
149
|
-
var
|
146
|
+
var _f = (0, util_1.parseCustomSectionPlacement)({
|
150
147
|
isMobile: isMobile,
|
151
148
|
customSectionProps: CB_PLACEMENT_PROP_SECTION
|
152
|
-
}), width =
|
149
|
+
}), width = _f.width, minHeight = _f.minHeight, isFullWidth = _f.isFullWidth;
|
153
150
|
var customSectionStyles = {
|
154
151
|
minHeight: "".concat(minHeight, "vh"),
|
155
152
|
width: '100%',
|
@@ -208,17 +205,25 @@ var GridAutoRowEditor = (0, react_1.forwardRef)(function CustomSection(props, re
|
|
208
205
|
return 16;
|
209
206
|
})();
|
210
207
|
var pedigree = jsonProperties === null || jsonProperties === void 0 ? void 0 : jsonProperties.pedigree;
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
208
|
+
// const [editingGroupBlock, setEditingGroupBlock] = useState<string>('ROOT');
|
209
|
+
// const editableCBIds = findDirectChildrenCbIds(pedigree, 'ROOT');
|
210
|
+
// const groupblocks = findGroupBlocks(pedigree, editingGroupBlock) ?? [];
|
211
|
+
// const handleGroupBlockDoubleClick = (blockId: string) => {
|
212
|
+
// setEditingGroupBlock(blockId);
|
213
|
+
// };
|
214
|
+
var _g = (0, react_1.useState)([]), pinnedGBs = _g[0], setPinnedGBs = _g[1];
|
215
|
+
// const pinnedChildrens = pinnedGBs.map((gbId) => findAllChildrenCbIds(pedigree, gbId)).flat();
|
216
|
+
// const currentDepthCbs = props.componentBlocks?.filter((cb) => {
|
217
|
+
// return editableCBIds.includes(cb.id);
|
218
|
+
// });
|
219
|
+
var onToggleGBPinned = function (gbId) {
|
220
|
+
setPinnedGBs(function (prev) {
|
221
|
+
if (prev.includes(gbId)) {
|
222
|
+
return prev.filter(function (id) { return id !== gbId; });
|
223
|
+
}
|
224
|
+
return __spreadArray(__spreadArray([], prev, true), [gbId], false);
|
225
|
+
});
|
216
226
|
};
|
217
|
-
var _k = (0, react_1.useState)([]), pinnedGBs = _k[0], setPinnedGBs = _k[1];
|
218
|
-
var pinnedChildrens = pinnedGBs.map(function (gbId) { return (0, group_1.findAllChildrenCbIds)(pedigree, gbId); }).flat();
|
219
|
-
var currentDepthCbs = (_b = props.componentBlocks) === null || _b === void 0 ? void 0 : _b.filter(function (cb) {
|
220
|
-
return editableCBIds.includes(cb.id);
|
221
|
-
});
|
222
227
|
return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(dynamicLayoutContext_1.dynamicLayoutContext.Provider, __assign({ value: {
|
223
228
|
device: device,
|
224
229
|
mode: mode,
|
@@ -265,7 +270,7 @@ var GridAutoRowEditor = (0, react_1.forwardRef)(function CustomSection(props, re
|
|
265
270
|
backgroundColor: '#e8e1e189',
|
266
271
|
border: '1px solid #6b666688'
|
267
272
|
}, "data-row": rIdx + 1, "data-col": cIdx + 1 }, "bg-grid-item-".concat(rIdx + 1, "-").concat(cIdx + 1))); }) }), "bg-grid-row-".concat(rIdx + 1)));
|
268
|
-
}), pedigree.children.map(function (child) { return ((0, jsx_runtime_1.jsx)(groupUtils_1.default, { block: child, rowHeight: rowHeight, layoutItems: layouts[device === 'DESKTOP' ? 'lg' : 'sm'], cbs: props.componentBlocks, device: device, selectedRows: selectedRows }, child.blockId)); })] })) })) })) }) })) }));
|
273
|
+
}), pedigree.children.map(function (child) { return ((0, jsx_runtime_1.jsx)(groupUtils_1.default, { block: child, rowHeight: rowHeight, layoutItems: layouts[device === 'DESKTOP' ? 'lg' : 'sm'], cbs: props.componentBlocks, device: device, selectedRows: selectedRows, pinnedGBs: pinnedGBs, onToggleGBPinned: onToggleGBPinned, isEditMode: true }, child.blockId)); })] })) })) })) }) })) }));
|
269
274
|
});
|
270
275
|
function GroupBlockRender(_a) {
|
271
276
|
var block = _a.block, layouts = _a.layouts, pedigree = _a.pedigree, isEditing = _a.isEditing, isPinned = _a.isPinned, componentBlocks = _a.componentBlocks, onTogglePinned = _a.onTogglePinned, onDoubleClick = _a.onDoubleClick, onDoubleClickOutside = _a.onDoubleClickOutside;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { ISection } from '../types';
|
3
|
+
import type { Layout } from 'publ-echo-test/dist/lib/GridLayoutEditor/types';
|
4
|
+
export type LayoutsType = {
|
5
|
+
sm: Layout;
|
6
|
+
lg: Layout;
|
7
|
+
};
|
8
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ISection & React.RefAttributes<unknown>>>;
|
9
|
+
export default _default;
|
@@ -0,0 +1,213 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
4
|
+
return cooked;
|
5
|
+
};
|
6
|
+
var __assign = (this && this.__assign) || function () {
|
7
|
+
__assign = Object.assign || function(t) {
|
8
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
9
|
+
s = arguments[i];
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
11
|
+
t[p] = s[p];
|
12
|
+
}
|
13
|
+
return t;
|
14
|
+
};
|
15
|
+
return __assign.apply(this, arguments);
|
16
|
+
};
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
|
+
if (k2 === undefined) k2 = k;
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
22
|
+
}
|
23
|
+
Object.defineProperty(o, k2, desc);
|
24
|
+
}) : (function(o, m, k, k2) {
|
25
|
+
if (k2 === undefined) k2 = k;
|
26
|
+
o[k2] = m[k];
|
27
|
+
}));
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
30
|
+
}) : function(o, v) {
|
31
|
+
o["default"] = v;
|
32
|
+
});
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
34
|
+
if (mod && mod.__esModule) return mod;
|
35
|
+
var result = {};
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
37
|
+
__setModuleDefault(result, mod);
|
38
|
+
return result;
|
39
|
+
};
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
|
+
};
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
44
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
45
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
46
|
+
var react_1 = __importStar(require("react"));
|
47
|
+
var ErrorBoundary_1 = require("../../DynamicLayout/components/Section/ErrorBoundary");
|
48
|
+
var dynamicLayoutContext_1 = require("../../DynamicLayout/dynamicLayoutContext");
|
49
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
50
|
+
var components_1 = require("../components");
|
51
|
+
var gleStyles_1 = require("../gleStyles");
|
52
|
+
var FlexGridItem_1 = __importDefault(require("./CustomSection/FlexGridItem"));
|
53
|
+
var useResizableObserver_1 = require("./CustomSection/hooks/useResizableObserver");
|
54
|
+
var util_1 = require("./CustomSection/util");
|
55
|
+
var parseSectionPadding_1 = __importDefault(require("./CustomSection/util/layoutPropParsers/parseSectionPadding"));
|
56
|
+
var GRID_CELL_MIN = 24;
|
57
|
+
var DESKTOP_GRID_COLS = 24;
|
58
|
+
var MOBILE_GRID_COLS = 8;
|
59
|
+
var GLE_MIN_WIDTH_DESKTOP_PX = "".concat(GRID_CELL_MIN * DESKTOP_GRID_COLS, "px");
|
60
|
+
var GLE_MIN_WIDTH_MOBILE_PX = "".concat(GRID_CELL_MIN * MOBILE_GRID_COLS, "px");
|
61
|
+
var FlexGridCustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
|
62
|
+
var _a;
|
63
|
+
var _b = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext), device = _b.device, editingSectionId = _b.editingSectionId, mode = _b.mode, shortcutKeyMode = _b.shortcutKeyMode, sectionActionHandler = _b.sectionActionHandler;
|
64
|
+
var componentBlocks = props.componentBlocks, jsonProperties = props.jsonProperties;
|
65
|
+
var _c = jsonProperties, _d = _c.data, CB_PLACEMENT_PROP_SECTION = _d.CB_PLACEMENT_PROP_SECTION, CB_LAYOUT_PROP_PADDING = _d.CB_LAYOUT_PROP_PADDING, zOrders = _c.zOrders;
|
66
|
+
var containerRef = (0, react_1.useRef)(null);
|
67
|
+
var size = (0, useResizableObserver_1.useResizeObserver)({ ref: containerRef, box: 'border-box' });
|
68
|
+
var _e = (0, react_1.useState)(null), selectedCB = _e[0], setSelectedCB = _e[1];
|
69
|
+
var gleRef = (0, react_1.useRef)(null);
|
70
|
+
var isMobile = device === 'MOBILE';
|
71
|
+
var isEditMode = mode === 'EDIT';
|
72
|
+
// const layoutByDevice = device === 'DESKTOP' ? 'lg' : 'sm';
|
73
|
+
// const [layouts] = useState<LayoutsType>(() => {
|
74
|
+
// const { lg, sm } = parsePlacement(componentBlocks ?? []);
|
75
|
+
// return {
|
76
|
+
// lg,
|
77
|
+
// sm
|
78
|
+
// };
|
79
|
+
// });
|
80
|
+
(0, react_1.useEffect)(function () {
|
81
|
+
if (editingSectionId !== props.id) {
|
82
|
+
setSelectedCB(null);
|
83
|
+
// breakGroupCB();
|
84
|
+
}
|
85
|
+
}, [editingSectionId]);
|
86
|
+
// NOTE: 추후에 event를 외부에서 전달받게하거나, 아예 상태를 끌어올리거나 해야합니다.
|
87
|
+
(0, react_1.useLayoutEffect)(function () {
|
88
|
+
if (props.id !== editingSectionId) {
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
if (!shortcutKeyMode) {
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
if (shortcutKeyMode === 'SELECT_ALL') {
|
95
|
+
if ((componentBlocks === null || componentBlocks === void 0 ? void 0 : componentBlocks.length) === 1) {
|
96
|
+
setSelectedCB(componentBlocks[0].id);
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
// makeAllInOneGroup();
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
if (shortcutKeyMode === 'MANUAL_BULK_BREAK') {
|
103
|
+
// breakGroupCB();
|
104
|
+
setSelectedCB(null);
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
}, [shortcutKeyMode, setSelectedCB]);
|
108
|
+
(0, react_1.useLayoutEffect)(function () {
|
109
|
+
if (props.id !== editingSectionId) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
if (shortcutKeyMode === 'MANUAL_COLLISION_SELECT') {
|
113
|
+
if (!selectedCB || selectedCB === 'BULK') {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
// makeCollisionGroup(selectedCB);
|
117
|
+
// sectionActionHandler &&
|
118
|
+
// sectionActionHandler({
|
119
|
+
// type: '@CUSTOMSECTION/BLOCK_CLICKED',
|
120
|
+
// payload: {
|
121
|
+
// block:
|
122
|
+
// }
|
123
|
+
// });
|
124
|
+
setSelectedCB('BULK');
|
125
|
+
}
|
126
|
+
}, [selectedCB, shortcutKeyMode, sectionActionHandler, setSelectedCB]);
|
127
|
+
var _f = (0, util_1.parseCustomSectionPlacement)({
|
128
|
+
isMobile: isMobile,
|
129
|
+
customSectionProps: CB_PLACEMENT_PROP_SECTION
|
130
|
+
}), width = _f.width, minHeight = _f.minHeight, isFullWidth = _f.isFullWidth;
|
131
|
+
var customSectionStyles = {
|
132
|
+
minHeight: "".concat(minHeight, "vh"),
|
133
|
+
width: '100%',
|
134
|
+
maxWidth: isFullWidth ? '' : "".concat(width, "px")
|
135
|
+
};
|
136
|
+
var onClickSection = function () {
|
137
|
+
if (!isEditMode) {
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
setSelectedCB(null);
|
141
|
+
sectionActionHandler &&
|
142
|
+
sectionActionHandler({
|
143
|
+
type: '@CUSTOMSECTION/SECTION_CLICKED',
|
144
|
+
payload: {
|
145
|
+
sectionId: props.id
|
146
|
+
}
|
147
|
+
});
|
148
|
+
};
|
149
|
+
var padding = (0, parseSectionPadding_1.default)(CB_LAYOUT_PROP_PADDING, device);
|
150
|
+
var sectionRow = CB_PLACEMENT_PROP_SECTION[device === 'DESKTOP'
|
151
|
+
? 'CB_PLACEMENT_PROP_SECTION_SPEC_ROWS'
|
152
|
+
: 'CB_PLACEMENT_PROP_SECTION_SPEC_ROWS:MOBILE'];
|
153
|
+
var rowHeight = (function () {
|
154
|
+
if (!size.width) {
|
155
|
+
return 50;
|
156
|
+
}
|
157
|
+
if (device === 'MOBILE') {
|
158
|
+
var cellWidth_1 = size.width / MOBILE_GRID_COLS;
|
159
|
+
return cellWidth_1 * 0.56;
|
160
|
+
}
|
161
|
+
var cellWidth = size.width / DESKTOP_GRID_COLS;
|
162
|
+
return cellWidth * 0.56;
|
163
|
+
})();
|
164
|
+
var baseFontSize = (function () {
|
165
|
+
var _a, _b;
|
166
|
+
if (!size.width) {
|
167
|
+
return 16;
|
168
|
+
}
|
169
|
+
var responsiveFontMode = !!((_b = (_a = props.jsonProperties) === null || _a === void 0 ? void 0 : _a.data.CB_CONTENT_PROP_SECTION) === null || _b === void 0 ? void 0 : _b.CB_CONTENT_PROP_SECTION_SPEC_VARIABLEROOTFONTSIZE);
|
170
|
+
if (device === 'MOBILE') {
|
171
|
+
if (responsiveFontMode) {
|
172
|
+
return size.width * 0.0421;
|
173
|
+
}
|
174
|
+
if (size.width < 327) {
|
175
|
+
return Math.max(getDefensiveFontSize(device, size.width), 14);
|
176
|
+
}
|
177
|
+
return 16;
|
178
|
+
}
|
179
|
+
// NOTE: Desktop
|
180
|
+
if (responsiveFontMode) {
|
181
|
+
return size.width * 0.0133;
|
182
|
+
}
|
183
|
+
if (size.width < 1200) {
|
184
|
+
return Math.max(getDefensiveFontSize(device, size.width), 16);
|
185
|
+
}
|
186
|
+
return 16;
|
187
|
+
})();
|
188
|
+
return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(gleStyles_1.S_gleStyles, { children: (0, jsx_runtime_1.jsx)(S_SectionWrapper, __assign({ ref: gleRef, "x-dlayout-section-type": "NO_NAME", onClick: onClickSection }, { children: (0, jsx_runtime_1.jsx)(components_1.CustomSection, __assign({}, props, { isMobile: isMobile, overrideStyles: {
|
189
|
+
minHeight: customSectionStyles.minHeight,
|
190
|
+
paddingTop: padding.top,
|
191
|
+
paddingBottom: padding.bottom,
|
192
|
+
paddingRight: padding.right,
|
193
|
+
paddingLeft: padding.left
|
194
|
+
} }, { children: (0, jsx_runtime_1.jsx)(GridContainer, __assign({ ref: containerRef, cols: isMobile ? 8 : 24, rowHeight: rowHeight, sectionRow: sectionRow !== null && sectionRow !== void 0 ? sectionRow : 0, style: {
|
195
|
+
width: customSectionStyles.width,
|
196
|
+
maxWidth: customSectionStyles.maxWidth,
|
197
|
+
minWidth: isMobile ? GLE_MIN_WIDTH_MOBILE_PX : GLE_MIN_WIDTH_DESKTOP_PX,
|
198
|
+
fontSize: "".concat(baseFontSize, "px")
|
199
|
+
} }, { children: (_a = props.componentBlocks) === null || _a === void 0 ? void 0 : _a.map(function (cb, index) {
|
200
|
+
var _a;
|
201
|
+
return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(FlexGridItem_1.default, { cb: cb, index: index, device: device, rowHeight: rowHeight, zIndex: (_a = zOrders === null || zOrders === void 0 ? void 0 : zOrders[device === 'DESKTOP' ? 'desktop' : 'mobile'][cb.id]) !== null && _a !== void 0 ? _a : 0 }) }, cb.id));
|
202
|
+
}) })) })) })) }) }));
|
203
|
+
});
|
204
|
+
var GridContainer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid; /* Space between grid items */\n gap: 10px;\n grid-auto-rows: minmax(", ", auto);\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: repeat(\n ", ",\n minmax(", ", auto)\n );\n padding: 10px 10px;\n\n * {\n box-sizing: border-box;\n }\n"], ["\n display: grid; /* Space between grid items */\n gap: 10px;\n grid-auto-rows: minmax(", ", auto);\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: repeat(\n ", ",\n minmax(", ", auto)\n );\n padding: 10px 10px;\n\n * {\n box-sizing: border-box;\n }\n"])), function (props) { return "".concat(props.rowHeight, "px"); }, function (props) { return props.cols; }, function (props) { return props.sectionRow; }, function (props) { return "".concat(props.rowHeight, "px"); });
|
205
|
+
var S_SectionWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
206
|
+
exports.default = react_1.default.memo(FlexGridCustomSection);
|
207
|
+
function getDefensiveFontSize(device, width) {
|
208
|
+
if (device === 'MOBILE') {
|
209
|
+
return width * (0.0000868 * width + 0.0202);
|
210
|
+
}
|
211
|
+
return width * (0.0000246 * width - 0.01618);
|
212
|
+
}
|
213
|
+
var templateObject_1, templateObject_2;
|
@@ -37,6 +37,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
37
|
__setModuleDefault(result, mod);
|
38
38
|
return result;
|
39
39
|
};
|
40
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
41
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
42
|
+
if (ar || !(i in from)) {
|
43
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
44
|
+
ar[i] = from[i];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
48
|
+
};
|
40
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
41
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
51
|
};
|
@@ -49,7 +58,8 @@ var dynamicLayoutContext_1 = require("../../DynamicLayout/dynamicLayoutContext")
|
|
49
58
|
var styled_components_1 = __importDefault(require("styled-components"));
|
50
59
|
var components_1 = require("../components");
|
51
60
|
var gleStyles_1 = require("../gleStyles");
|
52
|
-
var
|
61
|
+
var groupUtils_1 = __importDefault(require("../utils/groupUtils"));
|
62
|
+
require("./CustomSection/FlexGridItem");
|
53
63
|
var useResizableObserver_1 = require("./CustomSection/hooks/useResizableObserver");
|
54
64
|
var util_1 = require("./CustomSection/util");
|
55
65
|
var parseSectionPadding_1 = __importDefault(require("./CustomSection/util/layoutPropParsers/parseSectionPadding"));
|
@@ -59,13 +69,12 @@ var MOBILE_GRID_COLS = 8;
|
|
59
69
|
var GLE_MIN_WIDTH_DESKTOP_PX = "".concat(GRID_CELL_MIN * DESKTOP_GRID_COLS, "px");
|
60
70
|
var GLE_MIN_WIDTH_MOBILE_PX = "".concat(GRID_CELL_MIN * MOBILE_GRID_COLS, "px");
|
61
71
|
var FlexGridCustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
|
62
|
-
var _a;
|
63
|
-
var _b = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext), device = _b.device, editingSectionId = _b.editingSectionId, mode = _b.mode, shortcutKeyMode = _b.shortcutKeyMode, sectionActionHandler = _b.sectionActionHandler;
|
72
|
+
var _a = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext), device = _a.device, editingSectionId = _a.editingSectionId, mode = _a.mode, shortcutKeyMode = _a.shortcutKeyMode, sectionActionHandler = _a.sectionActionHandler;
|
64
73
|
var componentBlocks = props.componentBlocks, jsonProperties = props.jsonProperties;
|
65
|
-
var
|
74
|
+
var _b = jsonProperties, _c = _b.data, CB_PLACEMENT_PROP_SECTION = _c.CB_PLACEMENT_PROP_SECTION, CB_LAYOUT_PROP_PADDING = _c.CB_LAYOUT_PROP_PADDING, zOrders = _b.zOrders;
|
66
75
|
var containerRef = (0, react_1.useRef)(null);
|
67
76
|
var size = (0, useResizableObserver_1.useResizeObserver)({ ref: containerRef, box: 'border-box' });
|
68
|
-
var
|
77
|
+
var _d = (0, react_1.useState)(null), selectedCB = _d[0], setSelectedCB = _d[1];
|
69
78
|
var gleRef = (0, react_1.useRef)(null);
|
70
79
|
var isMobile = device === 'MOBILE';
|
71
80
|
var isEditMode = mode === 'EDIT';
|
@@ -124,10 +133,10 @@ var FlexGridCustomSection = (0, react_1.forwardRef)(function CustomSection(props
|
|
124
133
|
setSelectedCB('BULK');
|
125
134
|
}
|
126
135
|
}, [selectedCB, shortcutKeyMode, sectionActionHandler, setSelectedCB]);
|
127
|
-
var
|
136
|
+
var _e = (0, util_1.parseCustomSectionPlacement)({
|
128
137
|
isMobile: isMobile,
|
129
138
|
customSectionProps: CB_PLACEMENT_PROP_SECTION
|
130
|
-
}), width =
|
139
|
+
}), width = _e.width, minHeight = _e.minHeight, isFullWidth = _e.isFullWidth;
|
131
140
|
var customSectionStyles = {
|
132
141
|
minHeight: "".concat(minHeight, "vh"),
|
133
142
|
width: '100%',
|
@@ -185,21 +194,54 @@ var FlexGridCustomSection = (0, react_1.forwardRef)(function CustomSection(props
|
|
185
194
|
}
|
186
195
|
return 16;
|
187
196
|
})();
|
197
|
+
var pedigree = jsonProperties === null || jsonProperties === void 0 ? void 0 : jsonProperties.pedigree;
|
198
|
+
var layouts = (0, util_1.parsePlacement)(componentBlocks !== null && componentBlocks !== void 0 ? componentBlocks : [], zOrders);
|
199
|
+
var _f = (0, react_1.useState)([]), selectedRows = _f[0], setSelectedRows = _f[1];
|
200
|
+
var _g = (0, react_1.useState)([]), pinnedGBs = _g[0], setPinnedGBs = _g[1];
|
201
|
+
var onToggleGBPinned = function (gbId) {
|
202
|
+
setPinnedGBs(function (prev) {
|
203
|
+
if (prev.includes(gbId)) {
|
204
|
+
return prev.filter(function (id) { return id !== gbId; });
|
205
|
+
}
|
206
|
+
return __spreadArray(__spreadArray([], prev, true), [gbId], false);
|
207
|
+
});
|
208
|
+
};
|
188
209
|
return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(gleStyles_1.S_gleStyles, { children: (0, jsx_runtime_1.jsx)(S_SectionWrapper, __assign({ ref: gleRef, "x-dlayout-section-type": "NO_NAME", onClick: onClickSection }, { children: (0, jsx_runtime_1.jsx)(components_1.CustomSection, __assign({}, props, { isMobile: isMobile, overrideStyles: {
|
189
210
|
minHeight: customSectionStyles.minHeight,
|
190
211
|
paddingTop: padding.top,
|
191
212
|
paddingBottom: padding.bottom,
|
192
213
|
paddingRight: padding.right,
|
193
214
|
paddingLeft: padding.left
|
194
|
-
} }, { children: (0, jsx_runtime_1.
|
215
|
+
} }, { children: (0, jsx_runtime_1.jsxs)(GridContainer, __assign({ ref: containerRef, cols: isMobile ? 8 : 24, rowHeight: rowHeight, sectionRow: sectionRow !== null && sectionRow !== void 0 ? sectionRow : 0, style: {
|
195
216
|
width: customSectionStyles.width,
|
196
217
|
maxWidth: customSectionStyles.maxWidth,
|
197
218
|
minWidth: isMobile ? GLE_MIN_WIDTH_MOBILE_PX : GLE_MIN_WIDTH_DESKTOP_PX,
|
198
219
|
fontSize: "".concat(baseFontSize, "px")
|
199
|
-
} }, { children: (
|
200
|
-
|
201
|
-
|
202
|
-
|
220
|
+
} }, { children: [Array.from({ length: sectionRow !== null && sectionRow !== void 0 ? sectionRow : 0 }).map(function (_, rIdx) {
|
221
|
+
// selectedRows 배열에 현재 행의 인덱스가 포함되어 있는지 확인합니다.
|
222
|
+
var isSelected = selectedRows.includes(rIdx);
|
223
|
+
var handleRowClick = function () {
|
224
|
+
setSelectedRows(function (prevSelectedRows) {
|
225
|
+
// 이미 선택된 상태라면, 배열에서 해당 인덱스를 제거합니다 (선택 해제).
|
226
|
+
if (isSelected) {
|
227
|
+
return prevSelectedRows.filter(function (rowIdx) { return rowIdx !== rIdx; });
|
228
|
+
}
|
229
|
+
// 선택되지 않은 상태라면, 배열에 현재 인덱스를 추가합니다 (선택).
|
230
|
+
return __spreadArray(__spreadArray([], prevSelectedRows, true), [rIdx], false);
|
231
|
+
});
|
232
|
+
};
|
233
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ className: "bg-grid-row ".concat(isSelected ? 'selected' : ''), style: {
|
234
|
+
gridRow: "".concat(rIdx + 1),
|
235
|
+
gridColumn: "1 / -1",
|
236
|
+
display: 'contents',
|
237
|
+
cursor: 'pointer'
|
238
|
+
}, onClick: handleRowClick }, { children: Array.from({ length: isMobile ? MOBILE_GRID_COLS : DESKTOP_GRID_COLS }).map(function (_, cIdx) { return ((0, jsx_runtime_1.jsx)("div", { className: "bg-grid-item", style: {
|
239
|
+
gridArea: "".concat(rIdx + 1, " / ").concat(cIdx + 1),
|
240
|
+
position: 'relative',
|
241
|
+
backgroundColor: '#e8e1e189',
|
242
|
+
border: '1px solid #6b666688'
|
243
|
+
}, "data-row": rIdx + 1, "data-col": cIdx + 1 }, "bg-grid-item-".concat(rIdx + 1, "-").concat(cIdx + 1))); }) }), "bg-grid-row-".concat(rIdx + 1)));
|
244
|
+
}), pedigree.children.map(function (child) { return ((0, jsx_runtime_1.jsx)(groupUtils_1.default, { block: child, rowHeight: rowHeight, layoutItems: layouts[device === 'DESKTOP' ? 'lg' : 'sm'], cbs: props.componentBlocks, device: device, selectedRows: selectedRows, pinnedGBs: pinnedGBs, onToggleGBPinned: onToggleGBPinned, isEditMode: true }, child.blockId)); })] })) })) })) }) }));
|
203
245
|
});
|
204
246
|
var GridContainer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid; /* Space between grid items */\n gap: 10px;\n grid-auto-rows: minmax(", ", auto);\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: repeat(\n ", ",\n minmax(", ", auto)\n );\n padding: 10px 10px;\n\n * {\n box-sizing: border-box;\n }\n"], ["\n display: grid; /* Space between grid items */\n gap: 10px;\n grid-auto-rows: minmax(", ", auto);\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: repeat(\n ", ",\n minmax(", ", auto)\n );\n padding: 10px 10px;\n\n * {\n box-sizing: border-box;\n }\n"])), function (props) { return "".concat(props.rowHeight, "px"); }, function (props) { return props.cols; }, function (props) { return props.sectionRow; }, function (props) { return "".concat(props.rowHeight, "px"); });
|
205
247
|
var S_SectionWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
@@ -4,13 +4,17 @@ import type { Device } from '../sections/CustomSection/util/types';
|
|
4
4
|
import type { LayoutItem } from 'publ-echo/dist/lib';
|
5
5
|
import type { Block } from 'publ-echo/dist/lib/GridLayoutEditor/group';
|
6
6
|
export declare function findAllChildrenCbIds(block: Block, targetGroupId: string): number[];
|
7
|
-
export default function RenderPedigreeRecursively({ block, layoutItems, cbs, parentGroupArea, rowHeight, device, selectedRows }: {
|
7
|
+
export default function RenderPedigreeRecursively({ isEditMode, block, layoutItems, cbs, parentGroupArea, rowHeight, device, selectedRows, pinnedGBs, isParentGroupPinned, onToggleGBPinned }: {
|
8
|
+
isEditMode: boolean;
|
8
9
|
block: Block;
|
9
10
|
layoutItems: LayoutItem[];
|
10
11
|
cbs: ComponentBlock[];
|
11
12
|
rowHeight: number;
|
12
13
|
device: Device;
|
13
14
|
selectedRows: number[];
|
15
|
+
pinnedGBs: string[];
|
16
|
+
onToggleGBPinned: (gbId: string) => void;
|
17
|
+
isParentGroupPinned?: boolean;
|
14
18
|
parentGroupArea?: {
|
15
19
|
rowStart: number;
|
16
20
|
colStart: number;
|
@@ -78,7 +78,7 @@ function findAllChildrenCbIds(block, targetGroupId) {
|
|
78
78
|
}
|
79
79
|
exports.findAllChildrenCbIds = findAllChildrenCbIds;
|
80
80
|
function RenderPedigreeRecursively(_a) {
|
81
|
-
var block = _a.block, layoutItems = _a.layoutItems, cbs = _a.cbs, parentGroupArea = _a.parentGroupArea, rowHeight = _a.rowHeight, device = _a.device, selectedRows = _a.selectedRows;
|
81
|
+
var isEditMode = _a.isEditMode, block = _a.block, layoutItems = _a.layoutItems, cbs = _a.cbs, parentGroupArea = _a.parentGroupArea, rowHeight = _a.rowHeight, device = _a.device, selectedRows = _a.selectedRows, pinnedGBs = _a.pinnedGBs, _b = _a.isParentGroupPinned, isParentGroupPinned = _b === void 0 ? false : _b, onToggleGBPinned = _a.onToggleGBPinned;
|
82
82
|
var type = block.type;
|
83
83
|
if (type === 'GROUP_BLOCK') {
|
84
84
|
var childrenIds = findAllChildrenCbIds(block, block.blockId).map(function (i) { return i.toString(); });
|
@@ -99,13 +99,16 @@ function RenderPedigreeRecursively(_a) {
|
|
99
99
|
var relativeSelectedRows_1 = selectedRows
|
100
100
|
.map(function (row) { return row - gridArea_1.rowStart + 1; })
|
101
101
|
.filter(function (row) { return row >= 0 && row <= bounding_1.h; });
|
102
|
-
|
102
|
+
var isGBPinned_1 = pinnedGBs.includes(block.blockId);
|
103
|
+
var defaultHeight = getMaxHeight({ cols: bounding_1.w, rows: bounding_1.h, x: bounding_1.x, y: bounding_1.y }, rowHeight);
|
104
|
+
return ((0, jsx_runtime_1.jsxs)(S_GroupItem, __assign({ cols: bounding_1.w, sectionRow: bounding_1.h, rowHeight: rowHeight, selectedRows: relativeSelectedRows_1, style: {
|
103
105
|
gridArea: gridAreaObjToString(relativeGridArea_1),
|
104
106
|
display: 'grid',
|
105
107
|
zIndex: device === 'DESKTOP'
|
106
108
|
? block.zOrderDesktopInternal
|
107
|
-
: block.zOrderMobileInternal
|
108
|
-
|
109
|
+
: block.zOrderMobileInternal,
|
110
|
+
maxHeight: isGBPinned_1 ? defaultHeight : 'none'
|
111
|
+
} }, { children: [isEditMode && ((0, jsx_runtime_1.jsx)(S_Pinned, { children: isGBPinned_1 ? ((0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: function () { return onToggleGBPinned(block.blockId); } }, { children: "H\uACE0\uC815\uB428 \uD83D\uDCCC" }))) : ((0, jsx_runtime_1.jsx)("button", __assign({ type: "button", onClick: function () { return onToggleGBPinned(block.blockId); } }, { children: "H\uB298\uC5B4\uB0A8 \uD83E\uDEB1" }))) })), block.children.map(function (child) { return ((0, jsx_runtime_1.jsx)(RenderPedigreeRecursively, { rowHeight: rowHeight, block: child, layoutItems: layoutItems, cbs: cbs, parentGroupArea: gridArea_1, device: device, selectedRows: relativeSelectedRows_1, pinnedGBs: pinnedGBs, onToggleGBPinned: onToggleGBPinned, isEditMode: isEditMode, isParentGroupPinned: isGBPinned_1 }, child.blockId)); })] })));
|
109
112
|
}
|
110
113
|
// default: TYPE === 'COMPONENT_BLOCK'
|
111
114
|
var cbIndex = cbs.findIndex(function (c) { return c.blockId === block.blockId; });
|
@@ -119,8 +122,6 @@ function RenderPedigreeRecursively(_a) {
|
|
119
122
|
var relativeGridArea = parentGroupArea
|
120
123
|
? calculateRelativeGridArea(originalGridArea, parentGroupArea)
|
121
124
|
: originalGridArea;
|
122
|
-
var isEditing = false;
|
123
|
-
var isPinned = false;
|
124
125
|
return (
|
125
126
|
// <S_GridItem
|
126
127
|
// style={{
|
@@ -129,18 +130,18 @@ function RenderPedigreeRecursively(_a) {
|
|
129
130
|
// data-og-grid-area={originalGridAreaString}
|
130
131
|
// data-rel-grid-area={gridAreaObjToString(relativeGridArea)}
|
131
132
|
// >
|
132
|
-
(0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(FlexGridItem_1.default, { cb: cb, index: cbIndex, device: device, rowHeight:
|
133
|
+
(0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(FlexGridItem_1.default, { cb: cb, index: cbIndex, device: device, rowHeight: rowHeight, zIndex: device === 'DESKTOP'
|
133
134
|
? block.zOrderDesktopInternal
|
134
135
|
: block.zOrderMobileInternal, style: {
|
135
|
-
pointerEvents: 'none',
|
136
136
|
gridArea: gridAreaObjToString(relativeGridArea),
|
137
|
-
|
138
|
-
|
139
|
-
}, showPinned:
|
137
|
+
pointerEvents: isEditMode ? 'none' : 'auto',
|
138
|
+
boxShadow: isEditMode ? '0 0 0 2px red' : ''
|
139
|
+
}, showPinned: parentGroupArea ? false : true, isParentGroupPinned: isParentGroupPinned }) }, cb.id)
|
140
140
|
// </S_GridItem>
|
141
141
|
);
|
142
142
|
}
|
143
143
|
exports.default = RenderPedigreeRecursively;
|
144
|
+
var S_Pinned = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n pointer-events: auto;\n position: absolute;\n right: 0;\n top: 0;\n z-index: 9999999;\n"], ["\n pointer-events: auto;\n position: absolute;\n right: 0;\n top: 0;\n z-index: 9999999;\n"])));
|
144
145
|
function clamp(num, min, max) {
|
145
146
|
return Math.max(Math.min(num, max), min);
|
146
147
|
}
|
@@ -194,7 +195,21 @@ function calculateRelativeGridArea(componentArea, parentArea) {
|
|
194
195
|
colEnd: componentArea.colEnd - parentArea.colStart + 1
|
195
196
|
};
|
196
197
|
}
|
197
|
-
|
198
|
+
function getMaxHeight(props, rowHeight) {
|
199
|
+
var gap = 10;
|
200
|
+
var rows = props.rows;
|
201
|
+
var height = rows * rowHeight + (rows - 1) * gap;
|
202
|
+
return height;
|
203
|
+
// if (device === 'DESKTOP') {
|
204
|
+
// const { rows } = props;
|
205
|
+
// const height = rows * rowHeight + (rows - 1) * gap;
|
206
|
+
// return height;
|
207
|
+
// }
|
208
|
+
// const rowsMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS:MOBILE'];
|
209
|
+
// const height = rowsMobile * rowHeight + (rowsMobile - 1) * gap;
|
210
|
+
// return height;
|
211
|
+
}
|
212
|
+
var S_GroupItem = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 0 0 0 3px blue;\n gap: 10px;\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: ", ";\n position: relative; /* \uBC30\uC5F4\uC744 \uACF5\uBC31\uC73C\uB85C \uAD6C\uBD84\uB41C \uBB38\uC790\uC5F4\uB85C \uD569\uCE69\uB2C8\uB2E4. */\n"], ["\n box-shadow: 0 0 0 3px blue;\n gap: 10px;\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: ", ";\n position: relative; /* \uBC30\uC5F4\uC744 \uACF5\uBC31\uC73C\uB85C \uAD6C\uBD84\uB41C \uBB38\uC790\uC5F4\uB85C \uD569\uCE69\uB2C8\uB2E4. */\n"])), function (props) { return props.cols; }, function (props) {
|
198
213
|
// // 전체 행 개수만큼 배열을 생성하여 각 행의 CSS 값을 정의합니다.
|
199
214
|
return Array.from({ length: props.sectionRow })
|
200
215
|
.map(function (_, index) {
|
@@ -206,4 +221,4 @@ var S_GroupItem = styled_components_1.default.div(templateObject_1 || (templateO
|
|
206
221
|
)
|
207
222
|
.join(' ');
|
208
223
|
});
|
209
|
-
var templateObject_1;
|
224
|
+
var templateObject_1, templateObject_2;
|