@vuu-ui/vuu-layout 2.1.19-beta.2 → 2.1.19-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Component.js +14 -0
- package/cjs/Component.js.map +1 -0
- package/cjs/LayoutContainer.css.js +6 -0
- package/cjs/LayoutContainer.css.js.map +1 -0
- package/cjs/LayoutContainer.js +33 -0
- package/cjs/LayoutContainer.js.map +1 -0
- package/cjs/dock-layout/DockLayout.css.js +6 -0
- package/cjs/dock-layout/DockLayout.css.js.map +1 -0
- package/cjs/dock-layout/DockLayout.js +41 -0
- package/cjs/dock-layout/DockLayout.js.map +1 -0
- package/cjs/dock-layout/Drawer.css.js +6 -0
- package/cjs/dock-layout/Drawer.css.js.map +1 -0
- package/cjs/dock-layout/Drawer.js +95 -0
- package/cjs/dock-layout/Drawer.js.map +1 -0
- package/cjs/drag-drop/BoxModel.js +416 -0
- package/cjs/drag-drop/BoxModel.js.map +1 -0
- package/cjs/drag-drop/DragState.js +161 -0
- package/cjs/drag-drop/DragState.js.map +1 -0
- package/cjs/drag-drop/Draggable.js +192 -0
- package/cjs/drag-drop/Draggable.js.map +1 -0
- package/cjs/drag-drop/DropTarget.js +257 -0
- package/cjs/drag-drop/DropTarget.js.map +1 -0
- package/cjs/drag-drop/DropTargetRenderer.js +218 -0
- package/cjs/drag-drop/DropTargetRenderer.js.map +1 -0
- package/cjs/flexbox/Flexbox.css.js +6 -0
- package/cjs/flexbox/Flexbox.css.js.map +1 -0
- package/cjs/flexbox/Flexbox.js +69 -0
- package/cjs/flexbox/Flexbox.js.map +1 -0
- package/cjs/flexbox/FlexboxLayout.js +30 -0
- package/cjs/flexbox/FlexboxLayout.js.map +1 -0
- package/cjs/flexbox/Splitter.css.js +6 -0
- package/cjs/flexbox/Splitter.css.js.map +1 -0
- package/cjs/flexbox/Splitter.js +122 -0
- package/cjs/flexbox/Splitter.js.map +1 -0
- package/cjs/flexbox/flexbox-utils.js +95 -0
- package/cjs/flexbox/flexbox-utils.js.map +1 -0
- package/cjs/flexbox/useSplitterResizing.js +197 -0
- package/cjs/flexbox/useSplitterResizing.js.map +1 -0
- package/cjs/index.js +122 -0
- package/cjs/index.js.map +1 -0
- package/cjs/layout-action.js +24 -0
- package/cjs/layout-action.js.map +1 -0
- package/cjs/layout-header/Header.css.js +6 -0
- package/cjs/layout-header/Header.css.js.map +1 -0
- package/cjs/layout-header/Header.js +152 -0
- package/cjs/layout-header/Header.js.map +1 -0
- package/cjs/layout-header/useHeader.js +85 -0
- package/cjs/layout-header/useHeader.js.map +1 -0
- package/cjs/layout-provider/LayoutProvider.js +304 -0
- package/cjs/layout-provider/LayoutProvider.js.map +1 -0
- package/cjs/layout-provider/LayoutProviderContext.js +23 -0
- package/cjs/layout-provider/LayoutProviderContext.js.map +1 -0
- package/cjs/layout-provider/useLayoutDragDrop.js +177 -0
- package/cjs/layout-provider/useLayoutDragDrop.js.map +1 -0
- package/cjs/layout-reducer/flexUtils.js +227 -0
- package/cjs/layout-reducer/flexUtils.js.map +1 -0
- package/cjs/layout-reducer/insert-layout-element.js +286 -0
- package/cjs/layout-reducer/insert-layout-element.js.map +1 -0
- package/cjs/layout-reducer/layout-reducer.js +202 -0
- package/cjs/layout-reducer/layout-reducer.js.map +1 -0
- package/cjs/layout-reducer/layoutTypes.js +40 -0
- package/cjs/layout-reducer/layoutTypes.js.map +1 -0
- package/cjs/layout-reducer/layoutUtils.js +237 -0
- package/cjs/layout-reducer/layoutUtils.js.map +1 -0
- package/cjs/layout-reducer/move-layout-element.js +31 -0
- package/cjs/layout-reducer/move-layout-element.js.map +1 -0
- package/cjs/layout-reducer/remove-layout-element.js +237 -0
- package/cjs/layout-reducer/remove-layout-element.js.map +1 -0
- package/cjs/layout-reducer/replace-layout-element.js +96 -0
- package/cjs/layout-reducer/replace-layout-element.js.map +1 -0
- package/cjs/layout-reducer/resize-flex-children.js +62 -0
- package/cjs/layout-reducer/resize-flex-children.js.map +1 -0
- package/cjs/layout-reducer/wrap-layout-element.js +211 -0
- package/cjs/layout-reducer/wrap-layout-element.js.map +1 -0
- package/cjs/layout-view/View.css.js +6 -0
- package/cjs/layout-view/View.css.js.map +1 -0
- package/cjs/layout-view/View.js +160 -0
- package/cjs/layout-view/View.js.map +1 -0
- package/cjs/layout-view/useView.js +75 -0
- package/cjs/layout-view/useView.js.map +1 -0
- package/cjs/layout-view/useViewBroadcastChannel.js +35 -0
- package/cjs/layout-view/useViewBroadcastChannel.js.map +1 -0
- package/cjs/layout-view/useViewResize.js +42 -0
- package/cjs/layout-view/useViewResize.js.map +1 -0
- package/cjs/layout-view-actions/ViewContext.js +16 -0
- package/cjs/layout-view-actions/ViewContext.js.map +1 -0
- package/cjs/layout-view-actions/useViewActionDispatcher.js +112 -0
- package/cjs/layout-view-actions/useViewActionDispatcher.js.map +1 -0
- package/cjs/layout-view-actions/useViewContributions.js +33 -0
- package/cjs/layout-view-actions/useViewContributions.js.map +1 -0
- package/cjs/palette/Palette.css.js +6 -0
- package/cjs/palette/Palette.css.js.map +1 -0
- package/cjs/palette/Palette.js +115 -0
- package/cjs/palette/Palette.js.map +1 -0
- package/cjs/placeholder/LayoutStartPanel.css.js +6 -0
- package/cjs/placeholder/LayoutStartPanel.css.js.map +1 -0
- package/cjs/placeholder/LayoutStartPanel.js +56 -0
- package/cjs/placeholder/LayoutStartPanel.js.map +1 -0
- package/cjs/placeholder/Placeholder.css.js +6 -0
- package/cjs/placeholder/Placeholder.css.js.map +1 -0
- package/cjs/placeholder/Placeholder.js +34 -0
- package/cjs/placeholder/Placeholder.js.map +1 -0
- package/cjs/responsive/useResizeObserver.js +118 -0
- package/cjs/responsive/useResizeObserver.js.map +1 -0
- package/cjs/responsive/utils.js +34 -0
- package/cjs/responsive/utils.js.map +1 -0
- package/cjs/stack/Stack.css.js +6 -0
- package/cjs/stack/Stack.css.js.map +1 -0
- package/cjs/stack/Stack.js +150 -0
- package/cjs/stack/Stack.js.map +1 -0
- package/cjs/stack/StackLayout.js +116 -0
- package/cjs/stack/StackLayout.js.map +1 -0
- package/cjs/use-persistent-state.js +63 -0
- package/cjs/use-persistent-state.js.map +1 -0
- package/cjs/utils/pathUtils.js +293 -0
- package/cjs/utils/pathUtils.js.map +1 -0
- package/cjs/utils/propUtils.js +27 -0
- package/cjs/utils/propUtils.js.map +1 -0
- package/cjs/utils/refUtils.js +12 -0
- package/cjs/utils/refUtils.js.map +1 -0
- package/cjs/utils/styleUtils.js +15 -0
- package/cjs/utils/styleUtils.js.map +1 -0
- package/cjs/utils/typeOf.js +27 -0
- package/cjs/utils/typeOf.js.map +1 -0
- package/esm/Component.js +12 -0
- package/esm/Component.js.map +1 -0
- package/esm/LayoutContainer.css.js +4 -0
- package/esm/LayoutContainer.css.js.map +1 -0
- package/esm/LayoutContainer.js +31 -0
- package/esm/LayoutContainer.js.map +1 -0
- package/esm/dock-layout/DockLayout.css.js +4 -0
- package/esm/dock-layout/DockLayout.css.js.map +1 -0
- package/esm/dock-layout/DockLayout.js +39 -0
- package/esm/dock-layout/DockLayout.js.map +1 -0
- package/esm/dock-layout/Drawer.css.js +4 -0
- package/esm/dock-layout/Drawer.css.js.map +1 -0
- package/esm/dock-layout/Drawer.js +93 -0
- package/esm/dock-layout/Drawer.js.map +1 -0
- package/esm/drag-drop/BoxModel.js +409 -0
- package/esm/drag-drop/BoxModel.js.map +1 -0
- package/esm/drag-drop/DragState.js +159 -0
- package/esm/drag-drop/DragState.js.map +1 -0
- package/esm/drag-drop/Draggable.js +190 -0
- package/esm/drag-drop/Draggable.js.map +1 -0
- package/esm/drag-drop/DropTarget.js +253 -0
- package/esm/drag-drop/DropTarget.js.map +1 -0
- package/esm/drag-drop/DropTargetRenderer.js +216 -0
- package/esm/drag-drop/DropTargetRenderer.js.map +1 -0
- package/esm/flexbox/Flexbox.css.js +4 -0
- package/esm/flexbox/Flexbox.css.js.map +1 -0
- package/esm/flexbox/Flexbox.js +67 -0
- package/esm/flexbox/Flexbox.js.map +1 -0
- package/esm/flexbox/FlexboxLayout.js +28 -0
- package/esm/flexbox/FlexboxLayout.js.map +1 -0
- package/esm/flexbox/Splitter.css.js +4 -0
- package/esm/flexbox/Splitter.css.js.map +1 -0
- package/esm/flexbox/Splitter.js +120 -0
- package/esm/flexbox/Splitter.js.map +1 -0
- package/esm/flexbox/flexbox-utils.js +89 -0
- package/esm/flexbox/flexbox-utils.js.map +1 -0
- package/esm/flexbox/useSplitterResizing.js +195 -0
- package/esm/flexbox/useSplitterResizing.js.map +1 -0
- package/esm/index.js +33 -0
- package/esm/index.js.map +1 -0
- package/esm/layout-action.js +22 -0
- package/esm/layout-action.js.map +1 -0
- package/esm/layout-header/Header.css.js +4 -0
- package/esm/layout-header/Header.css.js.map +1 -0
- package/esm/layout-header/Header.js +150 -0
- package/esm/layout-header/Header.js.map +1 -0
- package/esm/layout-header/useHeader.js +83 -0
- package/esm/layout-header/useHeader.js.map +1 -0
- package/esm/layout-provider/LayoutProvider.js +297 -0
- package/esm/layout-provider/LayoutProvider.js.map +1 -0
- package/esm/layout-provider/LayoutProviderContext.js +20 -0
- package/esm/layout-provider/LayoutProviderContext.js.map +1 -0
- package/esm/layout-provider/useLayoutDragDrop.js +175 -0
- package/esm/layout-provider/useLayoutDragDrop.js.map +1 -0
- package/esm/layout-reducer/flexUtils.js +218 -0
- package/esm/layout-reducer/flexUtils.js.map +1 -0
- package/esm/layout-reducer/insert-layout-element.js +282 -0
- package/esm/layout-reducer/insert-layout-element.js.map +1 -0
- package/esm/layout-reducer/layout-reducer.js +200 -0
- package/esm/layout-reducer/layout-reducer.js.map +1 -0
- package/esm/layout-reducer/layoutTypes.js +36 -0
- package/esm/layout-reducer/layoutTypes.js.map +1 -0
- package/esm/layout-reducer/layoutUtils.js +226 -0
- package/esm/layout-reducer/layoutUtils.js.map +1 -0
- package/esm/layout-reducer/move-layout-element.js +29 -0
- package/esm/layout-reducer/move-layout-element.js.map +1 -0
- package/esm/layout-reducer/remove-layout-element.js +235 -0
- package/esm/layout-reducer/remove-layout-element.js.map +1 -0
- package/esm/layout-reducer/replace-layout-element.js +92 -0
- package/esm/layout-reducer/replace-layout-element.js.map +1 -0
- package/esm/layout-reducer/resize-flex-children.js +59 -0
- package/esm/layout-reducer/resize-flex-children.js.map +1 -0
- package/esm/layout-reducer/wrap-layout-element.js +209 -0
- package/esm/layout-reducer/wrap-layout-element.js.map +1 -0
- package/esm/layout-view/View.css.js +4 -0
- package/esm/layout-view/View.css.js.map +1 -0
- package/esm/layout-view/View.js +158 -0
- package/esm/layout-view/View.js.map +1 -0
- package/esm/layout-view/useView.js +73 -0
- package/esm/layout-view/useView.js.map +1 -0
- package/esm/layout-view/useViewBroadcastChannel.js +33 -0
- package/esm/layout-view/useViewBroadcastChannel.js.map +1 -0
- package/esm/layout-view/useViewResize.js +40 -0
- package/esm/layout-view/useViewResize.js.map +1 -0
- package/esm/layout-view-actions/ViewContext.js +12 -0
- package/esm/layout-view-actions/ViewContext.js.map +1 -0
- package/esm/layout-view-actions/useViewActionDispatcher.js +110 -0
- package/esm/layout-view-actions/useViewActionDispatcher.js.map +1 -0
- package/esm/layout-view-actions/useViewContributions.js +31 -0
- package/esm/layout-view-actions/useViewContributions.js.map +1 -0
- package/esm/palette/Palette.css.js +4 -0
- package/esm/palette/Palette.css.js.map +1 -0
- package/esm/palette/Palette.js +112 -0
- package/esm/palette/Palette.js.map +1 -0
- package/esm/placeholder/LayoutStartPanel.css.js +4 -0
- package/esm/placeholder/LayoutStartPanel.css.js.map +1 -0
- package/esm/placeholder/LayoutStartPanel.js +54 -0
- package/esm/placeholder/LayoutStartPanel.js.map +1 -0
- package/esm/placeholder/Placeholder.css.js +4 -0
- package/esm/placeholder/Placeholder.css.js.map +1 -0
- package/esm/placeholder/Placeholder.js +32 -0
- package/esm/placeholder/Placeholder.js.map +1 -0
- package/esm/responsive/useResizeObserver.js +112 -0
- package/esm/responsive/useResizeObserver.js.map +1 -0
- package/esm/responsive/utils.js +31 -0
- package/esm/responsive/utils.js.map +1 -0
- package/esm/stack/Stack.css.js +4 -0
- package/esm/stack/Stack.css.js.map +1 -0
- package/esm/stack/Stack.js +148 -0
- package/esm/stack/Stack.js.map +1 -0
- package/esm/stack/StackLayout.js +114 -0
- package/esm/stack/StackLayout.js.map +1 -0
- package/esm/use-persistent-state.js +58 -0
- package/esm/use-persistent-state.js.map +1 -0
- package/esm/utils/pathUtils.js +280 -0
- package/esm/utils/pathUtils.js.map +1 -0
- package/esm/utils/propUtils.js +23 -0
- package/esm/utils/propUtils.js.map +1 -0
- package/esm/utils/refUtils.js +10 -0
- package/esm/utils/refUtils.js.map +1 -0
- package/esm/utils/styleUtils.js +13 -0
- package/esm/utils/styleUtils.js.map +1 -0
- package/esm/utils/typeOf.js +23 -0
- package/esm/utils/typeOf.js.map +1 -0
- package/package.json +18 -15
- 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/src/Component.js +0 -14
- package/src/LayoutContainer.css.js +0 -24
- package/src/LayoutContainer.js +0 -26
- package/src/debug.js +0 -16
- package/src/dock-layout/DockLayout.css.js +0 -36
- package/src/dock-layout/DockLayout.js +0 -43
- package/src/dock-layout/Drawer.css.js +0 -150
- package/src/dock-layout/Drawer.js +0 -82
- package/src/dock-layout/index.js +0 -2
- package/src/drag-drop/BoxModel.js +0 -337
- package/src/drag-drop/DragState.js +0 -119
- package/src/drag-drop/Draggable.js +0 -140
- package/src/drag-drop/DropTarget.js +0 -286
- package/src/drag-drop/DropTargetRenderer.js +0 -275
- package/src/drag-drop/dragDropTypes.js +0 -0
- package/src/drag-drop/index.js +0 -3
- package/src/flexbox/Flexbox.css.js +0 -45
- package/src/flexbox/Flexbox.js +0 -45
- package/src/flexbox/FlexboxLayout.js +0 -27
- package/src/flexbox/Splitter.css.js +0 -57
- package/src/flexbox/Splitter.js +0 -112
- package/src/flexbox/flexbox-utils.js +0 -92
- package/src/flexbox/flexboxTypes.js +0 -0
- package/src/flexbox/index.js +0 -2
- package/src/flexbox/useSplitterResizing.js +0 -181
- package/src/index.js +0 -20
- package/src/layout-action.js +0 -20
- package/src/layout-header/ActionButton.js +0 -15
- package/src/layout-header/Header.css.js +0 -32
- package/src/layout-header/Header.js +0 -99
- package/src/layout-header/index.js +0 -1
- package/src/layout-header/useHeader.js +0 -76
- package/src/layout-provider/LayoutProvider.js +0 -242
- package/src/layout-provider/LayoutProviderContext.js +0 -13
- package/src/layout-provider/index.js +0 -2
- package/src/layout-provider/useLayoutDragDrop.js +0 -147
- package/src/layout-reducer/flexUtils.js +0 -186
- package/src/layout-reducer/index.js +0 -4
- package/src/layout-reducer/insert-layout-element.js +0 -179
- package/src/layout-reducer/layout-reducer.js +0 -121
- package/src/layout-reducer/layoutTypes.js +0 -34
- package/src/layout-reducer/layoutUtils.js +0 -178
- package/src/layout-reducer/move-layout-element.js +0 -18
- package/src/layout-reducer/remove-layout-element.js +0 -161
- package/src/layout-reducer/replace-layout-element.js +0 -70
- package/src/layout-reducer/resize-flex-children.js +0 -48
- package/src/layout-reducer/wrap-layout-element.js +0 -134
- package/src/layout-view/View.css.js +0 -76
- package/src/layout-view/View.js +0 -116
- package/src/layout-view/useView.js +0 -69
- package/src/layout-view/useViewBroadcastChannel.js +0 -29
- package/src/layout-view/useViewResize.js +0 -27
- package/src/layout-view/viewTypes.js +0 -0
- package/src/layout-view-actions/ViewContext.js +0 -11
- package/src/layout-view-actions/useViewActionDispatcher.js +0 -116
- package/src/layout-view-actions/useViewContributions.js +0 -31
- package/src/palette/Palette.css.js +0 -31
- package/src/palette/Palette.js +0 -85
- package/src/palette/index.js +0 -1
- package/src/placeholder/LayoutStartPanel.css.js +0 -35
- package/src/placeholder/LayoutStartPanel.js +0 -57
- package/src/placeholder/Placeholder.css.js +0 -20
- package/src/placeholder/Placeholder.js +0 -33
- package/src/placeholder/index.js +0 -1
- package/src/responsive/index.js +0 -2
- package/src/responsive/measureMinimumNodeSize.js +0 -24
- package/src/responsive/useResizeObserver.js +0 -109
- package/src/responsive/utils.js +0 -27
- package/src/stack/Stack.css.js +0 -44
- package/src/stack/Stack.js +0 -98
- package/src/stack/StackLayout.js +0 -116
- package/src/stack/index.js +0 -3
- package/src/stack/stackTypes.js +0 -0
- package/src/tabs/TabPanel.css.js +0 -17
- package/src/tabs/TabPanel.js +0 -11
- package/src/tabs/index.js +0 -1
- package/src/tools/config-wrapper/ConfigWrapper.js +0 -55
- package/src/tools/config-wrapper/index.js +0 -1
- package/src/tools/devtools-box/layout-configurator.css.js +0 -113
- package/src/tools/devtools-tree/layout-tree-viewer.css.js +0 -17
- package/src/tools/index.js +0 -3
- package/src/use-persistent-state.js +0 -43
- package/src/utils/index.js +0 -5
- package/src/utils/pathUtils.js +0 -212
- package/src/utils/propUtils.js +0 -15
- package/src/utils/refUtils.js +0 -5
- package/src/utils/styleUtils.js +0 -9
- package/src/utils/typeOf.js +0 -15
package/src/utils/pathUtils.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { isContainer } from "@vuu-ui/vuu-utils";
|
|
2
|
-
import react, { isValidElement } from "react";
|
|
3
|
-
import { getProp, getProps } from "./propUtils.js";
|
|
4
|
-
import { typeOf } from "./typeOf.js";
|
|
5
|
-
const removeFinalPathSegment = (path)=>{
|
|
6
|
-
const pos = path.lastIndexOf(".");
|
|
7
|
-
if (-1 === pos) return path;
|
|
8
|
-
return path.slice(0, pos);
|
|
9
|
-
};
|
|
10
|
-
const getChildren = (c)=>react.isValidElement(c.props.children) ? [
|
|
11
|
-
c.props.children
|
|
12
|
-
] : c.props.children;
|
|
13
|
-
const resolvePath = (source, path = "")=>{
|
|
14
|
-
const [step1, ...steps] = path.split(".");
|
|
15
|
-
if (step1?.startsWith("#")) {
|
|
16
|
-
const node = findTargetById(source, step1.slice(1), true);
|
|
17
|
-
if (node && steps.length) return resolvePath(node, steps.join("."));
|
|
18
|
-
} else if ("ACTIVE_CHILD" === step1) {
|
|
19
|
-
const { active } = getProps(source);
|
|
20
|
-
const children = getChildren(source);
|
|
21
|
-
const { path } = getProps(children[active]);
|
|
22
|
-
return path;
|
|
23
|
-
}
|
|
24
|
-
return "";
|
|
25
|
-
};
|
|
26
|
-
const resolveJSONPath = (source, path = "")=>{
|
|
27
|
-
const [step1, ...steps] = path.split(".");
|
|
28
|
-
if (step1?.startsWith("#")) {
|
|
29
|
-
const node = findTargetJSONById(source, step1.slice(1), true);
|
|
30
|
-
if (node && steps.length) return resolveJSONPath(node, steps.join("."));
|
|
31
|
-
} else if ("ACTIVE_CHILD" === step1) {
|
|
32
|
-
const { children, props } = source;
|
|
33
|
-
const { active } = props;
|
|
34
|
-
if ("number" == typeof active && children?.[active]) return children[active];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function followPathToParent(source, path) {
|
|
38
|
-
const { "data-path": dataPath, path: sourcePath = dataPath } = getProps(source);
|
|
39
|
-
if ("0" === path) return null;
|
|
40
|
-
if (path === sourcePath) return null;
|
|
41
|
-
return followPath(source, removeFinalPathSegment(path), true);
|
|
42
|
-
}
|
|
43
|
-
function findTarget(source, test) {
|
|
44
|
-
if (source) {
|
|
45
|
-
const { children, ...props } = getProps(source);
|
|
46
|
-
if (test(props)) return source;
|
|
47
|
-
if (react.Children.count(children) > 0) {
|
|
48
|
-
const array = react.isValidElement(children) ? [
|
|
49
|
-
children
|
|
50
|
-
] : children;
|
|
51
|
-
for (const child of array){
|
|
52
|
-
const target = findTarget(child, test);
|
|
53
|
-
if (target) return target;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function containerOf(source, target) {
|
|
59
|
-
if (target === source) return null;
|
|
60
|
-
const { path: sourcePath, children } = getProps(source);
|
|
61
|
-
const { idx, finalStep } = pathUtils_nextStep(sourcePath, getProp(target, "path"));
|
|
62
|
-
if (finalStep) return source;
|
|
63
|
-
if (void 0 === children || void 0 === children[idx]) return null;
|
|
64
|
-
return containerOf(children[idx], target);
|
|
65
|
-
}
|
|
66
|
-
const getChild = (children, idx)=>{
|
|
67
|
-
if (react.isValidElement(children) && 0 == idx) return children;
|
|
68
|
-
if (Array.isArray(children)) return children[idx];
|
|
69
|
-
};
|
|
70
|
-
function followPathToComponent(component, path) {
|
|
71
|
-
const paths = path.split(".");
|
|
72
|
-
let children = [
|
|
73
|
-
component
|
|
74
|
-
];
|
|
75
|
-
for(let i = 0; i < paths.length; i++){
|
|
76
|
-
const idx = parseInt(paths[i]);
|
|
77
|
-
const child = children[idx];
|
|
78
|
-
if (i === paths.length - 1) return child;
|
|
79
|
-
children = getChildren(child);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const findTargetById = (source, id, throwIfNotFound = true)=>{
|
|
83
|
-
const { children, id: idProp } = source.props;
|
|
84
|
-
if (idProp === id) return source;
|
|
85
|
-
if (react.Children.count(children) > 0) {
|
|
86
|
-
const childArray = isValidElement(children) ? [
|
|
87
|
-
children
|
|
88
|
-
] : children;
|
|
89
|
-
for (const child of childArray)if (isValidElement(child)) {
|
|
90
|
-
const target = findTargetById(child, id, false);
|
|
91
|
-
if (target) return target;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (true === throwIfNotFound) throw Error(`pathUtils.findTargetById id #${id} not found in source`);
|
|
95
|
-
};
|
|
96
|
-
const findTargetJSONById = (source, id, throwIfNotFound = true)=>{
|
|
97
|
-
const { children, id: idProp } = source;
|
|
98
|
-
if (idProp === id) return source;
|
|
99
|
-
if (Array.isArray(children) && children.length > 0) {
|
|
100
|
-
for (const child of children)if (null !== child && "object" == typeof child) {
|
|
101
|
-
const target = findTargetJSONById(child, id, false);
|
|
102
|
-
if (target) return target;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (true === throwIfNotFound) throw Error(`pathUtils.findTargetJSONById id #${id} not found in source`);
|
|
106
|
-
};
|
|
107
|
-
function followPath(source, path, throwIfNotFound = false) {
|
|
108
|
-
if (path.startsWith("#")) return findTargetById(source, path.slice(1), throwIfNotFound);
|
|
109
|
-
const { "data-path": dataPath, path: sourcePath = dataPath } = getProps(source);
|
|
110
|
-
if (0 !== path.indexOf(sourcePath)) throw Error(`pathUtils.followPath path ${path} is not within source path ${sourcePath}`);
|
|
111
|
-
const route = path.slice(sourcePath.length + 1);
|
|
112
|
-
if ("" === route) return source;
|
|
113
|
-
let target = source;
|
|
114
|
-
const paths = route.split(".");
|
|
115
|
-
for(let i = 0; i < paths.length; i++){
|
|
116
|
-
if (0 === react.Children.count(target.props.children)) {
|
|
117
|
-
const message = `element at 0.${paths.slice(0, i).join(".")} has no children, so cannot fulfill rest of path ${paths.slice(i).join(".")}`;
|
|
118
|
-
if (!throwIfNotFound) return void console.warn(message);
|
|
119
|
-
throw Error(message);
|
|
120
|
-
}
|
|
121
|
-
target = getChild(target.props.children, parseInt(paths[i]));
|
|
122
|
-
if (void 0 === target) {
|
|
123
|
-
const message = `model at 0.${paths.slice(0, i).join(".")} has no children that fulfill next step of path ${paths.slice(i).join(".")}`;
|
|
124
|
-
if (throwIfNotFound) throw Error(message);
|
|
125
|
-
console.warn(message);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return target;
|
|
129
|
-
}
|
|
130
|
-
function nextLeaf(root, path) {
|
|
131
|
-
const parent = followPathToParent(root, path);
|
|
132
|
-
let pathIndices = path.split(".").map((idx)=>parseInt(idx, 10));
|
|
133
|
-
if (parent) {
|
|
134
|
-
const lastIdx = pathIndices.pop();
|
|
135
|
-
const { children } = parent.props;
|
|
136
|
-
if (children.length - 1 > lastIdx) return firstLeaf(children[lastIdx + 1]);
|
|
137
|
-
{
|
|
138
|
-
const parentIdx = pathIndices.pop();
|
|
139
|
-
const nextParent = followPathToParent(root, getProp(parent, "path"));
|
|
140
|
-
if (nextParent && "number" == typeof parentIdx) {
|
|
141
|
-
pathIndices = nextParent.props.path.split(".").map((idx)=>parseInt(idx, 10));
|
|
142
|
-
if (nextParent.props.children.length - 1 > parentIdx) {
|
|
143
|
-
const nextStep = nextParent.props.children[parentIdx + 1];
|
|
144
|
-
if (isContainer(typeOf(nextStep))) return firstLeaf(nextStep);
|
|
145
|
-
return nextStep;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return firstLeaf(root);
|
|
151
|
-
}
|
|
152
|
-
function previousLeaf(root, path) {
|
|
153
|
-
const pathIndices = path.split(".").map((idx)=>parseInt(idx, 10));
|
|
154
|
-
let lastIdx = pathIndices.pop();
|
|
155
|
-
let parent = followPathToParent(root, path);
|
|
156
|
-
if (null != parent && "number" == typeof lastIdx) {
|
|
157
|
-
const { children } = parent.props;
|
|
158
|
-
if (lastIdx > 0) return lastLeaf(children[lastIdx - 1]);
|
|
159
|
-
while(pathIndices.length > 1){
|
|
160
|
-
lastIdx = pathIndices.pop();
|
|
161
|
-
parent = followPathToParent(root, getProp(parent, "path"));
|
|
162
|
-
if (lastIdx > 0) {
|
|
163
|
-
const nextStep = parent.props.children[lastIdx - 1];
|
|
164
|
-
if (isContainer(typeOf(nextStep))) return lastLeaf(nextStep);
|
|
165
|
-
return nextStep;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return lastLeaf(root);
|
|
170
|
-
}
|
|
171
|
-
function firstLeaf(layoutRoot) {
|
|
172
|
-
if (isContainer(typeOf(layoutRoot))) {
|
|
173
|
-
const { children } = layoutRoot.props || layoutRoot;
|
|
174
|
-
return firstLeaf(children[0]);
|
|
175
|
-
}
|
|
176
|
-
return layoutRoot;
|
|
177
|
-
}
|
|
178
|
-
function lastLeaf(root) {
|
|
179
|
-
if (isContainer(typeOf(root))) {
|
|
180
|
-
const { children } = root.props || root;
|
|
181
|
-
return lastLeaf(children[children.length - 1]);
|
|
182
|
-
}
|
|
183
|
-
return root;
|
|
184
|
-
}
|
|
185
|
-
function pathUtils_nextStep(pathSoFar, targetPath, followPathToEnd = false) {
|
|
186
|
-
if (pathSoFar === targetPath) return {
|
|
187
|
-
idx: -1,
|
|
188
|
-
finalStep: true
|
|
189
|
-
};
|
|
190
|
-
const pathVisited = `${pathSoFar}.`;
|
|
191
|
-
if (!targetPath.startsWith(pathVisited)) throw Error("pathUtils nextStep has strayed from the path");
|
|
192
|
-
const endOfTheLine = followPathToEnd ? 0 : 1;
|
|
193
|
-
const paths = targetPath.replace(pathVisited, "").split(".").map((n)=>parseInt(n, 10));
|
|
194
|
-
return {
|
|
195
|
-
idx: paths[0],
|
|
196
|
-
finalStep: paths.length === endOfTheLine
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
function resetPath(model, path, additionalProps) {
|
|
200
|
-
if (getProp(model, "path") === path) return model;
|
|
201
|
-
const children = [];
|
|
202
|
-
react.Children.forEach(model.props.children, (child, i)=>{
|
|
203
|
-
if (getProp(child, "path")) children.push(resetPath(child, `${path}.${i}`));
|
|
204
|
-
else children.push(child);
|
|
205
|
-
});
|
|
206
|
-
const pathPropName = model.props["data-path"] ? "data-path" : "path";
|
|
207
|
-
return react.cloneElement(model, {
|
|
208
|
-
[pathPropName]: path,
|
|
209
|
-
...additionalProps
|
|
210
|
-
}, children);
|
|
211
|
-
}
|
|
212
|
-
export { containerOf, findTarget, followPath, followPathToComponent, followPathToParent, getChild, nextLeaf, pathUtils_nextStep as nextStep, previousLeaf, resetPath, resolveJSONPath, resolvePath };
|
package/src/utils/propUtils.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const NO_PROPS = {};
|
|
2
|
-
const getProp = (component, propName)=>{
|
|
3
|
-
const props = getProps(component);
|
|
4
|
-
return props[propName] ?? props[`data-${propName}`];
|
|
5
|
-
};
|
|
6
|
-
const getProps = (component)=>component?.props || component || NO_PROPS;
|
|
7
|
-
const getChildProp = (container)=>{
|
|
8
|
-
const props = getProps(container);
|
|
9
|
-
if (props.children) {
|
|
10
|
-
const { children: [target, ...rest] } = props;
|
|
11
|
-
if (rest.length > 0) console.warn(`getChild expected a single child, found ${rest.length + 1}`);
|
|
12
|
-
return target;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
export { getChildProp, getProp, getProps };
|
package/src/utils/refUtils.js
DELETED
package/src/utils/styleUtils.js
DELETED
package/src/utils/typeOf.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function typeOf(element) {
|
|
2
|
-
if (element) {
|
|
3
|
-
const type = element.type;
|
|
4
|
-
if ("function" == typeof type || "object" == typeof type) {
|
|
5
|
-
const elementName = type.displayName || type.name || type.type?.name;
|
|
6
|
-
if ("string" == typeof elementName) return elementName;
|
|
7
|
-
}
|
|
8
|
-
if ("string" == typeof element.type) return element.type;
|
|
9
|
-
if (element.constructor) return element.constructor.displayName;
|
|
10
|
-
throw Error("typeOf unable to determine type of element");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const isTypeOf = (element, type)=>typeOf(element) === type;
|
|
14
|
-
const isLayoutJSON = (layout)=>void 0 !== layout && "type" in layout;
|
|
15
|
-
export { isLayoutJSON, isTypeOf, typeOf };
|