@vuu-ui/vuu-layout 0.8.34 → 0.8.35

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 (248) hide show
  1. package/package.json +8 -10
  2. package/cjs/Component.js +0 -14
  3. package/cjs/Component.js.map +0 -1
  4. package/cjs/DraggableLayout.css +0 -18
  5. package/cjs/DraggableLayout.js +0 -24
  6. package/cjs/DraggableLayout.js.map +0 -1
  7. package/cjs/dock-layout/DockLayout.css +0 -36
  8. package/cjs/dock-layout/DockLayout.js +0 -27
  9. package/cjs/dock-layout/DockLayout.js.map +0 -1
  10. package/cjs/dock-layout/Drawer.css +0 -159
  11. package/cjs/dock-layout/Drawer.js +0 -87
  12. package/cjs/dock-layout/Drawer.js.map +0 -1
  13. package/cjs/drag-drop/BoxModel.js +0 -422
  14. package/cjs/drag-drop/BoxModel.js.map +0 -1
  15. package/cjs/drag-drop/DragState.js +0 -154
  16. package/cjs/drag-drop/DragState.js.map +0 -1
  17. package/cjs/drag-drop/Draggable.js +0 -192
  18. package/cjs/drag-drop/Draggable.js.map +0 -1
  19. package/cjs/drag-drop/DropMenu.css +0 -71
  20. package/cjs/drag-drop/DropMenu.js +0 -46
  21. package/cjs/drag-drop/DropMenu.js.map +0 -1
  22. package/cjs/drag-drop/DropTarget.js +0 -244
  23. package/cjs/drag-drop/DropTarget.js.map +0 -1
  24. package/cjs/drag-drop/DropTargetRenderer.css +0 -40
  25. package/cjs/drag-drop/DropTargetRenderer.js +0 -233
  26. package/cjs/drag-drop/DropTargetRenderer.js.map +0 -1
  27. package/cjs/flexbox/Flexbox.css +0 -45
  28. package/cjs/flexbox/Flexbox.js +0 -61
  29. package/cjs/flexbox/Flexbox.js.map +0 -1
  30. package/cjs/flexbox/FlexboxLayout.js +0 -30
  31. package/cjs/flexbox/FlexboxLayout.js.map +0 -1
  32. package/cjs/flexbox/FluidGrid.css +0 -134
  33. package/cjs/flexbox/FluidGrid.js +0 -78
  34. package/cjs/flexbox/FluidGrid.js.map +0 -1
  35. package/cjs/flexbox/FluidGridLayout.js +0 -14
  36. package/cjs/flexbox/FluidGridLayout.js.map +0 -1
  37. package/cjs/flexbox/Splitter.css +0 -148
  38. package/cjs/flexbox/Splitter.js +0 -113
  39. package/cjs/flexbox/Splitter.js.map +0 -1
  40. package/cjs/flexbox/flexbox-utils.js +0 -109
  41. package/cjs/flexbox/flexbox-utils.js.map +0 -1
  42. package/cjs/flexbox/useResponsiveSizing.js +0 -62
  43. package/cjs/flexbox/useResponsiveSizing.js.map +0 -1
  44. package/cjs/flexbox/useSplitterResizing.js +0 -209
  45. package/cjs/flexbox/useSplitterResizing.js.map +0 -1
  46. package/cjs/index.js.map +0 -1
  47. package/cjs/layout-action.js +0 -27
  48. package/cjs/layout-action.js.map +0 -1
  49. package/cjs/layout-header/Header.css +0 -9
  50. package/cjs/layout-header/Header.js +0 -122
  51. package/cjs/layout-header/Header.js.map +0 -1
  52. package/cjs/layout-provider/LayoutProvider.js +0 -178
  53. package/cjs/layout-provider/LayoutProvider.js.map +0 -1
  54. package/cjs/layout-provider/LayoutProviderContext.js +0 -14
  55. package/cjs/layout-provider/LayoutProviderContext.js.map +0 -1
  56. package/cjs/layout-provider/useLayoutDragDrop.js +0 -170
  57. package/cjs/layout-provider/useLayoutDragDrop.js.map +0 -1
  58. package/cjs/layout-reducer/flexUtils.js +0 -219
  59. package/cjs/layout-reducer/flexUtils.js.map +0 -1
  60. package/cjs/layout-reducer/insert-layout-element.js +0 -273
  61. package/cjs/layout-reducer/insert-layout-element.js.map +0 -1
  62. package/cjs/layout-reducer/layout-reducer.js +0 -198
  63. package/cjs/layout-reducer/layout-reducer.js.map +0 -1
  64. package/cjs/layout-reducer/layoutTypes.js +0 -41
  65. package/cjs/layout-reducer/layoutTypes.js.map +0 -1
  66. package/cjs/layout-reducer/layoutUtils.js +0 -226
  67. package/cjs/layout-reducer/layoutUtils.js.map +0 -1
  68. package/cjs/layout-reducer/move-layout-element.js +0 -31
  69. package/cjs/layout-reducer/move-layout-element.js.map +0 -1
  70. package/cjs/layout-reducer/remove-layout-element.js +0 -223
  71. package/cjs/layout-reducer/remove-layout-element.js.map +0 -1
  72. package/cjs/layout-reducer/replace-layout-element.js +0 -91
  73. package/cjs/layout-reducer/replace-layout-element.js.map +0 -1
  74. package/cjs/layout-reducer/resize-flex-children.js +0 -61
  75. package/cjs/layout-reducer/resize-flex-children.js.map +0 -1
  76. package/cjs/layout-reducer/wrap-layout-element.js +0 -212
  77. package/cjs/layout-reducer/wrap-layout-element.js.map +0 -1
  78. package/cjs/layout-view/View.css +0 -62
  79. package/cjs/layout-view/View.js +0 -155
  80. package/cjs/layout-view/View.js.map +0 -1
  81. package/cjs/layout-view/useView.js +0 -92
  82. package/cjs/layout-view/useView.js.map +0 -1
  83. package/cjs/layout-view/useViewResize.js +0 -42
  84. package/cjs/layout-view/useViewResize.js.map +0 -1
  85. package/cjs/layout-view-actions/ViewContext.js +0 -16
  86. package/cjs/layout-view-actions/ViewContext.js.map +0 -1
  87. package/cjs/layout-view-actions/useViewActionDispatcher.js +0 -103
  88. package/cjs/layout-view-actions/useViewActionDispatcher.js.map +0 -1
  89. package/cjs/palette/Palette.css +0 -33
  90. package/cjs/palette/Palette.js +0 -118
  91. package/cjs/palette/Palette.js.map +0 -1
  92. package/cjs/placeholder/LayoutStartPanel.css +0 -30
  93. package/cjs/placeholder/LayoutStartPanel.js +0 -51
  94. package/cjs/placeholder/LayoutStartPanel.js.map +0 -1
  95. package/cjs/placeholder/Placeholder.css +0 -17
  96. package/cjs/placeholder/Placeholder.js +0 -25
  97. package/cjs/placeholder/Placeholder.js.map +0 -1
  98. package/cjs/registry/ComponentRegistry.js +0 -27
  99. package/cjs/registry/ComponentRegistry.js.map +0 -1
  100. package/cjs/responsive/breakpoints.js +0 -36
  101. package/cjs/responsive/breakpoints.js.map +0 -1
  102. package/cjs/responsive/use-breakpoints.js +0 -76
  103. package/cjs/responsive/use-breakpoints.js.map +0 -1
  104. package/cjs/responsive/useResizeObserver.js +0 -118
  105. package/cjs/responsive/useResizeObserver.js.map +0 -1
  106. package/cjs/responsive/utils.js +0 -34
  107. package/cjs/responsive/utils.js.map +0 -1
  108. package/cjs/stack/Stack.css +0 -39
  109. package/cjs/stack/Stack.js +0 -139
  110. package/cjs/stack/Stack.js.map +0 -1
  111. package/cjs/stack/StackLayout.js +0 -122
  112. package/cjs/stack/StackLayout.js.map +0 -1
  113. package/cjs/use-persistent-state.js +0 -109
  114. package/cjs/use-persistent-state.js.map +0 -1
  115. package/cjs/utils/pathUtils.js +0 -293
  116. package/cjs/utils/pathUtils.js.map +0 -1
  117. package/cjs/utils/propUtils.js +0 -27
  118. package/cjs/utils/propUtils.js.map +0 -1
  119. package/cjs/utils/refUtils.js +0 -12
  120. package/cjs/utils/refUtils.js.map +0 -1
  121. package/cjs/utils/styleUtils.js +0 -15
  122. package/cjs/utils/styleUtils.js.map +0 -1
  123. package/cjs/utils/typeOf.js +0 -27
  124. package/cjs/utils/typeOf.js.map +0 -1
  125. package/esm/Component.js +0 -12
  126. package/esm/Component.js.map +0 -1
  127. package/esm/DraggableLayout.css +0 -18
  128. package/esm/DraggableLayout.js +0 -22
  129. package/esm/DraggableLayout.js.map +0 -1
  130. package/esm/dock-layout/DockLayout.css +0 -36
  131. package/esm/dock-layout/DockLayout.js +0 -25
  132. package/esm/dock-layout/DockLayout.js.map +0 -1
  133. package/esm/dock-layout/Drawer.css +0 -159
  134. package/esm/dock-layout/Drawer.js +0 -85
  135. package/esm/dock-layout/Drawer.js.map +0 -1
  136. package/esm/drag-drop/BoxModel.js +0 -415
  137. package/esm/drag-drop/BoxModel.js.map +0 -1
  138. package/esm/drag-drop/DragState.js +0 -152
  139. package/esm/drag-drop/DragState.js.map +0 -1
  140. package/esm/drag-drop/Draggable.js +0 -190
  141. package/esm/drag-drop/Draggable.js.map +0 -1
  142. package/esm/drag-drop/DropMenu.css +0 -71
  143. package/esm/drag-drop/DropMenu.js +0 -43
  144. package/esm/drag-drop/DropMenu.js.map +0 -1
  145. package/esm/drag-drop/DropTarget.js +0 -240
  146. package/esm/drag-drop/DropTarget.js.map +0 -1
  147. package/esm/drag-drop/DropTargetRenderer.css +0 -40
  148. package/esm/drag-drop/DropTargetRenderer.js +0 -231
  149. package/esm/drag-drop/DropTargetRenderer.js.map +0 -1
  150. package/esm/flexbox/Flexbox.css +0 -45
  151. package/esm/flexbox/Flexbox.js +0 -59
  152. package/esm/flexbox/Flexbox.js.map +0 -1
  153. package/esm/flexbox/FlexboxLayout.js +0 -28
  154. package/esm/flexbox/FlexboxLayout.js.map +0 -1
  155. package/esm/flexbox/FluidGrid.css +0 -134
  156. package/esm/flexbox/FluidGrid.js +0 -76
  157. package/esm/flexbox/FluidGrid.js.map +0 -1
  158. package/esm/flexbox/FluidGridLayout.js +0 -12
  159. package/esm/flexbox/FluidGridLayout.js.map +0 -1
  160. package/esm/flexbox/Splitter.css +0 -148
  161. package/esm/flexbox/Splitter.js +0 -111
  162. package/esm/flexbox/Splitter.js.map +0 -1
  163. package/esm/flexbox/flexbox-utils.js +0 -103
  164. package/esm/flexbox/flexbox-utils.js.map +0 -1
  165. package/esm/flexbox/useResponsiveSizing.js +0 -60
  166. package/esm/flexbox/useResponsiveSizing.js.map +0 -1
  167. package/esm/flexbox/useSplitterResizing.js +0 -207
  168. package/esm/flexbox/useSplitterResizing.js.map +0 -1
  169. package/esm/index.js +0 -37
  170. package/esm/index.js.map +0 -1
  171. package/esm/layout-action.js +0 -25
  172. package/esm/layout-action.js.map +0 -1
  173. package/esm/layout-header/Header.css +0 -9
  174. package/esm/layout-header/Header.js +0 -120
  175. package/esm/layout-header/Header.js.map +0 -1
  176. package/esm/layout-provider/LayoutProvider.js +0 -172
  177. package/esm/layout-provider/LayoutProvider.js.map +0 -1
  178. package/esm/layout-provider/LayoutProviderContext.js +0 -12
  179. package/esm/layout-provider/LayoutProviderContext.js.map +0 -1
  180. package/esm/layout-provider/useLayoutDragDrop.js +0 -168
  181. package/esm/layout-provider/useLayoutDragDrop.js.map +0 -1
  182. package/esm/layout-reducer/flexUtils.js +0 -210
  183. package/esm/layout-reducer/flexUtils.js.map +0 -1
  184. package/esm/layout-reducer/insert-layout-element.js +0 -269
  185. package/esm/layout-reducer/insert-layout-element.js.map +0 -1
  186. package/esm/layout-reducer/layout-reducer.js +0 -196
  187. package/esm/layout-reducer/layout-reducer.js.map +0 -1
  188. package/esm/layout-reducer/layoutTypes.js +0 -37
  189. package/esm/layout-reducer/layoutTypes.js.map +0 -1
  190. package/esm/layout-reducer/layoutUtils.js +0 -215
  191. package/esm/layout-reducer/layoutUtils.js.map +0 -1
  192. package/esm/layout-reducer/move-layout-element.js +0 -29
  193. package/esm/layout-reducer/move-layout-element.js.map +0 -1
  194. package/esm/layout-reducer/remove-layout-element.js +0 -221
  195. package/esm/layout-reducer/remove-layout-element.js.map +0 -1
  196. package/esm/layout-reducer/replace-layout-element.js +0 -87
  197. package/esm/layout-reducer/replace-layout-element.js.map +0 -1
  198. package/esm/layout-reducer/resize-flex-children.js +0 -58
  199. package/esm/layout-reducer/resize-flex-children.js.map +0 -1
  200. package/esm/layout-reducer/wrap-layout-element.js +0 -210
  201. package/esm/layout-reducer/wrap-layout-element.js.map +0 -1
  202. package/esm/layout-view/View.css +0 -62
  203. package/esm/layout-view/View.js +0 -153
  204. package/esm/layout-view/View.js.map +0 -1
  205. package/esm/layout-view/useView.js +0 -90
  206. package/esm/layout-view/useView.js.map +0 -1
  207. package/esm/layout-view/useViewResize.js +0 -40
  208. package/esm/layout-view/useViewResize.js.map +0 -1
  209. package/esm/layout-view-actions/ViewContext.js +0 -12
  210. package/esm/layout-view-actions/ViewContext.js.map +0 -1
  211. package/esm/layout-view-actions/useViewActionDispatcher.js +0 -101
  212. package/esm/layout-view-actions/useViewActionDispatcher.js.map +0 -1
  213. package/esm/palette/Palette.css +0 -33
  214. package/esm/palette/Palette.js +0 -115
  215. package/esm/palette/Palette.js.map +0 -1
  216. package/esm/placeholder/LayoutStartPanel.css +0 -30
  217. package/esm/placeholder/LayoutStartPanel.js +0 -49
  218. package/esm/placeholder/LayoutStartPanel.js.map +0 -1
  219. package/esm/placeholder/Placeholder.css +0 -17
  220. package/esm/placeholder/Placeholder.js +0 -23
  221. package/esm/placeholder/Placeholder.js.map +0 -1
  222. package/esm/registry/ComponentRegistry.js +0 -21
  223. package/esm/registry/ComponentRegistry.js.map +0 -1
  224. package/esm/responsive/breakpoints.js +0 -33
  225. package/esm/responsive/breakpoints.js.map +0 -1
  226. package/esm/responsive/use-breakpoints.js +0 -74
  227. package/esm/responsive/use-breakpoints.js.map +0 -1
  228. package/esm/responsive/useResizeObserver.js +0 -112
  229. package/esm/responsive/useResizeObserver.js.map +0 -1
  230. package/esm/responsive/utils.js +0 -31
  231. package/esm/responsive/utils.js.map +0 -1
  232. package/esm/stack/Stack.css +0 -39
  233. package/esm/stack/Stack.js +0 -137
  234. package/esm/stack/Stack.js.map +0 -1
  235. package/esm/stack/StackLayout.js +0 -120
  236. package/esm/stack/StackLayout.js.map +0 -1
  237. package/esm/use-persistent-state.js +0 -104
  238. package/esm/use-persistent-state.js.map +0 -1
  239. package/esm/utils/pathUtils.js +0 -280
  240. package/esm/utils/pathUtils.js.map +0 -1
  241. package/esm/utils/propUtils.js +0 -23
  242. package/esm/utils/propUtils.js.map +0 -1
  243. package/esm/utils/refUtils.js +0 -10
  244. package/esm/utils/refUtils.js.map +0 -1
  245. package/esm/utils/styleUtils.js +0 -13
  246. package/esm/utils/styleUtils.js.map +0 -1
  247. package/esm/utils/typeOf.js +0 -23
  248. package/esm/utils/typeOf.js.map +0 -1
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var pathUtils = require('../utils/pathUtils.js');
5
- var propUtils = require('../utils/propUtils.js');
6
- var replaceLayoutElement = require('./replace-layout-element.js');
7
-
8
- function resizeFlexChild(layoutRoot, { path, size }) {
9
- const target = pathUtils.followPath(layoutRoot, path, true);
10
- const { style } = propUtils.getProps(target);
11
- const newStyle = {
12
- ...style,
13
- width: size
14
- };
15
- const replacement = React.cloneElement(target, { style: newStyle });
16
- return replaceLayoutElement.swapChild(layoutRoot, target, replacement);
17
- }
18
- function resizeFlexChildren(layoutRoot, { path, sizes }) {
19
- const target = pathUtils.followPath(layoutRoot, path, true);
20
- const { children, style } = propUtils.getProps(target);
21
- const dimension2 = style.flexDirection === "column" ? "height" : "width";
22
- const replacementChildren = applySizesToChildren(children, sizes, dimension2);
23
- const replacement = React.cloneElement(
24
- target,
25
- void 0,
26
- replacementChildren
27
- );
28
- return replaceLayoutElement.swapChild(layoutRoot, target, replacement);
29
- }
30
- function applySizesToChildren(children, sizes, dimension2) {
31
- return children.map((child, i) => {
32
- const {
33
- style: { [dimension2]: size, flexBasis: actualFlexBasis }
34
- } = propUtils.getProps(child);
35
- const meta = sizes[i];
36
- const { currentSize, flexBasis } = meta;
37
- const hasCurrentSize = currentSize !== void 0;
38
- const newSize = hasCurrentSize ? meta.currentSize : flexBasis;
39
- if (newSize === void 0 || size === newSize || actualFlexBasis === newSize) {
40
- return child;
41
- }
42
- return React.cloneElement(child, {
43
- style: applySizeToChild(child.props.style, dimension2, newSize)
44
- });
45
- });
46
- }
47
- function applySizeToChild(style, dimension2, newSize) {
48
- const hasSize = typeof style[dimension2] === "number";
49
- const { flexShrink = 1, flexGrow = 1 } = style;
50
- return {
51
- ...style,
52
- [dimension2]: hasSize ? newSize : "auto",
53
- flexBasis: hasSize ? "auto" : newSize,
54
- flexShrink,
55
- flexGrow
56
- };
57
- }
58
-
59
- exports.resizeFlexChild = resizeFlexChild;
60
- exports.resizeFlexChildren = resizeFlexChildren;
61
- //# sourceMappingURL=resize-flex-children.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resize-flex-children.js","sources":["../../src/layout-reducer/resize-flex-children.ts"],"sourcesContent":["import { dimension } from \"@vuu-ui/vuu-utils\";\nimport React, { CSSProperties, ReactElement } from \"react\";\nimport { followPath, getProps } from \"../utils\";\nimport { LayoutResizeAction, SplitterResizeAction } from \"./layoutTypes\";\nimport { swapChild } from \"./replace-layout-element\";\n\nexport function resizeFlexChild(\n layoutRoot: ReactElement,\n { path, size }: LayoutResizeAction\n) {\n const target = followPath(layoutRoot, path, true);\n\n const { style } = getProps(target);\n\n const newStyle = {\n ...style,\n width: size,\n };\n\n // const dimension = style.flexDirection === \"column\" ? \"height\" : \"width\";\n // const replacementChildren = applySizesToChildren(children, sizes, dimension);\n\n const replacement = React.cloneElement(target, { style: newStyle });\n\n return swapChild(layoutRoot, target, replacement);\n}\n\nexport function resizeFlexChildren(\n layoutRoot: ReactElement,\n { path, sizes }: SplitterResizeAction\n) {\n const target = followPath(layoutRoot, path, true);\n const { children, style } = getProps(target);\n\n const dimension = style.flexDirection === \"column\" ? \"height\" : \"width\";\n const replacementChildren = applySizesToChildren(children, sizes, dimension);\n\n const replacement = React.cloneElement(\n target,\n undefined,\n replacementChildren\n );\n\n return swapChild(layoutRoot, target, replacement);\n}\n\nfunction applySizesToChildren(\n children: ReactElement[],\n sizes: { currentSize: number; flexBasis: number }[],\n dimension: dimension\n) {\n return children.map((child, i) => {\n const {\n style: { [dimension]: size, flexBasis: actualFlexBasis },\n } = getProps(child);\n const meta = sizes[i];\n const { currentSize, flexBasis } = meta;\n const hasCurrentSize = currentSize !== undefined;\n const newSize = hasCurrentSize ? meta.currentSize : flexBasis;\n\n if (\n newSize === undefined ||\n size === newSize ||\n actualFlexBasis === newSize\n ) {\n return child;\n }\n return React.cloneElement(child, {\n style: applySizeToChild(child.props.style, dimension, newSize),\n });\n });\n}\n\nfunction applySizeToChild(\n style: CSSProperties,\n dimension: dimension,\n newSize: number\n) {\n const hasSize = typeof style[dimension] === \"number\";\n const { flexShrink = 1, flexGrow = 1 } = style;\n return {\n ...style,\n [dimension]: hasSize ? newSize : \"auto\",\n flexBasis: hasSize ? \"auto\" : newSize,\n flexShrink,\n flexGrow,\n };\n}\n"],"names":["followPath","getProps","swapChild","dimension"],"mappings":";;;;;;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vuu-ui/vuu-utils');
4
- var React = require('react');
5
- var ComponentRegistry = require('../registry/ComponentRegistry.js');
6
- var pathUtils = require('../utils/pathUtils.js');
7
- var propUtils = require('../utils/propUtils.js');
8
- var typeOf = require('../utils/typeOf.js');
9
- var flexUtils = require('./flexUtils.js');
10
- var layoutUtils = require('./layoutUtils.js');
11
-
12
- const isHtmlElement = (component) => {
13
- const [firstLetter] = typeOf.typeOf(component);
14
- return firstLetter === firstLetter.toLowerCase();
15
- };
16
- function wrap(container, existingComponent, newComponent, pos, clientRect, dropRect) {
17
- const { children: containerChildren, path: containerPath } = propUtils.getProps(container);
18
- const existingComponentPath = propUtils.getProp(existingComponent, "path");
19
- const { idx, finalStep } = pathUtils.nextStep(containerPath, existingComponentPath);
20
- const children = finalStep ? updateChildren(
21
- container,
22
- containerChildren,
23
- existingComponent,
24
- newComponent,
25
- pos,
26
- clientRect,
27
- dropRect
28
- ) : containerChildren.map(
29
- (child, index) => index === idx ? wrap(
30
- child,
31
- existingComponent,
32
- newComponent,
33
- pos,
34
- clientRect,
35
- dropRect
36
- ) : child
37
- );
38
- return React.cloneElement(container, void 0, children);
39
- }
40
- function updateChildren(container, containerChildren, existingComponent, newComponent, pos, clientRect, dropRect) {
41
- const intrinsicSize = flexUtils.getIntrinsicSize(newComponent);
42
- if (intrinsicSize?.width && intrinsicSize?.height) {
43
- if (clientRect === void 0 || dropRect === void 0) {
44
- throw Error(
45
- "wrap-layout-element, updateChildren clientRect and dropRect must both be available"
46
- );
47
- }
48
- return wrapIntrinsicSizedComponent(
49
- containerChildren,
50
- existingComponent,
51
- newComponent,
52
- pos,
53
- clientRect,
54
- dropRect
55
- );
56
- }
57
- return wrapFlexComponent(
58
- container,
59
- containerChildren,
60
- existingComponent,
61
- newComponent,
62
- pos
63
- );
64
- }
65
- function wrapFlexComponent(container, containerChildren, existingComponent, newComponent, pos) {
66
- const { version = 0 } = propUtils.getProps(newComponent);
67
- const { path: existingComponentPath, title } = propUtils.getProps(existingComponent);
68
- const {
69
- type,
70
- flexDirection: flexDirection2,
71
- showTabs: showTabsProp
72
- } = getLayoutSpecForWrapper(pos);
73
- const [style, existingComponentStyle, newComponentStyle] = getWrappedFlexStyles(
74
- type,
75
- existingComponent,
76
- newComponent,
77
- flexDirection2,
78
- pos
79
- );
80
- const targetFirst = isTargetFirst(pos);
81
- const active = targetFirst ? 1 : 0;
82
- const newComponentProps = {
83
- resizeable: true,
84
- style: newComponentStyle,
85
- version: version + 1
86
- };
87
- const resizeProp = isHtmlElement(existingComponent) ? "data-resizeable" : "resizeable";
88
- const existingComponentProps = {
89
- [resizeProp]: true,
90
- style: existingComponentStyle
91
- };
92
- const showTabs = type === "Stack" ? { showTabs: showTabsProp } : void 0;
93
- const splitterSize = type === "Flexbox" ? {
94
- splitterSize: (typeOf.typeOf(container) === "Flexbox" && container.props.splitterSize) ?? void 0
95
- } : void 0;
96
- const id = vuuUtils.uuid();
97
- const wrapper = React.createElement(
98
- ComponentRegistry.ComponentRegistry[type],
99
- {
100
- active,
101
- id,
102
- key: id,
103
- path: propUtils.getProp(existingComponent, "path"),
104
- flexFill: propUtils.getProp(existingComponent, "flexFill"),
105
- ...splitterSize,
106
- ...showTabs,
107
- style,
108
- title,
109
- resizeable: propUtils.getProp(existingComponent, "resizeable")
110
- },
111
- targetFirst ? [
112
- pathUtils.resetPath(
113
- existingComponent,
114
- `${existingComponentPath}.0`,
115
- existingComponentProps
116
- ),
117
- layoutUtils.applyLayoutProps(
118
- React.cloneElement(newComponent, newComponentProps),
119
- `${existingComponentPath}.1`
120
- )
121
- ] : [
122
- layoutUtils.applyLayoutProps(
123
- React.cloneElement(newComponent, newComponentProps),
124
- `${existingComponentPath}.0`
125
- ),
126
- pathUtils.resetPath(
127
- existingComponent,
128
- `${existingComponentPath}.1`,
129
- existingComponentProps
130
- )
131
- ]
132
- );
133
- return containerChildren.map(
134
- (child) => child === existingComponent ? wrapper : child
135
- );
136
- }
137
- function wrapIntrinsicSizedComponent(containerChildren, existingComponent, newComponent, pos, clientRect, dropRect) {
138
- const { flexDirection: flexDirection2 } = getLayoutSpecForWrapper(pos);
139
- const contraDirection = flexDirection2 === "column" ? "row" : "column";
140
- const targetFirst = isTargetFirst(pos);
141
- const [dropLeft, dropTop, dropRight, dropBottom] = dropRect;
142
- const [startPlaceholder, endPlaceholder] = flexDirection2 === "column" ? [dropTop - clientRect.top, clientRect.bottom - dropBottom] : [dropLeft - clientRect.left, clientRect.right - dropRight];
143
- const pathRoot = propUtils.getProp(existingComponent, "path");
144
- let pathIndex = 0;
145
- const resizeProp = isHtmlElement(existingComponent) ? "data-resizeable" : "resizeable";
146
- const wrappedChildren = [];
147
- if (startPlaceholder) {
148
- wrappedChildren.push(
149
- targetFirst ? pathUtils.resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {
150
- [resizeProp]: true,
151
- style: { flexBasis: startPlaceholder, flexGrow: 1, flexShrink: 1 }
152
- }) : flexUtils.createPlaceHolder(`${pathRoot}.${pathIndex++}`, startPlaceholder, {
153
- flexGrow: 0,
154
- flexShrink: 0
155
- })
156
- );
157
- }
158
- wrappedChildren.push(
159
- flexUtils.wrapIntrinsicSizeComponentWithFlexbox(
160
- newComponent,
161
- contraDirection,
162
- `${pathRoot}.${pathIndex++}`,
163
- clientRect,
164
- dropRect
165
- )
166
- );
167
- if (endPlaceholder) {
168
- wrappedChildren.push(
169
- targetFirst ? flexUtils.createPlaceHolder(`${pathRoot}.${pathIndex++}`, 0) : pathUtils.resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {
170
- [resizeProp]: true,
171
- style: { flexBasis: 0, flexGrow: 1, flexShrink: 1 }
172
- })
173
- );
174
- }
175
- const wrapper = flexUtils.createFlexbox(
176
- flexDirection2,
177
- existingComponent.props,
178
- wrappedChildren,
179
- pathRoot
180
- );
181
- return containerChildren.map(
182
- (child) => child === existingComponent ? wrapper : child
183
- );
184
- }
185
- function getWrappedFlexStyles(type, existingComponent, newComponent, flexDirection2, pos) {
186
- const style = {
187
- ...existingComponent.props.style,
188
- flexDirection: flexDirection2
189
- };
190
- const dimension = type === "Flexbox" && flexDirection2 === "column" ? "height" : "width";
191
- const newComponentStyle = flexUtils.getFlexStyle(newComponent, dimension, pos);
192
- const existingComponentStyle = flexUtils.getFlexStyle(existingComponent, dimension);
193
- return [style, existingComponentStyle, newComponentStyle];
194
- }
195
- const isTargetFirst = (pos) => pos.position.SouthOrEast ? true : pos?.tab?.positionRelativeToTab === "before" ? false : pos.position.Header ? true : false;
196
- function getLayoutSpecForWrapper(pos) {
197
- if (pos.position.Header) {
198
- return {
199
- type: "Stack",
200
- flexDirection: "column",
201
- showTabs: true
202
- };
203
- } else {
204
- return {
205
- type: "Flexbox",
206
- flexDirection: pos.position.EastOrWest ? "row" : "column"
207
- };
208
- }
209
- }
210
-
211
- exports.wrap = wrap;
212
- //# sourceMappingURL=wrap-layout-element.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrap-layout-element.js","sources":["../../src/layout-reducer/wrap-layout-element.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { rectTuple, uuid } from \"@vuu-ui/vuu-utils\";\nimport React, { ReactElement } from \"react\";\nimport { DropPos } from \"../drag-drop/dragDropTypes\";\nimport { DropTarget } from \"../drag-drop/DropTarget\";\nimport { ComponentRegistry } from \"../registry/ComponentRegistry\";\nimport { getProp, getProps, nextStep, resetPath, typeOf } from \"../utils\";\nimport {\n createFlexbox,\n createPlaceHolder,\n flexDirection,\n getFlexStyle,\n getIntrinsicSize,\n wrapIntrinsicSizeComponentWithFlexbox,\n} from \"./flexUtils\";\nimport { LayoutModel } from \"./layoutTypes\";\nimport { applyLayoutProps, LayoutProps } from \"./layoutUtils\";\n\nexport interface LayoutSpec {\n type: \"Stack\" | \"Flexbox\";\n flexDirection: \"column\" | \"row\";\n showTabs?: boolean;\n}\n\nconst isHtmlElement = (component: LayoutModel) => {\n const [firstLetter] = typeOf(component) as string;\n return firstLetter === firstLetter.toLowerCase();\n};\n\nexport function wrap(\n container: ReactElement,\n existingComponent: ReactElement,\n newComponent: any,\n pos: DropPos,\n clientRect?: DropTarget[\"clientRect\"],\n dropRect?: DropTarget[\"dropRect\"]\n): ReactElement {\n const { children: containerChildren, path: containerPath } =\n getProps(container);\n\n const existingComponentPath = getProp(existingComponent, \"path\");\n const { idx, finalStep } = nextStep(containerPath, existingComponentPath);\n const children = finalStep\n ? updateChildren(\n container,\n containerChildren,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect\n )\n : containerChildren.map((child: ReactElement, index: number) =>\n index === idx\n ? wrap(\n child,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect\n )\n : child\n );\n\n return React.cloneElement(container, undefined, children);\n}\n\nfunction updateChildren(\n container: LayoutModel,\n containerChildren: ReactElement[],\n existingComponent: ReactElement,\n newComponent: ReactElement,\n pos: DropPos,\n clientRect?: DropTarget[\"clientRect\"],\n dropRect?: rectTuple\n) {\n const intrinsicSize = getIntrinsicSize(newComponent);\n\n if (intrinsicSize?.width && intrinsicSize?.height) {\n if (clientRect === undefined || dropRect === undefined) {\n throw Error(\n \"wrap-layout-element, updateChildren clientRect and dropRect must both be available\"\n );\n }\n return wrapIntrinsicSizedComponent(\n containerChildren,\n existingComponent,\n newComponent,\n pos,\n clientRect,\n dropRect\n );\n }\n return wrapFlexComponent(\n container,\n containerChildren,\n existingComponent,\n newComponent,\n pos\n );\n}\n\nfunction wrapFlexComponent(\n container: LayoutModel,\n containerChildren: ReactElement[],\n existingComponent: ReactElement,\n newComponent: ReactElement,\n pos: DropPos\n) {\n const { version = 0 } = getProps(newComponent);\n const { path: existingComponentPath, title } = getProps(existingComponent);\n const {\n type,\n flexDirection,\n showTabs: showTabsProp,\n } = getLayoutSpecForWrapper(pos);\n const [style, existingComponentStyle, newComponentStyle] =\n getWrappedFlexStyles(\n type,\n existingComponent,\n newComponent,\n flexDirection,\n pos\n );\n const targetFirst = isTargetFirst(pos);\n const active = targetFirst ? 1 : 0;\n\n const newComponentProps = {\n resizeable: true,\n style: newComponentStyle,\n version: version + 1,\n };\n const resizeProp = isHtmlElement(existingComponent)\n ? \"data-resizeable\"\n : \"resizeable\";\n\n const existingComponentProps = {\n [resizeProp]: true,\n style: existingComponentStyle,\n };\n\n const showTabs = type === \"Stack\" ? { showTabs: showTabsProp } : undefined;\n const splitterSize =\n type === \"Flexbox\"\n ? {\n splitterSize:\n (typeOf(container) === \"Flexbox\" && container.props.splitterSize) ??\n undefined,\n }\n : undefined;\n\n const id = uuid();\n const wrapper = React.createElement(\n ComponentRegistry[type],\n {\n active,\n id,\n key: id,\n path: getProp(existingComponent, \"path\"),\n flexFill: getProp(existingComponent, \"flexFill\"),\n ...splitterSize,\n ...showTabs,\n style,\n title,\n resizeable: getProp(existingComponent, \"resizeable\"),\n } as LayoutProps,\n targetFirst\n ? [\n resetPath(\n existingComponent,\n `${existingComponentPath}.0`,\n existingComponentProps\n ),\n applyLayoutProps(\n React.cloneElement(newComponent, newComponentProps),\n `${existingComponentPath}.1`\n ),\n ]\n : [\n applyLayoutProps(\n React.cloneElement(newComponent, newComponentProps),\n `${existingComponentPath}.0`\n ),\n resetPath(\n existingComponent,\n `${existingComponentPath}.1`,\n existingComponentProps\n ),\n ]\n );\n return containerChildren.map((child: ReactElement) =>\n child === existingComponent ? wrapper : child\n );\n}\n\nfunction wrapIntrinsicSizedComponent(\n containerChildren: ReactElement[],\n existingComponent: ReactElement,\n newComponent: ReactElement,\n pos: DropPos,\n clientRect: DropTarget[\"clientRect\"],\n dropRect: rectTuple\n) {\n const { flexDirection } = getLayoutSpecForWrapper(pos);\n const contraDirection = flexDirection === \"column\" ? \"row\" : \"column\";\n const targetFirst = isTargetFirst(pos);\n\n const [dropLeft, dropTop, dropRight, dropBottom] = dropRect;\n const [startPlaceholder, endPlaceholder] =\n flexDirection === \"column\"\n ? [dropTop - clientRect.top, clientRect.bottom - dropBottom]\n : [dropLeft - clientRect.left, clientRect.right - dropRight];\n const pathRoot = getProp(existingComponent, \"path\");\n let pathIndex = 0;\n\n const resizeProp = isHtmlElement(existingComponent)\n ? \"data-resizeable\"\n : \"resizeable\";\n\n const wrappedChildren = [];\n if (startPlaceholder) {\n wrappedChildren.push(\n targetFirst\n ? resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {\n [resizeProp]: true,\n style: { flexBasis: startPlaceholder, flexGrow: 1, flexShrink: 1 },\n })\n : createPlaceHolder(`${pathRoot}.${pathIndex++}`, startPlaceholder, {\n flexGrow: 0,\n flexShrink: 0,\n })\n );\n }\n wrappedChildren.push(\n wrapIntrinsicSizeComponentWithFlexbox(\n newComponent,\n contraDirection,\n `${pathRoot}.${pathIndex++}`,\n clientRect,\n dropRect\n )\n );\n if (endPlaceholder) {\n wrappedChildren.push(\n targetFirst\n ? createPlaceHolder(`${pathRoot}.${pathIndex++}`, 0)\n : resetPath(existingComponent, `${pathRoot}.${pathIndex++}`, {\n [resizeProp]: true,\n style: { flexBasis: 0, flexGrow: 1, flexShrink: 1 },\n })\n );\n }\n\n const wrapper = createFlexbox(\n flexDirection,\n existingComponent.props,\n wrappedChildren,\n pathRoot\n );\n return containerChildren.map((child) =>\n child === existingComponent ? wrapper : child\n );\n}\n\nfunction getWrappedFlexStyles(\n type: string,\n existingComponent: ReactElement,\n newComponent: ReactElement,\n flexDirection: flexDirection,\n pos: DropPos\n) {\n const style = {\n ...existingComponent.props.style,\n flexDirection,\n };\n\n const dimension =\n type === \"Flexbox\" && flexDirection === \"column\" ? \"height\" : \"width\";\n const newComponentStyle = getFlexStyle(newComponent, dimension, pos);\n const existingComponentStyle = getFlexStyle(existingComponent, dimension);\n\n return [style, existingComponentStyle, newComponentStyle];\n}\n\nconst isTargetFirst = (pos: DropPos) =>\n pos.position.SouthOrEast\n ? true\n : pos?.tab?.positionRelativeToTab === \"before\"\n ? false\n : pos.position.Header\n ? true\n : false;\n\nfunction getLayoutSpecForWrapper(pos: DropPos): LayoutSpec {\n if (pos.position.Header) {\n return {\n type: \"Stack\",\n flexDirection: \"column\",\n showTabs: true,\n };\n } else {\n return {\n type: \"Flexbox\",\n flexDirection: pos.position.EastOrWest ? \"row\" : \"column\",\n };\n }\n}\n"],"names":["typeOf","getProps","getProp","nextStep","getIntrinsicSize","flexDirection","uuid","ComponentRegistry","resetPath","applyLayoutProps","createPlaceHolder","wrapIntrinsicSizeComponentWithFlexbox","createFlexbox","getFlexStyle"],"mappings":";;;;;;;;;;;AAwBA,MAAM,aAAA,GAAgB,CAAC,SAA2B,KAAA;AAChD,EAAA,MAAM,CAAC,WAAW,CAAI,GAAAA,aAAA,CAAO,SAAS,CAAA,CAAA;AACtC,EAAO,OAAA,WAAA,KAAgB,YAAY,WAAY,EAAA,CAAA;AACjD,CAAA,CAAA;AAEO,SAAS,KACd,SACA,EAAA,iBAAA,EACA,YACA,EAAA,GAAA,EACA,YACA,QACc,EAAA;AACd,EAAA,MAAM,EAAE,QAAU,EAAA,iBAAA,EAAmB,MAAM,aAAc,EAAA,GACvDC,mBAAS,SAAS,CAAA,CAAA;AAEpB,EAAM,MAAA,qBAAA,GAAwBC,iBAAQ,CAAA,iBAAA,EAAmB,MAAM,CAAA,CAAA;AAC/D,EAAA,MAAM,EAAE,GAAK,EAAA,SAAA,EAAc,GAAAC,kBAAA,CAAS,eAAe,qBAAqB,CAAA,CAAA;AACxE,EAAA,MAAM,WAAW,SACb,GAAA,cAAA;AAAA,IACE,SAAA;AAAA,IACA,iBAAA;AAAA,IACA,iBAAA;AAAA,IACA,YAAA;AAAA,IACA,GAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,MAEF,iBAAkB,CAAA,GAAA;AAAA,IAAI,CAAC,KAAA,EAAqB,KAC1C,KAAA,KAAA,KAAU,GACN,GAAA,IAAA;AAAA,MACE,KAAA;AAAA,MACA,iBAAA;AAAA,MACA,YAAA;AAAA,MACA,GAAA;AAAA,MACA,UAAA;AAAA,MACA,QAAA;AAAA,KAEF,GAAA,KAAA;AAAA,GACN,CAAA;AAEJ,EAAA,O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GAAK,EAAA,GAAA,EAAK,0BAA0B,QACpC,GAAA,KAAA,GACA,GAAI,CAAA,QAAA,CAAS,SACb,IACA,GAAA,KAAA,CAAA;AAEN,SAAS,wBAAwB,GAA0B,EAAA;AACzD,EAAI,IAAA,GAAA,CAAI,SAAS,MAAQ,EAAA;AACvB,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,aAAe,EAAA,QAAA;AAAA,MACf,QAAU,EAAA,IAAA;AAAA,KACZ,CAAA;AAAA,GACK,MAAA;AACL,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,aAAe,EAAA,GAAA,CAAI,QAAS,CAAA,UAAA,GAAa,KAAQ,GAAA,QAAA;AAAA,KACnD,CAAA;AAAA,GACF;AACF;;;;"}
@@ -1,62 +0,0 @@
1
- .vuuView {
2
- border-color: var(--vuuView-borderColor, var(--salt-container-primary-borderColor));
3
- border-width: var(--vuuView-borderWidth, 1px);
4
- border-style: var(--vuuView-borderStyle, none);
5
-
6
- display: flex;
7
- flex-direction: column;
8
- margin: var(--vuuView-margin, 0px);
9
- min-height: 50px;
10
- min-width: 50px;
11
- outline: none;
12
- overflow: hidden;
13
- position: relative;
14
- }
15
-
16
- .vuuView.focus-visible:after {
17
- content: '';
18
- position: absolute;
19
- top: 0;
20
- left: 0;
21
- right: 0;
22
- bottom: 0;
23
- border: dotted cornflowerblue 2px;
24
- }
25
-
26
- .vuuView.dragging {
27
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
28
- }
29
-
30
- .vuuView-main {
31
- /* height: var(--view-content-height);
32
- width: var(--view-content-width); */
33
- display: flex;
34
- flex-direction: var(--vuuView-flexDirection, column);
35
- flex-wrap: var(--vuuView-flex-wrap, nowrap);
36
- flex: 1;
37
- justify-content: var(--vuuView-justify, flex-start);
38
- overflow: hidden;
39
- position: relative;
40
- }
41
-
42
- .vuuView-main > * {
43
- flex-basis: auto;
44
- flex-grow: var(--vuuView-flex-grow, 1);
45
- flex-shrink: var(--vuuView-flex-shrink, 1);
46
- }
47
-
48
- .vuuView-collapsed .vuuView-main {
49
- display: none;
50
- }
51
-
52
- .vuuView-collapsed + .Splitter {
53
- display: none;
54
- }
55
-
56
- .vuuView-collapsed .Toolbar-vertical {
57
- border-right: solid 1px var(--grey40);
58
- }
59
-
60
- .vuuView-collapsed .Toolbar-vertical .toolbar-title {
61
- display: none;
62
- }
@@ -1,155 +0,0 @@
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 cx = require('clsx');
7
- var React = require('react');
8
- var Header = require('../layout-header/Header.js');
9
- var ComponentRegistry = require('../registry/ComponentRegistry.js');
10
- var useView = require('./useView.js');
11
- var useViewResize = require('./useViewResize.js');
12
- require('../layout-provider/LayoutProviderContext.js');
13
- require('../drag-drop/Draggable.js');
14
- require('../drag-drop/BoxModel.js');
15
- var ViewContext = require('../layout-view-actions/ViewContext.js');
16
-
17
- const classBase = "vuuView";
18
- const getProps = (state, props) => {
19
- if (state && props) {
20
- return {
21
- ...state,
22
- ...props
23
- };
24
- } else
25
- return state || props;
26
- };
27
- const View = React.forwardRef(function View2(props, forwardedRef) {
28
- const {
29
- Header: Header$1 = Header.Header,
30
- children,
31
- className,
32
- collapsed,
33
- closeable,
34
- "data-path": dataPath,
35
- "data-resizeable": dataResizeable,
36
- dropTargets,
37
- expanded,
38
- flexFill,
39
- id: idProp,
40
- header,
41
- orientation = "horizontal",
42
- path = dataPath,
43
- resize = "responsive",
44
- resizeable = dataResizeable,
45
- tearOut,
46
- style = {},
47
- title: titleProp,
48
- ...restProps
49
- } = props;
50
- const id = vuuUtils.useId(idProp);
51
- const rootRef = React.useRef(null);
52
- const mainRef = React.useRef(null);
53
- const [componentProps, _setComponentProps] = React.useState();
54
- const {
55
- contributions,
56
- dispatchViewAction,
57
- load,
58
- loadSession,
59
- onConfigChange,
60
- onEditTitle,
61
- purge,
62
- restoredState,
63
- save,
64
- saveSession,
65
- title
66
- } = useView.useView({
67
- id,
68
- rootRef,
69
- path,
70
- dropTargets,
71
- title: titleProp
72
- });
73
- useViewResize.useViewResize({ mainRef, resize, rootRef });
74
- const setComponentProps = React.useCallback((props2) => {
75
- _setComponentProps(props2);
76
- }, []);
77
- const getContent = () => {
78
- if (React.isValidElement(children) && (restoredState || componentProps)) {
79
- return React.cloneElement(
80
- children,
81
- getProps(restoredState, componentProps)
82
- );
83
- }
84
- return children;
85
- };
86
- const viewContextValue = React.useMemo(
87
- () => ({
88
- dispatch: dispatchViewAction,
89
- id,
90
- path,
91
- title,
92
- load,
93
- loadSession,
94
- onConfigChange,
95
- purge,
96
- save,
97
- saveSession,
98
- setComponentProps
99
- }),
100
- [
101
- dispatchViewAction,
102
- id,
103
- load,
104
- loadSession,
105
- onConfigChange,
106
- path,
107
- purge,
108
- save,
109
- saveSession,
110
- setComponentProps,
111
- title
112
- ]
113
- );
114
- const headerProps = typeof header === "object" ? header : {};
115
- return /* @__PURE__ */ jsxRuntime.jsx(
116
- "div",
117
- {
118
- ...restProps,
119
- className: cx(classBase, className, {
120
- [`${classBase}-collapsed`]: collapsed,
121
- [`${classBase}-expanded`]: expanded,
122
- [`${classBase}-resize-defer`]: resize === "defer"
123
- }),
124
- "data-resizeable": resizeable,
125
- id,
126
- ref: core.useForkRef(forwardedRef, rootRef),
127
- style,
128
- tabIndex: -1,
129
- children: /* @__PURE__ */ jsxRuntime.jsxs(ViewContext.ViewContext.Provider, { value: viewContextValue, children: [
130
- header ? /* @__PURE__ */ jsxRuntime.jsx(
131
- Header$1,
132
- {
133
- ...headerProps,
134
- collapsed,
135
- contributions,
136
- expanded,
137
- closeable,
138
- onEditTitle,
139
- orientation,
140
- tearOut,
141
- title
142
- }
143
- ) : null,
144
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classBase}-main`, ref: mainRef, children: getContent() })
145
- ] })
146
- }
147
- );
148
- });
149
- View.displayName = "View";
150
- const MemoView = React.memo(View);
151
- MemoView.displayName = "View";
152
- ComponentRegistry.registerComponent("View", MemoView, "view");
153
-
154
- exports.View = MemoView;
155
- //# sourceMappingURL=View.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"View.js","sources":["../../src/layout-view/View.tsx"],"sourcesContent":["import { useId } from \"@vuu-ui/vuu-utils\";\nimport { useForkRef } from \"@salt-ds/core\";\nimport cx from \"clsx\";\nimport React, {\n ForwardedRef,\n forwardRef,\n ReactElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Header as VuuHeader } from \"../layout-header/Header\";\nimport { registerComponent } from \"../registry/ComponentRegistry\";\nimport { useView } from \"./useView\";\nimport { useViewResize } from \"./useViewResize\";\nimport { ViewContext, ViewContextAPI } from \"../layout-view-actions\";\nimport { ViewProps } from \"./viewTypes\";\n\nimport \"./View.css\";\n\nconst classBase = \"vuuView\";\n\ntype Props = { [key: string]: unknown };\n\nconst getProps = (state?: Props, props?: Props) => {\n if (state && props) {\n return {\n ...state,\n ...props,\n };\n } else return state || props;\n};\n\n/**\n * View is the leaf-level entity managed by the Vuu layout system. It may represent a component\n * or a group of components. It also offers an API (via useViewContext) for persistence.\n */\nconst View = forwardRef(function View(\n props: ViewProps,\n forwardedRef: ForwardedRef<HTMLDivElement>\n) {\n const {\n Header = VuuHeader,\n children,\n className,\n collapsed,\n closeable,\n \"data-path\": dataPath,\n \"data-resizeable\": dataResizeable,\n dropTargets,\n expanded,\n flexFill,\n id: idProp,\n header,\n orientation = \"horizontal\",\n path = dataPath,\n resize = \"responsive\",\n resizeable = dataResizeable,\n tearOut,\n style = {},\n title: titleProp,\n ...restProps\n } = props;\n\n const id = useId(idProp);\n const rootRef = useRef<HTMLDivElement>(null);\n const mainRef = useRef<HTMLDivElement>(null);\n const [componentProps, _setComponentProps] = useState<Props>();\n const {\n contributions,\n dispatchViewAction,\n load,\n loadSession,\n onConfigChange,\n onEditTitle,\n purge,\n restoredState,\n save,\n saveSession,\n title,\n } = useView({\n id,\n rootRef,\n path,\n dropTargets,\n title: titleProp,\n });\n\n useViewResize({ mainRef, resize, rootRef });\n\n const setComponentProps = useCallback((props?: Props) => {\n _setComponentProps(props);\n }, []);\n\n const getContent = () => {\n if (React.isValidElement(children) && (restoredState || componentProps)) {\n return React.cloneElement(\n children,\n getProps(restoredState, componentProps)\n );\n }\n return children;\n };\n\n const viewContextValue: ViewContextAPI = useMemo(\n () => ({\n dispatch: dispatchViewAction,\n id,\n path,\n title,\n load,\n loadSession,\n onConfigChange,\n purge,\n save,\n saveSession,\n setComponentProps,\n }),\n [\n dispatchViewAction,\n id,\n load,\n loadSession,\n onConfigChange,\n path,\n purge,\n save,\n saveSession,\n setComponentProps,\n title,\n ]\n );\n\n const headerProps = typeof header === \"object\" ? header : {};\n\n return (\n <div\n {...restProps}\n className={cx(classBase, className, {\n [`${classBase}-collapsed`]: collapsed,\n [`${classBase}-expanded`]: expanded,\n [`${classBase}-resize-defer`]: resize === \"defer\",\n })}\n data-resizeable={resizeable}\n id={id}\n ref={useForkRef(forwardedRef, rootRef)}\n style={style}\n tabIndex={-1}\n >\n <ViewContext.Provider value={viewContextValue}>\n {header ? (\n <Header\n {...headerProps}\n collapsed={collapsed}\n contributions={contributions}\n expanded={expanded}\n closeable={closeable}\n onEditTitle={onEditTitle}\n orientation={orientation}\n tearOut={tearOut}\n title={title}\n />\n ) : null}\n <div className={`${classBase}-main`} ref={mainRef}>\n {getContent()}\n </div>\n </ViewContext.Provider>\n </div>\n );\n});\nView.displayName = \"View\";\n\ninterface ViewComponentType {\n (\n props: ViewProps & {\n ref?: ForwardedRef<HTMLDivElement>;\n }\n ): ReactElement<ViewProps>;\n displayName?: string;\n}\n\nconst MemoView = React.memo(View) as ViewComponentType;\n\nMemoView.displayName = \"View\";\n\nregisterComponent(\"View\", MemoView, \"view\");\n\nexport { MemoView as View };\n"],"names":["forwardRef","View","Header","VuuHeader","useId","useRef","useState","useView","useViewResize","useCallback","props","useMemo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KAAA;AAAA,GACF,CAAA;AAEJ,CAAC,CAAA,CAAA;AACD,IAAA,CAAK,WAAc,GAAA,MAAA,CAAA;AAWb,MAAA,QAAA,GAAW,KAAM,CAAA,IAAA,CAAK,IAAI,EAAA;AAEhC,QAAA,CAAS,WAAc,GAAA,MAAA,CAAA;AAEvBI,mCAAkB,CAAA,MAAA,EAAQ,UAAU,MAAM,CAAA;;;;"}
@@ -1,92 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var LayoutProvider = require('../layout-provider/LayoutProvider.js');
5
- require('../layout-provider/LayoutProviderContext.js');
6
- var usePersistentState = require('../use-persistent-state.js');
7
- var useViewActionDispatcher = require('../layout-view-actions/useViewActionDispatcher.js');
8
-
9
- const useView = ({
10
- id,
11
- rootRef,
12
- path,
13
- dropTargets,
14
- title: titleProp
15
- }) => {
16
- const layoutDispatch = LayoutProvider.useLayoutProviderDispatch();
17
- const {
18
- loadState,
19
- loadSessionState,
20
- purgeState,
21
- saveState,
22
- saveSessionState
23
- } = usePersistentState.usePersistentState();
24
- const [dispatchViewAction, contributions] = useViewActionDispatcher.useViewActionDispatcher(
25
- id,
26
- rootRef,
27
- path,
28
- dropTargets
29
- );
30
- const title = React.useMemo(
31
- () => loadState("view-title") ?? titleProp,
32
- [loadState, titleProp]
33
- );
34
- const onEditTitle = React.useCallback(
35
- (title2) => {
36
- if (path) {
37
- layoutDispatch({ type: "set-title", path, title: title2 });
38
- }
39
- },
40
- [layoutDispatch, path]
41
- );
42
- const restoredState = React.useMemo(() => loadState(id), [id, loadState]);
43
- const load = React.useCallback(
44
- (key) => loadState(id, key),
45
- [id, loadState]
46
- );
47
- const purge = React.useCallback(
48
- (key) => {
49
- purgeState(id, key);
50
- layoutDispatch({ type: "save" });
51
- },
52
- [id, layoutDispatch, purgeState]
53
- );
54
- const save = React.useCallback(
55
- (state, key) => {
56
- saveState(id, key, state);
57
- layoutDispatch({ type: "save" });
58
- },
59
- [id, layoutDispatch, saveState]
60
- );
61
- const loadSession = React.useCallback(
62
- (key) => loadSessionState(id, key),
63
- [id, loadSessionState]
64
- );
65
- const saveSession = React.useCallback(
66
- (state, key) => saveSessionState(id, key, state),
67
- [id, saveSessionState]
68
- );
69
- const onConfigChange = React.useCallback(
70
- ({ type: key, ...config }) => {
71
- const { [key]: data } = config;
72
- save(data, key);
73
- },
74
- [save]
75
- );
76
- return {
77
- contributions,
78
- dispatchViewAction,
79
- load,
80
- loadSession,
81
- onConfigChange,
82
- onEditTitle,
83
- purge,
84
- restoredState,
85
- save,
86
- saveSession,
87
- title
88
- };
89
- };
90
-
91
- exports.useView = useView;
92
- //# sourceMappingURL=useView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useView.js","sources":["../../src/layout-view/useView.tsx"],"sourcesContent":["import { RefObject, useCallback, useMemo } from \"react\";\nimport { useLayoutProviderDispatch } from \"../layout-provider\";\nimport { usePersistentState } from \"../use-persistent-state\";\nimport { useViewActionDispatcher } from \"../layout-view-actions/useViewActionDispatcher\";\n\nexport interface ViewHookProps {\n id: string;\n rootRef: RefObject<HTMLDivElement>;\n path?: string;\n dropTargets?: string[];\n title?: string;\n}\n\nexport const useView = ({\n id,\n rootRef,\n path,\n dropTargets,\n title: titleProp,\n}: ViewHookProps) => {\n const layoutDispatch = useLayoutProviderDispatch();\n\n const {\n loadState,\n loadSessionState,\n purgeState,\n saveState,\n saveSessionState,\n } = usePersistentState();\n\n const [dispatchViewAction, contributions] = useViewActionDispatcher(\n id,\n rootRef,\n path,\n dropTargets\n );\n\n const title = useMemo(\n () => loadState(\"view-title\") ?? titleProp,\n [loadState, titleProp]\n );\n\n const onEditTitle = useCallback(\n (title: string) => {\n if (path) {\n layoutDispatch({ type: \"set-title\", path, title });\n }\n },\n [layoutDispatch, path]\n );\n\n const restoredState = useMemo(() => loadState(id), [id, loadState]);\n\n const load = useCallback(\n (key?: string) => loadState(id, key),\n [id, loadState]\n );\n\n const purge = useCallback(\n (key) => {\n purgeState(id, key);\n layoutDispatch({ type: \"save\" });\n },\n [id, layoutDispatch, purgeState]\n );\n\n const save = useCallback(\n (state, key) => {\n saveState(id, key, state);\n layoutDispatch({ type: \"save\" });\n },\n [id, layoutDispatch, saveState]\n );\n const loadSession = useCallback(\n (key?: string) => loadSessionState(id, key),\n [id, loadSessionState]\n );\n const saveSession = useCallback(\n (state, key) => saveSessionState(id, key, state),\n [id, saveSessionState]\n );\n\n const onConfigChange = useCallback(\n ({ type: key, ...config }) => {\n const { [key]: data } = config;\n save(data, key);\n },\n [save]\n );\n\n return {\n contributions,\n dispatchViewAction,\n load,\n loadSession,\n onConfigChange,\n onEditTitle,\n purge,\n restoredState,\n save,\n saveSession,\n title,\n };\n};\n"],"names":["useLayoutProviderDispatch","usePersistentState","useViewActionDispatcher","useMemo","useCallback","title"],"mappings":";;;;;;;;AAaO,MAAM,UAAU,CAAC;AAAA,EACtB,EAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAO,EAAA,SAAA;AACT,CAAqB,KAAA;AACnB,EAAA,MAAM,iBAAiBA,wCAA0B,EAAA,CAAA;AAEjD,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,gBAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,IACA,gBAAA;AAAA,MACEC,qCAAmB,EAAA,CAAA;AAEvB,EAAM,MAAA,CAAC,kBAAoB,EAAA,aAAa,CAAI,GAAAC,+CAAA;AAAA,IAC1C,EAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,KAAQ,GAAAC,aAAA;AAAA,IACZ,MAAM,SAAU,CAAA,YAAY,CAAK,IAAA,SAAA;AAAA,IACjC,CAAC,WAAW,SAAS,CAAA;AAAA,GACvB,CAAA;AAEA,EAAA,MAAM,WAAc,GAAAC,iBAAA;AAAA,IAClB,CAACC,MAAkB,KAAA;AACjB,MAAA,IAAI,IAAM,EAA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