@m4l/components 0.1.42 → 0.1.44

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 (251) hide show
  1. package/@types/types.d.ts +117 -0
  2. package/components/CmpDisenoTest/index.d.ts +4 -0
  3. package/components/CmpDisenoTest/types.d.ts +20 -0
  4. package/components/CommonActions/components/ActionCancel/{index.9230c57b.js → index.a81752ef.js} +1 -1
  5. package/components/CommonActions/components/ActionFormCancel/{index.ab514bd9.js → index.82569769.js} +25 -9
  6. package/components/CommonActions/components/ActionIntro/{index.a0a341c7.js → index.d567aebb.js} +1 -1
  7. package/components/CommonActions/components/Actions/{index.d3e1f36e.js → index.c8754d33.js} +19 -8
  8. package/components/DataGrid/formatters/columnConcatenatedValueFormatter/index.d.ts +3 -0
  9. package/components/DataGrid/formatters/columnConcatenatedValueFormatter/types.d.ts +6 -0
  10. package/components/DataGrid/formatters/index.d.ts +1 -0
  11. package/components/DataGrid/{index.67260455.js → index.fd736623.js} +42 -15
  12. package/components/DynamicFilter/contexts/BaseContext/types.d.ts +3 -0
  13. package/components/DynamicFilter/{index.071aa795.js → index.4c43cc99.js} +208 -110
  14. package/components/DynamicFilter/index.d.ts +4 -1
  15. package/components/DynamicFilter/styles.d.ts +4 -6
  16. package/components/DynamicFilter/subcomponents/PopupEditFilter/styles.d.ts +7 -0
  17. package/components/DynamicFilter/types.d.ts +4 -0
  18. package/components/DynamicFilter/utils/Clases/index.d.ts +20 -0
  19. package/components/DynamicFilter/utils/Clases/types.d.ts +17 -0
  20. package/components/ErrorLabel/index.73f9362c.js +65 -0
  21. package/components/ErrorLabel/index.d.ts +8 -1
  22. package/components/ErrorLabel/styles.d.ts +1 -1
  23. package/components/ErrorLabel/types.d.ts +2 -1
  24. package/components/ErrorLabel/utils/Clases/index.d.ts +6 -0
  25. package/components/ErrorLabel/utils/Clases/types.d.ts +3 -0
  26. package/components/Icon/Icon.d.ts +8 -0
  27. package/components/Icon/classes/constants.d.ts +1 -0
  28. package/components/Icon/classes/index.d.ts +9 -0
  29. package/components/Icon/classes/types.d.ts +17 -0
  30. package/components/Icon/index.d.ts +2 -3
  31. package/components/Icon/{index.8d754623.js → index.f6e8d810.js} +58 -11
  32. package/components/Icon/styles.d.ts +1 -1
  33. package/components/Icon/types.d.ts +5 -0
  34. package/components/Image/Image.d.ts +9 -0
  35. package/components/Image/{index.93d5f37f.js → index.aa24e982.js} +107 -43
  36. package/components/Image/index.d.ts +2 -4
  37. package/components/Image/styles.d.ts +2 -2
  38. package/components/Image/subcomponents/LazyLoadComponent/index.d.ts +5 -0
  39. package/components/Image/subcomponents/LazyLoadComponent/styles.d.ts +2 -0
  40. package/components/Image/types.d.ts +17 -1
  41. package/components/Image/utils/classes/constant.d.ts +1 -0
  42. package/components/Image/utils/classes/index.d.ts +12 -0
  43. package/components/Image/utils/classes/types.d.ts +9 -0
  44. package/components/LanguagePopover/LanguagePopover.d.ts +8 -0
  45. package/components/LanguagePopover/classes/constants.d.ts +1 -0
  46. package/components/LanguagePopover/classes/index.d.ts +9 -0
  47. package/components/LanguagePopover/classes/types.d.ts +7 -0
  48. package/components/LanguagePopover/{index.cbc4b282.js → index.26b694ef.js} +57 -16
  49. package/components/LanguagePopover/index.d.ts +2 -2
  50. package/components/LanguagePopover/styles.d.ts +1 -0
  51. package/components/LanguagePopover/types.d.ts +9 -0
  52. package/components/ModalDialog/{index.a684827f.js → index.d605b574.js} +5 -5
  53. package/components/NoItemSelected/{index.46d2f632.js → index.9636ec8a.js} +1 -1
  54. package/components/NoItemSelected/styles.d.ts +1 -1
  55. package/components/ObjectLogs/{index.4a859658.js → index.91d29e9e.js} +22 -11
  56. package/components/PaperForm/{index.c5948756.js → index.0114aa9b.js} +1 -1
  57. package/components/Period/{index.abe445bd.js → index.c439d1ed.js} +20 -9
  58. package/components/Resizeable/{index.c96c0f09.js → index.8a442a8b.js} +1 -1
  59. package/components/areas/components/Area/types.d.ts +24 -12
  60. package/components/areas/components/AreasAdmin/{index.6794b22f.js → index.7a526b73.js} +24 -15
  61. package/components/areas/components/AreasContainer/{index.a2f8899b.js → index.ca690110.js} +9 -10
  62. package/components/areas/components/GridLayout/{index.b9c1e846.js → index.4fb84fff.js} +28 -18
  63. package/components/areas/components/Window/{index.252fbf4e.js → index.76143c30.js} +105 -85
  64. package/components/areas/components/Window/styles.d.ts +5 -2
  65. package/components/areas/components/Window/subcomponents/InnerForHooks/index.d.ts +4 -0
  66. package/components/areas/components/Window/subcomponents/InnerForHooks/styles.d.ts +2 -0
  67. package/components/areas/components/Window/subcomponents/{Component → InnerForHooks/subcomponents/Component}/index.d.ts +4 -3
  68. package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/index.d.ts +1 -1
  69. package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/index.d.ts +1 -1
  70. package/components/areas/components/Window/subcomponents/InnerForHooks/subcomponents/MicroFrontend/types.d.ts +8 -0
  71. package/components/areas/components/WindowPopUp/index.33bc0a5a.js +117 -0
  72. package/components/areas/components/WindowPopUp/index.d.ts +2 -1
  73. package/components/areas/components/{index.7d6cd649.js → index.4b828081.js} +18 -13
  74. package/components/areas/components/index.d.ts +2 -1
  75. package/components/areas/contexts/AreaContext/helper.d.ts +12 -0
  76. package/components/areas/contexts/AreaContext/index.d.ts +2 -2
  77. package/components/areas/contexts/AreaContext/index.ec85aee7.js +392 -0
  78. package/components/areas/contexts/AreaContext/store.d.ts +49 -0
  79. package/components/areas/contexts/AreaContext/types.d.ts +8 -16
  80. package/components/areas/contexts/AreasContext/index.d.ts +10 -2
  81. package/components/areas/contexts/AreasContext/index.e65fd347.js +204 -0
  82. package/components/areas/contexts/AreasContext/store.d.ts +38 -0
  83. package/components/areas/contexts/AreasContext/types.d.ts +1 -13
  84. package/components/areas/contexts/DynamicMFParmsContext/index.c19cb8cc.js +43 -0
  85. package/components/areas/contexts/DynamicMFParmsContext/index.d.ts +13 -4
  86. package/components/areas/contexts/DynamicMFParmsContext/store.d.ts +20 -0
  87. package/components/areas/contexts/DynamicMFParmsContext/types.d.ts +4 -16
  88. package/components/areas/contexts/WindowContext/helper.d.ts +1 -0
  89. package/components/areas/contexts/WindowContext/index.d.ts +13 -0
  90. package/components/areas/contexts/WindowContext/store.d.ts +31 -0
  91. package/components/areas/contexts/WindowContext/types.d.ts +5 -0
  92. package/components/areas/contexts/WindowToolsMFContext/index.d.ts +6 -0
  93. package/components/areas/contexts/WindowToolsMFContext/types.d.ts +21 -0
  94. package/components/areas/contexts/index.137257b8.js +203 -0
  95. package/components/areas/contexts/index.d.ts +4 -1
  96. package/components/areas/hooks/index.b8c93059.js +27 -0
  97. package/components/areas/hooks/index.d.ts +2 -0
  98. package/components/areas/hooks/useArea/index.89306f6a.js +20 -0
  99. package/components/areas/hooks/useArea/index.d.ts +2 -0
  100. package/components/areas/hooks/useAreas/index.d.ts +11 -1
  101. package/components/areas/hooks/useDynamicMFParameters/index.041a666b.js +14 -0
  102. package/components/areas/hooks/useDynamicMFParameters/index.d.ts +11 -1
  103. package/components/areas/hooks/useWindow/index.d.ts +11 -0
  104. package/components/areas/hooks/useWindowToolsMF/index.d.ts +1 -0
  105. package/components/areas/index.a2586fb3.js +21 -0
  106. package/components/areas/index.d.ts +1 -0
  107. package/components/formatters/BooleanFormatter/{index.3a9b16c8.js → index.b3fb8a75.js} +1 -1
  108. package/components/formatters/ConcatenatedFormatter/index.d.ts +8 -0
  109. package/components/formatters/ConcatenatedFormatter/types.d.ts +11 -0
  110. package/components/formatters/PeriodFormatter/index.d.ts +8 -0
  111. package/components/formatters/PeriodFormatter/types.d.ts +13 -0
  112. package/components/formatters/dictionary.d.ts +9 -0
  113. package/components/formatters/index.0368bab3.js +127 -0
  114. package/components/formatters/index.d.ts +2 -0
  115. package/components/hook-form/RHFAutocomplete/{index.de93fe01.js → index.74add0d0.js} +1 -1
  116. package/components/hook-form/RHFAutocompleteAsync/{index.ca696cce.js → index.0aa3c224.js} +1 -1
  117. package/components/hook-form/RHFCheckbox/RHFCheckbox.d.ts +8 -0
  118. package/components/hook-form/RHFCheckbox/classes/index.d.ts +7 -0
  119. package/components/hook-form/RHFCheckbox/classes/types.d.ts +5 -0
  120. package/components/hook-form/RHFCheckbox/index.ebfe1e3c.js +110 -0
  121. package/components/hook-form/RHFCheckbox/styles.d.ts +14 -0
  122. package/components/hook-form/RHFCheckbox/subcomponents/Skeleton/index.d.ts +2 -1
  123. package/components/hook-form/RHFCheckbox/subcomponents/Skeleton/types.d.ts +3 -0
  124. package/components/hook-form/RHFPeriod/{index.3772295b.js → index.3c5e5fb7.js} +2 -2
  125. package/components/hook-form/RHFTextField/RHFTextField.d.ts +8 -0
  126. package/components/hook-form/RHFTextField/classes/constants.d.ts +1 -0
  127. package/components/hook-form/RHFTextField/classes/index.d.ts +7 -0
  128. package/components/hook-form/RHFTextField/classes/types.d.ts +10 -0
  129. package/components/hook-form/RHFTextField/index.57f138f7.js +219 -0
  130. package/components/hook-form/RHFTextField/index.d.ts +2 -3
  131. package/components/hook-form/RHFTextField/styles.d.ts +3 -0
  132. package/components/hook-form/RHFTextField/subcomponents/Skeleton/types.d.ts +6 -1
  133. package/components/hook-form/RHFTextField/types.d.ts +0 -1
  134. package/components/hook-form/RHFTextFieldPassword/RHFTextFieldPassword.d.ts +9 -0
  135. package/components/hook-form/RHFTextFieldPassword/classes/index.d.ts +6 -0
  136. package/components/hook-form/RHFTextFieldPassword/classes/types.d.ts +4 -0
  137. package/components/hook-form/RHFTextFieldPassword/index.d.ts +2 -3
  138. package/components/hook-form/RHFTextFieldPassword/styles.d.ts +2 -0
  139. package/components/hook-form/RHFUpload/{index.d5cc7c13.js → index.7fdff30f.js} +1 -1
  140. package/components/hook-form/index.d.ts +3 -3
  141. package/components/index.d.ts +3 -2
  142. package/components/modal/{WindowBase.04439b8e.js → WindowBase.ff74f597.js} +3 -4
  143. package/components/modal/{WindowConfirm.0b8a6818.js → WindowConfirm.f2cc1072.js} +22 -11
  144. package/components/modal/index.f62c55c7.js +29 -0
  145. package/components/mui_extended/Accordion/{index.a541c71c.js → index.1d513477.js} +2 -2
  146. package/components/mui_extended/Button/Button.d.ts +8 -0
  147. package/components/mui_extended/Button/classes/constants.d.ts +1 -0
  148. package/components/mui_extended/Button/classes/index.d.ts +7 -0
  149. package/components/mui_extended/Button/classes/types.d.ts +5 -0
  150. package/components/mui_extended/Button/index.8406ed5b.js +150 -0
  151. package/components/mui_extended/Button/index.d.ts +2 -3
  152. package/components/mui_extended/Button/styles.d.ts +13 -0
  153. package/components/mui_extended/IconButton/IconButton.d.ts +9 -0
  154. package/components/mui_extended/IconButton/classes/constants.d.ts +1 -0
  155. package/components/mui_extended/IconButton/classes/index.d.ts +7 -0
  156. package/components/mui_extended/IconButton/classes/types.d.ts +5 -0
  157. package/components/mui_extended/IconButton/index.1318a283.js +100 -0
  158. package/components/mui_extended/IconButton/index.d.ts +2 -4
  159. package/components/mui_extended/IconButton/styles.d.ts +2 -0
  160. package/components/mui_extended/IconButton/subcomponents/SkeletonIconButton/index.d.ts +2 -1
  161. package/components/mui_extended/IconButton/subcomponents/SkeletonIconButton/types.d.ts +3 -0
  162. package/components/mui_extended/ImageButton/ImageButton.d.ts +6 -0
  163. package/components/mui_extended/ImageButton/styles.d.ts +2 -0
  164. package/components/mui_extended/ImageButton/types.d.ts +0 -2
  165. package/components/mui_extended/ImageButton/utils/Clases/constants.d.ts +1 -0
  166. package/components/mui_extended/ImageButton/utils/Clases/index.d.ts +6 -0
  167. package/components/mui_extended/ImageButton/utils/Clases/types.d.ts +3 -0
  168. package/components/mui_extended/MenuActions/{index.ee17bddd.js → index.1261168c.js} +2 -2
  169. package/components/mui_extended/Pager/{index.74d3f5fc.js → index.80ccec47.js} +1 -1
  170. package/components/mui_extended/Popover/Popover.d.ts +9 -0
  171. package/components/mui_extended/Popover/classes/index.d.ts +8 -0
  172. package/components/mui_extended/Popover/classes/types.d.ts +17 -0
  173. package/components/mui_extended/Popover/{index.53c77d23.js → index.58c49cc0.js} +55 -13
  174. package/components/mui_extended/Popover/styles.d.ts +1 -0
  175. package/components/mui_extended/Popover/subcomponts/ArrowIcon/index.d.ts +3 -0
  176. package/components/mui_extended/Popover/types.d.ts +1 -1
  177. package/components/mui_extended/Typography/index.be3a279a.js +63 -0
  178. package/components/mui_extended/Typography/index.d.ts +3 -0
  179. package/components/mui_extended/Typography/styles.d.ts +2 -0
  180. package/components/mui_extended/Typography/utils/Clases/index.d.ts +6 -0
  181. package/components/mui_extended/Typography/utils/Clases/types.d.ts +3 -0
  182. package/components/mui_extended/index.3106c913.js +19 -0
  183. package/components/mui_extended/index.d.ts +5 -4
  184. package/contexts/ModalContext/{index.b90eec94.js → index.4442afd9.js} +1 -1
  185. package/contexts/RHFormContext/{index.d88e6e27.js → index.828b60ad.js} +1 -1
  186. package/contexts/index.d.ts +1 -1
  187. package/hooks/index.d.ts +0 -1
  188. package/hooks/useFormAddEdit/{index.d4845f1a.js → index.15de3ba8.js} +5 -0
  189. package/hooks/useModal/{index.d14edee3.js → index.2f5abe84.js} +1 -1
  190. package/index.js +165 -109
  191. package/package.json +12 -8
  192. package/{react-draggable.84d6b038.js → react-draggable.0eef011c.js} +1 -1
  193. package/{react-resizable.1d00271d.js → react-resizable.bb58c8fc.js} +103 -67
  194. package/utils/{index.899eb67b.js → index.e882b264.js} +26 -18
  195. package/vite-env.d.ts +2 -1
  196. package/components/DynamicFilter/components/PopupEditFilter/styles.d.ts +0 -6
  197. package/components/ErrorLabel/index.c8615f16.js +0 -20
  198. package/components/areas/components/Window/contexts/WindowContext/index.d.ts +0 -5
  199. package/components/areas/components/Window/contexts/WindowContext/types.d.ts +0 -13
  200. package/components/areas/components/Window/hooks/useWindow/index.d.ts +0 -1
  201. package/components/areas/components/WindowPopUp/index.214cf099.js +0 -120
  202. package/components/areas/components/WindowPopUp/styles.d.ts +0 -2
  203. package/components/areas/contexts/AreaContext/index.4894cf23.js +0 -286
  204. package/components/areas/contexts/AreasContext/index.cd8e4bee.js +0 -158
  205. package/components/areas/contexts/DynamicMFParmsContext/index.668bc2e2.js +0 -17
  206. package/components/areas/contexts/index.f9196fb2.js +0 -1
  207. package/components/areas/hooks/useArea/index.9b85ce24.js +0 -19
  208. package/components/areas/hooks/useDynamicMFParameters/index.e6a44ae3.js +0 -11
  209. package/components/areas/index.d1bf612c.js +0 -16
  210. package/components/formatters/dicctionary.d.ts +0 -3
  211. package/components/formatters/index.0b5f95d0.js +0 -21
  212. package/components/hook-form/RHFCheckbox/index.6dcec9e2.js +0 -68
  213. package/components/hook-form/RHFCheckbox/index.d.ts +0 -4
  214. package/components/hook-form/RHFTextField/index.b17d68f4.js +0 -146
  215. package/components/modal/index.8387e90e.js +0 -18
  216. package/components/mui_extended/Button/index.86a155a2.js +0 -101
  217. package/components/mui_extended/IconButton/index.82f16572.js +0 -63
  218. package/components/mui_extended/ImageButton/index.d.ts +0 -3
  219. package/components/mui_extended/Popover/index.d.ts +0 -4
  220. package/components/mui_extended/Typography/index.e5494696.js +0 -35
  221. package/components/mui_extended/index.85dfadf1.js +0 -16
  222. /package/components/DynamicFilter/{components → subcomponents}/ApplyedFilters/components/ApplyedFilter/index.d.ts +0 -0
  223. /package/components/DynamicFilter/{components → subcomponents}/ApplyedFilters/components/ApplyedFilter/styles.d.ts +0 -0
  224. /package/components/DynamicFilter/{components → subcomponents}/ApplyedFilters/index.d.ts +0 -0
  225. /package/components/DynamicFilter/{components → subcomponents}/ApplyedFilters/styles.d.ts +0 -0
  226. /package/components/DynamicFilter/{components → subcomponents}/ClearFilters/index.d.ts +0 -0
  227. /package/components/DynamicFilter/{components → subcomponents}/ClearFilters/styles.d.ts +0 -0
  228. /package/components/DynamicFilter/{components → subcomponents}/FilterButton/index.d.ts +0 -0
  229. /package/components/DynamicFilter/{components → subcomponents}/FilterButton/styles.d.ts +0 -0
  230. /package/components/DynamicFilter/{components → subcomponents}/InputFilter/index.d.ts +0 -0
  231. /package/components/DynamicFilter/{components → subcomponents}/InputFilter/styles.d.ts +0 -0
  232. /package/components/DynamicFilter/{components → subcomponents}/PopupEditFilter/index.d.ts +0 -0
  233. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/BooleanFilter/index.d.ts +0 -0
  234. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/BooleanFilter/styles.d.ts +0 -0
  235. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/DateTimeFilter/index.d.ts +0 -0
  236. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/DateTimeFilter/styles.d.ts +0 -0
  237. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/NumberFilter/index.d.ts +0 -0
  238. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/NumberFilter/styles.d.ts +0 -0
  239. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/StringFilter/index.d.ts +0 -0
  240. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/StringFilter/styles.d.ts +0 -0
  241. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/factory.d.ts +0 -0
  242. /package/components/DynamicFilter/{components → subcomponents}/fieldstypes/validations.d.ts +0 -0
  243. /package/components/areas/components/Window/subcomponents/{Header → InnerForHooks/subcomponents/Header}/index.d.ts +0 -0
  244. /package/components/areas/components/Window/subcomponents/{Header → InnerForHooks/subcomponents/Header}/skeleton.d.ts +0 -0
  245. /package/components/areas/components/Window/subcomponents/{Header → InnerForHooks/subcomponents/Header}/styles.d.ts +0 -0
  246. /package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/subcomponents/LoadingMF/index.d.ts +0 -0
  247. /package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/subcomponents/LoadingMF/styles.d.ts +0 -0
  248. /package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/subcomponents/LoadingMF/subcomponents/NotFound/index.d.ts +0 -0
  249. /package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/subcomponents/LoadingMF/subcomponents/NotFound/styles.d.ts +0 -0
  250. /package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/subcomponents/LoadingMF/subcomponents/NotFound/types.d.ts +0 -0
  251. /package/components/areas/components/Window/subcomponents/{MicroFrontend → InnerForHooks/subcomponents/MicroFrontend}/subcomponents/MFLoader/subcomponents/LoadingMF/types.d.ts +0 -0
@@ -0,0 +1,392 @@
1
+ import React__default, { createContext, forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from "react";
2
+ import { shallow } from "zustand/shallow";
3
+ import { W as Window } from "../../components/Window/index.76143c30.js";
4
+ import { u as useModal } from "../../../../hooks/useModal/index.2f5abe84.js";
5
+ import { useNetwork } from "@m4l/core";
6
+ import { createStore, useStore } from "zustand";
7
+ import { immer } from "zustand/middleware/immer";
8
+ import { devtools } from "zustand/middleware";
9
+ import debounce from "lodash/debounce";
10
+ import { u as useAreasStore } from "../../hooks/useArea/index.89306f6a.js";
11
+ import { jsx } from "react/jsx-runtime";
12
+ const DEBOUCED_SAVE_TIME = 500;
13
+ const COOKIE_BREAKPOINT_LAYOUTS = "layoutPros";
14
+ const COOKIE_WINDOWS = "windows";
15
+ const getParmsFromValue = (key, data) => {
16
+ try {
17
+ if (Array.isArray(data)) {
18
+ let ob = data.find((f) => f.id === key);
19
+ if (ob) {
20
+ ob = JSON.parse(ob.value);
21
+ }
22
+ return ob;
23
+ }
24
+ } catch (error) {
25
+ }
26
+ return void 0;
27
+ };
28
+ function getDataFromResponse(data, state) {
29
+ const newBreakPointsLayouts = getParmsFromValue(COOKIE_BREAKPOINT_LAYOUTS, data);
30
+ const windows = getParmsFromValue(COOKIE_WINDOWS, data);
31
+ const newGridLayouts = [];
32
+ const newHashWindowLayouts = {};
33
+ if (windows) {
34
+ for (const key in windows) {
35
+ const element = windows[key];
36
+ if (element && element["layoutProps"] && element["mfProps"] && element["emergeType"] === "layout" && element["winType"] === "microfrontend") {
37
+ element["layoutProps"].i = key;
38
+ newGridLayouts.push(element["layoutProps"]);
39
+ newHashWindowLayouts[key] = {
40
+ ...element,
41
+ windowId: key,
42
+ emergeType: "layout",
43
+ onClose: state.actions.closeWindowLayout
44
+ };
45
+ }
46
+ }
47
+ console.log("GET cookies", newBreakPointsLayouts, newHashWindowLayouts);
48
+ }
49
+ return {
50
+ newBreakPointsLayouts,
51
+ newGridLayouts,
52
+ newHashWindowLayouts
53
+ };
54
+ }
55
+ const createAreaStore = (initProps) => {
56
+ console.debug("Creating Area State");
57
+ const startProps = {
58
+ zPopUpIndex: 999,
59
+ status: "init",
60
+ breakpointsLayouts: {},
61
+ gridLayouts: [],
62
+ windowsPopUps: [],
63
+ hashWindowsPopups: {},
64
+ hashWindowsLayouts: {},
65
+ currentLayoutId: "",
66
+ currentPopUpId: "",
67
+ ...initProps
68
+ };
69
+ return createStore(
70
+ devtools(
71
+ immer((set, get) => ({
72
+ ...startProps,
73
+ actions: {
74
+ closeWindowPopUp: (removePopUpId) => {
75
+ set((state) => {
76
+ const removeIndex = state.windowsPopUps.findIndex(
77
+ (wpId) => wpId === removePopUpId
78
+ );
79
+ if (removeIndex > -1) {
80
+ state.windowsPopUps.splice(removeIndex, 1);
81
+ }
82
+ delete state.hashWindowsPopups[removePopUpId];
83
+ });
84
+ },
85
+ addWindowPopUp: (windowId, newWindowPopupProps) => {
86
+ let popUpId = windowId;
87
+ set((state) => {
88
+ if (newWindowPopupProps.replaceMeId) {
89
+ for (const key in state.hashWindowsPopups) {
90
+ const WindoPopUp = state.hashWindowsPopups[key];
91
+ if (WindoPopUp.replaceMeId === newWindowPopupProps.replaceMeId) {
92
+ popUpId = key;
93
+ state.hashWindowsPopups[key].dynamicParams = newWindowPopupProps.dynamicParams;
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ if (popUpId === windowId) {
99
+ state.windowsPopUps.push(windowId);
100
+ state.hashWindowsPopups[windowId] = {
101
+ ...newWindowPopupProps,
102
+ emergeType: "popup",
103
+ windowId,
104
+ onClose: get().actions.closeWindowPopUp,
105
+ zIndex: state.zPopUpIndex
106
+ };
107
+ state.currentPopUpId = windowId;
108
+ }
109
+ console.log("addWindowPopUp fin");
110
+ });
111
+ get().actions.selectWindowPopUp(popUpId);
112
+ },
113
+ closeWindowLayout: (removeLayoutId) => {
114
+ set((state) => {
115
+ const removeIndex = state.gridLayouts.findIndex(
116
+ (gl) => gl.i === removeLayoutId
117
+ );
118
+ if (removeIndex > -1) {
119
+ state.gridLayouts.splice(removeIndex, 1);
120
+ }
121
+ delete state.hashWindowsLayouts[removeLayoutId];
122
+ });
123
+ get().actions.saveLayouts();
124
+ },
125
+ addWindowLayout: (windowId, newWindow) => {
126
+ const newLayout = {
127
+ ...newWindow.layoutProps,
128
+ i: windowId,
129
+ isDraggable: true,
130
+ isResizable: true,
131
+ winType: newWindow.winType
132
+ };
133
+ set((state) => {
134
+ state.gridLayouts.push(newLayout);
135
+ state.hashWindowsLayouts[windowId] = {
136
+ ...newWindow,
137
+ windowId,
138
+ emergeType: "layout",
139
+ onClose: get().actions.closeWindowLayout
140
+ };
141
+ });
142
+ get().actions.selectWindowLayout(windowId);
143
+ get().actions.saveLayouts();
144
+ },
145
+ saveLayouts: () => {
146
+ let nrKeys = 0;
147
+ const saveObjetc = {};
148
+ for (const key in get().hashWindowsLayouts) {
149
+ const element = get().hashWindowsLayouts[key];
150
+ if (element.winType === "microfrontend") {
151
+ const newElement = { ...element };
152
+ delete newElement.onClose;
153
+ delete newElement.devCookies;
154
+ saveObjetc[key] = newElement;
155
+ nrKeys++;
156
+ }
157
+ }
158
+ console.log("saveWindows", nrKeys, saveObjetc, JSON.stringify(saveObjetc));
159
+ if (nrKeys > 0) {
160
+ get().networkOperation({
161
+ method: "PUT",
162
+ endPoint: `cookies/${get().id}/${COOKIE_WINDOWS}`,
163
+ data: {
164
+ value: JSON.stringify(saveObjetc)
165
+ },
166
+ toastSuccess: false,
167
+ toastError: false
168
+ });
169
+ } else {
170
+ get().networkOperation({
171
+ method: "DELETE",
172
+ endPoint: `cookies`,
173
+ data: { f: [{ n: "container_id", o: "c", o1: get().id }] },
174
+ toastSuccess: false,
175
+ toastError: false
176
+ });
177
+ }
178
+ },
179
+ bouncedSaveBreakpointsLayouts: debounce(
180
+ () => {
181
+ const purgedLayouts = { ...get().breakpointsLayouts };
182
+ const finalLayouts = {};
183
+ for (const key in purgedLayouts) {
184
+ const element = purgedLayouts[key];
185
+ purgedLayouts[key] = element.filter((l) => {
186
+ if (l.i === "none") {
187
+ return false;
188
+ }
189
+ if (get().hashWindowsLayouts[l.i]) {
190
+ return true;
191
+ }
192
+ return false;
193
+ });
194
+ if (purgedLayouts[key].length > 0) {
195
+ finalLayouts[key] = purgedLayouts[key];
196
+ }
197
+ }
198
+ if (Object.keys(finalLayouts).length > 0) {
199
+ console.log(finalLayouts);
200
+ get().networkOperation({
201
+ method: "PUT",
202
+ endPoint: `cookies/${get().id}/${COOKIE_BREAKPOINT_LAYOUTS}`,
203
+ data: {
204
+ value: JSON.stringify(finalLayouts)
205
+ },
206
+ toastSuccess: false,
207
+ toastError: false
208
+ });
209
+ }
210
+ },
211
+ DEBOUCED_SAVE_TIME
212
+ ),
213
+ onBreakpointsLayoutsChange: (_currentLayouts, newAllLayouts) => {
214
+ set((state) => {
215
+ state.breakpointsLayouts = newAllLayouts;
216
+ });
217
+ get().actions.bouncedSaveBreakpointsLayouts();
218
+ },
219
+ selectWindowLayout: (layoutId) => {
220
+ set((state) => {
221
+ state.currentLayoutId = layoutId;
222
+ if (state.currentPopUpId !== "" && state.hashWindowsPopups[state.currentPopUpId]) {
223
+ const windowPopup = state.hashWindowsPopups[state.currentPopUpId];
224
+ if (windowPopup.parentLayoutId !== layoutId) {
225
+ state.currentPopUpId = "";
226
+ }
227
+ }
228
+ });
229
+ },
230
+ selectWindowPopUp: (popUpId) => {
231
+ set((state) => {
232
+ state.zPopUpIndex++;
233
+ state.currentPopUpId = popUpId;
234
+ state.zPopUpIndex++;
235
+ state.currentPopUpId = popUpId;
236
+ state.hashWindowsPopups[popUpId].zIndex = state.zPopUpIndex;
237
+ if (state.hashWindowsPopups[popUpId].parentLayoutId && state.hashWindowsPopups[popUpId].parentLayoutId !== "") {
238
+ state.currentLayoutId = state.hashWindowsPopups[popUpId].parentLayoutId;
239
+ } else {
240
+ state.currentLayoutId = "";
241
+ }
242
+ });
243
+ setTimeout(() => {
244
+ const container = document.getElementsByClassName(
245
+ `M4L_GridLayout_${get().id}`
246
+ )[0];
247
+ const element = document.getElementsByClassName(
248
+ `M4L_WindowPopUp_${popUpId}`
249
+ )[0];
250
+ if (element && container) {
251
+ const { top, left } = element.getBoundingClientRect();
252
+ const { top: containerTop, left: containerLeft } = container.getBoundingClientRect();
253
+ console.log(
254
+ "scroll top:",
255
+ `M4L_WindowPopUp_${popUpId}`,
256
+ top,
257
+ containerTop
258
+ );
259
+ container.scrollTop = container.scrollTop + top - containerTop;
260
+ container.scrollLeft = container.scrollLeft + left - containerLeft;
261
+ }
262
+ }, 100);
263
+ }
264
+ },
265
+ internalActions: {
266
+ loadFromApi: () => {
267
+ if (get().status !== "init") {
268
+ return;
269
+ }
270
+ if (!get().loadAreasFromNetwork || !get().loadWindows) {
271
+ set((state) => {
272
+ state.status = "loaded";
273
+ });
274
+ return;
275
+ }
276
+ get().networkOperation({
277
+ method: "GET",
278
+ endPoint: `cookies`,
279
+ parms: { f: [{ n: "container_id", o: "e", o1: get().id }] },
280
+ toastSuccess: false,
281
+ toastError: false
282
+ }).then((response) => {
283
+ set((state) => {
284
+ const {
285
+ newBreakPointsLayouts,
286
+ newGridLayouts,
287
+ newHashWindowLayouts
288
+ } = getDataFromResponse(response.data, state);
289
+ state.breakpointsLayouts = newBreakPointsLayouts;
290
+ state.gridLayouts = newGridLayouts;
291
+ state.hashWindowsLayouts = newHashWindowLayouts;
292
+ console.log("Area loaded");
293
+ state.status = "loaded";
294
+ });
295
+ }).catch((_response) => {
296
+ set((state) => {
297
+ state.status = "loaded";
298
+ });
299
+ });
300
+ }
301
+ }
302
+ })),
303
+ { name: `Area state ${initProps.id}` }
304
+ )
305
+ );
306
+ };
307
+ const AreaContext = createContext(null);
308
+ const AreaProvider = forwardRef((props, ref) => {
309
+ const {
310
+ children,
311
+ id,
312
+ active,
313
+ loadWindows = true
314
+ } = props;
315
+ const loadAreasFromNetwork = useAreasStore((state) => state.loadAreasFromNetwork);
316
+ const {
317
+ networkOperation
318
+ } = useNetwork();
319
+ const areaStoreRef = useRef();
320
+ if (!areaStoreRef.current) {
321
+ areaStoreRef.current = createAreaStore({
322
+ id,
323
+ networkOperation,
324
+ loadAreasFromNetwork,
325
+ loadWindows
326
+ });
327
+ }
328
+ const {
329
+ addWindowLayout,
330
+ addWindowPopUp
331
+ } = useStore(areaStoreRef.current, (state) => state.actions, shallow);
332
+ const {
333
+ loadFromApi
334
+ } = useStore(areaStoreRef.current, (state) => state.internalActions, shallow);
335
+ const status = useStore(areaStoreRef.current, (state) => state.status, shallow);
336
+ const {
337
+ openModal,
338
+ closeModal
339
+ } = useModal();
340
+ useImperativeHandle(ref, () => ({
341
+ store: areaStoreRef.current,
342
+ addWindow
343
+ }), []);
344
+ useEffect(() => {
345
+ console.log("useEffect AreaProvider");
346
+ return () => {
347
+ console.log("useEffect cluanUp AreaProvider****");
348
+ };
349
+ }, []);
350
+ useEffect(() => {
351
+ if (active && status === "init") {
352
+ loadFromApi();
353
+ }
354
+ }, [active]);
355
+ console.log("Rendeer AreaProvider status", status, loadAreasFromNetwork);
356
+ const closeWindowModal = useCallback(() => {
357
+ closeModal();
358
+ }, []);
359
+ const openWindowModal = useCallback((container_id, newWindowProps) => {
360
+ openModal({
361
+ window: /* @__PURE__ */ jsx(Window, {
362
+ ...newWindowProps,
363
+ windowId: container_id,
364
+ onClose: closeWindowModal
365
+ })
366
+ });
367
+ }, []);
368
+ const addWindow = useCallback((newWindow) => {
369
+ const newId = `${id}_window_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
370
+ if (newWindow.emergeType === "layout") {
371
+ addWindowLayout(newId, newWindow);
372
+ } else if (newWindow.emergeType === "popup") {
373
+ addWindowPopUp(newId, newWindow);
374
+ } else {
375
+ openWindowModal(newId, newWindow);
376
+ }
377
+ return newId;
378
+ }, []);
379
+ return /* @__PURE__ */ jsx(AreaContext.Provider, {
380
+ value: {
381
+ store: areaStoreRef.current,
382
+ addWindow
383
+ },
384
+ children
385
+ });
386
+ });
387
+ AreaProvider.displayName = "AreaProvider";
388
+ React__default.memo(AreaProvider);
389
+ export {
390
+ AreaProvider as A,
391
+ AreaContext as a
392
+ };
@@ -0,0 +1,49 @@
1
+ import { NetworkProps } from '@m4l/core';
2
+ import { Layout, Layouts } from 'react-grid-layout';
3
+ import { DebouncedFunc } from 'lodash';
4
+ import { HashWindowsByLayouts, HashWindowsByPopups, NewLayoutProps, NewPopUpProps } from '../../components/Area/types';
5
+ export declare type AreaStatus = 'init' | 'load' | 'loaded' | 'error';
6
+ export interface AreaState {
7
+ zPopUpIndex: number;
8
+ id: string;
9
+ loadAreasFromNetwork: boolean;
10
+ loadWindows: boolean;
11
+ status: AreaStatus;
12
+ breakpointsLayouts: Layouts;
13
+ gridLayouts: Layout[];
14
+ windowsPopUps: string[];
15
+ hashWindowsPopups: HashWindowsByPopups;
16
+ hashWindowsLayouts: HashWindowsByLayouts;
17
+ networkOperation: (props: NetworkProps) => Promise<any>;
18
+ currentLayoutId: string;
19
+ currentPopUpId: string;
20
+ }
21
+ export interface AreaStateWithActions extends AreaState {
22
+ actions: {
23
+ closeWindowPopUp: (removePopUpId: string) => void;
24
+ addWindowPopUp: (container_id: string, newWindowPopupProps: NewPopUpProps) => void;
25
+ closeWindowLayout: (removeLayoutId: string) => void;
26
+ addWindowLayout: (container_id: string, newWindow: NewLayoutProps) => void;
27
+ saveLayouts: () => void;
28
+ onBreakpointsLayoutsChange: (currentLayouts: Layout[], newAllLayouts: Layouts) => void;
29
+ bouncedSaveBreakpointsLayouts: DebouncedFunc<() => void>;
30
+ selectWindowLayout: (layoutId: string) => void;
31
+ selectWindowPopUp: (popUpId: string) => void;
32
+ };
33
+ internalActions: {
34
+ loadFromApi: () => void;
35
+ };
36
+ }
37
+ declare type DefaultStoreProps = Omit<AreaState, 'id'>;
38
+ declare type InitialStoreProps = Pick<AreaState, 'id' | 'networkOperation' | 'loadAreasFromNetwork' | 'loadWindows'> & Partial<DefaultStoreProps>;
39
+ export declare const createAreaStore: (initProps: InitialStoreProps) => Omit<Omit<import("zustand").StoreApi<AreaStateWithActions>, "setState"> & {
40
+ setState<A extends string | {
41
+ type: unknown;
42
+ }>(partial: AreaStateWithActions | Partial<AreaStateWithActions> | ((state: AreaStateWithActions) => AreaStateWithActions | Partial<AreaStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
43
+ }, "setState"> & {
44
+ setState(nextStateOrUpdater: AreaStateWithActions | Partial<AreaStateWithActions> | ((state: import("immer/dist/internal").WritableDraft<AreaStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
45
+ type: unknown;
46
+ } | undefined): void;
47
+ };
48
+ export declare type AreaStore = ReturnType<typeof createAreaStore>;
49
+ export {};
@@ -1,7 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import type { Layout, Layouts } from 'react-grid-layout';
3
- import { NewWindowProps, PopUpProps, WinType } from '../../components/Area/types';
4
- import { AreaProps, HashWindowsByLayouts } from '../../components/Area/types';
2
+ import type { Layout } from 'react-grid-layout';
3
+ import { NewWindowProps, WinType } from '../../components/Area/types';
4
+ import { AreaProps } from '../../components/Area/types';
5
+ import { AreaStore } from './store';
5
6
  export declare type AreaStatus = 'init' | 'load' | 'loaded' | 'error';
6
7
  export interface AreaProviderProps extends AreaProps {
7
8
  children: ReactNode;
@@ -10,19 +11,10 @@ export declare type WinLayout = Layout & {
10
11
  winType: WinType;
11
12
  };
12
13
  export declare type AreaProviderRef = {
13
- addWindow: (newWindowMF: NewWindowProps) => string;
14
+ store: AreaStore;
15
+ addWindow: (newWindow: NewWindowProps) => string;
14
16
  };
15
- export interface AreaContextProps extends Omit<AreaProps, 'children' | 'active'> {
16
- status: AreaStatus;
17
- isWindowSelected: (id: string) => boolean;
18
- selectWindow: (newSeletectedId: string) => void;
19
- getWindowPopUpZindex: () => number;
20
- allLayouts: Layouts;
21
- layouts: Layout[];
22
- hashWindowsLayouts: HashWindowsByLayouts;
17
+ export interface AreaContextProps {
18
+ store: AreaStore;
23
19
  addWindow: (newWindow: NewWindowProps) => string;
24
- onCloseWindowLayout: (removeLayoutId: string) => void;
25
- onLayoutChange: (currentLayouts: Layout[], allLayouts: Layouts) => void;
26
- windowsPopUps: PopUpProps[];
27
- onCloseWindowPopUp: (removePopUpId: string) => void;
28
20
  }
@@ -1,5 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { AreasContextProps, AreasProviderProps } from './types';
3
- declare const AreasContext: import("react").Context<AreasContextProps | null>;
2
+ import { AreasProviderProps } from './types';
3
+ declare const AreasContext: import("react").Context<(Omit<Omit<import("zustand").StoreApi<import("./store").AreasStateWithActions>, "setState"> & {
4
+ setState<A extends string | {
5
+ type: unknown;
6
+ }>(partial: import("./store").AreasStateWithActions | Partial<import("./store").AreasStateWithActions> | ((state: import("./store").AreasStateWithActions) => import("./store").AreasStateWithActions | Partial<import("./store").AreasStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
7
+ }, "setState"> & {
8
+ setState(nextStateOrUpdater: import("./store").AreasStateWithActions | Partial<import("./store").AreasStateWithActions> | ((state: import("immer/dist/internal").WritableDraft<import("./store").AreasStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
9
+ type: unknown;
10
+ } | undefined): void;
11
+ }) | null>;
4
12
  declare function AreasProvider(props: AreasProviderProps): JSX.Element;
5
13
  export { AreasProvider, AreasContext };
@@ -0,0 +1,204 @@
1
+ import { createContext, useRef, useCallback, useEffect } from "react";
2
+ import { useHostTools, useModuleDictionary, useNetwork, EmitEvents } from "@m4l/core";
3
+ import { createStore, useStore } from "zustand";
4
+ import { devtools } from "zustand/middleware";
5
+ import { immer } from "zustand/middleware/immer";
6
+ import { L as LABEL_NEW_AREA } from "../../index.a2586fb3.js";
7
+ import { shallow } from "zustand/shallow";
8
+ import { useFirstRender } from "@m4l/graphics";
9
+ import { jsx } from "react/jsx-runtime";
10
+ const addAreaNoBoilerPlate = (state) => {
11
+ let newName = "";
12
+ const newId = `area_${new Date().getTime()}_${(Math.random() * 1e3).toFixed(0)}`;
13
+ newName = `${state.getLabel(LABEL_NEW_AREA)} ${state.areas.length + 1}`;
14
+ console.log("addAreaNoBoilerPlate", newName);
15
+ state.areas.push({ id: newId, name: newName, loadWindows: false });
16
+ state.currentArea = newId;
17
+ if (state.loadAreasFromNetwork) {
18
+ state.networkOperation({
19
+ method: "POST",
20
+ endPoint: `areas`,
21
+ data: { id: newId, name: newName },
22
+ toastSuccess: false,
23
+ toastError: false
24
+ });
25
+ }
26
+ return newId;
27
+ };
28
+ const createAreasStore = (initProps) => {
29
+ const startProps = {
30
+ status: "init",
31
+ currentArea: "",
32
+ areas: [],
33
+ ...initProps
34
+ };
35
+ return createStore(
36
+ devtools(
37
+ immer((set, get) => ({
38
+ ...startProps,
39
+ actions: {
40
+ addArea: () => {
41
+ let newId = "";
42
+ set((state) => {
43
+ newId = addAreaNoBoilerPlate(state);
44
+ });
45
+ return newId;
46
+ },
47
+ deleteArea: (areaId) => {
48
+ set((state) => {
49
+ const removeIndex = state.areas.findIndex((area) => area.id === areaId);
50
+ if (removeIndex > -1) {
51
+ state.areas.splice(removeIndex, 1);
52
+ }
53
+ if (state.currentArea === areaId) {
54
+ if (state.areas.length > 0) {
55
+ state.currentArea = state.areas[0].id;
56
+ } else {
57
+ state.currentArea = "";
58
+ }
59
+ }
60
+ if (state.loadAreasFromNetwork) {
61
+ state.networkOperation({
62
+ method: "DELETE",
63
+ endPoint: `areas/${areaId}`,
64
+ parms: {},
65
+ toastSuccess: false,
66
+ toastError: false
67
+ });
68
+ }
69
+ });
70
+ },
71
+ selectArea: (newAreaId) => {
72
+ console.log("Areas selected, ", newAreaId);
73
+ set((state) => {
74
+ if (state.areas.findIndex((area) => area.id === newAreaId) > -1) {
75
+ state.currentArea = newAreaId;
76
+ }
77
+ });
78
+ }
79
+ },
80
+ internalActions: {
81
+ setHandlerGetLabel: (newHandler) => {
82
+ set((state) => {
83
+ state.getLabel = newHandler;
84
+ });
85
+ },
86
+ loadFromApi: () => {
87
+ if (get().status === "init") {
88
+ if (!get().loadAreasFromNetwork) {
89
+ get().actions.addArea();
90
+ set((state) => {
91
+ state.status = "loaded";
92
+ });
93
+ } else {
94
+ set((state) => {
95
+ state.status = "loading";
96
+ state.networkOperation({
97
+ method: "GET",
98
+ endPoint: `areas`,
99
+ parms: {},
100
+ toastSuccess: false
101
+ }).then((response) => {
102
+ set((otherState) => {
103
+ if (response?.data && Array.isArray(response.data) && response.data.length > 0) {
104
+ otherState.areas = response.data;
105
+ otherState.currentArea = response.data[0].id;
106
+ } else {
107
+ addAreaNoBoilerPlate(otherState);
108
+ }
109
+ });
110
+ }).finally(() => {
111
+ set((otherState) => {
112
+ otherState.status = "loaded";
113
+ });
114
+ });
115
+ });
116
+ }
117
+ }
118
+ },
119
+ setAreaRef: (areaId, ref) => {
120
+ set((state) => {
121
+ const areaIndex = state.areas.findIndex((area) => area.id === areaId);
122
+ if (areaIndex > -1 && !state.areas[areaIndex].ref) {
123
+ state.areas[areaIndex].ref = ref;
124
+ }
125
+ });
126
+ }
127
+ }
128
+ })),
129
+ { name: `Areas store` }
130
+ )
131
+ );
132
+ };
133
+ const AreasContext = createContext(null);
134
+ function AreasProvider(props) {
135
+ const {
136
+ children,
137
+ loadAreasFromNetwork,
138
+ onLoad
139
+ } = props;
140
+ const {
141
+ events_add_listener,
142
+ events_remove_listener
143
+ } = useHostTools();
144
+ const {
145
+ getLabel
146
+ } = useModuleDictionary();
147
+ const {
148
+ networkOperation
149
+ } = useNetwork();
150
+ const isFirstRender = useFirstRender([getLabel]);
151
+ const areasStoreRef = useRef();
152
+ if (!areasStoreRef.current) {
153
+ areasStoreRef.current = createAreasStore({
154
+ getLabel,
155
+ loadAreasFromNetwork,
156
+ networkOperation
157
+ });
158
+ }
159
+ const status = useStore(areasStoreRef.current, (state) => state.status, shallow);
160
+ const {
161
+ setHandlerGetLabel
162
+ } = useStore(areasStoreRef.current, (state) => state.internalActions, shallow);
163
+ const addWindow = useCallback((newWindow) => {
164
+ console.log("addWindow raw");
165
+ const currentArea = areasStoreRef.current?.getState().currentArea;
166
+ const areas = areasStoreRef.current?.getState().areas;
167
+ if (currentArea && areas) {
168
+ const areaIndex = areas.findIndex((area) => area.id == currentArea);
169
+ if (areaIndex > -1 && areas[areaIndex].ref) {
170
+ const areaRef = areas[areaIndex].ref;
171
+ if (areaRef) {
172
+ areaRef.addWindow(newWindow);
173
+ }
174
+ }
175
+ }
176
+ }, []);
177
+ useEffect(() => {
178
+ if (status === "loaded") {
179
+ console.log("useEffect Areas loaded");
180
+ onLoad && onLoad();
181
+ }
182
+ }, [status]);
183
+ useEffect(() => {
184
+ if (!isFirstRender) {
185
+ setHandlerGetLabel(getLabel);
186
+ }
187
+ }, [getLabel]);
188
+ useEffect(() => {
189
+ events_add_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
190
+ areasStoreRef.current?.getState().internalActions.loadFromApi();
191
+ console.log("useEffect AreasProvider Emmiter");
192
+ return () => {
193
+ events_remove_listener(EmitEvents.EMMIT_EVENT_HOST_EMERGE_WINDOW, addWindow);
194
+ };
195
+ }, []);
196
+ return /* @__PURE__ */ jsx(AreasContext.Provider, {
197
+ value: areasStoreRef.current,
198
+ children
199
+ });
200
+ }
201
+ export {
202
+ AreasContext as A,
203
+ AreasProvider as a
204
+ };