@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,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as cloneLayoutItem, t as cloneLayout, u as compact, v as correctBounds, w as isEqualLayout, x as DEFAULT_RESPONSIVE_BREAKPOINTS, m as DEFAULT_CONTAINER_PADDING, l as DEFAULT_MARGIN, y as DEFAULT_RESPONSIVE_COLS, o as DEFAULT_COLAPSED_HEIGHT, i as DEFAULT_ROW_HEIGHT, z as isEqualLayouts, G as GridLayout, A as noop } from "../../index.76bccc4f.js";
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from "react";
|
|
3
3
|
import { useFirstRender } from "@m4l/graphics";
|
|
4
|
-
import { d as deepEqual } from "
|
|
4
|
+
import { d as deepEqual } from "../../../../node_modules.d73a220d.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
function getBreakpointFromWidth(breakpoints, width) {
|
|
7
7
|
const sorted = sortBreakpoints(breakpoints);
|
|
@@ -21,7 +21,7 @@ function getColsFromBreakpoint(breakpoint, cols) {
|
|
|
21
21
|
}
|
|
22
22
|
return cols[breakpoint];
|
|
23
23
|
}
|
|
24
|
-
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactType, brekpointsCols, colapsedHeight) {
|
|
24
|
+
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactType, brekpointsCols, colapsedHeight, rowHeight) {
|
|
25
25
|
let layout = layouts[breakpoint];
|
|
26
26
|
const breakpointsSorted = sortBreakpoints(breakpoints);
|
|
27
27
|
const indexBreakointInit = breakpointsSorted.indexOf(breakpoint);
|
|
@@ -61,10 +61,11 @@ function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBr
|
|
|
61
61
|
}
|
|
62
62
|
layout = cloneLayout(layout);
|
|
63
63
|
const ret = compact(
|
|
64
|
-
correctBounds(layout, { cols }, colapsedHeight),
|
|
64
|
+
correctBounds(layout, { cols }, colapsedHeight, rowHeight),
|
|
65
65
|
compactType,
|
|
66
66
|
cols,
|
|
67
|
-
colapsedHeight
|
|
67
|
+
colapsedHeight,
|
|
68
|
+
rowHeight
|
|
68
69
|
);
|
|
69
70
|
return ret;
|
|
70
71
|
}
|
|
@@ -138,67 +139,42 @@ function cloneLayouts(layouts, layoutItemReplaceProps) {
|
|
|
138
139
|
}
|
|
139
140
|
return newLayouts;
|
|
140
141
|
}
|
|
141
|
-
function isEqualLayoutItem(layoutA, layoutB) {
|
|
142
|
-
if (layoutA.i !== layoutB.i) {
|
|
143
|
-
return false;
|
|
144
|
-
} 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) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
function isEqualLayout(layoutA, layoutB) {
|
|
150
|
-
if (layoutA.length !== layoutB.length) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
for (let index = 0; index < layoutA.length; index++) {
|
|
154
|
-
if (!isEqualLayoutItem(layoutA[index], layoutB[index])) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
function isEqualLayouts(layoutsA, layoutsB) {
|
|
161
|
-
if (Object.keys(layoutsA).length !== Object.keys(layoutsB).length) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
for (const breakPoint in layoutsA) {
|
|
165
|
-
if (layoutsB[breakPoint]) {
|
|
166
|
-
if (!isEqualLayout(layoutsA[breakPoint], layoutsB[breakPoint])) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
} else {
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
142
|
function generateInitialState(props) {
|
|
176
143
|
const {
|
|
177
|
-
|
|
144
|
+
containerWidth,
|
|
178
145
|
breakpoint,
|
|
179
|
-
breakpoints,
|
|
180
|
-
containerPadding =
|
|
181
|
-
containerMargin =
|
|
146
|
+
breakpoints = DEFAULT_RESPONSIVE_BREAKPOINTS,
|
|
147
|
+
containerPadding = DEFAULT_CONTAINER_PADDING,
|
|
148
|
+
containerMargin = DEFAULT_MARGIN,
|
|
182
149
|
layouts: defaultLayouts = {},
|
|
183
|
-
cols,
|
|
150
|
+
cols = DEFAULT_RESPONSIVE_COLS,
|
|
184
151
|
compactType = null,
|
|
185
|
-
colapsedHeight =
|
|
152
|
+
colapsedHeight = DEFAULT_COLAPSED_HEIGHT,
|
|
153
|
+
rowHeight = DEFAULT_ROW_HEIGHT
|
|
186
154
|
} = props;
|
|
187
|
-
const newBreakpoint = breakpoint || getBreakpointFromWidth(breakpoints,
|
|
188
|
-
const
|
|
155
|
+
const newBreakpoint = breakpoint || getBreakpointFromWidth(breakpoints, containerWidth);
|
|
156
|
+
const newCols = getColsFromBreakpoint(newBreakpoint, cols);
|
|
189
157
|
let fireOnLoadLayoutChange = true;
|
|
190
|
-
const initialLayout = findOrGenerateResponsiveLayout(
|
|
191
|
-
|
|
192
|
-
|
|
158
|
+
const initialLayout = findOrGenerateResponsiveLayout(
|
|
159
|
+
defaultLayouts,
|
|
160
|
+
breakpoints,
|
|
161
|
+
newBreakpoint,
|
|
162
|
+
newBreakpoint,
|
|
163
|
+
newCols,
|
|
164
|
+
compactType,
|
|
165
|
+
{ [newBreakpoint]: newCols },
|
|
166
|
+
colapsedHeight,
|
|
167
|
+
rowHeight
|
|
168
|
+
);
|
|
193
169
|
if (defaultLayouts[newBreakpoint]) {
|
|
194
|
-
if (
|
|
170
|
+
if (isEqualLayout(defaultLayouts[newBreakpoint], initialLayout)) {
|
|
195
171
|
fireOnLoadLayoutChange = false;
|
|
196
172
|
}
|
|
197
173
|
}
|
|
198
174
|
const ret = {
|
|
199
|
-
|
|
175
|
+
breakpointLayout: initialLayout,
|
|
200
176
|
breakpoint: newBreakpoint,
|
|
201
|
-
cols:
|
|
177
|
+
cols: newCols,
|
|
202
178
|
contaierMargin: getIndentationValue(containerMargin, newBreakpoint),
|
|
203
179
|
contaierPadding: getIndentationValue(containerPadding, newBreakpoint),
|
|
204
180
|
fireOnLoadLayoutChange
|
|
@@ -207,137 +183,119 @@ function generateInitialState(props) {
|
|
|
207
183
|
}
|
|
208
184
|
function Responsive(props) {
|
|
209
185
|
const {
|
|
210
|
-
|
|
211
|
-
|
|
186
|
+
layoutItemRender,
|
|
187
|
+
containerWidth,
|
|
188
|
+
containerHeight,
|
|
212
189
|
breakpoint,
|
|
213
190
|
compactType = null,
|
|
214
|
-
breakpoints =
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
xs: 480,
|
|
219
|
-
xxs: 1
|
|
220
|
-
},
|
|
221
|
-
cols = {
|
|
222
|
-
lg: 12,
|
|
223
|
-
md: 10,
|
|
224
|
-
sm: 6,
|
|
225
|
-
xs: 4,
|
|
226
|
-
xxs: 2
|
|
227
|
-
},
|
|
228
|
-
containerPadding = [10, 10],
|
|
229
|
-
containerMargin = [10, 10],
|
|
191
|
+
breakpoints = DEFAULT_RESPONSIVE_BREAKPOINTS,
|
|
192
|
+
cols = DEFAULT_RESPONSIVE_COLS,
|
|
193
|
+
containerPadding = DEFAULT_CONTAINER_PADDING,
|
|
194
|
+
containerMargin = DEFAULT_MARGIN,
|
|
230
195
|
layouts = {},
|
|
231
|
-
onBreakpointChange = noop,
|
|
232
196
|
onLayoutChange = noop,
|
|
233
197
|
onContainerChange = noop,
|
|
234
|
-
|
|
235
|
-
|
|
198
|
+
colapsedHeight = DEFAULT_COLAPSED_HEIGHT,
|
|
199
|
+
rowHeight = DEFAULT_ROW_HEIGHT,
|
|
236
200
|
...other
|
|
237
201
|
} = props;
|
|
238
202
|
const [currentState, setCurrentState] = useState(() => generateInitialState(props));
|
|
239
|
-
const
|
|
203
|
+
const refState = useRef({
|
|
240
204
|
layouts: {
|
|
241
205
|
...layouts,
|
|
242
|
-
[currentState.breakpoint]: currentState.
|
|
206
|
+
[currentState.breakpoint]: currentState.breakpointLayout
|
|
243
207
|
},
|
|
244
|
-
|
|
208
|
+
cols,
|
|
209
|
+
currentBreakpointCols: currentState.cols,
|
|
210
|
+
currentBreakpoint: currentState.breakpoint,
|
|
245
211
|
breakpoints,
|
|
246
|
-
|
|
247
|
-
|
|
212
|
+
containerWidth,
|
|
213
|
+
containerHeight
|
|
248
214
|
});
|
|
249
|
-
const
|
|
215
|
+
const isFirstRenderFull = useFirstRender([containerWidth, containerHeight, layouts, breakpoint, breakpoints, cols]);
|
|
216
|
+
const isFirstRenderBreakpointLayout = useFirstRender([currentState.breakpointLayout]);
|
|
250
217
|
useEffect(() => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
containerHeight: refLayouts.current.height,
|
|
254
|
-
containerMargin: currentState.contaierMargin,
|
|
255
|
-
containerPadding: currentState.contaierPadding,
|
|
256
|
-
breakpoint: currentState.breakpoint,
|
|
257
|
-
cols: currentState.cols
|
|
258
|
-
});
|
|
259
|
-
if (currentState.fireOnLoadLayoutChange) {
|
|
260
|
-
onLayoutChange(currentState.layout, {
|
|
261
|
-
...layouts,
|
|
262
|
-
[currentState.breakpoint]: currentState.layout
|
|
263
|
-
});
|
|
218
|
+
if (!isFirstRenderBreakpointLayout) {
|
|
219
|
+
onLayoutChange(currentState.breakpointLayout, refState.current.layouts);
|
|
264
220
|
}
|
|
265
|
-
|
|
266
|
-
console.debug("destruccion del componente");
|
|
267
|
-
};
|
|
268
|
-
}, []);
|
|
221
|
+
}, [currentState.breakpointLayout]);
|
|
269
222
|
useEffect(() => {
|
|
270
|
-
if (
|
|
223
|
+
if (isFirstRenderFull) {
|
|
224
|
+
onContainerChange({
|
|
225
|
+
containerWidth: refState.current.containerWidth,
|
|
226
|
+
containerHeight: refState.current.containerHeight,
|
|
227
|
+
breakpoint: currentState.breakpoint,
|
|
228
|
+
cols: currentState.cols
|
|
229
|
+
});
|
|
230
|
+
if (currentState.fireOnLoadLayoutChange) {
|
|
231
|
+
console.warn("layout inicial incompatible, se notifica al host del componente");
|
|
232
|
+
onLayoutChange(currentState.breakpointLayout, {
|
|
233
|
+
...layouts,
|
|
234
|
+
[currentState.breakpoint]: currentState.breakpointLayout
|
|
235
|
+
});
|
|
236
|
+
}
|
|
271
237
|
return;
|
|
272
238
|
}
|
|
273
|
-
const
|
|
239
|
+
const lastBreakpoint = refState.current.currentBreakpoint;
|
|
240
|
+
const lastContainerWidth = refState.current.containerWidth;
|
|
241
|
+
const lastContainerHeight = refState.current.containerHeight;
|
|
242
|
+
const lastBreakpointCols = refState.current.currentBreakpointCols;
|
|
243
|
+
const newBreakpoint = breakpoint || getBreakpointFromWidth(breakpoints, containerWidth);
|
|
274
244
|
const newCols = getColsFromBreakpoint(newBreakpoint, cols);
|
|
275
|
-
const lastBreakpoint = currentState.breakpoint;
|
|
276
245
|
const newLayouts = {
|
|
277
246
|
...layouts
|
|
278
247
|
};
|
|
279
248
|
let newContainerMargin = currentState.contaierMargin;
|
|
280
249
|
let newContainerPadding = currentState.contaierPadding;
|
|
281
|
-
if (newBreakpoint !==
|
|
250
|
+
if (newBreakpoint !== lastBreakpoint || newCols !== lastBreakpointCols || !deepEqual(cols, refState.current.cols) || !deepEqual(breakpoints, refState.current.breakpoints) || !isEqualLayouts(layouts, refState.current.layouts)) {
|
|
282
251
|
console.debug("useEffect responsive con cambio de algo", newBreakpoint, lastBreakpoint);
|
|
283
252
|
newContainerMargin = getIndentationValue(containerMargin, newBreakpoint);
|
|
284
253
|
newContainerPadding = getIndentationValue(containerPadding, newBreakpoint);
|
|
285
254
|
if (!(lastBreakpoint in newLayouts)) {
|
|
286
255
|
console.error("useEffect casi imposible", lastBreakpoint, newLayouts);
|
|
287
|
-
newLayouts[lastBreakpoint] = cloneLayout(currentState.
|
|
256
|
+
newLayouts[lastBreakpoint] = cloneLayout(currentState.breakpointLayout);
|
|
288
257
|
}
|
|
289
|
-
const layout = findOrGenerateResponsiveLayout(newLayouts, breakpoints, newBreakpoint, lastBreakpoint, newCols, compactType, cols, colapsedHeight);
|
|
258
|
+
const layout = findOrGenerateResponsiveLayout(newLayouts, breakpoints, newBreakpoint, lastBreakpoint, newCols, compactType, cols, colapsedHeight, rowHeight);
|
|
290
259
|
newLayouts[newBreakpoint] = layout;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
refLayouts.current.breakpoint = newBreakpoint;
|
|
296
|
-
refLayouts.current.breakpoints = breakpoints;
|
|
297
|
-
console.debug("useEffect responsive****", layout);
|
|
260
|
+
refState.current.layouts = newLayouts;
|
|
261
|
+
refState.current.breakpoints = breakpoints;
|
|
262
|
+
refState.current.currentBreakpoint = newBreakpoint;
|
|
263
|
+
refState.current.currentBreakpointCols = newCols;
|
|
298
264
|
setCurrentState({
|
|
299
265
|
breakpoint: newBreakpoint,
|
|
300
|
-
layout,
|
|
266
|
+
breakpointLayout: layout,
|
|
301
267
|
cols: newCols,
|
|
302
268
|
contaierMargin: newContainerMargin,
|
|
303
269
|
contaierPadding: newContainerPadding
|
|
304
270
|
});
|
|
305
271
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
});
|
|
314
|
-
}, [width, height, layouts, breakpoint, breakpoints]);
|
|
315
|
-
useEffect(() => {
|
|
316
|
-
onLayoutChange(currentState.layout, refLayouts.current.layouts);
|
|
317
|
-
}, [currentState.layout]);
|
|
318
|
-
const localOnLayoutChange = useCallback((newlayout) => {
|
|
319
|
-
try {
|
|
320
|
-
refLayouts.current.layouts[refLayouts.current.breakpoint] = cloneLayout(newlayout);
|
|
321
|
-
} catch (error) {
|
|
322
|
-
console.warn("localOnLayoutChange error");
|
|
272
|
+
if (newBreakpoint !== lastBreakpoint || newCols !== lastBreakpointCols || lastContainerWidth !== containerWidth || lastContainerHeight != containerHeight) {
|
|
273
|
+
onContainerChange({
|
|
274
|
+
containerWidth,
|
|
275
|
+
containerHeight,
|
|
276
|
+
breakpoint: newBreakpoint,
|
|
277
|
+
cols: newCols
|
|
278
|
+
});
|
|
323
279
|
}
|
|
280
|
+
}, [containerWidth, containerHeight, layouts, breakpoint, breakpoints, cols]);
|
|
281
|
+
const localOnLayoutChange = useCallback((newlayout) => {
|
|
282
|
+
const newLayoutClone = cloneLayout(newlayout);
|
|
283
|
+
refState.current.layouts[refState.current.currentBreakpoint] = newLayoutClone;
|
|
324
284
|
setCurrentState((prev) => ({
|
|
325
285
|
...prev,
|
|
326
|
-
|
|
286
|
+
breakpointLayout: newLayoutClone
|
|
327
287
|
}));
|
|
328
|
-
onLayoutChange(newlayout, {
|
|
329
|
-
...refLayouts.current.layouts
|
|
330
|
-
});
|
|
331
288
|
}, [onLayoutChange]);
|
|
332
289
|
return /* @__PURE__ */ jsx(GridLayout, {
|
|
333
|
-
|
|
334
|
-
|
|
290
|
+
rowHeight,
|
|
291
|
+
containerWidth,
|
|
292
|
+
containerHeight,
|
|
335
293
|
colapsedHeight,
|
|
336
294
|
layoutItemRender,
|
|
337
|
-
|
|
295
|
+
margin: currentState.contaierMargin,
|
|
338
296
|
containerPadding: getIndentationValue(containerPadding, currentState.breakpoint),
|
|
339
297
|
onLayoutChange: localOnLayoutChange,
|
|
340
|
-
layout: currentState.
|
|
298
|
+
layout: currentState.breakpointLayout,
|
|
341
299
|
cols: currentState.cols,
|
|
342
300
|
compactType,
|
|
343
301
|
...other
|
|
@@ -347,7 +305,5 @@ export {
|
|
|
347
305
|
Responsive as R,
|
|
348
306
|
addLayoutItemToBreakPointIfNoExists as a,
|
|
349
307
|
addLayoutItemToBreakPoints as b,
|
|
350
|
-
|
|
351
|
-
cloneLayouts as d,
|
|
352
|
-
isEqualLayout as i
|
|
308
|
+
cloneLayouts as c
|
|
353
309
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CompactType, Layout, LayoutItem, Margin } from '../../types';
|
|
2
|
-
import {
|
|
1
|
+
import { Breakpoint, CompactType, Layout, LayoutItem, Layouts, Margin } from '../../types';
|
|
2
|
+
import { BreakpointCols, Breakpoints, ResponsiveLayout, ResponsiveMargin } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Given a width, find the highest breakpoint that matches is valid for it (width > breakpoint).
|
|
5
5
|
*
|
|
@@ -29,7 +29,7 @@ export declare function getColsFromBreakpoint(breakpoint: Breakpoint, cols: Brea
|
|
|
29
29
|
* vertically.
|
|
30
30
|
* @return {Array} New layout.
|
|
31
31
|
*/
|
|
32
|
-
export declare function findOrGenerateResponsiveLayout(layouts: ResponsiveLayout<Breakpoint>, breakpoints: Breakpoints<Breakpoint>, breakpoint: Breakpoint, lastBreakpoint: Breakpoint, cols: number, compactType: CompactType, brekpointsCols: BreakpointCols, colapsedHeight: number): Layout;
|
|
32
|
+
export declare function findOrGenerateResponsiveLayout(layouts: ResponsiveLayout<Breakpoint>, breakpoints: Breakpoints<Breakpoint>, breakpoint: Breakpoint, lastBreakpoint: Breakpoint, cols: number, compactType: CompactType, brekpointsCols: BreakpointCols, colapsedHeight: number, rowHeight: number): Layout;
|
|
33
33
|
/**
|
|
34
34
|
* Given breakpoints, return an array of breakpoints sorted by width. This is usually
|
|
35
35
|
* e.g. ['xxs', 'xs', 'sm', ...]
|
|
@@ -59,6 +59,3 @@ export declare function addLayoutItemToBreakPointIfNoExists(layouts: Layouts, br
|
|
|
59
59
|
*/
|
|
60
60
|
export declare function addLayoutItemToBreakPoints(layouts: Layouts, layoutItem: LayoutItem, cols: BreakpointCols, margin: ResponsiveMargin, containerPadding: ResponsiveMargin, rowHeight: number, containerHeight?: number, currentBreakpoint?: Breakpoint): Layouts;
|
|
61
61
|
export declare function cloneLayouts(layouts: Layouts, layoutItemReplaceProps?: Partial<Exclude<LayoutItem, 'i'>>): Layouts;
|
|
62
|
-
export declare function isEqualLayoutItem(layoutA: LayoutItem, layoutB: LayoutItem): boolean;
|
|
63
|
-
export declare function isEqualLayout(layoutA: Layout, layoutB: Layout): boolean;
|
|
64
|
-
export declare function isEqualLayouts(layoutsA: Layouts, layoutsB: Layouts): boolean;
|
|
@@ -1,45 +1,90 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare type Breakpoint = string;
|
|
1
|
+
import type { Breakpoint, CoreProps, Layout, Layouts, Margin } from '../../types';
|
|
3
2
|
export declare type DefaultBreakpoints = 'lg' | 'md' | 'sm' | 'xs' | 'xxs';
|
|
4
3
|
export declare type ResponsiveLayout<T extends Breakpoint> = Record<T, Layout>;
|
|
5
4
|
export declare type Breakpoints<T extends Breakpoint> = Readonly<Record<T, number>>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
/**
|
|
6
|
+
* "ResponsiveState" interface usada para manejar el estado reactivo del Responsive
|
|
7
|
+
*/
|
|
8
|
+
export declare type ResponsiveState = {
|
|
9
|
+
/**
|
|
10
|
+
* "breakpointLayout" variable de estado que sirve de parametro de entrada al GridLayout
|
|
11
|
+
* Esta variable cambia con base en los movimientos del usuario y los cambios a traves de los props
|
|
12
|
+
*/
|
|
13
|
+
breakpointLayout: Layout;
|
|
14
|
+
/**
|
|
15
|
+
* "breakpoint" Breeakpoint actual
|
|
16
|
+
*/
|
|
15
17
|
breakpoint: Breakpoint;
|
|
18
|
+
/**
|
|
19
|
+
* "cols" Columnas con base en el brekpoint actual
|
|
20
|
+
*/
|
|
16
21
|
cols: number;
|
|
22
|
+
/**
|
|
23
|
+
* "fireOnLoadLayoutChange" Indica si se debe notificiar el evento "onLayoutChange" en la primera carga, pero solo
|
|
24
|
+
* cuando el layout que viende de la prop es diferente despues verificarlo y compactarlo.
|
|
25
|
+
* Este valor normalmente es falso, sin embargo al momento de cambiar el compactType en un despliegue puede arrojar un
|
|
26
|
+
* layout diferente por cambio en la forma de compactación
|
|
27
|
+
*/
|
|
17
28
|
fireOnLoadLayoutChange?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* "contaierMargin" margen del breakpoint actual para todo los gridItems
|
|
31
|
+
*/
|
|
18
32
|
contaierMargin: Margin;
|
|
33
|
+
/**
|
|
34
|
+
* "contaierPadding" padding del contenedor para el brekpoint actual
|
|
35
|
+
**/
|
|
19
36
|
contaierPadding: Margin;
|
|
20
37
|
};
|
|
21
|
-
export declare type
|
|
22
|
-
export declare type OnLayoutChangeCallback = (layout: LayoutNotReadOnly, layouts: LayoutsNotReadonly) => void;
|
|
38
|
+
export declare type OnLayoutChangeCallback = (layout: Layout, layouts: Layouts) => void;
|
|
23
39
|
export declare type LayoutItemResponsive = {
|
|
24
40
|
i: string;
|
|
25
41
|
freeMove: boolean;
|
|
26
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* "ResponsiveMargin" interface para denotar el padding o margin de manera responsive que incluye la opción no responsive Marghin
|
|
45
|
+
*/
|
|
27
46
|
export declare type ResponsiveMargin = {
|
|
28
47
|
[key: Breakpoint]: Margin;
|
|
29
48
|
} | Margin;
|
|
49
|
+
/**
|
|
50
|
+
* "RefResponsiveState" interface para manejar las variables de referencia que son accesibles en useCallbacs
|
|
51
|
+
* Adicionalmente sirve para comparar las props vs lo ultimo guardado y tomar acciones cuando realmente cambian los datos.
|
|
52
|
+
*/
|
|
30
53
|
export declare type RefResponsiveState = {
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
/**
|
|
55
|
+
* "cols": ultimo valor de la prop cols
|
|
56
|
+
*/
|
|
57
|
+
cols: BreakpointCols;
|
|
58
|
+
/**
|
|
59
|
+
* "currentBreakpointCols": Cantidad de columnnas que tiene el breakpoint actual
|
|
60
|
+
*/
|
|
61
|
+
currentBreakpointCols: number;
|
|
62
|
+
/**
|
|
63
|
+
* "currentBreakpoint": brekpoint actual
|
|
64
|
+
*/
|
|
65
|
+
currentBreakpoint: Breakpoint;
|
|
66
|
+
/**
|
|
67
|
+
* "layouts": todos los layout por cada breakpoint con las moficaciones hechas por el usuario,
|
|
68
|
+
* puede diferir a la que viene por los props, por las diferentes transformaciones y se ha tomado la decision de que
|
|
69
|
+
* no sea controlado el componente.
|
|
70
|
+
*/
|
|
71
|
+
layouts: Layouts;
|
|
72
|
+
/**
|
|
73
|
+
* "breakpoints" breakpoints actuales, se inicializa con los breakpoints que vienen de las props
|
|
74
|
+
*/
|
|
33
75
|
breakpoints: Breakpoints<Breakpoint>;
|
|
34
|
-
|
|
35
|
-
|
|
76
|
+
/**
|
|
77
|
+
* "containerWidth" ancho del contendor offsetParent.width (No incluye el contenido oculto )
|
|
78
|
+
*/
|
|
79
|
+
containerWidth: number;
|
|
80
|
+
/**
|
|
81
|
+
* "containerHeight" altura del contendor offsetParent.height (No incluye el contenido oculto )
|
|
82
|
+
*/
|
|
83
|
+
containerHeight: number;
|
|
36
84
|
};
|
|
37
|
-
export declare type OnBreakpointChange = (breakPoint: Breakpoint, cols: number, width: number, height: number) => void;
|
|
38
85
|
export declare type ContainerChangeEvent = {
|
|
39
86
|
containerWidth: number;
|
|
40
87
|
containerHeight: number;
|
|
41
|
-
containerMargin: Margin;
|
|
42
|
-
containerPadding: Margin;
|
|
43
88
|
breakpoint: Breakpoint;
|
|
44
89
|
cols: number;
|
|
45
90
|
};
|
|
@@ -47,23 +92,59 @@ export declare type OnContainerChange = (event: ContainerChangeEvent) => void;
|
|
|
47
92
|
export declare type BreakpointCols = {
|
|
48
93
|
[key: Breakpoint]: number;
|
|
49
94
|
};
|
|
50
|
-
export
|
|
95
|
+
export interface ResponsiveProps extends CoreProps {
|
|
51
96
|
/**
|
|
52
|
-
*
|
|
97
|
+
* "breakpoint" permite configurar a traves de prop el breakpoint a mostrar,
|
|
98
|
+
* por encima del que puede estar detectando en el contenedor root del gridLayout
|
|
99
|
+
*/
|
|
100
|
+
breakpoint?: Breakpoint | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* "breakpoints" indica los breakpoints en que medidas del contenedor cambian
|
|
103
|
+
* Para los valores por defecto sería:
|
|
104
|
+
* lg cuando es mayor a 1200 pixels
|
|
105
|
+
* md: Entre 996 y 1200
|
|
106
|
+
* sm: Entre 768 y 996
|
|
107
|
+
* etc.
|
|
108
|
+
* Valor por defecto: { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }
|
|
109
|
+
*/
|
|
110
|
+
breakpoints?: Breakpoints<Breakpoint>;
|
|
111
|
+
/**
|
|
112
|
+
* "cols" Indica las columnas por cada breakpoint
|
|
113
|
+
* Valor por defecto: { lg: 12, md: 10, sm: 6, xs: 4, xxs: 1 }
|
|
114
|
+
*/
|
|
115
|
+
cols?: BreakpointCols;
|
|
116
|
+
/**
|
|
117
|
+
* "layouts" Objeto que contiene los layout por cada breakpoint
|
|
53
118
|
*/
|
|
54
|
-
addItemPosition?: AddItemPostion;
|
|
55
|
-
layoutItemRender: LayoutItemRender;
|
|
56
|
-
allowOverlap?: boolean;
|
|
57
|
-
breakpoint?: Breakpoint;
|
|
58
|
-
breakpoints: Breakpoints<Breakpoint>;
|
|
59
|
-
cols: BreakpointCols;
|
|
60
119
|
layouts: ResponsiveLayout<Breakpoint>;
|
|
61
|
-
|
|
62
|
-
|
|
120
|
+
/**
|
|
121
|
+
* "containerWidth" Ancho del contendor
|
|
122
|
+
* TODO: Reservar espacio para el scrollbar vertical
|
|
123
|
+
*/
|
|
124
|
+
containerWidth: number;
|
|
125
|
+
/**
|
|
126
|
+
* "containerHeight" Alto del contendor
|
|
127
|
+
* TODO: Reservar espacio para el scrollbar horizontal
|
|
128
|
+
*/
|
|
129
|
+
containerHeight: number;
|
|
130
|
+
/**
|
|
131
|
+
* "containerMargin" margin de para los gridItems
|
|
132
|
+
*/
|
|
63
133
|
containerMargin?: ResponsiveMargin;
|
|
134
|
+
/**
|
|
135
|
+
* "containerPadding" padding del contenedor
|
|
136
|
+
*/
|
|
64
137
|
containerPadding?: ResponsiveMargin;
|
|
65
|
-
|
|
138
|
+
/**
|
|
139
|
+
* "onLayoutChange" handler que recibirá los cambios del layout actual
|
|
140
|
+
*/
|
|
66
141
|
onLayoutChange?: OnLayoutChangeCallback;
|
|
142
|
+
/**
|
|
143
|
+
* "onLayoutChange" handler que recibirá los cambios asociados a las medidas del contenedor, breakpoint y columnas
|
|
144
|
+
*/
|
|
67
145
|
onContainerChange?: OnContainerChange;
|
|
68
|
-
}
|
|
69
|
-
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* "ResponsiveInitialStateProps" interfaz usada en la inicialización y conciliación del primer estado del componente
|
|
149
|
+
*/
|
|
150
|
+
export declare type ResponsiveInitialStateProps = Pick<ResponsiveProps, 'containerWidth' | 'containerHeight' | 'breakpoint' | 'breakpoints' | 'cols' | 'compactType' | 'layouts' | 'containerMargin' | 'containerPadding' | 'colapsedHeight' | 'rowHeight'>;
|
|
@@ -2,8 +2,8 @@ import { useRef, useState, useMemo, useCallback, useEffect } from "react";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { throttle } from "lodash";
|
|
4
4
|
import { useResizeObserver } from "@m4l/graphics";
|
|
5
|
+
import { j as DEFAULT_CONTAINER_WIDTH, k as DEFAULT_CONTAINER_HEIGHT, T as THROTTLE_RESIZE_TIME } from "../../index.76bccc4f.js";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
const THROTTLE_RESIZE_TIME = 200;
|
|
7
7
|
const layoutClassName = "M4LGridLayout";
|
|
8
8
|
function WidthProvider(ComposedComponent) {
|
|
9
9
|
return (props) => {
|
|
@@ -14,8 +14,8 @@ function WidthProvider(ComposedComponent) {
|
|
|
14
14
|
const refMounted = useRef(false);
|
|
15
15
|
const [currentState, setCurrentState] = useState({
|
|
16
16
|
mounted: false,
|
|
17
|
-
width:
|
|
18
|
-
height:
|
|
17
|
+
width: DEFAULT_CONTAINER_WIDTH,
|
|
18
|
+
height: DEFAULT_CONTAINER_HEIGHT
|
|
19
19
|
});
|
|
20
20
|
const onWindowResizeMemo = useMemo(() => () => {
|
|
21
21
|
const node = elementRef.current;
|
|
@@ -54,8 +54,8 @@ function WidthProvider(ComposedComponent) {
|
|
|
54
54
|
}
|
|
55
55
|
return /* @__PURE__ */ jsx(ComposedComponent, {
|
|
56
56
|
innerRef: elementRef,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
containerWidth: currentState.width,
|
|
58
|
+
containerHeight: currentState.height,
|
|
59
59
|
...rest
|
|
60
60
|
});
|
|
61
61
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { CoreProps, GridLayoutProps } from '../../types';
|
|
3
|
-
import {
|
|
4
|
-
export declare const THROTTLE_RESIZE_TIME = 200;
|
|
3
|
+
import { ResponsiveProps } from '../Responsive/types';
|
|
5
4
|
export declare type HOCProps = {
|
|
6
5
|
measureBeforeMount?: boolean;
|
|
7
6
|
};
|
|
8
7
|
export declare type ComponentReactGridLayoutProps = GridLayoutProps & {
|
|
9
8
|
measureBeforeMount?: boolean;
|
|
10
9
|
};
|
|
11
|
-
export interface ComponentResponsiveReactGridLayoutProps extends Omit<
|
|
10
|
+
export interface ComponentResponsiveReactGridLayoutProps extends Omit<ResponsiveProps, 'width' | 'height'> {
|
|
12
11
|
measureBeforeMount?: boolean;
|
|
13
12
|
}
|
|
14
|
-
declare type MinimalParameters = Pick<CoreProps, '
|
|
15
|
-
export declare function WidthProvider<T extends MinimalParameters>(ComposedComponent: FunctionComponent<T>): (props: Omit<T, '
|
|
13
|
+
declare type MinimalParameters = Pick<CoreProps, 'containerWidth' | 'containerHeight' | 'innerRef' | 'style' | 'className'>;
|
|
14
|
+
export declare function WidthProvider<T extends MinimalParameters>(ComposedComponent: FunctionComponent<T>): (props: Omit<T, 'containerWidth' | 'containerHeight' | 'innerRef'> & HOCProps) => import("react").JSX.Element;
|
|
16
15
|
export {};
|