@m4l/components 3.1.7 → 3.1.8

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.
Files changed (201) hide show
  1. package/index.js +183 -340
  2. package/node_modules-CQtkw0uG.js +7350 -0
  3. package/package.json +1 -1
  4. package/vendor-AfIOyqRr.js +24636 -0
  5. package/components/AccountPopover/index-Dm2-k-Mv.js +0 -334
  6. package/components/AppBar/index-i0rhG3J1.js +0 -93
  7. package/components/BaseModule/index-CiNNlxzS.js +0 -30
  8. package/components/CommonActions/components/ActionCancel/index-CIdpDXkr.js +0 -12
  9. package/components/CommonActions/components/ActionFormCancel/index-CpyASN3q.js +0 -56
  10. package/components/CommonActions/components/ActionFormIntro/index-7KKtcUra.js +0 -33
  11. package/components/CommonActions/components/ActionIntro/index-CqqDZZcG.js +0 -25
  12. package/components/CommonActions/components/Actions/index-CuG1pnXW.js +0 -70
  13. package/components/DataGrid/constants-8L7QgBKi.js +0 -10
  14. package/components/DataGrid/formatters/ColumnBooleanFormatter/index-CveSCbq_.js +0 -26
  15. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-CHqvieM2.js +0 -22
  16. package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
  17. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-DE6bwaKP.js +0 -23
  18. package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
  19. package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
  20. package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
  21. package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
  22. package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
  23. package/components/DataGrid/formatters/index-CrZXPa0e.js +0 -13
  24. package/components/DataGrid/index-BZ-lbmuU.js +0 -908
  25. package/components/DataGrid/subcomponents/Actions/index-CHvPZ4Ru.js +0 -549
  26. package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
  27. package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
  28. package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
  29. package/components/DynamicFilter/dictionary-PrbXU3VZ.js +0 -51
  30. package/components/DynamicFilter/index-DZiJc9h7.js +0 -116
  31. package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
  32. package/components/DynamicFilter/slots/dynamicFilterSlots-DHxelhXP.js +0 -151
  33. package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
  34. package/components/DynamicFilter/store/index-BT-eWVnJ.js +0 -254
  35. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-B32bAzi-.js +0 -60
  36. package/components/DynamicFilter/subcomponents/AppliedFilters/index-Bha19drV.js +0 -26
  37. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BmvzoHit.js +0 -40
  38. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-BcO3SlP5.js +0 -129
  39. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BCJhpNS8.js +0 -171
  40. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-DCNhz68u.js +0 -153
  41. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-BdypjM1Y.js +0 -146
  42. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-D-NFIVnK.js +0 -114
  43. package/components/DynamicFilter/subcomponents/FieldTypes/index-BwQHJqk9.js +0 -38
  44. package/components/DynamicFilter/subcomponents/FilterActions/index-B9UWmk07.js +0 -88
  45. package/components/DynamicFilter/subcomponents/InputFilter/index-CfGb1TfV.js +0 -188
  46. package/components/DynamicFilter/subcomponents/PopoverFilter/index-DkfRGrlO.js +0 -158
  47. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DSegwAm2.js +0 -63
  48. package/components/FieldLabel/index-CI57EizR.js +0 -54
  49. package/components/GridLayout/index-C4HyxNYX.js +0 -1044
  50. package/components/GridLayout/subcomponents/Griditem/index-C7jT4s8t.js +0 -395
  51. package/components/GridLayout/subcomponents/Responsive/index-BKcU2OnF.js +0 -348
  52. package/components/GridLayout/subcomponents/SizeProvider/index-1aJ-e_54.js +0 -71
  53. package/components/HelperText/index-Crn_XIPF.js +0 -50
  54. package/components/Icon/index-C89MAkeH.js +0 -176
  55. package/components/Image/index-COp8vP0X.js +0 -175
  56. package/components/LanguagePopover/index-BA2Igs9L.js +0 -179
  57. package/components/LinearProgressIndeterminate/index-BwI756Mb.js +0 -55
  58. package/components/Loadable/index-BMbi9ISF.js +0 -9
  59. package/components/LoadingError/index-Cf0oGUrL.js +0 -89
  60. package/components/MFIsolationApp/index-V4R55hNU.js +0 -169
  61. package/components/MFLoader/index-BI8vQZSH.js +0 -299
  62. package/components/ModalDialog/index-CEVQBQ7W.js +0 -77
  63. package/components/NavLink/index-D1S_vtFO.js +0 -55
  64. package/components/NoItemSelected/index-B9oM26AX.js +0 -54
  65. package/components/ObjectLogs/index-CiXOJpS4.js +0 -233
  66. package/components/PDFViewer/index-GVN2rfd6.js +0 -51
  67. package/components/Page/index-DZMkYmr4.js +0 -117
  68. package/components/PaperForm/index-DwgAfjci.js +0 -59
  69. package/components/Period/index-2pJG3VmY.js +0 -238
  70. package/components/PrintingSystem/index-B2qcnfw0.js +0 -187
  71. package/components/PrintingSystem/subcomponents/BodyNode/index-Cv2aoy8S.js +0 -49
  72. package/components/PrintingSystem/subcomponents/ChartNode/index-BmJm8v_C.js +0 -105
  73. package/components/PrintingSystem/subcomponents/DividerNode/index-MpFhE-H0.js +0 -20
  74. package/components/PrintingSystem/subcomponents/FooterNode/index-ZEcWdMSM.js +0 -49
  75. package/components/PrintingSystem/subcomponents/GridNode/index-SsKax2xu.js +0 -74
  76. package/components/PrintingSystem/subcomponents/HeaderNode/index-Cs8TOOBL.js +0 -49
  77. package/components/PrintingSystem/subcomponents/PaperNode/index-DBb25Ecg.js +0 -30
  78. package/components/PrintingSystem/subcomponents/PropertyValueNode/index-CTVn7J9Q.js +0 -47
  79. package/components/PrintingSystem/subcomponents/SectionNode/index-iYPM3EaS.js +0 -49
  80. package/components/PrintingSystem/subcomponents/TextBoxNode/index-DGjXCFKJ.js +0 -24
  81. package/components/PropertyValue/index-Bh-Jnrte.js +0 -264
  82. package/components/Resizeable/index-DdP1xfE9.js +0 -20
  83. package/components/ScrollBar/index-f2URPPE2.js +0 -35
  84. package/components/ScrollToTop/index-TxORk5dB.js +0 -12
  85. package/components/SideBar/index-PUBBe0yH.js +0 -758
  86. package/components/SplitLayout/index-Bu1hcO6G.js +0 -89
  87. package/components/ToastContainer/index-DK1d8NNd.js +0 -191
  88. package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
  89. package/components/animate/LoadingScreen/index-CkVLOrMz.js +0 -70
  90. package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
  91. package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
  92. package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
  93. package/components/animate/features-BbnE33u3.js +0 -5
  94. package/components/animate/index-BsWiJfzp.js +0 -89
  95. package/components/animate/variants/bounce-DanQqHAX.js +0 -101
  96. package/components/animate/variants/container-Dmpr6tg5.js +0 -22
  97. package/components/animate/variants/fade-CAOJNn06.js +0 -65
  98. package/components/animate/variants/index-l0sNRNKZ.js +0 -1
  99. package/components/animate/variants/transition-B9W5SWTa.js +0 -20
  100. package/components/areas/components/AreasAdmin/index-OxQU3P8Y.js +0 -699
  101. package/components/areas/components/AreasViewer/index-DQ0aPioP.js +0 -805
  102. package/components/areas/components/index-l0sNRNKZ.js +0 -1
  103. package/components/areas/constants-rqODZNZe.js +0 -6
  104. package/components/areas/contexts/AreasContext/index-BqRlA7JA.js +0 -1110
  105. package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
  106. package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
  107. package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
  108. package/components/areas/dictionary-YUsP9beq.js +0 -36
  109. package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
  110. package/components/areas/hooks/useAreas/index-BSbwbJLS.js +0 -11
  111. package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
  112. package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
  113. package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
  114. package/components/areas/icons-CwFr-alN.js +0 -24
  115. package/components/areas/index-B_Odny9h.js +0 -22
  116. package/components/commercial/AppBarCommercial/index-CHq3P3GY.js +0 -28
  117. package/components/commercial/SectionCommercial/index-BeABGtdr.js +0 -56
  118. package/components/commercial/TopBar/index-F1repmti.js +0 -232
  119. package/components/commercial/index-CxDzs6Ax.js +0 -81
  120. package/components/formatters/BooleanFormatter/index-DktIidqW.js +0 -44
  121. package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
  122. package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
  123. package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
  124. package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
  125. package/components/formatters/index-pnJhDYKe.js +0 -109
  126. package/components/hook-form/HelperError/index-BVnmUazV.js +0 -19
  127. package/components/hook-form/RHFAutocomplete/index-BtPL16HR.js +0 -657
  128. package/components/hook-form/RHFAutocompleteAsync/index-BfzjLHG8.js +0 -226
  129. package/components/hook-form/RHFCheckbox/index-Vyttu8Vx.js +0 -132
  130. package/components/hook-form/RHFColorPicker/index-Cxxb5Wa_.js +0 -191
  131. package/components/hook-form/RHFDateTime/index-CW1Slb-f.js +0 -190
  132. package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
  133. package/components/hook-form/RHFPeriod/index-r-HeIOoZ.js +0 -98
  134. package/components/hook-form/RHFRadioGroup/index-CTD-0zKo.js +0 -52
  135. package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
  136. package/components/hook-form/RHFTextField/index-B6ufruSB.js +0 -337
  137. package/components/hook-form/RHFUpload/index-CDPbm8NR.js +0 -253
  138. package/components/maps/components/GpsTools/index-5MXlhIEt.js +0 -1948
  139. package/components/maps/components/Map/index-2Lx5ARXa.js +0 -2546
  140. package/components/maps/index-Ci-7-FHg.js +0 -7
  141. package/components/modal/WindowBase-Gd27v5FU.js +0 -44
  142. package/components/modal/WindowConfirm-u6vAMFo7.js +0 -73
  143. package/components/modal/index-CydPIpKZ.js +0 -65
  144. package/components/mui_extended/Accordion/index-DMLYJL7o.js +0 -124
  145. package/components/mui_extended/Avatar/index-ClBa-6eF.js +0 -64
  146. package/components/mui_extended/Badge/index-zI-F_Qkq.js +0 -29
  147. package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
  148. package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
  149. package/components/mui_extended/Button/index-CGfZbaea.js +0 -222
  150. package/components/mui_extended/CheckBox-BXUrbonB.js +0 -76
  151. package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
  152. package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
  153. package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
  154. package/components/mui_extended/IconButton/index-CusYFjie.js +0 -97
  155. package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
  156. package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
  157. package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
  158. package/components/mui_extended/MenuActions/MenuActions-C6CjSU6C.js +0 -149
  159. package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
  160. package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
  161. package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
  162. package/components/mui_extended/MenuActions/slots/MenuActionsSlots-D65KZAKF.js +0 -46
  163. package/components/mui_extended/Pager/index-DCbxiTZA.js +0 -257
  164. package/components/mui_extended/Popover/index-DfrJAQkV.js +0 -153
  165. package/components/mui_extended/Stack/index-DzEeCYfp.js +0 -31
  166. package/components/mui_extended/Tab/index-Bu3dPidV.js +0 -129
  167. package/components/mui_extended/ToggleButton/index-C9cBkT1V.js +0 -18
  168. package/components/mui_extended/ToggleIconButton/index--0b3Td6C.js +0 -26
  169. package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
  170. package/components/mui_extended/Typography/index-Cf_4Zw8f.js +0 -54
  171. package/components/mui_extended/index-l0sNRNKZ.js +0 -1
  172. package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
  173. package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
  174. package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
  175. package/components/popups/PopupsViewer/index-BecevSns.js +0 -172
  176. package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
  177. package/components/popups/PopupsViewer/slots/popupsViewerSlots-BXH77nCF.js +0 -46
  178. package/components/popups/index-l0sNRNKZ.js +0 -1
  179. package/contexts/ModalContext/index-CPfNnfTL.js +0 -39
  180. package/contexts/RHFormContext/index-D_nK759o.js +0 -78
  181. package/hocs/withToggle/index-C1_DMZD3.js +0 -14
  182. package/hooks/useFormAddEdit/index-D9oSjUn1.js +0 -90
  183. package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
  184. package/hooks/useModal/index-BJSQOX3U.js +0 -10
  185. package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
  186. package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
  187. package/hooks/useTab/index-B_GEQFOP.js +0 -12
  188. package/react-data-grid-BfYuZ6AK.js +0 -2606
  189. package/react-draggable-DsCPdgQP.js +0 -811
  190. package/react-json-view-bhqIAaNg.js +0 -2576
  191. package/react-resizable-eBbFl2dX.js +0 -618
  192. package/react-spinners-TpKN9lZg.js +0 -123
  193. package/react-splitter-layout-C-JTsNGs.js +0 -158
  194. package/styles/DynamicFilter-CJFsIegc.js +0 -319
  195. package/styles/MenuActions-lTi-ynPM.js +0 -42
  196. package/styles/index-DKj6m8SL.js +0 -1691
  197. package/test/constants_no_mock-CF-669v-.js +0 -4
  198. package/test/getNameDataTestId-BaBTWhBr.js +0 -10
  199. package/utils/index-DiMrtgIu.js +0 -502
  200. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
  201. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/types.d.ts +0 -0
@@ -1,1044 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useRef, useEffect, useCallback } from "react";
3
- import clsx from "clsx";
4
- import { M as MemonizedGridItem } from "./subcomponents/Griditem/index-C7jT4s8t.js";
5
- import { G as GridLayoutRoot } from "../../styles/index-DKj6m8SL.js";
6
- import { generateUtilityClasses } from "@mui/material";
7
- import "@mui/base";
8
- const COMPONENT_CLASS_NAME = "M4LGridLayout";
9
- const DEFAULT_COLS = 12;
10
- const DEFAULT_ROW_HEIGHT = 20;
11
- const DEFAULT_CONTAINER_WIDTH = 1280;
12
- const DEFAULT_CONTAINER_HEIGHT = 480;
13
- const DEFAULT_RESPONSIVE_COLS = { lg: 12, md: 10, sm: 6, xs: 4, xxs: 1 };
14
- const DEFAULT_RESPONSIVE_BREAKPOINTS = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
15
- const DEFAULT_CONTAINER_PADDING = [10, 10];
16
- const DEFAULT_MARGIN = [10, 10];
17
- const DEFAULT_TRANSFORM_SCALE = 1;
18
- const DEFAULT_COLAPSED_HEIGHT = 35;
19
- const THROTTLE_RESIZE_TIMEOUT = 200;
20
- const noop = () => {
21
- };
22
- function bottom(layout, colapsedHeight, rowHeight) {
23
- let max = 0, bottomY;
24
- for (let i = 0, len = layout.length; i < len; i++) {
25
- bottomY = layout[i].y + getLayoutItemH(layout[i], colapsedHeight, rowHeight);
26
- if (bottomY > max) max = bottomY;
27
- }
28
- return max;
29
- }
30
- function cloneLayoutItem(layoutItem, layoutItemReplaceProps) {
31
- return {
32
- w: layoutItem.w,
33
- h: layoutItem.h,
34
- x: layoutItem.x,
35
- y: layoutItem.y,
36
- i: layoutItem.i,
37
- minW: layoutItem.minW,
38
- maxW: layoutItem.maxW,
39
- minH: layoutItem.minH,
40
- maxH: layoutItem.maxH,
41
- moved: Boolean(layoutItem.moved),
42
- static: Boolean(layoutItem.static),
43
- // These can be null/undefined
44
- isDraggable: layoutItem.isDraggable,
45
- isResizable: layoutItem.isResizable,
46
- resizeHandles: layoutItem.resizeHandles,
47
- isBounded: layoutItem.isBounded,
48
- freeMove: layoutItem.freeMove,
49
- colapsed: layoutItem.colapsed,
50
- visible: layoutItem.visible,
51
- ...layoutItemReplaceProps
52
- };
53
- }
54
- function cloneLayout(layout, layoutItemReplaceProps) {
55
- const newLayout = Array(layout.length);
56
- for (let i = 0, len = layout.length; i < len; i++) {
57
- newLayout[i] = cloneLayoutItem(layout[i], layoutItemReplaceProps);
58
- }
59
- return newLayout;
60
- }
61
- function collides(l1, l2, colapsedHeight, rowHeight) {
62
- if (l1.i === l2.i) return false;
63
- if (l1.x + l1.w <= l2.x) return false;
64
- if (l1.x >= l2.x + l2.w) return false;
65
- if (l1.y + getLayoutItemH(l1, colapsedHeight, rowHeight) <= l2.y) return false;
66
- if (l1.y >= l2.y + getLayoutItemH(l2, colapsedHeight, rowHeight)) return false;
67
- return true;
68
- }
69
- function compactItem(compareWith, l, compactType, cols, fullLayout, colapsedHeight, rowHeight, allowOverlap) {
70
- const compactV = compactType === "vertical";
71
- const compactH = compactType === "horizontal";
72
- if (compactV) {
73
- l.y = Math.min(bottom(compareWith, colapsedHeight, rowHeight), l.y);
74
- while (l.y > 0 && !getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) {
75
- l.y--;
76
- }
77
- } else if (compactH) {
78
- while (l.x > 0 && !getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) {
79
- l.x--;
80
- }
81
- }
82
- let collidesItem;
83
- while ((collidesItem = getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) && !(compactType === null && allowOverlap)) {
84
- if (compactH) {
85
- resolveCompactionCollision(
86
- fullLayout,
87
- l,
88
- collidesItem.x + collidesItem.w,
89
- "x",
90
- colapsedHeight,
91
- rowHeight
92
- );
93
- } else {
94
- resolveCompactionCollision(
95
- fullLayout,
96
- l,
97
- collidesItem.y + getLayoutItemH(collidesItem, colapsedHeight, rowHeight),
98
- "y",
99
- colapsedHeight,
100
- rowHeight
101
- );
102
- }
103
- if (compactH && l.x + l.w > cols) {
104
- l.x = cols - l.w;
105
- l.y++;
106
- while (l.x > 0 && !getFirstCollision(compareWith, l, colapsedHeight, rowHeight)) {
107
- l.x--;
108
- }
109
- }
110
- }
111
- l.y = Math.max(l.y, 0);
112
- l.x = Math.max(l.x, 0);
113
- return l;
114
- }
115
- function compact(layout, compactType, cols, colapsedHeight, rowHeight, allowOverlap) {
116
- const layoutToCompact = layout.filter((l) => !l.freeMove);
117
- const layoutFreeMov = layout.filter((l) => l?.freeMove);
118
- const compareWith = getStatics(layoutToCompact);
119
- const sorted = sortLayoutItems(layoutToCompact, compactType);
120
- const out = Array(layoutToCompact.length);
121
- for (let i = 0, len = sorted.length; i < len; i++) {
122
- let l = cloneLayoutItem(sorted[i]);
123
- if (!l.static) {
124
- l = compactItem(
125
- compareWith,
126
- l,
127
- compactType,
128
- cols,
129
- sorted,
130
- colapsedHeight,
131
- rowHeight,
132
- allowOverlap
133
- );
134
- compareWith.push(l);
135
- }
136
- out[layoutToCompact.indexOf(sorted[i])] = l;
137
- l.moved = false;
138
- }
139
- return out.concat(layoutFreeMov);
140
- }
141
- function getLayoutItem(layout, id) {
142
- for (let i = 0, len = layout.length; i < len; i++) {
143
- if (layout[i].i === id) return layout[i];
144
- }
145
- return void 0;
146
- }
147
- function getStatics(layout) {
148
- return layout.filter((l) => l.static);
149
- }
150
- function getAllCollisions(layout, layoutItem, colapsedHeight, rowHeight) {
151
- return layout.filter((l) => collides(l, layoutItem, colapsedHeight, rowHeight));
152
- }
153
- function getFirstCollision(layout, layoutItem, colapsedHeight, rowHeight) {
154
- for (let i = 0, len = layout.length; i < len; i++) {
155
- if (collides(layout[i], layoutItem, colapsedHeight, rowHeight)) return layout[i];
156
- }
157
- return void 0;
158
- }
159
- function modifyLayout(layout, layoutItem) {
160
- const newLayout = Array(layout.length);
161
- for (let i = 0, len = layout.length; i < len; i++) {
162
- if (layoutItem.i === layout[i].i) {
163
- newLayout[i] = layoutItem;
164
- } else {
165
- newLayout[i] = layout[i];
166
- }
167
- }
168
- return newLayout;
169
- }
170
- function moveElementAwayFromCollision(layout, collidesWith, itemToMove, isUserAction, compactType, cols, colapsedHeight, rowHeight) {
171
- const compactH = compactType === "horizontal";
172
- const compactV = compactType !== "horizontal";
173
- const preventCollision = collidesWith.static;
174
- if (isUserAction) {
175
- isUserAction = false;
176
- const fakeItem = {
177
- x: compactH ? Math.max(collidesWith.x - itemToMove.w, 0) : itemToMove.x,
178
- y: compactV ? Math.max(collidesWith.y - getLayoutItemH(itemToMove, colapsedHeight, rowHeight), 0) : itemToMove.y,
179
- w: itemToMove.w,
180
- h: getLayoutItemH(itemToMove, colapsedHeight, rowHeight),
181
- i: "-1"
182
- };
183
- if (!getFirstCollision(layout, fakeItem, colapsedHeight, rowHeight)) {
184
- return moveElement(
185
- layout,
186
- itemToMove,
187
- compactH ? fakeItem.x : void 0,
188
- compactV ? fakeItem.y : void 0,
189
- isUserAction,
190
- !!preventCollision,
191
- compactType,
192
- cols,
193
- colapsedHeight,
194
- rowHeight,
195
- false
196
- );
197
- }
198
- }
199
- return moveElement(
200
- layout,
201
- itemToMove,
202
- compactH ? itemToMove.x + 1 : void 0,
203
- compactV ? itemToMove.y + 1 : void 0,
204
- isUserAction,
205
- !!preventCollision,
206
- compactType,
207
- cols,
208
- colapsedHeight,
209
- rowHeight,
210
- false
211
- );
212
- }
213
- function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols, colapsedHeight, rowHeight, allowOverlap) {
214
- if (l.static && l.isDraggable !== true) return layout;
215
- if (l.y === y && l.x === x) return layout;
216
- const oldX = l.x;
217
- const oldY = l.y;
218
- if (typeof x === "number") l.x = x;
219
- if (typeof y === "number") l.y = y;
220
- l.moved = true;
221
- let sorted = sortLayoutItems(layout, compactType);
222
- const movingUp = compactType === "vertical" && typeof y === "number" ? oldY >= y : compactType === "horizontal" && typeof x === "number" ? oldX >= x : false;
223
- if (movingUp) sorted = sorted.reverse();
224
- const collisions = getAllCollisions(sorted, l, colapsedHeight, rowHeight);
225
- const hasCollisions = collisions.length > 0;
226
- if (hasCollisions && allowOverlap) {
227
- return cloneLayout(layout);
228
- } else if (hasCollisions && preventCollision) {
229
- l.x = oldX;
230
- l.y = oldY;
231
- l.moved = false;
232
- return layout;
233
- }
234
- for (let i = 0, len = collisions.length; i < len; i++) {
235
- const collision = collisions[i];
236
- if (collision.moved) continue;
237
- if (collision.static) {
238
- layout = moveElementAwayFromCollision(
239
- layout,
240
- collision,
241
- l,
242
- isUserAction,
243
- compactType,
244
- cols,
245
- colapsedHeight,
246
- rowHeight
247
- );
248
- } else {
249
- layout = moveElementAwayFromCollision(
250
- layout,
251
- l,
252
- collision,
253
- isUserAction,
254
- compactType,
255
- cols,
256
- colapsedHeight,
257
- rowHeight
258
- );
259
- }
260
- }
261
- return layout;
262
- }
263
- function perc(num) {
264
- return num * 100 + "%";
265
- }
266
- function resolveCompactionCollision(layout, item, moveToCoord, axis, colapsedHeight, rowHeight) {
267
- item[axis] += 1;
268
- const itemIndex = layout.map((layoutItem) => {
269
- return layoutItem.i;
270
- }).indexOf(item.i);
271
- for (let i = itemIndex + 1; i < layout.length; i++) {
272
- const otherItem = layout[i];
273
- if (otherItem.static) continue;
274
- if (otherItem.y > item.y + getLayoutItemH(item, colapsedHeight, rowHeight)) break;
275
- if (collides(item, otherItem, colapsedHeight, rowHeight)) {
276
- resolveCompactionCollision(
277
- layout,
278
- otherItem,
279
- moveToCoord + (axis === "x" ? item.w : getLayoutItemH(item, colapsedHeight, rowHeight)),
280
- axis,
281
- colapsedHeight,
282
- rowHeight
283
- );
284
- }
285
- }
286
- item[axis] = moveToCoord;
287
- }
288
- function setTransform({ top, left, width, height }) {
289
- return {
290
- /* transform: translate,
291
- WebkitTransform: translate,
292
- MozTransform: translate,
293
- msTransform: translate,
294
- OTransform: translate, */
295
- width: `${width}px`,
296
- height: `${height}px`,
297
- position: "absolute",
298
- left,
299
- top
300
- };
301
- }
302
- function setTopLeft({ top, left, width, height }) {
303
- return {
304
- top: `${top}px`,
305
- left: `${left}px`,
306
- width: `${width}px`,
307
- height: `${height}px`,
308
- position: "absolute"
309
- };
310
- }
311
- function sortLayoutItemsByRowCol(layout) {
312
- return layout.slice(0).sort(function(a, b) {
313
- if (a.y > b.y || a.y === b.y && a.x > b.x) {
314
- return 1;
315
- } else if (a.y === b.y && a.x === b.x) {
316
- return 0;
317
- }
318
- return -1;
319
- });
320
- }
321
- function sortLayoutItemsByColRow(layout) {
322
- return layout.slice(0).sort(function(a, b) {
323
- if (a.x > b.x || a.x === b.x && a.y > b.y) {
324
- return 1;
325
- }
326
- return -1;
327
- });
328
- }
329
- function sortLayoutItems(layout, compactType) {
330
- if (compactType === "horizontal") return sortLayoutItemsByColRow(layout);
331
- if (compactType === "vertical") return sortLayoutItemsByRowCol(layout);
332
- else return layout;
333
- }
334
- function withLayoutItem(layout, itemKey, cb) {
335
- let item = getLayoutItem(layout, itemKey);
336
- if (!item) return [layout, void 0];
337
- item = cb(cloneLayoutItem(item));
338
- layout = modifyLayout(layout, item);
339
- return [layout, item];
340
- }
341
- function correctBounds(layout, bounds, colapsedHeight, rowHeight) {
342
- const collidesWith = getStatics(layout);
343
- for (let i = 0, len = layout.length; i < len; i++) {
344
- const l = layout[i];
345
- if (l.x + l.w > bounds.cols) l.x = bounds.cols - l.w;
346
- if (l.x < 0) {
347
- l.x = 0;
348
- l.w = bounds.cols;
349
- }
350
- if (!l.static) collidesWith.push(l);
351
- else {
352
- while (getFirstCollision(collidesWith, l, colapsedHeight, rowHeight)) {
353
- l.y++;
354
- }
355
- }
356
- }
357
- return layout;
358
- }
359
- function getH(h, colapsedHeight, rowHeight, colapsed) {
360
- if (colapsed) {
361
- let ret;
362
- if (rowHeight && rowHeight > 0) {
363
- ret = colapsedHeight / rowHeight;
364
- } else {
365
- ret = colapsedHeight / DEFAULT_ROW_HEIGHT;
366
- }
367
- return ret;
368
- }
369
- return h;
370
- }
371
- function getLayoutItemH(layoutItem, colapsedHeight, rowHeight) {
372
- return getH(layoutItem.h, colapsedHeight, rowHeight, layoutItem.colapsed);
373
- }
374
- function isEqualLayoutItem(layoutA, layoutB) {
375
- if (layoutA.i !== layoutB.i) {
376
- return false;
377
- } 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) {
378
- return false;
379
- }
380
- return true;
381
- }
382
- function isEqualLayout(layoutA, layoutB) {
383
- if (layoutA.length !== layoutB.length) {
384
- return false;
385
- }
386
- for (let index = 0; index < layoutA.length; index++) {
387
- if (!isEqualLayoutItem(layoutA[index], layoutB[index])) {
388
- return false;
389
- }
390
- }
391
- return true;
392
- }
393
- function isEqualLayouts(layoutsA, layoutsB) {
394
- if (Object.keys(layoutsA).length !== Object.keys(layoutsB).length) {
395
- return false;
396
- }
397
- for (const breakPoint in layoutsA) {
398
- if (layoutsB[breakPoint]) {
399
- if (!isEqualLayout(layoutsA[breakPoint], layoutsB[breakPoint])) {
400
- return false;
401
- }
402
- } else {
403
- return false;
404
- }
405
- }
406
- return true;
407
- }
408
- function calcGridColWidth(positionParams) {
409
- const { containerMargin: margin, containerPadding, containerWidth, cols } = positionParams;
410
- return (containerWidth - margin[0] * (cols - 1) - containerPadding[0] * 2) / cols;
411
- }
412
- function calcGridItemWHPx(gridUnits, colOrRowSize, marginPx) {
413
- if (!Number.isFinite(gridUnits)) return gridUnits;
414
- return Math.round(colOrRowSize * gridUnits + Math.max(0, gridUnits - 1) * marginPx);
415
- }
416
- function calcGridItemPosition(positionParams, x, y, w, h, maximize, state) {
417
- const {
418
- containerMargin,
419
- containerPadding,
420
- rowHeight
421
- } = positionParams;
422
- const colWidth = calcGridColWidth(positionParams);
423
- const out = {};
424
- if (state && state.resizing) {
425
- out.width = Math.round(state.resizing.width);
426
- out.height = Math.round(state.resizing.height);
427
- } else {
428
- if (maximize === "maximize_me") {
429
- out.width = positionParams.containerWidth - 2 * containerPadding[0] - 0;
430
- out.height = positionParams.containerHeight - 2 * containerPadding[1] - 0;
431
- } else {
432
- out.width = calcGridItemWHPx(w, colWidth, containerMargin[0]);
433
- out.height = calcGridItemWHPx(h, rowHeight, containerMargin[1]);
434
- }
435
- }
436
- if (state && state.dragging) {
437
- out.top = Math.round(state.dragging.top);
438
- out.left = Math.round(state.dragging.left);
439
- } else {
440
- if (maximize === "maximize_me") {
441
- out.left = containerPadding[0];
442
- out.top = containerPadding[1];
443
- } else {
444
- out.left = Math.round((colWidth + containerMargin[0]) * x + containerPadding[0]);
445
- out.top = Math.round((rowHeight + containerMargin[1]) * y + containerPadding[1]);
446
- }
447
- }
448
- return out;
449
- }
450
- function calcXY(positionParams, top, left, w, h) {
451
- const { containerMargin: margin, cols, rowHeight, maxRows } = positionParams;
452
- const colWidth = calcGridColWidth(positionParams);
453
- let x = Math.round((left - margin[0]) / (colWidth + margin[0]));
454
- let y = Math.round((top - margin[1]) / (rowHeight + margin[1]));
455
- x = clamp(x, 0, cols - w);
456
- y = clamp(y, 0, maxRows - h);
457
- return { x, y };
458
- }
459
- function calcWH(positionParams, width, height, x, y) {
460
- const { containerMargin: margin, maxRows, cols, rowHeight } = positionParams;
461
- const colWidth = calcGridColWidth(positionParams);
462
- let w = Math.round((width + margin[0]) / (colWidth + margin[0]));
463
- let h = Math.round((height + margin[1]) / (rowHeight + margin[1]));
464
- w = clamp(w, 0, cols - x);
465
- h = clamp(h, 0, maxRows - y);
466
- return { w, h };
467
- }
468
- function clamp(num, lowerBound, upperBound) {
469
- return Math.max(Math.min(num, upperBound), lowerBound);
470
- }
471
- const gridLayoutClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
472
- /* elements */
473
- "root",
474
- "gridItemRoot",
475
- "gridItemType",
476
- "gridItemPlaceholder",
477
- "gridItemFreeMove",
478
- /* states or variants of elements */
479
- "maximizeMe",
480
- "maximizeOther",
481
- "colapsed",
482
- "resizeHide",
483
- "invisible",
484
- "cssTransforms",
485
- "resizing",
486
- "dragging",
487
- "static"
488
- ]);
489
- function GridLayout(props) {
490
- const {
491
- layoutItemRender,
492
- innerRef,
493
- //Referencia requerida por el provedor WidthProvider para detectar los cambios de tamaño
494
- autoSize = true,
495
- cols = DEFAULT_COLS,
496
- containerPadding = DEFAULT_CONTAINER_PADDING,
497
- margin = DEFAULT_MARGIN,
498
- rowHeight = DEFAULT_ROW_HEIGHT,
499
- colapsedHeight = DEFAULT_COLAPSED_HEIGHT,
500
- containerWidth = DEFAULT_CONTAINER_WIDTH,
501
- containerHeight = DEFAULT_CONTAINER_HEIGHT,
502
- transformScale = DEFAULT_TRANSFORM_SCALE,
503
- className = "",
504
- style = {},
505
- draggableHandle = "",
506
- draggableCancel = "",
507
- maxRows = Infinity,
508
- // infinite vertical growth
509
- layout = [],
510
- isBounded = false,
511
- isDraggable = true,
512
- isResizable = true,
513
- allowOverlap = false,
514
- useCSSTransforms = true,
515
- compactType = "vertical",
516
- preventCollision = false,
517
- resizeHandles = ["se"],
518
- resizeHandle,
519
- maximizeId,
520
- onLayoutChange = noop,
521
- onDragStart = noop,
522
- onDrag = noop,
523
- onDragStop = noop,
524
- onResizeStart = noop,
525
- onResize = noop,
526
- onResizeStop = noop
527
- } = props;
528
- const [currentState, setCurrentState] = useState({
529
- mounted: false
530
- });
531
- const [nrOnlayoutChanges, setNrOnlayoutChanges] = useState(0);
532
- const [finalLayoutRender, setFinalLayoutRender] = useState(layout);
533
- const [zIndexes, setzIndexes] = useState(() => {
534
- return layout.filter((li) => li.freeMove).map((lmap) => lmap.i);
535
- });
536
- const refState = useRef({
537
- layout,
538
- oldDragItem: void 0,
539
- oldLayout: void 0,
540
- oldResizeItem: void 0,
541
- zIndexes,
542
- colapsedHeight,
543
- rowHeight
544
- });
545
- refState.current.colapsedHeight = colapsedHeight;
546
- refState.current.rowHeight = rowHeight;
547
- useEffect(() => {
548
- setCurrentState({ mounted: true });
549
- }, []);
550
- useEffect(() => {
551
- if (nrOnlayoutChanges > 0) {
552
- onLayoutChange(refState.current.layout);
553
- }
554
- }, [nrOnlayoutChanges]);
555
- useEffect(() => {
556
- if (!isEqualLayout(finalLayoutRender, layout)) {
557
- const newLayout = cloneLayout(layout);
558
- const newzIndexes = [...zIndexes];
559
- for (let index = 0; index < newLayout.length; index++) {
560
- const li = newLayout[index];
561
- if (li.freeMove && newzIndexes.indexOf(li.i) === -1) {
562
- newzIndexes.push(li.i);
563
- }
564
- }
565
- refState.current.layout = newLayout;
566
- setFinalLayoutRender(newLayout);
567
- if (newzIndexes.length !== zIndexes.length) {
568
- setzIndexes(newzIndexes);
569
- refState.current.zIndexes = newzIndexes;
570
- }
571
- }
572
- }, [layout]);
573
- const onLayoutMaybeChanged = useCallback((newLayout, oldLayout) => {
574
- if (!oldLayout) {
575
- oldLayout = refState.current.layout;
576
- }
577
- if (!isEqualLayout(oldLayout, newLayout)) {
578
- setNrOnlayoutChanges((prev) => prev + 1);
579
- }
580
- }, []);
581
- const localOnDragStart = useCallback(
582
- (i, _x, _y, gridDragEvent) => {
583
- const { layout: layout2 } = refState.current;
584
- const { e, node } = gridDragEvent;
585
- const li = getLayoutItem(layout2, i);
586
- if (!li) return;
587
- refState.current = {
588
- ...refState.current,
589
- oldDragItem: cloneLayoutItem(li),
590
- oldLayout: layout2
591
- //Punto de arranque, layout actual
592
- };
593
- if (li && li.freeMove) {
594
- onClickSetOnTopFreeMove(li.i, "onDragStart");
595
- }
596
- if (gridDragEvent.e.type !== "touchmove") {
597
- gridDragEvent.e.preventDefault();
598
- }
599
- gridDragEvent.e.stopPropagation();
600
- return onDragStart(layout2, li, li, void 0, e, node);
601
- },
602
- []
603
- );
604
- const localOnDrag = useCallback(
605
- (i, x, y, gridDragEvent) => {
606
- const { oldDragItem, layout: layout2 } = refState.current;
607
- const { e, node } = gridDragEvent;
608
- const li = getLayoutItem(layout2, i);
609
- if (!li) return;
610
- const newPlaceholder = {
611
- w: li.w,
612
- h: getLayoutItemH(li, refState.current.colapsedHeight, refState.current.rowHeight),
613
- x: li.x,
614
- y: li.y,
615
- placeholder: true,
616
- i
617
- };
618
- const isUserAction = true;
619
- try {
620
- let newLayout;
621
- if (!li.freeMove) {
622
- newLayout = moveElement(
623
- layout2,
624
- li,
625
- x,
626
- y,
627
- isUserAction,
628
- preventCollision,
629
- compactType,
630
- cols,
631
- refState.current.colapsedHeight,
632
- refState.current.rowHeight,
633
- allowOverlap
634
- );
635
- } else {
636
- li.x = x;
637
- li.y = y;
638
- newPlaceholder.x = x;
639
- newPlaceholder.y = y;
640
- newLayout = cloneLayout(layout2);
641
- }
642
- const finalLayout = allowOverlap || li.freeMove ? newLayout : compact(
643
- newLayout,
644
- compactType,
645
- cols,
646
- refState.current.colapsedHeight,
647
- refState.current.rowHeight,
648
- allowOverlap
649
- );
650
- refState.current = {
651
- ...refState.current,
652
- layout: finalLayout,
653
- activeDrag: newPlaceholder
654
- };
655
- setCurrentState((prev) => ({
656
- ...prev,
657
- activeDrag: newPlaceholder
658
- }));
659
- setFinalLayoutRender(finalLayout);
660
- if (gridDragEvent.e.type !== "touchmove") {
661
- gridDragEvent.e.preventDefault();
662
- }
663
- gridDragEvent.e.stopPropagation();
664
- onDrag(newLayout, oldDragItem, li, newPlaceholder, e, node);
665
- } catch (error) {
666
- console.warn("GridLayout error capturado");
667
- }
668
- },
669
- []
670
- );
671
- const localOnDragStop = useCallback(
672
- (i, x, y, { e, node }) => {
673
- if (!refState.current.activeDrag) {
674
- return;
675
- }
676
- const { oldDragItem, layout: layout2, oldLayout } = refState.current;
677
- const li = getLayoutItem(layout2, i);
678
- if (!li) return;
679
- let newLayout;
680
- const isUserAction = true;
681
- if (!li.freeMove) {
682
- newLayout = moveElement(
683
- layout2,
684
- li,
685
- x,
686
- y,
687
- isUserAction,
688
- preventCollision,
689
- compactType,
690
- cols,
691
- refState.current.colapsedHeight,
692
- refState.current.rowHeight,
693
- allowOverlap
694
- );
695
- } else {
696
- li.x = x;
697
- li.y = y;
698
- newLayout = cloneLayout(layout2);
699
- }
700
- const finalLayout = allowOverlap ? newLayout || li.freeMove : compact(
701
- newLayout,
702
- compactType,
703
- cols,
704
- refState.current.colapsedHeight,
705
- refState.current.rowHeight,
706
- allowOverlap
707
- );
708
- setCurrentState((prev) => ({
709
- ...prev,
710
- activeDrag: void 0
711
- }));
712
- setFinalLayoutRender(finalLayout);
713
- refState.current = {
714
- ...refState.current,
715
- layout: finalLayout,
716
- oldDragItem: void 0,
717
- oldLayout: void 0,
718
- activeDrag: void 0
719
- };
720
- if (e.type !== "touchmove") {
721
- e.preventDefault();
722
- }
723
- e.stopPropagation();
724
- onLayoutMaybeChanged(finalLayout, oldLayout);
725
- onDragStop(layout2, oldDragItem, li, void 0, e, node);
726
- },
727
- []
728
- );
729
- const localOnResizeStart = useCallback(
730
- (i, _w, _h, { e, node }) => {
731
- const { layout: layout2 } = refState.current;
732
- const li = getLayoutItem(layout2, i);
733
- if (!li) return;
734
- refState.current = {
735
- ...refState.current,
736
- oldResizeItem: cloneLayoutItem(li),
737
- oldLayout: refState.current.layout
738
- //Punto de arranque, layout actual
739
- };
740
- onResizeStart(layout2, li, li, void 0, e, node);
741
- if (li && li.freeMove) {
742
- onClickSetOnTopFreeMove(li.i, "onResizeStart");
743
- }
744
- },
745
- []
746
- );
747
- const localOnResize = useCallback(
748
- (i, w, h, { e, node }) => {
749
- const { layout: layout2, oldResizeItem } = refState.current;
750
- let newLayout;
751
- let li;
752
- if (!oldResizeItem?.freeMove) {
753
- const cb = (cbLi) => {
754
- let hasCollisions;
755
- if (preventCollision && !allowOverlap) {
756
- const collisions = getAllCollisions(
757
- layout2,
758
- { ...cbLi, w, h },
759
- refState.current.colapsedHeight,
760
- refState.current.rowHeight
761
- ).filter((layoutItem) => layoutItem.i !== cbLi.i);
762
- hasCollisions = collisions.length > 0;
763
- if (hasCollisions) {
764
- let leastX = Infinity, leastY = Infinity;
765
- collisions.forEach((layoutItem) => {
766
- if (layoutItem.x > cbLi.x) leastX = Math.min(leastX, layoutItem.x);
767
- if (layoutItem.y > cbLi.y) leastY = Math.min(leastY, layoutItem.y);
768
- });
769
- if (Number.isFinite(leastX)) cbLi.w = leastX - cbLi.x;
770
- if (Number.isFinite(leastY)) cbLi.h = leastY - cbLi.y;
771
- }
772
- }
773
- if (!hasCollisions) {
774
- cbLi.w = w;
775
- cbLi.h = h;
776
- }
777
- return cbLi;
778
- };
779
- const [tempLayout, tempLi] = withLayoutItem(cloneLayout(layout2), i, cb);
780
- newLayout = tempLayout;
781
- li = tempLi;
782
- } else {
783
- newLayout = cloneLayout(layout2);
784
- li = getLayoutItem(newLayout, i);
785
- if (li) {
786
- li.w = w;
787
- li.h = h;
788
- }
789
- }
790
- if (!li) return;
791
- const newPlaceholder = {
792
- w: li.w,
793
- h: li.h,
794
- x: li.x,
795
- y: li.y,
796
- static: true,
797
- i
798
- };
799
- try {
800
- const finalLayout = allowOverlap || li.freeMove ? newLayout : compact(
801
- newLayout,
802
- compactType,
803
- cols,
804
- refState.current.colapsedHeight,
805
- refState.current.rowHeight,
806
- allowOverlap
807
- );
808
- refState.current = {
809
- ...refState.current,
810
- layout: finalLayout,
811
- activeDrag: newPlaceholder
812
- };
813
- setFinalLayoutRender(finalLayout);
814
- setCurrentState((prev) => ({ ...prev, activeDrag: newPlaceholder }));
815
- onResize(newLayout, oldResizeItem, li, newPlaceholder, e, node);
816
- } catch (error) {
817
- }
818
- if (e.type !== "touchmove") {
819
- e.preventDefault();
820
- }
821
- e.stopPropagation();
822
- },
823
- []
824
- );
825
- const localOnResizeStop = useCallback(
826
- (i, _w, _h, { e, node }) => {
827
- if (!refState.current.activeDrag) {
828
- return;
829
- }
830
- const { layout: layout2, oldResizeItem, oldLayout } = refState.current;
831
- const l = getLayoutItem(layout2, i);
832
- refState.current = {
833
- ...refState.current,
834
- // layout: finalLayout,
835
- oldResizeItem: void 0,
836
- oldLayout: void 0,
837
- activeDrag: void 0
838
- };
839
- setCurrentState((prev) => ({ ...prev, activeDrag: void 0 }));
840
- onLayoutMaybeChanged(layout2, oldLayout);
841
- if (l) {
842
- onResizeStop(layout2, oldResizeItem, l, void 0, e, node);
843
- }
844
- },
845
- []
846
- );
847
- const onClickSetOnTopFreeMove = useCallback((i, _source) => {
848
- const { layout: layout2 } = refState.current;
849
- const index = refState.current.zIndexes.indexOf(i);
850
- const l = getLayoutItem(layout2, i);
851
- if (l && l?.freeMove) {
852
- if (index !== refState.current.zIndexes.length - 1 || index === -1) {
853
- const newIndexes = [...refState.current.zIndexes];
854
- if (index !== -1) {
855
- newIndexes.splice(index, 1);
856
- }
857
- newIndexes.push(i);
858
- refState.current.zIndexes = newIndexes;
859
- setzIndexes(newIndexes);
860
- }
861
- }
862
- }, []);
863
- const placeholder = () => {
864
- const { activeDrag } = currentState;
865
- if (!activeDrag) return null;
866
- return /* @__PURE__ */ jsx(
867
- MemonizedGridItem,
868
- {
869
- type: "placeholder",
870
- layoutItemRender,
871
- w: activeDrag.w,
872
- h: activeDrag.h,
873
- x: activeDrag.x,
874
- y: activeDrag.y,
875
- i: activeDrag.i,
876
- className: gridLayoutClasses.gridItemPlaceholder,
877
- containerWidth,
878
- containerHeight,
879
- cols,
880
- margin,
881
- containerPadding,
882
- maxRows,
883
- rowHeight,
884
- isDraggable: false,
885
- isResizable: false,
886
- isBounded: false,
887
- useCSSTransforms,
888
- transformScale,
889
- draggableCancel: "",
890
- draggableHandle: "",
891
- minW: 0,
892
- maxW: 0,
893
- minH: 0,
894
- maxH: 0,
895
- maximize: "none",
896
- colapsed: activeDrag.colapsed,
897
- colapsedHeight
898
- }
899
- );
900
- };
901
- const processGridItem = useCallback(
902
- (l, isMounted) => {
903
- const draggable = typeof l.isDraggable === "boolean" ? l.isDraggable : !l.static && isDraggable;
904
- const resizable = typeof l.isResizable === "boolean" ? l.isResizable : !l.static && isResizable;
905
- const resizeHandlesOptions = l.resizeHandles || resizeHandles;
906
- const bounded = draggable && isBounded && l.isBounded !== false;
907
- const mximize = maximizeId ? maximizeId === l.i ? "maximize_me" : "maximize_other" : "none";
908
- let zIndex = void 0;
909
- let style2;
910
- if (l.freeMove) {
911
- zIndex = zIndexes.indexOf(l.i);
912
- if (zIndex !== -1) {
913
- zIndex = zIndex + 1;
914
- style2 = { zIndex };
915
- }
916
- }
917
- return /* @__PURE__ */ jsx(
918
- MemonizedGridItem,
919
- {
920
- type: "layoutItem",
921
- layoutItemRender,
922
- containerWidth,
923
- containerHeight,
924
- cols,
925
- margin,
926
- containerPadding: containerPadding || margin,
927
- maxRows,
928
- rowHeight,
929
- draggableCancel,
930
- draggableHandle,
931
- onDragStart: localOnDragStart,
932
- onDrag: localOnDrag,
933
- onDragStop: localOnDragStop,
934
- onResizeStart: localOnResizeStart,
935
- onResize: localOnResize,
936
- onResizeStop: localOnResizeStop,
937
- onFreeMoveClick: l.freeMove ? onClickSetOnTopFreeMove : void 0,
938
- isDraggable: draggable,
939
- isResizable: resizable,
940
- isBounded: bounded,
941
- useCSSTransforms: useCSSTransforms && isMounted,
942
- usePercentages: !isMounted,
943
- transformScale,
944
- w: l.w,
945
- h: l.h,
946
- x: l.x,
947
- y: l.y,
948
- i: l.i,
949
- minH: l.minH,
950
- minW: l.minW,
951
- maxH: l.maxH,
952
- maxW: l.maxW,
953
- static: l.static,
954
- resizeHandles: resizeHandlesOptions,
955
- resizeHandle,
956
- maximize: mximize,
957
- freeMove: l.freeMove,
958
- colapsed: l.colapsed,
959
- visible: l.visible,
960
- colapsedHeight,
961
- style: style2
962
- },
963
- l.i
964
- );
965
- },
966
- [
967
- containerWidth,
968
- containerHeight,
969
- cols,
970
- margin,
971
- containerPadding,
972
- maxRows,
973
- rowHeight,
974
- draggableCancel,
975
- draggableHandle,
976
- isDraggable,
977
- isResizable,
978
- isBounded,
979
- useCSSTransforms,
980
- transformScale,
981
- resizeHandles,
982
- resizeHandle,
983
- maximizeId,
984
- zIndexes,
985
- colapsedHeight,
986
- rowHeight
987
- ]
988
- );
989
- const containerAutoSizeHeight = useCallback(() => {
990
- if (!autoSize) return;
991
- const nbRow = bottom(finalLayoutRender, colapsedHeight, rowHeight);
992
- const containerPaddingY = containerPadding ? containerPadding[1] : margin[1];
993
- return nbRow * rowHeight + (nbRow - 1) * margin[1] + containerPaddingY * 2 + "px";
994
- }, [autoSize, containerPadding, margin, finalLayoutRender, colapsedHeight]);
995
- const mergedStyle = {
996
- height: containerAutoSizeHeight(),
997
- ...style
998
- };
999
- return /* @__PURE__ */ jsxs(
1000
- GridLayoutRoot,
1001
- {
1002
- className: clsx(gridLayoutClasses.root, className),
1003
- style: mergedStyle,
1004
- ref: innerRef,
1005
- children: [
1006
- finalLayoutRender.map((li) => processGridItem(li, !!currentState.mounted)),
1007
- placeholder()
1008
- ]
1009
- }
1010
- );
1011
- }
1012
- export {
1013
- noop as A,
1014
- COMPONENT_CLASS_NAME as C,
1015
- DEFAULT_COLS as D,
1016
- GridLayout as G,
1017
- THROTTLE_RESIZE_TIMEOUT as T,
1018
- calcGridItemWHPx as a,
1019
- calcGridColWidth as b,
1020
- calcXY as c,
1021
- calcWH as d,
1022
- clamp as e,
1023
- calcGridItemPosition as f,
1024
- getH as g,
1025
- gridLayoutClasses as h,
1026
- DEFAULT_ROW_HEIGHT as i,
1027
- DEFAULT_CONTAINER_WIDTH as j,
1028
- DEFAULT_CONTAINER_HEIGHT as k,
1029
- DEFAULT_MARGIN as l,
1030
- DEFAULT_CONTAINER_PADDING as m,
1031
- DEFAULT_TRANSFORM_SCALE as n,
1032
- DEFAULT_COLAPSED_HEIGHT as o,
1033
- perc as p,
1034
- setTopLeft as q,
1035
- cloneLayoutItem as r,
1036
- setTransform as s,
1037
- cloneLayout as t,
1038
- compact as u,
1039
- correctBounds as v,
1040
- isEqualLayout as w,
1041
- DEFAULT_RESPONSIVE_BREAKPOINTS as x,
1042
- DEFAULT_RESPONSIVE_COLS as y,
1043
- isEqualLayouts as z
1044
- };