@m4l/components 0.1.80 → 0.1.82
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/@types/export.d.ts +9 -1
- package/components/AccountPopover/AccountPopover.d.ts +21 -0
- package/components/AccountPopover/classes/types.d.ts +1 -1
- package/components/AccountPopover/{index.00d1d15f.js → index.0ba26726.js} +68 -72
- package/components/AccountPopover/subcomponents/MyAvatar/index.d.ts +2 -2
- package/components/AccountPopover/subcomponents/MyAvatar/types.d.ts +7 -0
- package/components/AccountPopover/subcomponents/PopOver/index.d.ts +6 -0
- package/components/AccountPopover/subcomponents/PopOver/types.d.ts +5 -4
- package/components/AccountPopover/types.d.ts +3 -4
- package/components/AppBar/{index.c85b100d.js → index.fadcefc6.js} +7 -7
- package/components/CommonActions/components/ActionCancel/{index.1051a117.js → index.6cf96d04.js} +2 -2
- package/components/CommonActions/components/ActionFormCancel/{index.a0d727b2.js → index.a0335cbf.js} +15 -15
- package/components/CommonActions/components/ActionFormIntro/{index.a20dc88d.js → index.273b1b9f.js} +2 -2
- package/components/CommonActions/components/ActionIntro/{index.bfe3256c.js → index.856df8ef.js} +2 -2
- package/components/CommonActions/components/Actions/{index.19d67bc6.js → index.5abb6ac4.js} +13 -13
- package/components/DataGrid/classes/index.d.ts +1 -0
- package/components/DataGrid/classes/types.d.ts +1 -0
- package/components/DataGrid/constants.d.ts +1 -0
- package/components/DataGrid/{index.2f175eba.js → index.03ad08af.js} +28 -681
- package/components/DataGrid/subcomponents/Actions/index.db54ec98.js +621 -0
- package/components/DataGrid/subcomponents/editors/TextEditor/index.91380a55.js +64 -0
- package/components/DynamicFilter/constants.d.ts +1 -1
- package/components/DynamicFilter/{index.c1f9d560.js → index.9b72180b.js} +28 -28
- package/components/GridLayout/GridLayout.d.ts +1 -0
- package/components/GridLayout/classes/index.d.ts +4 -0
- package/components/GridLayout/classes/types.d.ts +17 -0
- package/components/GridLayout/constants.d.ts +26 -0
- package/components/GridLayout/{index.a792aacb.js → index.76bccc4f.js} +322 -575
- package/components/GridLayout/index.d.ts +4 -3
- package/components/GridLayout/subcomponents/Griditem/index.01fc14c3.js +370 -0
- package/components/GridLayout/subcomponents/Griditem/index.d.ts +9 -0
- package/components/GridLayout/subcomponents/Griditem/types.d.ts +103 -0
- package/components/GridLayout/subcomponents/Responsive/helper.d.ts +10 -0
- package/components/GridLayout/subcomponents/Responsive/index.d.ts +15 -2
- package/components/GridLayout/{Responsive/index.1671380a.js → subcomponents/Responsive/index.e589d8bf.js} +95 -139
- package/components/GridLayout/subcomponents/Responsive/responsiveUtils.d.ts +3 -6
- package/components/GridLayout/subcomponents/Responsive/types.d.ts +114 -33
- package/components/GridLayout/{WidthProvider/index.9a26dfe4.js → subcomponents/WidthProvider/index.50dafd87.js} +5 -5
- package/components/GridLayout/subcomponents/WidthProvider/index.d.ts +4 -5
- package/components/GridLayout/types.d.ts +83 -18
- package/components/GridLayout/utils.d.ts +15 -12
- package/components/HelperText/{index.6ef76993.js → index.6c3adb40.js} +7 -7
- package/components/Icon/{index.9fcd1476.js → index.2414ff25.js} +1 -1
- package/components/LanguagePopover/{index.1564bd08.js → index.66e11634.js} +7 -7
- package/components/ModalDialog/{index.fbc4cd71.js → index.4dc1c8ed.js} +4 -4
- package/components/NavLink/{index.6c9c2588.js → index.5859e048.js} +7 -7
- package/components/ObjectLogs/{index.eab1c15f.js → index.51de2deb.js} +17 -17
- package/components/PaperForm/{index.ba38a0bd.js → index.f931dc02.js} +1 -1
- package/components/Period/{index.26071a16.js → index.4fd9df2a.js} +14 -14
- package/components/PropertyValue/{index.18d3c0fd.js → index.1b09f426.js} +1 -1
- package/components/ScrollBar/{index.bbe48f4d.js → index.d4410cb5.js} +5 -0
- package/components/SideBar/{index.2f497e6c.js → index.72564ef2.js} +11 -6
- package/components/animate/AnimatedScroll/animatedScroll.d.ts +3 -0
- package/components/animate/AnimatedScroll/index.d.ts +1 -0
- package/components/animate/AnimatedScroll/types.d.ts +5 -0
- package/components/animate/index.4e9774a6.js +150 -0
- package/components/animate/index.d.ts +1 -0
- package/components/areas/components/AreasAdmin/{index.7a0dabbe.js → index.f011d49d.js} +60 -49
- package/components/areas/components/AreasAdmin/subcomponents/AreaChipMobile/subcomponents/PanelWindowPopUp/index.d.ts +1 -1
- package/components/areas/components/AreasViewer/{index.fd49f06c.js → index.51a52736.js} +41 -153
- package/components/areas/components/{index.7756928a.js → index.f496660b.js} +11 -11
- package/components/areas/contexts/AreasContext/helper.d.ts +2 -2
- package/components/areas/contexts/AreasContext/{index.0a08a08b.js → index.9820bc7f.js} +12 -6
- package/components/areas/contexts/AreasContext/types.d.ts +4 -4
- package/components/areas/contexts/{index.b303b664.js → index.361acb6f.js} +1 -1
- package/components/areas/hooks/useAreas/{index.c6eb2569.js → index.b403f383.js} +1 -1
- package/components/areas/{index.6e67d89a.js → index.eacab372.js} +11 -11
- package/components/formatters/BooleanFormatter/{index.e8de8e4c.js → index.32de0803.js} +1 -1
- package/components/formatters/{index.67aeb049.js → index.d16d2331.js} +2 -2
- package/components/hook-form/RHFAutocomplete/{index.d1bbb015.js → index.6edb51b1.js} +8 -8
- package/components/hook-form/RHFAutocompleteAsync/{index.f9a9ef48.js → index.c2ca5c66.js} +1 -1
- package/components/hook-form/RHFCheckbox/{index.7b4a21d7.js → index.c6c3933b.js} +8 -8
- package/components/hook-form/RHFDateTime/{index.46cf616e.js → index.3add0fa4.js} +8 -8
- package/components/hook-form/RHFPeriod/{index.ce513149.js → index.72edef4d.js} +2 -2
- package/components/hook-form/RHFTextField/{index.f7ee202c.js → index.20daa95e.js} +3 -3
- package/components/hook-form/RHFUpload/{index.1befd5bb.js → index.cc5adc15.js} +8 -8
- package/components/modal/{WindowBase.7e19843e.js → WindowBase.4016485b.js} +9 -9
- package/components/modal/{WindowConfirm.12a9608a.js → WindowConfirm.f148e495.js} +16 -16
- package/components/modal/{index.b0a7236c.js → index.e9fece72.js} +13 -13
- package/components/mui_extended/Accordion/{index.a6447bf8.js → index.42cef1c7.js} +3 -3
- package/components/mui_extended/Avatar/types.d.ts +3 -1
- package/components/mui_extended/Button/classes/types.d.ts +3 -0
- package/components/mui_extended/Button/{index.4288f9fc.js → index.40af964e.js} +8 -3
- package/components/mui_extended/Button/types.d.ts +2 -1
- package/components/mui_extended/IconButton/{index.12f1a3c3.js → index.a318316e.js} +1 -1
- package/components/mui_extended/MenuActions/{index.43a2e1ae.js → index.f6bfdd40.js} +2 -2
- package/components/mui_extended/Pager/classes/index.d.ts +12 -0
- package/components/mui_extended/Pager/classes/types.d.ts +12 -4
- package/components/mui_extended/Pager/{index.82e89328.js → index.da26e9d4.js} +114 -62
- package/components/mui_extended/Pager/subcomponents/CustomTablePagination/index.d.ts +3 -0
- package/components/mui_extended/Pager/subcomponents/CustomTablePagination/types.d.ts +12 -0
- package/components/mui_extended/Pager/{components → subcomponents}/PagerActions/types.d.ts +2 -0
- package/components/mui_extended/Tab/{index.c39a6681.js → index.0d5f96e6.js} +1 -1
- package/components/mui_extended/{index.d78bde19.js → index.f6a356b9.js} +7 -7
- package/contexts/ModalContext/{index.89805978.js → index.efc1135a.js} +1 -1
- package/contexts/RHFormContext/{index.fe175bab.js → index.b9266262.js} +1 -1
- package/hooks/useModal/{index.e1c5c31e.js → index.9b0cc3fe.js} +1 -1
- package/index.js +92 -88
- package/package.json +1 -2
- package/{vendor.f57d47a7.js → vendor.88ed58a5.js} +51 -48
- package/components/AccountPopover/subcomponents/MyAvatar/createAvatar.d.ts +0 -4
- package/components/GridLayout/subcomponents/GridItem/index.d.ts +0 -26
- package/components/GridLayout/subcomponents/GridItem/types.d.ts +0 -78
- package/components/animate/index.1f8eadd4.js +0 -66
- /package/components/mui_extended/Pager/{components → subcomponents}/PagerActions/index.d.ts +0 -0
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { d as deepEqual } from "../../node_modules.d73a220d.js";
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
3
2
|
import clsx from "clsx";
|
|
4
|
-
import {
|
|
5
|
-
import { jsx,
|
|
6
|
-
import { D as DraggableCore_1 } from "../../react-draggable.7abb5d0a.js";
|
|
7
|
-
import { R as Resizable, r as react_resizable_css } from "../../react-resizable.ba08699a.js";
|
|
3
|
+
import { M as MemonizedGridItem } from "./subcomponents/Griditem/index.01fc14c3.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
5
|
import { styled } from "@mui/material/styles";
|
|
6
|
+
import { r as react_resizable_css } from "../../react-resizable.ba08699a.js";
|
|
7
|
+
import { generateUtilityClasses } from "@mui/material";
|
|
8
|
+
import "@mui/base";
|
|
9
9
|
import "@m4l/graphics";
|
|
10
10
|
import "lodash";
|
|
11
|
+
const COMPONENT_CLASS_NAME = "M4LGridLayout";
|
|
12
|
+
const DEFAULT_COLS = 12;
|
|
13
|
+
const DEFAULT_ROW_HEIGHT = 150;
|
|
14
|
+
const DEFAULT_CONTAINER_WIDTH = 1280;
|
|
15
|
+
const DEFAULT_CONTAINER_HEIGHT = 480;
|
|
16
|
+
const DEFAULT_RESPONSIVE_COLS = { lg: 12, md: 10, sm: 6, xs: 4, xxs: 1 };
|
|
17
|
+
const DEFAULT_RESPONSIVE_BREAKPOINTS = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
|
|
18
|
+
const DEFAULT_CONTAINER_PADDING = [10, 10];
|
|
19
|
+
const DEFAULT_MARGIN = [10, 10];
|
|
20
|
+
const DEFAULT_TRANSFORM_SCALE = 1;
|
|
21
|
+
const DEFAULT_COLAPSED_HEIGHT = 35;
|
|
22
|
+
const THROTTLE_RESIZE_TIME = 200;
|
|
11
23
|
const noop = () => {
|
|
12
24
|
};
|
|
13
|
-
function bottom(layout, colapsedHeight) {
|
|
25
|
+
function bottom(layout, colapsedHeight, rowHeight) {
|
|
14
26
|
let max = 0, bottomY;
|
|
15
27
|
for (let i = 0, len = layout.length; i < len; i++) {
|
|
16
|
-
bottomY = layout[i].y + getLayoutItemH(layout[i], colapsedHeight);
|
|
28
|
+
bottomY = layout[i].y + getLayoutItemH(layout[i], colapsedHeight, rowHeight);
|
|
17
29
|
if (bottomY > max)
|
|
18
30
|
max = bottomY;
|
|
19
31
|
}
|
|
@@ -49,55 +61,57 @@ function cloneLayout(layout, layoutItemReplaceProps) {
|
|
|
49
61
|
}
|
|
50
62
|
return newLayout;
|
|
51
63
|
}
|
|
52
|
-
function collides(l1, l2, colapsedHeight) {
|
|
64
|
+
function collides(l1, l2, colapsedHeight, rowHeight) {
|
|
53
65
|
if (l1.i === l2.i)
|
|
54
66
|
return false;
|
|
55
67
|
if (l1.x + l1.w <= l2.x)
|
|
56
68
|
return false;
|
|
57
69
|
if (l1.x >= l2.x + l2.w)
|
|
58
70
|
return false;
|
|
59
|
-
if (l1.y + getLayoutItemH(l1, colapsedHeight) <= l2.y)
|
|
71
|
+
if (l1.y + getLayoutItemH(l1, colapsedHeight, rowHeight) <= l2.y)
|
|
60
72
|
return false;
|
|
61
|
-
if (l1.y >= l2.y + getLayoutItemH(l2, colapsedHeight))
|
|
73
|
+
if (l1.y >= l2.y + getLayoutItemH(l2, colapsedHeight, rowHeight))
|
|
62
74
|
return false;
|
|
63
75
|
return true;
|
|
64
76
|
}
|
|
65
|
-
function compactItem(compareWith, l, compactType, cols, fullLayout, colapsedHeight, allowOverlap) {
|
|
77
|
+
function compactItem(compareWith, l, compactType, cols, fullLayout, colapsedHeight, rowHeight, allowOverlap) {
|
|
66
78
|
const compactV = compactType === "vertical";
|
|
67
79
|
const compactH = compactType === "horizontal";
|
|
68
80
|
if (compactV) {
|
|
69
|
-
l.y = Math.min(bottom(compareWith, colapsedHeight), l.y);
|
|
70
|
-
while (l.y > 0 && !getFirstCollision(compareWith, l, colapsedHeight)) {
|
|
81
|
+
l.y = Math.min(bottom(compareWith, colapsedHeight, rowHeight), l.y);
|
|
82
|
+
while (l.y > 0 && !getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) {
|
|
71
83
|
l.y--;
|
|
72
84
|
}
|
|
73
85
|
} else if (compactH) {
|
|
74
|
-
while (l.x > 0 && !getFirstCollision(compareWith, l, colapsedHeight)) {
|
|
86
|
+
while (l.x > 0 && !getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) {
|
|
75
87
|
l.x--;
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
let collidesItem;
|
|
79
|
-
while ((collidesItem = getFirstCollision(compareWith, l, colapsedHeight)) && !(compactType === null && allowOverlap)) {
|
|
91
|
+
while ((collidesItem = getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) && !(compactType === null && allowOverlap)) {
|
|
80
92
|
if (compactH) {
|
|
81
93
|
resolveCompactionCollision(
|
|
82
94
|
fullLayout,
|
|
83
95
|
l,
|
|
84
96
|
collidesItem.x + collidesItem.w,
|
|
85
97
|
"x",
|
|
86
|
-
colapsedHeight
|
|
98
|
+
colapsedHeight,
|
|
99
|
+
rowHeight
|
|
87
100
|
);
|
|
88
101
|
} else {
|
|
89
102
|
resolveCompactionCollision(
|
|
90
103
|
fullLayout,
|
|
91
104
|
l,
|
|
92
|
-
collidesItem.y + getLayoutItemH(collidesItem, colapsedHeight),
|
|
105
|
+
collidesItem.y + getLayoutItemH(collidesItem, colapsedHeight, rowHeight),
|
|
93
106
|
"y",
|
|
94
|
-
colapsedHeight
|
|
107
|
+
colapsedHeight,
|
|
108
|
+
rowHeight
|
|
95
109
|
);
|
|
96
110
|
}
|
|
97
111
|
if (compactH && l.x + l.w > cols) {
|
|
98
112
|
l.x = cols - l.w;
|
|
99
113
|
l.y++;
|
|
100
|
-
while (l.x > 0 && !getFirstCollision(compareWith, l, colapsedHeight)) {
|
|
114
|
+
while (l.x > 0 && !getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) {
|
|
101
115
|
l.x--;
|
|
102
116
|
}
|
|
103
117
|
}
|
|
@@ -106,7 +120,7 @@ function compactItem(compareWith, l, compactType, cols, fullLayout, colapsedHeig
|
|
|
106
120
|
l.x = Math.max(l.x, 0);
|
|
107
121
|
return l;
|
|
108
122
|
}
|
|
109
|
-
function compact(layout, compactType, cols, colapsedHeight, allowOverlap) {
|
|
123
|
+
function compact(layout, compactType, cols, colapsedHeight, rowHeight, allowOverlap) {
|
|
110
124
|
const layoutToCompact = layout.filter((l) => !l.freeMove);
|
|
111
125
|
const layoutFreeMov = layout.filter((l) => l?.freeMove);
|
|
112
126
|
const compareWith = getStatics(layoutToCompact);
|
|
@@ -122,6 +136,7 @@ function compact(layout, compactType, cols, colapsedHeight, allowOverlap) {
|
|
|
122
136
|
cols,
|
|
123
137
|
sorted,
|
|
124
138
|
colapsedHeight,
|
|
139
|
+
rowHeight,
|
|
125
140
|
allowOverlap
|
|
126
141
|
);
|
|
127
142
|
compareWith.push(l);
|
|
@@ -141,12 +156,12 @@ function getLayoutItem(layout, id) {
|
|
|
141
156
|
function getStatics(layout) {
|
|
142
157
|
return layout.filter((l) => l.static);
|
|
143
158
|
}
|
|
144
|
-
function getAllCollisions(layout, layoutItem, colapsedHeight) {
|
|
145
|
-
return layout.filter((l) => collides(l, layoutItem, colapsedHeight));
|
|
159
|
+
function getAllCollisions(layout, layoutItem, colapsedHeight, rowHeight) {
|
|
160
|
+
return layout.filter((l) => collides(l, layoutItem, colapsedHeight, rowHeight));
|
|
146
161
|
}
|
|
147
|
-
function getFirstCollision(layout, layoutItem, colapsedHeight) {
|
|
162
|
+
function getFirstCollision(layout, layoutItem, colapsedHeight, rowHeight) {
|
|
148
163
|
for (let i = 0, len = layout.length; i < len; i++) {
|
|
149
|
-
if (collides(layout[i], layoutItem, colapsedHeight))
|
|
164
|
+
if (collides(layout[i], layoutItem, colapsedHeight, rowHeight))
|
|
150
165
|
return layout[i];
|
|
151
166
|
}
|
|
152
167
|
return void 0;
|
|
@@ -162,7 +177,7 @@ function modifyLayout(layout, layoutItem) {
|
|
|
162
177
|
}
|
|
163
178
|
return newLayout;
|
|
164
179
|
}
|
|
165
|
-
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols, colapsedHeight) {
|
|
180
|
+
function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols, colapsedHeight, rowHeight) {
|
|
166
181
|
const compactH = compactType === "horizontal";
|
|
167
182
|
const compactV = compactType !== "horizontal";
|
|
168
183
|
const preventCollision = collidesWith.static;
|
|
@@ -170,12 +185,15 @@ function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAc
|
|
|
170
185
|
isUserAction = false;
|
|
171
186
|
const fakeItem = {
|
|
172
187
|
x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
|
|
173
|
-
y: compactV ? Math.max(
|
|
188
|
+
y: compactV ? Math.max(
|
|
189
|
+
collidesWith.y - getLayoutItemH(itemToMove, colapsedHeight, rowHeight),
|
|
190
|
+
0
|
|
191
|
+
) : itemToMove.y,
|
|
174
192
|
w: itemToMove.w,
|
|
175
|
-
h: getLayoutItemH(itemToMove, colapsedHeight),
|
|
193
|
+
h: getLayoutItemH(itemToMove, colapsedHeight, rowHeight),
|
|
176
194
|
i: "-1"
|
|
177
195
|
};
|
|
178
|
-
if (!getFirstCollision(layout, fakeItem, colapsedHeight)) {
|
|
196
|
+
if (!getFirstCollision(layout, fakeItem, colapsedHeight, rowHeight)) {
|
|
179
197
|
return moveElement(
|
|
180
198
|
layout,
|
|
181
199
|
itemToMove,
|
|
@@ -186,6 +204,7 @@ function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAc
|
|
|
186
204
|
compactType,
|
|
187
205
|
cols,
|
|
188
206
|
colapsedHeight,
|
|
207
|
+
rowHeight,
|
|
189
208
|
false
|
|
190
209
|
);
|
|
191
210
|
}
|
|
@@ -200,10 +219,11 @@ function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAc
|
|
|
200
219
|
compactType,
|
|
201
220
|
cols,
|
|
202
221
|
colapsedHeight,
|
|
222
|
+
rowHeight,
|
|
203
223
|
false
|
|
204
224
|
);
|
|
205
225
|
}
|
|
206
|
-
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, colapsedHeight, allowOverlap) {
|
|
226
|
+
function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, colapsedHeight, rowHeight, allowOverlap) {
|
|
207
227
|
if (l.static && l.isDraggable !== true)
|
|
208
228
|
return layout;
|
|
209
229
|
if (l.y === y && l.x === x)
|
|
@@ -219,7 +239,7 @@ function moveElement(layout, l, x, y, isUserAction, preventCollision, compactTyp
|
|
|
219
239
|
const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
|
|
220
240
|
if (movingUp)
|
|
221
241
|
sorted = sorted.reverse();
|
|
222
|
-
const collisions = getAllCollisions(sorted, l, colapsedHeight);
|
|
242
|
+
const collisions = getAllCollisions(sorted, l, colapsedHeight, rowHeight);
|
|
223
243
|
const hasCollisions = collisions.length > 0;
|
|
224
244
|
if (hasCollisions && allowOverlap) {
|
|
225
245
|
return cloneLayout(layout);
|
|
@@ -241,7 +261,8 @@ function moveElement(layout, l, x, y, isUserAction, preventCollision, compactTyp
|
|
|
241
261
|
isUserAction,
|
|
242
262
|
compactType,
|
|
243
263
|
cols,
|
|
244
|
-
colapsedHeight
|
|
264
|
+
colapsedHeight,
|
|
265
|
+
rowHeight
|
|
245
266
|
);
|
|
246
267
|
} else {
|
|
247
268
|
layout = moveElementAwayFromCollision(
|
|
@@ -251,7 +272,8 @@ function moveElement(layout, l, x, y, isUserAction, preventCollision, compactTyp
|
|
|
251
272
|
isUserAction,
|
|
252
273
|
compactType,
|
|
253
274
|
cols,
|
|
254
|
-
colapsedHeight
|
|
275
|
+
colapsedHeight,
|
|
276
|
+
rowHeight
|
|
255
277
|
);
|
|
256
278
|
}
|
|
257
279
|
}
|
|
@@ -260,7 +282,7 @@ function moveElement(layout, l, x, y, isUserAction, preventCollision, compactTyp
|
|
|
260
282
|
function perc(num) {
|
|
261
283
|
return num * 100 + "%";
|
|
262
284
|
}
|
|
263
|
-
function resolveCompactionCollision(layout, item, moveToCoord, axis, colapsedHeight) {
|
|
285
|
+
function resolveCompactionCollision(layout, item, moveToCoord, axis, colapsedHeight, rowHeight) {
|
|
264
286
|
item[axis] += 1;
|
|
265
287
|
const itemIndex = layout.map((layoutItem) => {
|
|
266
288
|
return layoutItem.i;
|
|
@@ -269,15 +291,16 @@ function resolveCompactionCollision(layout, item, moveToCoord, axis, colapsedHei
|
|
|
269
291
|
const otherItem = layout[i];
|
|
270
292
|
if (otherItem.static)
|
|
271
293
|
continue;
|
|
272
|
-
if (otherItem.y > item.y + getLayoutItemH(item, colapsedHeight))
|
|
294
|
+
if (otherItem.y > item.y + getLayoutItemH(item, colapsedHeight, rowHeight))
|
|
273
295
|
break;
|
|
274
|
-
if (collides(item, otherItem, colapsedHeight)) {
|
|
296
|
+
if (collides(item, otherItem, colapsedHeight, rowHeight)) {
|
|
275
297
|
resolveCompactionCollision(
|
|
276
298
|
layout,
|
|
277
299
|
otherItem,
|
|
278
|
-
moveToCoord + (axis === "x" ? item.w : getLayoutItemH(item, colapsedHeight)),
|
|
300
|
+
moveToCoord + (axis === "x" ? item.w : getLayoutItemH(item, colapsedHeight, rowHeight)),
|
|
279
301
|
axis,
|
|
280
|
-
colapsedHeight
|
|
302
|
+
colapsedHeight,
|
|
303
|
+
rowHeight
|
|
281
304
|
);
|
|
282
305
|
}
|
|
283
306
|
}
|
|
@@ -339,7 +362,7 @@ function withLayoutItem(layout, itemKey, cb) {
|
|
|
339
362
|
layout = modifyLayout(layout, item);
|
|
340
363
|
return [layout, item];
|
|
341
364
|
}
|
|
342
|
-
function correctBounds(layout, bounds, colapsedHeight) {
|
|
365
|
+
function correctBounds(layout, bounds, colapsedHeight, rowHeight) {
|
|
343
366
|
const collidesWith = getStatics(layout);
|
|
344
367
|
for (let i = 0, len = layout.length; i < len; i++) {
|
|
345
368
|
const l = layout[i];
|
|
@@ -352,21 +375,61 @@ function correctBounds(layout, bounds, colapsedHeight) {
|
|
|
352
375
|
if (!l.static)
|
|
353
376
|
collidesWith.push(l);
|
|
354
377
|
else {
|
|
355
|
-
while (getFirstCollision(collidesWith, l, colapsedHeight)) {
|
|
378
|
+
while (getFirstCollision(collidesWith, l, colapsedHeight, rowHeight)) {
|
|
356
379
|
l.y++;
|
|
357
380
|
}
|
|
358
381
|
}
|
|
359
382
|
}
|
|
360
383
|
return layout;
|
|
361
384
|
}
|
|
362
|
-
function getH(h, colapsedHeight, colapsed) {
|
|
385
|
+
function getH(h, colapsedHeight, rowHeight, colapsed) {
|
|
363
386
|
if (colapsed) {
|
|
364
|
-
|
|
387
|
+
let ret;
|
|
388
|
+
if (rowHeight && rowHeight > 0) {
|
|
389
|
+
ret = colapsedHeight / rowHeight;
|
|
390
|
+
} else {
|
|
391
|
+
ret = colapsedHeight / DEFAULT_ROW_HEIGHT;
|
|
392
|
+
}
|
|
393
|
+
return ret;
|
|
365
394
|
}
|
|
366
395
|
return h;
|
|
367
396
|
}
|
|
368
|
-
function getLayoutItemH(layoutItem, colapsedHeight) {
|
|
369
|
-
return getH(layoutItem.h, colapsedHeight, layoutItem.colapsed);
|
|
397
|
+
function getLayoutItemH(layoutItem, colapsedHeight, rowHeight) {
|
|
398
|
+
return getH(layoutItem.h, colapsedHeight, rowHeight, layoutItem.colapsed);
|
|
399
|
+
}
|
|
400
|
+
function isEqualLayoutItem(layoutA, layoutB) {
|
|
401
|
+
if (layoutA.i !== layoutB.i) {
|
|
402
|
+
return false;
|
|
403
|
+
} else if (layoutA.x !== layoutB.x || layoutA.y !== layoutB.y || layoutA.w !== layoutB.w || layoutA.h !== layoutB.h || layoutA.colapsed !== layoutB.colapsed || layoutA.visible !== layoutB.visible || layoutA.freeMove !== layoutB.freeMove) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
function isEqualLayout(layoutA, layoutB) {
|
|
409
|
+
if (layoutA.length !== layoutB.length) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
for (let index = 0; index < layoutA.length; index++) {
|
|
413
|
+
if (!isEqualLayoutItem(layoutA[index], layoutB[index])) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
function isEqualLayouts(layoutsA, layoutsB) {
|
|
420
|
+
if (Object.keys(layoutsA).length !== Object.keys(layoutsB).length) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
for (const breakPoint in layoutsA) {
|
|
424
|
+
if (layoutsB[breakPoint]) {
|
|
425
|
+
if (!isEqualLayout(layoutsA[breakPoint], layoutsB[breakPoint])) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return true;
|
|
370
433
|
}
|
|
371
434
|
function calcGridColWidth(positionParams) {
|
|
372
435
|
const { containerMargin: margin, containerPadding, containerWidth, cols } = positionParams;
|
|
@@ -432,367 +495,22 @@ function calcWH(positionParams, width, height, x, y) {
|
|
|
432
495
|
function clamp(num, lowerBound, upperBound) {
|
|
433
496
|
return Math.max(Math.min(num, upperBound), lowerBound);
|
|
434
497
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
className = "",
|
|
452
|
-
cancel = "",
|
|
453
|
-
handle = "",
|
|
454
|
-
minH = 1,
|
|
455
|
-
minW = 1,
|
|
456
|
-
maxH = Infinity,
|
|
457
|
-
maxW = Infinity,
|
|
458
|
-
isResizable,
|
|
459
|
-
isDraggable,
|
|
460
|
-
onDragStart,
|
|
461
|
-
onDrag,
|
|
462
|
-
onDragStop,
|
|
463
|
-
onFreeMoveClick,
|
|
464
|
-
layoutItemRender: ComponentItemRender,
|
|
465
|
-
resizeHandles,
|
|
466
|
-
resizeHandle,
|
|
467
|
-
transformScale = 1,
|
|
468
|
-
useCSSTransforms = true,
|
|
469
|
-
usePercentages,
|
|
470
|
-
style,
|
|
471
|
-
freeMove,
|
|
472
|
-
maximize = "none",
|
|
473
|
-
colapsed,
|
|
474
|
-
colapsedHeight = 1.5,
|
|
475
|
-
visible = true
|
|
476
|
-
} = props;
|
|
477
|
-
const refProps = useRef({
|
|
478
|
-
cols,
|
|
479
|
-
x,
|
|
480
|
-
y,
|
|
481
|
-
w,
|
|
482
|
-
h: getH(h, colapsedHeight, colapsed),
|
|
483
|
-
minW,
|
|
484
|
-
maxW,
|
|
485
|
-
minH,
|
|
486
|
-
maxH,
|
|
487
|
-
containerWidth,
|
|
488
|
-
containerHeight,
|
|
489
|
-
margin,
|
|
490
|
-
containerPadding,
|
|
491
|
-
rowHeight,
|
|
492
|
-
maxRows,
|
|
493
|
-
colapsed
|
|
494
|
-
});
|
|
495
|
-
useEffect(() => {
|
|
496
|
-
refProps.current = {
|
|
497
|
-
cols,
|
|
498
|
-
x,
|
|
499
|
-
y,
|
|
500
|
-
w,
|
|
501
|
-
h: getH(h, colapsedHeight, colapsed),
|
|
502
|
-
minW,
|
|
503
|
-
maxW,
|
|
504
|
-
minH,
|
|
505
|
-
maxH,
|
|
506
|
-
containerWidth,
|
|
507
|
-
containerHeight,
|
|
508
|
-
margin,
|
|
509
|
-
containerPadding,
|
|
510
|
-
rowHeight,
|
|
511
|
-
maxRows,
|
|
512
|
-
colapsed
|
|
513
|
-
};
|
|
514
|
-
}, [cols, x, y, w, h, minW, maxW, minH, maxH, containerWidth, containerHeight, margin, containerPadding, rowHeight, maxRows, colapsed, colapsedHeight]);
|
|
515
|
-
const [currentState, setCurrentState] = useState({
|
|
516
|
-
resizing: void 0,
|
|
517
|
-
dragging: void 0,
|
|
518
|
-
className: ""
|
|
519
|
-
});
|
|
520
|
-
const refState = useRef({
|
|
521
|
-
resizing: void 0,
|
|
522
|
-
dragging: void 0,
|
|
523
|
-
className: ""
|
|
524
|
-
});
|
|
525
|
-
const elementRef = useRef(null);
|
|
526
|
-
const getPositionParams = useCallback((preferContainerWidth, preferContainerHeight) => {
|
|
527
|
-
return {
|
|
528
|
-
cols: refProps.current.cols,
|
|
529
|
-
containerPadding: refProps.current.containerPadding,
|
|
530
|
-
containerWidth: preferContainerWidth || refProps.current.containerWidth,
|
|
531
|
-
containerHeight: preferContainerHeight || refProps.current.containerHeight,
|
|
532
|
-
containerMargin: refProps.current.margin,
|
|
533
|
-
maxRows: refProps.current.maxRows,
|
|
534
|
-
rowHeight: refProps.current.rowHeight
|
|
535
|
-
};
|
|
536
|
-
}, []);
|
|
537
|
-
useEffect(() => {
|
|
538
|
-
return () => {
|
|
539
|
-
};
|
|
540
|
-
}, []);
|
|
541
|
-
const createStyle = (pos2) => {
|
|
542
|
-
let newStyle;
|
|
543
|
-
if (useCSSTransforms) {
|
|
544
|
-
newStyle = setTransform(pos2);
|
|
545
|
-
} else {
|
|
546
|
-
newStyle = setTopLeft(pos2);
|
|
547
|
-
if (usePercentages) {
|
|
548
|
-
newStyle.left = perc(pos2.left / containerWidth);
|
|
549
|
-
newStyle.width = perc(pos2.width / containerWidth);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return newStyle;
|
|
553
|
-
};
|
|
554
|
-
const gridItemOnDragStart = useCallback((e, {
|
|
555
|
-
node
|
|
556
|
-
}) => {
|
|
557
|
-
if (!onDragStart)
|
|
558
|
-
return;
|
|
559
|
-
const newPosition = {
|
|
560
|
-
top: 0,
|
|
561
|
-
left: 0
|
|
562
|
-
};
|
|
563
|
-
const {
|
|
564
|
-
offsetParent
|
|
565
|
-
} = node;
|
|
566
|
-
if (!offsetParent)
|
|
567
|
-
return;
|
|
568
|
-
const parentRect = offsetParent.getBoundingClientRect();
|
|
569
|
-
const clientRect = node.getBoundingClientRect();
|
|
570
|
-
const cLeft = clientRect.left / transformScale;
|
|
571
|
-
const pLeft = parentRect.left / transformScale;
|
|
572
|
-
const cTop = clientRect.top / transformScale;
|
|
573
|
-
const pTop = parentRect.top / transformScale;
|
|
574
|
-
newPosition.left = cLeft - pLeft + offsetParent.scrollLeft;
|
|
575
|
-
newPosition.top = cTop - pTop + offsetParent.scrollTop;
|
|
576
|
-
setCurrentState((prev) => ({
|
|
577
|
-
...prev,
|
|
578
|
-
dragging: newPosition
|
|
579
|
-
}));
|
|
580
|
-
refState.current.dragging = newPosition;
|
|
581
|
-
const {
|
|
582
|
-
x: newX,
|
|
583
|
-
y: newY
|
|
584
|
-
} = calcXY(getPositionParams(), newPosition.top, newPosition.left, refProps.current.w, refProps.current.h);
|
|
585
|
-
onDragStart(i, newX, newY, {
|
|
586
|
-
e,
|
|
587
|
-
node,
|
|
588
|
-
newPosition
|
|
589
|
-
});
|
|
590
|
-
}, []);
|
|
591
|
-
const gridItemOnDrag = useCallback((e, {
|
|
592
|
-
node,
|
|
593
|
-
deltaX,
|
|
594
|
-
deltaY
|
|
595
|
-
}) => {
|
|
596
|
-
if (!onDrag)
|
|
597
|
-
return;
|
|
598
|
-
if (!refState.current.dragging) {
|
|
599
|
-
console.warn("gridItemOnDrag onDrag called before onDragStart");
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
let top = refState.current.dragging.top + deltaY;
|
|
603
|
-
let left = refState.current.dragging.left + deltaX;
|
|
604
|
-
const positionParams = getPositionParams();
|
|
605
|
-
if (isBounded) {
|
|
606
|
-
const {
|
|
607
|
-
offsetParent
|
|
608
|
-
} = node;
|
|
609
|
-
if (offsetParent) {
|
|
610
|
-
const bottomBoundary = offsetParent.clientHeight - calcGridItemWHPx(refProps.current.h, refProps.current.rowHeight, refProps.current.margin[1]);
|
|
611
|
-
top = clamp(top, 0, bottomBoundary);
|
|
612
|
-
const colWidth = calcGridColWidth(positionParams);
|
|
613
|
-
const rightBoundary = containerWidth - calcGridItemWHPx(refProps.current.w, colWidth, refProps.current.margin[0]);
|
|
614
|
-
left = clamp(left, 0, rightBoundary);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
const newPosition = {
|
|
618
|
-
top,
|
|
619
|
-
left
|
|
620
|
-
};
|
|
621
|
-
refState.current.dragging = newPosition;
|
|
622
|
-
const {
|
|
623
|
-
x: newX,
|
|
624
|
-
y: newY
|
|
625
|
-
} = calcXY(positionParams, top, left, refProps.current.w, refProps.current.h);
|
|
626
|
-
onDrag(i, newX, newY, {
|
|
627
|
-
e,
|
|
628
|
-
node,
|
|
629
|
-
newPosition
|
|
630
|
-
});
|
|
631
|
-
setCurrentState((prev) => ({
|
|
632
|
-
...prev,
|
|
633
|
-
dragging: newPosition
|
|
634
|
-
}));
|
|
635
|
-
}, []);
|
|
636
|
-
const gridItemOnDragStop = useCallback((e, {
|
|
637
|
-
node
|
|
638
|
-
}) => {
|
|
639
|
-
if (!onDragStop)
|
|
640
|
-
return;
|
|
641
|
-
if (!refState.current.dragging) {
|
|
642
|
-
console.warn("onDragEnd called before onDragStart");
|
|
643
|
-
return;
|
|
644
|
-
}
|
|
645
|
-
const {
|
|
646
|
-
left,
|
|
647
|
-
top
|
|
648
|
-
} = refState.current.dragging;
|
|
649
|
-
const newPosition = {
|
|
650
|
-
top,
|
|
651
|
-
left
|
|
652
|
-
};
|
|
653
|
-
setCurrentState((prev) => ({
|
|
654
|
-
...prev,
|
|
655
|
-
dragging: void 0
|
|
656
|
-
}));
|
|
657
|
-
refState.current.dragging = void 0;
|
|
658
|
-
const {
|
|
659
|
-
x: newX,
|
|
660
|
-
y: newY
|
|
661
|
-
} = calcXY(getPositionParams(), top, left, refProps.current.w, refProps.current.h);
|
|
662
|
-
return onDragStop(i, newX, newY, {
|
|
663
|
-
e,
|
|
664
|
-
node,
|
|
665
|
-
newPosition
|
|
666
|
-
});
|
|
667
|
-
}, []);
|
|
668
|
-
const onResizeHandler = useCallback((e, {
|
|
669
|
-
node,
|
|
670
|
-
size
|
|
671
|
-
}, handlerName) => {
|
|
672
|
-
const handler = props[handlerName];
|
|
673
|
-
if (!handler) {
|
|
674
|
-
console.error("no puede irse por aca");
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
if (colapsed) {
|
|
678
|
-
console.error("no puede tener resize");
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
let {
|
|
682
|
-
w: newW,
|
|
683
|
-
h: newH
|
|
684
|
-
} = calcWH(getPositionParams(), size.width, size.height, refProps.current.x, refProps.current.y);
|
|
685
|
-
const newMinW = Math.max(refProps.current.minW, 1);
|
|
686
|
-
const newMaxW = Math.min(refProps.current.maxW, refProps.current.cols - refProps.current.x);
|
|
687
|
-
newW = clamp(newW, newMinW, newMaxW);
|
|
688
|
-
newH = clamp(newH, refProps.current.minH, refProps.current.maxH);
|
|
689
|
-
setCurrentState((prev) => ({
|
|
690
|
-
...prev,
|
|
691
|
-
resizing: handlerName === "onResizeStop" ? void 0 : size
|
|
692
|
-
}));
|
|
693
|
-
handler(i, newW, newH, {
|
|
694
|
-
e,
|
|
695
|
-
node,
|
|
696
|
-
size
|
|
697
|
-
});
|
|
698
|
-
}, []);
|
|
699
|
-
const localOnResizeStop = useCallback((e, callbackData) => {
|
|
700
|
-
onResizeHandler(e, callbackData, "onResizeStop");
|
|
701
|
-
}, []);
|
|
702
|
-
const localOnResizeStart = useCallback((e, callbackData) => {
|
|
703
|
-
onResizeHandler(e, callbackData, "onResizeStart");
|
|
704
|
-
}, []);
|
|
705
|
-
const localFreeMoveOnClick = useCallback(() => {
|
|
706
|
-
if (!onFreeMoveClick)
|
|
707
|
-
return;
|
|
708
|
-
onFreeMoveClick(i);
|
|
709
|
-
}, []);
|
|
710
|
-
const mixinResizable = useCallback((child, position, positionParams) => {
|
|
711
|
-
const maxWidth = calcGridItemPosition(positionParams, 0, 0, cols - x, 0, maximize).width;
|
|
712
|
-
const mins = calcGridItemPosition(positionParams, 0, 0, minW, minH, maximize);
|
|
713
|
-
const maxes = calcGridItemPosition(positionParams, 0, 0, maxW, maxH, maximize);
|
|
714
|
-
const minConstraints = [mins.width, mins.height];
|
|
715
|
-
const maxConstraints = [Math.min(maxes.width, maxWidth), Math.min(maxes.height, Infinity)];
|
|
716
|
-
return /* @__PURE__ */ jsx(
|
|
717
|
-
Resizable,
|
|
718
|
-
{
|
|
719
|
-
draggableOpts: {
|
|
720
|
-
disabled: !isResizable || maximize !== "none" || colapsed
|
|
721
|
-
},
|
|
722
|
-
className: isResizable ? void 0 : "react-resizable-hide",
|
|
723
|
-
width: position.width,
|
|
724
|
-
height: position.height,
|
|
725
|
-
minConstraints,
|
|
726
|
-
maxConstraints,
|
|
727
|
-
onResizeStop: localOnResizeStop,
|
|
728
|
-
onResizeStart: localOnResizeStart,
|
|
729
|
-
onResize: localOnResize,
|
|
730
|
-
transformScale,
|
|
731
|
-
resizeHandles,
|
|
732
|
-
handle: resizeHandle,
|
|
733
|
-
children: child
|
|
734
|
-
}
|
|
735
|
-
);
|
|
736
|
-
}, [cols, x, minW, minH, maxW, maxH, isResizable, transformScale, resizeHandles, resizeHandle, maximize, colapsed]);
|
|
737
|
-
const mixinDraggable = useCallback((child) => {
|
|
738
|
-
return /* @__PURE__ */ jsx(DraggableCore_1, {
|
|
739
|
-
disabled: !isDraggable || maximize !== "none",
|
|
740
|
-
onStart: gridItemOnDragStart,
|
|
741
|
-
onDrag: gridItemOnDrag,
|
|
742
|
-
onStop: gridItemOnDragStop,
|
|
743
|
-
handle,
|
|
744
|
-
cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""),
|
|
745
|
-
scale: transformScale,
|
|
746
|
-
nodeRef: elementRef,
|
|
747
|
-
children: child
|
|
748
|
-
});
|
|
749
|
-
}, [isDraggable, handle, transformScale, cancel, maximize]);
|
|
750
|
-
const localOnResize = useCallback((e, callbackData) => {
|
|
751
|
-
onResizeHandler(e, callbackData, "onResize");
|
|
752
|
-
}, []);
|
|
753
|
-
const positionParms = getPositionParams(containerWidth, containerHeight);
|
|
754
|
-
const pos = calcGridItemPosition(positionParms, x, y, w, getH(h, colapsedHeight, colapsed), maximize, currentState);
|
|
755
|
-
const classNameFinal = clsx("M4LGridItem", className, {
|
|
756
|
-
type,
|
|
757
|
-
static: props.static,
|
|
758
|
-
resizing: Boolean(currentState.resizing),
|
|
759
|
-
"react-draggable": isDraggable,
|
|
760
|
-
"react-maximize-me": maximize === "maximize_me",
|
|
761
|
-
"react-maximize-other": maximize === "maximize_other",
|
|
762
|
-
"react-colapsed": colapsed,
|
|
763
|
-
M4LGridItemPopup: freeMove,
|
|
764
|
-
"react-draggable-dragging": Boolean(currentState.dragging),
|
|
765
|
-
M4LColapsed: colapsed,
|
|
766
|
-
M4LResizeHide: colapsed,
|
|
767
|
-
M4LInvisible: !visible,
|
|
768
|
-
cssTransforms: useCSSTransforms
|
|
769
|
-
});
|
|
770
|
-
const styleFinal = {
|
|
771
|
-
...style,
|
|
772
|
-
...createStyle(pos)
|
|
773
|
-
};
|
|
774
|
-
const memoLayouItemRender = useMemo(() => {
|
|
775
|
-
return /* @__PURE__ */ jsx(ComponentItemRender, {
|
|
776
|
-
type,
|
|
777
|
-
i
|
|
778
|
-
});
|
|
779
|
-
}, [type, i]);
|
|
780
|
-
const baseGridItem = /* @__PURE__ */ jsx("div", {
|
|
781
|
-
className: classNameFinal,
|
|
782
|
-
ref: elementRef,
|
|
783
|
-
style: styleFinal,
|
|
784
|
-
role: "presentation",
|
|
785
|
-
onClick: localFreeMoveOnClick,
|
|
786
|
-
children: memoLayouItemRender
|
|
787
|
-
});
|
|
788
|
-
const gridItem = mixinDraggable(mixinResizable(baseGridItem, pos, getPositionParams()));
|
|
789
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
790
|
-
children: gridItem
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
const MemonizedGridItem = React__default.memo(GridItem, (prevProps, nextProps) => {
|
|
794
|
-
return deepEqual(prevProps, nextProps);
|
|
795
|
-
});
|
|
498
|
+
const gridLayoutClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
|
|
499
|
+
"root",
|
|
500
|
+
"gridItemRoot",
|
|
501
|
+
"gridItemType",
|
|
502
|
+
"gridItemPlaceholder",
|
|
503
|
+
"gridItemFreeMove",
|
|
504
|
+
"maximizeMe",
|
|
505
|
+
"maximizeOther",
|
|
506
|
+
"colapsed",
|
|
507
|
+
"resizeHide",
|
|
508
|
+
"invisible",
|
|
509
|
+
"cssTransforms",
|
|
510
|
+
"resizing",
|
|
511
|
+
"dragging",
|
|
512
|
+
"static"
|
|
513
|
+
]);
|
|
796
514
|
const GridLayoutRoot = styled("div")`
|
|
797
515
|
/* height: 100%; */
|
|
798
516
|
overflow: auto;
|
|
@@ -801,45 +519,45 @@ const GridLayoutRoot = styled("div")`
|
|
|
801
519
|
transition: height 200ms ease;
|
|
802
520
|
/* border: 1px dashed gray; //TODO:Para borrar */
|
|
803
521
|
|
|
804
|
-
.
|
|
522
|
+
.${gridLayoutClasses.gridItemRoot} {
|
|
805
523
|
transition: all 200ms ease;
|
|
806
524
|
transition-property: left, top;
|
|
807
525
|
}
|
|
808
|
-
.
|
|
526
|
+
.${gridLayoutClasses.gridItemRoot} img {
|
|
809
527
|
pointer-events: none;
|
|
810
528
|
user-select: none;
|
|
811
529
|
}
|
|
812
|
-
.
|
|
530
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.cssTransforms} {
|
|
813
531
|
transition-property: transform;
|
|
814
532
|
}
|
|
815
|
-
.
|
|
533
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.maximizeOther} {
|
|
816
534
|
display: none;
|
|
817
535
|
}
|
|
818
536
|
|
|
819
|
-
.
|
|
537
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.gridItemFreeMove} {
|
|
820
538
|
z-index: 1;
|
|
821
539
|
will-change: width, height;
|
|
822
540
|
}
|
|
823
|
-
.
|
|
541
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.resizing} {
|
|
824
542
|
z-index: 2000;
|
|
825
543
|
will-change: width, height;
|
|
826
544
|
}
|
|
827
545
|
|
|
828
|
-
.
|
|
546
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.dragging} {
|
|
829
547
|
transition: none;
|
|
830
548
|
z-index: 4000;
|
|
831
549
|
will-change: transform;
|
|
832
550
|
}
|
|
833
551
|
|
|
834
|
-
.
|
|
552
|
+
.${gridLayoutClasses.gridItemRoot}.dropping {
|
|
835
553
|
visibility: hidden;
|
|
836
554
|
}
|
|
837
555
|
|
|
838
|
-
.
|
|
556
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.gridItemPlaceholder} {
|
|
839
557
|
background: green;
|
|
840
558
|
opacity: 0.2;
|
|
841
559
|
transition-duration: 100ms;
|
|
842
|
-
z-index:
|
|
560
|
+
z-index: 3000;
|
|
843
561
|
-webkit-user-select: none;
|
|
844
562
|
-moz-user-select: none;
|
|
845
563
|
-ms-user-select: none;
|
|
@@ -847,13 +565,13 @@ const GridLayoutRoot = styled("div")`
|
|
|
847
565
|
user-select: none;
|
|
848
566
|
}
|
|
849
567
|
|
|
850
|
-
.
|
|
568
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle {
|
|
851
569
|
position: absolute;
|
|
852
570
|
width: 20px;
|
|
853
571
|
height: 20px;
|
|
854
572
|
}
|
|
855
573
|
|
|
856
|
-
.
|
|
574
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle::after {
|
|
857
575
|
content: '';
|
|
858
576
|
position: absolute;
|
|
859
577
|
right: 3px;
|
|
@@ -868,128 +586,133 @@ const GridLayoutRoot = styled("div")`
|
|
|
868
586
|
display: none;
|
|
869
587
|
}
|
|
870
588
|
|
|
871
|
-
.
|
|
589
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-sw {
|
|
872
590
|
bottom: 0;
|
|
873
591
|
left: 0;
|
|
874
592
|
cursor: sw-resize;
|
|
875
593
|
transform: rotate(90deg);
|
|
876
594
|
}
|
|
877
|
-
.
|
|
595
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-se {
|
|
878
596
|
bottom: 0;
|
|
879
597
|
right: 0;
|
|
880
598
|
cursor: se-resize;
|
|
881
599
|
}
|
|
882
|
-
.
|
|
600
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-nw {
|
|
883
601
|
top: 0;
|
|
884
602
|
left: 0;
|
|
885
603
|
cursor: nw-resize;
|
|
886
604
|
transform: rotate(180deg);
|
|
887
605
|
}
|
|
888
|
-
.
|
|
606
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-ne {
|
|
889
607
|
top: 0;
|
|
890
608
|
right: 0;
|
|
891
609
|
cursor: ne-resize;
|
|
892
610
|
transform: rotate(270deg);
|
|
893
611
|
}
|
|
894
|
-
.
|
|
895
|
-
.
|
|
612
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-w,
|
|
613
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-e {
|
|
896
614
|
top: 50%;
|
|
897
615
|
margin-top: -10px;
|
|
898
616
|
cursor: ew-resize;
|
|
899
617
|
}
|
|
900
|
-
.
|
|
618
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-w {
|
|
901
619
|
left: 0;
|
|
902
620
|
transform: rotate(135deg);
|
|
903
621
|
}
|
|
904
|
-
.
|
|
622
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-e {
|
|
905
623
|
right: 0;
|
|
906
624
|
transform: rotate(315deg);
|
|
907
625
|
}
|
|
908
|
-
.
|
|
909
|
-
.
|
|
626
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-n,
|
|
627
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-s {
|
|
910
628
|
left: 50%;
|
|
911
629
|
margin-left: -10px;
|
|
912
630
|
cursor: ns-resize;
|
|
913
631
|
}
|
|
914
|
-
.
|
|
632
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-n {
|
|
915
633
|
top: 0;
|
|
916
634
|
transform: rotate(225deg);
|
|
917
635
|
}
|
|
918
|
-
.
|
|
636
|
+
.${gridLayoutClasses.gridItemRoot} > .react-resizable-handle.react-resizable-handle-s {
|
|
919
637
|
bottom: 0;
|
|
920
638
|
transform: rotate(45deg);
|
|
921
639
|
}
|
|
922
|
-
.
|
|
923
|
-
.
|
|
640
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.maximizeMe} > .react-resizable-handle,
|
|
641
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.resizeHide} > .react-resizable-handle {
|
|
924
642
|
display: none;
|
|
925
643
|
}
|
|
926
|
-
.
|
|
644
|
+
.${gridLayoutClasses.gridItemRoot}.${gridLayoutClasses.invisible} {
|
|
927
645
|
display: none;
|
|
928
646
|
}
|
|
929
647
|
|
|
930
648
|
${react_resizable_css}
|
|
649
|
+
${(props) => props.theme.components?.M4LGridLayout?.styleOverrides}
|
|
931
650
|
`;
|
|
932
|
-
const layoutClassName = "M4LGridLayout";
|
|
933
651
|
function GridLayout(props) {
|
|
934
652
|
const {
|
|
653
|
+
layoutItemRender,
|
|
935
654
|
innerRef,
|
|
936
655
|
autoSize = true,
|
|
937
|
-
cols =
|
|
656
|
+
cols = DEFAULT_COLS,
|
|
657
|
+
containerPadding = DEFAULT_CONTAINER_PADDING,
|
|
658
|
+
margin = DEFAULT_MARGIN,
|
|
659
|
+
rowHeight = DEFAULT_ROW_HEIGHT,
|
|
660
|
+
containerWidth = DEFAULT_CONTAINER_WIDTH,
|
|
661
|
+
containerHeight = DEFAULT_CONTAINER_HEIGHT,
|
|
662
|
+
transformScale = DEFAULT_TRANSFORM_SCALE,
|
|
663
|
+
colapsedHeight = DEFAULT_COLAPSED_HEIGHT,
|
|
938
664
|
className = "",
|
|
939
665
|
style = {},
|
|
940
666
|
draggableHandle = "",
|
|
941
667
|
draggableCancel = "",
|
|
942
|
-
containerPadding = null,
|
|
943
|
-
rowHeight = 150,
|
|
944
668
|
maxRows = Infinity,
|
|
945
669
|
layout = [],
|
|
946
|
-
containerMargin = [10, 10],
|
|
947
670
|
isBounded = false,
|
|
948
671
|
isDraggable = true,
|
|
949
672
|
isResizable = true,
|
|
950
673
|
allowOverlap = false,
|
|
951
674
|
useCSSTransforms = true,
|
|
952
|
-
transformScale = 1,
|
|
953
675
|
compactType = null,
|
|
954
676
|
preventCollision = false,
|
|
955
677
|
resizeHandles = ["se"],
|
|
956
678
|
resizeHandle,
|
|
957
|
-
|
|
958
|
-
width = 1280,
|
|
959
|
-
height = 720,
|
|
679
|
+
maximizeId,
|
|
960
680
|
onLayoutChange = noop,
|
|
961
681
|
onDragStart = noop,
|
|
962
682
|
onDrag = noop,
|
|
963
683
|
onDragStop = noop,
|
|
964
684
|
onResizeStart = noop,
|
|
965
685
|
onResize = noop,
|
|
966
|
-
onResizeStop = noop
|
|
967
|
-
maximizeId,
|
|
968
|
-
colapsedHeight = 2
|
|
686
|
+
onResizeStop = noop
|
|
969
687
|
} = props;
|
|
970
688
|
const [currentState, setCurrentState] = useState({
|
|
971
689
|
mounted: false
|
|
972
690
|
});
|
|
691
|
+
const [nrOnlayoutChanges, setNrOnlayoutChanges] = useState(0);
|
|
973
692
|
const [finalLayoutRender, setFinalLayoutRender] = useState(layout);
|
|
974
693
|
const [zIndexes, setzIndexes] = useState(() => {
|
|
975
694
|
return layout.filter((li) => li.freeMove).map((lmap) => lmap.i);
|
|
976
695
|
});
|
|
977
|
-
const refZindexes = useRef(zIndexes);
|
|
978
696
|
const refState = useRef({
|
|
979
697
|
layout,
|
|
980
|
-
mounted: false,
|
|
981
698
|
oldDragItem: void 0,
|
|
982
699
|
oldLayout: void 0,
|
|
983
|
-
oldResizeItem: void 0
|
|
700
|
+
oldResizeItem: void 0,
|
|
701
|
+
zIndexes
|
|
984
702
|
});
|
|
985
703
|
useEffect(() => {
|
|
986
704
|
setCurrentState({
|
|
987
705
|
mounted: true
|
|
988
706
|
});
|
|
989
707
|
}, []);
|
|
708
|
+
useEffect(() => {
|
|
709
|
+
if (nrOnlayoutChanges > 0) {
|
|
710
|
+
console.log("nrOnlayoutChanges fired", nrOnlayoutChanges, finalLayoutRender, refState.current.layout);
|
|
711
|
+
onLayoutChange(refState.current.layout);
|
|
712
|
+
}
|
|
713
|
+
}, [nrOnlayoutChanges]);
|
|
990
714
|
useEffect(() => {
|
|
991
715
|
if (!isEqualLayout(finalLayoutRender, layout)) {
|
|
992
|
-
console.debug("****useEffect GridLayout cambio de layout****", layout);
|
|
993
716
|
const newLayout = cloneLayout(layout);
|
|
994
717
|
const newzIndexes = [...zIndexes];
|
|
995
718
|
for (let index = 0; index < newLayout.length; index++) {
|
|
@@ -1002,19 +725,18 @@ function GridLayout(props) {
|
|
|
1002
725
|
setFinalLayoutRender(newLayout);
|
|
1003
726
|
if (newzIndexes.length !== zIndexes.length) {
|
|
1004
727
|
setzIndexes(newzIndexes);
|
|
1005
|
-
|
|
728
|
+
refState.current.zIndexes = newzIndexes;
|
|
1006
729
|
}
|
|
1007
|
-
} else {
|
|
1008
|
-
console.debug("****useEffect cambio de layout sin cambios****");
|
|
1009
730
|
}
|
|
1010
731
|
}, [layout]);
|
|
1011
|
-
const
|
|
1012
|
-
if (!
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
732
|
+
const onLayoutMaybeChanged = useCallback((newLayout, oldLayout) => {
|
|
733
|
+
if (!oldLayout) {
|
|
734
|
+
oldLayout = refState.current.layout;
|
|
735
|
+
}
|
|
736
|
+
if (!isEqualLayout(oldLayout, newLayout)) {
|
|
737
|
+
setNrOnlayoutChanges((prev) => prev + 1);
|
|
738
|
+
}
|
|
739
|
+
}, []);
|
|
1018
740
|
const localOnDragStart = useCallback((i, _x, _y, gridDragEvent) => {
|
|
1019
741
|
const {
|
|
1020
742
|
layout: layout2
|
|
@@ -1023,26 +745,22 @@ function GridLayout(props) {
|
|
|
1023
745
|
e,
|
|
1024
746
|
node
|
|
1025
747
|
} = gridDragEvent;
|
|
1026
|
-
const
|
|
1027
|
-
if (!
|
|
748
|
+
const li = getLayoutItem(layout2, i);
|
|
749
|
+
if (!li)
|
|
1028
750
|
return;
|
|
1029
751
|
refState.current = {
|
|
1030
752
|
...refState.current,
|
|
1031
|
-
oldDragItem: cloneLayoutItem(
|
|
1032
|
-
oldLayout:
|
|
753
|
+
oldDragItem: cloneLayoutItem(li),
|
|
754
|
+
oldLayout: layout2
|
|
1033
755
|
};
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
}, []);
|
|
1037
|
-
const onLayoutMaybeChanged = useCallback((newLayout, oldLayout) => {
|
|
1038
|
-
console.log("onLayoutMaybeChanged", deepEqual(oldLayout, newLayout));
|
|
1039
|
-
if (!oldLayout) {
|
|
1040
|
-
oldLayout = refState.current.layout;
|
|
756
|
+
if (li && li.freeMove) {
|
|
757
|
+
onClickSetOnTopFreeMove(li.i, "onDragStart");
|
|
1041
758
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
onLayoutChange(newLayout);
|
|
759
|
+
if (gridDragEvent.e.type !== "touchmove") {
|
|
760
|
+
gridDragEvent.e.preventDefault();
|
|
1045
761
|
}
|
|
762
|
+
gridDragEvent.e.stopPropagation();
|
|
763
|
+
return onDragStart(layout2, li, li, void 0, e, node);
|
|
1046
764
|
}, []);
|
|
1047
765
|
const localOnDrag = useCallback((i, x, y, gridDragEvent) => {
|
|
1048
766
|
const {
|
|
@@ -1053,31 +771,30 @@ function GridLayout(props) {
|
|
|
1053
771
|
e,
|
|
1054
772
|
node
|
|
1055
773
|
} = gridDragEvent;
|
|
1056
|
-
const
|
|
1057
|
-
if (!
|
|
774
|
+
const li = getLayoutItem(layout2, i);
|
|
775
|
+
if (!li)
|
|
1058
776
|
return;
|
|
1059
777
|
const newPlaceholder = {
|
|
1060
|
-
w:
|
|
1061
|
-
h: getLayoutItemH(
|
|
1062
|
-
x:
|
|
1063
|
-
y:
|
|
778
|
+
w: li.w,
|
|
779
|
+
h: getLayoutItemH(li, colapsedHeight, rowHeight),
|
|
780
|
+
x: li.x,
|
|
781
|
+
y: li.y,
|
|
1064
782
|
placeholder: true,
|
|
1065
783
|
i
|
|
1066
784
|
};
|
|
1067
785
|
const isUserAction = true;
|
|
1068
786
|
try {
|
|
1069
787
|
let newLayout;
|
|
1070
|
-
if (!
|
|
1071
|
-
newLayout = moveElement(layout2,
|
|
788
|
+
if (!li.freeMove) {
|
|
789
|
+
newLayout = moveElement(layout2, li, x, y, isUserAction, preventCollision, compactType, cols, colapsedHeight, rowHeight, allowOverlap);
|
|
1072
790
|
} else {
|
|
1073
|
-
|
|
1074
|
-
|
|
791
|
+
li.x = x;
|
|
792
|
+
li.y = y;
|
|
1075
793
|
newPlaceholder.x = x;
|
|
1076
794
|
newPlaceholder.y = y;
|
|
1077
795
|
newLayout = cloneLayout(layout2);
|
|
1078
796
|
}
|
|
1079
|
-
|
|
1080
|
-
const finalLayout = allowOverlap || l.freeMove ? newLayout : compact(newLayout, compactType, cols, colapsedHeight, allowOverlap);
|
|
797
|
+
const finalLayout = allowOverlap || li.freeMove ? newLayout : compact(newLayout, compactType, cols, colapsedHeight, rowHeight, allowOverlap);
|
|
1081
798
|
refState.current = {
|
|
1082
799
|
...refState.current,
|
|
1083
800
|
layout: finalLayout,
|
|
@@ -1087,11 +804,12 @@ function GridLayout(props) {
|
|
|
1087
804
|
...prev,
|
|
1088
805
|
activeDrag: newPlaceholder
|
|
1089
806
|
}));
|
|
1090
|
-
setFinalLayoutRender(
|
|
807
|
+
setFinalLayoutRender(finalLayout);
|
|
1091
808
|
if (gridDragEvent.e.type !== "touchmove") {
|
|
1092
809
|
gridDragEvent.e.preventDefault();
|
|
1093
810
|
}
|
|
1094
811
|
gridDragEvent.e.stopPropagation();
|
|
812
|
+
onDrag(newLayout, oldDragItem, li, newPlaceholder, e, node);
|
|
1095
813
|
} catch (error) {
|
|
1096
814
|
console.warn("GridLayout error capturado");
|
|
1097
815
|
}
|
|
@@ -1100,37 +818,33 @@ function GridLayout(props) {
|
|
|
1100
818
|
e,
|
|
1101
819
|
node
|
|
1102
820
|
}) => {
|
|
1103
|
-
if (!refState.current.activeDrag)
|
|
821
|
+
if (!refState.current.activeDrag) {
|
|
822
|
+
console.log("GridLayout localOnDragStop sin movimiento");
|
|
1104
823
|
return;
|
|
824
|
+
}
|
|
1105
825
|
const {
|
|
1106
826
|
oldDragItem,
|
|
1107
827
|
layout: layout2,
|
|
1108
828
|
oldLayout
|
|
1109
829
|
} = refState.current;
|
|
1110
|
-
const
|
|
1111
|
-
if (!
|
|
830
|
+
const li = getLayoutItem(layout2, i);
|
|
831
|
+
if (!li)
|
|
1112
832
|
return;
|
|
1113
833
|
let newLayout;
|
|
1114
834
|
const isUserAction = true;
|
|
1115
|
-
if (!
|
|
1116
|
-
newLayout = moveElement(layout2,
|
|
835
|
+
if (!li.freeMove) {
|
|
836
|
+
newLayout = moveElement(layout2, li, x, y, isUserAction, preventCollision, compactType, cols, colapsedHeight, rowHeight, allowOverlap);
|
|
1117
837
|
} else {
|
|
1118
|
-
|
|
1119
|
-
|
|
838
|
+
li.x = x;
|
|
839
|
+
li.y = y;
|
|
1120
840
|
newLayout = cloneLayout(layout2);
|
|
1121
|
-
const nl = getLayoutItem(newLayout, i);
|
|
1122
|
-
if (nl) {
|
|
1123
|
-
nl.x = x;
|
|
1124
|
-
nl.y = y;
|
|
1125
|
-
}
|
|
1126
841
|
}
|
|
1127
|
-
|
|
1128
|
-
const finalLayout = allowOverlap ? newLayout || l.freeMove : compact(newLayout, compactType, cols, colapsedHeight, allowOverlap);
|
|
842
|
+
const finalLayout = allowOverlap ? newLayout || li.freeMove : compact(newLayout, compactType, cols, colapsedHeight, rowHeight, allowOverlap);
|
|
1129
843
|
setCurrentState((prev) => ({
|
|
1130
844
|
...prev,
|
|
1131
845
|
activeDrag: void 0
|
|
1132
846
|
}));
|
|
1133
|
-
|
|
847
|
+
setFinalLayoutRender(finalLayout);
|
|
1134
848
|
refState.current = {
|
|
1135
849
|
...refState.current,
|
|
1136
850
|
layout: finalLayout,
|
|
@@ -1138,9 +852,13 @@ function GridLayout(props) {
|
|
|
1138
852
|
oldLayout: void 0,
|
|
1139
853
|
activeDrag: void 0
|
|
1140
854
|
};
|
|
1141
|
-
console.log("localOnDragStop");
|
|
1142
|
-
e.
|
|
855
|
+
console.log("localOnDragStop", finalLayout);
|
|
856
|
+
if (e.type !== "touchmove") {
|
|
857
|
+
e.preventDefault();
|
|
858
|
+
}
|
|
1143
859
|
e.stopPropagation();
|
|
860
|
+
onLayoutMaybeChanged(finalLayout, oldLayout);
|
|
861
|
+
onDragStop(layout2, oldDragItem, li, void 0, e, node);
|
|
1144
862
|
}, []);
|
|
1145
863
|
const localOnResizeStart = useCallback((i, _w, _h, {
|
|
1146
864
|
e,
|
|
@@ -1149,15 +867,18 @@ function GridLayout(props) {
|
|
|
1149
867
|
const {
|
|
1150
868
|
layout: layout2
|
|
1151
869
|
} = refState.current;
|
|
1152
|
-
const
|
|
1153
|
-
if (!
|
|
870
|
+
const li = getLayoutItem(layout2, i);
|
|
871
|
+
if (!li)
|
|
1154
872
|
return;
|
|
1155
873
|
refState.current = {
|
|
1156
874
|
...refState.current,
|
|
1157
|
-
oldResizeItem: cloneLayoutItem(
|
|
1158
|
-
oldLayout:
|
|
875
|
+
oldResizeItem: cloneLayoutItem(li),
|
|
876
|
+
oldLayout: refState.current.layout
|
|
1159
877
|
};
|
|
1160
|
-
onResizeStart(layout2,
|
|
878
|
+
onResizeStart(layout2, li, li, void 0, e, node);
|
|
879
|
+
if (li && li.freeMove) {
|
|
880
|
+
onClickSetOnTopFreeMove(li.i, "onResizeStart");
|
|
881
|
+
}
|
|
1161
882
|
}, []);
|
|
1162
883
|
const localOnResize = useCallback((i, w, h, {
|
|
1163
884
|
e,
|
|
@@ -1168,59 +889,60 @@ function GridLayout(props) {
|
|
|
1168
889
|
oldResizeItem
|
|
1169
890
|
} = refState.current;
|
|
1170
891
|
let newLayout;
|
|
1171
|
-
let
|
|
892
|
+
let li;
|
|
1172
893
|
if (!oldResizeItem?.freeMove) {
|
|
1173
|
-
const
|
|
894
|
+
const cb = (cbLi) => {
|
|
1174
895
|
let hasCollisions;
|
|
1175
896
|
if (preventCollision && !allowOverlap) {
|
|
1176
897
|
const collisions = getAllCollisions(layout2, {
|
|
1177
|
-
...
|
|
898
|
+
...cbLi,
|
|
1178
899
|
w,
|
|
1179
900
|
h
|
|
1180
|
-
}, colapsedHeight).filter((layoutItem) => layoutItem.i !==
|
|
901
|
+
}, colapsedHeight, rowHeight).filter((layoutItem) => layoutItem.i !== cbLi.i);
|
|
1181
902
|
hasCollisions = collisions.length > 0;
|
|
1182
903
|
if (hasCollisions) {
|
|
1183
904
|
let leastX = Infinity, leastY = Infinity;
|
|
1184
905
|
collisions.forEach((layoutItem) => {
|
|
1185
|
-
if (layoutItem.x >
|
|
906
|
+
if (layoutItem.x > cbLi.x)
|
|
1186
907
|
leastX = Math.min(leastX, layoutItem.x);
|
|
1187
|
-
if (layoutItem.y >
|
|
908
|
+
if (layoutItem.y > cbLi.y)
|
|
1188
909
|
leastY = Math.min(leastY, layoutItem.y);
|
|
1189
910
|
});
|
|
1190
911
|
if (Number.isFinite(leastX))
|
|
1191
|
-
|
|
912
|
+
cbLi.w = leastX - cbLi.x;
|
|
1192
913
|
if (Number.isFinite(leastY))
|
|
1193
|
-
|
|
914
|
+
cbLi.h = leastY - cbLi.y;
|
|
1194
915
|
}
|
|
1195
916
|
}
|
|
1196
917
|
if (!hasCollisions) {
|
|
1197
|
-
|
|
1198
|
-
|
|
918
|
+
cbLi.w = w;
|
|
919
|
+
cbLi.h = h;
|
|
1199
920
|
}
|
|
1200
|
-
return
|
|
1201
|
-
}
|
|
921
|
+
return cbLi;
|
|
922
|
+
};
|
|
923
|
+
const [tempLayout, tempLi] = withLayoutItem(cloneLayout(layout2), i, cb);
|
|
1202
924
|
newLayout = tempLayout;
|
|
1203
|
-
|
|
925
|
+
li = tempLi;
|
|
1204
926
|
} else {
|
|
1205
927
|
newLayout = cloneLayout(layout2);
|
|
1206
|
-
|
|
1207
|
-
if (
|
|
1208
|
-
|
|
1209
|
-
|
|
928
|
+
li = getLayoutItem(newLayout, i);
|
|
929
|
+
if (li) {
|
|
930
|
+
li.w = w;
|
|
931
|
+
li.h = h;
|
|
1210
932
|
}
|
|
1211
933
|
}
|
|
1212
|
-
if (!
|
|
934
|
+
if (!li)
|
|
1213
935
|
return;
|
|
1214
936
|
const newPlaceholder = {
|
|
1215
|
-
w:
|
|
1216
|
-
h:
|
|
1217
|
-
x:
|
|
1218
|
-
y:
|
|
937
|
+
w: li.w,
|
|
938
|
+
h: li.h,
|
|
939
|
+
x: li.x,
|
|
940
|
+
y: li.y,
|
|
1219
941
|
static: true,
|
|
1220
942
|
i
|
|
1221
943
|
};
|
|
1222
944
|
try {
|
|
1223
|
-
const finalLayout = allowOverlap ||
|
|
945
|
+
const finalLayout = allowOverlap || li.freeMove ? newLayout : compact(newLayout, compactType, cols, colapsedHeight, rowHeight, allowOverlap);
|
|
1224
946
|
refState.current = {
|
|
1225
947
|
...refState.current,
|
|
1226
948
|
layout: finalLayout,
|
|
@@ -1231,7 +953,7 @@ function GridLayout(props) {
|
|
|
1231
953
|
...prev,
|
|
1232
954
|
activeDrag: newPlaceholder
|
|
1233
955
|
}));
|
|
1234
|
-
onResize(newLayout, oldResizeItem,
|
|
956
|
+
onResize(newLayout, oldResizeItem, li, newPlaceholder, e, node);
|
|
1235
957
|
} catch (error) {
|
|
1236
958
|
}
|
|
1237
959
|
}, []);
|
|
@@ -1239,26 +961,18 @@ function GridLayout(props) {
|
|
|
1239
961
|
e,
|
|
1240
962
|
node
|
|
1241
963
|
}) => {
|
|
964
|
+
if (!refState.current.activeDrag) {
|
|
965
|
+
console.log("GridLayout localOnResizeStop sin cambio");
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
1242
968
|
const {
|
|
1243
969
|
layout: layout2,
|
|
1244
970
|
oldResizeItem,
|
|
1245
971
|
oldLayout
|
|
1246
972
|
} = refState.current;
|
|
1247
973
|
const l = getLayoutItem(layout2, i);
|
|
1248
|
-
if (l) {
|
|
1249
|
-
onResizeStop(layout2, oldResizeItem, l, void 0, e, node);
|
|
1250
|
-
}
|
|
1251
|
-
const finalLayout = allowOverlap || l?.freeMove ? layout2 : compact(layout2, compactType, cols, colapsedHeight, allowOverlap);
|
|
1252
|
-
if (l && l?.freeMove) {
|
|
1253
|
-
const index = finalLayout.indexOf(l);
|
|
1254
|
-
if (index !== -1 && index !== finalLayout.length - 1) {
|
|
1255
|
-
finalLayout.splice(index, 1);
|
|
1256
|
-
finalLayout.push(l);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
974
|
refState.current = {
|
|
1260
975
|
...refState.current,
|
|
1261
|
-
layout: [...finalLayout],
|
|
1262
976
|
oldResizeItem: void 0,
|
|
1263
977
|
oldLayout: void 0,
|
|
1264
978
|
activeDrag: void 0
|
|
@@ -1267,24 +981,26 @@ function GridLayout(props) {
|
|
|
1267
981
|
...prev,
|
|
1268
982
|
activeDrag: void 0
|
|
1269
983
|
}));
|
|
1270
|
-
onLayoutMaybeChanged(
|
|
984
|
+
onLayoutMaybeChanged(layout2, oldLayout);
|
|
985
|
+
if (l) {
|
|
986
|
+
onResizeStop(layout2, oldResizeItem, l, void 0, e, node);
|
|
987
|
+
}
|
|
1271
988
|
}, []);
|
|
1272
|
-
const
|
|
989
|
+
const onClickSetOnTopFreeMove = useCallback((i, source) => {
|
|
1273
990
|
const {
|
|
1274
991
|
layout: layout2
|
|
1275
992
|
} = refState.current;
|
|
1276
|
-
const index =
|
|
993
|
+
const index = refState.current.zIndexes.indexOf(i);
|
|
1277
994
|
const l = getLayoutItem(layout2, i);
|
|
1278
|
-
console.log("
|
|
995
|
+
console.log("onClickSetOnTopFreeMove", index, refState.current.zIndexes.length, source);
|
|
1279
996
|
if (l && l?.freeMove) {
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
const newIndexes = [...refZindexes.current];
|
|
997
|
+
if (index !== refState.current.zIndexes.length - 1 || index === -1) {
|
|
998
|
+
const newIndexes = [...refState.current.zIndexes];
|
|
1283
999
|
if (index !== -1) {
|
|
1284
1000
|
newIndexes.splice(index, 1);
|
|
1285
1001
|
}
|
|
1286
1002
|
newIndexes.push(i);
|
|
1287
|
-
|
|
1003
|
+
refState.current.zIndexes = newIndexes;
|
|
1288
1004
|
setzIndexes(newIndexes);
|
|
1289
1005
|
}
|
|
1290
1006
|
}
|
|
@@ -1297,18 +1013,18 @@ function GridLayout(props) {
|
|
|
1297
1013
|
return null;
|
|
1298
1014
|
return /* @__PURE__ */ jsx(MemonizedGridItem, {
|
|
1299
1015
|
type: "placeholder",
|
|
1300
|
-
layoutItemRender
|
|
1016
|
+
layoutItemRender,
|
|
1301
1017
|
w: activeDrag.w,
|
|
1302
1018
|
h: activeDrag.h,
|
|
1303
1019
|
x: activeDrag.x,
|
|
1304
1020
|
y: activeDrag.y,
|
|
1305
1021
|
i: activeDrag.i,
|
|
1306
|
-
className:
|
|
1307
|
-
containerWidth
|
|
1308
|
-
containerHeight
|
|
1022
|
+
className: gridLayoutClasses.gridItemPlaceholder,
|
|
1023
|
+
containerWidth,
|
|
1024
|
+
containerHeight,
|
|
1309
1025
|
cols,
|
|
1310
|
-
margin
|
|
1311
|
-
containerPadding
|
|
1026
|
+
margin,
|
|
1027
|
+
containerPadding,
|
|
1312
1028
|
maxRows,
|
|
1313
1029
|
rowHeight,
|
|
1314
1030
|
isDraggable: false,
|
|
@@ -1316,8 +1032,8 @@ function GridLayout(props) {
|
|
|
1316
1032
|
isBounded: false,
|
|
1317
1033
|
useCSSTransforms,
|
|
1318
1034
|
transformScale,
|
|
1319
|
-
|
|
1320
|
-
|
|
1035
|
+
draggableCancel: "",
|
|
1036
|
+
draggableHandle: "",
|
|
1321
1037
|
minW: 0,
|
|
1322
1038
|
maxW: 0,
|
|
1323
1039
|
minH: 0,
|
|
@@ -1346,23 +1062,23 @@ function GridLayout(props) {
|
|
|
1346
1062
|
}
|
|
1347
1063
|
return /* @__PURE__ */ jsx(MemonizedGridItem, {
|
|
1348
1064
|
type: "layoutItem",
|
|
1349
|
-
layoutItemRender
|
|
1350
|
-
containerWidth
|
|
1351
|
-
containerHeight
|
|
1065
|
+
layoutItemRender,
|
|
1066
|
+
containerWidth,
|
|
1067
|
+
containerHeight,
|
|
1352
1068
|
cols,
|
|
1353
|
-
margin
|
|
1354
|
-
containerPadding: containerPadding ||
|
|
1069
|
+
margin,
|
|
1070
|
+
containerPadding: containerPadding || margin,
|
|
1355
1071
|
maxRows,
|
|
1356
1072
|
rowHeight,
|
|
1357
|
-
|
|
1358
|
-
|
|
1073
|
+
draggableCancel,
|
|
1074
|
+
draggableHandle,
|
|
1359
1075
|
onDragStart: localOnDragStart,
|
|
1360
1076
|
onDrag: localOnDrag,
|
|
1361
1077
|
onDragStop: localOnDragStop,
|
|
1362
1078
|
onResizeStart: localOnResizeStart,
|
|
1363
1079
|
onResize: localOnResize,
|
|
1364
1080
|
onResizeStop: localOnResizeStop,
|
|
1365
|
-
onFreeMoveClick:
|
|
1081
|
+
onFreeMoveClick: l.freeMove ? onClickSetOnTopFreeMove : void 0,
|
|
1366
1082
|
isDraggable: draggable,
|
|
1367
1083
|
isResizable: resizable,
|
|
1368
1084
|
isBounded: bounded,
|
|
@@ -1388,23 +1104,54 @@ function GridLayout(props) {
|
|
|
1388
1104
|
colapsedHeight,
|
|
1389
1105
|
style: style2
|
|
1390
1106
|
}, l.i);
|
|
1391
|
-
}, [
|
|
1107
|
+
}, [containerWidth, containerHeight, cols, margin, containerPadding, maxRows, rowHeight, draggableCancel, draggableHandle, isDraggable, isResizable, isBounded, useCSSTransforms, transformScale, resizeHandles, resizeHandle, maximizeId, zIndexes]);
|
|
1108
|
+
const containerAutoSizeHeight = useCallback(() => {
|
|
1109
|
+
if (!autoSize)
|
|
1110
|
+
return;
|
|
1111
|
+
const nbRow = bottom(finalLayoutRender, colapsedHeight, rowHeight);
|
|
1112
|
+
const containerPaddingY = containerPadding ? containerPadding[1] : margin[1];
|
|
1113
|
+
return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
|
|
1114
|
+
}, [autoSize, containerPadding, margin, finalLayoutRender, colapsedHeight]);
|
|
1392
1115
|
const mergedStyle = {
|
|
1393
|
-
height:
|
|
1116
|
+
height: containerAutoSizeHeight(),
|
|
1394
1117
|
...style
|
|
1395
1118
|
};
|
|
1396
1119
|
return /* @__PURE__ */ jsxs(GridLayoutRoot, {
|
|
1397
|
-
className: clsx(
|
|
1120
|
+
className: clsx(gridLayoutClasses.root, className),
|
|
1398
1121
|
style: mergedStyle,
|
|
1399
1122
|
ref: innerRef,
|
|
1400
1123
|
children: [finalLayoutRender.map((li) => processGridItem(li, !!currentState.mounted)), placeholder()]
|
|
1401
1124
|
});
|
|
1402
1125
|
}
|
|
1403
1126
|
export {
|
|
1127
|
+
noop as A,
|
|
1128
|
+
DEFAULT_COLS as D,
|
|
1404
1129
|
GridLayout as G,
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1130
|
+
THROTTLE_RESIZE_TIME as T,
|
|
1131
|
+
calcGridItemWHPx as a,
|
|
1132
|
+
calcGridColWidth as b,
|
|
1133
|
+
calcXY as c,
|
|
1134
|
+
calcWH as d,
|
|
1135
|
+
clamp as e,
|
|
1136
|
+
calcGridItemPosition as f,
|
|
1137
|
+
getH as g,
|
|
1138
|
+
gridLayoutClasses as h,
|
|
1139
|
+
DEFAULT_ROW_HEIGHT as i,
|
|
1140
|
+
DEFAULT_CONTAINER_WIDTH as j,
|
|
1141
|
+
DEFAULT_CONTAINER_HEIGHT as k,
|
|
1142
|
+
DEFAULT_MARGIN as l,
|
|
1143
|
+
DEFAULT_CONTAINER_PADDING as m,
|
|
1144
|
+
DEFAULT_TRANSFORM_SCALE as n,
|
|
1145
|
+
DEFAULT_COLAPSED_HEIGHT as o,
|
|
1146
|
+
perc as p,
|
|
1147
|
+
setTopLeft as q,
|
|
1148
|
+
cloneLayoutItem as r,
|
|
1149
|
+
setTransform as s,
|
|
1150
|
+
cloneLayout as t,
|
|
1151
|
+
compact as u,
|
|
1152
|
+
correctBounds as v,
|
|
1153
|
+
isEqualLayout as w,
|
|
1154
|
+
DEFAULT_RESPONSIVE_BREAKPOINTS as x,
|
|
1155
|
+
DEFAULT_RESPONSIVE_COLS as y,
|
|
1156
|
+
isEqualLayouts as z
|
|
1410
1157
|
};
|