@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,58 @@
1
+ import React from 'react';
2
+ import { followPath } from '../utils/pathUtils.js';
3
+ import { getProps } from '../utils/propUtils.js';
4
+ import { swapChild } from './replace-layout-element.js';
5
+
6
+ function resizeFlexChild(layoutRoot, { path, size }) {
7
+ const target = followPath(layoutRoot, path, true);
8
+ const { style } = getProps(target);
9
+ const newStyle = {
10
+ ...style,
11
+ width: size
12
+ };
13
+ const replacement = React.cloneElement(target, { style: newStyle });
14
+ return swapChild(layoutRoot, target, replacement);
15
+ }
16
+ function resizeFlexChildren(layoutRoot, { path, sizes }) {
17
+ const target = followPath(layoutRoot, path, true);
18
+ const { children, style } = getProps(target);
19
+ const dimension2 = style.flexDirection === "column" ? "height" : "width";
20
+ const replacementChildren = applySizesToChildren(children, sizes, dimension2);
21
+ const replacement = React.cloneElement(
22
+ target,
23
+ void 0,
24
+ replacementChildren
25
+ );
26
+ return swapChild(layoutRoot, target, replacement);
27
+ }
28
+ function applySizesToChildren(children, sizes, dimension2) {
29
+ return children.map((child, i) => {
30
+ const {
31
+ style: { [dimension2]: size, flexBasis: actualFlexBasis }
32
+ } = getProps(child);
33
+ const meta = sizes[i];
34
+ const { currentSize, flexBasis } = meta;
35
+ const hasCurrentSize = currentSize !== void 0;
36
+ const newSize = hasCurrentSize ? meta.currentSize : flexBasis;
37
+ if (newSize === void 0 || size === newSize || actualFlexBasis === newSize) {
38
+ return child;
39
+ }
40
+ return React.cloneElement(child, {
41
+ style: applySizeToChild(child.props.style, dimension2, newSize)
42
+ });
43
+ });
44
+ }
45
+ function applySizeToChild(style, dimension2, newSize) {
46
+ const hasSize = typeof style[dimension2] === "number";
47
+ const { flexShrink = 1, flexGrow = 1 } = style;
48
+ return {
49
+ ...style,
50
+ [dimension2]: hasSize ? newSize : "auto",
51
+ flexBasis: hasSize ? "auto" : newSize,
52
+ flexShrink,
53
+ flexGrow
54
+ };
55
+ }
56
+
57
+ export { resizeFlexChild, resizeFlexChildren };
58
+ //# 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":["dimension"],"mappings":";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
3
+ import { ComponentRegistry } from '../registry/ComponentRegistry.js';
4
+ import { nextStep, resetPath } from '../utils/pathUtils.js';
5
+ import { getProps, getProp } from '../utils/propUtils.js';
6
+ import { typeOf } from '../utils/typeOf.js';
7
+ import { getIntrinsicSize, createPlaceHolder, wrapIntrinsicSizeComponentWithFlexbox, createFlexbox, getFlexStyle } from './flexUtils.js';
8
+ import { applyLayoutProps } from './layoutUtils.js';
9
+
10
+ const isHtmlElement = (component) => {
11
+ const [firstLetter] = typeOf(component);
12
+ return firstLetter === firstLetter.toLowerCase();
13
+ };
14
+ function wrap(container, existingComponent, newComponent, pos, clientRect, dropRect) {
15
+ const { children: containerChildren, path: containerPath } = getProps(container);
16
+ const existingComponentPath = getProp(existingComponent, "path");
17
+ const { idx, finalStep } = nextStep(containerPath, existingComponentPath);
18
+ const children = finalStep ? updateChildren(
19
+ container,
20
+ containerChildren,
21
+ existingComponent,
22
+ newComponent,
23
+ pos,
24
+ clientRect,
25
+ dropRect
26
+ ) : containerChildren.map(
27
+ (child, index) => index === idx ? wrap(
28
+ child,
29
+ existingComponent,
30
+ newComponent,
31
+ pos,
32
+ clientRect,
33
+ dropRect
34
+ ) : child
35
+ );
36
+ return React.cloneElement(container, void 0, children);
37
+ }
38
+ function updateChildren(container, containerChildren, existingComponent, newComponent, pos, clientRect, dropRect) {
39
+ const intrinsicSize = getIntrinsicSize(newComponent);
40
+ if (intrinsicSize?.width && intrinsicSize?.height) {
41
+ if (clientRect === void 0 || dropRect === void 0) {
42
+ throw Error(
43
+ "wrap-layout-element, updateChildren clientRect and dropRect must both be available"
44
+ );
45
+ }
46
+ return wrapIntrinsicSizedComponent(
47
+ containerChildren,
48
+ existingComponent,
49
+ newComponent,
50
+ pos,
51
+ clientRect,
52
+ dropRect
53
+ );
54
+ }
55
+ return wrapFlexComponent(
56
+ container,
57
+ containerChildren,
58
+ existingComponent,
59
+ newComponent,
60
+ pos
61
+ );
62
+ }
63
+ function wrapFlexComponent(container, containerChildren, existingComponent, newComponent, pos) {
64
+ const { version = 0 } = getProps(newComponent);
65
+ const { path: existingComponentPath, title } = getProps(existingComponent);
66
+ const {
67
+ type,
68
+ flexDirection: flexDirection2,
69
+ showTabs: showTabsProp
70
+ } = getLayoutSpecForWrapper(pos);
71
+ const [style, existingComponentStyle, newComponentStyle] = getWrappedFlexStyles(
72
+ type,
73
+ existingComponent,
74
+ newComponent,
75
+ flexDirection2,
76
+ pos
77
+ );
78
+ const targetFirst = isTargetFirst(pos);
79
+ const active = targetFirst ? 1 : 0;
80
+ const newComponentProps = {
81
+ resizeable: true,
82
+ style: newComponentStyle,
83
+ version: version + 1
84
+ };
85
+ const resizeProp = isHtmlElement(existingComponent) ? "data-resizeable" : "resizeable";
86
+ const existingComponentProps = {
87
+ [resizeProp]: true,
88
+ style: existingComponentStyle
89
+ };
90
+ const showTabs = type === "Stack" ? { showTabs: showTabsProp } : void 0;
91
+ const splitterSize = type === "Flexbox" ? {
92
+ splitterSize: (typeOf(container) === "Flexbox" && container.props.splitterSize) ?? void 0
93
+ } : void 0;
94
+ const id = uuid();
95
+ const wrapper = React.createElement(
96
+ ComponentRegistry[type],
97
+ {
98
+ active,
99
+ id,
100
+ key: id,
101
+ path: getProp(existingComponent, "path"),
102
+ flexFill: getProp(existingComponent, "flexFill"),
103
+ ...splitterSize,
104
+ ...showTabs,
105
+ style,
106
+ title,
107
+ resizeable: getProp(existingComponent, "resizeable")
108
+ },
109
+ targetFirst ? [
110
+ resetPath(
111
+ existingComponent,
112
+ `${existingComponentPath}.0`,
113
+ existingComponentProps
114
+ ),
115
+ applyLayoutProps(
116
+ React.cloneElement(newComponent, newComponentProps),
117
+ `${existingComponentPath}.1`
118
+ )
119
+ ] : [
120
+ applyLayoutProps(
121
+ React.cloneElement(newComponent, newComponentProps),
122
+ `${existingComponentPath}.0`
123
+ ),
124
+ resetPath(
125
+ existingComponent,
126
+ `${existingComponentPath}.1`,
127
+ existingComponentProps
128
+ )
129
+ ]
130
+ );
131
+ return containerChildren.map(
132
+ (child) => child === existingComponent ? wrapper : child
133
+ );
134
+ }
135
+ function wrapIntrinsicSizedComponent(containerChildren, existingComponent, newComponent, pos, clientRect, dropRect) {
136
+ const { flexDirection: flexDirection2 } = getLayoutSpecForWrapper(pos);
137
+ const contraDirection = flexDirection2 === "column" ? "row" : "column";
138
+ const targetFirst = isTargetFirst(pos);
139
+ const [dropLeft, dropTop, dropRight, dropBottom] = dropRect;
140
+ const [startPlaceholder, endPlaceholder] = flexDirection2 === "column" ? [dropTop - clientRect.top, clientRect.bottom - dropBottom] : [dropLeft - clientRect.left, clientRect.right - dropRight];
141
+ const pathRoot = getProp(existingComponent, "path");
142
+ let pathIndex = 0;
143
+ const resizeProp = isHtmlElement(existingComponent) ? "data-resizeable" : "resizeable";
144
+ const wrappedChildren = [];
145
+ if (startPlaceholder) {
146
+ wrappedChildren.push(
147
+ targetFirst ? resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {
148
+ [resizeProp]: true,
149
+ style: { flexBasis: startPlaceholder, flexGrow: 1, flexShrink: 1 }
150
+ }) : createPlaceHolder(`${pathRoot}.${pathIndex++}`, startPlaceholder, {
151
+ flexGrow: 0,
152
+ flexShrink: 0
153
+ })
154
+ );
155
+ }
156
+ wrappedChildren.push(
157
+ wrapIntrinsicSizeComponentWithFlexbox(
158
+ newComponent,
159
+ contraDirection,
160
+ `${pathRoot}.${pathIndex++}`,
161
+ clientRect,
162
+ dropRect
163
+ )
164
+ );
165
+ if (endPlaceholder) {
166
+ wrappedChildren.push(
167
+ targetFirst ? createPlaceHolder(`${pathRoot}.${pathIndex++}`, 0) : resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {
168
+ [resizeProp]: true,
169
+ style: { flexBasis: 0, flexGrow: 1, flexShrink: 1 }
170
+ })
171
+ );
172
+ }
173
+ const wrapper = createFlexbox(
174
+ flexDirection2,
175
+ existingComponent.props,
176
+ wrappedChildren,
177
+ pathRoot
178
+ );
179
+ return containerChildren.map(
180
+ (child) => child === existingComponent ? wrapper : child
181
+ );
182
+ }
183
+ function getWrappedFlexStyles(type, existingComponent, newComponent, flexDirection2, pos) {
184
+ const style = {
185
+ ...existingComponent.props.style,
186
+ flexDirection: flexDirection2
187
+ };
188
+ const dimension = type === "Flexbox" && flexDirection2 === "column" ? "height" : "width";
189
+ const newComponentStyle = getFlexStyle(newComponent, dimension, pos);
190
+ const existingComponentStyle = getFlexStyle(existingComponent, dimension);
191
+ return [style, existingComponentStyle, newComponentStyle];
192
+ }
193
+ const isTargetFirst = (pos) => pos.position.SouthOrEast ? true : pos?.tab?.positionRelativeToTab === "before" ? false : pos.position.Header ? true : false;
194
+ function getLayoutSpecForWrapper(pos) {
195
+ if (pos.position.Header) {
196
+ return {
197
+ type: "Stack",
198
+ flexDirection: "column",
199
+ showTabs: true
200
+ };
201
+ } else {
202
+ return {
203
+ type: "Flexbox",
204
+ flexDirection: pos.position.EastOrWest ? "row" : "column"
205
+ };
206
+ }
207
+ }
208
+
209
+ export { wrap };
210
+ //# 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":["flexDirection"],"mappings":";;;;;;;;;AAwBA,MAAM,aAAA,GAAgB,CAAC,SAA2B,KAAA;AAChD,EAAA,MAAM,CAAC,WAAW,CAAI,GAAA,MAAA,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,GACvD,SAAS,SAAS,CAAA,CAAA;AAEpB,EAAM,MAAA,qBAAA,GAAwB,OAAQ,CAAA,iBAAA,EAAmB,MAAM,CAAA,CAAA;AAC/D,EAAA,MAAM,EAAE,GAAK,EAAA,SAAA,EAAc,GAAA,QAAA,CAAS,eAAe,qBAAqB,CAAA,CAAA;AACxE,EAAA,MAAM,WAAW,SACb,GAAA,cAAA;AAAA,IACE,SAAA;AAAA,IACA,iBAAA;AAAA,IACA,iBAAA;AAAA,IACA,YAAA;AAAA,IACA,GAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,MAEF,iBAAkB,CAAA,GAAA;AAAA,IAAI,CAAC,KAAA,EAAqB,KAC1C,KAAA,KAAA,KAAU,GACN,GAAA,IAAA;AAAA,MACE,KAAA;AAAA,MACA,iBAAA;AAAA,MACA,YAAA;AAAA,MACA,GAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,KAEF,GAAA,KAAA;AAAA,GACN,CAAA;AAEJ,EAAA,OAAO,KAAM,CAAA,YAAA,CAA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AAA,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,4 @@
1
+ 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";
2
+
3
+ export { viewCss as default };
4
+ //# sourceMappingURL=View.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"View.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,162 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useId } from '@vuu-ui/vuu-utils';
3
+ import { useForkRef } from '@salt-ds/core';
4
+ import { useComponentCssInjection } from '@salt-ds/styles';
5
+ import { useWindow } from '@salt-ds/window';
6
+ import cx from 'clsx';
7
+ import React, { forwardRef, useRef, useState, useCallback, useMemo } from 'react';
8
+ import { Header } from '../layout-header/Header.js';
9
+ import { registerComponent } from '../registry/ComponentRegistry.js';
10
+ import { useView } from './useView.js';
11
+ import { useViewResize } from './useViewResize.js';
12
+ import '../layout-provider/LayoutProviderContext.js';
13
+ import '../drag-drop/Draggable.js';
14
+ import '../drag-drop/BoxModel.js';
15
+ import { ViewContext } from '../layout-view-actions/ViewContext.js';
16
+ import viewCss from './View.css.js';
17
+
18
+ const classBase = "vuuView";
19
+ const getProps = (state, props) => {
20
+ if (state && props) {
21
+ return {
22
+ ...state,
23
+ ...props
24
+ };
25
+ } else
26
+ return state || props;
27
+ };
28
+ const View = forwardRef(function View2(props, forwardedRef) {
29
+ const {
30
+ Header: Header$1 = Header,
31
+ children,
32
+ className,
33
+ collapsed,
34
+ closeable,
35
+ "data-path": dataPath,
36
+ "data-resizeable": dataResizeable,
37
+ dropTargets,
38
+ expanded,
39
+ flexFill,
40
+ id: idProp,
41
+ header,
42
+ orientation = "horizontal",
43
+ path = dataPath,
44
+ resize = "responsive",
45
+ resizeable = dataResizeable,
46
+ tearOut,
47
+ style = {},
48
+ title: titleProp,
49
+ ...restProps
50
+ } = props;
51
+ const targetWindow = useWindow();
52
+ useComponentCssInjection({
53
+ testId: "vuu-view",
54
+ css: viewCss,
55
+ window: targetWindow
56
+ });
57
+ const id = useId(idProp);
58
+ const rootRef = useRef(null);
59
+ const mainRef = useRef(null);
60
+ const [componentProps, _setComponentProps] = useState();
61
+ const {
62
+ contributions,
63
+ dispatchViewAction,
64
+ load,
65
+ loadSession,
66
+ onConfigChange,
67
+ onEditTitle,
68
+ purge,
69
+ restoredState,
70
+ save,
71
+ saveSession,
72
+ title
73
+ } = useView({
74
+ id,
75
+ rootRef,
76
+ path,
77
+ dropTargets,
78
+ title: titleProp
79
+ });
80
+ useViewResize({ mainRef, resize, rootRef });
81
+ const setComponentProps = useCallback((props2) => {
82
+ _setComponentProps(props2);
83
+ }, []);
84
+ const getContent = () => {
85
+ if (React.isValidElement(children) && (restoredState || componentProps)) {
86
+ return React.cloneElement(
87
+ children,
88
+ getProps(restoredState, componentProps)
89
+ );
90
+ }
91
+ return children;
92
+ };
93
+ const viewContextValue = useMemo(
94
+ () => ({
95
+ dispatch: dispatchViewAction,
96
+ id,
97
+ path,
98
+ title,
99
+ load,
100
+ loadSession,
101
+ onConfigChange,
102
+ purge,
103
+ save,
104
+ saveSession,
105
+ setComponentProps
106
+ }),
107
+ [
108
+ dispatchViewAction,
109
+ id,
110
+ load,
111
+ loadSession,
112
+ onConfigChange,
113
+ path,
114
+ purge,
115
+ save,
116
+ saveSession,
117
+ setComponentProps,
118
+ title
119
+ ]
120
+ );
121
+ const headerProps = typeof header === "object" ? header : {};
122
+ return /* @__PURE__ */ jsx(
123
+ "div",
124
+ {
125
+ ...restProps,
126
+ className: cx(classBase, className, {
127
+ [`${classBase}-collapsed`]: collapsed,
128
+ [`${classBase}-expanded`]: expanded,
129
+ [`${classBase}-resize-defer`]: resize === "defer"
130
+ }),
131
+ "data-resizeable": resizeable,
132
+ id,
133
+ ref: useForkRef(forwardedRef, rootRef),
134
+ style,
135
+ tabIndex: -1,
136
+ children: /* @__PURE__ */ jsxs(ViewContext.Provider, { value: viewContextValue, children: [
137
+ header ? /* @__PURE__ */ jsx(
138
+ Header$1,
139
+ {
140
+ ...headerProps,
141
+ collapsed,
142
+ contributions,
143
+ expanded,
144
+ closeable,
145
+ onEditTitle,
146
+ orientation,
147
+ tearOut,
148
+ title
149
+ }
150
+ ) : null,
151
+ /* @__PURE__ */ jsx("div", { className: `${classBase}-main`, ref: mainRef, children: getContent() })
152
+ ] })
153
+ }
154
+ );
155
+ });
156
+ View.displayName = "View";
157
+ const MemoView = React.memo(View);
158
+ MemoView.displayName = "View";
159
+ registerComponent("View", MemoView, "view");
160
+
161
+ export { MemoView as View };
162
+ //# 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":["View","Header","VuuHeader","props"],"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,KAAS,IAAA,KAAA,CAAA;AACzB,CAAA,CAAA;AAMA,MAAM,IAAO,GAAA,UAAA,CAAW,SAASA,KAAAA,CAC/B,OACA,YACA,EAAA;AACA,EAAM,MAAA;AAAA,YACJC,QAAS,GAAAC,MAAA;AAAA,IACT,QAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAa,EAAA,QAAA;AAAA,IACb,iBAAmB,EAAA,cAAA;AAAA,IACnB,WAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,EAAI,EAAA,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,WAAc,GAAA,YAAA;AAAA,IACd,IAAO,GAAA,QAAA;AAAA,IACP,MAAS,GAAA,YAAA;AAAA,IACT,UAAa,GAAA,cAAA;AAAA,IACb,OAAA;AAAA,IACA,QAAQ,EAAC;AAAA,IACT,KAAO,EAAA,SAAA;AAAA,IACP,GAAG,SAAA;AAAA,GACD,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,eAAe,S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QAAA,EAAA;AAAA,QACC,MAAA,mBAAA,GAAA;AAAA,UAACF,QAAA;AAAA,UAAA;AAAA,YACE,GAAG,WAAA;AAAA,YACJ,SAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAA;AAAA,YACA,SAAA;AAAA,YACA,WAAA;AAAA,YACA,WAAA;AAAA,YACA,OAAA;AAAA,YACA,KAAA;AAAA,WAAA;AAAA,SAEA,GAAA,IAAA;AAAA,wBACJ,GAAA,CAAC,SAAI,SAAW,EAAA,CAAA,EAAG,SAAS,CAAS,KAAA,CAAA,EAAA,GAAA,EAAK,OACvC,EAAA,QAAA,EAAA,UAAA,EACH,EAAA,CAAA;AAAA,OACF,EAAA,CAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ,CAAC,CAAA,CAAA;AACD,IAAA,CAAK,WAAc,GAAA,MAAA,CAAA;AAWb,MAAA,QAAA,GAAW,KAAM,CAAA,IAAA,CAAK,IAAI,EAAA;AAEhC,QAAA,CAAS,WAAc,GAAA,MAAA,CAAA;AAEvB,iBAAkB,CAAA,MAAA,EAAQ,UAAU,MAAM,CAAA;;;;"}
@@ -0,0 +1,90 @@
1
+ import { useMemo, useCallback } from 'react';
2
+ import { useLayoutProviderDispatch } from '../layout-provider/LayoutProvider.js';
3
+ import '../layout-provider/LayoutProviderContext.js';
4
+ import { usePersistentState } from '../use-persistent-state.js';
5
+ import { useViewActionDispatcher } from '../layout-view-actions/useViewActionDispatcher.js';
6
+
7
+ const useView = ({
8
+ id,
9
+ rootRef,
10
+ path,
11
+ dropTargets,
12
+ title: titleProp
13
+ }) => {
14
+ const layoutDispatch = useLayoutProviderDispatch();
15
+ const {
16
+ loadState,
17
+ loadSessionState,
18
+ purgeState,
19
+ saveState,
20
+ saveSessionState
21
+ } = usePersistentState();
22
+ const [dispatchViewAction, contributions] = useViewActionDispatcher(
23
+ id,
24
+ rootRef,
25
+ path,
26
+ dropTargets
27
+ );
28
+ const title = useMemo(
29
+ () => loadState("view-title") ?? titleProp,
30
+ [loadState, titleProp]
31
+ );
32
+ const onEditTitle = useCallback(
33
+ (title2) => {
34
+ if (path) {
35
+ layoutDispatch({ type: "set-title", path, title: title2 });
36
+ }
37
+ },
38
+ [layoutDispatch, path]
39
+ );
40
+ const restoredState = useMemo(() => loadState(id), [id, loadState]);
41
+ const load = useCallback(
42
+ (key) => loadState(id, key),
43
+ [id, loadState]
44
+ );
45
+ const purge = useCallback(
46
+ (key) => {
47
+ purgeState(id, key);
48
+ layoutDispatch({ type: "save" });
49
+ },
50
+ [id, layoutDispatch, purgeState]
51
+ );
52
+ const save = useCallback(
53
+ (state, key) => {
54
+ saveState(id, key, state);
55
+ layoutDispatch({ type: "save" });
56
+ },
57
+ [id, layoutDispatch, saveState]
58
+ );
59
+ const loadSession = useCallback(
60
+ (key) => loadSessionState(id, key),
61
+ [id, loadSessionState]
62
+ );
63
+ const saveSession = useCallback(
64
+ (state, key) => saveSessionState(id, key, state),
65
+ [id, saveSessionState]
66
+ );
67
+ const onConfigChange = useCallback(
68
+ ({ type: key, ...config }) => {
69
+ const { [key]: data } = config;
70
+ save(data, key);
71
+ },
72
+ [save]
73
+ );
74
+ return {
75
+ contributions,
76
+ dispatchViewAction,
77
+ load,
78
+ loadSession,
79
+ onConfigChange,
80
+ onEditTitle,
81
+ purge,
82
+ restoredState,
83
+ save,
84
+ saveSession,
85
+ title
86
+ };
87
+ };
88
+
89
+ export { useView };
90
+ //# 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":["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,iBAAiB,yBAA0B,EAAA,CAAA;AAEjD,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,gBAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,I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U,SAAA,CAAA,EAAA,EAAI,KAAK,KAAK,CAAA,CAAA;AACxB,MAAe,cAAA,CAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,CAAA,CAAA;AAAA,KACjC;AAAA,IACA,CAAC,EAAI,EAAA,cAAA,EAAgB,SAAS,CAAA;AAAA,GAChC,CAAA;AACA,EAAA,MAAM,WAAc,GAAA,WAAA;AAAA,IAClB,CAAC,GAAA,KAAiB,gBAAiB,CAAA,EAAA,EAAI,GAAG,CAAA;AAAA,IAC1C,CAAC,IAAI,gBAAgB,CAAA;AAAA,GACvB,CAAA;AACA,EAAA,MAAM,WAAc,GAAA,WAAA;AAAA,IAClB,CAAC,KAAO,EAAA,GAAA,KAAQ,gBAAiB,CAAA,EAAA,EAAI,KAAK,KAAK,CAAA;AAAA,IAC/C,CAAC,IAAI,gBAAgB,CAAA;AAAA,GACvB,CAAA;AAEA,EAAA,MAAM,cAAiB,GAAA,WAAA;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,40 @@
1
+ import { useRef, useCallback } from 'react';
2
+ import { useResizeObserver, WidthHeight } from '../responsive/useResizeObserver.js';
3
+
4
+ const NO_MEASUREMENT = [];
5
+ const useViewResize = ({
6
+ mainRef,
7
+ resize = "responsive",
8
+ rootRef
9
+ }) => {
10
+ const deferResize = resize === "defer";
11
+ const mainSize = useRef({});
12
+ const resizeHandle = useRef();
13
+ const setMainSize = useCallback(() => {
14
+ if (mainRef.current) {
15
+ mainRef.current.style.height = mainSize.current.height + "px";
16
+ mainRef.current.style.width = mainSize.current.width + "px";
17
+ }
18
+ resizeHandle.current = void 0;
19
+ }, [mainRef]);
20
+ const onResize = useCallback(
21
+ ({ height, width }) => {
22
+ mainSize.current.height = height;
23
+ mainSize.current.width = width;
24
+ if (resizeHandle.current !== null) {
25
+ clearTimeout(resizeHandle.current);
26
+ }
27
+ resizeHandle.current = window.setTimeout(setMainSize, 40);
28
+ },
29
+ [setMainSize]
30
+ );
31
+ useResizeObserver(
32
+ rootRef,
33
+ deferResize ? WidthHeight : NO_MEASUREMENT,
34
+ onResize,
35
+ deferResize
36
+ );
37
+ };
38
+
39
+ export { useViewResize };
40
+ //# sourceMappingURL=useViewResize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewResize.js","sources":["../../src/layout-view/useViewResize.ts"],"sourcesContent":["import { useResizeObserver, WidthHeight } from \"../responsive\";\nimport { RefObject, useCallback, useRef } from \"react\";\n\nconst NO_MEASUREMENT: string[] = [];\n\ntype size = {\n height?: number;\n width?: number;\n};\n\nexport interface ViewResizeHookProps {\n mainRef: RefObject<HTMLDivElement>;\n resize?: \"defer\" | \"responsive\";\n rootRef: RefObject<HTMLDivElement>;\n}\n\nexport const useViewResize = ({\n mainRef,\n resize = \"responsive\",\n rootRef,\n}: ViewResizeHookProps) => {\n const deferResize = resize === \"defer\";\n\n const mainSize = useRef<size>({});\n const resizeHandle = useRef<number>();\n\n const setMainSize = useCallback(() => {\n if (mainRef.current) {\n mainRef.current.style.height = mainSize.current.height + \"px\";\n mainRef.current.style.width = mainSize.current.width + \"px\";\n }\n resizeHandle.current = undefined;\n }, [mainRef]);\n\n const onResize = useCallback(\n ({ height, width }) => {\n mainSize.current.height = height;\n mainSize.current.width = width;\n if (resizeHandle.current !== null) {\n clearTimeout(resizeHandle.current);\n }\n resizeHandle.current = window.setTimeout(setMainSize, 40);\n },\n [setMainSize]\n );\n\n useResizeObserver(\n rootRef,\n deferResize ? WidthHeight : NO_MEASUREMENT,\n onResize,\n deferResize\n );\n};\n"],"names":[],"mappings":";;;AAGA,MAAM,iBAA2B,EAAC,CAAA;AAa3B,MAAM,gBAAgB,CAAC;AAAA,EAC5B,OAAA;AAAA,EACA,MAAS,GAAA,YAAA;AAAA,EACT,OAAA;AACF,CAA2B,KAAA;AACzB,EAAA,MAAM,cAAc,MAAW,KAAA,OAAA,CAAA;AAE/B,EAAM,MAAA,QAAA,GAAW,MAAa,CAAA,EAAE,CAAA,CAAA;AAChC,EAAA,MAAM,eAAe,MAAe,EAAA,CAAA;AAEpC,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,IAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,MAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,CAAM,MAAS,GAAA,QAAA,CAAS,QAAQ,MAAS,GAAA,IAAA,CAAA;AACzD,MAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,CAAM,KAAQ,GAAA,QAAA,CAAS,QAAQ,KAAQ,GAAA,IAAA,CAAA;AAAA,KACzD;AACA,IAAA,YAAA,CAAa,OAAU,GAAA,KAAA,CAAA,CAAA;AAAA,GACzB,EAAG,CAAC,OAAO,CAAC,CAAA,CAAA;AAEZ,EAAA,MAAM,QAAW,GAAA,WAAA;AAAA,IACf,CAAC,EAAE,MAAQ,EAAA,KAAA,EAAY,KAAA;AACrB,MAAA,QAAA,CAAS,QAAQ,MAAS,GAAA,MAAA,CAAA;AAC1B,MAAA,QAAA,CAAS,QAAQ,KAAQ,GAAA,KAAA,CAAA;AACzB,MAAI,IAAA,YAAA,CAAa,YAAY,IAAM,EAAA;AACjC,QAAA,YAAA,CAAa,aAAa,OAAO,CAAA,CAAA;AAAA,OACnC;AACA,MAAA,YAAA,CAAa,OAAU,GAAA,MAAA,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