@m4l/components 3.1.6 → 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 (203) hide show
  1. package/components/mui_extended/IconButton/index.d.ts +1 -1
  2. package/components/mui_extended/MenuActions/slots/MenuActionsSlots.d.ts +2 -4
  3. package/index.js +183 -339
  4. package/node_modules-CQtkw0uG.js +7350 -0
  5. package/package.json +1 -1
  6. package/vendor-AfIOyqRr.js +24636 -0
  7. package/components/AccountPopover/index-BdnzI23R.js +0 -334
  8. package/components/AppBar/index-Dvrx1jsr.js +0 -93
  9. package/components/BaseModule/index-BQ2UIUCy.js +0 -30
  10. package/components/CommonActions/components/ActionCancel/index-DSVEMl41.js +0 -12
  11. package/components/CommonActions/components/ActionFormCancel/index-DMsGH0wx.js +0 -56
  12. package/components/CommonActions/components/ActionFormIntro/index-C8zb7R3W.js +0 -33
  13. package/components/CommonActions/components/ActionIntro/index-BNIG3KAH.js +0 -25
  14. package/components/CommonActions/components/Actions/index-90JsZTzb.js +0 -70
  15. package/components/DataGrid/constants-8L7QgBKi.js +0 -10
  16. package/components/DataGrid/formatters/ColumnBooleanFormatter/index-ZsSxUL_T.js +0 -26
  17. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-D-gZpvcm.js +0 -22
  18. package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
  19. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-kZGiDU5k.js +0 -23
  20. package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
  21. package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
  22. package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
  23. package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
  24. package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
  25. package/components/DataGrid/formatters/index-iKq2iRoa.js +0 -13
  26. package/components/DataGrid/index-DGHnRo8z.js +0 -908
  27. package/components/DataGrid/subcomponents/Actions/index-BhBvobKS.js +0 -549
  28. package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
  29. package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
  30. package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
  31. package/components/DynamicFilter/dictionary-D9Z9YGDb.js +0 -51
  32. package/components/DynamicFilter/index-CRmtRWlr.js +0 -116
  33. package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
  34. package/components/DynamicFilter/slots/dynamicFilterSlots-CQiB8TmY.js +0 -151
  35. package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
  36. package/components/DynamicFilter/store/index-DoIifWTk.js +0 -254
  37. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-DQESCg04.js +0 -60
  38. package/components/DynamicFilter/subcomponents/AppliedFilters/index-CGmflaoY.js +0 -26
  39. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BfH6YHNi.js +0 -40
  40. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-Dv3KjuYK.js +0 -129
  41. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BnhNICK4.js +0 -171
  42. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-CNN6DeHY.js +0 -153
  43. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-C2dNPFtM.js +0 -146
  44. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-B03ahaU6.js +0 -114
  45. package/components/DynamicFilter/subcomponents/FieldTypes/index-EF7A6WnZ.js +0 -38
  46. package/components/DynamicFilter/subcomponents/FilterActions/index-CQtA2ELu.js +0 -88
  47. package/components/DynamicFilter/subcomponents/InputFilter/index-EXbXDSZA.js +0 -188
  48. package/components/DynamicFilter/subcomponents/PopoverFilter/index-BX8YCh9v.js +0 -158
  49. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DvAYf5-a.js +0 -63
  50. package/components/FieldLabel/index-C8od8D0w.js +0 -54
  51. package/components/GridLayout/index-EPw3AYiQ.js +0 -1044
  52. package/components/GridLayout/subcomponents/Griditem/index-B8Q7iMhr.js +0 -395
  53. package/components/GridLayout/subcomponents/Responsive/index-D6BbBdVx.js +0 -348
  54. package/components/GridLayout/subcomponents/SizeProvider/index-OhbtnEN4.js +0 -71
  55. package/components/HelperText/index-sLK3dYG0.js +0 -50
  56. package/components/Icon/index-BJF_0F6d.js +0 -176
  57. package/components/Image/index-BxphCFC7.js +0 -175
  58. package/components/LanguagePopover/index-CkKie1Ph.js +0 -179
  59. package/components/LinearProgressIndeterminate/index-CTvXOPRx.js +0 -55
  60. package/components/Loadable/index-BMbi9ISF.js +0 -9
  61. package/components/LoadingError/index-BaaPhmyF.js +0 -89
  62. package/components/MFIsolationApp/index-BfHLGDcN.js +0 -169
  63. package/components/MFLoader/index-B8FmSpE7.js +0 -299
  64. package/components/ModalDialog/index-WSVr5sZr.js +0 -77
  65. package/components/NavLink/index-CKgi5l5M.js +0 -55
  66. package/components/NoItemSelected/index-BKsZKc_f.js +0 -54
  67. package/components/ObjectLogs/index-BJkjYQaa.js +0 -233
  68. package/components/PDFViewer/index-Cnbioqzo.js +0 -51
  69. package/components/Page/index-DSSwuNSp.js +0 -117
  70. package/components/PaperForm/index-C1OKDnuY.js +0 -59
  71. package/components/Period/index-DYE7Bj45.js +0 -238
  72. package/components/PrintingSystem/index-BkfHXcTV.js +0 -187
  73. package/components/PrintingSystem/subcomponents/BodyNode/index-Btg2zXVQ.js +0 -49
  74. package/components/PrintingSystem/subcomponents/ChartNode/index-GLjhqKd2.js +0 -105
  75. package/components/PrintingSystem/subcomponents/DividerNode/index-D9T1MWQd.js +0 -20
  76. package/components/PrintingSystem/subcomponents/FooterNode/index-C3LET1ZY.js +0 -49
  77. package/components/PrintingSystem/subcomponents/GridNode/index-BPz7lGvC.js +0 -74
  78. package/components/PrintingSystem/subcomponents/HeaderNode/index-DY4Yci1r.js +0 -49
  79. package/components/PrintingSystem/subcomponents/PaperNode/index-BYoGJll5.js +0 -30
  80. package/components/PrintingSystem/subcomponents/PropertyValueNode/index-vFZ5Skyl.js +0 -47
  81. package/components/PrintingSystem/subcomponents/SectionNode/index-BNqGWpcj.js +0 -49
  82. package/components/PrintingSystem/subcomponents/TextBoxNode/index-wgdfWbfF.js +0 -24
  83. package/components/PropertyValue/index-dwO3Qo0Y.js +0 -264
  84. package/components/Resizeable/index-CHseEYjL.js +0 -20
  85. package/components/ScrollBar/index-BYMy_qJE.js +0 -35
  86. package/components/ScrollToTop/index-TxORk5dB.js +0 -12
  87. package/components/SideBar/index-DqKD_S9_.js +0 -758
  88. package/components/SplitLayout/index-D4lxi0ig.js +0 -89
  89. package/components/ToastContainer/index-jnQcIcV1.js +0 -191
  90. package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
  91. package/components/animate/LoadingScreen/index-CTGGa4Yt.js +0 -70
  92. package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
  93. package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
  94. package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
  95. package/components/animate/features-BbnE33u3.js +0 -5
  96. package/components/animate/index-9dC9NmWv.js +0 -89
  97. package/components/animate/variants/bounce-DanQqHAX.js +0 -101
  98. package/components/animate/variants/container-Dmpr6tg5.js +0 -22
  99. package/components/animate/variants/fade-CAOJNn06.js +0 -65
  100. package/components/animate/variants/index-l0sNRNKZ.js +0 -1
  101. package/components/animate/variants/transition-B9W5SWTa.js +0 -20
  102. package/components/areas/components/AreasAdmin/index-BU9AX60_.js +0 -699
  103. package/components/areas/components/AreasViewer/index-CPlZxIzK.js +0 -805
  104. package/components/areas/components/index-l0sNRNKZ.js +0 -1
  105. package/components/areas/constants-rqODZNZe.js +0 -6
  106. package/components/areas/contexts/AreasContext/index-DGguLxcX.js +0 -1110
  107. package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
  108. package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
  109. package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
  110. package/components/areas/dictionary-YUsP9beq.js +0 -36
  111. package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
  112. package/components/areas/hooks/useAreas/index-DBXtbtIu.js +0 -11
  113. package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
  114. package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
  115. package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
  116. package/components/areas/icons-CwFr-alN.js +0 -24
  117. package/components/areas/index-B_Odny9h.js +0 -22
  118. package/components/commercial/AppBarCommercial/index-faX1fxjn.js +0 -28
  119. package/components/commercial/SectionCommercial/index-Dspd2Hd7.js +0 -56
  120. package/components/commercial/TopBar/index-zACdM_C0.js +0 -232
  121. package/components/commercial/index-9P0yOdH4.js +0 -81
  122. package/components/formatters/BooleanFormatter/index-PoFZ3r_m.js +0 -44
  123. package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
  124. package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
  125. package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
  126. package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
  127. package/components/formatters/index-CEJ6VCMb.js +0 -109
  128. package/components/hook-form/HelperError/index-DRvAkpwm.js +0 -19
  129. package/components/hook-form/RHFAutocomplete/index-DS57m8AX.js +0 -657
  130. package/components/hook-form/RHFAutocompleteAsync/index-Bu6NYmG_.js +0 -226
  131. package/components/hook-form/RHFCheckbox/index-BsB42rRc.js +0 -132
  132. package/components/hook-form/RHFColorPicker/index-Dox0FPrV.js +0 -191
  133. package/components/hook-form/RHFDateTime/index-ef19Az1N.js +0 -190
  134. package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
  135. package/components/hook-form/RHFPeriod/index-DyRLTD0w.js +0 -98
  136. package/components/hook-form/RHFRadioGroup/index-pgTLVF9t.js +0 -52
  137. package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
  138. package/components/hook-form/RHFTextField/index-BgsElxUF.js +0 -337
  139. package/components/hook-form/RHFUpload/index-B6m3ypzh.js +0 -253
  140. package/components/maps/components/GpsTools/index-CeLi75XZ.js +0 -1948
  141. package/components/maps/components/Map/index-D4B8Lfgv.js +0 -2545
  142. package/components/maps/index-Ci-7-FHg.js +0 -7
  143. package/components/modal/WindowBase-CkftshqR.js +0 -44
  144. package/components/modal/WindowConfirm-C5YnzF-B.js +0 -73
  145. package/components/modal/index-CydPIpKZ.js +0 -65
  146. package/components/mui_extended/Accordion/index-jF2uxSmi.js +0 -124
  147. package/components/mui_extended/Avatar/index-CHmsrmfc.js +0 -64
  148. package/components/mui_extended/Badge/index-B_BGIjkQ.js +0 -29
  149. package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
  150. package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
  151. package/components/mui_extended/Button/index-CgvCim_g.js +0 -222
  152. package/components/mui_extended/CheckBox-H73kpinr.js +0 -76
  153. package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
  154. package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
  155. package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
  156. package/components/mui_extended/IconButton/index-B8lOMybH.js +0 -117
  157. package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
  158. package/components/mui_extended/IconButton/types-l0sNRNKZ.js +0 -1
  159. package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
  160. package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
  161. package/components/mui_extended/MenuActions/MenuActions-DA_aS7o5.js +0 -149
  162. package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
  163. package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
  164. package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
  165. package/components/mui_extended/MenuActions/slots/MenuActionsSlots-BVp0M8fu.js +0 -47
  166. package/components/mui_extended/Pager/index-Dtk4aUiU.js +0 -257
  167. package/components/mui_extended/Popover/index-Dl1PwIS2.js +0 -153
  168. package/components/mui_extended/Stack/index-CRzpVi2a.js +0 -31
  169. package/components/mui_extended/Tab/index-DmrsMLOq.js +0 -129
  170. package/components/mui_extended/ToggleButton/index-CAnHC1N-.js +0 -18
  171. package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
  172. package/components/mui_extended/Typography/index-DXq1fG8k.js +0 -54
  173. package/components/mui_extended/index-l0sNRNKZ.js +0 -1
  174. package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
  175. package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
  176. package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
  177. package/components/popups/PopupsViewer/index-CMI1SK_O.js +0 -172
  178. package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
  179. package/components/popups/PopupsViewer/slots/popupsViewerSlots-DOkmuvnx.js +0 -46
  180. package/components/popups/index-l0sNRNKZ.js +0 -1
  181. package/contexts/ModalContext/index-Bp_s1qUm.js +0 -39
  182. package/contexts/RHFormContext/index-BQ0XWrpK.js +0 -78
  183. package/hocs/withToggle/index-C1_DMZD3.js +0 -14
  184. package/hooks/useFormAddEdit/index-dLVQB7hC.js +0 -90
  185. package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
  186. package/hooks/useModal/index-69rbrQ0v.js +0 -10
  187. package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
  188. package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
  189. package/hooks/useTab/index-DYRxOmMI.js +0 -12
  190. package/react-data-grid-BfYuZ6AK.js +0 -2606
  191. package/react-draggable-DsCPdgQP.js +0 -811
  192. package/react-json-view-bhqIAaNg.js +0 -2576
  193. package/react-resizable-eBbFl2dX.js +0 -618
  194. package/react-spinners-TpKN9lZg.js +0 -123
  195. package/react-splitter-layout-C-JTsNGs.js +0 -158
  196. package/styles/DynamicFilter-CJFsIegc.js +0 -319
  197. package/styles/MenuActions-lTi-ynPM.js +0 -42
  198. package/styles/index-CqpubQQr.js +0 -1691
  199. package/test/constants_no_mock-CF-669v-.js +0 -4
  200. package/test/getNameDataTestId-BaBTWhBr.js +0 -10
  201. package/utils/index-DiMrtgIu.js +0 -502
  202. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
  203. /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-B8Q7iMhr.js";
5
- import { G as GridLayoutRoot } from "../../styles/index-CqpubQQr.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
- };