@m4l/components 3.1.7 → 3.1.9

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 (232) hide show
  1. package/@types/export.d.ts +0 -3
  2. package/@types/types.d.ts +29 -11
  3. package/components/DynamicSort/constants.d.ts +12 -0
  4. package/components/DynamicSort/slots/DynamicSortSlots.d.ts +84 -0
  5. package/components/DynamicSort/slots/SlotsEnum.d.ts +30 -0
  6. package/components/DynamicSort/slots/index.d.ts +2 -0
  7. package/components/DynamicSort/types.d.ts +183 -0
  8. package/components/FieldLabel/types.d.ts +1 -0
  9. package/components/ObjectLogs/types.d.ts +1 -1
  10. package/components/areas/contexts/AreasContext/helper.d.ts +3 -0
  11. package/components/hook-form/RHFTextField/constant.d.ts +1 -0
  12. package/components/hook-form/RHFTextField/index.d.ts +0 -1
  13. package/components/hook-form/RHFTextField/slots/RHFTextFieldEnum.d.ts +7 -0
  14. package/components/hook-form/RHFTextField/slots/RHFTextFieldSlots.d.ts +18 -0
  15. package/components/hook-form/RHFTextField/slots/index.d.ts +2 -0
  16. package/components/hook-form/RHFTextField/subcomponents/Skeleton/types.d.ts +3 -4
  17. package/components/hook-form/RHFTextField/types.d.ts +11 -3
  18. package/helpers/cookies/cookies.d.ts +4 -0
  19. package/helpers/cookies/index.d.ts +1 -0
  20. package/helpers/cookies/types.d.ts +42 -0
  21. package/index.js +180 -340
  22. package/node_modules-CQtkw0uG.js +7350 -0
  23. package/package.json +1 -1
  24. package/styles/DynamicSort.styles.d.ts +2 -0
  25. package/styles/MenuActions.styles.d.ts +1 -1
  26. package/styles/RHFTextField.styles.d.ts +2 -0
  27. package/utils/index.d.ts +1 -1
  28. package/vendor-BDLrgGjq.js +24692 -0
  29. package/components/AccountPopover/index-Dm2-k-Mv.js +0 -334
  30. package/components/AppBar/index-i0rhG3J1.js +0 -93
  31. package/components/BaseModule/index-CiNNlxzS.js +0 -30
  32. package/components/CommonActions/components/ActionCancel/index-CIdpDXkr.js +0 -12
  33. package/components/CommonActions/components/ActionFormCancel/index-CpyASN3q.js +0 -56
  34. package/components/CommonActions/components/ActionFormIntro/index-7KKtcUra.js +0 -33
  35. package/components/CommonActions/components/ActionIntro/index-CqqDZZcG.js +0 -25
  36. package/components/CommonActions/components/Actions/index-CuG1pnXW.js +0 -70
  37. package/components/DataGrid/constants-8L7QgBKi.js +0 -10
  38. package/components/DataGrid/formatters/ColumnBooleanFormatter/index-CveSCbq_.js +0 -26
  39. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-CHqvieM2.js +0 -22
  40. package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
  41. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-DE6bwaKP.js +0 -23
  42. package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
  43. package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
  44. package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
  45. package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
  46. package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
  47. package/components/DataGrid/formatters/index-CrZXPa0e.js +0 -13
  48. package/components/DataGrid/index-BZ-lbmuU.js +0 -908
  49. package/components/DataGrid/subcomponents/Actions/index-CHvPZ4Ru.js +0 -549
  50. package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
  51. package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
  52. package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
  53. package/components/DynamicFilter/dictionary-PrbXU3VZ.js +0 -51
  54. package/components/DynamicFilter/index-DZiJc9h7.js +0 -116
  55. package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
  56. package/components/DynamicFilter/slots/dynamicFilterSlots-DHxelhXP.js +0 -151
  57. package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
  58. package/components/DynamicFilter/store/index-BT-eWVnJ.js +0 -254
  59. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-B32bAzi-.js +0 -60
  60. package/components/DynamicFilter/subcomponents/AppliedFilters/index-Bha19drV.js +0 -26
  61. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BmvzoHit.js +0 -40
  62. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-BcO3SlP5.js +0 -129
  63. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BCJhpNS8.js +0 -171
  64. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-DCNhz68u.js +0 -153
  65. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-BdypjM1Y.js +0 -146
  66. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-D-NFIVnK.js +0 -114
  67. package/components/DynamicFilter/subcomponents/FieldTypes/index-BwQHJqk9.js +0 -38
  68. package/components/DynamicFilter/subcomponents/FilterActions/index-B9UWmk07.js +0 -88
  69. package/components/DynamicFilter/subcomponents/InputFilter/index-CfGb1TfV.js +0 -188
  70. package/components/DynamicFilter/subcomponents/PopoverFilter/index-DkfRGrlO.js +0 -158
  71. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DSegwAm2.js +0 -63
  72. package/components/FieldLabel/index-CI57EizR.js +0 -54
  73. package/components/GridLayout/index-C4HyxNYX.js +0 -1044
  74. package/components/GridLayout/subcomponents/Griditem/index-C7jT4s8t.js +0 -395
  75. package/components/GridLayout/subcomponents/Responsive/index-BKcU2OnF.js +0 -348
  76. package/components/GridLayout/subcomponents/SizeProvider/index-1aJ-e_54.js +0 -71
  77. package/components/HelperText/index-Crn_XIPF.js +0 -50
  78. package/components/Icon/index-C89MAkeH.js +0 -176
  79. package/components/Image/index-COp8vP0X.js +0 -175
  80. package/components/LanguagePopover/index-BA2Igs9L.js +0 -179
  81. package/components/LinearProgressIndeterminate/index-BwI756Mb.js +0 -55
  82. package/components/Loadable/index-BMbi9ISF.js +0 -9
  83. package/components/LoadingError/index-Cf0oGUrL.js +0 -89
  84. package/components/MFIsolationApp/index-V4R55hNU.js +0 -169
  85. package/components/MFLoader/index-BI8vQZSH.js +0 -299
  86. package/components/ModalDialog/index-CEVQBQ7W.js +0 -77
  87. package/components/NavLink/index-D1S_vtFO.js +0 -55
  88. package/components/NoItemSelected/index-B9oM26AX.js +0 -54
  89. package/components/ObjectLogs/index-CiXOJpS4.js +0 -233
  90. package/components/PDFViewer/index-GVN2rfd6.js +0 -51
  91. package/components/Page/index-DZMkYmr4.js +0 -117
  92. package/components/PaperForm/index-DwgAfjci.js +0 -59
  93. package/components/Period/index-2pJG3VmY.js +0 -238
  94. package/components/PrintingSystem/index-B2qcnfw0.js +0 -187
  95. package/components/PrintingSystem/subcomponents/BodyNode/index-Cv2aoy8S.js +0 -49
  96. package/components/PrintingSystem/subcomponents/ChartNode/index-BmJm8v_C.js +0 -105
  97. package/components/PrintingSystem/subcomponents/DividerNode/index-MpFhE-H0.js +0 -20
  98. package/components/PrintingSystem/subcomponents/FooterNode/index-ZEcWdMSM.js +0 -49
  99. package/components/PrintingSystem/subcomponents/GridNode/index-SsKax2xu.js +0 -74
  100. package/components/PrintingSystem/subcomponents/HeaderNode/index-Cs8TOOBL.js +0 -49
  101. package/components/PrintingSystem/subcomponents/PaperNode/index-DBb25Ecg.js +0 -30
  102. package/components/PrintingSystem/subcomponents/PropertyValueNode/index-CTVn7J9Q.js +0 -47
  103. package/components/PrintingSystem/subcomponents/SectionNode/index-iYPM3EaS.js +0 -49
  104. package/components/PrintingSystem/subcomponents/TextBoxNode/index-DGjXCFKJ.js +0 -24
  105. package/components/PropertyValue/index-Bh-Jnrte.js +0 -264
  106. package/components/Resizeable/index-DdP1xfE9.js +0 -20
  107. package/components/ScrollBar/index-f2URPPE2.js +0 -35
  108. package/components/ScrollToTop/index-TxORk5dB.js +0 -12
  109. package/components/SideBar/index-PUBBe0yH.js +0 -758
  110. package/components/SplitLayout/index-Bu1hcO6G.js +0 -89
  111. package/components/ToastContainer/index-DK1d8NNd.js +0 -191
  112. package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
  113. package/components/animate/LoadingScreen/index-CkVLOrMz.js +0 -70
  114. package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
  115. package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
  116. package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
  117. package/components/animate/features-BbnE33u3.js +0 -5
  118. package/components/animate/index-BsWiJfzp.js +0 -89
  119. package/components/animate/variants/bounce-DanQqHAX.js +0 -101
  120. package/components/animate/variants/container-Dmpr6tg5.js +0 -22
  121. package/components/animate/variants/fade-CAOJNn06.js +0 -65
  122. package/components/animate/variants/index-l0sNRNKZ.js +0 -1
  123. package/components/animate/variants/transition-B9W5SWTa.js +0 -20
  124. package/components/areas/components/AreasAdmin/index-OxQU3P8Y.js +0 -699
  125. package/components/areas/components/AreasViewer/index-DQ0aPioP.js +0 -805
  126. package/components/areas/components/index-l0sNRNKZ.js +0 -1
  127. package/components/areas/constants-rqODZNZe.js +0 -6
  128. package/components/areas/contexts/AreasContext/index-BqRlA7JA.js +0 -1110
  129. package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
  130. package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
  131. package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
  132. package/components/areas/dictionary-YUsP9beq.js +0 -36
  133. package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
  134. package/components/areas/hooks/useAreas/index-BSbwbJLS.js +0 -11
  135. package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
  136. package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
  137. package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
  138. package/components/areas/icons-CwFr-alN.js +0 -24
  139. package/components/areas/index-B_Odny9h.js +0 -22
  140. package/components/commercial/AppBarCommercial/index-CHq3P3GY.js +0 -28
  141. package/components/commercial/SectionCommercial/index-BeABGtdr.js +0 -56
  142. package/components/commercial/TopBar/index-F1repmti.js +0 -232
  143. package/components/commercial/index-CxDzs6Ax.js +0 -81
  144. package/components/formatters/BooleanFormatter/index-DktIidqW.js +0 -44
  145. package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
  146. package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
  147. package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
  148. package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
  149. package/components/formatters/index-pnJhDYKe.js +0 -109
  150. package/components/hook-form/HelperError/index-BVnmUazV.js +0 -19
  151. package/components/hook-form/RHFAutocomplete/index-BtPL16HR.js +0 -657
  152. package/components/hook-form/RHFAutocompleteAsync/index-BfzjLHG8.js +0 -226
  153. package/components/hook-form/RHFCheckbox/index-Vyttu8Vx.js +0 -132
  154. package/components/hook-form/RHFColorPicker/index-Cxxb5Wa_.js +0 -191
  155. package/components/hook-form/RHFDateTime/index-CW1Slb-f.js +0 -190
  156. package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
  157. package/components/hook-form/RHFPeriod/index-r-HeIOoZ.js +0 -98
  158. package/components/hook-form/RHFRadioGroup/index-CTD-0zKo.js +0 -52
  159. package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
  160. package/components/hook-form/RHFTextField/classes/constants.d.ts +0 -1
  161. package/components/hook-form/RHFTextField/classes/index.d.ts +0 -8
  162. package/components/hook-form/RHFTextField/classes/types.d.ts +0 -17
  163. package/components/hook-form/RHFTextField/index-B6ufruSB.js +0 -337
  164. package/components/hook-form/RHFTextField/styles.d.ts +0 -3
  165. package/components/hook-form/RHFTextField/subcomponents/Skeleton/styles.d.ts +0 -3
  166. package/components/hook-form/RHFTextField/tests/constants.d.ts +0 -3
  167. package/components/hook-form/RHFTextField/tests/utils.d.ts +0 -2
  168. package/components/hook-form/RHFUpload/index-CDPbm8NR.js +0 -253
  169. package/components/maps/components/GpsTools/index-5MXlhIEt.js +0 -1948
  170. package/components/maps/components/Map/index-2Lx5ARXa.js +0 -2546
  171. package/components/maps/index-Ci-7-FHg.js +0 -7
  172. package/components/modal/WindowBase-Gd27v5FU.js +0 -44
  173. package/components/modal/WindowConfirm-u6vAMFo7.js +0 -73
  174. package/components/modal/index-CydPIpKZ.js +0 -65
  175. package/components/mui_extended/Accordion/index-DMLYJL7o.js +0 -124
  176. package/components/mui_extended/Avatar/index-ClBa-6eF.js +0 -64
  177. package/components/mui_extended/Badge/index-zI-F_Qkq.js +0 -29
  178. package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
  179. package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
  180. package/components/mui_extended/Button/index-CGfZbaea.js +0 -222
  181. package/components/mui_extended/CheckBox-BXUrbonB.js +0 -76
  182. package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
  183. package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
  184. package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
  185. package/components/mui_extended/IconButton/index-CusYFjie.js +0 -97
  186. package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
  187. package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
  188. package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
  189. package/components/mui_extended/MenuActions/MenuActions-C6CjSU6C.js +0 -149
  190. package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
  191. package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
  192. package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
  193. package/components/mui_extended/MenuActions/slots/MenuActionsSlots-D65KZAKF.js +0 -46
  194. package/components/mui_extended/Pager/index-DCbxiTZA.js +0 -257
  195. package/components/mui_extended/Popover/index-DfrJAQkV.js +0 -153
  196. package/components/mui_extended/Stack/index-DzEeCYfp.js +0 -31
  197. package/components/mui_extended/Tab/index-Bu3dPidV.js +0 -129
  198. package/components/mui_extended/ToggleButton/index-C9cBkT1V.js +0 -18
  199. package/components/mui_extended/ToggleIconButton/index--0b3Td6C.js +0 -26
  200. package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
  201. package/components/mui_extended/Typography/index-Cf_4Zw8f.js +0 -54
  202. package/components/mui_extended/index-l0sNRNKZ.js +0 -1
  203. package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
  204. package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
  205. package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
  206. package/components/popups/PopupsViewer/index-BecevSns.js +0 -172
  207. package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
  208. package/components/popups/PopupsViewer/slots/popupsViewerSlots-BXH77nCF.js +0 -46
  209. package/components/popups/index-l0sNRNKZ.js +0 -1
  210. package/contexts/ModalContext/index-CPfNnfTL.js +0 -39
  211. package/contexts/RHFormContext/index-D_nK759o.js +0 -78
  212. package/hocs/withToggle/index-C1_DMZD3.js +0 -14
  213. package/hooks/useFormAddEdit/index-D9oSjUn1.js +0 -90
  214. package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
  215. package/hooks/useModal/index-BJSQOX3U.js +0 -10
  216. package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
  217. package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
  218. package/hooks/useTab/index-B_GEQFOP.js +0 -12
  219. package/react-data-grid-BfYuZ6AK.js +0 -2606
  220. package/react-draggable-DsCPdgQP.js +0 -811
  221. package/react-json-view-bhqIAaNg.js +0 -2576
  222. package/react-resizable-eBbFl2dX.js +0 -618
  223. package/react-spinners-TpKN9lZg.js +0 -123
  224. package/react-splitter-layout-C-JTsNGs.js +0 -158
  225. package/styles/DynamicFilter-CJFsIegc.js +0 -319
  226. package/styles/MenuActions-lTi-ynPM.js +0 -42
  227. package/styles/index-DKj6m8SL.js +0 -1691
  228. package/test/constants_no_mock-CF-669v-.js +0 -4
  229. package/test/getNameDataTestId-BaBTWhBr.js +0 -10
  230. package/utils/index-DiMrtgIu.js +0 -502
  231. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
  232. /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
- };