@vuu-ui/vuu-layout 2.1.19-beta.1 → 2.1.19-beta.3

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 (265) hide show
  1. package/cjs/Component.js +14 -0
  2. package/cjs/Component.js.map +1 -0
  3. package/cjs/LayoutContainer.css.js +6 -0
  4. package/cjs/LayoutContainer.css.js.map +1 -0
  5. package/cjs/LayoutContainer.js +33 -0
  6. package/cjs/LayoutContainer.js.map +1 -0
  7. package/cjs/dock-layout/DockLayout.css.js +6 -0
  8. package/cjs/dock-layout/DockLayout.css.js.map +1 -0
  9. package/cjs/dock-layout/DockLayout.js +41 -0
  10. package/cjs/dock-layout/DockLayout.js.map +1 -0
  11. package/cjs/dock-layout/Drawer.css.js +6 -0
  12. package/cjs/dock-layout/Drawer.css.js.map +1 -0
  13. package/cjs/dock-layout/Drawer.js +95 -0
  14. package/cjs/dock-layout/Drawer.js.map +1 -0
  15. package/cjs/drag-drop/BoxModel.js +416 -0
  16. package/cjs/drag-drop/BoxModel.js.map +1 -0
  17. package/cjs/drag-drop/DragState.js +161 -0
  18. package/cjs/drag-drop/DragState.js.map +1 -0
  19. package/cjs/drag-drop/Draggable.js +192 -0
  20. package/cjs/drag-drop/Draggable.js.map +1 -0
  21. package/cjs/drag-drop/DropTarget.js +257 -0
  22. package/cjs/drag-drop/DropTarget.js.map +1 -0
  23. package/cjs/drag-drop/DropTargetRenderer.js +218 -0
  24. package/cjs/drag-drop/DropTargetRenderer.js.map +1 -0
  25. package/cjs/flexbox/Flexbox.css.js +6 -0
  26. package/cjs/flexbox/Flexbox.css.js.map +1 -0
  27. package/cjs/flexbox/Flexbox.js +69 -0
  28. package/cjs/flexbox/Flexbox.js.map +1 -0
  29. package/cjs/flexbox/FlexboxLayout.js +30 -0
  30. package/cjs/flexbox/FlexboxLayout.js.map +1 -0
  31. package/cjs/flexbox/Splitter.css.js +6 -0
  32. package/cjs/flexbox/Splitter.css.js.map +1 -0
  33. package/cjs/flexbox/Splitter.js +122 -0
  34. package/cjs/flexbox/Splitter.js.map +1 -0
  35. package/cjs/flexbox/flexbox-utils.js +95 -0
  36. package/cjs/flexbox/flexbox-utils.js.map +1 -0
  37. package/cjs/flexbox/useSplitterResizing.js +197 -0
  38. package/cjs/flexbox/useSplitterResizing.js.map +1 -0
  39. package/cjs/index.js +122 -0
  40. package/cjs/index.js.map +1 -0
  41. package/cjs/layout-action.js +24 -0
  42. package/cjs/layout-action.js.map +1 -0
  43. package/cjs/layout-header/Header.css.js +6 -0
  44. package/cjs/layout-header/Header.css.js.map +1 -0
  45. package/cjs/layout-header/Header.js +152 -0
  46. package/cjs/layout-header/Header.js.map +1 -0
  47. package/cjs/layout-header/useHeader.js +85 -0
  48. package/cjs/layout-header/useHeader.js.map +1 -0
  49. package/cjs/layout-provider/LayoutProvider.js +304 -0
  50. package/cjs/layout-provider/LayoutProvider.js.map +1 -0
  51. package/cjs/layout-provider/LayoutProviderContext.js +23 -0
  52. package/cjs/layout-provider/LayoutProviderContext.js.map +1 -0
  53. package/cjs/layout-provider/useLayoutDragDrop.js +177 -0
  54. package/cjs/layout-provider/useLayoutDragDrop.js.map +1 -0
  55. package/cjs/layout-reducer/flexUtils.js +227 -0
  56. package/cjs/layout-reducer/flexUtils.js.map +1 -0
  57. package/cjs/layout-reducer/insert-layout-element.js +286 -0
  58. package/cjs/layout-reducer/insert-layout-element.js.map +1 -0
  59. package/cjs/layout-reducer/layout-reducer.js +202 -0
  60. package/cjs/layout-reducer/layout-reducer.js.map +1 -0
  61. package/cjs/layout-reducer/layoutTypes.js +40 -0
  62. package/cjs/layout-reducer/layoutTypes.js.map +1 -0
  63. package/cjs/layout-reducer/layoutUtils.js +237 -0
  64. package/cjs/layout-reducer/layoutUtils.js.map +1 -0
  65. package/cjs/layout-reducer/move-layout-element.js +31 -0
  66. package/cjs/layout-reducer/move-layout-element.js.map +1 -0
  67. package/cjs/layout-reducer/remove-layout-element.js +237 -0
  68. package/cjs/layout-reducer/remove-layout-element.js.map +1 -0
  69. package/cjs/layout-reducer/replace-layout-element.js +96 -0
  70. package/cjs/layout-reducer/replace-layout-element.js.map +1 -0
  71. package/cjs/layout-reducer/resize-flex-children.js +62 -0
  72. package/cjs/layout-reducer/resize-flex-children.js.map +1 -0
  73. package/cjs/layout-reducer/wrap-layout-element.js +211 -0
  74. package/cjs/layout-reducer/wrap-layout-element.js.map +1 -0
  75. package/cjs/layout-view/View.css.js +6 -0
  76. package/cjs/layout-view/View.css.js.map +1 -0
  77. package/cjs/layout-view/View.js +160 -0
  78. package/cjs/layout-view/View.js.map +1 -0
  79. package/cjs/layout-view/useView.js +75 -0
  80. package/cjs/layout-view/useView.js.map +1 -0
  81. package/cjs/layout-view/useViewBroadcastChannel.js +35 -0
  82. package/cjs/layout-view/useViewBroadcastChannel.js.map +1 -0
  83. package/cjs/layout-view/useViewResize.js +42 -0
  84. package/cjs/layout-view/useViewResize.js.map +1 -0
  85. package/cjs/layout-view-actions/ViewContext.js +16 -0
  86. package/cjs/layout-view-actions/ViewContext.js.map +1 -0
  87. package/cjs/layout-view-actions/useViewActionDispatcher.js +112 -0
  88. package/cjs/layout-view-actions/useViewActionDispatcher.js.map +1 -0
  89. package/cjs/layout-view-actions/useViewContributions.js +33 -0
  90. package/cjs/layout-view-actions/useViewContributions.js.map +1 -0
  91. package/cjs/palette/Palette.css.js +6 -0
  92. package/cjs/palette/Palette.css.js.map +1 -0
  93. package/cjs/palette/Palette.js +115 -0
  94. package/cjs/palette/Palette.js.map +1 -0
  95. package/cjs/placeholder/LayoutStartPanel.css.js +6 -0
  96. package/cjs/placeholder/LayoutStartPanel.css.js.map +1 -0
  97. package/cjs/placeholder/LayoutStartPanel.js +56 -0
  98. package/cjs/placeholder/LayoutStartPanel.js.map +1 -0
  99. package/cjs/placeholder/Placeholder.css.js +6 -0
  100. package/cjs/placeholder/Placeholder.css.js.map +1 -0
  101. package/cjs/placeholder/Placeholder.js +34 -0
  102. package/cjs/placeholder/Placeholder.js.map +1 -0
  103. package/cjs/responsive/useResizeObserver.js +118 -0
  104. package/cjs/responsive/useResizeObserver.js.map +1 -0
  105. package/cjs/responsive/utils.js +34 -0
  106. package/cjs/responsive/utils.js.map +1 -0
  107. package/cjs/stack/Stack.css.js +6 -0
  108. package/cjs/stack/Stack.css.js.map +1 -0
  109. package/cjs/stack/Stack.js +150 -0
  110. package/cjs/stack/Stack.js.map +1 -0
  111. package/cjs/stack/StackLayout.js +116 -0
  112. package/cjs/stack/StackLayout.js.map +1 -0
  113. package/cjs/use-persistent-state.js +63 -0
  114. package/cjs/use-persistent-state.js.map +1 -0
  115. package/cjs/utils/pathUtils.js +293 -0
  116. package/cjs/utils/pathUtils.js.map +1 -0
  117. package/cjs/utils/propUtils.js +27 -0
  118. package/cjs/utils/propUtils.js.map +1 -0
  119. package/cjs/utils/refUtils.js +12 -0
  120. package/cjs/utils/refUtils.js.map +1 -0
  121. package/cjs/utils/styleUtils.js +15 -0
  122. package/cjs/utils/styleUtils.js.map +1 -0
  123. package/cjs/utils/typeOf.js +27 -0
  124. package/cjs/utils/typeOf.js.map +1 -0
  125. package/esm/Component.js +12 -0
  126. package/esm/Component.js.map +1 -0
  127. package/esm/LayoutContainer.css.js +4 -0
  128. package/esm/LayoutContainer.css.js.map +1 -0
  129. package/esm/LayoutContainer.js +31 -0
  130. package/esm/LayoutContainer.js.map +1 -0
  131. package/esm/dock-layout/DockLayout.css.js +4 -0
  132. package/esm/dock-layout/DockLayout.css.js.map +1 -0
  133. package/esm/dock-layout/DockLayout.js +39 -0
  134. package/esm/dock-layout/DockLayout.js.map +1 -0
  135. package/esm/dock-layout/Drawer.css.js +4 -0
  136. package/esm/dock-layout/Drawer.css.js.map +1 -0
  137. package/esm/dock-layout/Drawer.js +93 -0
  138. package/esm/dock-layout/Drawer.js.map +1 -0
  139. package/esm/drag-drop/BoxModel.js +409 -0
  140. package/esm/drag-drop/BoxModel.js.map +1 -0
  141. package/esm/drag-drop/DragState.js +159 -0
  142. package/esm/drag-drop/DragState.js.map +1 -0
  143. package/esm/drag-drop/Draggable.js +190 -0
  144. package/esm/drag-drop/Draggable.js.map +1 -0
  145. package/esm/drag-drop/DropTarget.js +253 -0
  146. package/esm/drag-drop/DropTarget.js.map +1 -0
  147. package/esm/drag-drop/DropTargetRenderer.js +216 -0
  148. package/esm/drag-drop/DropTargetRenderer.js.map +1 -0
  149. package/esm/flexbox/Flexbox.css.js +4 -0
  150. package/esm/flexbox/Flexbox.css.js.map +1 -0
  151. package/esm/flexbox/Flexbox.js +67 -0
  152. package/esm/flexbox/Flexbox.js.map +1 -0
  153. package/esm/flexbox/FlexboxLayout.js +28 -0
  154. package/esm/flexbox/FlexboxLayout.js.map +1 -0
  155. package/esm/flexbox/Splitter.css.js +4 -0
  156. package/esm/flexbox/Splitter.css.js.map +1 -0
  157. package/esm/flexbox/Splitter.js +120 -0
  158. package/esm/flexbox/Splitter.js.map +1 -0
  159. package/esm/flexbox/flexbox-utils.js +89 -0
  160. package/esm/flexbox/flexbox-utils.js.map +1 -0
  161. package/esm/flexbox/useSplitterResizing.js +195 -0
  162. package/esm/flexbox/useSplitterResizing.js.map +1 -0
  163. package/esm/index.js +33 -0
  164. package/esm/index.js.map +1 -0
  165. package/esm/layout-action.js +22 -0
  166. package/esm/layout-action.js.map +1 -0
  167. package/esm/layout-header/Header.css.js +4 -0
  168. package/esm/layout-header/Header.css.js.map +1 -0
  169. package/esm/layout-header/Header.js +150 -0
  170. package/esm/layout-header/Header.js.map +1 -0
  171. package/esm/layout-header/useHeader.js +83 -0
  172. package/esm/layout-header/useHeader.js.map +1 -0
  173. package/esm/layout-provider/LayoutProvider.js +297 -0
  174. package/esm/layout-provider/LayoutProvider.js.map +1 -0
  175. package/esm/layout-provider/LayoutProviderContext.js +20 -0
  176. package/esm/layout-provider/LayoutProviderContext.js.map +1 -0
  177. package/esm/layout-provider/useLayoutDragDrop.js +175 -0
  178. package/esm/layout-provider/useLayoutDragDrop.js.map +1 -0
  179. package/esm/layout-reducer/flexUtils.js +218 -0
  180. package/esm/layout-reducer/flexUtils.js.map +1 -0
  181. package/esm/layout-reducer/insert-layout-element.js +282 -0
  182. package/esm/layout-reducer/insert-layout-element.js.map +1 -0
  183. package/esm/layout-reducer/layout-reducer.js +200 -0
  184. package/esm/layout-reducer/layout-reducer.js.map +1 -0
  185. package/esm/layout-reducer/layoutTypes.js +36 -0
  186. package/esm/layout-reducer/layoutTypes.js.map +1 -0
  187. package/esm/layout-reducer/layoutUtils.js +226 -0
  188. package/esm/layout-reducer/layoutUtils.js.map +1 -0
  189. package/esm/layout-reducer/move-layout-element.js +29 -0
  190. package/esm/layout-reducer/move-layout-element.js.map +1 -0
  191. package/esm/layout-reducer/remove-layout-element.js +235 -0
  192. package/esm/layout-reducer/remove-layout-element.js.map +1 -0
  193. package/esm/layout-reducer/replace-layout-element.js +92 -0
  194. package/esm/layout-reducer/replace-layout-element.js.map +1 -0
  195. package/esm/layout-reducer/resize-flex-children.js +59 -0
  196. package/esm/layout-reducer/resize-flex-children.js.map +1 -0
  197. package/esm/layout-reducer/wrap-layout-element.js +209 -0
  198. package/esm/layout-reducer/wrap-layout-element.js.map +1 -0
  199. package/esm/layout-view/View.css.js +4 -0
  200. package/esm/layout-view/View.css.js.map +1 -0
  201. package/esm/layout-view/View.js +158 -0
  202. package/esm/layout-view/View.js.map +1 -0
  203. package/esm/layout-view/useView.js +73 -0
  204. package/esm/layout-view/useView.js.map +1 -0
  205. package/esm/layout-view/useViewBroadcastChannel.js +33 -0
  206. package/esm/layout-view/useViewBroadcastChannel.js.map +1 -0
  207. package/esm/layout-view/useViewResize.js +40 -0
  208. package/esm/layout-view/useViewResize.js.map +1 -0
  209. package/esm/layout-view-actions/ViewContext.js +12 -0
  210. package/esm/layout-view-actions/ViewContext.js.map +1 -0
  211. package/esm/layout-view-actions/useViewActionDispatcher.js +110 -0
  212. package/esm/layout-view-actions/useViewActionDispatcher.js.map +1 -0
  213. package/esm/layout-view-actions/useViewContributions.js +31 -0
  214. package/esm/layout-view-actions/useViewContributions.js.map +1 -0
  215. package/esm/palette/Palette.css.js +4 -0
  216. package/esm/palette/Palette.css.js.map +1 -0
  217. package/esm/palette/Palette.js +112 -0
  218. package/esm/palette/Palette.js.map +1 -0
  219. package/esm/placeholder/LayoutStartPanel.css.js +4 -0
  220. package/esm/placeholder/LayoutStartPanel.css.js.map +1 -0
  221. package/esm/placeholder/LayoutStartPanel.js +54 -0
  222. package/esm/placeholder/LayoutStartPanel.js.map +1 -0
  223. package/esm/placeholder/Placeholder.css.js +4 -0
  224. package/esm/placeholder/Placeholder.css.js.map +1 -0
  225. package/esm/placeholder/Placeholder.js +32 -0
  226. package/esm/placeholder/Placeholder.js.map +1 -0
  227. package/esm/responsive/useResizeObserver.js +112 -0
  228. package/esm/responsive/useResizeObserver.js.map +1 -0
  229. package/esm/responsive/utils.js +31 -0
  230. package/esm/responsive/utils.js.map +1 -0
  231. package/esm/stack/Stack.css.js +4 -0
  232. package/esm/stack/Stack.css.js.map +1 -0
  233. package/esm/stack/Stack.js +148 -0
  234. package/esm/stack/Stack.js.map +1 -0
  235. package/esm/stack/StackLayout.js +114 -0
  236. package/esm/stack/StackLayout.js.map +1 -0
  237. package/esm/use-persistent-state.js +58 -0
  238. package/esm/use-persistent-state.js.map +1 -0
  239. package/esm/utils/pathUtils.js +280 -0
  240. package/esm/utils/pathUtils.js.map +1 -0
  241. package/esm/utils/propUtils.js +23 -0
  242. package/esm/utils/propUtils.js.map +1 -0
  243. package/esm/utils/refUtils.js +10 -0
  244. package/esm/utils/refUtils.js.map +1 -0
  245. package/esm/utils/styleUtils.js +13 -0
  246. package/esm/utils/styleUtils.js.map +1 -0
  247. package/esm/utils/typeOf.js +23 -0
  248. package/esm/utils/typeOf.js.map +1 -0
  249. package/package.json +16 -14
  250. package/types/dock-layout/DockLayout.d.ts +4 -4
  251. package/types/dock-layout/Drawer.d.ts +4 -4
  252. package/types/drag-drop/BoxModel.d.ts +7 -7
  253. package/types/flexbox/FlexboxLayout.d.ts +4 -4
  254. package/types/flexbox/Splitter.d.ts +1 -1
  255. package/types/layout-reducer/layoutUtils.d.ts +1 -1
  256. package/types/layout-reducer/remove-layout-element.d.ts +1 -1
  257. package/types/layout-reducer/replace-layout-element.d.ts +2 -2
  258. package/types/layout-reducer/resize-flex-children.d.ts +2 -2
  259. package/types/layout-view/useView.d.ts +1 -1
  260. package/types/placeholder/Placeholder.d.ts +4 -4
  261. package/types/responsive/overflowUtils.d.ts +2 -2
  262. package/types/stack/StackLayout.d.ts +4 -4
  263. package/types/tools/devtools-box/layout-configurator.d.ts +26 -26
  264. package/types/tools/devtools-tree/layout-tree-viewer.d.ts +2 -2
  265. package/types/utils/pathUtils.d.ts +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-layout-element.js","sources":["../../../../packages/vuu-layout/src/layout-reducer/wrap-layout-element.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n getLayoutComponent,\n LayoutModel,\n rectTuple,\n uuid,\n} from \"@vuu-ui/vuu-utils\";\nimport React, { ReactElement } from \"react\";\nimport { DropPos } from \"../drag-drop/dragDropTypes\";\nimport { DropTarget } from \"../drag-drop/DropTarget\";\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 { 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\" &&\n (container.props as any).splitterSize) ??\n undefined,\n }\n : undefined;\n\n const id = uuid();\n const wrapper = React.createElement(\n getLayoutComponent(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 as any).style,\n flexDirection,\n };\n\n const dimension =\n type === \"Flexbox\" && flexDirection === \"column\" ? \"height\" : \"width\";\n const newComponentStyle = getFlexStyle(newComponent, dimension, pos);\n const existingComponentStyle = getFlexStyle(existingComponent, dimension);\n\n return [style, existingComponentStyle, newComponentStyle];\n}\n\nconst isTargetFirst = (pos: DropPos) =>\n pos.position.SouthOrEast\n ? true\n : pos?.tab?.positionRelativeToTab === \"before\"\n ? false\n : pos.position.Header\n ? true\n : false;\n\nfunction getLayoutSpecForWrapper(pos: DropPos): LayoutSpec {\n if (pos.position.Header) {\n return {\n type: \"Stack\",\n flexDirection: \"column\",\n showTabs: true,\n };\n } else {\n return {\n type: \"Flexbox\",\n flexDirection: pos.position.EastOrWest ? \"row\" : \"column\",\n };\n }\n}\n"],"names":["typeOf","getProps","getProp","nextStep","getIntrinsicSize","flexDirection","uuid","getLayoutComponent","resetPath","applyLayoutProps","createPlaceHolder","wrapIntrinsicSizeComponentWithFlexbox","createFlexbox","getFlexStyle"],"mappings":";;;;;;;;;;AA2BA,MAAM,aAAA,GAAgB,CAAC,SAA2B,KAAA;AAChD,EAAA,MAAM,CAAC,WAAW,CAAI,GAAAA,aAAA,CAAO,SAAS,CAAA;AACtC,EAAO,OAAA,WAAA,KAAgB,YAAY,WAAY,EAAA;AACjD,CAAA;AAEO,SAAS,KACd,SACA,EAAA,iBAAA,EACA,YACA,EAAA,GAAA,EACA,YACA,QACc,EAAA;AACd,EAAA,MAAM,EAAE,QAAU,EAAA,iBAAA,EAAmB,MAAM,aAAc,EAAA,GACvDC,mBAAS,SAAS,CAAA;AAEpB,EAAM,MAAA,qBAAA,GAAwBC,iBAAQ,CAAA,iBAAA,EAAmB,MAAM,CAAA;AAC/D,EAAA,MAAM,EAAE,GAAK,EAAA,SAAA,EAAc,GAAAC,kBAAA,CAAS,eAAe,qBAAqB,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;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;AAAA,KAEF,GAAA;AAAA,GACN;AAEJ,EAAA,OAAO,KAAM,CAAA,YAAA,CAAa,SAAW,EAAA,KAAA,CAAA,EAAW,QAAQ,CAAA;AAC1D;AAEA,SAAS,eACP,SACA,EAAA,iBAAA,EACA,mBACA,YACA,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, transparent);\n border-width: var(--vuuView-borderWidth, 1px);\n border-style: var(--vuuView-borderStyle, solid);\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 transition: flex-basis .3s ease-in-out;\n\n &.vuuHighlighted {\n --vuuView-borderStyle: dashed;\n --vuuView-borderColor: var(--salt-container-primary-borderColor);\n }\n}\n\n.vuuSplitterResizing .vuuView {\n transition: none;\n\n}\n\n.vuuView:has(> .vuuHeader){\n min-height: var(--vuuToolbarProxy-height);\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 {\n flex: 0 0 0 !important;\n}\n\n\n.vuuView-collapsed + .Splitter {\n display: none;\n}\n\n.vuuView-collapsed .Toolbar-vertical {\n border-right: solid 1px var(--grey40);\n}\n\n.vuuView-collapsed .Toolbar-vertical .toolbar-title {\n display: none;\n}\n";
4
+
5
+ module.exports = viewCss;
6
+ //# sourceMappingURL=View.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"View.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,160 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var vuuUtils = require('@vuu-ui/vuu-utils');
5
+ var core = require('@salt-ds/core');
6
+ var styles = require('@salt-ds/styles');
7
+ var window = require('@salt-ds/window');
8
+ var cx = require('clsx');
9
+ var React = require('react');
10
+ var Header = require('../layout-header/Header.js');
11
+ var useView = require('./useView.js');
12
+ var useViewResize = require('./useViewResize.js');
13
+ var ViewContext = require('../layout-view-actions/ViewContext.js');
14
+ var View$1 = require('./View.css.js');
15
+
16
+ const classBase = "vuuView";
17
+ const getProps = (state, props) => {
18
+ if (state && props) {
19
+ return {
20
+ ...state,
21
+ ...props
22
+ };
23
+ } else return state || props;
24
+ };
25
+ const View = React.forwardRef(function View2(props, forwardedRef) {
26
+ const {
27
+ Header: Header$1 = Header.Header,
28
+ allowRename,
29
+ children,
30
+ className,
31
+ collapsed,
32
+ closeable,
33
+ "data-path": dataPath,
34
+ "data-resizeable": dataResizeable,
35
+ dropTargets,
36
+ expanded,
37
+ flexFill,
38
+ id: idProp,
39
+ header,
40
+ onCollapse,
41
+ onExpand,
42
+ orientation = "horizontal",
43
+ path = dataPath,
44
+ resize = "responsive",
45
+ resizeable = dataResizeable,
46
+ restoreStyle,
47
+ tearOut,
48
+ style = {},
49
+ title: titleProp,
50
+ ...restProps
51
+ } = props;
52
+ const targetWindow = window.useWindow();
53
+ styles.useComponentCssInjection({
54
+ testId: "vuu-view",
55
+ css: View$1,
56
+ window: targetWindow
57
+ });
58
+ const id = vuuUtils.useId(idProp);
59
+ const rootRef = React.useRef(null);
60
+ const mainRef = React.useRef(null);
61
+ const [componentProps, _setComponentProps] = React.useState();
62
+ const {
63
+ contributions,
64
+ dispatchViewAction,
65
+ load,
66
+ onConfigChange,
67
+ onEditTitle,
68
+ purge,
69
+ restoredState,
70
+ save,
71
+ title
72
+ } = useView.useView({
73
+ id,
74
+ rootRef,
75
+ path,
76
+ dropTargets,
77
+ title: titleProp
78
+ });
79
+ useViewResize.useViewResize({ mainRef, resize, rootRef });
80
+ const setComponentProps = React.useCallback((props2) => {
81
+ _setComponentProps(props2);
82
+ }, []);
83
+ const getContent = () => {
84
+ if (React.isValidElement(children) && (restoredState || componentProps)) {
85
+ return React.cloneElement(
86
+ children,
87
+ getProps(restoredState, componentProps)
88
+ );
89
+ }
90
+ return children;
91
+ };
92
+ const viewContextValue = React.useMemo(
93
+ () => ({
94
+ dispatch: dispatchViewAction,
95
+ id,
96
+ path,
97
+ title,
98
+ load,
99
+ onConfigChange,
100
+ purge,
101
+ save,
102
+ setComponentProps
103
+ }),
104
+ [
105
+ dispatchViewAction,
106
+ id,
107
+ load,
108
+ onConfigChange,
109
+ path,
110
+ purge,
111
+ save,
112
+ setComponentProps,
113
+ title
114
+ ]
115
+ );
116
+ const headerProps = typeof header === "object" ? header : {};
117
+ return /* @__PURE__ */ jsxRuntime.jsx(
118
+ "div",
119
+ {
120
+ ...restProps,
121
+ className: cx(classBase, className, {
122
+ [`${classBase}-collapsed`]: collapsed,
123
+ [`${classBase}-expanded`]: expanded,
124
+ [`${classBase}-resize-defer`]: resize === "defer"
125
+ }),
126
+ "data-resizeable": resizeable,
127
+ id,
128
+ ref: core.useForkRef(forwardedRef, rootRef),
129
+ style,
130
+ tabIndex: -1,
131
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ViewContext.ViewContext.Provider, { value: viewContextValue, children: [
132
+ header ? /* @__PURE__ */ jsxRuntime.jsx(
133
+ Header$1,
134
+ {
135
+ ...headerProps,
136
+ allowRename,
137
+ collapsed,
138
+ contributions,
139
+ expanded,
140
+ closeable,
141
+ onCollapse,
142
+ onEditTitle,
143
+ onExpand,
144
+ orientation,
145
+ tearOut,
146
+ title
147
+ }
148
+ ) : null,
149
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase}-main`, ref: mainRef, children: getContent() })
150
+ ] })
151
+ }
152
+ );
153
+ });
154
+ View.displayName = "View";
155
+ const MemoView = React.memo(View);
156
+ MemoView.displayName = "View";
157
+ vuuUtils.registerComponent("View", MemoView, "view");
158
+
159
+ exports.View = MemoView;
160
+ //# sourceMappingURL=View.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"View.js","sources":["../../../../packages/vuu-layout/src/layout-view/View.tsx"],"sourcesContent":["import { registerComponent, 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 { useView } from \"./useView\";\nimport { useViewResize } from \"./useViewResize\";\nimport {\n ViewContext,\n ViewContextAPI,\n} from \"../layout-view-actions/ViewContext\";\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 allowRename,\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 onCollapse,\n onExpand,\n orientation = \"horizontal\",\n path = dataPath,\n resize = \"responsive\",\n resizeable = dataResizeable,\n restoreStyle,\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\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 onConfigChange,\n onEditTitle,\n purge,\n restoredState,\n save,\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 onConfigChange,\n purge,\n save,\n setComponentProps,\n }),\n [\n dispatchViewAction,\n id,\n load,\n onConfigChange,\n path,\n purge,\n save,\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 allowRename={allowRename}\n collapsed={collapsed}\n contributions={contributions}\n expanded={expanded}\n closeable={closeable}\n onCollapse={onCollapse}\n onEditTitle={onEditTitle}\n onExpand={onExpand}\n orientation={orientation}\n tearOut={tearOut}\n title={title}\n />\n ) : null}\n <div className={`${classBase}-main`} ref={mainRef}>\n {getContent()}\n </div>\n </ViewContext.Provider>\n </div>\n );\n});\nView.displayName = \"View\";\n\ninterface ViewComponentType {\n (\n props: ViewProps & {\n ref?: ForwardedRef<HTMLDivElement>;\n },\n ): ReactElement<ViewProps>;\n displayName?: string;\n}\n\nconst MemoView = React.memo(View) as ViewComponentType;\n\nMemoView.displayName = \"View\";\n\nregisterComponent(\"View\", MemoView, \"view\");\n\nexport { MemoView as View };\n"],"names":["forwardRef","View","Header","VuuHeader","useWindow","useComponentCssInjection","viewCss","useId","useRef","useState","useView","useViewResize","useCallback","props","useMemo","jsx","useForkRef","jsxs","ViewContext","registerComponent"],"mappings":";;;;;;;;;;;;;;;AAyBA,MAAM,SAAY,GAAA,SAAA;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;AAAA,KACL;AAAA,GACF,aAAc,KAAS,IAAA,KAAA;AACzB,CAAA;AAMA,MAAM,IAAO,GAAAA,gBAAA,CAAW,SAASC,KAAAA,CAC/B,OACA,YACA,EAAA;AACA,EAAM,MAAA;AAAA,YACJC,QAAS,GAAAC,aAAA;AAAA,IACT,WAAA;AAAA,IACA,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,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAc,GAAA,YAAA;AAAA,IACd,IAAO,GAAA,QAAA;AAAA,IACP,MAAS,GAAA,YAAA;AAAA,IACT,UAAa,GAAA,cAAA;AAAA,IACb,YAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAQ,EAAC;AAAA,IACT,KAAO,EAAA,SAAA;AAAA,IACP,GAAG;AAAA,GACD,GAAA,KAAA;AAEJ,EAAA,MAAM,eAAeC,gBAAU,EAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,UAAA;AAAA,IACR,GAAK,EAAAC,MAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CA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,SAAS,CAAS,KAAA,CAAA,EAAA,GAAA,EAAK,OACvC,EAAA,QAAA,EAAA,UAAA,EACH,EAAA;AAAA,OACF,EAAA;AAAA;AAAA,GACF;AAEJ,CAAC,CAAA;AACD,IAAA,CAAK,WAAc,GAAA,MAAA;AAWb,MAAA,QAAA,GAAW,KAAM,CAAA,IAAA,CAAK,IAAI;AAEhC,QAAA,CAAS,WAAc,GAAA,MAAA;AAEvBI,0BAAkB,CAAA,MAAA,EAAQ,UAAU,MAAM,CAAA;;;;"}
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var LayoutProvider = require('../layout-provider/LayoutProvider.js');
5
+ var usePersistentState = require('../use-persistent-state.js');
6
+ var useViewActionDispatcher = require('../layout-view-actions/useViewActionDispatcher.js');
7
+
8
+ const useView = ({
9
+ id,
10
+ rootRef,
11
+ path,
12
+ dropTargets,
13
+ title: titleProp
14
+ }) => {
15
+ const layoutDispatch = LayoutProvider.useLayoutProviderDispatch();
16
+ const { loadState, purgeState, saveState } = usePersistentState.usePersistentState();
17
+ const [dispatchViewAction, contributions] = useViewActionDispatcher.useViewActionDispatcher(
18
+ id,
19
+ rootRef,
20
+ path,
21
+ dropTargets
22
+ );
23
+ const title = React.useMemo(
24
+ () => loadState("view-title") ?? titleProp,
25
+ [loadState, titleProp]
26
+ );
27
+ const onEditTitle = React.useCallback(
28
+ (title2) => {
29
+ if (path) {
30
+ layoutDispatch({ type: "set-title", path, title: title2 });
31
+ }
32
+ },
33
+ [layoutDispatch, path]
34
+ );
35
+ const restoredState = React.useMemo(() => loadState(id), [id, loadState]);
36
+ const load = React.useCallback(
37
+ (key) => loadState(id, key),
38
+ [id, loadState]
39
+ );
40
+ const purge = React.useCallback(
41
+ (key) => {
42
+ purgeState(id, key);
43
+ layoutDispatch({ type: "save" });
44
+ },
45
+ [id, layoutDispatch, purgeState]
46
+ );
47
+ const save = React.useCallback(
48
+ (state, key) => {
49
+ saveState(id, key, state);
50
+ layoutDispatch({ type: "save" });
51
+ },
52
+ [id, layoutDispatch, saveState]
53
+ );
54
+ const onConfigChange = React.useCallback(
55
+ ({ type: key, ...config }) => {
56
+ const { [key]: data } = config;
57
+ save(data, key);
58
+ },
59
+ [save]
60
+ );
61
+ return {
62
+ contributions,
63
+ dispatchViewAction,
64
+ load,
65
+ onConfigChange,
66
+ onEditTitle,
67
+ purge,
68
+ restoredState,
69
+ save,
70
+ title
71
+ };
72
+ };
73
+
74
+ exports.useView = useView;
75
+ //# sourceMappingURL=useView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useView.js","sources":["../../../../packages/vuu-layout/src/layout-view/useView.tsx"],"sourcesContent":["import { RefObject, useCallback, useMemo } from \"react\";\nimport { useLayoutProviderDispatch } from \"../layout-provider/LayoutProvider\";\nimport { usePersistentState } from \"../use-persistent-state\";\nimport { useViewActionDispatcher } from \"../layout-view-actions/useViewActionDispatcher\";\nimport { ConfigChangeHandler } from \"../layout-view-actions/ViewContext\";\n\nexport interface ViewHookProps {\n id: string;\n rootRef: RefObject<HTMLDivElement | null>;\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 { loadState, purgeState, saveState } = 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: string) => {\n purgeState(id, key);\n layoutDispatch({ type: \"save\" });\n },\n [id, layoutDispatch, purgeState],\n );\n\n const save = useCallback(\n (state: unknown, key: string) => {\n saveState(id, key, state);\n layoutDispatch({ type: \"save\" });\n },\n [id, layoutDispatch, saveState],\n );\n\n const onConfigChange = useCallback<ConfigChangeHandler>(\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 onConfigChange,\n onEditTitle,\n purge,\n restoredState,\n save,\n title,\n };\n};\n"],"names":["useLayoutProviderDispatch","usePersistentState","useViewActionDispatcher","useMemo","useCallback","title"],"mappings":";;;;;;;AAcO,MAAM,UAAU,CAAC;AAAA,EACtB,EAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAO,EAAA;AACT,CAAqB,KAAA;AACnB,EAAA,MAAM,iBAAiBA,wCAA0B,EAAA;AAEjD,EAAA,MAAM,EAAE,SAAA,EAAW,UAAY,EAAA,SAAA,KAAcC,qCAAmB,EAAA;AAEhE,EAAM,MAAA,CAAC,kBAAoB,EAAA,aAAa,CAAI,GAAAC,+CAAA;AAAA,IAC1C,EAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,KAAQ,GAAAC,aAAA;AAAA,IACZ,MAAM,SAAU,CAAA,YAAY,CAAK,IAAA,SAAA;AAAA,IACjC,CAAC,WAAW,SAAS;AAAA,GACvB;AAEA,EAAA,MAAM,WAAc,GAAAC,iBAAA;AAAA,IAClB,CAACC,MAAkB,KAAA;AACjB,MAAA,IAAI,IAAM,EAAA;AACR,QAAA,cAAA,CAAe,EAAE,IAAM,EAAA,WAAA,EAAa,IAAM,EAAA,KAAA,EAAAA,QAAO,CAAA;AAAA;AACnD,KACF;AAAA,IACA,CAAC,gBAAgB,IAAI;AAAA,GACvB;AAEA,EAAM,MAAA,aAAA,GAAgBF,cAAQ,MAAM,SAAA,CAAU,EAAE,CAAG,EAAA,CAAC,EAAI,EAAA,SAAS,CAAC,CAAA;AAElE,EAAA,MAAM,IAAO,GAAAC,iBAAA;AAAA,IACX,CAAC,GAAA,KAAiB,SAAU,CAAA,EAAA,EAAI,GAAG,CAAA;AAAA,IACnC,CAAC,IAAI,SAAS;AAAA,GAChB;AAEA,EAAA,MAAM,KAAQ,GAAAA,iBAAA;AAAA,IACZ,CAAC,GAAgB,KAAA;AACf,MAAA,UAAA,CAAW,IAAI,GAAG,CAAA;AAClB,MAAe,cAAA,CAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,CAAA;AAAA,KACjC;AAAA,IACA,CAAC,EAAI,EAAA,cAAA,EAAgB,UAAU;AAAA,GACjC;AAEA,EAAA,MAAM,IAAO,GAAAA,iBAAA;AAAA,IACX,CAAC,OAAgB,GAAgB,KAAA;AAC/B,MAAU,SAAA,CAAA,EAAA,EAAI,KAAK,KAAK,CAAA;AACxB,MAAe,cAAA,CAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,CAAA;AAAA,KACjC;AAAA,IACA,CAAC,EAAI,EAAA,cAAA,EAAgB,SAAS;AAAA,GAChC;AAEA,EAAA,MAAM,cAAiB,GAAAA,iBAAA;AAAA,IACrB,CAAC,EAAE,IAAA,EAAM,GAAK,EAAA,GAAG,QAAa,KAAA;AAC5B,MAAA,MAAM,EAAE,CAAC,GAAG,GAAG,MAAS,GAAA,MAAA;AACxB,MAAA,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,KAChB;AAAA,IACA,CAAC,IAAI;AAAA,GACP;AAEA,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,kBAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const isMessageForSelf = (message, id, path) => {
6
+ if (id && message.targetId === id) {
7
+ return true;
8
+ } else if (message.path && path?.startsWith(message.path)) {
9
+ return true;
10
+ }
11
+ return false;
12
+ };
13
+ const useViewBroadcastChannel = (id, path, onMessageReceived) => {
14
+ const broadcastChannelRef = React.useRef(void 0);
15
+ React.useEffect(() => {
16
+ const broadcastChannel = new BroadcastChannel("vuu");
17
+ broadcastChannel.onmessage = (evt) => {
18
+ if (isMessageForSelf(evt.data, id, path)) {
19
+ onMessageReceived?.(evt.data);
20
+ }
21
+ };
22
+ broadcastChannelRef.current = broadcastChannel;
23
+ return () => {
24
+ broadcastChannel.close();
25
+ broadcastChannelRef.current = void 0;
26
+ };
27
+ }, [id, onMessageReceived, path]);
28
+ const sendMessage = React.useCallback((message) => {
29
+ broadcastChannelRef.current?.postMessage(message);
30
+ }, []);
31
+ return sendMessage;
32
+ };
33
+
34
+ exports.useViewBroadcastChannel = useViewBroadcastChannel;
35
+ //# sourceMappingURL=useViewBroadcastChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewBroadcastChannel.js","sources":["../../../../packages/vuu-layout/src/layout-view/useViewBroadcastChannel.ts"],"sourcesContent":["import { VuuBroadcastChannel } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useEffect, useRef } from \"react\";\n\nexport interface ViewBroadcastMessage {\n path?: string;\n targetId?: string;\n type: \"highlight-on\" | \"highlight-off\" | \"layout-closed\";\n}\n\nexport type BroadcastMessageHandler = (message: ViewBroadcastMessage) => void;\n\nconst isMessageForSelf = (\n message: ViewBroadcastMessage,\n id?: string,\n path?: string,\n) => {\n if (id && message.targetId === id) {\n return true;\n } else if (message.path && path?.startsWith(message.path)) {\n return true;\n }\n return false;\n};\n\nexport const useViewBroadcastChannel = (\n id?: string,\n path?: string,\n onMessageReceived?: BroadcastMessageHandler,\n) => {\n const broadcastChannelRef =\n useRef<VuuBroadcastChannel<ViewBroadcastMessage>>(undefined);\n\n useEffect(() => {\n const broadcastChannel: VuuBroadcastChannel<ViewBroadcastMessage> =\n new BroadcastChannel(\"vuu\");\n broadcastChannel.onmessage = (evt) => {\n if (isMessageForSelf(evt.data, id, path)) {\n onMessageReceived?.(evt.data);\n }\n };\n broadcastChannelRef.current = broadcastChannel;\n return () => {\n broadcastChannel.close();\n broadcastChannelRef.current = undefined;\n };\n }, [id, onMessageReceived, path]);\n\n const sendMessage = useCallback((message: ViewBroadcastMessage) => {\n broadcastChannelRef.current?.postMessage(message);\n }, []);\n\n return sendMessage;\n};\n"],"names":["useRef","useEffect","useCallback"],"mappings":";;;;AAWA,MAAM,gBAAmB,GAAA,CACvB,OACA,EAAA,EAAA,EACA,IACG,KAAA;AACH,EAAI,IAAA,EAAA,IAAM,OAAQ,CAAA,QAAA,KAAa,EAAI,EAAA;AACjC,IAAO,OAAA,IAAA;AAAA,aACE,OAAQ,CAAA,IAAA,IAAQ,MAAM,UAAW,CAAA,OAAA,CAAQ,IAAI,CAAG,EAAA;AACzD,IAAO,OAAA,IAAA;AAAA;AAET,EAAO,OAAA,KAAA;AACT,CAAA;AAEO,MAAM,uBAA0B,GAAA,CACrC,EACA,EAAA,IAAA,EACA,iBACG,KAAA;AACH,EAAM,MAAA,mBAAA,GACJA,aAAkD,KAAS,CAAA,CAAA;AAE7D,EAAAC,eAAA,CAAU,MAAM;AACd,IAAM,MAAA,gBAAA,GACJ,IAAI,gBAAA,CAAiB,KAAK,CAAA;AAC5B,IAAiB,gBAAA,CAAA,SAAA,GAAY,CAAC,GAAQ,KAAA;AACpC,MAAA,IAAI,gBAAiB,CAAA,GAAA,CAAI,IAAM,EAAA,EAAA,EAAI,IAAI,CAAG,EAAA;AACxC,QAAA,iBAAA,GAAoB,IAAI,IAAI,CAAA;AAAA;AAC9B,KACF;AACA,IAAA,mBAAA,CAAoB,OAAU,GAAA,gBAAA;AAC9B,IAAA,OAAO,MAAM;AACX,MAAA,gBAAA,CAAiB,KAAM,EAAA;AACvB,MAAA,mBAAA,CAAoB,OAAU,GAAA,KAAA,CAAA;AAAA,KAChC;AAAA,GACC,EAAA,CAAC,EAAI,EAAA,iBAAA,EAAmB,IAAI,CAAC,CAAA;AAEhC,EAAM,MAAA,WAAA,GAAcC,iBAAY,CAAA,CAAC,OAAkC,KAAA;AACjE,IAAoB,mBAAA,CAAA,OAAA,EAAS,YAAY,OAAO,CAAA;AAAA,GAClD,EAAG,EAAE,CAAA;AAEL,EAAO,OAAA,WAAA;AACT;;;;"}
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var useResizeObserver = require('../responsive/useResizeObserver.js');
4
+ var React = require('react');
5
+
6
+ const NO_MEASUREMENT = [];
7
+ const useViewResize = ({
8
+ mainRef,
9
+ resize = "responsive",
10
+ rootRef
11
+ }) => {
12
+ const deferResize = resize === "defer";
13
+ const mainSize = React.useRef({});
14
+ const resizeHandle = React.useRef(void 0);
15
+ const setMainSize = React.useCallback(() => {
16
+ if (mainRef.current) {
17
+ mainRef.current.style.height = mainSize.current.height + "px";
18
+ mainRef.current.style.width = mainSize.current.width + "px";
19
+ }
20
+ resizeHandle.current = void 0;
21
+ }, [mainRef]);
22
+ const onResize = React.useCallback(
23
+ ({ height, width }) => {
24
+ mainSize.current.height = height;
25
+ mainSize.current.width = width;
26
+ if (resizeHandle.current !== null) {
27
+ clearTimeout(resizeHandle.current);
28
+ }
29
+ resizeHandle.current = window.setTimeout(setMainSize, 40);
30
+ },
31
+ [setMainSize]
32
+ );
33
+ useResizeObserver.useResizeObserver(
34
+ rootRef,
35
+ deferResize ? useResizeObserver.WidthHeight : NO_MEASUREMENT,
36
+ onResize,
37
+ deferResize
38
+ );
39
+ };
40
+
41
+ exports.useViewResize = useViewResize;
42
+ //# sourceMappingURL=useViewResize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewResize.js","sources":["../../../../packages/vuu-layout/src/layout-view/useViewResize.ts"],"sourcesContent":["import { ResizeHandler } from \"@vuu-ui/vuu-ui-controls\";\nimport { 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 | null>;\n resize?: \"defer\" | \"responsive\";\n rootRef: RefObject<HTMLDivElement | null>;\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>(undefined);\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<ResizeHandler>(\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":["useRef","useCallback","useResizeObserver","WidthHeight"],"mappings":";;;;;AAIA,MAAM,iBAA2B,EAAC;AAa3B,MAAM,gBAAgB,CAAC;AAAA,EAC5B,OAAA;AAAA,EACA,MAAS,GAAA,YAAA;AAAA,EACT;AACF,CAA2B,KAAA;AACzB,EAAA,MAAM,cAAc,MAAW,KAAA,OAAA;AAE/B,EAAM,MAAA,QAAA,GAAWA,YAAa,CAAA,EAAE,CAAA;AAChC,EAAM,MAAA,YAAA,GAAeA,aAAe,KAAS,CAAA,CAAA;AAE7C,EAAM,MAAA,WAAA,GAAcC,kBAAY,MAAM;AACpC,IAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,MAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,CAAM,MAAS,GAAA,QAAA,CAAS,QAAQ,MAAS,GAAA,IAAA;AACzD,MAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,CAAM,KAAQ,GAAA,QAAA,CAAS,QAAQ,KAAQ,GAAA,IAAA;AAAA;AAEzD,IAAA,YAAA,CAAa,OAAU,GAAA,KAAA,CAAA;AAAA,GACzB,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,MAAM,QAAW,GAAAA,iBAAA;AAAA,IACf,CAAC,EAAE,MAAQ,EAAA,KAAA,EAAY,KAAA;AACrB,MAAA,QAAA,CAAS,QAAQ,MAAS,GAAA,MAAA;AAC1B,MAAA,QAAA,CAAS,QAAQ,KAAQ,GAAA,KAAA;AACzB,MAAI,IAAA,YAAA,CAAa,YAAY,IAAM,EAAA;AACjC,QAAA,YAAA,CAAa,aAAa,OAAO,CAAA;AAAA;AAEnC,MAAA,YAAA,CAAa,OAAU,GAAA,MAAA,CAAO,UAAW,CAAA,WAAA,EAAa,EAAE,CAAA;AAAA,KAC1D;AAAA,IACA,CAAC,WAAW;AAAA,GACd;AAEA,EAAAC,mCAAA;AAAA,IACE,OAAA;AAAA,IACA,cAAcC,6BAAc,GAAA,cAAA;AAAA,IAC5B,QAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const NO_CONTEXT = { dispatch: null };
6
+ const ViewContext = React.createContext(NO_CONTEXT);
7
+ const useViewDispatch = () => {
8
+ const context = React.useContext(ViewContext);
9
+ return context?.dispatch ?? null;
10
+ };
11
+ const useViewContext = () => React.useContext(ViewContext);
12
+
13
+ exports.ViewContext = ViewContext;
14
+ exports.useViewContext = useViewContext;
15
+ exports.useViewDispatch = useViewDispatch;
16
+ //# sourceMappingURL=ViewContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewContext.js","sources":["../../../../packages/vuu-layout/src/layout-view-actions/ViewContext.ts"],"sourcesContent":["import React, { SyntheticEvent, useContext } from \"react\";\nimport { ViewAction } from \"../layout-view/viewTypes\";\n\nexport type QueryResponse = { [key: string]: unknown };\n\nexport type ConfigChangeHandler = (config: {\n [key: string]: unknown;\n type: string;\n}) => void;\n\nexport type ViewDispatch = <Action extends ViewAction = ViewAction>(\n action: Action,\n evt?: SyntheticEvent,\n) => Promise<boolean | QueryResponse | void>;\n\n/**\n * This API is available to any Feature hosted within Vuu (as all Features are wrapped\n * with View component). It offers metadata about the View as well as access to the\n * Vuu persistencew API;\n */\nexport interface ViewContextAPI {\n /**\n * dispatcher for View actions. These are a subset of LayoutActions, specifically for\n * View manipulation\n */\n dispatch?: ViewDispatch | null;\n id?: string;\n load?: <T = unknown>(key?: string) => T;\n onConfigChange?: ConfigChangeHandler;\n path?: string;\n purge?: (key: string) => void;\n save?: (state: unknown, key: string) => void;\n setComponentProps: (props: { [key: string]: unknown }) => void;\n title?: string;\n}\n\nconst NO_CONTEXT = { dispatch: null } as ViewContextAPI;\nexport const ViewContext = React.createContext<ViewContextAPI>(NO_CONTEXT);\n\nexport const useViewDispatch = () => {\n const context = useContext(ViewContext);\n return context?.dispatch ?? null;\n};\n\nexport const useViewContext = () => useContext(ViewContext);\n"],"names":["useContext"],"mappings":";;;;AAoCA,MAAM,UAAA,GAAa,EAAE,QAAA,EAAU,IAAK,EAAA;AACvB,MAAA,WAAA,GAAc,KAAM,CAAA,aAAA,CAA8B,UAAU;AAElE,MAAM,kBAAkB,MAAM;AACnC,EAAM,MAAA,OAAA,GAAUA,iBAAW,WAAW,CAAA;AACtC,EAAA,OAAO,SAAS,QAAY,IAAA,IAAA;AAC9B;AAEa,MAAA,cAAA,GAAiB,MAAMA,gBAAA,CAAW,WAAW;;;;;;"}
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ var vuuDataReact = require('@vuu-ui/vuu-data-react');
4
+ var React = require('react');
5
+ var LayoutProvider = require('../layout-provider/LayoutProvider.js');
6
+ var useViewBroadcastChannel = require('../layout-view/useViewBroadcastChannel.js');
7
+ var usePersistentState = require('../use-persistent-state.js');
8
+ var useViewContributions = require('./useViewContributions.js');
9
+
10
+ const useViewActionDispatcher = (id, rootRef, viewPath, dropTargets) => {
11
+ const { purgeState } = usePersistentState.usePersistentState();
12
+ const { clearDataSource: clearDataSourceFromSessionState } = vuuDataReact.useSessionDataSource();
13
+ const { clearContributions, contributions, updateContributions } = useViewContributions.useViewContributions({ sessionKey: id });
14
+ const dispatchLayoutAction = LayoutProvider.useLayoutProviderDispatch();
15
+ const unsubscribeAndClearState = React.useCallback(() => {
16
+ clearDataSourceFromSessionState(id, true);
17
+ purgeState(id);
18
+ }, [clearDataSourceFromSessionState, id, purgeState]);
19
+ const handleRemove = React.useCallback(() => {
20
+ unsubscribeAndClearState();
21
+ dispatchLayoutAction({ type: "remove", path: viewPath });
22
+ }, [unsubscribeAndClearState, dispatchLayoutAction, viewPath]);
23
+ const handleMouseDown = React.useCallback(
24
+ async (evt, index, preDragActivity) => {
25
+ evt.stopPropagation();
26
+ const dragRect = rootRef.current?.getBoundingClientRect();
27
+ return new Promise((resolve, reject) => {
28
+ dispatchLayoutAction({
29
+ type: "drag-start",
30
+ evt,
31
+ path: index === void 0 ? viewPath : `${viewPath}.${index}`,
32
+ dragRect,
33
+ preDragActivity,
34
+ dropTargets,
35
+ resolveDragStart: resolve,
36
+ rejectDragStart: reject
37
+ });
38
+ });
39
+ },
40
+ [rootRef, dispatchLayoutAction, viewPath, dropTargets]
41
+ );
42
+ const handleMessageReceived = React.useCallback(
43
+ (message) => {
44
+ switch (message.type) {
45
+ case "highlight-on":
46
+ rootRef?.current?.classList.add("vuuHighlighted");
47
+ break;
48
+ case "highlight-off":
49
+ rootRef?.current?.classList.remove("vuuHighlighted");
50
+ break;
51
+ case "layout-closed":
52
+ unsubscribeAndClearState();
53
+ break;
54
+ default:
55
+ console.log(`received ${message.type} message`);
56
+ }
57
+ },
58
+ [rootRef, unsubscribeAndClearState]
59
+ );
60
+ const sendMessage = useViewBroadcastChannel.useViewBroadcastChannel(
61
+ id,
62
+ viewPath,
63
+ handleMessageReceived
64
+ );
65
+ const dispatchAction = React.useCallback(
66
+ async (action, evt) => {
67
+ const { type } = action;
68
+ switch (type) {
69
+ case "collapse":
70
+ case "expand":
71
+ return dispatchLayoutAction({ type, path: action.path ?? viewPath });
72
+ case "remove":
73
+ return handleRemove();
74
+ case "mousedown":
75
+ return handleMouseDown(
76
+ evt,
77
+ action.index,
78
+ action.preDragActivity
79
+ );
80
+ case "add-toolbar-contribution":
81
+ return updateContributions(action.location, action.content);
82
+ case "remove-toolbar-contribution":
83
+ return clearContributions();
84
+ case "query":
85
+ return dispatchLayoutAction({
86
+ type,
87
+ path: action.path,
88
+ query: action.query
89
+ });
90
+ case "broadcast-message":
91
+ sendMessage(action.message);
92
+ break;
93
+ default: {
94
+ return void 0;
95
+ }
96
+ }
97
+ },
98
+ [
99
+ dispatchLayoutAction,
100
+ viewPath,
101
+ handleRemove,
102
+ handleMouseDown,
103
+ updateContributions,
104
+ clearContributions,
105
+ sendMessage
106
+ ]
107
+ );
108
+ return [dispatchAction, contributions];
109
+ };
110
+
111
+ exports.useViewActionDispatcher = useViewActionDispatcher;
112
+ //# sourceMappingURL=useViewActionDispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewActionDispatcher.js","sources":["../../../../packages/vuu-layout/src/layout-view-actions/useViewActionDispatcher.ts"],"sourcesContent":["import { useSessionDataSource } from \"@vuu-ui/vuu-data-react\";\nimport { RefObject, SyntheticEvent, useCallback } from \"react\";\nimport { useLayoutProviderDispatch } from \"../layout-provider/LayoutProvider\";\nimport { DragStartAction } from \"../layout-reducer\";\nimport {\n BroadcastMessageHandler,\n useViewBroadcastChannel,\n} from \"../layout-view/useViewBroadcastChannel\";\nimport { usePersistentState } from \"../use-persistent-state\";\nimport { useViewContributions } from \"./useViewContributions\";\nimport { QueryResponse, ViewDispatch } from \"./ViewContext\";\nimport { Contribution, ViewAction } from \"../layout-view/viewTypes\";\n\nexport const useViewActionDispatcher = (\n id: string,\n rootRef: RefObject<HTMLDivElement | null>,\n viewPath?: string,\n dropTargets?: string[],\n): [ViewDispatch, Contribution[] | undefined] => {\n const { purgeState } = usePersistentState();\n\n const { clearDataSource: clearDataSourceFromSessionState } =\n useSessionDataSource();\n\n const { clearContributions, contributions, updateContributions } =\n useViewContributions({ sessionKey: id });\n\n const dispatchLayoutAction = useLayoutProviderDispatch();\n\n // This assumes datasource has been stored in session state\n // we should extend to accommodate multiple dataSources\n const unsubscribeAndClearState = useCallback(() => {\n clearDataSourceFromSessionState(id, true);\n purgeState(id);\n }, [clearDataSourceFromSessionState, id, purgeState]);\n\n const handleRemove = useCallback(() => {\n unsubscribeAndClearState();\n dispatchLayoutAction({ type: \"remove\", path: viewPath });\n }, [unsubscribeAndClearState, dispatchLayoutAction, viewPath]);\n\n const handleMouseDown = useCallback(\n async (\n evt: MouseEvent,\n index: number,\n preDragActivity: unknown,\n ): Promise<boolean> => {\n evt.stopPropagation();\n const dragRect = rootRef.current?.getBoundingClientRect();\n return new Promise((resolve, reject) => {\n dispatchLayoutAction({\n type: \"drag-start\",\n evt,\n path: index === undefined ? viewPath : `${viewPath}.${index}`,\n dragRect,\n preDragActivity,\n dropTargets,\n resolveDragStart: resolve,\n rejectDragStart: reject,\n } as DragStartAction);\n });\n },\n [rootRef, dispatchLayoutAction, viewPath, dropTargets],\n );\n\n const handleMessageReceived = useCallback<BroadcastMessageHandler>(\n (message) => {\n switch (message.type) {\n case \"highlight-on\":\n rootRef?.current?.classList.add(\"vuuHighlighted\");\n break;\n case \"highlight-off\":\n rootRef?.current?.classList.remove(\"vuuHighlighted\");\n break;\n case \"layout-closed\":\n unsubscribeAndClearState();\n break;\n default:\n console.log(`received ${message.type} message`);\n }\n },\n [rootRef, unsubscribeAndClearState],\n );\n\n const sendMessage = useViewBroadcastChannel(\n id,\n viewPath,\n handleMessageReceived,\n );\n\n const dispatchAction = useCallback(\n async <A extends ViewAction = ViewAction>(\n action: A,\n evt?: MouseEvent | SyntheticEvent,\n ): Promise<boolean | QueryResponse | void> => {\n const { type } = action;\n switch (type) {\n case \"collapse\":\n case \"expand\":\n return dispatchLayoutAction({ type, path: action.path ?? viewPath });\n case \"remove\":\n return handleRemove();\n case \"mousedown\":\n // TODO fix types\n return handleMouseDown(\n evt as MouseEvent,\n action.index as number,\n action.preDragActivity,\n );\n case \"add-toolbar-contribution\":\n return updateContributions(action.location, action.content);\n case \"remove-toolbar-contribution\":\n return clearContributions();\n case \"query\":\n return dispatchLayoutAction({\n type,\n path: action.path,\n query: action.query,\n });\n case \"broadcast-message\":\n sendMessage(action.message);\n break;\n\n default: {\n return undefined;\n }\n }\n },\n [\n dispatchLayoutAction,\n viewPath,\n handleRemove,\n handleMouseDown,\n updateContributions,\n clearContributions,\n sendMessage,\n ],\n );\n\n return [dispatchAction, contributions];\n};\n"],"names":["usePersistentState","useSessionDataSource","useViewContributions","useLayoutProviderDispatch","useCallback","useViewBroadcastChannel"],"mappings":";;;;;;;;;AAaO,MAAM,uBAA0B,GAAA,CACrC,EACA,EAAA,OAAA,EACA,UACA,WAC+C,KAAA;AAC/C,EAAM,MAAA,EAAE,UAAW,EAAA,GAAIA,qCAAmB,EAAA;AAE1C,EAAA,MAAM,EAAE,eAAA,EAAiB,+BAAgC,EAAA,GACvDC,iCAAqB,EAAA;AAEvB,EAAM,MAAA,EAAE,oBAAoB,aAAe,EAAA,mBAAA,KACzCC,yCAAqB,CAAA,EAAE,UAAY,EAAA,EAAA,EAAI,CAAA;AAEzC,EAAA,MAAM,uBAAuBC,wCAA0B,EAAA;AAIvD,EAAM,MAAA,wBAAA,GAA2BC,kBAAY,MAAM;AACjD,IAAA,+BAAA,CAAgC,IAAI,IAAI,CAAA;AACxC,IAAA,UAAA,CAAW,EAAE,CAAA;AAAA,GACZ,EAAA,CAAC,+BAAiC,EAAA,EAAA,EAAI,UAAU,CAAC,CAAA;AAEpD,EAAM,MAAA,YAAA,GAAeA,kBAAY,MAAM;AACrC,IAAyB,wBAAA,EAAA;AACzB,IAAA,oBAAA,CAAqB,EAAE,IAAA,EAA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A;AAAA;AACF,GACF;AAEA,EAAO,OAAA,CAAC,gBAAgB,aAAa,CAAA;AACvC;;;;"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const sessionState = /* @__PURE__ */ new Map();
6
+ const EMPTY_ARRAY = [];
7
+ const useViewContributions = ({
8
+ sessionKey
9
+ }) => {
10
+ const [contributions, setContributions] = React.useState(EMPTY_ARRAY);
11
+ const updateContributions = React.useCallback(
12
+ (location, content) => {
13
+ const updatedContributions = contributions.concat([
14
+ { location, content }
15
+ ]);
16
+ sessionState.set(sessionKey, updatedContributions);
17
+ setContributions(updatedContributions);
18
+ },
19
+ [contributions, sessionKey]
20
+ );
21
+ const clearContributions = React.useCallback(() => {
22
+ sessionState.delete(sessionKey);
23
+ setContributions([]);
24
+ }, [sessionKey]);
25
+ return {
26
+ clearContributions,
27
+ contributions,
28
+ updateContributions
29
+ };
30
+ };
31
+
32
+ exports.useViewContributions = useViewContributions;
33
+ //# sourceMappingURL=useViewContributions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewContributions.js","sources":["../../../../packages/vuu-layout/src/layout-view-actions/useViewContributions.ts"],"sourcesContent":["import { ReactElement, useCallback, useState } from \"react\";\nimport type {\n Contribution,\n ContributionLocation,\n} from \"../layout-view/viewTypes\";\n\nconst sessionState = new Map<string, Contribution[]>();\n\nconst EMPTY_ARRAY: Contribution[] = [];\n\nexport const useViewContributions = ({\n sessionKey,\n}: {\n sessionKey: string;\n}) => {\n const [contributions, setContributions] =\n useState<Contribution[]>(EMPTY_ARRAY);\n\n const updateContributions = useCallback(\n (location: ContributionLocation, content: ReactElement) => {\n const updatedContributions = contributions.concat([\n { location, content },\n ]);\n sessionState.set(sessionKey, updatedContributions);\n setContributions(updatedContributions);\n },\n [contributions, sessionKey],\n );\n\n const clearContributions = useCallback(() => {\n sessionState.delete(sessionKey);\n setContributions([]);\n }, [sessionKey]);\n\n return {\n clearContributions,\n contributions,\n updateContributions,\n };\n};\n"],"names":["useState","useCallback"],"mappings":";;;;AAMA,MAAM,YAAA,uBAAmB,GAA4B,EAAA;AAErD,MAAM,cAA8B,EAAC;AAE9B,MAAM,uBAAuB,CAAC;AAAA,EACnC;AACF,CAEM,KAAA;AACJ,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GACpCA,eAAyB,WAAW,CAAA;AAEtC,EAAA,MAAM,mBAAsB,GAAAC,iBAAA;AAAA,IAC1B,CAAC,UAAgC,OAA0B,KAAA;AACzD,MAAM,MAAA,oBAAA,GAAuB,cAAc,MAAO,CAAA;AAAA,QAChD,EAAE,UAAU,OAAQ;AAAA,OACrB,CAAA;AACD,MAAa,YAAA,CAAA,GAAA,CAAI,YAAY,oBAAoB,CAAA;AACjD,MAAA,gBAAA,CAAiB,oBAAoB,CAAA;AAAA,KACvC;AAAA,IACA,CAAC,eAAe,UAAU;AAAA,GAC5B;AAEA,EAAM,MAAA,kBAAA,GAAqBA,kBAAY,MAAM;AAC3C,IAAA,YAAA,CAAa,OAAO,UAAU,CAAA;AAC9B,IAAA,gBAAA,CAAiB,EAAE,CAAA;AAAA,GACrB,EAAG,CAAC,UAAU,CAAC,CAAA;AAEf,EAAO,OAAA;AAAA,IACL,kBAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ var paletteCss = ".vuuPalette {\n --vuuList-borderStyle: none;\n}\n\n.vuuPalette-horizontal {\n align-items: center;\n display: flex;\n}\n\n.vuuPaletteItem {\n --vuu-icon-color: var(--salt-content-secondary-foreground);\n --list-item-text-padding: 0 0 0 calc(var(--salt-size-unit) * 3);\n font-size: 12px;\n font-weight: 600;\n gap: var(--salt-spacing-200);\n padding-left: 12px;\n}\n\n.vuuSimpleDraggableWrapper > .vuuPaletteItem {\n --vuu-icon-color: var(--salt-selectable-foreground);\n}\n\n.salt-theme .vuuPaletteItem {\n font-size: 11px;\n font-weight: normal;\n}\n";
4
+
5
+ module.exports = paletteCss;
6
+ //# sourceMappingURL=Palette.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Palette.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}