@vuu-ui/vuu-layout 2.1.18 → 2.1.19-beta.2

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 (353) hide show
  1. package/package.json +15 -18
  2. package/src/Component.js +14 -0
  3. package/src/LayoutContainer.css.js +24 -0
  4. package/src/LayoutContainer.js +26 -0
  5. package/src/debug.js +16 -0
  6. package/src/dock-layout/DockLayout.css.js +36 -0
  7. package/src/dock-layout/DockLayout.js +43 -0
  8. package/src/dock-layout/Drawer.css.js +150 -0
  9. package/src/dock-layout/Drawer.js +82 -0
  10. package/src/dock-layout/index.js +2 -0
  11. package/src/drag-drop/BoxModel.js +337 -0
  12. package/src/drag-drop/DragState.js +119 -0
  13. package/src/drag-drop/Draggable.js +140 -0
  14. package/src/drag-drop/DropTarget.js +286 -0
  15. package/src/drag-drop/DropTargetRenderer.js +275 -0
  16. package/src/drag-drop/dragDropTypes.js +0 -0
  17. package/src/drag-drop/index.js +3 -0
  18. package/src/flexbox/Flexbox.css.js +45 -0
  19. package/src/flexbox/Flexbox.js +45 -0
  20. package/src/flexbox/FlexboxLayout.js +27 -0
  21. package/src/flexbox/Splitter.css.js +57 -0
  22. package/src/flexbox/Splitter.js +112 -0
  23. package/src/flexbox/flexbox-utils.js +92 -0
  24. package/src/flexbox/flexboxTypes.js +0 -0
  25. package/src/flexbox/index.js +2 -0
  26. package/src/flexbox/useSplitterResizing.js +181 -0
  27. package/src/index.js +20 -0
  28. package/src/layout-action.js +20 -0
  29. package/src/layout-header/ActionButton.js +15 -0
  30. package/src/layout-header/Header.css.js +32 -0
  31. package/src/layout-header/Header.js +99 -0
  32. package/src/layout-header/index.js +1 -0
  33. package/src/layout-header/useHeader.js +76 -0
  34. package/src/layout-provider/LayoutProvider.js +242 -0
  35. package/src/layout-provider/LayoutProviderContext.js +13 -0
  36. package/src/layout-provider/index.js +2 -0
  37. package/src/layout-provider/useLayoutDragDrop.js +147 -0
  38. package/src/layout-reducer/flexUtils.js +186 -0
  39. package/src/layout-reducer/index.js +4 -0
  40. package/src/layout-reducer/insert-layout-element.js +179 -0
  41. package/src/layout-reducer/layout-reducer.js +121 -0
  42. package/src/layout-reducer/layoutTypes.js +34 -0
  43. package/src/layout-reducer/layoutUtils.js +178 -0
  44. package/src/layout-reducer/move-layout-element.js +18 -0
  45. package/src/layout-reducer/remove-layout-element.js +161 -0
  46. package/src/layout-reducer/replace-layout-element.js +70 -0
  47. package/src/layout-reducer/resize-flex-children.js +48 -0
  48. package/src/layout-reducer/wrap-layout-element.js +134 -0
  49. package/src/layout-view/View.css.js +76 -0
  50. package/src/layout-view/View.js +116 -0
  51. package/src/layout-view/useView.js +69 -0
  52. package/src/layout-view/useViewBroadcastChannel.js +29 -0
  53. package/src/layout-view/useViewResize.js +27 -0
  54. package/src/layout-view/viewTypes.js +0 -0
  55. package/src/layout-view-actions/ViewContext.js +11 -0
  56. package/src/layout-view-actions/useViewActionDispatcher.js +116 -0
  57. package/src/layout-view-actions/useViewContributions.js +31 -0
  58. package/src/palette/Palette.css.js +31 -0
  59. package/src/palette/Palette.js +85 -0
  60. package/src/palette/index.js +1 -0
  61. package/src/placeholder/LayoutStartPanel.css.js +35 -0
  62. package/src/placeholder/LayoutStartPanel.js +57 -0
  63. package/src/placeholder/Placeholder.css.js +20 -0
  64. package/src/placeholder/Placeholder.js +33 -0
  65. package/src/placeholder/index.js +1 -0
  66. package/src/responsive/index.js +2 -0
  67. package/src/responsive/measureMinimumNodeSize.js +24 -0
  68. package/src/responsive/useResizeObserver.js +109 -0
  69. package/src/responsive/utils.js +27 -0
  70. package/src/stack/Stack.css.js +44 -0
  71. package/src/stack/Stack.js +98 -0
  72. package/src/stack/StackLayout.js +116 -0
  73. package/src/stack/index.js +3 -0
  74. package/src/stack/stackTypes.js +0 -0
  75. package/src/tabs/TabPanel.css.js +17 -0
  76. package/src/tabs/TabPanel.js +11 -0
  77. package/src/tabs/index.js +1 -0
  78. package/src/tools/config-wrapper/ConfigWrapper.js +55 -0
  79. package/src/tools/config-wrapper/index.js +1 -0
  80. package/src/tools/devtools-box/layout-configurator.css.js +113 -0
  81. package/src/tools/devtools-tree/layout-tree-viewer.css.js +17 -0
  82. package/src/tools/index.js +3 -0
  83. package/src/use-persistent-state.js +43 -0
  84. package/src/utils/index.js +5 -0
  85. package/src/utils/pathUtils.js +212 -0
  86. package/src/utils/propUtils.js +15 -0
  87. package/src/utils/refUtils.js +5 -0
  88. package/src/utils/styleUtils.js +9 -0
  89. package/src/utils/typeOf.js +15 -0
  90. package/types/dock-layout/DockLayout.d.ts +4 -4
  91. package/types/dock-layout/Drawer.d.ts +4 -4
  92. package/types/drag-drop/BoxModel.d.ts +7 -7
  93. package/types/flexbox/FlexboxLayout.d.ts +4 -4
  94. package/types/flexbox/Splitter.d.ts +1 -1
  95. package/types/layout-reducer/layoutUtils.d.ts +1 -1
  96. package/types/layout-reducer/remove-layout-element.d.ts +1 -1
  97. package/types/layout-reducer/replace-layout-element.d.ts +2 -2
  98. package/types/layout-reducer/resize-flex-children.d.ts +2 -2
  99. package/types/layout-view/useView.d.ts +1 -1
  100. package/types/placeholder/Placeholder.d.ts +4 -4
  101. package/types/responsive/overflowUtils.d.ts +2 -2
  102. package/types/stack/StackLayout.d.ts +4 -4
  103. package/types/tools/devtools-box/layout-configurator.d.ts +26 -26
  104. package/types/tools/devtools-tree/layout-tree-viewer.d.ts +2 -2
  105. package/types/utils/pathUtils.d.ts +1 -1
  106. package/cjs/Component.js +0 -14
  107. package/cjs/Component.js.map +0 -1
  108. package/cjs/LayoutContainer.css.js +0 -6
  109. package/cjs/LayoutContainer.css.js.map +0 -1
  110. package/cjs/LayoutContainer.js +0 -33
  111. package/cjs/LayoutContainer.js.map +0 -1
  112. package/cjs/dock-layout/DockLayout.css.js +0 -6
  113. package/cjs/dock-layout/DockLayout.css.js.map +0 -1
  114. package/cjs/dock-layout/DockLayout.js +0 -41
  115. package/cjs/dock-layout/DockLayout.js.map +0 -1
  116. package/cjs/dock-layout/Drawer.css.js +0 -6
  117. package/cjs/dock-layout/Drawer.css.js.map +0 -1
  118. package/cjs/dock-layout/Drawer.js +0 -95
  119. package/cjs/dock-layout/Drawer.js.map +0 -1
  120. package/cjs/drag-drop/BoxModel.js +0 -416
  121. package/cjs/drag-drop/BoxModel.js.map +0 -1
  122. package/cjs/drag-drop/DragState.js +0 -161
  123. package/cjs/drag-drop/DragState.js.map +0 -1
  124. package/cjs/drag-drop/Draggable.js +0 -192
  125. package/cjs/drag-drop/Draggable.js.map +0 -1
  126. package/cjs/drag-drop/DropTarget.js +0 -257
  127. package/cjs/drag-drop/DropTarget.js.map +0 -1
  128. package/cjs/drag-drop/DropTargetRenderer.js +0 -218
  129. package/cjs/drag-drop/DropTargetRenderer.js.map +0 -1
  130. package/cjs/flexbox/Flexbox.css.js +0 -6
  131. package/cjs/flexbox/Flexbox.css.js.map +0 -1
  132. package/cjs/flexbox/Flexbox.js +0 -69
  133. package/cjs/flexbox/Flexbox.js.map +0 -1
  134. package/cjs/flexbox/FlexboxLayout.js +0 -30
  135. package/cjs/flexbox/FlexboxLayout.js.map +0 -1
  136. package/cjs/flexbox/Splitter.css.js +0 -6
  137. package/cjs/flexbox/Splitter.css.js.map +0 -1
  138. package/cjs/flexbox/Splitter.js +0 -122
  139. package/cjs/flexbox/Splitter.js.map +0 -1
  140. package/cjs/flexbox/flexbox-utils.js +0 -95
  141. package/cjs/flexbox/flexbox-utils.js.map +0 -1
  142. package/cjs/flexbox/useSplitterResizing.js +0 -197
  143. package/cjs/flexbox/useSplitterResizing.js.map +0 -1
  144. package/cjs/index.js +0 -122
  145. package/cjs/index.js.map +0 -1
  146. package/cjs/layout-action.js +0 -24
  147. package/cjs/layout-action.js.map +0 -1
  148. package/cjs/layout-header/Header.css.js +0 -6
  149. package/cjs/layout-header/Header.css.js.map +0 -1
  150. package/cjs/layout-header/Header.js +0 -152
  151. package/cjs/layout-header/Header.js.map +0 -1
  152. package/cjs/layout-header/useHeader.js +0 -85
  153. package/cjs/layout-header/useHeader.js.map +0 -1
  154. package/cjs/layout-provider/LayoutProvider.js +0 -304
  155. package/cjs/layout-provider/LayoutProvider.js.map +0 -1
  156. package/cjs/layout-provider/LayoutProviderContext.js +0 -23
  157. package/cjs/layout-provider/LayoutProviderContext.js.map +0 -1
  158. package/cjs/layout-provider/useLayoutDragDrop.js +0 -177
  159. package/cjs/layout-provider/useLayoutDragDrop.js.map +0 -1
  160. package/cjs/layout-reducer/flexUtils.js +0 -227
  161. package/cjs/layout-reducer/flexUtils.js.map +0 -1
  162. package/cjs/layout-reducer/insert-layout-element.js +0 -286
  163. package/cjs/layout-reducer/insert-layout-element.js.map +0 -1
  164. package/cjs/layout-reducer/layout-reducer.js +0 -202
  165. package/cjs/layout-reducer/layout-reducer.js.map +0 -1
  166. package/cjs/layout-reducer/layoutTypes.js +0 -40
  167. package/cjs/layout-reducer/layoutTypes.js.map +0 -1
  168. package/cjs/layout-reducer/layoutUtils.js +0 -237
  169. package/cjs/layout-reducer/layoutUtils.js.map +0 -1
  170. package/cjs/layout-reducer/move-layout-element.js +0 -31
  171. package/cjs/layout-reducer/move-layout-element.js.map +0 -1
  172. package/cjs/layout-reducer/remove-layout-element.js +0 -237
  173. package/cjs/layout-reducer/remove-layout-element.js.map +0 -1
  174. package/cjs/layout-reducer/replace-layout-element.js +0 -96
  175. package/cjs/layout-reducer/replace-layout-element.js.map +0 -1
  176. package/cjs/layout-reducer/resize-flex-children.js +0 -62
  177. package/cjs/layout-reducer/resize-flex-children.js.map +0 -1
  178. package/cjs/layout-reducer/wrap-layout-element.js +0 -211
  179. package/cjs/layout-reducer/wrap-layout-element.js.map +0 -1
  180. package/cjs/layout-view/View.css.js +0 -6
  181. package/cjs/layout-view/View.css.js.map +0 -1
  182. package/cjs/layout-view/View.js +0 -160
  183. package/cjs/layout-view/View.js.map +0 -1
  184. package/cjs/layout-view/useView.js +0 -75
  185. package/cjs/layout-view/useView.js.map +0 -1
  186. package/cjs/layout-view/useViewBroadcastChannel.js +0 -35
  187. package/cjs/layout-view/useViewBroadcastChannel.js.map +0 -1
  188. package/cjs/layout-view/useViewResize.js +0 -42
  189. package/cjs/layout-view/useViewResize.js.map +0 -1
  190. package/cjs/layout-view-actions/ViewContext.js +0 -16
  191. package/cjs/layout-view-actions/ViewContext.js.map +0 -1
  192. package/cjs/layout-view-actions/useViewActionDispatcher.js +0 -112
  193. package/cjs/layout-view-actions/useViewActionDispatcher.js.map +0 -1
  194. package/cjs/layout-view-actions/useViewContributions.js +0 -33
  195. package/cjs/layout-view-actions/useViewContributions.js.map +0 -1
  196. package/cjs/palette/Palette.css.js +0 -6
  197. package/cjs/palette/Palette.css.js.map +0 -1
  198. package/cjs/palette/Palette.js +0 -115
  199. package/cjs/palette/Palette.js.map +0 -1
  200. package/cjs/placeholder/LayoutStartPanel.css.js +0 -6
  201. package/cjs/placeholder/LayoutStartPanel.css.js.map +0 -1
  202. package/cjs/placeholder/LayoutStartPanel.js +0 -56
  203. package/cjs/placeholder/LayoutStartPanel.js.map +0 -1
  204. package/cjs/placeholder/Placeholder.css.js +0 -6
  205. package/cjs/placeholder/Placeholder.css.js.map +0 -1
  206. package/cjs/placeholder/Placeholder.js +0 -34
  207. package/cjs/placeholder/Placeholder.js.map +0 -1
  208. package/cjs/responsive/useResizeObserver.js +0 -118
  209. package/cjs/responsive/useResizeObserver.js.map +0 -1
  210. package/cjs/responsive/utils.js +0 -34
  211. package/cjs/responsive/utils.js.map +0 -1
  212. package/cjs/stack/Stack.css.js +0 -6
  213. package/cjs/stack/Stack.css.js.map +0 -1
  214. package/cjs/stack/Stack.js +0 -150
  215. package/cjs/stack/Stack.js.map +0 -1
  216. package/cjs/stack/StackLayout.js +0 -116
  217. package/cjs/stack/StackLayout.js.map +0 -1
  218. package/cjs/use-persistent-state.js +0 -63
  219. package/cjs/use-persistent-state.js.map +0 -1
  220. package/cjs/utils/pathUtils.js +0 -293
  221. package/cjs/utils/pathUtils.js.map +0 -1
  222. package/cjs/utils/propUtils.js +0 -27
  223. package/cjs/utils/propUtils.js.map +0 -1
  224. package/cjs/utils/refUtils.js +0 -12
  225. package/cjs/utils/refUtils.js.map +0 -1
  226. package/cjs/utils/styleUtils.js +0 -15
  227. package/cjs/utils/styleUtils.js.map +0 -1
  228. package/cjs/utils/typeOf.js +0 -27
  229. package/cjs/utils/typeOf.js.map +0 -1
  230. package/esm/Component.js +0 -12
  231. package/esm/Component.js.map +0 -1
  232. package/esm/LayoutContainer.css.js +0 -4
  233. package/esm/LayoutContainer.css.js.map +0 -1
  234. package/esm/LayoutContainer.js +0 -31
  235. package/esm/LayoutContainer.js.map +0 -1
  236. package/esm/dock-layout/DockLayout.css.js +0 -4
  237. package/esm/dock-layout/DockLayout.css.js.map +0 -1
  238. package/esm/dock-layout/DockLayout.js +0 -39
  239. package/esm/dock-layout/DockLayout.js.map +0 -1
  240. package/esm/dock-layout/Drawer.css.js +0 -4
  241. package/esm/dock-layout/Drawer.css.js.map +0 -1
  242. package/esm/dock-layout/Drawer.js +0 -93
  243. package/esm/dock-layout/Drawer.js.map +0 -1
  244. package/esm/drag-drop/BoxModel.js +0 -409
  245. package/esm/drag-drop/BoxModel.js.map +0 -1
  246. package/esm/drag-drop/DragState.js +0 -159
  247. package/esm/drag-drop/DragState.js.map +0 -1
  248. package/esm/drag-drop/Draggable.js +0 -190
  249. package/esm/drag-drop/Draggable.js.map +0 -1
  250. package/esm/drag-drop/DropTarget.js +0 -253
  251. package/esm/drag-drop/DropTarget.js.map +0 -1
  252. package/esm/drag-drop/DropTargetRenderer.js +0 -216
  253. package/esm/drag-drop/DropTargetRenderer.js.map +0 -1
  254. package/esm/flexbox/Flexbox.css.js +0 -4
  255. package/esm/flexbox/Flexbox.css.js.map +0 -1
  256. package/esm/flexbox/Flexbox.js +0 -67
  257. package/esm/flexbox/Flexbox.js.map +0 -1
  258. package/esm/flexbox/FlexboxLayout.js +0 -28
  259. package/esm/flexbox/FlexboxLayout.js.map +0 -1
  260. package/esm/flexbox/Splitter.css.js +0 -4
  261. package/esm/flexbox/Splitter.css.js.map +0 -1
  262. package/esm/flexbox/Splitter.js +0 -120
  263. package/esm/flexbox/Splitter.js.map +0 -1
  264. package/esm/flexbox/flexbox-utils.js +0 -89
  265. package/esm/flexbox/flexbox-utils.js.map +0 -1
  266. package/esm/flexbox/useSplitterResizing.js +0 -195
  267. package/esm/flexbox/useSplitterResizing.js.map +0 -1
  268. package/esm/index.js +0 -33
  269. package/esm/index.js.map +0 -1
  270. package/esm/layout-action.js +0 -22
  271. package/esm/layout-action.js.map +0 -1
  272. package/esm/layout-header/Header.css.js +0 -4
  273. package/esm/layout-header/Header.css.js.map +0 -1
  274. package/esm/layout-header/Header.js +0 -150
  275. package/esm/layout-header/Header.js.map +0 -1
  276. package/esm/layout-header/useHeader.js +0 -83
  277. package/esm/layout-header/useHeader.js.map +0 -1
  278. package/esm/layout-provider/LayoutProvider.js +0 -297
  279. package/esm/layout-provider/LayoutProvider.js.map +0 -1
  280. package/esm/layout-provider/LayoutProviderContext.js +0 -20
  281. package/esm/layout-provider/LayoutProviderContext.js.map +0 -1
  282. package/esm/layout-provider/useLayoutDragDrop.js +0 -175
  283. package/esm/layout-provider/useLayoutDragDrop.js.map +0 -1
  284. package/esm/layout-reducer/flexUtils.js +0 -218
  285. package/esm/layout-reducer/flexUtils.js.map +0 -1
  286. package/esm/layout-reducer/insert-layout-element.js +0 -282
  287. package/esm/layout-reducer/insert-layout-element.js.map +0 -1
  288. package/esm/layout-reducer/layout-reducer.js +0 -200
  289. package/esm/layout-reducer/layout-reducer.js.map +0 -1
  290. package/esm/layout-reducer/layoutTypes.js +0 -36
  291. package/esm/layout-reducer/layoutTypes.js.map +0 -1
  292. package/esm/layout-reducer/layoutUtils.js +0 -226
  293. package/esm/layout-reducer/layoutUtils.js.map +0 -1
  294. package/esm/layout-reducer/move-layout-element.js +0 -29
  295. package/esm/layout-reducer/move-layout-element.js.map +0 -1
  296. package/esm/layout-reducer/remove-layout-element.js +0 -235
  297. package/esm/layout-reducer/remove-layout-element.js.map +0 -1
  298. package/esm/layout-reducer/replace-layout-element.js +0 -92
  299. package/esm/layout-reducer/replace-layout-element.js.map +0 -1
  300. package/esm/layout-reducer/resize-flex-children.js +0 -59
  301. package/esm/layout-reducer/resize-flex-children.js.map +0 -1
  302. package/esm/layout-reducer/wrap-layout-element.js +0 -209
  303. package/esm/layout-reducer/wrap-layout-element.js.map +0 -1
  304. package/esm/layout-view/View.css.js +0 -4
  305. package/esm/layout-view/View.css.js.map +0 -1
  306. package/esm/layout-view/View.js +0 -158
  307. package/esm/layout-view/View.js.map +0 -1
  308. package/esm/layout-view/useView.js +0 -73
  309. package/esm/layout-view/useView.js.map +0 -1
  310. package/esm/layout-view/useViewBroadcastChannel.js +0 -33
  311. package/esm/layout-view/useViewBroadcastChannel.js.map +0 -1
  312. package/esm/layout-view/useViewResize.js +0 -40
  313. package/esm/layout-view/useViewResize.js.map +0 -1
  314. package/esm/layout-view-actions/ViewContext.js +0 -12
  315. package/esm/layout-view-actions/ViewContext.js.map +0 -1
  316. package/esm/layout-view-actions/useViewActionDispatcher.js +0 -110
  317. package/esm/layout-view-actions/useViewActionDispatcher.js.map +0 -1
  318. package/esm/layout-view-actions/useViewContributions.js +0 -31
  319. package/esm/layout-view-actions/useViewContributions.js.map +0 -1
  320. package/esm/palette/Palette.css.js +0 -4
  321. package/esm/palette/Palette.css.js.map +0 -1
  322. package/esm/palette/Palette.js +0 -112
  323. package/esm/palette/Palette.js.map +0 -1
  324. package/esm/placeholder/LayoutStartPanel.css.js +0 -4
  325. package/esm/placeholder/LayoutStartPanel.css.js.map +0 -1
  326. package/esm/placeholder/LayoutStartPanel.js +0 -54
  327. package/esm/placeholder/LayoutStartPanel.js.map +0 -1
  328. package/esm/placeholder/Placeholder.css.js +0 -4
  329. package/esm/placeholder/Placeholder.css.js.map +0 -1
  330. package/esm/placeholder/Placeholder.js +0 -32
  331. package/esm/placeholder/Placeholder.js.map +0 -1
  332. package/esm/responsive/useResizeObserver.js +0 -112
  333. package/esm/responsive/useResizeObserver.js.map +0 -1
  334. package/esm/responsive/utils.js +0 -31
  335. package/esm/responsive/utils.js.map +0 -1
  336. package/esm/stack/Stack.css.js +0 -4
  337. package/esm/stack/Stack.css.js.map +0 -1
  338. package/esm/stack/Stack.js +0 -148
  339. package/esm/stack/Stack.js.map +0 -1
  340. package/esm/stack/StackLayout.js +0 -114
  341. package/esm/stack/StackLayout.js.map +0 -1
  342. package/esm/use-persistent-state.js +0 -58
  343. package/esm/use-persistent-state.js.map +0 -1
  344. package/esm/utils/pathUtils.js +0 -280
  345. package/esm/utils/pathUtils.js.map +0 -1
  346. package/esm/utils/propUtils.js +0 -23
  347. package/esm/utils/propUtils.js.map +0 -1
  348. package/esm/utils/refUtils.js +0 -10
  349. package/esm/utils/refUtils.js.map +0 -1
  350. package/esm/utils/styleUtils.js +0 -13
  351. package/esm/utils/styleUtils.js.map +0 -1
  352. package/esm/utils/typeOf.js +0 -23
  353. package/esm/utils/typeOf.js.map +0 -1
@@ -1,282 +0,0 @@
1
- import { uuid } from '@vuu-ui/vuu-utils';
2
- import React from 'react';
3
- import { nextStep, resetPath } from '../utils/pathUtils.js';
4
- import { getProps, getProp } from '../utils/propUtils.js';
5
- import { typeOf } from '../utils/typeOf.js';
6
- import { getIntrinsicSize, wrapIntrinsicSizeComponentWithFlexbox, createPlaceHolder, getFlexOrIntrinsicStyle, getFlexDimensions } from './flexUtils.js';
7
- import { getManagedDimension, getDefaultTabLabel } from './layoutUtils.js';
8
-
9
- function getInsertTabBeforeAfter(stack, pos) {
10
- const { children: tabs } = stack.props;
11
- const tabCount = tabs.length;
12
- const { index = -1, positionRelativeToTab = "after" } = pos.tab || {};
13
- return index === -1 || index >= tabCount ? [tabs[tabCount - 1], "after"] : [tabs[index] ?? null, positionRelativeToTab];
14
- }
15
- function insertIntoContainer(container, targetContainer, newComponent) {
16
- const {
17
- active: containerActive,
18
- children: containerChildren = [],
19
- path: containerPath
20
- } = getProps(container);
21
- const existingComponentPath = getProp(targetContainer, "path");
22
- const { idx, finalStep } = nextStep(
23
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
24
- containerPath,
25
- existingComponentPath,
26
- true
27
- );
28
- const [insertedIdx, children] = finalStep ? insertIntoChildren(container, containerChildren, newComponent) : [
29
- containerActive,
30
- containerChildren?.map(
31
- (child, index) => index === idx ? insertIntoContainer(
32
- child,
33
- targetContainer,
34
- newComponent
35
- ) : child
36
- )
37
- ];
38
- const active = typeOf(container) === "Stack" ? Array.isArray(insertedIdx) ? insertedIdx[0] : insertedIdx : containerActive;
39
- return React.cloneElement(container, { active }, children);
40
- }
41
- const getDefaultTitle = (containerType, component, index, existingLabels) => containerType === "Stack" ? getDefaultTabLabel(component, index, existingLabels) : void 0;
42
- const getChildrenTitles = (children) => children.map((child) => child.props.title);
43
- function insertIntoChildren(container, containerChildren, newComponent) {
44
- if (Array.isArray(newComponent)) {
45
- const [firstChild, ...rest] = newComponent;
46
- let [idx, children] = insertIntoChildren(
47
- container,
48
- containerChildren,
49
- firstChild
50
- );
51
- for (const child of rest) {
52
- [, children] = insertIntoChildren(container, children, child);
53
- }
54
- return [idx, children];
55
- }
56
- const containerPath = getProp(container, "path");
57
- const count = containerChildren?.length;
58
- const {
59
- id = uuid(),
60
- title = getDefaultTitle(
61
- typeOf(container),
62
- newComponent,
63
- count ?? 0,
64
- getChildrenTitles(containerChildren)
65
- )
66
- } = getProps(newComponent);
67
- if (count) {
68
- return [
69
- count,
70
- containerChildren.concat(
71
- resetPath(newComponent, `${containerPath}.${count}`, {
72
- id,
73
- key: id,
74
- title
75
- })
76
- )
77
- ];
78
- } else {
79
- return [0, [resetPath(newComponent, `${containerPath}.0`, { id, title })]];
80
- }
81
- }
82
- function insertBesideChild(container, existingComponent, newComponent, insertionPosition, pos, clientRect, dropRect) {
83
- const {
84
- active: containerActive,
85
- children: containerChildren,
86
- path: containerPath
87
- } = getProps(container);
88
- const existingComponentPath = getProp(existingComponent, "path");
89
- const { idx, finalStep } = nextStep(containerPath, existingComponentPath);
90
- const [insertedIdx, children] = finalStep ? updateChildren(
91
- container,
92
- containerChildren,
93
- idx,
94
- newComponent,
95
- insertionPosition,
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- pos,
98
- clientRect,
99
- dropRect
100
- ) : [
101
- containerActive,
102
- containerChildren.map(
103
- (child, index) => index === idx ? insertBesideChild(
104
- child,
105
- existingComponent,
106
- newComponent,
107
- insertionPosition,
108
- pos,
109
- clientRect,
110
- dropRect
111
- ) : child
112
- )
113
- ];
114
- const active = typeOf(container) === "Stack" ? insertedIdx : containerActive;
115
- return React.cloneElement(container, { active }, children);
116
- }
117
- function updateChildren(container, containerChildren, idx, newComponent, insertionPosition, pos, clientRect, dropRect) {
118
- const intrinsicSize = getIntrinsicSize(newComponent);
119
- if (intrinsicSize?.width && intrinsicSize?.height) {
120
- return insertIntrinsicSizedComponent(
121
- container,
122
- containerChildren,
123
- idx,
124
- newComponent,
125
- insertionPosition,
126
- clientRect,
127
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
128
- dropRect
129
- );
130
- } else {
131
- return insertFlexComponent(
132
- container,
133
- containerChildren,
134
- idx,
135
- newComponent,
136
- insertionPosition,
137
- pos?.width || pos?.height,
138
- clientRect
139
- );
140
- }
141
- }
142
- const getLeadingPlaceholderSize = (flexDirection2, insertionPosition, { top, right, bottom, left }, [rectLeft, rectTop, rectRight, rectBottom]) => {
143
- if (flexDirection2 === "column" && insertionPosition === "before") {
144
- return rectTop - top;
145
- } else if (flexDirection2 === "column") {
146
- return bottom - rectBottom;
147
- } else if (flexDirection2 === "row" && insertionPosition === "before") {
148
- return rectLeft - left;
149
- } else if (flexDirection2 === "row") {
150
- return right - rectRight;
151
- }
152
- };
153
- function insertIntrinsicSizedComponent(container, containerChildren, idx, newComponent, insertionPosition, clientRect, dropRect) {
154
- const {
155
- style: { flexDirection: flexDirection2 }
156
- } = getProps(container);
157
- const [dimension, crossDimension, contraDirection] = getFlexDimensions(flexDirection2);
158
- const { [crossDimension]: intrinsicCrossSize, [dimension]: intrinsicSize } = getIntrinsicSize(newComponent);
159
- const path = getProp(containerChildren[idx], "path");
160
- const placeholderSize = getLeadingPlaceholderSize(
161
- flexDirection2,
162
- insertionPosition,
163
- clientRect,
164
- dropRect
165
- );
166
- const [itemToInsert, size] = intrinsicCrossSize < clientRect[crossDimension] ? [
167
- wrapIntrinsicSizeComponentWithFlexbox(
168
- newComponent,
169
- contraDirection,
170
- path,
171
- clientRect,
172
- dropRect
173
- ),
174
- intrinsicSize
175
- ] : [newComponent, void 0];
176
- const placeholder = placeholderSize ? createPlaceHolder(path, placeholderSize, { flexGrow: 0, flexShrink: 0 }) : void 0;
177
- if (intrinsicCrossSize > clientRect[crossDimension]) {
178
- containerChildren = containerChildren.map((child) => {
179
- if (getProp(child, "placeholder")) {
180
- return child;
181
- } else {
182
- const { [crossDimension]: intrinsicCrossChildSize } = getIntrinsicSize(
183
- child
184
- );
185
- if (intrinsicCrossChildSize && intrinsicCrossChildSize < intrinsicCrossSize) {
186
- return wrapIntrinsicSizeComponentWithFlexbox(
187
- child,
188
- contraDirection,
189
- getProp(child, "path")
190
- );
191
- } else {
192
- return child;
193
- }
194
- }
195
- });
196
- }
197
- return insertFlexComponent(
198
- container,
199
- containerChildren,
200
- idx,
201
- itemToInsert,
202
- insertionPosition,
203
- size,
204
- clientRect,
205
- placeholder
206
- );
207
- }
208
- function insertFlexComponent(container, containerChildren, idx, newComponent, insertionPosition, size, targetRect, placeholder) {
209
- const containerPath = getProp(container, "path");
210
- let insertedIdx = 0;
211
- const children = !containerChildren || containerChildren.length === 0 ? [newComponent] : containerChildren.reduce((arr, child, i) => {
212
- if (idx === i) {
213
- const [existingComponent, insertedComponent] = getStyledComponents(container, child, newComponent, targetRect);
214
- if (insertionPosition === "before") {
215
- if (placeholder) {
216
- arr.push(placeholder, insertedComponent, existingComponent);
217
- } else {
218
- arr.push(insertedComponent, existingComponent);
219
- }
220
- } else {
221
- if (placeholder) {
222
- arr.push(existingComponent, insertedComponent, placeholder);
223
- } else {
224
- arr.push(existingComponent, insertedComponent);
225
- }
226
- }
227
- insertedIdx = arr.indexOf(insertedComponent);
228
- } else {
229
- arr.push(child);
230
- }
231
- return arr;
232
- }, []).map(
233
- (child, i) => i < insertedIdx ? child : resetPath(child, `${containerPath}.${i}`)
234
- );
235
- return [insertedIdx, children];
236
- }
237
- function getStyledComponents(container, existingComponent, newComponent, targetRect) {
238
- const id = uuid();
239
- let { version = 0 } = getProps(newComponent);
240
- version += 1;
241
- if (typeOf(container) === "Flexbox") {
242
- const { style: containerStyle } = container.props;
243
- const [dim] = getManagedDimension(containerStyle);
244
- const splitterSize = 6;
245
- const size = { [dim]: (targetRect[dim] - splitterSize) / 2 };
246
- const existingComponentStyle = getFlexOrIntrinsicStyle(
247
- existingComponent,
248
- dim,
249
- size
250
- );
251
- const newComponentStyle = getFlexOrIntrinsicStyle(newComponent, dim, size);
252
- return [
253
- React.cloneElement(existingComponent, {
254
- style: existingComponentStyle
255
- }),
256
- React.cloneElement(newComponent, {
257
- id,
258
- version,
259
- style: newComponentStyle
260
- })
261
- ];
262
- } else {
263
- const {
264
- style: { left: _1, top: _2, flex: _3, ...style } = {
265
- left: void 0,
266
- top: void 0,
267
- flex: void 0
268
- }
269
- } = getProps(newComponent);
270
- return [
271
- existingComponent,
272
- React.cloneElement(newComponent, {
273
- id,
274
- version,
275
- style: { ...style, flex: "1 1 0px" }
276
- })
277
- ];
278
- }
279
- }
280
-
281
- export { getInsertTabBeforeAfter, insertBesideChild, insertIntoContainer };
282
- //# sourceMappingURL=insert-layout-element.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert-layout-element.js","sources":["../../../../packages/vuu-layout/src/layout-reducer/insert-layout-element.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { LayoutModel, rectTuple, uuid } from \"@vuu-ui/vuu-utils\";\nimport React, { ReactElement } from \"react\";\nimport { DropPos } from \"../drag-drop\";\nimport { DropTarget } from \"../drag-drop/DropTarget\";\nimport { getProp, getProps, nextStep, resetPath, typeOf } from \"../utils\";\nimport {\n createPlaceHolder,\n flexDirection,\n getFlexDimensions,\n getFlexOrIntrinsicStyle,\n getIntrinsicSize,\n wrapIntrinsicSizeComponentWithFlexbox,\n} from \"./flexUtils\";\nimport {\n LayoutProps,\n getDefaultTabLabel,\n getManagedDimension,\n} from \"./layoutUtils\";\n\ntype insertionPosition = \"before\" | \"after\";\n\nexport function getInsertTabBeforeAfter(stack: LayoutModel, pos: DropPos) {\n const { children: tabs } = stack.props as any;\n const tabCount = tabs.length;\n const { index = -1, positionRelativeToTab = \"after\" } = pos.tab || {};\n return index === -1 || index >= tabCount\n ? [tabs[tabCount - 1], \"after\"]\n : [tabs[index] ?? null, positionRelativeToTab];\n}\n\nexport function insertIntoContainer(\n container: ReactElement,\n targetContainer: ReactElement,\n newComponent: ReactElement | ReactElement[],\n): ReactElement {\n const {\n active: containerActive,\n children: containerChildren = [],\n path: containerPath,\n } = getProps(container) as LayoutProps;\n\n const existingComponentPath = getProp(targetContainer, \"path\");\n const { idx, finalStep } = nextStep(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n containerPath!,\n existingComponentPath,\n true,\n );\n const [insertedIdx, children] = finalStep\n ? insertIntoChildren(container, containerChildren, newComponent)\n : [\n containerActive,\n containerChildren?.map((child, index) =>\n index === idx\n ? (insertIntoContainer(\n child,\n targetContainer,\n newComponent,\n ) as ReactElement)\n : child,\n ),\n ];\n const active =\n typeOf(container) === \"Stack\"\n ? Array.isArray(insertedIdx)\n ? (insertedIdx[0] as number)\n : insertedIdx\n : containerActive;\n\n return React.cloneElement(container, { active } as any, children);\n}\n\nconst getDefaultTitle = (\n containerType: string | undefined,\n component: ReactElement,\n index: number,\n existingLabels: string[],\n) =>\n containerType === \"Stack\"\n ? getDefaultTabLabel(component, index, existingLabels)\n : undefined;\n\nconst getChildrenTitles = (children: ReactElement[]) =>\n children.map((child) => (child.props as any).title);\n\nfunction insertIntoChildren(\n container: ReactElement,\n containerChildren: ReactElement[],\n newComponent: ReactElement | ReactElement[],\n): [number, ReactElement[]] {\n if (Array.isArray(newComponent)) {\n const [firstChild, ...rest] = newComponent;\n let [idx, children] = insertIntoChildren(\n container,\n containerChildren,\n firstChild,\n );\n for (const child of rest) {\n [, children] = insertIntoChildren(container, children, child);\n }\n return [idx, children];\n }\n\n const containerPath = getProp(container, \"path\");\n const count = containerChildren?.length;\n\n const {\n id = uuid(),\n title = getDefaultTitle(\n typeOf(container),\n newComponent,\n count ?? 0,\n getChildrenTitles(containerChildren),\n ),\n } = getProps(newComponent);\n\n if (count) {\n return [\n count,\n containerChildren.concat(\n resetPath(newComponent, `${containerPath}.${count}`, {\n id,\n key: id,\n title,\n }),\n ),\n ];\n } else {\n return [0, [resetPath(newComponent, `${containerPath}.0`, { id, title })]];\n }\n}\n\nexport function insertBesideChild(\n container: ReactElement,\n existingComponent: any,\n newComponent: any,\n insertionPosition: insertionPosition,\n pos?: DropPos,\n clientRect?: any,\n dropRect?: any,\n): ReactElement {\n const {\n active: containerActive,\n children: containerChildren,\n path: containerPath,\n } = getProps(container);\n\n const existingComponentPath = getProp(existingComponent, \"path\");\n const { idx, finalStep } = nextStep(containerPath, existingComponentPath);\n const [insertedIdx, children] = finalStep\n ? updateChildren(\n container,\n containerChildren,\n idx,\n newComponent,\n insertionPosition,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n pos!,\n clientRect,\n dropRect,\n )\n : [\n containerActive,\n containerChildren.map((child: ReactElement, index: number) =>\n index === idx\n ? insertBesideChild(\n child,\n existingComponent,\n newComponent,\n insertionPosition,\n pos,\n clientRect,\n dropRect,\n )\n : child,\n ),\n ];\n\n const active = typeOf(container) === \"Stack\" ? insertedIdx : containerActive;\n return React.cloneElement(container, { active } as any, children);\n}\n\nfunction updateChildren(\n container: LayoutModel,\n containerChildren: ReactElement[],\n idx: number,\n newComponent: ReactElement,\n insertionPosition: insertionPosition,\n pos: DropPos,\n clientRect: DropTarget[\"clientRect\"],\n dropRect: DropTarget[\"dropRect\"],\n) {\n const intrinsicSize = getIntrinsicSize(newComponent);\n if (intrinsicSize?.width && intrinsicSize?.height) {\n return insertIntrinsicSizedComponent(\n container,\n containerChildren,\n idx,\n newComponent,\n insertionPosition,\n clientRect,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dropRect!,\n );\n } else {\n return insertFlexComponent(\n container,\n containerChildren,\n idx,\n newComponent,\n insertionPosition,\n pos?.width || pos?.height,\n clientRect,\n );\n }\n}\n\nconst getLeadingPlaceholderSize = (\n flexDirection: flexDirection,\n insertionPosition: insertionPosition,\n { top, right, bottom, left }: DropTarget[\"clientRect\"],\n [rectLeft, rectTop, rectRight, rectBottom]: rectTuple,\n) => {\n if (flexDirection === \"column\" && insertionPosition === \"before\") {\n return rectTop - top;\n } else if (flexDirection === \"column\") {\n return bottom - rectBottom;\n } else if (flexDirection === \"row\" && insertionPosition === \"before\") {\n return rectLeft - left;\n } else if (flexDirection === \"row\") {\n return right - rectRight;\n }\n};\n\nfunction insertIntrinsicSizedComponent(\n container: LayoutModel,\n containerChildren: ReactElement[],\n idx: number,\n newComponent: ReactElement,\n insertionPosition: insertionPosition,\n clientRect: DropTarget[\"clientRect\"],\n dropRect: rectTuple,\n) {\n const {\n style: { flexDirection },\n } = getProps(container);\n const [dimension, crossDimension, contraDirection] =\n getFlexDimensions(flexDirection);\n const { [crossDimension]: intrinsicCrossSize, [dimension]: intrinsicSize } =\n getIntrinsicSize(newComponent) as { height: number; width: number };\n const path = getProp(containerChildren[idx], \"path\");\n\n const placeholderSize = getLeadingPlaceholderSize(\n flexDirection,\n insertionPosition,\n clientRect,\n dropRect,\n );\n\n const [itemToInsert, size] =\n intrinsicCrossSize < clientRect[crossDimension]\n ? [\n wrapIntrinsicSizeComponentWithFlexbox(\n newComponent,\n contraDirection,\n path,\n clientRect,\n dropRect,\n ),\n intrinsicSize,\n ]\n : [newComponent, undefined];\n\n const placeholder = placeholderSize\n ? createPlaceHolder(path, placeholderSize, { flexGrow: 0, flexShrink: 0 })\n : undefined;\n\n if (intrinsicCrossSize > clientRect[crossDimension]) {\n containerChildren = containerChildren.map((child) => {\n if (getProp(child, \"placeholder\")) {\n return child;\n } else {\n const { [crossDimension]: intrinsicCrossChildSize } = getIntrinsicSize(\n child,\n ) as {\n height: number;\n width: number;\n };\n if (\n intrinsicCrossChildSize &&\n intrinsicCrossChildSize < intrinsicCrossSize\n ) {\n return wrapIntrinsicSizeComponentWithFlexbox(\n child,\n contraDirection,\n getProp(child, \"path\"),\n );\n } else {\n return child;\n }\n }\n });\n }\n\n return insertFlexComponent(\n container,\n containerChildren,\n idx,\n itemToInsert,\n insertionPosition,\n size,\n clientRect,\n placeholder,\n );\n}\n\nfunction insertFlexComponent(\n container: LayoutModel,\n containerChildren: ReactElement[],\n idx: number,\n newComponent: ReactElement,\n insertionPosition: \"before\" | \"after\",\n size: number | undefined,\n targetRect: DropTarget[\"clientRect\"],\n placeholder?: ReactElement,\n) {\n const containerPath = getProp(container, \"path\");\n let insertedIdx = 0;\n const children =\n !containerChildren || containerChildren.length === 0\n ? [newComponent]\n : containerChildren\n .reduce<ReactElement[]>((arr, child, i) => {\n if (idx === i) {\n const [existingComponent, insertedComponent] =\n getStyledComponents(container, child, newComponent, targetRect);\n if (insertionPosition === \"before\") {\n if (placeholder) {\n arr.push(placeholder, insertedComponent, existingComponent);\n } else {\n arr.push(insertedComponent, existingComponent);\n }\n } else {\n if (placeholder) {\n arr.push(existingComponent, insertedComponent, placeholder);\n } else {\n arr.push(existingComponent, insertedComponent);\n }\n }\n insertedIdx = arr.indexOf(insertedComponent);\n } else {\n arr.push(child);\n }\n return arr;\n }, [])\n .map((child, i) =>\n i < insertedIdx ? child : resetPath(child, `${containerPath}.${i}`),\n );\n\n return [insertedIdx, children];\n}\n\nfunction getStyledComponents(\n container: LayoutModel,\n existingComponent: ReactElement,\n newComponent: ReactElement,\n targetRect: DropTarget[\"clientRect\"],\n): [ReactElement, ReactElement] {\n const id = uuid();\n let { version = 0 } = getProps(newComponent);\n version += 1;\n if (typeOf(container) === \"Flexbox\") {\n const { style: containerStyle } = container.props as any;\n const [dim] = getManagedDimension(containerStyle);\n const splitterSize = 6;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const size = { [dim]: (targetRect[dim] - splitterSize) / 2 };\n const existingComponentStyle = getFlexOrIntrinsicStyle(\n existingComponent,\n dim,\n size,\n );\n const newComponentStyle = getFlexOrIntrinsicStyle(newComponent, dim, size);\n\n return [\n React.cloneElement(existingComponent, {\n style: existingComponentStyle,\n } as any),\n React.cloneElement(newComponent, {\n id,\n version,\n style: newComponentStyle,\n } as any),\n ];\n } else {\n const {\n style: { left: _1, top: _2, flex: _3, ...style } = {\n left: undefined,\n top: undefined,\n flex: undefined,\n },\n } = getProps(newComponent);\n return [\n existingComponent,\n React.cloneElement(newComponent, {\n id,\n version,\n style: { ...style, flex: \"1 1 0px\" },\n } as any),\n ];\n }\n}\n"],"names":["flexDirection"],"mappings":";;;;;;;;AAsBgB,SAAA,uBAAA,CAAwB,OAAoB,GAAc,EAAA;AACxE,EAAA,MAAM,EAAE,QAAA,EAAU,IAAK,EAAA,GAAI,KAAM,CAAA,KAAA;AACjC,EAAA,MAAM,WAAW,IAAK,CAAA,MAAA;AACtB,EAAM,MAAA,EAAE,QAAQ,CAAI,CAAA,EAAA,qBAAA,GAAwB,SAAY,GAAA,GAAA,CAAI,OAAO,EAAC;AACpE,EAAA,OAAO,UAAU,CAAM,CAAA,IAAA,KAAA,IAAS,QAC5B,GAAA,CAAC,KAAK,QAAW,GAAA,CAAC,CAAG,EAAA,OAAO,IAC5B,CAAC,IAAA,CAAK,KAAK,CAAA,IAAK,MAAM,qBAAqB,CAAA;AACjD;AAEgB,SAAA,mBAAA,CACd,SACA,EAAA,eAAA,EACA,YACc,EAAA;AACd,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA,e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YAAc,EAAA;AAAA,QAC/B,EAAA;AAAA,QACA,OAAA;AAAA,QACA,KAAO,EAAA;AAAA,OACD;AAAA,KACV;AAAA,GACK,MAAA;AACL,IAAM,MAAA;AAAA,MACJ,KAAA,EAAO,EAAE,IAAA,EAAM,EAAI,EAAA,GAAA,EAAK,IAAI,IAAM,EAAA,EAAA,EAAI,GAAG,KAAA,EAAU,GAAA;AAAA,QACjD,IAAM,EAAA,KAAA,CAAA;AAAA,QACN,GAAK,EAAA,KAAA,CAAA;AAAA,QACL,IAAM,EAAA,KAAA;AAAA;AACR,KACF,GAAI,SAAS,YAAY,CAAA;AACzB,IAAO,OAAA;AAAA,MACL,iBAAA;AAAA,MACA,KAAA,CAAM,aAAa,YAAc,EAAA;AAAA,QAC/B,EAAA;AAAA,QACA,OAAA;AAAA,QACA,KAAO,EAAA,EAAE,GAAG,KAAA,EAAO,MAAM,SAAU;AAAA,OAC7B;AAAA,KACV;AAAA;AAEJ;;;;"}
@@ -1,200 +0,0 @@
1
- import { isContainer } from '@vuu-ui/vuu-utils';
2
- import React from 'react';
3
- import { followPath, findTarget, followPathToParent } from '../utils/pathUtils.js';
4
- import { getProps, getProp } from '../utils/propUtils.js';
5
- import { typeOf } from '../utils/typeOf.js';
6
- import { getIntrinsicSize } from './flexUtils.js';
7
- import { getInsertTabBeforeAfter, insertIntoContainer, insertBesideChild } from './insert-layout-element.js';
8
- import { moveChild } from './move-layout-element.js';
9
- import { LayoutActionType } from './layoutTypes.js';
10
- import { removeChild } from './remove-layout-element.js';
11
- import { replaceChild, swapChild, _replaceChild } from './replace-layout-element.js';
12
- import { resizeFlexChild, resizeFlexChildren } from './resize-flex-children.js';
13
- import { wrap } from './wrap-layout-element.js';
14
-
15
- const layoutReducer = (state, action) => {
16
- switch (action.type) {
17
- case LayoutActionType.ADD:
18
- return addChild(state, action);
19
- case LayoutActionType.DRAG_DROP:
20
- return dragDrop(state, action);
21
- case "collapse":
22
- case "expand":
23
- return setChildProps(state, action);
24
- case LayoutActionType.REMOVE:
25
- return removeChild(state, action);
26
- case LayoutActionType.REPLACE:
27
- return replaceChild(state, action);
28
- case LayoutActionType.SET_PROP:
29
- return setProp(state, action);
30
- case LayoutActionType.SET_PROPS:
31
- return setProps(state, action);
32
- case LayoutActionType.SET_TITLE:
33
- return setProp(state, {
34
- type: "set-prop",
35
- path: action.path,
36
- propName: "title",
37
- propValue: action.title
38
- });
39
- case LayoutActionType.SPLITTER_RESIZE:
40
- return resizeFlexChildren(state, action);
41
- case LayoutActionType.LAYOUT_RESIZE:
42
- return resizeFlexChild(state, action);
43
- case LayoutActionType.SWITCH_TAB:
44
- return switchTab(state, action);
45
- case LayoutActionType.MOVE_CHILD:
46
- return moveChild(state, action);
47
- default:
48
- return state;
49
- }
50
- };
51
- const switchTab = (state, { path, nextIdx }) => {
52
- const target = followPath(state, path, true);
53
- const replacement = React.cloneElement(target, {
54
- active: nextIdx
55
- });
56
- return swapChild(state, target, replacement);
57
- };
58
- const setProp = (state, { path, propName, propValue }) => {
59
- const target = followPath(state, path, true);
60
- const replacement = React.cloneElement(target, {
61
- [propName]: propValue
62
- });
63
- return swapChild(state, target, replacement);
64
- };
65
- const setProps = (state, { path, props }) => {
66
- const target = followPath(state, path, true);
67
- const replacement = React.cloneElement(target, props);
68
- return swapChild(state, target, replacement);
69
- };
70
- const setChildProps = (state, { path, type }) => {
71
- if (path) {
72
- const target = followPath(state, path, true);
73
- return swapChild(state, target, target, type);
74
- } else {
75
- return state;
76
- }
77
- };
78
- const dragDrop = (layoutRoot, action) => {
79
- const {
80
- draggedReactElement: newComponent,
81
- dragInstructions,
82
- dropTarget
83
- } = action;
84
- const existingComponent = dropTarget.component;
85
- const { pos } = dropTarget;
86
- const destinationTabstrip = pos?.position?.Header && typeOf(existingComponent) === "Stack";
87
- const { id, version } = getProps(newComponent);
88
- const intrinsicSize = getIntrinsicSize(newComponent);
89
- let newLayoutRoot;
90
- if (destinationTabstrip) {
91
- const [targetTab, insertionPosition] = getInsertTabBeforeAfter(
92
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
93
- existingComponent,
94
- pos
95
- );
96
- if (targetTab === void 0) {
97
- newLayoutRoot = insertIntoContainer(
98
- layoutRoot,
99
- existingComponent,
100
- newComponent
101
- );
102
- } else {
103
- newLayoutRoot = insertBesideChild(
104
- layoutRoot,
105
- targetTab,
106
- newComponent,
107
- insertionPosition
108
- );
109
- }
110
- } else if (!intrinsicSize && pos?.position?.Centre) {
111
- newLayoutRoot = _replaceChild(
112
- layoutRoot,
113
- existingComponent,
114
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
- newComponent
116
- );
117
- } else {
118
- newLayoutRoot = dropLayoutIntoContainer(
119
- layoutRoot,
120
- dropTarget,
121
- newComponent
122
- );
123
- }
124
- if (dragInstructions.DoNotRemove) {
125
- return newLayoutRoot;
126
- }
127
- const finalTarget = findTarget(
128
- newLayoutRoot,
129
- (props) => props.id === id && props.version === version
130
- );
131
- const finalPath = getProp(finalTarget, "path");
132
- return removeChild(newLayoutRoot, { path: finalPath, type: "remove" });
133
- };
134
- const addChild = (layoutRoot, { path: containerPath, component }) => {
135
- return insertIntoContainer(
136
- layoutRoot,
137
- followPath(layoutRoot, containerPath),
138
- component
139
- );
140
- };
141
- const dropLayoutIntoContainer = (layoutRoot, dropTarget, newComponent) => {
142
- const { component, pos, clientRect, dropRect } = dropTarget;
143
- const existingComponent = component;
144
- const existingComponentPath = getProp(existingComponent, "path");
145
- if (existingComponentPath === "0.0") {
146
- return wrap(
147
- layoutRoot,
148
- existingComponent,
149
- newComponent,
150
- pos
151
- );
152
- }
153
- const targetContainer = followPathToParent(
154
- layoutRoot,
155
- existingComponentPath
156
- );
157
- if (withTheGrain(pos, targetContainer)) {
158
- const insertionPosition = pos.position.SouthOrEast ? "after" : "before";
159
- return insertBesideChild(
160
- layoutRoot,
161
- existingComponent,
162
- newComponent,
163
- insertionPosition,
164
- pos,
165
- clientRect,
166
- dropRect
167
- );
168
- }
169
- if (!withTheGrain(pos, targetContainer)) {
170
- return wrap(
171
- layoutRoot,
172
- existingComponent,
173
- newComponent,
174
- pos,
175
- clientRect,
176
- dropRect
177
- );
178
- }
179
- if (isContainer(typeOf(targetContainer))) {
180
- return wrap(layoutRoot, existingComponent, newComponent, pos);
181
- }
182
- throw Error(`no support right now for position = ${pos.position}`);
183
- };
184
- const withTheGrain = (pos, container) => {
185
- if (pos.position.Centre) {
186
- return isTerrace(container) || isTower(container);
187
- }
188
- return pos.position.NorthOrSouth ? isTower(container) : pos.position.EastOrWest ? isTerrace(container) : false;
189
- };
190
- const isTower = (container) => {
191
- const { style } = container.props;
192
- return typeOf(container) === "Flexbox" && style.flexDirection === "column";
193
- };
194
- const isTerrace = (container) => {
195
- const { style } = container.props;
196
- return typeOf(container) === "Flexbox" && style.flexDirection !== "column";
197
- };
198
-
199
- export { layoutReducer };
200
- //# sourceMappingURL=layout-reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"layout-reducer.js","sources":["../../../../packages/vuu-layout/src/layout-reducer/layout-reducer.ts"],"sourcesContent":["import { isContainer } from \"@vuu-ui/vuu-utils\";\nimport React, { ReactElement } from \"react\";\nimport { DropPos } from \"../drag-drop/dragDropTypes\";\nimport { DropTarget } from \"../drag-drop/DropTarget\";\nimport {\n findTarget,\n followPath,\n followPathToParent,\n getProp,\n getProps,\n typeOf,\n} from \"../utils\";\nimport { getIntrinsicSize } from \"./flexUtils\";\nimport {\n getInsertTabBeforeAfter,\n insertBesideChild,\n insertIntoContainer,\n} from \"./insert-layout-element\";\nimport { moveChild } from \"./move-layout-element\";\nimport {\n AddAction,\n CollapseAction,\n DragDropAction,\n ExpandAction,\n LayoutActionType,\n LayoutReducerAction,\n SetPropAction,\n SetPropsAction,\n SwitchTabAction,\n} from \"./layoutTypes\";\nimport { LayoutProps } from \"./layoutUtils\";\nimport { removeChild } from \"./remove-layout-element\";\nimport {\n replaceChild,\n swapChild,\n _replaceChild,\n} from \"./replace-layout-element\";\nimport { resizeFlexChild, resizeFlexChildren } from \"./resize-flex-children\";\nimport { wrap } from \"./wrap-layout-element\";\n\nexport const layoutReducer = (\n state: ReactElement,\n action: LayoutReducerAction,\n): ReactElement => {\n switch (action.type) {\n case LayoutActionType.ADD:\n return addChild(state, action);\n case LayoutActionType.DRAG_DROP:\n return dragDrop(state, action);\n case \"collapse\":\n case \"expand\":\n return setChildProps(state, action);\n case LayoutActionType.REMOVE:\n return removeChild(state, action);\n case LayoutActionType.REPLACE:\n return replaceChild(state, action);\n case LayoutActionType.SET_PROP:\n return setProp(state, action);\n case LayoutActionType.SET_PROPS:\n return setProps(state, action);\n case LayoutActionType.SET_TITLE:\n return setProp(state, {\n type: \"set-prop\",\n path: action.path,\n propName: \"title\",\n propValue: action.title,\n });\n case LayoutActionType.SPLITTER_RESIZE:\n return resizeFlexChildren(state, action);\n case LayoutActionType.LAYOUT_RESIZE:\n return resizeFlexChild(state, action);\n case LayoutActionType.SWITCH_TAB:\n return switchTab(state, action);\n case LayoutActionType.MOVE_CHILD:\n return moveChild(state, action);\n default:\n return state;\n }\n};\n\nconst switchTab = (state: ReactElement, { path, nextIdx }: SwitchTabAction) => {\n const target = followPath(state, path, true);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const replacement = React.cloneElement<any>(target, {\n active: nextIdx,\n });\n return swapChild(state, target, replacement);\n};\n\nconst setProp = (\n state: ReactElement,\n { path, propName, propValue }: SetPropAction,\n) => {\n const target = followPath(state, path, true);\n const replacement = React.cloneElement(target, {\n [propName]: propValue,\n });\n return swapChild(state, target, replacement);\n};\n\nconst setProps = (state: ReactElement, { path, props }: SetPropsAction) => {\n const target = followPath(state, path, true);\n const replacement = React.cloneElement(target, props);\n return swapChild(state, target, replacement);\n};\n\nconst setChildProps = (\n state: ReactElement,\n { path, type }: CollapseAction | ExpandAction,\n) => {\n if (path) {\n const target = followPath(state, path, true);\n return swapChild(state, target, target, type);\n } else {\n return state;\n }\n};\n\nconst dragDrop = (\n layoutRoot: ReactElement,\n action: DragDropAction,\n): ReactElement => {\n const {\n draggedReactElement: newComponent,\n dragInstructions,\n dropTarget,\n } = action;\n const existingComponent = dropTarget.component as ReactElement;\n const { pos } = dropTarget;\n const destinationTabstrip =\n pos?.position?.Header && typeOf(existingComponent) === \"Stack\";\n const { id, version } = getProps(newComponent);\n const intrinsicSize = getIntrinsicSize(newComponent);\n let newLayoutRoot: ReactElement;\n if (destinationTabstrip) {\n const [targetTab, insertionPosition] = getInsertTabBeforeAfter(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n existingComponent!,\n pos,\n );\n if (targetTab === undefined) {\n newLayoutRoot = insertIntoContainer(\n layoutRoot,\n existingComponent,\n newComponent,\n );\n } else {\n newLayoutRoot = insertBesideChild(\n layoutRoot,\n targetTab,\n newComponent,\n insertionPosition,\n );\n }\n } else if (!intrinsicSize && pos?.position?.Centre) {\n newLayoutRoot = _replaceChild(\n layoutRoot,\n existingComponent as ReactElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newComponent as any,\n );\n } else {\n newLayoutRoot = dropLayoutIntoContainer(\n layoutRoot,\n dropTarget as DropTarget,\n newComponent,\n );\n }\n\n if (dragInstructions.DoNotRemove) {\n return newLayoutRoot;\n }\n\n const finalTarget = findTarget(\n newLayoutRoot,\n (props: LayoutProps) => props.id === id && props.version === version,\n ) as ReactElement;\n const finalPath = getProp(finalTarget, \"path\");\n return removeChild(newLayoutRoot, { path: finalPath, type: \"remove\" });\n};\n\nconst addChild = (\n layoutRoot: ReactElement,\n { path: containerPath, component }: AddAction,\n) => {\n return insertIntoContainer(\n layoutRoot,\n followPath(layoutRoot, containerPath) as ReactElement,\n component,\n );\n};\n\nconst dropLayoutIntoContainer = (\n layoutRoot: ReactElement,\n dropTarget: DropTarget,\n newComponent: ReactElement,\n): ReactElement => {\n const { component, pos, clientRect, dropRect } = dropTarget;\n const existingComponent = component as ReactElement;\n\n const existingComponentPath = getProp(existingComponent, \"path\");\n\n if (existingComponentPath === \"0.0\") {\n return wrap(\n layoutRoot,\n existingComponent as ReactElement,\n newComponent,\n pos,\n );\n }\n\n const targetContainer = followPathToParent(\n layoutRoot,\n existingComponentPath,\n ) as ReactElement;\n\n if (withTheGrain(pos, targetContainer)) {\n const insertionPosition = pos.position.SouthOrEast ? \"after\" : \"before\";\n return insertBesideChild(\n layoutRoot,\n existingComponent,\n newComponent,\n insertionPosition,\n pos,\n clientRect,\n dropRect,\n );\n }\n\n if (!withTheGrain(pos, targetContainer)) {\n return wrap(\n layoutRoot,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect,\n );\n }\n\n if (isContainer(typeOf(targetContainer) as string)) {\n return wrap(layoutRoot, existingComponent, newComponent, pos);\n }\n\n throw Error(`no support right now for position = ${pos.position}`);\n};\n\nconst withTheGrain = (pos: DropPos, container: ReactElement) => {\n if (pos.position.Centre) {\n return isTerrace(container) || isTower(container);\n }\n\n return pos.position.NorthOrSouth\n ? isTower(container)\n : pos.position.EastOrWest\n ? isTerrace(container)\n : false;\n};\n\nconst isTower = (container: ReactElement) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { style } = container.props as any;\n return typeOf(container) === \"Flexbox\" && style.flexDirection === \"column\";\n};\n\nconst isTerrace = (container: ReactElement) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { style } = container.props as any;\n return typeOf(container) === \"Flexbox\" && style.flexDirection !== \"column\";\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAwCa,MAAA,aAAA,GAAgB,CAC3B,KAAA,EACA,MACiB,KAAA;AACjB,EAAA,QAAQ,OAAO,IAAM;AAAA,IACnB,KAAK,gBAAiB,CAAA,GAAA;AACpB,MAAO,OAAA,QAAA,CAAS,OAAO,MAAM,CAAA;AAAA,IAC/B,KAAK,gBAAiB,CAAA,SAAA;AACpB,MAAO,OAAA,QAAA,CAAS,OAAO,MAAM,CAAA;AAAA,IAC/B,KAAK,UAAA;AAAA,IACL,KAAK,QAAA;AACH,MAAO,OAAA,a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RESIZE: "layout-resize",
6
- MAXIMIZE: "maximize",
7
- MINIMIZE: "minimize",
8
- MOVE_CHILD: "move-child",
9
- QUERY: "query",
10
- REMOVE: "remove",
11
- REPLACE: "replace",
12
- RESTORE: "restore",
13
- SET_PROP: "set-prop",
14
- SET_PROPS: "set-props",
15
- SET_TITLE: "set-title",
16
- SPLITTER_RESIZE: "splitter-resize",
17
- SWITCH_TAB: "switch-tab",
18
- TEAROUT: "tearout"
19
- };
20
- const isApplicationLevelChange = (layoutChangeReason) => [
21
- "switch-active-layout",
22
- "open-layout",
23
- "close-layout",
24
- "rename-layout"
25
- ].includes(layoutChangeReason);
26
- const isLayoutLevelChange = (layoutChangeReason) => [
27
- "switch-active-tab",
28
- "edit-feature-title",
29
- "save-feature-props",
30
- "remove-component",
31
- "resize-component",
32
- "drag-drop-operation"
33
- ].includes(layoutChangeReason);
34
-
35
- export { LayoutActionType, isApplicationLevelChange, isLayoutLevelChange };
36
- //# sourceMappingURL=layoutTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"layoutTypes.js","sources":["../../../../packages/vuu-layout/src/layout-reducer/layoutTypes.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { LayoutJSON } from \"@vuu-ui/vuu-utils\";\nimport { ReactElement } from \"react\";\nimport { DragDropRect, DragInstructions } from \"../drag-drop\";\nimport { DropTarget } from \"../drag-drop/DropTarget\";\n\nexport type layoutType = \"Flexbox\" | \"View\" | \"LayoutContainer\" | \"Stack\";\n\n// TODO duplicated in layout-action\nexport const LayoutActionType = {\n ADD: \"add\",\n DRAG_START: \"drag-start\",\n DRAG_DROP: \"drag-drop\",\n LAYOUT_RESIZE: \"layout-resize\",\n MAXIMIZE: \"maximize\",\n MINIMIZE: \"minimize\",\n MOVE_CHILD: \"move-child\",\n QUERY: \"query\",\n REMOVE: \"remove\",\n REPLACE: \"replace\",\n RESTORE: \"restore\",\n SET_PROP: \"set-prop\",\n SET_PROPS: \"set-props\",\n SET_TITLE: \"set-title\",\n SPLITTER_RESIZE: \"splitter-resize\",\n SWITCH_TAB: \"switch-tab\",\n TEAROUT: \"tearout\",\n} as const;\n\nexport type AddAction = {\n component: any;\n path: string;\n type: typeof LayoutActionType.ADD;\n};\n\nexport type DragDropAction = {\n draggedReactElement: ReactElement;\n dragInstructions: any;\n dropTarget: Partial<DropTarget>;\n type: typeof LayoutActionType.DRAG_DROP;\n};\n\nexport type MaximizeAction = {\n path?: string;\n type: typeof LayoutActionType.MAXIMIZE;\n};\n\nexport type CollapseAction = {\n path?: string;\n type: \"collapse\";\n};\n\nexport type ExpandAction = {\n path?: string;\n type: \"expand\";\n};\n\nexport type MoveChildAction = {\n fromIndex: number;\n toIndex: number;\n path: string;\n type: typeof LayoutActionType.MOVE_CHILD;\n};\n\nexport type QueryAction = {\n path?: string;\n query: string;\n type: typeof LayoutActionType.QUERY;\n};\n\nexport type RemoveAction = {\n path?: string;\n type: typeof LayoutActionType.REMOVE;\n};\n\nexport type ReplaceAction = {\n replacement: any;\n target: any;\n type: typeof LayoutActionType.REPLACE;\n};\n\nexport type RestoreAction = {\n path?: string;\n type: typeof LayoutActionType.RESTORE;\n};\n\nexport type SetPropAction = {\n path: string;\n propName: string;\n propValue: string | number | boolean;\n type: typeof LayoutActionType.SET_PROP;\n};\n\nexport type SetPropsAction = {\n path: string;\n props: { [key: string]: unknown };\n type: typeof LayoutActionType.SET_PROPS;\n};\n\nexport type SetTitleAction = {\n path: string;\n title: string;\n type: typeof LayoutActionType.SET_TITLE;\n};\n\nexport type SplitterResizeAction = {\n path: string;\n sizes: { currentSize: number; flexBasis: number }[];\n type: typeof LayoutActionType.SPLITTER_RESIZE;\n};\n\nexport type LayoutResizeAction = {\n path: string;\n size: number;\n type: typeof LayoutActionType.LAYOUT_RESIZE;\n};\n\nexport type SwitchTabAction = {\n id?: string;\n nextIdx: number;\n path: string;\n type: typeof LayoutActionType.SWITCH_TAB;\n};\n\nexport type TearoutAction = {\n path?: string;\n type: typeof LayoutActionType.TEAROUT;\n};\n\nexport type LayoutReducerAction =\n | AddAction\n | DragDropAction\n | LayoutResizeAction\n | CollapseAction\n | ExpandAction\n | MoveChildAction\n | RemoveAction\n | ReplaceAction\n | RestoreAction\n | SetPropAction\n | SetPropsAction\n | SetTitleAction\n | SplitterResizeAction\n | SwitchTabAction;\n\nexport type MousedownViewAction = {\n preDragActivity?: unknown;\n index?: number;\n type: \"mousedown\";\n};\n\nexport type DragStartAction = {\n payload?: ReactElement;\n dragContainerPath?: string;\n dragElement?: HTMLElement;\n dragRect: DragDropRect;\n dropTargets?: string[];\n evt: MouseEvent;\n instructions?: DragInstructions;\n path: string;\n type: typeof LayoutActionType.DRAG_START;\n};\n\nexport type LayoutLevelChange =\n | \"add-component\"\n | \"drag-drop-operation\"\n | \"edit-feature-title\"\n | \"remove-component\"\n | \"resize-component\"\n | \"switch-active-tab\"\n | \"save-feature-props\";\n\nexport type ApplicationLevelChange =\n | \"switch-active-layout\"\n | \"open-layout\"\n | \"close-layout\"\n | \"rename-layout\"\n | \"resize-application-chrome\";\n\nexport type LayoutChangeReason = LayoutLevelChange | ApplicationLevelChange;\n\nexport type LayoutChangeHandler = (\n layout: LayoutJSON,\n layoutChangeReason: LayoutChangeReason,\n) => void;\n\nexport const isApplicationLevelChange = (\n layoutChangeReason: LayoutChangeReason,\n): layoutChangeReason is ApplicationLevelChange =>\n [\n \"switch-active-layout\",\n \"open-layout\",\n \"close-layout\",\n \"rename-layout\",\n ].includes(layoutChangeReason);\n\nexport const isLayoutLevelChange = (\n layoutChangeReason: LayoutChangeReason,\n): layoutChangeReason is LayoutLevelChange =>\n [\n \"switch-active-tab\",\n \"edit-feature-title\",\n \"save-feature-props\",\n \"remove-component\",\n \"resize-component\",\n \"drag-drop-operation\",\n ].includes(layoutChangeReason);\n"],"names":[],"mappings":"AASO,MAAM,gBAAmB,GAAA;AAAA,EAC9B,GAAK,EAAA,KAAA;AAAA,EACL,UAAY,EAAA,YAAA;AAAA,EACZ,SAAW,EAAA,WAAA;AAAA,EACX,aAAe,EAAA,eAAA;AAAA,EACf,QAAU,EAAA,UAAA;AAAA,EACV,QAAU,EAAA,UAAA;AAAA,EACV,UAAY,EAAA,YAAA;AAAA,EACZ,KAAO,EAAA,OAAA;AAAA,EACP,MAAQ,EAAA,QAAA;AAAA,EACR,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,QAAU,EAAA,UAAA;AAAA,EACV,SAAW,EAAA,WAAA;AAAA,EACX,SAAW,EAAA,WAAA;AAAA,EACX,eAAiB,EAAA,iBAAA;AAAA,EACjB,UAAY,EAAA,YAAA;AAAA,EACZ,OAAS,EAAA;AACX;AA+Ja,MAAA,wBAAA,GAA2B,CACtC,kBAEA,KAAA;AAAA,EACE,sBAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,CAAE,SAAS,kBAAkB;AAElB,MAAA,mBAAA,GAAsB,CACjC,kBAEA,KAAA;AAAA,EACE,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA,CAAE,SAAS,kBAAkB;;;;"}