@vuu-ui/vuu-layout 2.1.18 → 2.1.19-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -18
- package/src/Component.js +14 -0
- package/src/LayoutContainer.css.js +24 -0
- package/src/LayoutContainer.js +26 -0
- package/src/debug.js +16 -0
- package/src/dock-layout/DockLayout.css.js +36 -0
- package/src/dock-layout/DockLayout.js +43 -0
- package/src/dock-layout/Drawer.css.js +150 -0
- package/src/dock-layout/Drawer.js +82 -0
- package/src/dock-layout/index.js +2 -0
- package/src/drag-drop/BoxModel.js +337 -0
- package/src/drag-drop/DragState.js +119 -0
- package/src/drag-drop/Draggable.js +140 -0
- package/src/drag-drop/DropTarget.js +286 -0
- package/src/drag-drop/DropTargetRenderer.js +275 -0
- package/src/drag-drop/dragDropTypes.js +0 -0
- package/src/drag-drop/index.js +3 -0
- package/src/flexbox/Flexbox.css.js +45 -0
- package/src/flexbox/Flexbox.js +45 -0
- package/src/flexbox/FlexboxLayout.js +27 -0
- package/src/flexbox/Splitter.css.js +57 -0
- package/src/flexbox/Splitter.js +112 -0
- package/src/flexbox/flexbox-utils.js +92 -0
- package/src/flexbox/flexboxTypes.js +0 -0
- package/src/flexbox/index.js +2 -0
- package/src/flexbox/useSplitterResizing.js +181 -0
- package/src/index.js +20 -0
- package/src/layout-action.js +20 -0
- package/src/layout-header/ActionButton.js +15 -0
- package/src/layout-header/Header.css.js +32 -0
- package/src/layout-header/Header.js +99 -0
- package/src/layout-header/index.js +1 -0
- package/src/layout-header/useHeader.js +76 -0
- package/src/layout-provider/LayoutProvider.js +242 -0
- package/src/layout-provider/LayoutProviderContext.js +13 -0
- package/src/layout-provider/index.js +2 -0
- package/src/layout-provider/useLayoutDragDrop.js +147 -0
- package/src/layout-reducer/flexUtils.js +186 -0
- package/src/layout-reducer/index.js +4 -0
- package/src/layout-reducer/insert-layout-element.js +179 -0
- package/src/layout-reducer/layout-reducer.js +121 -0
- package/src/layout-reducer/layoutTypes.js +34 -0
- package/src/layout-reducer/layoutUtils.js +178 -0
- package/src/layout-reducer/move-layout-element.js +18 -0
- package/src/layout-reducer/remove-layout-element.js +161 -0
- package/src/layout-reducer/replace-layout-element.js +70 -0
- package/src/layout-reducer/resize-flex-children.js +48 -0
- package/src/layout-reducer/wrap-layout-element.js +134 -0
- package/src/layout-view/View.css.js +76 -0
- package/src/layout-view/View.js +116 -0
- package/src/layout-view/useView.js +69 -0
- package/src/layout-view/useViewBroadcastChannel.js +29 -0
- package/src/layout-view/useViewResize.js +27 -0
- package/src/layout-view/viewTypes.js +0 -0
- package/src/layout-view-actions/ViewContext.js +11 -0
- package/src/layout-view-actions/useViewActionDispatcher.js +116 -0
- package/src/layout-view-actions/useViewContributions.js +31 -0
- package/src/palette/Palette.css.js +31 -0
- package/src/palette/Palette.js +85 -0
- package/src/palette/index.js +1 -0
- package/src/placeholder/LayoutStartPanel.css.js +35 -0
- package/src/placeholder/LayoutStartPanel.js +57 -0
- package/src/placeholder/Placeholder.css.js +20 -0
- package/src/placeholder/Placeholder.js +33 -0
- package/src/placeholder/index.js +1 -0
- package/src/responsive/index.js +2 -0
- package/src/responsive/measureMinimumNodeSize.js +24 -0
- package/src/responsive/useResizeObserver.js +109 -0
- package/src/responsive/utils.js +27 -0
- package/src/stack/Stack.css.js +44 -0
- package/src/stack/Stack.js +98 -0
- package/src/stack/StackLayout.js +116 -0
- package/src/stack/index.js +3 -0
- package/src/stack/stackTypes.js +0 -0
- package/src/tabs/TabPanel.css.js +17 -0
- package/src/tabs/TabPanel.js +11 -0
- package/src/tabs/index.js +1 -0
- package/src/tools/config-wrapper/ConfigWrapper.js +55 -0
- package/src/tools/config-wrapper/index.js +1 -0
- package/src/tools/devtools-box/layout-configurator.css.js +113 -0
- package/src/tools/devtools-tree/layout-tree-viewer.css.js +17 -0
- package/src/tools/index.js +3 -0
- package/src/use-persistent-state.js +43 -0
- package/src/utils/index.js +5 -0
- package/src/utils/pathUtils.js +212 -0
- package/src/utils/propUtils.js +15 -0
- package/src/utils/refUtils.js +5 -0
- package/src/utils/styleUtils.js +9 -0
- package/src/utils/typeOf.js +15 -0
- package/types/dock-layout/DockLayout.d.ts +4 -4
- package/types/dock-layout/Drawer.d.ts +4 -4
- package/types/drag-drop/BoxModel.d.ts +7 -7
- package/types/flexbox/FlexboxLayout.d.ts +4 -4
- package/types/flexbox/Splitter.d.ts +1 -1
- package/types/layout-reducer/layoutUtils.d.ts +1 -1
- package/types/layout-reducer/remove-layout-element.d.ts +1 -1
- package/types/layout-reducer/replace-layout-element.d.ts +2 -2
- package/types/layout-reducer/resize-flex-children.d.ts +2 -2
- package/types/layout-view/useView.d.ts +1 -1
- package/types/placeholder/Placeholder.d.ts +4 -4
- package/types/responsive/overflowUtils.d.ts +2 -2
- package/types/stack/StackLayout.d.ts +4 -4
- package/types/tools/devtools-box/layout-configurator.d.ts +26 -26
- package/types/tools/devtools-tree/layout-tree-viewer.d.ts +2 -2
- package/types/utils/pathUtils.d.ts +1 -1
- package/cjs/Component.js +0 -14
- package/cjs/Component.js.map +0 -1
- package/cjs/LayoutContainer.css.js +0 -6
- package/cjs/LayoutContainer.css.js.map +0 -1
- package/cjs/LayoutContainer.js +0 -33
- package/cjs/LayoutContainer.js.map +0 -1
- package/cjs/dock-layout/DockLayout.css.js +0 -6
- package/cjs/dock-layout/DockLayout.css.js.map +0 -1
- package/cjs/dock-layout/DockLayout.js +0 -41
- package/cjs/dock-layout/DockLayout.js.map +0 -1
- package/cjs/dock-layout/Drawer.css.js +0 -6
- package/cjs/dock-layout/Drawer.css.js.map +0 -1
- package/cjs/dock-layout/Drawer.js +0 -95
- package/cjs/dock-layout/Drawer.js.map +0 -1
- package/cjs/drag-drop/BoxModel.js +0 -416
- package/cjs/drag-drop/BoxModel.js.map +0 -1
- package/cjs/drag-drop/DragState.js +0 -161
- package/cjs/drag-drop/DragState.js.map +0 -1
- package/cjs/drag-drop/Draggable.js +0 -192
- package/cjs/drag-drop/Draggable.js.map +0 -1
- package/cjs/drag-drop/DropTarget.js +0 -257
- package/cjs/drag-drop/DropTarget.js.map +0 -1
- package/cjs/drag-drop/DropTargetRenderer.js +0 -218
- package/cjs/drag-drop/DropTargetRenderer.js.map +0 -1
- package/cjs/flexbox/Flexbox.css.js +0 -6
- package/cjs/flexbox/Flexbox.css.js.map +0 -1
- package/cjs/flexbox/Flexbox.js +0 -69
- package/cjs/flexbox/Flexbox.js.map +0 -1
- package/cjs/flexbox/FlexboxLayout.js +0 -30
- package/cjs/flexbox/FlexboxLayout.js.map +0 -1
- package/cjs/flexbox/Splitter.css.js +0 -6
- package/cjs/flexbox/Splitter.css.js.map +0 -1
- package/cjs/flexbox/Splitter.js +0 -122
- package/cjs/flexbox/Splitter.js.map +0 -1
- package/cjs/flexbox/flexbox-utils.js +0 -95
- package/cjs/flexbox/flexbox-utils.js.map +0 -1
- package/cjs/flexbox/useSplitterResizing.js +0 -197
- package/cjs/flexbox/useSplitterResizing.js.map +0 -1
- package/cjs/index.js +0 -122
- package/cjs/index.js.map +0 -1
- package/cjs/layout-action.js +0 -24
- package/cjs/layout-action.js.map +0 -1
- package/cjs/layout-header/Header.css.js +0 -6
- package/cjs/layout-header/Header.css.js.map +0 -1
- package/cjs/layout-header/Header.js +0 -152
- package/cjs/layout-header/Header.js.map +0 -1
- package/cjs/layout-header/useHeader.js +0 -85
- package/cjs/layout-header/useHeader.js.map +0 -1
- package/cjs/layout-provider/LayoutProvider.js +0 -304
- package/cjs/layout-provider/LayoutProvider.js.map +0 -1
- package/cjs/layout-provider/LayoutProviderContext.js +0 -23
- package/cjs/layout-provider/LayoutProviderContext.js.map +0 -1
- package/cjs/layout-provider/useLayoutDragDrop.js +0 -177
- package/cjs/layout-provider/useLayoutDragDrop.js.map +0 -1
- package/cjs/layout-reducer/flexUtils.js +0 -227
- package/cjs/layout-reducer/flexUtils.js.map +0 -1
- package/cjs/layout-reducer/insert-layout-element.js +0 -286
- package/cjs/layout-reducer/insert-layout-element.js.map +0 -1
- package/cjs/layout-reducer/layout-reducer.js +0 -202
- package/cjs/layout-reducer/layout-reducer.js.map +0 -1
- package/cjs/layout-reducer/layoutTypes.js +0 -40
- package/cjs/layout-reducer/layoutTypes.js.map +0 -1
- package/cjs/layout-reducer/layoutUtils.js +0 -237
- package/cjs/layout-reducer/layoutUtils.js.map +0 -1
- package/cjs/layout-reducer/move-layout-element.js +0 -31
- package/cjs/layout-reducer/move-layout-element.js.map +0 -1
- package/cjs/layout-reducer/remove-layout-element.js +0 -237
- package/cjs/layout-reducer/remove-layout-element.js.map +0 -1
- package/cjs/layout-reducer/replace-layout-element.js +0 -96
- package/cjs/layout-reducer/replace-layout-element.js.map +0 -1
- package/cjs/layout-reducer/resize-flex-children.js +0 -62
- package/cjs/layout-reducer/resize-flex-children.js.map +0 -1
- package/cjs/layout-reducer/wrap-layout-element.js +0 -211
- package/cjs/layout-reducer/wrap-layout-element.js.map +0 -1
- package/cjs/layout-view/View.css.js +0 -6
- package/cjs/layout-view/View.css.js.map +0 -1
- package/cjs/layout-view/View.js +0 -160
- package/cjs/layout-view/View.js.map +0 -1
- package/cjs/layout-view/useView.js +0 -75
- package/cjs/layout-view/useView.js.map +0 -1
- package/cjs/layout-view/useViewBroadcastChannel.js +0 -35
- package/cjs/layout-view/useViewBroadcastChannel.js.map +0 -1
- package/cjs/layout-view/useViewResize.js +0 -42
- package/cjs/layout-view/useViewResize.js.map +0 -1
- package/cjs/layout-view-actions/ViewContext.js +0 -16
- package/cjs/layout-view-actions/ViewContext.js.map +0 -1
- package/cjs/layout-view-actions/useViewActionDispatcher.js +0 -112
- package/cjs/layout-view-actions/useViewActionDispatcher.js.map +0 -1
- package/cjs/layout-view-actions/useViewContributions.js +0 -33
- package/cjs/layout-view-actions/useViewContributions.js.map +0 -1
- package/cjs/palette/Palette.css.js +0 -6
- package/cjs/palette/Palette.css.js.map +0 -1
- package/cjs/palette/Palette.js +0 -115
- package/cjs/palette/Palette.js.map +0 -1
- package/cjs/placeholder/LayoutStartPanel.css.js +0 -6
- package/cjs/placeholder/LayoutStartPanel.css.js.map +0 -1
- package/cjs/placeholder/LayoutStartPanel.js +0 -56
- package/cjs/placeholder/LayoutStartPanel.js.map +0 -1
- package/cjs/placeholder/Placeholder.css.js +0 -6
- package/cjs/placeholder/Placeholder.css.js.map +0 -1
- package/cjs/placeholder/Placeholder.js +0 -34
- package/cjs/placeholder/Placeholder.js.map +0 -1
- package/cjs/responsive/useResizeObserver.js +0 -118
- package/cjs/responsive/useResizeObserver.js.map +0 -1
- package/cjs/responsive/utils.js +0 -34
- package/cjs/responsive/utils.js.map +0 -1
- package/cjs/stack/Stack.css.js +0 -6
- package/cjs/stack/Stack.css.js.map +0 -1
- package/cjs/stack/Stack.js +0 -150
- package/cjs/stack/Stack.js.map +0 -1
- package/cjs/stack/StackLayout.js +0 -116
- package/cjs/stack/StackLayout.js.map +0 -1
- package/cjs/use-persistent-state.js +0 -63
- package/cjs/use-persistent-state.js.map +0 -1
- package/cjs/utils/pathUtils.js +0 -293
- package/cjs/utils/pathUtils.js.map +0 -1
- package/cjs/utils/propUtils.js +0 -27
- package/cjs/utils/propUtils.js.map +0 -1
- package/cjs/utils/refUtils.js +0 -12
- package/cjs/utils/refUtils.js.map +0 -1
- package/cjs/utils/styleUtils.js +0 -15
- package/cjs/utils/styleUtils.js.map +0 -1
- package/cjs/utils/typeOf.js +0 -27
- package/cjs/utils/typeOf.js.map +0 -1
- package/esm/Component.js +0 -12
- package/esm/Component.js.map +0 -1
- package/esm/LayoutContainer.css.js +0 -4
- package/esm/LayoutContainer.css.js.map +0 -1
- package/esm/LayoutContainer.js +0 -31
- package/esm/LayoutContainer.js.map +0 -1
- package/esm/dock-layout/DockLayout.css.js +0 -4
- package/esm/dock-layout/DockLayout.css.js.map +0 -1
- package/esm/dock-layout/DockLayout.js +0 -39
- package/esm/dock-layout/DockLayout.js.map +0 -1
- package/esm/dock-layout/Drawer.css.js +0 -4
- package/esm/dock-layout/Drawer.css.js.map +0 -1
- package/esm/dock-layout/Drawer.js +0 -93
- package/esm/dock-layout/Drawer.js.map +0 -1
- package/esm/drag-drop/BoxModel.js +0 -409
- package/esm/drag-drop/BoxModel.js.map +0 -1
- package/esm/drag-drop/DragState.js +0 -159
- package/esm/drag-drop/DragState.js.map +0 -1
- package/esm/drag-drop/Draggable.js +0 -190
- package/esm/drag-drop/Draggable.js.map +0 -1
- package/esm/drag-drop/DropTarget.js +0 -253
- package/esm/drag-drop/DropTarget.js.map +0 -1
- package/esm/drag-drop/DropTargetRenderer.js +0 -216
- package/esm/drag-drop/DropTargetRenderer.js.map +0 -1
- package/esm/flexbox/Flexbox.css.js +0 -4
- package/esm/flexbox/Flexbox.css.js.map +0 -1
- package/esm/flexbox/Flexbox.js +0 -67
- package/esm/flexbox/Flexbox.js.map +0 -1
- package/esm/flexbox/FlexboxLayout.js +0 -28
- package/esm/flexbox/FlexboxLayout.js.map +0 -1
- package/esm/flexbox/Splitter.css.js +0 -4
- package/esm/flexbox/Splitter.css.js.map +0 -1
- package/esm/flexbox/Splitter.js +0 -120
- package/esm/flexbox/Splitter.js.map +0 -1
- package/esm/flexbox/flexbox-utils.js +0 -89
- package/esm/flexbox/flexbox-utils.js.map +0 -1
- package/esm/flexbox/useSplitterResizing.js +0 -195
- package/esm/flexbox/useSplitterResizing.js.map +0 -1
- package/esm/index.js +0 -33
- package/esm/index.js.map +0 -1
- package/esm/layout-action.js +0 -22
- package/esm/layout-action.js.map +0 -1
- package/esm/layout-header/Header.css.js +0 -4
- package/esm/layout-header/Header.css.js.map +0 -1
- package/esm/layout-header/Header.js +0 -150
- package/esm/layout-header/Header.js.map +0 -1
- package/esm/layout-header/useHeader.js +0 -83
- package/esm/layout-header/useHeader.js.map +0 -1
- package/esm/layout-provider/LayoutProvider.js +0 -297
- package/esm/layout-provider/LayoutProvider.js.map +0 -1
- package/esm/layout-provider/LayoutProviderContext.js +0 -20
- package/esm/layout-provider/LayoutProviderContext.js.map +0 -1
- package/esm/layout-provider/useLayoutDragDrop.js +0 -175
- package/esm/layout-provider/useLayoutDragDrop.js.map +0 -1
- package/esm/layout-reducer/flexUtils.js +0 -218
- package/esm/layout-reducer/flexUtils.js.map +0 -1
- package/esm/layout-reducer/insert-layout-element.js +0 -282
- package/esm/layout-reducer/insert-layout-element.js.map +0 -1
- package/esm/layout-reducer/layout-reducer.js +0 -200
- package/esm/layout-reducer/layout-reducer.js.map +0 -1
- package/esm/layout-reducer/layoutTypes.js +0 -36
- package/esm/layout-reducer/layoutTypes.js.map +0 -1
- package/esm/layout-reducer/layoutUtils.js +0 -226
- package/esm/layout-reducer/layoutUtils.js.map +0 -1
- package/esm/layout-reducer/move-layout-element.js +0 -29
- package/esm/layout-reducer/move-layout-element.js.map +0 -1
- package/esm/layout-reducer/remove-layout-element.js +0 -235
- package/esm/layout-reducer/remove-layout-element.js.map +0 -1
- package/esm/layout-reducer/replace-layout-element.js +0 -92
- package/esm/layout-reducer/replace-layout-element.js.map +0 -1
- package/esm/layout-reducer/resize-flex-children.js +0 -59
- package/esm/layout-reducer/resize-flex-children.js.map +0 -1
- package/esm/layout-reducer/wrap-layout-element.js +0 -209
- package/esm/layout-reducer/wrap-layout-element.js.map +0 -1
- package/esm/layout-view/View.css.js +0 -4
- package/esm/layout-view/View.css.js.map +0 -1
- package/esm/layout-view/View.js +0 -158
- package/esm/layout-view/View.js.map +0 -1
- package/esm/layout-view/useView.js +0 -73
- package/esm/layout-view/useView.js.map +0 -1
- package/esm/layout-view/useViewBroadcastChannel.js +0 -33
- package/esm/layout-view/useViewBroadcastChannel.js.map +0 -1
- package/esm/layout-view/useViewResize.js +0 -40
- package/esm/layout-view/useViewResize.js.map +0 -1
- package/esm/layout-view-actions/ViewContext.js +0 -12
- package/esm/layout-view-actions/ViewContext.js.map +0 -1
- package/esm/layout-view-actions/useViewActionDispatcher.js +0 -110
- package/esm/layout-view-actions/useViewActionDispatcher.js.map +0 -1
- package/esm/layout-view-actions/useViewContributions.js +0 -31
- package/esm/layout-view-actions/useViewContributions.js.map +0 -1
- package/esm/palette/Palette.css.js +0 -4
- package/esm/palette/Palette.css.js.map +0 -1
- package/esm/palette/Palette.js +0 -112
- package/esm/palette/Palette.js.map +0 -1
- package/esm/placeholder/LayoutStartPanel.css.js +0 -4
- package/esm/placeholder/LayoutStartPanel.css.js.map +0 -1
- package/esm/placeholder/LayoutStartPanel.js +0 -54
- package/esm/placeholder/LayoutStartPanel.js.map +0 -1
- package/esm/placeholder/Placeholder.css.js +0 -4
- package/esm/placeholder/Placeholder.css.js.map +0 -1
- package/esm/placeholder/Placeholder.js +0 -32
- package/esm/placeholder/Placeholder.js.map +0 -1
- package/esm/responsive/useResizeObserver.js +0 -112
- package/esm/responsive/useResizeObserver.js.map +0 -1
- package/esm/responsive/utils.js +0 -31
- package/esm/responsive/utils.js.map +0 -1
- package/esm/stack/Stack.css.js +0 -4
- package/esm/stack/Stack.css.js.map +0 -1
- package/esm/stack/Stack.js +0 -148
- package/esm/stack/Stack.js.map +0 -1
- package/esm/stack/StackLayout.js +0 -114
- package/esm/stack/StackLayout.js.map +0 -1
- package/esm/use-persistent-state.js +0 -58
- package/esm/use-persistent-state.js.map +0 -1
- package/esm/utils/pathUtils.js +0 -280
- package/esm/utils/pathUtils.js.map +0 -1
- package/esm/utils/propUtils.js +0 -23
- package/esm/utils/propUtils.js.map +0 -1
- package/esm/utils/refUtils.js +0 -10
- package/esm/utils/refUtils.js.map +0 -1
- package/esm/utils/styleUtils.js +0 -13
- package/esm/utils/styleUtils.js.map +0 -1
- package/esm/utils/typeOf.js +0 -23
- package/esm/utils/typeOf.js.map +0 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { getProps, typeOf } from "../utils/index.js";
|
|
2
|
+
import { BoxModel, Position, RelativeDropPosition, getPosition, positionValues } from "./BoxModel.js";
|
|
3
|
+
const isTabstrip = (dropTarget)=>dropTarget.pos.tab && "Stack" === typeOf(dropTarget.component) && dropTarget.pos.position.Header;
|
|
4
|
+
const { north: north, south: south, east: east, west: west } = positionValues;
|
|
5
|
+
const eastwest = east + west;
|
|
6
|
+
const northsouth = north + south;
|
|
7
|
+
class DropTarget {
|
|
8
|
+
active;
|
|
9
|
+
box;
|
|
10
|
+
clientRect;
|
|
11
|
+
component;
|
|
12
|
+
dropRect;
|
|
13
|
+
nextDropTarget;
|
|
14
|
+
pos;
|
|
15
|
+
constructor({ component, pos, clientRect, nextDropTarget }){
|
|
16
|
+
this.component = component;
|
|
17
|
+
this.pos = pos;
|
|
18
|
+
this.clientRect = clientRect;
|
|
19
|
+
this.nextDropTarget = nextDropTarget;
|
|
20
|
+
this.active = false;
|
|
21
|
+
this.dropRect = void 0;
|
|
22
|
+
}
|
|
23
|
+
targetTabPos(tab) {
|
|
24
|
+
const { left: tabLeft, width: tabWidth, positionRelativeToTab } = tab;
|
|
25
|
+
return positionRelativeToTab === RelativeDropPosition.BEFORE ? tabLeft : tabLeft + tabWidth;
|
|
26
|
+
}
|
|
27
|
+
getTargetDropOutline(lineWidth, dragState) {
|
|
28
|
+
if (this.pos.tab) return this.getDropTabOutline(lineWidth, this.pos.tab);
|
|
29
|
+
{
|
|
30
|
+
if (dragState && dragState.hasIntrinsicSize()) return this.getIntrinsicDropRect(dragState);
|
|
31
|
+
const [l, t, r, b] = this.getDropRectOutline(lineWidth, dragState);
|
|
32
|
+
return {
|
|
33
|
+
l,
|
|
34
|
+
t,
|
|
35
|
+
r,
|
|
36
|
+
b
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getDropTabOutline(lineWidth, tab) {
|
|
41
|
+
const { clientRect: { top, left, right, bottom, header } } = this;
|
|
42
|
+
const inset = 0;
|
|
43
|
+
const gap = Math.round(lineWidth / 2) + inset;
|
|
44
|
+
const t = Math.round(top);
|
|
45
|
+
const l = Math.round(left + gap);
|
|
46
|
+
const r = Math.round(right - gap);
|
|
47
|
+
const b = Math.round(bottom - gap);
|
|
48
|
+
const tabLeft = this.targetTabPos(tab);
|
|
49
|
+
const tabWidth = 60;
|
|
50
|
+
const tabHeight = (header?.bottom ?? 0) - (header?.top ?? 0);
|
|
51
|
+
return {
|
|
52
|
+
l,
|
|
53
|
+
t,
|
|
54
|
+
r,
|
|
55
|
+
b,
|
|
56
|
+
tabLeft,
|
|
57
|
+
tabWidth,
|
|
58
|
+
tabHeight
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
getIntrinsicDropRect(dragState) {
|
|
62
|
+
const { pos, clientRect: rect } = this;
|
|
63
|
+
const { x, y } = dragState;
|
|
64
|
+
let height = dragState.intrinsicSize?.height ?? 0;
|
|
65
|
+
let width = dragState.intrinsicSize?.height ?? 0;
|
|
66
|
+
if (height && height > rect.height) {
|
|
67
|
+
console.log("DropTarget: we're going to blow the gaff");
|
|
68
|
+
height = rect.height;
|
|
69
|
+
} else if (width && width > rect.width) {
|
|
70
|
+
console.log("DropTarget: we're going to blow the gaff");
|
|
71
|
+
width = rect.width;
|
|
72
|
+
}
|
|
73
|
+
const left = Math.min(rect.right - width, Math.max(rect.left, Math.round(pos.x - x.mousePct * width)));
|
|
74
|
+
const top = Math.min(rect.bottom - height, Math.max(rect.top, Math.round(pos.y - y.mousePct * height)));
|
|
75
|
+
const [l, t, r, b] = this.dropRect = [
|
|
76
|
+
left,
|
|
77
|
+
top,
|
|
78
|
+
left + width,
|
|
79
|
+
top + height
|
|
80
|
+
];
|
|
81
|
+
const guideLines = pos.position.EastOrWest ? [
|
|
82
|
+
l,
|
|
83
|
+
rect.top,
|
|
84
|
+
l,
|
|
85
|
+
rect.bottom,
|
|
86
|
+
r,
|
|
87
|
+
rect.top,
|
|
88
|
+
r,
|
|
89
|
+
rect.bottom
|
|
90
|
+
] : [
|
|
91
|
+
rect.left,
|
|
92
|
+
t,
|
|
93
|
+
rect.right,
|
|
94
|
+
t,
|
|
95
|
+
rect.left,
|
|
96
|
+
b,
|
|
97
|
+
rect.right,
|
|
98
|
+
b
|
|
99
|
+
];
|
|
100
|
+
return {
|
|
101
|
+
l,
|
|
102
|
+
r,
|
|
103
|
+
t,
|
|
104
|
+
b,
|
|
105
|
+
guideLines
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
getDropRectOutline(lineWidth, dragState) {
|
|
109
|
+
const { pos, clientRect: rect } = this;
|
|
110
|
+
const { width: suggestedWidth, height: suggestedHeight, position } = pos;
|
|
111
|
+
const { width: intrinsicWidth, height: intrinsicHeight } = dragState?.intrinsicSize ?? {};
|
|
112
|
+
const sizeHeight = intrinsicHeight ?? suggestedHeight ?? 0;
|
|
113
|
+
const sizeWidth = intrinsicWidth ?? suggestedWidth ?? 0;
|
|
114
|
+
this.dropRect = void 0;
|
|
115
|
+
const { top: t, left: l, right: r, bottom: b } = rect;
|
|
116
|
+
const inset = 0;
|
|
117
|
+
const gap = Math.round(lineWidth / 2) + inset;
|
|
118
|
+
switch(position){
|
|
119
|
+
case Position.North:
|
|
120
|
+
case Position.Header:
|
|
121
|
+
{
|
|
122
|
+
const halfHeight = Math.round((b - t) / 2);
|
|
123
|
+
const height = sizeHeight ? Math.min(halfHeight, Math.round(sizeHeight)) : halfHeight;
|
|
124
|
+
return sizeWidth && l + sizeWidth < r ? [
|
|
125
|
+
l + gap,
|
|
126
|
+
t + gap,
|
|
127
|
+
l + sizeWidth - gap,
|
|
128
|
+
t + gap + height
|
|
129
|
+
] : [
|
|
130
|
+
l + gap,
|
|
131
|
+
t + gap,
|
|
132
|
+
r - gap,
|
|
133
|
+
t + gap + height
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
case Position.West:
|
|
137
|
+
{
|
|
138
|
+
const halfWidth = Math.round((r - l) / 2);
|
|
139
|
+
const width = sizeWidth ? Math.min(halfWidth, Math.round(sizeWidth)) : halfWidth;
|
|
140
|
+
return sizeHeight && t + sizeHeight < b ? [
|
|
141
|
+
l + gap,
|
|
142
|
+
t + gap,
|
|
143
|
+
l - gap + width,
|
|
144
|
+
t + sizeHeight + gap
|
|
145
|
+
] : [
|
|
146
|
+
l + gap,
|
|
147
|
+
t + gap,
|
|
148
|
+
l - gap + width,
|
|
149
|
+
b - gap
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
case Position.East:
|
|
153
|
+
{
|
|
154
|
+
const halfWidth = Math.round((r - l) / 2);
|
|
155
|
+
const width = sizeWidth ? Math.min(halfWidth, Math.round(sizeWidth)) : halfWidth;
|
|
156
|
+
return sizeHeight && t + sizeHeight < b ? [
|
|
157
|
+
r - gap - width,
|
|
158
|
+
t + gap,
|
|
159
|
+
r - gap,
|
|
160
|
+
t + sizeHeight + gap
|
|
161
|
+
] : [
|
|
162
|
+
r - gap - width,
|
|
163
|
+
t + gap,
|
|
164
|
+
r - gap,
|
|
165
|
+
b - gap
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
case Position.South:
|
|
169
|
+
{
|
|
170
|
+
const halfHeight = Math.round((b - t) / 2);
|
|
171
|
+
const height = sizeHeight ? Math.min(halfHeight, Math.round(sizeHeight)) : halfHeight;
|
|
172
|
+
return sizeWidth && l + sizeWidth < r ? [
|
|
173
|
+
l + gap,
|
|
174
|
+
b - gap - height,
|
|
175
|
+
l + sizeWidth - gap,
|
|
176
|
+
b - gap
|
|
177
|
+
] : [
|
|
178
|
+
l + gap,
|
|
179
|
+
b - gap - height,
|
|
180
|
+
r - gap,
|
|
181
|
+
b - gap
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
case Position.Centre:
|
|
185
|
+
return [
|
|
186
|
+
l + gap,
|
|
187
|
+
t + gap,
|
|
188
|
+
r - gap,
|
|
189
|
+
b - gap
|
|
190
|
+
];
|
|
191
|
+
default:
|
|
192
|
+
console.warn(`DropTarget does not recognize position ${position}`);
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
activate() {
|
|
197
|
+
this.active = true;
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
toArray() {
|
|
201
|
+
let dropTarget = this;
|
|
202
|
+
const dropTargets = [
|
|
203
|
+
dropTarget
|
|
204
|
+
];
|
|
205
|
+
while(dropTarget = dropTarget.nextDropTarget)dropTargets.push(dropTarget);
|
|
206
|
+
return dropTargets;
|
|
207
|
+
}
|
|
208
|
+
static getActiveDropTarget(dropTarget) {
|
|
209
|
+
return null === dropTarget ? null : dropTarget?.active ? dropTarget : DropTarget.getActiveDropTarget(dropTarget.nextDropTarget);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function identifyDropTarget(x, y, rootLayout, measurements, intrinsicSize, validDropTargets) {
|
|
213
|
+
let dropTarget = null;
|
|
214
|
+
const allBoxesContainingPoint = BoxModel.allBoxesContainingPoint(rootLayout, measurements, x, y, validDropTargets);
|
|
215
|
+
if (allBoxesContainingPoint.length) {
|
|
216
|
+
const [component, ...containers] = allBoxesContainingPoint;
|
|
217
|
+
const { "data-path": dataPath, path = dataPath, "data-row-placeholder": isRowPlaceholder } = getProps(component);
|
|
218
|
+
const clientRect = measurements[path];
|
|
219
|
+
const placeholderOrientation = intrinsicSize && isRowPlaceholder ? "row" : void 0;
|
|
220
|
+
const pos = getPosition(x, y, clientRect, placeholderOrientation);
|
|
221
|
+
const box = measurements[path];
|
|
222
|
+
const nextDropTarget = ([nextTarget, ...targets])=>{
|
|
223
|
+
if (pos.position?.Header || pos.closeToTheEdge) {
|
|
224
|
+
const targetPosition = getTargetPosition(nextTarget, pos, box, measurements, x, y);
|
|
225
|
+
if (targetPosition) {
|
|
226
|
+
const [containerPos, clientRect] = targetPosition;
|
|
227
|
+
return new DropTarget({
|
|
228
|
+
component: nextTarget,
|
|
229
|
+
pos: containerPos,
|
|
230
|
+
clientRect,
|
|
231
|
+
nextDropTarget: nextDropTarget(targets) ?? null
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (targets.length) return nextDropTarget(targets);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
dropTarget = new DropTarget({
|
|
238
|
+
component,
|
|
239
|
+
pos,
|
|
240
|
+
clientRect,
|
|
241
|
+
nextDropTarget: nextDropTarget(containers) ?? null
|
|
242
|
+
}).activate();
|
|
243
|
+
}
|
|
244
|
+
return dropTarget;
|
|
245
|
+
}
|
|
246
|
+
function getTargetPosition(container, { closeToTheEdge, position }, box, measurements, x, y) {
|
|
247
|
+
if (!container || "LayoutContainer" === container.type) return;
|
|
248
|
+
const containingBox = measurements[container.props.path];
|
|
249
|
+
const closeToTop = closeToTheEdge & positionValues.north;
|
|
250
|
+
const closeToRight = closeToTheEdge & positionValues.east;
|
|
251
|
+
const closeToBottom = closeToTheEdge & positionValues.south;
|
|
252
|
+
const closeToLeft = closeToTheEdge & positionValues.west;
|
|
253
|
+
const atTop = (closeToTop || position.Header) && Math.round(box.top) === Math.round(containingBox.top);
|
|
254
|
+
const atRight = closeToRight && Math.round(box.right) === Math.round(containingBox.right);
|
|
255
|
+
const atBottom = closeToBottom && Math.round(box.bottom) === Math.round(containingBox.bottom);
|
|
256
|
+
const atLeft = closeToLeft && Math.round(box.left) === Math.round(containingBox.left);
|
|
257
|
+
if (atTop || atRight || atBottom || atLeft) {
|
|
258
|
+
const { "data-path": dataPath, path = dataPath } = container.props;
|
|
259
|
+
const clientRect = measurements[path];
|
|
260
|
+
const containerPos = getPosition(x, y, clientRect);
|
|
261
|
+
if ((isVBox(container) || isTabbedContainer(container)) && closeToTheEdge & eastwest) {
|
|
262
|
+
containerPos.width = 120;
|
|
263
|
+
return [
|
|
264
|
+
containerPos,
|
|
265
|
+
clientRect
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
if ((isHBox(container) || isTabbedContainer(container)) && (position.Header || closeToTheEdge & northsouth)) {
|
|
269
|
+
containerPos.height = 120;
|
|
270
|
+
return [
|
|
271
|
+
containerPos,
|
|
272
|
+
clientRect
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function isTabbedContainer(component) {
|
|
278
|
+
return "Stack" === typeOf(component);
|
|
279
|
+
}
|
|
280
|
+
function isVBox(component) {
|
|
281
|
+
return "Flexbox" === typeOf(component) && "column" === component.props.style.flexDirection;
|
|
282
|
+
}
|
|
283
|
+
function isHBox(component) {
|
|
284
|
+
return "Flexbox" === typeOf(component) && "row" === component.props.style.flexDirection;
|
|
285
|
+
}
|
|
286
|
+
export { DropTarget, identifyDropTarget, isTabstrip };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { RelativeDropPosition } from "./BoxModel.js";
|
|
2
|
+
let _hoverDropTarget = null;
|
|
3
|
+
let _shiftedTab = null;
|
|
4
|
+
const start = ([x, y])=>`M${x},${y}`;
|
|
5
|
+
const point = ([x, y])=>`L${x},${y}`;
|
|
6
|
+
const pathFromPoints = ([p1, ...points])=>`${start(p1)} ${points.map(point)}Z`;
|
|
7
|
+
const pathFromGuideLines = (guideLines)=>{
|
|
8
|
+
if (!guideLines) return "";
|
|
9
|
+
{
|
|
10
|
+
const [x1, y1, x2, y2, x3, y3, x4, y4] = guideLines;
|
|
11
|
+
return `M${x1},${y1} L${x2},${y2} M${x3},${y3} L${x4},${y4}`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function insertSVGRoot() {
|
|
15
|
+
if (null === document.getElementById("hw-drag-canvas")) {
|
|
16
|
+
const root = document.getElementById("root");
|
|
17
|
+
const container = document.createElement("div");
|
|
18
|
+
container.id = "hw-drag-canvas";
|
|
19
|
+
container.style.cssText = "visibility:hidden;z-index:10;position:absolute;top:0px;left:0;right:0;bottom:0;background-color:transparent";
|
|
20
|
+
container.innerHTML = `
|
|
21
|
+
<svg width="100%" height="100%" style="position: absolute;">
|
|
22
|
+
<path id="hw-drop-guides" style="fill: none; stroke: rgba(0, 0, 0, 0.3);stroke-dasharray: 2 3"/>
|
|
23
|
+
<path
|
|
24
|
+
id="vuu-drop-outline"
|
|
25
|
+
style="fill:rgba(0,0,255,.3);stroke:none;stroke-dasharray:4 2"
|
|
26
|
+
d="M300,132 L380,132 L380,100 L460,100 L460,132, L550,132 L550,350 L300,350z">
|
|
27
|
+
<animate
|
|
28
|
+
attributeName="d"
|
|
29
|
+
id="hw-drop-outline-animate"
|
|
30
|
+
begin="indefinite"
|
|
31
|
+
dur="300ms"
|
|
32
|
+
fill="freeze"
|
|
33
|
+
to="M255,33 L255,33,L255,1,L315,1,L315,1,L794,1,L794,164,L255,164Z"
|
|
34
|
+
/>
|
|
35
|
+
</path>
|
|
36
|
+
</svg>
|
|
37
|
+
`;
|
|
38
|
+
document.body.insertBefore(container, root);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class DropTargetCanvas {
|
|
42
|
+
currentPath = null;
|
|
43
|
+
tabMode = null;
|
|
44
|
+
constructor(){
|
|
45
|
+
insertSVGRoot();
|
|
46
|
+
}
|
|
47
|
+
prepare(dragRect, tabMode = "full-view") {
|
|
48
|
+
const dragCanvas = document.getElementById("hw-drag-canvas");
|
|
49
|
+
if (dragCanvas) dragCanvas.style.visibility = "visible";
|
|
50
|
+
else throw Error("DropTargetRenderer.prepare no drag canvas detected");
|
|
51
|
+
document.body.classList.add("drawing");
|
|
52
|
+
this.currentPath = null;
|
|
53
|
+
this.tabMode = tabMode;
|
|
54
|
+
const points = this.getPoints(0, 0, 0, 0);
|
|
55
|
+
const d = pathFromPoints(points);
|
|
56
|
+
const dropOutlinePath = document.getElementById("vuu-drop-outline");
|
|
57
|
+
dropOutlinePath?.setAttribute("d", d);
|
|
58
|
+
this.currentPath = d;
|
|
59
|
+
}
|
|
60
|
+
clear() {
|
|
61
|
+
_hoverDropTarget = null;
|
|
62
|
+
clearShiftedTab();
|
|
63
|
+
const dragCanvas = document.getElementById("hw-drag-canvas");
|
|
64
|
+
if (dragCanvas) dragCanvas.style.visibility = "hidden";
|
|
65
|
+
}
|
|
66
|
+
get hoverDropTarget() {
|
|
67
|
+
return _hoverDropTarget;
|
|
68
|
+
}
|
|
69
|
+
getPoints(x, y, width, height, tabLeft = 0, tabWidth = 0, tabHeight = 0) {
|
|
70
|
+
const tabOnly = "tab-only" === this.tabMode;
|
|
71
|
+
if (0 === tabWidth) return [
|
|
72
|
+
[
|
|
73
|
+
x,
|
|
74
|
+
y + tabHeight
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
x,
|
|
78
|
+
y + tabHeight
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
x,
|
|
82
|
+
y
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
x + tabWidth,
|
|
86
|
+
y
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
x + tabWidth,
|
|
90
|
+
y
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
x + width,
|
|
94
|
+
y
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
x + width,
|
|
98
|
+
y + height
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
x,
|
|
102
|
+
y + height
|
|
103
|
+
]
|
|
104
|
+
];
|
|
105
|
+
if (tabOnly) {
|
|
106
|
+
const left = tabLeft;
|
|
107
|
+
return [
|
|
108
|
+
[
|
|
109
|
+
left,
|
|
110
|
+
y
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
left,
|
|
114
|
+
y
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
left + tabWidth,
|
|
118
|
+
y
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
left + tabWidth,
|
|
122
|
+
y
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
left + tabWidth,
|
|
126
|
+
y + tabHeight
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
left + tabWidth,
|
|
130
|
+
y + tabHeight
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
left,
|
|
134
|
+
y + tabHeight
|
|
135
|
+
],
|
|
136
|
+
[
|
|
137
|
+
left,
|
|
138
|
+
y + tabHeight
|
|
139
|
+
]
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
if (0 === tabLeft) return [
|
|
143
|
+
[
|
|
144
|
+
x,
|
|
145
|
+
y + tabHeight
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
x,
|
|
149
|
+
y + tabHeight
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
x,
|
|
153
|
+
y
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
x + tabWidth,
|
|
157
|
+
y
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
x + tabWidth,
|
|
161
|
+
y + tabHeight
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
x + width,
|
|
165
|
+
y + tabHeight
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
x + width,
|
|
169
|
+
y + height
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
x,
|
|
173
|
+
y + height
|
|
174
|
+
]
|
|
175
|
+
];
|
|
176
|
+
return [
|
|
177
|
+
[
|
|
178
|
+
x,
|
|
179
|
+
y + tabHeight
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
x + tabLeft,
|
|
183
|
+
y + tabHeight
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
x + tabLeft,
|
|
187
|
+
y
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
x + tabLeft,
|
|
191
|
+
y
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
x + tabLeft,
|
|
195
|
+
y + tabHeight
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
x + width,
|
|
199
|
+
y + tabHeight
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
x + width,
|
|
203
|
+
y + height
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
x,
|
|
207
|
+
y + height
|
|
208
|
+
]
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
draw(dropTarget, dragState) {
|
|
212
|
+
const sameDropTarget = false;
|
|
213
|
+
if (null !== _hoverDropTarget) this.drawTarget(_hoverDropTarget);
|
|
214
|
+
else if (false === sameDropTarget) {
|
|
215
|
+
if (dropTarget.pos.tab) moveExistingTabs(dropTarget);
|
|
216
|
+
else if (_shiftedTab) clearShiftedTab();
|
|
217
|
+
this.drawTarget(dropTarget, dragState);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
drawTarget(dropTarget, dragState) {
|
|
221
|
+
const lineWidth = 6;
|
|
222
|
+
const targetDropOutline = dropTarget.getTargetDropOutline(lineWidth, dragState);
|
|
223
|
+
if (targetDropOutline) {
|
|
224
|
+
const { l, t, r, b, tabLeft, tabWidth, tabHeight, guideLines } = targetDropOutline;
|
|
225
|
+
const w = r - l;
|
|
226
|
+
const h = b - t;
|
|
227
|
+
if (this.currentPath) {
|
|
228
|
+
const path = document.getElementById("vuu-drop-outline");
|
|
229
|
+
path?.setAttribute("d", this.currentPath);
|
|
230
|
+
}
|
|
231
|
+
const points = this.getPoints(l, t, w, h, tabLeft, tabWidth, tabHeight);
|
|
232
|
+
const path = pathFromPoints(points);
|
|
233
|
+
const animation = document.getElementById("hw-drop-outline-animate");
|
|
234
|
+
animation?.setAttribute("to", path);
|
|
235
|
+
animation?.beginElement();
|
|
236
|
+
this.currentPath = path;
|
|
237
|
+
const dropGuidePath = document.getElementById("hw-drop-guides");
|
|
238
|
+
dropGuidePath?.setAttribute("d", pathFromGuideLines(guideLines));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const cssShiftRight = "transition:margin-left .4s ease-out;margin-left: 63px";
|
|
243
|
+
const cssShiftBack = "transition:margin-left .4s ease-out;margin-left: 0px";
|
|
244
|
+
function moveExistingTabs(dropTarget) {
|
|
245
|
+
const { AFTER, BEFORE } = RelativeDropPosition;
|
|
246
|
+
const { clientRect: { Stack }, pos: { tab } } = dropTarget;
|
|
247
|
+
const { id } = dropTarget.component.props;
|
|
248
|
+
let tabEl = null;
|
|
249
|
+
if (Stack && tab && tab.positionRelativeToTab !== AFTER) {
|
|
250
|
+
const tabOffset = tab.positionRelativeToTab === BEFORE ? 1 : 2;
|
|
251
|
+
const selector = `:scope .hwTabstrip > .hwTabstrip-inner > .hwTab:nth-child(${tab.index + tabOffset})`;
|
|
252
|
+
tabEl = document.getElementById(id)?.querySelector(selector);
|
|
253
|
+
if (tabEl) {
|
|
254
|
+
if (null === _shiftedTab || _shiftedTab !== tabEl) {
|
|
255
|
+
tabEl.style.cssText = cssShiftRight;
|
|
256
|
+
if (_shiftedTab) _shiftedTab.style.cssText = cssShiftBack;
|
|
257
|
+
_shiftedTab = tabEl;
|
|
258
|
+
}
|
|
259
|
+
} else clearShiftedTab();
|
|
260
|
+
} else if (tab?.positionRelativeToTab === BEFORE) {
|
|
261
|
+
if (null === _shiftedTab) {
|
|
262
|
+
const selector = ".vuuHeader-title";
|
|
263
|
+
tabEl = document.getElementById(id)?.querySelector(selector);
|
|
264
|
+
tabEl.style.cssText = cssShiftRight;
|
|
265
|
+
_shiftedTab = tabEl;
|
|
266
|
+
}
|
|
267
|
+
} else clearShiftedTab();
|
|
268
|
+
}
|
|
269
|
+
function clearShiftedTab() {
|
|
270
|
+
if (_shiftedTab) {
|
|
271
|
+
_shiftedTab.style.cssText = cssShiftBack;
|
|
272
|
+
_shiftedTab = null;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
export default DropTargetCanvas;
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
:root {
|
|
3
|
+
--hw-space-unit: 4px;
|
|
4
|
+
--hw-flex-gap: 3;
|
|
5
|
+
--hw-fluid-grid-col-bg: #c8c8c84d;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.hwFlexbox {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
gap: calc(var(--spacing) * var(--space));
|
|
11
|
+
min-width: 0;
|
|
12
|
+
min-height: 0;
|
|
13
|
+
display: flex;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.hwFlexbox-column {
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.hwFlexbox-row {
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.hwFlexbox > .Splitter {
|
|
26
|
+
flex: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.hwFlexbox.full-page {
|
|
30
|
+
width: 100vw;
|
|
31
|
+
height: 100vh;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.flex-fill {
|
|
35
|
+
border-color: red;
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.vuuView.flex-fill {
|
|
40
|
+
border-color: red;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
`;
|
|
45
|
+
export default css;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useForkRef } from "@salt-ds/core";
|
|
3
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
4
|
+
import { useWindow } from "@salt-ds/window";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { useSplitterResizing } from "./useSplitterResizing.js";
|
|
8
|
+
import Flexbox_0 from "./Flexbox.css";
|
|
9
|
+
const classBase = "hwFlexbox";
|
|
10
|
+
const Flexbox_Flexbox = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
11
|
+
const { breakPoints, children, column, className: classNameProp, flexFill, gap, fullPage, id, onSplitterMoved, resizeable, row, spacing, splitterSize, style, ...htmlAttributes } = props;
|
|
12
|
+
const targetWindow = useWindow();
|
|
13
|
+
useComponentCssInjection({
|
|
14
|
+
testId: "vuu-flexbox",
|
|
15
|
+
css: Flexbox_0,
|
|
16
|
+
window: targetWindow
|
|
17
|
+
});
|
|
18
|
+
const { content, rootRef } = useSplitterResizing({
|
|
19
|
+
children,
|
|
20
|
+
onSplitterMoved,
|
|
21
|
+
style
|
|
22
|
+
});
|
|
23
|
+
const className = clsx(classBase, classNameProp, {
|
|
24
|
+
[`${classBase}-column`]: column,
|
|
25
|
+
[`${classBase}-row`]: row,
|
|
26
|
+
"flex-fill": flexFill,
|
|
27
|
+
"full-page": fullPage
|
|
28
|
+
});
|
|
29
|
+
return /*#__PURE__*/ jsx("div", {
|
|
30
|
+
...htmlAttributes,
|
|
31
|
+
className: className,
|
|
32
|
+
"data-resizeable": resizeable || void 0,
|
|
33
|
+
id: id,
|
|
34
|
+
ref: useForkRef(rootRef, ref),
|
|
35
|
+
style: {
|
|
36
|
+
...style,
|
|
37
|
+
gap,
|
|
38
|
+
"--spacing": spacing
|
|
39
|
+
},
|
|
40
|
+
children: content
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
Flexbox_Flexbox.displayName = "Flexbox";
|
|
44
|
+
var flexbox_Flexbox = Flexbox_Flexbox;
|
|
45
|
+
export default flexbox_Flexbox;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { Action } from "../layout-action.js";
|
|
4
|
+
import { useLayoutProviderDispatch } from "../layout-provider/index.js";
|
|
5
|
+
import { registerComponent } from "@vuu-ui/vuu-utils";
|
|
6
|
+
import Flexbox from "./Flexbox.js";
|
|
7
|
+
const FlexboxLayout_FlexboxLayout = function(props) {
|
|
8
|
+
const { path } = props;
|
|
9
|
+
const dispatch = useLayoutProviderDispatch();
|
|
10
|
+
const handleSplitterMoved = useCallback((sizes)=>{
|
|
11
|
+
dispatch({
|
|
12
|
+
type: Action.SPLITTER_RESIZE,
|
|
13
|
+
path,
|
|
14
|
+
sizes
|
|
15
|
+
});
|
|
16
|
+
}, [
|
|
17
|
+
dispatch,
|
|
18
|
+
path
|
|
19
|
+
]);
|
|
20
|
+
return /*#__PURE__*/ jsx(Flexbox, {
|
|
21
|
+
...props,
|
|
22
|
+
onSplitterMoved: handleSplitterMoved
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
FlexboxLayout_FlexboxLayout.displayName = "Flexbox";
|
|
26
|
+
registerComponent("Flexbox", FlexboxLayout_FlexboxLayout, "container");
|
|
27
|
+
export { FlexboxLayout_FlexboxLayout as FlexboxLayout };
|