@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,6 +1,7 @@
|
|
|
1
1
|
export { GridLayout } from './GridLayout';
|
|
2
2
|
export { Responsive } from './subcomponents/Responsive';
|
|
3
|
-
export { addLayoutItemToBreakPoints, addLayoutItemToBreakPointIfNoExists, cloneLayouts,
|
|
4
|
-
export
|
|
5
|
-
export type { Layouts,
|
|
3
|
+
export { addLayoutItemToBreakPoints, addLayoutItemToBreakPointIfNoExists, cloneLayouts, } from './subcomponents/Responsive/responsiveUtils';
|
|
4
|
+
export { isEqualLayouts, isEqualLayout } from './utils';
|
|
5
|
+
export type { GridLayoutProps, LayoutItemRenderProps, Layout, LayoutItem, BaseLayoutItem, Layouts, } from './types';
|
|
6
|
+
export type { ContainerChangeEvent } from './subcomponents/Responsive/types';
|
|
6
7
|
export { WidthProvider } from './subcomponents/WidthProvider';
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import React__default, { useRef, useEffect, useState, useCallback, useMemo } from "react";
|
|
2
|
+
import { D as DraggableCore_1 } from "../../../../react-draggable.7abb5d0a.js";
|
|
3
|
+
import { R as Resizable } from "../../../../react-resizable.ba08699a.js";
|
|
4
|
+
import { g as getH, c as calcXY, a as calcGridItemWHPx, b as calcGridColWidth, d as calcWH, e as clamp, f as calcGridItemPosition, h as gridLayoutClasses, D as DEFAULT_COLS, i as DEFAULT_ROW_HEIGHT, j as DEFAULT_CONTAINER_WIDTH, k as DEFAULT_CONTAINER_HEIGHT, l as DEFAULT_MARGIN, m as DEFAULT_CONTAINER_PADDING, n as DEFAULT_TRANSFORM_SCALE, o as DEFAULT_COLAPSED_HEIGHT, p as perc, s as setTransform, q as setTopLeft } from "../../index.76bccc4f.js";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { d as deepEqual } from "../../../../node_modules.d73a220d.js";
|
|
7
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
8
|
+
function GridItem(props) {
|
|
9
|
+
const {
|
|
10
|
+
layoutItemRender: ComponentItemRender,
|
|
11
|
+
type,
|
|
12
|
+
i,
|
|
13
|
+
x,
|
|
14
|
+
y,
|
|
15
|
+
w,
|
|
16
|
+
h,
|
|
17
|
+
cols = DEFAULT_COLS,
|
|
18
|
+
rowHeight = DEFAULT_ROW_HEIGHT,
|
|
19
|
+
containerWidth = DEFAULT_CONTAINER_WIDTH,
|
|
20
|
+
containerHeight = DEFAULT_CONTAINER_HEIGHT,
|
|
21
|
+
margin = DEFAULT_MARGIN,
|
|
22
|
+
containerPadding = DEFAULT_CONTAINER_PADDING,
|
|
23
|
+
transformScale = DEFAULT_TRANSFORM_SCALE,
|
|
24
|
+
colapsedHeight = DEFAULT_COLAPSED_HEIGHT,
|
|
25
|
+
isBounded,
|
|
26
|
+
maxRows = Infinity,
|
|
27
|
+
className = "",
|
|
28
|
+
draggableCancel = "",
|
|
29
|
+
draggableHandle = "",
|
|
30
|
+
minH = 1,
|
|
31
|
+
minW = 1,
|
|
32
|
+
maxH = Infinity,
|
|
33
|
+
maxW = Infinity,
|
|
34
|
+
isResizable = true,
|
|
35
|
+
isDraggable = true,
|
|
36
|
+
resizeHandles,
|
|
37
|
+
resizeHandle,
|
|
38
|
+
useCSSTransforms = true,
|
|
39
|
+
usePercentages,
|
|
40
|
+
style,
|
|
41
|
+
freeMove,
|
|
42
|
+
maximize = "none",
|
|
43
|
+
colapsed,
|
|
44
|
+
visible = true,
|
|
45
|
+
onDragStart,
|
|
46
|
+
onDrag,
|
|
47
|
+
onDragStop,
|
|
48
|
+
onFreeMoveClick
|
|
49
|
+
} = props;
|
|
50
|
+
const refProps = useRef({
|
|
51
|
+
cols,
|
|
52
|
+
x,
|
|
53
|
+
y,
|
|
54
|
+
w,
|
|
55
|
+
h: getH(h, colapsedHeight, rowHeight, colapsed),
|
|
56
|
+
minW,
|
|
57
|
+
maxW,
|
|
58
|
+
minH,
|
|
59
|
+
maxH,
|
|
60
|
+
containerWidth,
|
|
61
|
+
containerHeight,
|
|
62
|
+
margin,
|
|
63
|
+
containerPadding,
|
|
64
|
+
rowHeight,
|
|
65
|
+
maxRows,
|
|
66
|
+
colapsed
|
|
67
|
+
});
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
refProps.current = {
|
|
70
|
+
cols,
|
|
71
|
+
x,
|
|
72
|
+
y,
|
|
73
|
+
w,
|
|
74
|
+
h: getH(h, colapsedHeight, rowHeight, colapsed),
|
|
75
|
+
minW,
|
|
76
|
+
maxW,
|
|
77
|
+
minH,
|
|
78
|
+
maxH,
|
|
79
|
+
containerWidth,
|
|
80
|
+
containerHeight,
|
|
81
|
+
margin,
|
|
82
|
+
containerPadding,
|
|
83
|
+
rowHeight,
|
|
84
|
+
maxRows,
|
|
85
|
+
colapsed
|
|
86
|
+
};
|
|
87
|
+
}, [cols, x, y, w, h, minW, maxW, minH, maxH, containerWidth, containerHeight, margin, containerPadding, rowHeight, maxRows, colapsed, colapsedHeight]);
|
|
88
|
+
const [currentState, setCurrentState] = useState({
|
|
89
|
+
resizing: void 0,
|
|
90
|
+
dragging: void 0
|
|
91
|
+
});
|
|
92
|
+
const refState = useRef({
|
|
93
|
+
resizing: void 0,
|
|
94
|
+
dragging: void 0
|
|
95
|
+
});
|
|
96
|
+
const elementRef = useRef(null);
|
|
97
|
+
const getPositionParams = useCallback((preferContainerWidth, preferContainerHeight) => {
|
|
98
|
+
return {
|
|
99
|
+
cols: refProps.current.cols,
|
|
100
|
+
containerPadding: refProps.current.containerPadding,
|
|
101
|
+
containerWidth: preferContainerWidth || refProps.current.containerWidth,
|
|
102
|
+
containerHeight: preferContainerHeight || refProps.current.containerHeight,
|
|
103
|
+
containerMargin: refProps.current.margin,
|
|
104
|
+
maxRows: refProps.current.maxRows,
|
|
105
|
+
rowHeight: refProps.current.rowHeight
|
|
106
|
+
};
|
|
107
|
+
}, []);
|
|
108
|
+
const createStyle = (pos2) => {
|
|
109
|
+
let newStyle;
|
|
110
|
+
if (useCSSTransforms) {
|
|
111
|
+
newStyle = setTransform(pos2);
|
|
112
|
+
} else {
|
|
113
|
+
newStyle = setTopLeft(pos2);
|
|
114
|
+
if (usePercentages) {
|
|
115
|
+
newStyle.left = perc(pos2.left / containerWidth);
|
|
116
|
+
newStyle.width = perc(pos2.width / containerWidth);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return newStyle;
|
|
120
|
+
};
|
|
121
|
+
const gridItemOnDragStart = useCallback((e, {
|
|
122
|
+
node
|
|
123
|
+
}) => {
|
|
124
|
+
if (!onDragStart)
|
|
125
|
+
return;
|
|
126
|
+
const newPosition = {
|
|
127
|
+
top: 0,
|
|
128
|
+
left: 0
|
|
129
|
+
};
|
|
130
|
+
const {
|
|
131
|
+
offsetParent
|
|
132
|
+
} = node;
|
|
133
|
+
if (!offsetParent)
|
|
134
|
+
return;
|
|
135
|
+
const parentRect = offsetParent.getBoundingClientRect();
|
|
136
|
+
const clientRect = node.getBoundingClientRect();
|
|
137
|
+
const cLeft = clientRect.left / transformScale;
|
|
138
|
+
const pLeft = parentRect.left / transformScale;
|
|
139
|
+
const cTop = clientRect.top / transformScale;
|
|
140
|
+
const pTop = parentRect.top / transformScale;
|
|
141
|
+
newPosition.left = cLeft - pLeft + offsetParent.scrollLeft;
|
|
142
|
+
newPosition.top = cTop - pTop + offsetParent.scrollTop;
|
|
143
|
+
console.log(`gridItemOnDragStart cleft:${cLeft},pleft:${pLeft}, offsetParent.scrollTop:${offsetParent.scrollTop} `, newPosition);
|
|
144
|
+
refState.current.dragging = newPosition;
|
|
145
|
+
setCurrentState((prev) => ({
|
|
146
|
+
...prev,
|
|
147
|
+
dragging: newPosition
|
|
148
|
+
}));
|
|
149
|
+
const {
|
|
150
|
+
x: newX,
|
|
151
|
+
y: newY
|
|
152
|
+
} = calcXY(getPositionParams(), newPosition.top, newPosition.left, refProps.current.w, refProps.current.h);
|
|
153
|
+
onDragStart(i, newX, newY, {
|
|
154
|
+
e,
|
|
155
|
+
node,
|
|
156
|
+
newPosition
|
|
157
|
+
});
|
|
158
|
+
}, []);
|
|
159
|
+
const gridItemOnDrag = useCallback((e, {
|
|
160
|
+
node,
|
|
161
|
+
deltaX,
|
|
162
|
+
deltaY
|
|
163
|
+
}) => {
|
|
164
|
+
if (!onDrag)
|
|
165
|
+
return;
|
|
166
|
+
if (!refState.current.dragging) {
|
|
167
|
+
console.warn("gridItemOnDrag onDrag called before onDragStart");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
let top = refState.current.dragging.top + deltaY;
|
|
171
|
+
let left = refState.current.dragging.left + deltaX;
|
|
172
|
+
const positionParams = getPositionParams();
|
|
173
|
+
if (isBounded) {
|
|
174
|
+
const {
|
|
175
|
+
offsetParent
|
|
176
|
+
} = node;
|
|
177
|
+
if (offsetParent) {
|
|
178
|
+
const bottomBoundary = offsetParent.clientHeight - calcGridItemWHPx(refProps.current.h, refProps.current.rowHeight, refProps.current.margin[1]);
|
|
179
|
+
top = clamp(top, 0, bottomBoundary);
|
|
180
|
+
const colWidth = calcGridColWidth(positionParams);
|
|
181
|
+
const rightBoundary = containerWidth - calcGridItemWHPx(refProps.current.w, colWidth, refProps.current.margin[0]);
|
|
182
|
+
left = clamp(left, 0, rightBoundary);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const newPosition = {
|
|
186
|
+
top,
|
|
187
|
+
left
|
|
188
|
+
};
|
|
189
|
+
refState.current.dragging = newPosition;
|
|
190
|
+
setCurrentState((prev) => ({
|
|
191
|
+
...prev,
|
|
192
|
+
dragging: newPosition
|
|
193
|
+
}));
|
|
194
|
+
const {
|
|
195
|
+
x: newX,
|
|
196
|
+
y: newY
|
|
197
|
+
} = calcXY(positionParams, top, left, refProps.current.w, refProps.current.h);
|
|
198
|
+
onDrag(i, newX, newY, {
|
|
199
|
+
e,
|
|
200
|
+
node,
|
|
201
|
+
newPosition
|
|
202
|
+
});
|
|
203
|
+
}, []);
|
|
204
|
+
const gridItemOnDragStop = useCallback((e, {
|
|
205
|
+
node
|
|
206
|
+
}) => {
|
|
207
|
+
if (!onDragStop)
|
|
208
|
+
return;
|
|
209
|
+
if (!refState.current.dragging) {
|
|
210
|
+
console.warn("onDragEnd called before onDragStart");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const {
|
|
214
|
+
left,
|
|
215
|
+
top
|
|
216
|
+
} = refState.current.dragging;
|
|
217
|
+
const newPosition = {
|
|
218
|
+
top,
|
|
219
|
+
left
|
|
220
|
+
};
|
|
221
|
+
refState.current.dragging = void 0;
|
|
222
|
+
setCurrentState((prev) => ({
|
|
223
|
+
...prev,
|
|
224
|
+
dragging: void 0
|
|
225
|
+
}));
|
|
226
|
+
const {
|
|
227
|
+
x: newX,
|
|
228
|
+
y: newY
|
|
229
|
+
} = calcXY(getPositionParams(), top, left, refProps.current.w, refProps.current.h);
|
|
230
|
+
return onDragStop(i, newX, newY, {
|
|
231
|
+
e,
|
|
232
|
+
node,
|
|
233
|
+
newPosition
|
|
234
|
+
});
|
|
235
|
+
}, []);
|
|
236
|
+
const onResizeHandler = useCallback((e, {
|
|
237
|
+
node,
|
|
238
|
+
size
|
|
239
|
+
}, handlerName) => {
|
|
240
|
+
const handler = props[handlerName];
|
|
241
|
+
if (!handler) {
|
|
242
|
+
console.warn("onResizeHandler invalid");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (refProps.current.colapsed) {
|
|
246
|
+
console.warn("onResizeHandler colapsed invalid");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
let {
|
|
250
|
+
w: newW,
|
|
251
|
+
h: newH
|
|
252
|
+
} = calcWH(getPositionParams(), size.width, size.height, refProps.current.x, refProps.current.y);
|
|
253
|
+
const newMinW = Math.max(refProps.current.minW, 1);
|
|
254
|
+
const newMaxW = Math.min(refProps.current.maxW, refProps.current.cols - refProps.current.x);
|
|
255
|
+
newW = clamp(newW, newMinW, newMaxW);
|
|
256
|
+
newH = clamp(newH, refProps.current.minH, refProps.current.maxH);
|
|
257
|
+
const resizing = handlerName === "onResizeStop" ? void 0 : size;
|
|
258
|
+
setCurrentState((prev) => ({
|
|
259
|
+
...prev,
|
|
260
|
+
resizing
|
|
261
|
+
}));
|
|
262
|
+
refState.current.resizing = resizing;
|
|
263
|
+
handler(i, newW, newH, {
|
|
264
|
+
e,
|
|
265
|
+
node,
|
|
266
|
+
size
|
|
267
|
+
});
|
|
268
|
+
}, []);
|
|
269
|
+
const localOnResizeStop = useCallback((e, callbackData) => {
|
|
270
|
+
onResizeHandler(e, callbackData, "onResizeStop");
|
|
271
|
+
}, []);
|
|
272
|
+
const localOnResizeStart = useCallback((e, callbackData) => {
|
|
273
|
+
onResizeHandler(e, callbackData, "onResizeStart");
|
|
274
|
+
}, []);
|
|
275
|
+
const localFreeMoveOnClick = useCallback(() => {
|
|
276
|
+
if (!onFreeMoveClick)
|
|
277
|
+
return;
|
|
278
|
+
onFreeMoveClick(i);
|
|
279
|
+
}, []);
|
|
280
|
+
const mixinResizable = useCallback((child, position, positionParams) => {
|
|
281
|
+
const maxWidth = calcGridItemPosition(positionParams, 0, 0, cols - x, 0, maximize).width;
|
|
282
|
+
const mins = calcGridItemPosition(positionParams, 0, 0, minW, minH, maximize);
|
|
283
|
+
const maxes = calcGridItemPosition(positionParams, 0, 0, maxW, maxH, maximize);
|
|
284
|
+
const minConstraints = [mins.width, mins.height];
|
|
285
|
+
const maxConstraints = [Math.min(maxes.width, maxWidth), Math.min(maxes.height, Infinity)];
|
|
286
|
+
return /* @__PURE__ */ jsx(
|
|
287
|
+
Resizable,
|
|
288
|
+
{
|
|
289
|
+
draggableOpts: {
|
|
290
|
+
disabled: !isResizable || maximize !== "none" || colapsed
|
|
291
|
+
},
|
|
292
|
+
className: isResizable ? void 0 : "react-resizable-hide",
|
|
293
|
+
width: position.width,
|
|
294
|
+
height: position.height,
|
|
295
|
+
minConstraints,
|
|
296
|
+
maxConstraints,
|
|
297
|
+
onResizeStop: localOnResizeStop,
|
|
298
|
+
onResizeStart: localOnResizeStart,
|
|
299
|
+
onResize: localOnResize,
|
|
300
|
+
transformScale,
|
|
301
|
+
resizeHandles,
|
|
302
|
+
handle: resizeHandle,
|
|
303
|
+
children: child
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}, [cols, x, minW, minH, maxW, maxH, isResizable, transformScale, resizeHandles, resizeHandle, maximize, colapsed]);
|
|
307
|
+
const mixinDraggable = useCallback((child) => {
|
|
308
|
+
return /* @__PURE__ */ jsx(
|
|
309
|
+
DraggableCore_1,
|
|
310
|
+
{
|
|
311
|
+
disabled: !isDraggable || maximize !== "none",
|
|
312
|
+
onStart: gridItemOnDragStart,
|
|
313
|
+
onDrag: gridItemOnDrag,
|
|
314
|
+
onStop: gridItemOnDragStop,
|
|
315
|
+
handle: draggableHandle,
|
|
316
|
+
cancel: ".react-resizable-handle" + (draggableCancel ? "," + draggableCancel : ""),
|
|
317
|
+
scale: transformScale,
|
|
318
|
+
nodeRef: elementRef,
|
|
319
|
+
children: child
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
}, [isDraggable, draggableHandle, transformScale, draggableCancel, maximize]);
|
|
323
|
+
const localOnResize = useCallback((e, callbackData) => {
|
|
324
|
+
onResizeHandler(e, callbackData, "onResize");
|
|
325
|
+
}, []);
|
|
326
|
+
const positionParms = getPositionParams(containerWidth, containerHeight);
|
|
327
|
+
const pos = calcGridItemPosition(positionParms, x, y, w, getH(h, colapsedHeight, rowHeight, colapsed), maximize, currentState);
|
|
328
|
+
const classNameFinal = clsx(gridLayoutClasses.gridItemRoot, className, {
|
|
329
|
+
[`${gridLayoutClasses.gridItemType}-${type}`]: true,
|
|
330
|
+
[gridLayoutClasses.static]: props.static,
|
|
331
|
+
[gridLayoutClasses.resizing]: Boolean(currentState.resizing),
|
|
332
|
+
[gridLayoutClasses.dragging]: Boolean(currentState.dragging),
|
|
333
|
+
[gridLayoutClasses.maximizeMe]: maximize === "maximize_me",
|
|
334
|
+
[gridLayoutClasses.maximizeOther]: maximize === "maximize_other",
|
|
335
|
+
[gridLayoutClasses.colapsed]: colapsed,
|
|
336
|
+
[gridLayoutClasses.gridItemFreeMove]: freeMove,
|
|
337
|
+
[gridLayoutClasses.resizeHide]: colapsed,
|
|
338
|
+
[gridLayoutClasses.invisible]: !visible,
|
|
339
|
+
[gridLayoutClasses.cssTransforms]: useCSSTransforms,
|
|
340
|
+
"react-draggable": isDraggable
|
|
341
|
+
});
|
|
342
|
+
const styleFinal = {
|
|
343
|
+
...style,
|
|
344
|
+
...createStyle(pos)
|
|
345
|
+
};
|
|
346
|
+
const memoLayouItemRender = useMemo(() => {
|
|
347
|
+
return /* @__PURE__ */ jsx(ComponentItemRender, {
|
|
348
|
+
type,
|
|
349
|
+
i
|
|
350
|
+
});
|
|
351
|
+
}, [type, i]);
|
|
352
|
+
const gridItemRoot = /* @__PURE__ */ jsx("div", {
|
|
353
|
+
className: classNameFinal,
|
|
354
|
+
ref: elementRef,
|
|
355
|
+
style: styleFinal,
|
|
356
|
+
role: "none",
|
|
357
|
+
onClick: localFreeMoveOnClick,
|
|
358
|
+
children: memoLayouItemRender
|
|
359
|
+
});
|
|
360
|
+
const gridItem = mixinDraggable(mixinResizable(gridItemRoot, pos, getPositionParams()));
|
|
361
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
362
|
+
children: gridItem
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const MemonizedGridItem = React__default.memo(GridItem, (prevProps, nextProps) => {
|
|
366
|
+
return deepEqual(prevProps, nextProps);
|
|
367
|
+
});
|
|
368
|
+
export {
|
|
369
|
+
MemonizedGridItem as M
|
|
370
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GridItemProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* An individual item within a ReactGridLayout.
|
|
5
|
+
* En el GridItem es realmente donde se generan los tamaños y posiciones denependiendo si se está
|
|
6
|
+
* en Dragging o en Resizing
|
|
7
|
+
*/
|
|
8
|
+
export declare function GridItem(props: GridItemProps): React.JSX.Element;
|
|
9
|
+
export declare const MemonizedGridItem: React.MemoExoticComponent<typeof GridItem>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { GridDragEvent, GridLayoutProps, GridResizeEvent, LayoutItem, LayoutItemRender, LayoutItemType } from '../../types';
|
|
2
|
+
export declare type GridItemState = {
|
|
3
|
+
/**
|
|
4
|
+
* "resizing" indica el tamaño actual cuando se está redimensionando el gridItem
|
|
5
|
+
*/
|
|
6
|
+
resizing?: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* "dragging" indica la posición actual cuando se está moviendo el gridItem
|
|
12
|
+
*/
|
|
13
|
+
dragging?: {
|
|
14
|
+
top: number;
|
|
15
|
+
left: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type PartialPosition = {
|
|
19
|
+
top: number;
|
|
20
|
+
left: number;
|
|
21
|
+
};
|
|
22
|
+
export interface DraggableData {
|
|
23
|
+
node: HTMLElement;
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
deltaX: number;
|
|
27
|
+
deltaY: number;
|
|
28
|
+
lastX: number;
|
|
29
|
+
lastY: number;
|
|
30
|
+
}
|
|
31
|
+
export declare type GridItemResizeCallback = (i: string, w: number, h: number, data: GridResizeEvent) => void;
|
|
32
|
+
export declare type GridItemDragCallback = (i: string, x: number, y: number, gridDragEvent: GridDragEvent) => void;
|
|
33
|
+
export declare type Maximize = 'maximize_me' | 'maximize_other' | 'none';
|
|
34
|
+
export interface GridItemProps extends Omit<LayoutItem, 'moved'>, Pick<GridLayoutProps, 'cols' | 'resizeHandle' | 'draggableCancel' | 'draggableHandle' | 'containerWidth' | 'containerHeight' | 'transformScale' | 'colapsedHeight' | 'rowHeight' | 'useCSSTransforms' | 'margin' | 'containerPadding' | 'maxRows' | 'style'> {
|
|
35
|
+
/**
|
|
36
|
+
* "type": Indica si es placeHolder o Layout
|
|
37
|
+
*/
|
|
38
|
+
type: LayoutItemType;
|
|
39
|
+
layoutItemRender: LayoutItemRender;
|
|
40
|
+
/**
|
|
41
|
+
* "className" permite identificar si es placeHolder y estilar
|
|
42
|
+
*/
|
|
43
|
+
className?: string;
|
|
44
|
+
/**
|
|
45
|
+
* zIndex: Permite modificar en los gridItems freeMove (popups) el zIndex
|
|
46
|
+
*/
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
/**
|
|
49
|
+
* "usePercentages" indica si usan porcentajes en vez de pixels, se usa antes de montar el componente
|
|
50
|
+
*/
|
|
51
|
+
usePercentages?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* "maximize" indica si el gridItem está maximizado, o si otro está maxmizado o si ninguno
|
|
54
|
+
*/
|
|
55
|
+
maximize: Maximize;
|
|
56
|
+
/**
|
|
57
|
+
* "onDrag" función que maneja el onDrag del gridItem
|
|
58
|
+
*/
|
|
59
|
+
onDrag?: GridItemDragCallback;
|
|
60
|
+
/**
|
|
61
|
+
* "onDragStart" función que maneja el onDragStart del gridItem
|
|
62
|
+
*/
|
|
63
|
+
onDragStart?: GridItemDragCallback;
|
|
64
|
+
/**
|
|
65
|
+
* "onDragStop" función que maneja el onDragStop del gridItem
|
|
66
|
+
*/
|
|
67
|
+
onDragStop?: GridItemDragCallback;
|
|
68
|
+
/**
|
|
69
|
+
* "onResize" función que maneja el onResize del gridItem
|
|
70
|
+
*/
|
|
71
|
+
onResize?: GridItemResizeCallback;
|
|
72
|
+
/**
|
|
73
|
+
* "onResizeStart" función que maneja el onResizeStart del gridItem
|
|
74
|
+
*/
|
|
75
|
+
onResizeStart?: GridItemResizeCallback;
|
|
76
|
+
/**
|
|
77
|
+
* "onResizeStop" función que maneja el onResizeStop del gridItem
|
|
78
|
+
*/
|
|
79
|
+
onResizeStop?: GridItemResizeCallback;
|
|
80
|
+
/**
|
|
81
|
+
* "onFreeMoveClick" función que va a tender los onclicks del gridItem
|
|
82
|
+
*/
|
|
83
|
+
onFreeMoveClick?: (i: string) => void;
|
|
84
|
+
}
|
|
85
|
+
export declare type RefProps = {
|
|
86
|
+
cols: number;
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
w: number;
|
|
90
|
+
h: number;
|
|
91
|
+
minW: number;
|
|
92
|
+
maxW: number;
|
|
93
|
+
minH: number;
|
|
94
|
+
maxH: number;
|
|
95
|
+
containerWidth: number;
|
|
96
|
+
containerHeight: number;
|
|
97
|
+
margin: [number, number];
|
|
98
|
+
containerPadding: [number, number];
|
|
99
|
+
rowHeight: number;
|
|
100
|
+
maxRows: number;
|
|
101
|
+
colapsed?: boolean;
|
|
102
|
+
visible?: boolean;
|
|
103
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ResponsiveState, ResponsiveInitialStateProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Funcion de apoyo que devuelve el esatado inicial del componente Responsive
|
|
4
|
+
* En caso de que sea diferente a la prop "layout" del breakpoint establecido inicialmeente no
|
|
5
|
+
* sea igual al que se regenera findOrGenerateResponsiveLayout se marca con la variable "fireOnLoadLayoutChange" que debe emitir
|
|
6
|
+
* cambio de layout en la primera renderización
|
|
7
|
+
* @param props
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateInitialState(props: ResponsiveInitialStateProps): ResponsiveState;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ResponsiveProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Componente encargado de proporcionar el layout basado
|
|
5
|
+
* en el breakpoint que se recibe o en el que se calcula dependiendo del containerWidth.
|
|
6
|
+
* Eventos:
|
|
7
|
+
* - onContainerChange: Este evento que indica las medidas del contendor, columnas actuales y breakpoint actual.
|
|
8
|
+
* Se genera cuando se renderiza la primera vez el componente
|
|
9
|
+
* Consideraciones de optimización
|
|
10
|
+
* - El compontente almacena en una posicion de memoria diferente los layouts que le llegan por los props.
|
|
11
|
+
* Cuando props.layouts cambia, el componente se-rerenderiza si hay un cambio (Se agrego/borro/movió un layoutItem)
|
|
12
|
+
* Es aconsejable no reintroducir el layouts cuando
|
|
13
|
+
* @param props
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function Responsive(props: ResponsiveProps): import("react").JSX.Element;
|