@vuu-ui/vuu-layout 0.0.26

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 (359) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -0
  3. package/cjs/Component.js +14 -0
  4. package/cjs/Component.js.map +1 -0
  5. package/cjs/DraggableLayout.css.js +6 -0
  6. package/cjs/DraggableLayout.css.js.map +1 -0
  7. package/cjs/DraggableLayout.js +33 -0
  8. package/cjs/DraggableLayout.js.map +1 -0
  9. package/cjs/dock-layout/DockLayout.css.js +6 -0
  10. package/cjs/dock-layout/DockLayout.css.js.map +1 -0
  11. package/cjs/dock-layout/DockLayout.js +36 -0
  12. package/cjs/dock-layout/DockLayout.js.map +1 -0
  13. package/cjs/dock-layout/Drawer.css.js +6 -0
  14. package/cjs/dock-layout/Drawer.css.js.map +1 -0
  15. package/cjs/dock-layout/Drawer.js +96 -0
  16. package/cjs/dock-layout/Drawer.js.map +1 -0
  17. package/cjs/drag-drop/BoxModel.js +422 -0
  18. package/cjs/drag-drop/BoxModel.js.map +1 -0
  19. package/cjs/drag-drop/DragState.js +154 -0
  20. package/cjs/drag-drop/DragState.js.map +1 -0
  21. package/cjs/drag-drop/Draggable.js +192 -0
  22. package/cjs/drag-drop/Draggable.js.map +1 -0
  23. package/cjs/drag-drop/DropMenu.css.js +6 -0
  24. package/cjs/drag-drop/DropMenu.css.js.map +1 -0
  25. package/cjs/drag-drop/DropMenu.js +55 -0
  26. package/cjs/drag-drop/DropMenu.js.map +1 -0
  27. package/cjs/drag-drop/DropTarget.js +244 -0
  28. package/cjs/drag-drop/DropTarget.js.map +1 -0
  29. package/cjs/drag-drop/DropTargetRenderer.js +244 -0
  30. package/cjs/drag-drop/DropTargetRenderer.js.map +1 -0
  31. package/cjs/flexbox/Flexbox.css.js +6 -0
  32. package/cjs/flexbox/Flexbox.css.js.map +1 -0
  33. package/cjs/flexbox/Flexbox.js +70 -0
  34. package/cjs/flexbox/Flexbox.js.map +1 -0
  35. package/cjs/flexbox/FlexboxLayout.js +30 -0
  36. package/cjs/flexbox/FlexboxLayout.js.map +1 -0
  37. package/cjs/flexbox/FluidGrid.css.js +6 -0
  38. package/cjs/flexbox/FluidGrid.css.js.map +1 -0
  39. package/cjs/flexbox/FluidGrid.js +87 -0
  40. package/cjs/flexbox/FluidGrid.js.map +1 -0
  41. package/cjs/flexbox/FluidGridLayout.js +14 -0
  42. package/cjs/flexbox/FluidGridLayout.js.map +1 -0
  43. package/cjs/flexbox/Splitter.css.js +6 -0
  44. package/cjs/flexbox/Splitter.css.js.map +1 -0
  45. package/cjs/flexbox/Splitter.js +122 -0
  46. package/cjs/flexbox/Splitter.js.map +1 -0
  47. package/cjs/flexbox/flexbox-utils.js +109 -0
  48. package/cjs/flexbox/flexbox-utils.js.map +1 -0
  49. package/cjs/flexbox/useResponsiveSizing.js +62 -0
  50. package/cjs/flexbox/useResponsiveSizing.js.map +1 -0
  51. package/cjs/flexbox/useSplitterResizing.js +209 -0
  52. package/cjs/flexbox/useSplitterResizing.js.map +1 -0
  53. package/cjs/index.js +133 -0
  54. package/cjs/index.js.map +1 -0
  55. package/cjs/layout-action.js +27 -0
  56. package/cjs/layout-action.js.map +1 -0
  57. package/cjs/layout-header/Header.css.js +6 -0
  58. package/cjs/layout-header/Header.css.js.map +1 -0
  59. package/cjs/layout-header/Header.js +131 -0
  60. package/cjs/layout-header/Header.js.map +1 -0
  61. package/cjs/layout-provider/LayoutProvider.js +178 -0
  62. package/cjs/layout-provider/LayoutProvider.js.map +1 -0
  63. package/cjs/layout-provider/LayoutProviderContext.js +14 -0
  64. package/cjs/layout-provider/LayoutProviderContext.js.map +1 -0
  65. package/cjs/layout-provider/useLayoutDragDrop.js +172 -0
  66. package/cjs/layout-provider/useLayoutDragDrop.js.map +1 -0
  67. package/cjs/layout-reducer/flexUtils.js +219 -0
  68. package/cjs/layout-reducer/flexUtils.js.map +1 -0
  69. package/cjs/layout-reducer/insert-layout-element.js +273 -0
  70. package/cjs/layout-reducer/insert-layout-element.js.map +1 -0
  71. package/cjs/layout-reducer/layout-reducer.js +198 -0
  72. package/cjs/layout-reducer/layout-reducer.js.map +1 -0
  73. package/cjs/layout-reducer/layoutTypes.js +41 -0
  74. package/cjs/layout-reducer/layoutTypes.js.map +1 -0
  75. package/cjs/layout-reducer/layoutUtils.js +226 -0
  76. package/cjs/layout-reducer/layoutUtils.js.map +1 -0
  77. package/cjs/layout-reducer/move-layout-element.js +31 -0
  78. package/cjs/layout-reducer/move-layout-element.js.map +1 -0
  79. package/cjs/layout-reducer/remove-layout-element.js +223 -0
  80. package/cjs/layout-reducer/remove-layout-element.js.map +1 -0
  81. package/cjs/layout-reducer/replace-layout-element.js +91 -0
  82. package/cjs/layout-reducer/replace-layout-element.js.map +1 -0
  83. package/cjs/layout-reducer/resize-flex-children.js +61 -0
  84. package/cjs/layout-reducer/resize-flex-children.js.map +1 -0
  85. package/cjs/layout-reducer/wrap-layout-element.js +212 -0
  86. package/cjs/layout-reducer/wrap-layout-element.js.map +1 -0
  87. package/cjs/layout-view/View.css.js +6 -0
  88. package/cjs/layout-view/View.css.js.map +1 -0
  89. package/cjs/layout-view/View.js +164 -0
  90. package/cjs/layout-view/View.js.map +1 -0
  91. package/cjs/layout-view/useView.js +92 -0
  92. package/cjs/layout-view/useView.js.map +1 -0
  93. package/cjs/layout-view/useViewResize.js +42 -0
  94. package/cjs/layout-view/useViewResize.js.map +1 -0
  95. package/cjs/layout-view-actions/ViewContext.js +16 -0
  96. package/cjs/layout-view-actions/ViewContext.js.map +1 -0
  97. package/cjs/layout-view-actions/useViewActionDispatcher.js +103 -0
  98. package/cjs/layout-view-actions/useViewActionDispatcher.js.map +1 -0
  99. package/cjs/palette/Palette.css.js +6 -0
  100. package/cjs/palette/Palette.css.js.map +1 -0
  101. package/cjs/palette/Palette.js +127 -0
  102. package/cjs/palette/Palette.js.map +1 -0
  103. package/cjs/placeholder/LayoutStartPanel.css.js +6 -0
  104. package/cjs/placeholder/LayoutStartPanel.css.js.map +1 -0
  105. package/cjs/placeholder/LayoutStartPanel.js +60 -0
  106. package/cjs/placeholder/LayoutStartPanel.js.map +1 -0
  107. package/cjs/placeholder/Placeholder.css.js +6 -0
  108. package/cjs/placeholder/Placeholder.css.js.map +1 -0
  109. package/cjs/placeholder/Placeholder.js +34 -0
  110. package/cjs/placeholder/Placeholder.js.map +1 -0
  111. package/cjs/registry/ComponentRegistry.js +27 -0
  112. package/cjs/registry/ComponentRegistry.js.map +1 -0
  113. package/cjs/responsive/breakpoints.js +36 -0
  114. package/cjs/responsive/breakpoints.js.map +1 -0
  115. package/cjs/responsive/use-breakpoints.js +76 -0
  116. package/cjs/responsive/use-breakpoints.js.map +1 -0
  117. package/cjs/responsive/useResizeObserver.js +118 -0
  118. package/cjs/responsive/useResizeObserver.js.map +1 -0
  119. package/cjs/responsive/utils.js +34 -0
  120. package/cjs/responsive/utils.js.map +1 -0
  121. package/cjs/stack/Stack.css.js +6 -0
  122. package/cjs/stack/Stack.css.js.map +1 -0
  123. package/cjs/stack/Stack.js +148 -0
  124. package/cjs/stack/Stack.js.map +1 -0
  125. package/cjs/stack/StackLayout.js +122 -0
  126. package/cjs/stack/StackLayout.js.map +1 -0
  127. package/cjs/use-persistent-state.js +109 -0
  128. package/cjs/use-persistent-state.js.map +1 -0
  129. package/cjs/utils/pathUtils.js +293 -0
  130. package/cjs/utils/pathUtils.js.map +1 -0
  131. package/cjs/utils/propUtils.js +27 -0
  132. package/cjs/utils/propUtils.js.map +1 -0
  133. package/cjs/utils/refUtils.js +12 -0
  134. package/cjs/utils/refUtils.js.map +1 -0
  135. package/cjs/utils/styleUtils.js +15 -0
  136. package/cjs/utils/styleUtils.js.map +1 -0
  137. package/cjs/utils/typeOf.js +27 -0
  138. package/cjs/utils/typeOf.js.map +1 -0
  139. package/esm/Component.js +12 -0
  140. package/esm/Component.js.map +1 -0
  141. package/esm/DraggableLayout.css.js +4 -0
  142. package/esm/DraggableLayout.css.js.map +1 -0
  143. package/esm/DraggableLayout.js +31 -0
  144. package/esm/DraggableLayout.js.map +1 -0
  145. package/esm/dock-layout/DockLayout.css.js +4 -0
  146. package/esm/dock-layout/DockLayout.css.js.map +1 -0
  147. package/esm/dock-layout/DockLayout.js +34 -0
  148. package/esm/dock-layout/DockLayout.js.map +1 -0
  149. package/esm/dock-layout/Drawer.css.js +4 -0
  150. package/esm/dock-layout/Drawer.css.js.map +1 -0
  151. package/esm/dock-layout/Drawer.js +94 -0
  152. package/esm/dock-layout/Drawer.js.map +1 -0
  153. package/esm/drag-drop/BoxModel.js +415 -0
  154. package/esm/drag-drop/BoxModel.js.map +1 -0
  155. package/esm/drag-drop/DragState.js +152 -0
  156. package/esm/drag-drop/DragState.js.map +1 -0
  157. package/esm/drag-drop/Draggable.js +190 -0
  158. package/esm/drag-drop/Draggable.js.map +1 -0
  159. package/esm/drag-drop/DropMenu.css.js +4 -0
  160. package/esm/drag-drop/DropMenu.css.js.map +1 -0
  161. package/esm/drag-drop/DropMenu.js +52 -0
  162. package/esm/drag-drop/DropMenu.js.map +1 -0
  163. package/esm/drag-drop/DropTarget.js +240 -0
  164. package/esm/drag-drop/DropTarget.js.map +1 -0
  165. package/esm/drag-drop/DropTargetRenderer.js +242 -0
  166. package/esm/drag-drop/DropTargetRenderer.js.map +1 -0
  167. package/esm/flexbox/Flexbox.css.js +4 -0
  168. package/esm/flexbox/Flexbox.css.js.map +1 -0
  169. package/esm/flexbox/Flexbox.js +68 -0
  170. package/esm/flexbox/Flexbox.js.map +1 -0
  171. package/esm/flexbox/FlexboxLayout.js +28 -0
  172. package/esm/flexbox/FlexboxLayout.js.map +1 -0
  173. package/esm/flexbox/FluidGrid.css.js +4 -0
  174. package/esm/flexbox/FluidGrid.css.js.map +1 -0
  175. package/esm/flexbox/FluidGrid.js +85 -0
  176. package/esm/flexbox/FluidGrid.js.map +1 -0
  177. package/esm/flexbox/FluidGridLayout.js +12 -0
  178. package/esm/flexbox/FluidGridLayout.js.map +1 -0
  179. package/esm/flexbox/Splitter.css.js +4 -0
  180. package/esm/flexbox/Splitter.css.js.map +1 -0
  181. package/esm/flexbox/Splitter.js +120 -0
  182. package/esm/flexbox/Splitter.js.map +1 -0
  183. package/esm/flexbox/flexbox-utils.js +103 -0
  184. package/esm/flexbox/flexbox-utils.js.map +1 -0
  185. package/esm/flexbox/useResponsiveSizing.js +60 -0
  186. package/esm/flexbox/useResponsiveSizing.js.map +1 -0
  187. package/esm/flexbox/useSplitterResizing.js +207 -0
  188. package/esm/flexbox/useSplitterResizing.js.map +1 -0
  189. package/esm/index.js +37 -0
  190. package/esm/index.js.map +1 -0
  191. package/esm/layout-action.js +25 -0
  192. package/esm/layout-action.js.map +1 -0
  193. package/esm/layout-header/Header.css.js +4 -0
  194. package/esm/layout-header/Header.css.js.map +1 -0
  195. package/esm/layout-header/Header.js +129 -0
  196. package/esm/layout-header/Header.js.map +1 -0
  197. package/esm/layout-provider/LayoutProvider.js +172 -0
  198. package/esm/layout-provider/LayoutProvider.js.map +1 -0
  199. package/esm/layout-provider/LayoutProviderContext.js +12 -0
  200. package/esm/layout-provider/LayoutProviderContext.js.map +1 -0
  201. package/esm/layout-provider/useLayoutDragDrop.js +170 -0
  202. package/esm/layout-provider/useLayoutDragDrop.js.map +1 -0
  203. package/esm/layout-reducer/flexUtils.js +210 -0
  204. package/esm/layout-reducer/flexUtils.js.map +1 -0
  205. package/esm/layout-reducer/insert-layout-element.js +269 -0
  206. package/esm/layout-reducer/insert-layout-element.js.map +1 -0
  207. package/esm/layout-reducer/layout-reducer.js +196 -0
  208. package/esm/layout-reducer/layout-reducer.js.map +1 -0
  209. package/esm/layout-reducer/layoutTypes.js +37 -0
  210. package/esm/layout-reducer/layoutTypes.js.map +1 -0
  211. package/esm/layout-reducer/layoutUtils.js +215 -0
  212. package/esm/layout-reducer/layoutUtils.js.map +1 -0
  213. package/esm/layout-reducer/move-layout-element.js +29 -0
  214. package/esm/layout-reducer/move-layout-element.js.map +1 -0
  215. package/esm/layout-reducer/remove-layout-element.js +221 -0
  216. package/esm/layout-reducer/remove-layout-element.js.map +1 -0
  217. package/esm/layout-reducer/replace-layout-element.js +87 -0
  218. package/esm/layout-reducer/replace-layout-element.js.map +1 -0
  219. package/esm/layout-reducer/resize-flex-children.js +58 -0
  220. package/esm/layout-reducer/resize-flex-children.js.map +1 -0
  221. package/esm/layout-reducer/wrap-layout-element.js +210 -0
  222. package/esm/layout-reducer/wrap-layout-element.js.map +1 -0
  223. package/esm/layout-view/View.css.js +4 -0
  224. package/esm/layout-view/View.css.js.map +1 -0
  225. package/esm/layout-view/View.js +162 -0
  226. package/esm/layout-view/View.js.map +1 -0
  227. package/esm/layout-view/useView.js +90 -0
  228. package/esm/layout-view/useView.js.map +1 -0
  229. package/esm/layout-view/useViewResize.js +40 -0
  230. package/esm/layout-view/useViewResize.js.map +1 -0
  231. package/esm/layout-view-actions/ViewContext.js +12 -0
  232. package/esm/layout-view-actions/ViewContext.js.map +1 -0
  233. package/esm/layout-view-actions/useViewActionDispatcher.js +101 -0
  234. package/esm/layout-view-actions/useViewActionDispatcher.js.map +1 -0
  235. package/esm/palette/Palette.css.js +4 -0
  236. package/esm/palette/Palette.css.js.map +1 -0
  237. package/esm/palette/Palette.js +124 -0
  238. package/esm/palette/Palette.js.map +1 -0
  239. package/esm/placeholder/LayoutStartPanel.css.js +4 -0
  240. package/esm/placeholder/LayoutStartPanel.css.js.map +1 -0
  241. package/esm/placeholder/LayoutStartPanel.js +58 -0
  242. package/esm/placeholder/LayoutStartPanel.js.map +1 -0
  243. package/esm/placeholder/Placeholder.css.js +4 -0
  244. package/esm/placeholder/Placeholder.css.js.map +1 -0
  245. package/esm/placeholder/Placeholder.js +32 -0
  246. package/esm/placeholder/Placeholder.js.map +1 -0
  247. package/esm/registry/ComponentRegistry.js +21 -0
  248. package/esm/registry/ComponentRegistry.js.map +1 -0
  249. package/esm/responsive/breakpoints.js +33 -0
  250. package/esm/responsive/breakpoints.js.map +1 -0
  251. package/esm/responsive/use-breakpoints.js +74 -0
  252. package/esm/responsive/use-breakpoints.js.map +1 -0
  253. package/esm/responsive/useResizeObserver.js +112 -0
  254. package/esm/responsive/useResizeObserver.js.map +1 -0
  255. package/esm/responsive/utils.js +31 -0
  256. package/esm/responsive/utils.js.map +1 -0
  257. package/esm/stack/Stack.css.js +4 -0
  258. package/esm/stack/Stack.css.js.map +1 -0
  259. package/esm/stack/Stack.js +146 -0
  260. package/esm/stack/Stack.js.map +1 -0
  261. package/esm/stack/StackLayout.js +120 -0
  262. package/esm/stack/StackLayout.js.map +1 -0
  263. package/esm/use-persistent-state.js +104 -0
  264. package/esm/use-persistent-state.js.map +1 -0
  265. package/esm/utils/pathUtils.js +280 -0
  266. package/esm/utils/pathUtils.js.map +1 -0
  267. package/esm/utils/propUtils.js +23 -0
  268. package/esm/utils/propUtils.js.map +1 -0
  269. package/esm/utils/refUtils.js +10 -0
  270. package/esm/utils/refUtils.js.map +1 -0
  271. package/esm/utils/styleUtils.js +13 -0
  272. package/esm/utils/styleUtils.js.map +1 -0
  273. package/esm/utils/typeOf.js +23 -0
  274. package/esm/utils/typeOf.js.map +1 -0
  275. package/package.json +43 -0
  276. package/types/Component.d.ts +7 -0
  277. package/types/DraggableLayout.d.ts +6 -0
  278. package/types/debug.d.ts +2 -0
  279. package/types/dock-layout/DockLayout.d.ts +9 -0
  280. package/types/dock-layout/Drawer.d.ts +17 -0
  281. package/types/dock-layout/index.d.ts +2 -0
  282. package/types/drag-drop/BoxModel.d.ts +143 -0
  283. package/types/drag-drop/DragState.d.ts +46 -0
  284. package/types/drag-drop/Draggable.d.ts +24 -0
  285. package/types/drag-drop/DropMenu.d.ts +9 -0
  286. package/types/drag-drop/DropTarget.d.ts +61 -0
  287. package/types/drag-drop/DropTargetRenderer.d.ts +17 -0
  288. package/types/drag-drop/dragDropTypes.d.ts +51 -0
  289. package/types/drag-drop/index.d.ts +4 -0
  290. package/types/flexbox/Flexbox.d.ts +4 -0
  291. package/types/flexbox/FlexboxLayout.d.ts +6 -0
  292. package/types/flexbox/FluidGrid.d.ts +6 -0
  293. package/types/flexbox/FluidGridLayout.d.ts +6 -0
  294. package/types/flexbox/Splitter.d.ts +12 -0
  295. package/types/flexbox/flexbox-utils.d.ts +12 -0
  296. package/types/flexbox/flexboxTypes.d.ts +51 -0
  297. package/types/flexbox/index.d.ts +4 -0
  298. package/types/flexbox/useResponsiveSizing.d.ts +10 -0
  299. package/types/flexbox/useSplitterResizing.d.ts +2 -0
  300. package/types/index.d.ts +18 -0
  301. package/types/layout-action.d.ts +22 -0
  302. package/types/layout-header/ActionButton.d.ts +8 -0
  303. package/types/layout-header/Header.d.ts +12 -0
  304. package/types/layout-header/index.d.ts +1 -0
  305. package/types/layout-provider/LayoutProvider.d.ts +15 -0
  306. package/types/layout-provider/LayoutProviderContext.d.ts +9 -0
  307. package/types/layout-provider/index.d.ts +2 -0
  308. package/types/layout-provider/useLayoutDragDrop.d.ts +4 -0
  309. package/types/layout-reducer/flexUtils.d.ts +22 -0
  310. package/types/layout-reducer/index.d.ts +4 -0
  311. package/types/layout-reducer/insert-layout-element.d.ts +8 -0
  312. package/types/layout-reducer/layout-reducer.d.ts +3 -0
  313. package/types/layout-reducer/layoutTypes.d.ts +193 -0
  314. package/types/layout-reducer/layoutUtils.d.ts +38 -0
  315. package/types/layout-reducer/move-layout-element.d.ts +3 -0
  316. package/types/layout-reducer/remove-layout-element.d.ts +3 -0
  317. package/types/layout-reducer/replace-layout-element.d.ts +6 -0
  318. package/types/layout-reducer/resize-flex-children.d.ts +4 -0
  319. package/types/layout-reducer/wrap-layout-element.d.ts +9 -0
  320. package/types/layout-view/View.d.ts +10 -0
  321. package/types/layout-view/index.d.ts +2 -0
  322. package/types/layout-view/useView.d.ts +21 -0
  323. package/types/layout-view/useViewResize.d.ts +7 -0
  324. package/types/layout-view/viewTypes.d.ts +21 -0
  325. package/types/layout-view-actions/ViewContext.d.ts +33 -0
  326. package/types/layout-view-actions/index.d.ts +2 -0
  327. package/types/layout-view-actions/useViewActionDispatcher.d.ts +9 -0
  328. package/types/palette/Palette.d.ts +21 -0
  329. package/types/palette/index.d.ts +1 -0
  330. package/types/placeholder/LayoutStartPanel.d.ts +5 -0
  331. package/types/placeholder/Placeholder.d.ts +17 -0
  332. package/types/placeholder/index.d.ts +1 -0
  333. package/types/registry/ComponentRegistry.d.ts +13 -0
  334. package/types/registry/index.d.ts +1 -0
  335. package/types/responsive/breakpoints.d.ts +4 -0
  336. package/types/responsive/index.d.ts +3 -0
  337. package/types/responsive/measureMinimumNodeSize.d.ts +1 -0
  338. package/types/responsive/overflowUtils.d.ts +2 -0
  339. package/types/responsive/use-breakpoints.d.ts +7 -0
  340. package/types/responsive/useResizeObserver.d.ts +13 -0
  341. package/types/responsive/utils.d.ts +6 -0
  342. package/types/stack/Stack.d.ts +3 -0
  343. package/types/stack/StackLayout.d.ts +6 -0
  344. package/types/stack/index.d.ts +3 -0
  345. package/types/stack/stackTypes.d.ts +22 -0
  346. package/types/tabs/TabPanel.d.ts +7 -0
  347. package/types/tabs/index.d.ts +1 -0
  348. package/types/tools/config-wrapper/ConfigWrapper.d.ts +2 -0
  349. package/types/tools/config-wrapper/index.d.ts +1 -0
  350. package/types/tools/devtools-box/layout-configurator.d.ts +31 -0
  351. package/types/tools/devtools-tree/layout-tree-viewer.d.ts +5 -0
  352. package/types/tools/index.d.ts +3 -0
  353. package/types/use-persistent-state.d.ts +11 -0
  354. package/types/utils/index.d.ts +5 -0
  355. package/types/utils/pathUtils.d.ts +31 -0
  356. package/types/utils/propUtils.d.ts +5 -0
  357. package/types/utils/refUtils.d.ts +2 -0
  358. package/types/utils/styleUtils.d.ts +3 -0
  359. package/types/utils/typeOf.d.ts +5 -0
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var pathUtils = require('../utils/pathUtils.js');
5
+ var propUtils = require('../utils/propUtils.js');
6
+ var replaceLayoutElement = require('./replace-layout-element.js');
7
+
8
+ function resizeFlexChild(layoutRoot, { path, size }) {
9
+ const target = pathUtils.followPath(layoutRoot, path, true);
10
+ const { style } = propUtils.getProps(target);
11
+ const newStyle = {
12
+ ...style,
13
+ width: size
14
+ };
15
+ const replacement = React.cloneElement(target, { style: newStyle });
16
+ return replaceLayoutElement.swapChild(layoutRoot, target, replacement);
17
+ }
18
+ function resizeFlexChildren(layoutRoot, { path, sizes }) {
19
+ const target = pathUtils.followPath(layoutRoot, path, true);
20
+ const { children, style } = propUtils.getProps(target);
21
+ const dimension2 = style.flexDirection === "column" ? "height" : "width";
22
+ const replacementChildren = applySizesToChildren(children, sizes, dimension2);
23
+ const replacement = React.cloneElement(
24
+ target,
25
+ void 0,
26
+ replacementChildren
27
+ );
28
+ return replaceLayoutElement.swapChild(layoutRoot, target, replacement);
29
+ }
30
+ function applySizesToChildren(children, sizes, dimension2) {
31
+ return children.map((child, i) => {
32
+ const {
33
+ style: { [dimension2]: size, flexBasis: actualFlexBasis }
34
+ } = propUtils.getProps(child);
35
+ const meta = sizes[i];
36
+ const { currentSize, flexBasis } = meta;
37
+ const hasCurrentSize = currentSize !== void 0;
38
+ const newSize = hasCurrentSize ? meta.currentSize : flexBasis;
39
+ if (newSize === void 0 || size === newSize || actualFlexBasis === newSize) {
40
+ return child;
41
+ }
42
+ return React.cloneElement(child, {
43
+ style: applySizeToChild(child.props.style, dimension2, newSize)
44
+ });
45
+ });
46
+ }
47
+ function applySizeToChild(style, dimension2, newSize) {
48
+ const hasSize = typeof style[dimension2] === "number";
49
+ const { flexShrink = 1, flexGrow = 1 } = style;
50
+ return {
51
+ ...style,
52
+ [dimension2]: hasSize ? newSize : "auto",
53
+ flexBasis: hasSize ? "auto" : newSize,
54
+ flexShrink,
55
+ flexGrow
56
+ };
57
+ }
58
+
59
+ exports.resizeFlexChild = resizeFlexChild;
60
+ exports.resizeFlexChildren = resizeFlexChildren;
61
+ //# sourceMappingURL=resize-flex-children.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resize-flex-children.js","sources":["../../src/layout-reducer/resize-flex-children.ts"],"sourcesContent":["import { dimension } from \"@vuu-ui/vuu-utils\";\nimport React, { CSSProperties, ReactElement } from \"react\";\nimport { followPath, getProps } from \"../utils\";\nimport { LayoutResizeAction, SplitterResizeAction } from \"./layoutTypes\";\nimport { swapChild } from \"./replace-layout-element\";\n\nexport function resizeFlexChild(\n layoutRoot: ReactElement,\n { path, size }: LayoutResizeAction\n) {\n const target = followPath(layoutRoot, path, true);\n\n const { style } = getProps(target);\n\n const newStyle = {\n ...style,\n width: size,\n };\n\n // const dimension = style.flexDirection === \"column\" ? \"height\" : \"width\";\n // const replacementChildren = applySizesToChildren(children, sizes, dimension);\n\n const replacement = React.cloneElement(target, { style: newStyle });\n\n return swapChild(layoutRoot, target, replacement);\n}\n\nexport function resizeFlexChildren(\n layoutRoot: ReactElement,\n { path, sizes }: SplitterResizeAction\n) {\n const target = followPath(layoutRoot, path, true);\n const { children, style } = getProps(target);\n\n const dimension = style.flexDirection === \"column\" ? \"height\" : \"width\";\n const replacementChildren = applySizesToChildren(children, sizes, dimension);\n\n const replacement = React.cloneElement(\n target,\n undefined,\n replacementChildren\n );\n\n return swapChild(layoutRoot, target, replacement);\n}\n\nfunction applySizesToChildren(\n children: ReactElement[],\n sizes: { currentSize: number; flexBasis: number }[],\n dimension: dimension\n) {\n return children.map((child, i) => {\n const {\n style: { [dimension]: size, flexBasis: actualFlexBasis },\n } = getProps(child);\n const meta = sizes[i];\n const { currentSize, flexBasis } = meta;\n const hasCurrentSize = currentSize !== undefined;\n const newSize = hasCurrentSize ? meta.currentSize : flexBasis;\n\n if (\n newSize === undefined ||\n size === newSize ||\n actualFlexBasis === newSize\n ) {\n return child;\n }\n return React.cloneElement(child, {\n style: applySizeToChild(child.props.style, dimension, newSize),\n });\n });\n}\n\nfunction applySizeToChild(\n style: CSSProperties,\n dimension: dimension,\n newSize: number\n) {\n const hasSize = typeof style[dimension] === \"number\";\n const { flexShrink = 1, flexGrow = 1 } = style;\n return {\n ...style,\n [dimension]: hasSize ? newSize : \"auto\",\n flexBasis: hasSize ? \"auto\" : newSize,\n flexShrink,\n flexGrow,\n };\n}\n"],"names":["followPath","getProps","swapChild","dimension"],"mappings":";;;;;;;AAMO,SAAS,eACd,CAAA,UAAA,EACA,EAAE,IAAA,EAAM,MACR,EAAA;AACA,EAAA,MAAM,MAAS,GAAAA,oBAAA,CAAW,UAAY,EAAA,IAAA,EAAM,IAAI,CAAA,CAAA;AAEhD,EAAA,MAAM,EAAE,KAAA,EAAU,GAAAC,kBAAA,CAAS,MAAM,CAAA,CAAA;AAEjC,EAAA,MAAM,QAAW,GAAA;AAAA,IACf,GAAG,KAAA;AAAA,IACH,KAAO,EAAA,IAAA;AAAA,GACT,CAAA;AAKA,EAAA,MAAM,cAAc,KAAM,CAAA,YAAA,CAAa,QAAQ,EAAE,KAAA,EAAO,UAAU,CAAA,CAAA;AAElE,EAAO,OAAAC,8BAAA,CAAU,UAAY,EAAA,MAAA,EAAQ,WAAW,CAAA,CAAA;AAClD,CAAA;AAEO,SAAS,kBACd,CAAA,UAAA,EACA,EAAE,IAAA,EAAM,OACR,EAAA;AACA,EAAA,MAAM,MAAS,GAAAF,oBAAA,CAAW,UAAY,EAAA,IAAA,EAAM,IAAI,CAAA,CAAA;AAChD,EAAA,MAAM,EAAE,QAAA,EAAU,KAAM,EAAA,GAAIC,mBAAS,MAAM,CAAA,CAAA;AAE3C,EAAA,MAAME,UAAY,GAAA,KAAA,CAAM,aAAkB,KAAA,QAAA,GAAW,QAAW,GAAA,OAAA,CAAA;AAChE,EAAA,MAAM,mBAAsB,GAAA,oBAAA,CAAqB,QAAU,EAAA,KAAA,EAAOA,UAAS,CAAA,CAAA;AAE3E,EAAA,MAAM,cAAc,KAAM,CAAA,YAAA;AAAA,IACxB,MAAA;AAAA,IACA,KAAA,CAAA;AAAA,IACA,mBAAA;AAAA,GACF,CAAA;AAEA,EAAO,OAAAD,8BAAA,CAAU,UAAY,EAAA,MAAA,EAAQ,W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MAAS,GAAA,OAAA;AAAA,IAC9B,UAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF;;;;;"}
@@ -0,0 +1,212 @@
1
+ 'use strict';
2
+
3
+ var vuuUtils = require('@vuu-ui/vuu-utils');
4
+ var React = require('react');
5
+ var ComponentRegistry = require('../registry/ComponentRegistry.js');
6
+ var pathUtils = require('../utils/pathUtils.js');
7
+ var propUtils = require('../utils/propUtils.js');
8
+ var typeOf = require('../utils/typeOf.js');
9
+ var flexUtils = require('./flexUtils.js');
10
+ var layoutUtils = require('./layoutUtils.js');
11
+
12
+ const isHtmlElement = (component) => {
13
+ const [firstLetter] = typeOf.typeOf(component);
14
+ return firstLetter === firstLetter.toLowerCase();
15
+ };
16
+ function wrap(container, existingComponent, newComponent, pos, clientRect, dropRect) {
17
+ const { children: containerChildren, path: containerPath } = propUtils.getProps(container);
18
+ const existingComponentPath = propUtils.getProp(existingComponent, "path");
19
+ const { idx, finalStep } = pathUtils.nextStep(containerPath, existingComponentPath);
20
+ const children = finalStep ? updateChildren(
21
+ container,
22
+ containerChildren,
23
+ existingComponent,
24
+ newComponent,
25
+ pos,
26
+ clientRect,
27
+ dropRect
28
+ ) : containerChildren.map(
29
+ (child, index) => index === idx ? wrap(
30
+ child,
31
+ existingComponent,
32
+ newComponent,
33
+ pos,
34
+ clientRect,
35
+ dropRect
36
+ ) : child
37
+ );
38
+ return React.cloneElement(container, void 0, children);
39
+ }
40
+ function updateChildren(container, containerChildren, existingComponent, newComponent, pos, clientRect, dropRect) {
41
+ const intrinsicSize = flexUtils.getIntrinsicSize(newComponent);
42
+ if (intrinsicSize?.width && intrinsicSize?.height) {
43
+ if (clientRect === void 0 || dropRect === void 0) {
44
+ throw Error(
45
+ "wrap-layout-element, updateChildren clientRect and dropRect must both be available"
46
+ );
47
+ }
48
+ return wrapIntrinsicSizedComponent(
49
+ containerChildren,
50
+ existingComponent,
51
+ newComponent,
52
+ pos,
53
+ clientRect,
54
+ dropRect
55
+ );
56
+ }
57
+ return wrapFlexComponent(
58
+ container,
59
+ containerChildren,
60
+ existingComponent,
61
+ newComponent,
62
+ pos
63
+ );
64
+ }
65
+ function wrapFlexComponent(container, containerChildren, existingComponent, newComponent, pos) {
66
+ const { version = 0 } = propUtils.getProps(newComponent);
67
+ const { path: existingComponentPath, title } = propUtils.getProps(existingComponent);
68
+ const {
69
+ type,
70
+ flexDirection: flexDirection2,
71
+ showTabs: showTabsProp
72
+ } = getLayoutSpecForWrapper(pos);
73
+ const [style, existingComponentStyle, newComponentStyle] = getWrappedFlexStyles(
74
+ type,
75
+ existingComponent,
76
+ newComponent,
77
+ flexDirection2,
78
+ pos
79
+ );
80
+ const targetFirst = isTargetFirst(pos);
81
+ const active = targetFirst ? 1 : 0;
82
+ const newComponentProps = {
83
+ resizeable: true,
84
+ style: newComponentStyle,
85
+ version: version + 1
86
+ };
87
+ const resizeProp = isHtmlElement(existingComponent) ? "data-resizeable" : "resizeable";
88
+ const existingComponentProps = {
89
+ [resizeProp]: true,
90
+ style: existingComponentStyle
91
+ };
92
+ const showTabs = type === "Stack" ? { showTabs: showTabsProp } : void 0;
93
+ const splitterSize = type === "Flexbox" ? {
94
+ splitterSize: (typeOf.typeOf(container) === "Flexbox" && container.props.splitterSize) ?? void 0
95
+ } : void 0;
96
+ const id = vuuUtils.uuid();
97
+ const wrapper = React.createElement(
98
+ ComponentRegistry.ComponentRegistry[type],
99
+ {
100
+ active,
101
+ id,
102
+ key: id,
103
+ path: propUtils.getProp(existingComponent, "path"),
104
+ flexFill: propUtils.getProp(existingComponent, "flexFill"),
105
+ ...splitterSize,
106
+ ...showTabs,
107
+ style,
108
+ title,
109
+ resizeable: propUtils.getProp(existingComponent, "resizeable")
110
+ },
111
+ targetFirst ? [
112
+ pathUtils.resetPath(
113
+ existingComponent,
114
+ `${existingComponentPath}.0`,
115
+ existingComponentProps
116
+ ),
117
+ layoutUtils.applyLayoutProps(
118
+ React.cloneElement(newComponent, newComponentProps),
119
+ `${existingComponentPath}.1`
120
+ )
121
+ ] : [
122
+ layoutUtils.applyLayoutProps(
123
+ React.cloneElement(newComponent, newComponentProps),
124
+ `${existingComponentPath}.0`
125
+ ),
126
+ pathUtils.resetPath(
127
+ existingComponent,
128
+ `${existingComponentPath}.1`,
129
+ existingComponentProps
130
+ )
131
+ ]
132
+ );
133
+ return containerChildren.map(
134
+ (child) => child === existingComponent ? wrapper : child
135
+ );
136
+ }
137
+ function wrapIntrinsicSizedComponent(containerChildren, existingComponent, newComponent, pos, clientRect, dropRect) {
138
+ const { flexDirection: flexDirection2 } = getLayoutSpecForWrapper(pos);
139
+ const contraDirection = flexDirection2 === "column" ? "row" : "column";
140
+ const targetFirst = isTargetFirst(pos);
141
+ const [dropLeft, dropTop, dropRight, dropBottom] = dropRect;
142
+ const [startPlaceholder, endPlaceholder] = flexDirection2 === "column" ? [dropTop - clientRect.top, clientRect.bottom - dropBottom] : [dropLeft - clientRect.left, clientRect.right - dropRight];
143
+ const pathRoot = propUtils.getProp(existingComponent, "path");
144
+ let pathIndex = 0;
145
+ const resizeProp = isHtmlElement(existingComponent) ? "data-resizeable" : "resizeable";
146
+ const wrappedChildren = [];
147
+ if (startPlaceholder) {
148
+ wrappedChildren.push(
149
+ targetFirst ? pathUtils.resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {
150
+ [resizeProp]: true,
151
+ style: { flexBasis: startPlaceholder, flexGrow: 1, flexShrink: 1 }
152
+ }) : flexUtils.createPlaceHolder(`${pathRoot}.${pathIndex++}`, startPlaceholder, {
153
+ flexGrow: 0,
154
+ flexShrink: 0
155
+ })
156
+ );
157
+ }
158
+ wrappedChildren.push(
159
+ flexUtils.wrapIntrinsicSizeComponentWithFlexbox(
160
+ newComponent,
161
+ contraDirection,
162
+ `${pathRoot}.${pathIndex++}`,
163
+ clientRect,
164
+ dropRect
165
+ )
166
+ );
167
+ if (endPlaceholder) {
168
+ wrappedChildren.push(
169
+ targetFirst ? flexUtils.createPlaceHolder(`${pathRoot}.${pathIndex++}`, 0) : pathUtils.resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {
170
+ [resizeProp]: true,
171
+ style: { flexBasis: 0, flexGrow: 1, flexShrink: 1 }
172
+ })
173
+ );
174
+ }
175
+ const wrapper = flexUtils.createFlexbox(
176
+ flexDirection2,
177
+ existingComponent.props,
178
+ wrappedChildren,
179
+ pathRoot
180
+ );
181
+ return containerChildren.map(
182
+ (child) => child === existingComponent ? wrapper : child
183
+ );
184
+ }
185
+ function getWrappedFlexStyles(type, existingComponent, newComponent, flexDirection2, pos) {
186
+ const style = {
187
+ ...existingComponent.props.style,
188
+ flexDirection: flexDirection2
189
+ };
190
+ const dimension = type === "Flexbox" && flexDirection2 === "column" ? "height" : "width";
191
+ const newComponentStyle = flexUtils.getFlexStyle(newComponent, dimension, pos);
192
+ const existingComponentStyle = flexUtils.getFlexStyle(existingComponent, dimension);
193
+ return [style, existingComponentStyle, newComponentStyle];
194
+ }
195
+ const isTargetFirst = (pos) => pos.position.SouthOrEast ? true : pos?.tab?.positionRelativeToTab === "before" ? false : pos.position.Header ? true : false;
196
+ function getLayoutSpecForWrapper(pos) {
197
+ if (pos.position.Header) {
198
+ return {
199
+ type: "Stack",
200
+ flexDirection: "column",
201
+ showTabs: true
202
+ };
203
+ } else {
204
+ return {
205
+ type: "Flexbox",
206
+ flexDirection: pos.position.EastOrWest ? "row" : "column"
207
+ };
208
+ }
209
+ }
210
+
211
+ exports.wrap = wrap;
212
+ //# sourceMappingURL=wrap-layout-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-layout-element.js","sources":["../../src/layout-reducer/wrap-layout-element.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { rectTuple, uuid } from \"@vuu-ui/vuu-utils\";\nimport React, { ReactElement } from \"react\";\nimport { DropPos } from \"../drag-drop/dragDropTypes\";\nimport { DropTarget } from \"../drag-drop/DropTarget\";\nimport { ComponentRegistry } from \"../registry/ComponentRegistry\";\nimport { getProp, getProps, nextStep, resetPath, typeOf } from \"../utils\";\nimport {\n createFlexbox,\n createPlaceHolder,\n flexDirection,\n getFlexStyle,\n getIntrinsicSize,\n wrapIntrinsicSizeComponentWithFlexbox,\n} from \"./flexUtils\";\nimport { LayoutModel } from \"./layoutTypes\";\nimport { applyLayoutProps, LayoutProps } from \"./layoutUtils\";\n\nexport interface LayoutSpec {\n type: \"Stack\" | \"Flexbox\";\n flexDirection: \"column\" | \"row\";\n showTabs?: boolean;\n}\n\nconst isHtmlElement = (component: LayoutModel) => {\n const [firstLetter] = typeOf(component) as string;\n return firstLetter === firstLetter.toLowerCase();\n};\n\nexport function wrap(\n container: ReactElement,\n existingComponent: ReactElement,\n newComponent: any,\n pos: DropPos,\n clientRect?: DropTarget[\"clientRect\"],\n dropRect?: DropTarget[\"dropRect\"]\n): ReactElement {\n const { children: containerChildren, path: containerPath } =\n getProps(container);\n\n const existingComponentPath = getProp(existingComponent, \"path\");\n const { idx, finalStep } = nextStep(containerPath, existingComponentPath);\n const children = finalStep\n ? updateChildren(\n container,\n containerChildren,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect\n )\n : containerChildren.map((child: ReactElement, index: number) =>\n index === idx\n ? wrap(\n child,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect\n )\n : child\n );\n\n return React.cloneElement(container, undefined, children);\n}\n\nfunction updateChildren(\n container: LayoutModel,\n containerChildren: ReactElement[],\n existingComponent: ReactElement,\n newComponent: ReactElement,\n pos: DropPos,\n clientRect?: DropTarget[\"clientRect\"],\n dropRect?: rectTuple\n) {\n const intrinsicSize = getIntrinsicSize(newComponent);\n\n if (intrinsicSize?.width && intrinsicSize?.height) {\n if (clientRect === undefined || dropRect === undefined) {\n throw Error(\n \"wrap-layout-element, updateChildren clientRect and dropRect must both be available\"\n );\n }\n return wrapIntrinsicSizedComponent(\n containerChildren,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect\n );\n }\n return wrapFlexComponent(\n container,\n containerChildren,\n existingComponent,\n newComponent,\n pos\n );\n}\n\nfunction wrapFlexComponent(\n container: LayoutModel,\n containerChildren: ReactElement[],\n existingComponent: ReactElement,\n newComponent: ReactElement,\n pos: DropPos\n) {\n const { version = 0 } = getProps(newComponent);\n const { path: existingComponentPath, title } = getProps(existingComponent);\n const {\n type,\n flexDirection,\n showTabs: showTabsProp,\n } = getLayoutSpecForWrapper(pos);\n const [style, existingComponentStyle, newComponentStyle] =\n getWrappedFlexStyles(\n type,\n existingComponent,\n newComponent,\n flexDirection,\n pos\n );\n const targetFirst = isTargetFirst(pos);\n const active = targetFirst ? 1 : 0;\n\n const newComponentProps = {\n resizeable: true,\n style: newComponentStyle,\n version: version + 1,\n };\n const resizeProp = isHtmlElement(existingComponent)\n ? \"data-resizeable\"\n : \"resizeable\";\n\n const existingComponentProps = {\n [resizeProp]: true,\n style: existingComponentStyle,\n };\n\n const showTabs = type === \"Stack\" ? { showTabs: showTabsProp } : undefined;\n const splitterSize =\n type === \"Flexbox\"\n ? {\n splitterSize:\n (typeOf(container) === \"Flexbox\" && container.props.splitterSize) ??\n undefined,\n }\n : undefined;\n\n const id = uuid();\n const wrapper = React.createElement(\n ComponentRegistry[type],\n {\n active,\n id,\n key: id,\n path: getProp(existingComponent, \"path\"),\n flexFill: getProp(existingComponent, \"flexFill\"),\n ...splitterSize,\n ...showTabs,\n style,\n title,\n resizeable: getProp(existingComponent, \"resizeable\"),\n } as LayoutProps,\n targetFirst\n ? [\n resetPath(\n existingComponent,\n `${existingComponentPath}.0`,\n existingComponentProps\n ),\n applyLayoutProps(\n React.cloneElement(newComponent, newComponentProps),\n `${existingComponentPath}.1`\n ),\n ]\n : [\n applyLayoutProps(\n React.cloneElement(newComponent, newComponentProps),\n `${existingComponentPath}.0`\n ),\n resetPath(\n existingComponent,\n `${existingComponentPath}.1`,\n existingComponentProps\n ),\n ]\n );\n return containerChildren.map((child: ReactElement) =>\n child === existingComponent ? wrapper : child\n );\n}\n\nfunction wrapIntrinsicSizedComponent(\n containerChildren: ReactElement[],\n existingComponent: ReactElement,\n newComponent: ReactElement,\n pos: DropPos,\n clientRect: DropTarget[\"clientRect\"],\n dropRect: rectTuple\n) {\n const { flexDirection } = getLayoutSpecForWrapper(pos);\n const contraDirection = flexDirection === \"column\" ? \"row\" : \"column\";\n const targetFirst = isTargetFirst(pos);\n\n const [dropLeft, dropTop, dropRight, dropBottom] = dropRect;\n const [startPlaceholder, endPlaceholder] =\n flexDirection === \"column\"\n ? [dropTop - clientRect.top, clientRect.bottom - dropBottom]\n : [dropLeft - clientRect.left, clientRect.right - dropRight];\n const pathRoot = getProp(existingComponent, \"path\");\n let pathIndex = 0;\n\n const resizeProp = isHtmlElement(existingComponent)\n ? \"data-resizeable\"\n : \"resizeable\";\n\n const wrappedChildren = [];\n if (startPlaceholder) {\n wrappedChildren.push(\n targetFirst\n ? resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {\n [resizeProp]: true,\n style: { flexBasis: startPlaceholder, flexGrow: 1, flexShrink: 1 },\n })\n : createPlaceHolder(`${pathRoot}.${pathIndex++}`, startPlaceholder, {\n flexGrow: 0,\n flexShrink: 0,\n })\n );\n }\n wrappedChildren.push(\n wrapIntrinsicSizeComponentWithFlexbox(\n newComponent,\n contraDirection,\n `${pathRoot}.${pathIndex++}`,\n clientRect,\n dropRect\n )\n );\n if (endPlaceholder) {\n wrappedChildren.push(\n targetFirst\n ? createPlaceHolder(`${pathRoot}.${pathIndex++}`, 0)\n : resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {\n [resizeProp]: true,\n style: { flexBasis: 0, flexGrow: 1, flexShrink: 1 },\n })\n );\n }\n\n const wrapper = createFlexbox(\n flexDirection,\n existingComponent.props,\n wrappedChildren,\n pathRoot\n );\n return containerChildren.map((child) =>\n child === existingComponent ? wrapper : child\n );\n}\n\nfunction getWrappedFlexStyles(\n type: string,\n existingComponent: ReactElement,\n newComponent: ReactElement,\n flexDirection: flexDirection,\n pos: DropPos\n) {\n const style = {\n ...existingComponent.props.style,\n flexDirection,\n };\n\n const dimension =\n type === \"Flexbox\" && flexDirection === \"column\" ? \"height\" : \"width\";\n const newComponentStyle = getFlexStyle(newComponent, dimension, pos);\n const existingComponentStyle = getFlexStyle(existingComponent, dimension);\n\n return [style, existingComponentStyle, newComponentStyle];\n}\n\nconst isTargetFirst = (pos: DropPos) =>\n pos.position.SouthOrEast\n ? true\n : pos?.tab?.positionRelativeToTab === \"before\"\n ? false\n : pos.position.Header\n ? true\n : false;\n\nfunction getLayoutSpecForWrapper(pos: DropPos): LayoutSpec {\n if (pos.position.Header) {\n return {\n type: \"Stack\",\n flexDirection: \"column\",\n showTabs: true,\n };\n } else {\n return {\n type: \"Flexbox\",\n flexDirection: pos.position.EastOrWest ? \"row\" : \"column\",\n };\n }\n}\n"],"names":["typeOf","getProps","getProp","nextStep","getIntrinsicSize","flexDirection","uuid","ComponentRegistry","resetPath","applyLayoutProps","createPlaceHolder","wrapIntrinsicSizeComponentWithFlexbox","createFlexbox","getFlexStyle"],"mappings":";;;;;;;;;;;AAwBA,MAAM,aAAA,GAAgB,CAAC,SAA2B,KAAA;AAChD,EAAA,MAAM,CAAC,WAAW,CAAI,GAAAA,aAAA,CAAO,SAAS,CAAA,CAAA;AACtC,EAAO,OAAA,WAAA,KAAgB,YAAY,WAAY,EAAA,CAAA;AACjD,CAAA,CAAA;AAEO,SAAS,KACd,SACA,EAAA,iBAAA,EACA,YACA,EAAA,GAAA,EACA,YACA,QACc,EAAA;AACd,EAAA,MAAM,EAAE,QAAU,EAAA,iBAAA,EAAmB,MAAM,aAAc,EAAA,GACvDC,mBAAS,SAAS,CAAA,CAAA;AAEpB,EAAM,MAAA,qBAAA,GAAwBC,iBAAQ,CAAA,iBAAA,EAAmB,MAAM,CAAA,CAAA;AAC/D,EAAA,MAAM,EAAE,GAAK,EAAA,SAAA,EAAc,GAAAC,kBAAA,CAAS,eAAe,qBAAqB,CAAA,CAAA;AACxE,EAAA,MAAM,WAAW,SACb,GAAA,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,IAAAA,cAAAA,KAAkB,WAAW,QAAW,GAAA,OAAA,CAAA;AAChE,EAAA,MAAM,iBAAoB,GAAAQ,sBAAA,CAAa,YAAc,EAAA,SAAA,EAAW,GAAG,CAAA,CAAA;AACnE,EAAM,MAAA,sBAAA,GAAyBA,sBAAa,CAAA,iBAAA,EAAmB,SAAS,CAAA,CAAA;AAExE,EAAO,OAAA,CAAC,KAAO,EAAA,sBAAA,EAAwB,iBAAiB,CAAA,CAAA;AAC1D,CAAA;AAEA,MAAM,aAAgB,GAAA,CAAC,GACrB,KAAA,GAAA,CAAI,SAAS,WACT,GAAA,IAAA,GACA,GAAK,EAAA,GAAA,EAAK,0BAA0B,QACpC,GAAA,KAAA,GACA,GAAI,CAAA,QAAA,CAAS,SACb,IACA,GAAA,KAAA,CAAA;AAEN,SAAS,wBAAwB,GAA0B,EAAA;AACzD,EAAI,IAAA,GAAA,CAAI,SAAS,MAAQ,EAAA;AACvB,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,aAAe,EAAA,QAAA;AAAA,MACf,QAAU,EAAA,IAAA;AAAA,KACZ,CAAA;AAAA,GACK,MAAA;AACL,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,aAAe,EAAA,GAAA,CAAI,QAAS,CAAA,UAAA,GAAa,KAAQ,GAAA,QAAA;AAAA,KACnD,CAAA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ var viewCss = ".vuuView {\n border-color: var(--vuuView-borderColor, var(--salt-container-primary-borderColor));\n border-width: var(--vuuView-borderWidth, 1px);\n border-style: var(--vuuView-borderStyle, none);\n\n display: flex;\n flex-direction: column;\n margin: var(--vuuView-margin, 0px);\n min-height: 50px;\n min-width: 50px;\n outline: none;\n overflow: hidden;\n position: relative;\n}\n\n.vuuView.focus-visible:after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border: dotted cornflowerblue 2px;\n}\n\n.vuuView.dragging {\n box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);\n}\n\n.vuuView-main {\n /* height: var(--view-content-height);\n width: var(--view-content-width); */\n display: flex;\n flex-direction: var(--vuuView-flexDirection, column);\n flex-wrap: var(--vuuView-flex-wrap, nowrap);\n flex: 1;\n justify-content: var(--vuuView-justify, flex-start);\n overflow: hidden;\n position: relative;\n}\n\n.vuuView-main > * {\n flex-basis: auto;\n flex-grow: var(--vuuView-flex-grow, 1);\n flex-shrink: var(--vuuView-flex-shrink, 1);\n}\n\n.vuuView-collapsed .vuuView-main {\n display: none;\n}\n\n.vuuView-collapsed + .Splitter {\n display: none;\n}\n\n.vuuView-collapsed .Toolbar-vertical {\n border-right: solid 1px var(--grey40);\n}\n\n.vuuView-collapsed .Toolbar-vertical .toolbar-title {\n display: none;\n}\n";
4
+
5
+ module.exports = viewCss;
6
+ //# sourceMappingURL=View.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"View.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,164 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var vuuUtils = require('@vuu-ui/vuu-utils');
5
+ var core = require('@salt-ds/core');
6
+ var styles = require('@salt-ds/styles');
7
+ var window = require('@salt-ds/window');
8
+ var cx = require('clsx');
9
+ var React = require('react');
10
+ var Header = require('../layout-header/Header.js');
11
+ var ComponentRegistry = require('../registry/ComponentRegistry.js');
12
+ var useView = require('./useView.js');
13
+ var useViewResize = require('./useViewResize.js');
14
+ require('../layout-provider/LayoutProviderContext.js');
15
+ require('../drag-drop/Draggable.js');
16
+ require('../drag-drop/BoxModel.js');
17
+ var ViewContext = require('../layout-view-actions/ViewContext.js');
18
+ var View$1 = require('./View.css.js');
19
+
20
+ const classBase = "vuuView";
21
+ const getProps = (state, props) => {
22
+ if (state && props) {
23
+ return {
24
+ ...state,
25
+ ...props
26
+ };
27
+ } else
28
+ return state || props;
29
+ };
30
+ const View = React.forwardRef(function View2(props, forwardedRef) {
31
+ const {
32
+ Header: Header$1 = Header.Header,
33
+ children,
34
+ className,
35
+ collapsed,
36
+ closeable,
37
+ "data-path": dataPath,
38
+ "data-resizeable": dataResizeable,
39
+ dropTargets,
40
+ expanded,
41
+ flexFill,
42
+ id: idProp,
43
+ header,
44
+ orientation = "horizontal",
45
+ path = dataPath,
46
+ resize = "responsive",
47
+ resizeable = dataResizeable,
48
+ tearOut,
49
+ style = {},
50
+ title: titleProp,
51
+ ...restProps
52
+ } = props;
53
+ const targetWindow = window.useWindow();
54
+ styles.useComponentCssInjection({
55
+ testId: "vuu-view",
56
+ css: View$1,
57
+ window: targetWindow
58
+ });
59
+ const id = vuuUtils.useId(idProp);
60
+ const rootRef = React.useRef(null);
61
+ const mainRef = React.useRef(null);
62
+ const [componentProps, _setComponentProps] = React.useState();
63
+ const {
64
+ contributions,
65
+ dispatchViewAction,
66
+ load,
67
+ loadSession,
68
+ onConfigChange,
69
+ onEditTitle,
70
+ purge,
71
+ restoredState,
72
+ save,
73
+ saveSession,
74
+ title
75
+ } = useView.useView({
76
+ id,
77
+ rootRef,
78
+ path,
79
+ dropTargets,
80
+ title: titleProp
81
+ });
82
+ useViewResize.useViewResize({ mainRef, resize, rootRef });
83
+ const setComponentProps = React.useCallback((props2) => {
84
+ _setComponentProps(props2);
85
+ }, []);
86
+ const getContent = () => {
87
+ if (React.isValidElement(children) && (restoredState || componentProps)) {
88
+ return React.cloneElement(
89
+ children,
90
+ getProps(restoredState, componentProps)
91
+ );
92
+ }
93
+ return children;
94
+ };
95
+ const viewContextValue = React.useMemo(
96
+ () => ({
97
+ dispatch: dispatchViewAction,
98
+ id,
99
+ path,
100
+ title,
101
+ load,
102
+ loadSession,
103
+ onConfigChange,
104
+ purge,
105
+ save,
106
+ saveSession,
107
+ setComponentProps
108
+ }),
109
+ [
110
+ dispatchViewAction,
111
+ id,
112
+ load,
113
+ loadSession,
114
+ onConfigChange,
115
+ path,
116
+ purge,
117
+ save,
118
+ saveSession,
119
+ setComponentProps,
120
+ title
121
+ ]
122
+ );
123
+ const headerProps = typeof header === "object" ? header : {};
124
+ return /* @__PURE__ */ jsxRuntime.jsx(
125
+ "div",
126
+ {
127
+ ...restProps,
128
+ className: cx(classBase, className, {
129
+ [`${classBase}-collapsed`]: collapsed,
130
+ [`${classBase}-expanded`]: expanded,
131
+ [`${classBase}-resize-defer`]: resize === "defer"
132
+ }),
133
+ "data-resizeable": resizeable,
134
+ id,
135
+ ref: core.useForkRef(forwardedRef, rootRef),
136
+ style,
137
+ tabIndex: -1,
138
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ViewContext.ViewContext.Provider, { value: viewContextValue, children: [
139
+ header ? /* @__PURE__ */ jsxRuntime.jsx(
140
+ Header$1,
141
+ {
142
+ ...headerProps,
143
+ collapsed,
144
+ contributions,
145
+ expanded,
146
+ closeable,
147
+ onEditTitle,
148
+ orientation,
149
+ tearOut,
150
+ title
151
+ }
152
+ ) : null,
153
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase}-main`, ref: mainRef, children: getContent() })
154
+ ] })
155
+ }
156
+ );
157
+ });
158
+ View.displayName = "View";
159
+ const MemoView = React.memo(View);
160
+ MemoView.displayName = "View";
161
+ ComponentRegistry.registerComponent("View", MemoView, "view");
162
+
163
+ exports.View = MemoView;
164
+ //# sourceMappingURL=View.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"View.js","sources":["../../src/layout-view/View.tsx"],"sourcesContent":["import { useId } from \"@vuu-ui/vuu-utils\";\nimport { useForkRef } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport cx from \"clsx\";\nimport React, {\n ForwardedRef,\n forwardRef,\n ReactElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Header as VuuHeader } from \"../layout-header/Header\";\nimport { registerComponent } from \"../registry/ComponentRegistry\";\nimport { useView } from \"./useView\";\nimport { useViewResize } from \"./useViewResize\";\nimport { ViewContext, ViewContextAPI } from \"../layout-view-actions\";\nimport { ViewProps } from \"./viewTypes\";\n\nimport viewCss from \"./View.css\";\n\nconst classBase = \"vuuView\";\n\ntype Props = { [key: string]: unknown };\n\nconst getProps = (state?: Props, props?: Props) => {\n if (state && props) {\n return {\n ...state,\n ...props,\n };\n } else return state || props;\n};\n\n/**\n * View is the leaf-level entity managed by the Vuu layout system. It may represent a component\n * or a group of components. It also offers an API (via useViewContext) for persistence.\n */\nconst View = forwardRef(function View(\n props: ViewProps,\n forwardedRef: ForwardedRef<HTMLDivElement>\n) {\n const {\n Header = VuuHeader,\n children,\n className,\n collapsed,\n closeable,\n \"data-path\": dataPath,\n \"data-resizeable\": dataResizeable,\n dropTargets,\n expanded,\n flexFill,\n id: idProp,\n header,\n orientation = \"horizontal\",\n path = dataPath,\n resize = \"responsive\",\n resizeable = dataResizeable,\n tearOut,\n style = {},\n title: titleProp,\n ...restProps\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-view\",\n css: viewCss,\n window: targetWindow,\n });\n\n const id = useId(idProp);\n const rootRef = useRef<HTMLDivElement>(null);\n const mainRef = useRef<HTMLDivElement>(null);\n const [componentProps, _setComponentProps] = useState<Props>();\n const {\n contributions,\n dispatchViewAction,\n load,\n loadSession,\n onConfigChange,\n onEditTitle,\n purge,\n restoredState,\n save,\n saveSession,\n title,\n } = useView({\n id,\n rootRef,\n path,\n dropTargets,\n title: titleProp,\n });\n\n useViewResize({ mainRef, resize, rootRef });\n\n const setComponentProps = useCallback((props?: Props) => {\n _setComponentProps(props);\n }, []);\n\n const getContent = () => {\n if (React.isValidElement(children) && (restoredState || componentProps)) {\n return React.cloneElement(\n children,\n getProps(restoredState, componentProps)\n );\n }\n return children;\n };\n\n const viewContextValue: ViewContextAPI = useMemo(\n () => ({\n dispatch: dispatchViewAction,\n id,\n path,\n title,\n load,\n loadSession,\n onConfigChange,\n purge,\n save,\n saveSession,\n setComponentProps,\n }),\n [\n dispatchViewAction,\n id,\n load,\n loadSession,\n onConfigChange,\n path,\n purge,\n save,\n saveSession,\n setComponentProps,\n title,\n ]\n );\n\n const headerProps = typeof header === \"object\" ? header : {};\n\n return (\n <div\n {...restProps}\n className={cx(classBase, className, {\n [`${classBase}-collapsed`]: collapsed,\n [`${classBase}-expanded`]: expanded,\n [`${classBase}-resize-defer`]: resize === \"defer\",\n })}\n data-resizeable={resizeable}\n id={id}\n ref={useForkRef(forwardedRef, rootRef)}\n style={style}\n tabIndex={-1}\n >\n <ViewContext.Provider value={viewContextValue}>\n {header ? (\n <Header\n {...headerProps}\n collapsed={collapsed}\n contributions={contributions}\n expanded={expanded}\n closeable={closeable}\n onEditTitle={onEditTitle}\n orientation={orientation}\n tearOut={tearOut}\n title={title}\n />\n ) : null}\n <div className={`${classBase}-main`} ref={mainRef}>\n {getContent()}\n </div>\n </ViewContext.Provider>\n </div>\n );\n});\nView.displayName = \"View\";\n\ninterface ViewComponentType {\n (\n props: ViewProps & {\n ref?: ForwardedRef<HTMLDivElement>;\n }\n ): ReactElement<ViewProps>;\n displayName?: string;\n}\n\nconst MemoView = React.memo(View) as ViewComponentType;\n\nMemoView.displayName = \"View\";\n\nregisterComponent(\"View\", MemoView, \"view\");\n\nexport { MemoView as View };\n"],"names":["forwardRef","View","Header","VuuHeader","useWindow","useComponentCssInjection","viewCss","useId","useRef","useState","useView","useViewResize","useCallback","props","useMemo","jsx","useForkRef","jsxs","ViewContext","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAM,SAAY,GAAA,SAAA,CAAA;AAIlB,MAAM,QAAA,GAAW,CAAC,KAAA,EAAe,KAAkB,KAAA;AACjD,EAAA,IAAI,SAAS,KAAO,EAAA;AAClB,IAAO,OAAA;AAAA,MACL,GAAG,KAAA;AAAA,MACH,GAAG,KAAA;AAAA,KACL,CAAA;AAAA,GACF;AAAO,IAAA,OAAO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,KAAM,CAAA,IAAA,CAAK,IAAI,EAAA;AAEhC,QAAA,CAAS,WAAc,GAAA,MAAA,CAAA;AAEvBI,mCAAkB,CAAA,MAAA,EAAQ,UAAU,MAAM,CAAA;;;;"}
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var LayoutProvider = require('../layout-provider/LayoutProvider.js');
5
+ require('../layout-provider/LayoutProviderContext.js');
6
+ var usePersistentState = require('../use-persistent-state.js');
7
+ var useViewActionDispatcher = require('../layout-view-actions/useViewActionDispatcher.js');
8
+
9
+ const useView = ({
10
+ id,
11
+ rootRef,
12
+ path,
13
+ dropTargets,
14
+ title: titleProp
15
+ }) => {
16
+ const layoutDispatch = LayoutProvider.useLayoutProviderDispatch();
17
+ const {
18
+ loadState,
19
+ loadSessionState,
20
+ purgeState,
21
+ saveState,
22
+ saveSessionState
23
+ } = usePersistentState.usePersistentState();
24
+ const [dispatchViewAction, contributions] = useViewActionDispatcher.useViewActionDispatcher(
25
+ id,
26
+ rootRef,
27
+ path,
28
+ dropTargets
29
+ );
30
+ const title = React.useMemo(
31
+ () => loadState("view-title") ?? titleProp,
32
+ [loadState, titleProp]
33
+ );
34
+ const onEditTitle = React.useCallback(
35
+ (title2) => {
36
+ if (path) {
37
+ layoutDispatch({ type: "set-title", path, title: title2 });
38
+ }
39
+ },
40
+ [layoutDispatch, path]
41
+ );
42
+ const restoredState = React.useMemo(() => loadState(id), [id, loadState]);
43
+ const load = React.useCallback(
44
+ (key) => loadState(id, key),
45
+ [id, loadState]
46
+ );
47
+ const purge = React.useCallback(
48
+ (key) => {
49
+ purgeState(id, key);
50
+ layoutDispatch({ type: "save" });
51
+ },
52
+ [id, layoutDispatch, purgeState]
53
+ );
54
+ const save = React.useCallback(
55
+ (state, key) => {
56
+ saveState(id, key, state);
57
+ layoutDispatch({ type: "save" });
58
+ },
59
+ [id, layoutDispatch, saveState]
60
+ );
61
+ const loadSession = React.useCallback(
62
+ (key) => loadSessionState(id, key),
63
+ [id, loadSessionState]
64
+ );
65
+ const saveSession = React.useCallback(
66
+ (state, key) => saveSessionState(id, key, state),
67
+ [id, saveSessionState]
68
+ );
69
+ const onConfigChange = React.useCallback(
70
+ ({ type: key, ...config }) => {
71
+ const { [key]: data } = config;
72
+ save(data, key);
73
+ },
74
+ [save]
75
+ );
76
+ return {
77
+ contributions,
78
+ dispatchViewAction,
79
+ load,
80
+ loadSession,
81
+ onConfigChange,
82
+ onEditTitle,
83
+ purge,
84
+ restoredState,
85
+ save,
86
+ saveSession,
87
+ title
88
+ };
89
+ };
90
+
91
+ exports.useView = useView;
92
+ //# sourceMappingURL=useView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useView.js","sources":["../../src/layout-view/useView.tsx"],"sourcesContent":["import { RefObject, useCallback, useMemo } from \"react\";\nimport { useLayoutProviderDispatch } from \"../layout-provider\";\nimport { usePersistentState } from \"../use-persistent-state\";\nimport { useViewActionDispatcher } from \"../layout-view-actions/useViewActionDispatcher\";\n\nexport interface ViewHookProps {\n id: string;\n rootRef: RefObject<HTMLDivElement>;\n path?: string;\n dropTargets?: string[];\n title?: string;\n}\n\nexport const useView = ({\n id,\n rootRef,\n path,\n dropTargets,\n title: titleProp,\n}: ViewHookProps) => {\n const layoutDispatch = useLayoutProviderDispatch();\n\n const {\n loadState,\n loadSessionState,\n purgeState,\n saveState,\n saveSessionState,\n } = usePersistentState();\n\n const [dispatchViewAction, contributions] = useViewActionDispatcher(\n id,\n rootRef,\n path,\n dropTargets\n );\n\n const title = useMemo(\n () => loadState(\"view-title\") ?? titleProp,\n [loadState, titleProp]\n );\n\n const onEditTitle = useCallback(\n (title: string) => {\n if (path) {\n layoutDispatch({ type: \"set-title\", path, title });\n }\n },\n [layoutDispatch, path]\n );\n\n const restoredState = useMemo(() => loadState(id), [id, loadState]);\n\n const load = useCallback(\n (key?: string) => loadState(id, key),\n [id, loadState]\n );\n\n const purge = useCallback(\n (key) => {\n purgeState(id, key);\n layoutDispatch({ type: \"save\" });\n },\n [id, layoutDispatch, purgeState]\n );\n\n const save = useCallback(\n (state, key) => {\n saveState(id, key, state);\n layoutDispatch({ type: \"save\" });\n },\n [id, layoutDispatch, saveState]\n );\n const loadSession = useCallback(\n (key?: string) => loadSessionState(id, key),\n [id, loadSessionState]\n );\n const saveSession = useCallback(\n (state, key) => saveSessionState(id, key, state),\n [id, saveSessionState]\n );\n\n const onConfigChange = useCallback(\n ({ type: key, ...config }) => {\n const { [key]: data } = config;\n save(data, key);\n },\n [save]\n );\n\n return {\n contributions,\n dispatchViewAction,\n load,\n loadSession,\n onConfigChange,\n onEditTitle,\n purge,\n restoredState,\n save,\n saveSession,\n title,\n };\n};\n"],"names":["useLayoutProviderDispatch","usePersistentState","useViewActionDispatcher","useMemo","useCallback","title"],"mappings":";;;;;;;;AAaO,MAAM,UAAU,CAAC;AAAA,EACtB,EAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAO,EAAA,SAAA;AACT,CAAqB,KAAA;AACnB,EAAA,MAAM,iBAAiBA,wCAA0B,EAAA,CAAA;AAEjD,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,gBAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,IACA,gBAAA;AAAA,MACEC,qCAAmB,EAAA,CAAA;AAEvB,EAAM,MAAA,CAAC,kBAAoB,EAAA,aAAa,CAAI,GAAAC,+CAAA;AAAA,IAC1C,EAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,KAAQ,GAAAC,aAAA;AAAA,IACZ,MAAM,SAAU,CAAA,YAAY,CAAK,IAAA,SAAA;AAAA,IACjC,CAAC,WAAW,SAAS,CAAA;AAAA,GACvB,CAAA;AAEA,EAAA,MAAM,WAAc,GAAAC,iBAAA;AAAA,IAClB,CAACC,MAAkB,KAAA;AACjB,MAAA,IAAI,IAAM,EAAA;A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AAA,GAAA,KAAQ,gBAAiB,CAAA,EAAA,EAAI,KAAK,KAAK,CAAA;AAAA,IAC/C,CAAC,IAAI,gBAAgB,CAAA;AAAA,GACvB,CAAA;AAEA,EAAA,MAAM,cAAiB,GAAAA,iBAAA;AAAA,IACrB,CAAC,EAAE,IAAA,EAAM,GAAK,EAAA,GAAG,QAAa,KAAA;AAC5B,MAAA,MAAM,EAAE,CAAC,GAAG,GAAG,MAAS,GAAA,MAAA,CAAA;AACxB,MAAA,IAAA,CAAK,MAAM,GAAG,CAAA,CAAA;AAAA,KAChB;AAAA,IACA,CAAC,IAAI,CAAA;AAAA,GACP,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,kBAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var useResizeObserver = require('../responsive/useResizeObserver.js');
5
+
6
+ const NO_MEASUREMENT = [];
7
+ const useViewResize = ({
8
+ mainRef,
9
+ resize = "responsive",
10
+ rootRef
11
+ }) => {
12
+ const deferResize = resize === "defer";
13
+ const mainSize = React.useRef({});
14
+ const resizeHandle = React.useRef();
15
+ const setMainSize = React.useCallback(() => {
16
+ if (mainRef.current) {
17
+ mainRef.current.style.height = mainSize.current.height + "px";
18
+ mainRef.current.style.width = mainSize.current.width + "px";
19
+ }
20
+ resizeHandle.current = void 0;
21
+ }, [mainRef]);
22
+ const onResize = React.useCallback(
23
+ ({ height, width }) => {
24
+ mainSize.current.height = height;
25
+ mainSize.current.width = width;
26
+ if (resizeHandle.current !== null) {
27
+ clearTimeout(resizeHandle.current);
28
+ }
29
+ resizeHandle.current = window.setTimeout(setMainSize, 40);
30
+ },
31
+ [setMainSize]
32
+ );
33
+ useResizeObserver.useResizeObserver(
34
+ rootRef,
35
+ deferResize ? useResizeObserver.WidthHeight : NO_MEASUREMENT,
36
+ onResize,
37
+ deferResize
38
+ );
39
+ };
40
+
41
+ exports.useViewResize = useViewResize;
42
+ //# sourceMappingURL=useViewResize.js.map