publ-echo-test 0.0.105 → 0.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { GridItemProps } from "./types";
|
3
3
|
import { PropsWithChildren } from "../types";
|
4
|
-
declare const GroupItem: ({ children, ...props }: PropsWithChildren<GridItemProps
|
4
|
+
declare const GroupItem: ({ children, ...props }: PropsWithChildren<GridItemProps & {
|
5
|
+
onContextGroup: (e: React.MouseEvent) => void;
|
6
|
+
}>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
5
7
|
export default GroupItem;
|
@@ -26,11 +26,10 @@ import { DraggableCore } from "../Draggable";
|
|
26
26
|
import classNames from "../../external-lib/classnames";
|
27
27
|
import { calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcXY, clamp, resolveRowHeight, } from "./utils/calculateUtils";
|
28
28
|
import { perc, setTopLeft, setTransform, } from "../GridLayoutEditor/utils/renderHelpers";
|
29
|
-
import { Resizable } from "../Resizable";
|
30
29
|
var GroupItem = function (_a) {
|
31
30
|
var _b;
|
32
31
|
var children = _a.children, props = __rest(_a, ["children"]);
|
33
|
-
var resizeHandle = props.resizeHandle, cols = props.cols, isDraggable = props.isDraggable, _c = props.transformScale, transformScale = _c === void 0 ? 1 : _c, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _d = props.cancel, cancel = _d === void 0 ? "" : _d, _e = props.handle, handle = _e === void 0 ? "" : _e, x = props.x, y = props.y, z = props.z, w = props.w, h = props.h, _f = props.minH, minH = _f === void 0 ? 1 : _f, _g = props.minW, minW = _g === void 0 ? 1 : _g, _h = props.maxH, maxH = _h === void 0 ? Infinity : _h, _j = props.maxW, maxW = _j === void 0 ? Infinity : _j, i = props.i, _k = props.isHiddenVisibility, isHiddenVisibility = _k === void 0 ? false : _k, containerWidth = props.containerWidth, customColWidth = props.customColWidth, autoResize = props.autoResize;
|
32
|
+
var resizeHandle = props.resizeHandle, cols = props.cols, isDraggable = props.isDraggable, _c = props.transformScale, transformScale = _c === void 0 ? 1 : _c, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _d = props.cancel, cancel = _d === void 0 ? "" : _d, _e = props.handle, handle = _e === void 0 ? "" : _e, x = props.x, y = props.y, z = props.z, w = props.w, h = props.h, _f = props.minH, minH = _f === void 0 ? 1 : _f, _g = props.minW, minW = _g === void 0 ? 1 : _g, _h = props.maxH, maxH = _h === void 0 ? Infinity : _h, _j = props.maxW, maxW = _j === void 0 ? Infinity : _j, i = props.i, _k = props.isHiddenVisibility, isHiddenVisibility = _k === void 0 ? false : _k, containerWidth = props.containerWidth, customColWidth = props.customColWidth, autoResize = props.autoResize, onContextGroup = props.onContextGroup;
|
34
33
|
var _l = useState(), resizing = _l[0], setResizing = _l[1];
|
35
34
|
var _m = useState(), dragging = _m[0], setDragging = _m[1];
|
36
35
|
var _o = useState(), dragStart = _o[0], setDragStart = _o[1];
|
@@ -173,33 +172,58 @@ var GroupItem = function (_a) {
|
|
173
172
|
var mixinDraggable = function (child, isDraggable) {
|
174
173
|
return (_jsx(DraggableCore, { disabled: !isDraggable, onStart: onDragStart, onDrag: onDrag, onStop: onDragStop, handle: handle, cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""), scale: transformScale, nodeRef: elementRef, children: child }));
|
175
174
|
};
|
176
|
-
/**
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
175
|
+
// /**
|
176
|
+
// * Mix a Resizable instance into a child.
|
177
|
+
// * @param {Element} child Child element.
|
178
|
+
// * @param {Object} position Position object (pixel values)
|
179
|
+
// * @return {Element} Child wrapped in Resizable.
|
180
|
+
// */
|
181
|
+
// const mixinResizable = (
|
182
|
+
// child: ReactElement<any>,
|
183
|
+
// position: Position,
|
184
|
+
// isResizable: boolean
|
185
|
+
// ): ReactElement<any> => {
|
186
|
+
// const positionParams = getPositionParams();
|
187
|
+
// // const maxWidth = calcGridItemPosition(
|
188
|
+
// // positionParams,
|
189
|
+
// // x,
|
190
|
+
// // y,
|
191
|
+
// // z,
|
192
|
+
// // cols - x, // TODO - 수정 필요
|
193
|
+
// // h
|
194
|
+
// // ).width;
|
195
|
+
// const mins = calcGridItemPosition(positionParams, x, y, z, minW, minH);
|
196
|
+
// const maxes = calcGridItemPosition(positionParams, x, y, z, maxW, maxH);
|
197
|
+
// const minConstraints = [mins.width, mins.height] as [number, number];
|
198
|
+
// const maxConstraints = [
|
199
|
+
// Math.min(maxes.width, containerWidth),
|
200
|
+
// Math.min(maxes.height, Infinity),
|
201
|
+
// ] as [number, number];
|
202
|
+
// return (
|
203
|
+
// <Resizable
|
204
|
+
// draggableOpts={{
|
205
|
+
// disabled: !isResizable,
|
206
|
+
// }}
|
207
|
+
// className={"react-resizable-hide"}
|
208
|
+
// width={position.width}
|
209
|
+
// height={position.height}
|
210
|
+
// top={position.top}
|
211
|
+
// left={position.left}
|
212
|
+
// onResizeStop={onResizeStop}
|
213
|
+
// onResizeStart={onResizeStart}
|
214
|
+
// onResize={onResize}
|
215
|
+
// minConstraints={minConstraints}
|
216
|
+
// maxConstraints={maxConstraints}
|
217
|
+
// transformScale={transformScale}
|
218
|
+
// isResizing={isResizing}
|
219
|
+
// autoResize={autoResize}
|
220
|
+
// colWidth={colWidth}
|
221
|
+
// margin={props.margin}
|
222
|
+
// >
|
223
|
+
// {child}
|
224
|
+
// </Resizable>
|
225
|
+
// );
|
226
|
+
// };
|
203
227
|
/**
|
204
228
|
* onDragStart event handler
|
205
229
|
* @param {Event} e event data
|
@@ -397,8 +421,11 @@ var GroupItem = function (_a) {
|
|
397
421
|
cssTransforms: useCSSTransforms,
|
398
422
|
}),
|
399
423
|
style: __assign(__assign(__assign({}, props.style), child.props.style), createStyle(pos)),
|
424
|
+
onContextMenu: function (e) {
|
425
|
+
onContextGroup(e);
|
426
|
+
},
|
400
427
|
});
|
401
|
-
newChild = mixinResizable(newChild, pos, isResizable);
|
428
|
+
// newChild = mixinResizable(newChild, pos, isResizable);
|
402
429
|
newChild = mixinDraggable(newChild, isDraggable);
|
403
430
|
return newChild;
|
404
431
|
};
|
@@ -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
|
-
declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps
|
5
|
+
declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps & {
|
6
|
+
onContextGroup?: ((e: React.MouseEvent, blockId: string, isEditingGroup: boolean) => void) | undefined;
|
7
|
+
}>) => React.ReactElement;
|
6
8
|
export default ReactGridLayout;
|
@@ -310,6 +310,59 @@ var ReactGridLayout = function (_a) {
|
|
310
310
|
setOldGroupChildren([]);
|
311
311
|
props.onLayoutChange && props.onLayoutChange(newLayout);
|
312
312
|
};
|
313
|
+
var onDragStopGroupHandler = function (i, x, y, _a) {
|
314
|
+
var _b;
|
315
|
+
var e = _a.e, node = _a.node;
|
316
|
+
if (!activeDrag || !oldDragItem) {
|
317
|
+
return;
|
318
|
+
}
|
319
|
+
;
|
320
|
+
var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 10, h: 10 };
|
321
|
+
if (!l)
|
322
|
+
return;
|
323
|
+
// NOTE: z-index 원래대로 복귀
|
324
|
+
l.z = oldDragItem.z;
|
325
|
+
var isUserAction = true;
|
326
|
+
var movedLayout = moveElement({
|
327
|
+
layout: layout,
|
328
|
+
l: l,
|
329
|
+
x: x,
|
330
|
+
y: y,
|
331
|
+
isUserAction: isUserAction,
|
332
|
+
preventCollision: preventCollision,
|
333
|
+
compactType: compactType,
|
334
|
+
cols: cols,
|
335
|
+
allowOverlap: allowOverlap,
|
336
|
+
overrideZ: oldDragItem.z
|
337
|
+
});
|
338
|
+
var updatedItems = oldGroupChildren.map(function (item) {
|
339
|
+
var layoutItem = getLayoutItem(layout, item.i);
|
340
|
+
return {
|
341
|
+
id: layoutItem.i,
|
342
|
+
x: layoutItem.x,
|
343
|
+
y: layoutItem.y,
|
344
|
+
};
|
345
|
+
});
|
346
|
+
props.onDragStopForGroup &&
|
347
|
+
props.onDragStopForGroup({
|
348
|
+
layout: movedLayout,
|
349
|
+
prev: oldDragItem,
|
350
|
+
item: l,
|
351
|
+
placeholder: undefined,
|
352
|
+
e: e,
|
353
|
+
node: node,
|
354
|
+
updatedItems: updatedItems
|
355
|
+
});
|
356
|
+
var newLayout = allowOverlap
|
357
|
+
? movedLayout
|
358
|
+
: compact(movedLayout, compactType, cols);
|
359
|
+
setActiveDrag(undefined);
|
360
|
+
setLayout(newLayout);
|
361
|
+
setOldDragItem(undefined);
|
362
|
+
setOldLayout(undefined);
|
363
|
+
setOldGroupChildren([]);
|
364
|
+
props.onLayoutChange && props.onLayoutChange(newLayout);
|
365
|
+
};
|
313
366
|
var onLayoutMaybeChanged = function (newLayout, oldLayout) {
|
314
367
|
if (!oldLayout) {
|
315
368
|
oldLayout = layout;
|
@@ -626,12 +679,15 @@ var ReactGridLayout = function (_a) {
|
|
626
679
|
var handleDoubleClick = function (e) {
|
627
680
|
onDoubleClickGroup && onDoubleClickGroup(e, block.blockId, type);
|
628
681
|
};
|
682
|
+
var handleClickContextGroup = function (e) {
|
683
|
+
(props === null || props === void 0 ? void 0 : props.onContextGroup) && props.onContextGroup(e, block.blockId, isEditingGroup);
|
684
|
+
};
|
629
685
|
return (_jsx(OutsideClickHandler, { onOutsideClick: onDoubleClickOutsideGroup, children: _jsx(GroupItem, { className: classNames({
|
630
686
|
'bulk-child-item': isInBulk,
|
631
687
|
'grid-bulk-block': block.blockId === 'BULK',
|
632
688
|
'editing': editingGroupBlock === block.blockId,
|
633
689
|
'selected': selectedGroupBlock === block.blockId
|
634
|
-
}), containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, cancel: draggableCancel, handle: draggableHandle, onDragStop:
|
690
|
+
}), containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, cancel: draggableCancel, handle: draggableHandle, onDragStop: onDragStopGroupHandler, onDragStart: onDragStartHandler, onDrag: onDragHandler, onResizeStart: onResizeStartHandler, onResize: onResizeHandler, onResizeStop: onResizeStopHandler, onFitToContent: onFitToContentHandler, isDraggable: !viewOnly && !isEditingGroup && !isInBulk, isResizable: !viewOnly && !isEditingGroup && !isInBulk, isBounded: false, useCSSTransforms: useCSSTransforms && isMounted, usePercentages: !isMounted, transformScale: transformScale, w: groupItem.w, h: groupItem.h, x: groupItem.x, y: groupItem.y, z: z, i: block.blockId,
|
635
691
|
// minH={l.minH}
|
636
692
|
// minW={l.minW}
|
637
693
|
// maxH={l.maxH}
|
@@ -640,7 +696,7 @@ var ReactGridLayout = function (_a) {
|
|
640
696
|
// droppingPosition={isDroppingItem ? droppingPosition : undefined}
|
641
697
|
// resizeHandles={resizeHandlesOptions}
|
642
698
|
// resizeHandle={resizeHandle}
|
643
|
-
isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, autoResize: false, children: _jsx("div", { onClick: handleClick, onDoubleClick: handleDoubleClick }) }, block.blockId) }));
|
699
|
+
isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, autoResize: false, onContextGroup: handleClickContextGroup, children: _jsx("div", { onClick: handleClick, onDoubleClick: handleDoubleClick }) }, block.blockId) }));
|
644
700
|
};
|
645
701
|
var currentGroupBlocks = blockStructure ? findGroupBlocks(blockStructure, editingGroupBlock) : [];
|
646
702
|
return (_jsxs("div", { ref: innerRef, className: mergedClassName, style: mergedStyle, onDrop: isDroppable ? onDropHandler : noop, onDragLeave: isDroppable ? onDragLeaveHandler : noop, onDragEnter: isDroppable ? onDragEnterHandler : noop, onDragOver: isDroppable ? onDragOverHandler : noop, children: [currentGroupBlocks.map(function (each) { return processGroup(each); }), React.Children.map(children, function (child) { return processGridItem(child); }), placeholder(), activeDrag && _jsx("div", { className: "grid-guide-line-center" }), activeDrag && (_jsx("div", { className: "grid-placeholder", style: {
|
@@ -29,6 +29,11 @@ export type DroppedEvent = {
|
|
29
29
|
item?: LayoutItem;
|
30
30
|
event?: DragEvent<HTMLDivElement>;
|
31
31
|
};
|
32
|
+
export type UpdatedItem = {
|
33
|
+
id: string;
|
34
|
+
x: number;
|
35
|
+
y: number;
|
36
|
+
};
|
32
37
|
export type ReactGridLayoutProps = {
|
33
38
|
children: ReactElement<any> | ReactElement[];
|
34
39
|
className?: string;
|
@@ -60,6 +65,7 @@ export type ReactGridLayoutProps = {
|
|
60
65
|
onDrag?: EventCallback;
|
61
66
|
onDragStart?: EventCallback;
|
62
67
|
onDragStop?: EventCallback;
|
68
|
+
onDragStopForGroup?: EventCallbackForGroup;
|
63
69
|
onResize?: EventCallback;
|
64
70
|
onResizeStart?: EventCallback;
|
65
71
|
onResizeStop?: EventCallback;
|
@@ -104,6 +110,15 @@ export type EventCallback = (properties: {
|
|
104
110
|
e?: ResizeEventType;
|
105
111
|
node?: HTMLElement;
|
106
112
|
}) => void;
|
113
|
+
export type EventCallbackForGroup = (properties: {
|
114
|
+
layout: Layout;
|
115
|
+
prev?: LayoutItem;
|
116
|
+
item?: LayoutItem;
|
117
|
+
placeholder?: LayoutItem;
|
118
|
+
e?: ResizeEventType;
|
119
|
+
node?: HTMLElement;
|
120
|
+
updatedItems: UpdatedItem[];
|
121
|
+
}) => void;
|
107
122
|
export type RowHeight = number | ((width: number) => number);
|
108
123
|
export type Position = {
|
109
124
|
left: number;
|