@vuu-ui/vuu-layout 0.13.4 → 0.13.6
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/layout-provider/LayoutProvider.js +0 -1
- package/cjs/layout-provider/LayoutProvider.js.map +1 -1
- package/esm/layout-provider/LayoutProvider.js +0 -1
- package/esm/layout-provider/LayoutProvider.js.map +1 -1
- package/package.json +14 -12
- package/types/Component.d.ts +6 -0
- package/types/LayoutContainer.d.ts +6 -0
- package/types/debug.d.ts +2 -0
- package/types/dock-layout/DockLayout.d.ts +7 -0
- package/types/dock-layout/Drawer.d.ts +17 -0
- package/types/dock-layout/index.d.ts +2 -0
- package/types/drag-drop/BoxModel.d.ts +143 -0
- package/types/drag-drop/DragState.d.ts +46 -0
- package/types/drag-drop/Draggable.d.ts +24 -0
- package/types/drag-drop/DropTarget.d.ts +60 -0
- package/types/drag-drop/DropTargetRenderer.d.ts +17 -0
- package/types/drag-drop/dragDropTypes.d.ts +51 -0
- package/types/drag-drop/index.d.ts +3 -0
- package/types/flexbox/Flexbox.d.ts +3 -0
- package/types/flexbox/FlexboxLayout.d.ts +5 -0
- package/types/flexbox/Splitter.d.ts +12 -0
- package/types/flexbox/flexbox-utils.d.ts +12 -0
- package/types/flexbox/flexboxTypes.d.ts +52 -0
- package/types/flexbox/index.d.ts +2 -0
- package/types/flexbox/useSplitterResizing.d.ts +2 -0
- package/types/index.d.ts +17 -0
- package/types/layout-action.d.ts +19 -0
- package/types/layout-header/ActionButton.d.ts +8 -0
- package/types/layout-header/Header.d.ts +15 -0
- package/types/layout-header/index.d.ts +1 -0
- package/types/layout-header/useHeader.d.ts +20 -0
- package/types/layout-provider/LayoutProvider.d.ts +20 -0
- package/types/layout-provider/LayoutProviderContext.d.ts +15 -0
- package/types/layout-provider/index.d.ts +2 -0
- package/types/layout-provider/useLayoutDragDrop.d.ts +4 -0
- package/types/layout-reducer/flexUtils.d.ts +22 -0
- package/types/layout-reducer/index.d.ts +4 -0
- package/types/layout-reducer/insert-layout-element.d.ts +8 -0
- package/types/layout-reducer/layout-reducer.d.ts +3 -0
- package/types/layout-reducer/layoutTypes.d.ts +135 -0
- package/types/layout-reducer/layoutUtils.d.ts +44 -0
- package/types/layout-reducer/move-layout-element.d.ts +3 -0
- package/types/layout-reducer/remove-layout-element.d.ts +3 -0
- package/types/layout-reducer/replace-layout-element.d.ts +6 -0
- package/types/layout-reducer/resize-flex-children.d.ts +4 -0
- package/types/layout-reducer/wrap-layout-element.d.ts +9 -0
- package/types/layout-view/View.d.ts +10 -0
- package/types/layout-view/index.d.ts +3 -0
- package/types/layout-view/useView.d.ts +22 -0
- package/types/layout-view/useViewBroadcastChannel.d.ts +7 -0
- package/types/layout-view/useViewResize.d.ts +7 -0
- package/types/layout-view/viewTypes.d.ts +48 -0
- package/types/layout-view-actions/ViewContext.d.ts +37 -0
- package/types/layout-view-actions/index.d.ts +2 -0
- package/types/layout-view-actions/useViewActionDispatcher.d.ts +4 -0
- package/types/palette/Palette.d.ts +24 -0
- package/types/palette/index.d.ts +1 -0
- package/types/placeholder/LayoutStartPanel.d.ts +5 -0
- package/types/placeholder/Placeholder.d.ts +16 -0
- package/types/placeholder/index.d.ts +1 -0
- package/types/responsive/index.d.ts +2 -0
- package/types/responsive/measureMinimumNodeSize.d.ts +1 -0
- package/types/responsive/overflowUtils.d.ts +2 -0
- package/types/responsive/useResizeObserver.d.ts +13 -0
- package/types/responsive/utils.d.ts +6 -0
- package/types/stack/Stack.d.ts +3 -0
- package/types/stack/StackLayout.d.ts +5 -0
- package/types/stack/index.d.ts +3 -0
- package/types/stack/stackTypes.d.ts +24 -0
- package/types/tabs/TabPanel.d.ts +7 -0
- package/types/tabs/index.d.ts +1 -0
- package/types/tools/config-wrapper/ConfigWrapper.d.ts +1 -0
- package/types/tools/config-wrapper/index.d.ts +1 -0
- package/types/tools/devtools-box/layout-configurator.d.ts +31 -0
- package/types/tools/devtools-tree/layout-tree-viewer.d.ts +5 -0
- package/types/tools/index.d.ts +3 -0
- package/types/use-persistent-state.d.ts +11 -0
- package/types/utils/index.d.ts +5 -0
- package/types/utils/pathUtils.d.ts +31 -0
- package/types/utils/propUtils.d.ts +5 -0
- package/types/utils/refUtils.d.ts +2 -0
- package/types/utils/styleUtils.d.ts +3 -0
- package/types/utils/typeOf.d.ts +5 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
export type SplitterDragStartHandler = (index: number) => void;
|
|
3
|
+
export type SplitterDragHandler = (index: number, distance: number) => void;
|
|
4
|
+
export type SplitterDragEndHandler = () => void;
|
|
5
|
+
export interface SplitterProps extends Omit<HTMLAttributes<HTMLDivElement>, "onDrag" | "onDragStart"> {
|
|
6
|
+
column: boolean;
|
|
7
|
+
index: number;
|
|
8
|
+
onDragStart: SplitterDragStartHandler;
|
|
9
|
+
onDrag: SplitterDragHandler;
|
|
10
|
+
onDragEnd: SplitterDragEndHandler;
|
|
11
|
+
}
|
|
12
|
+
export declare const Splitter: React.NamedExoticComponent<SplitterProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import type { BreakPoint, ContentMeta } from "./flexboxTypes";
|
|
3
|
+
export declare const SPLITTER = 1;
|
|
4
|
+
export declare const PLACEHOLDER = 2;
|
|
5
|
+
export declare const gatherChildMeta: (children: ReactElement[], dimension: "width" | "height", breakPoints?: BreakPoint[]) => {
|
|
6
|
+
index: number;
|
|
7
|
+
flexOpen: boolean;
|
|
8
|
+
intrinsicSize: number | undefined;
|
|
9
|
+
resizeable: any;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const findSplitterAndPlaceholderPositions: (childMeta: ContentMeta[]) => any[];
|
|
12
|
+
export declare const identifyResizeParties: (contentMeta: ContentMeta[], idx: number) => (number[] | undefined)[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CSSProperties, HTMLAttributes, MutableRefObject, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { SplitterProps } from "./Splitter";
|
|
3
|
+
export interface LayoutContainerProps {
|
|
4
|
+
resizeable?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type SplitterMoveHandler = (content: ContentMeta[]) => void;
|
|
7
|
+
export interface FlexboxProps extends LayoutContainerProps, HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
breakPoints?: BreakPointsProp;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
cols?: number;
|
|
11
|
+
column?: true;
|
|
12
|
+
fullPage?: number;
|
|
13
|
+
flexFill?: boolean;
|
|
14
|
+
gap?: number;
|
|
15
|
+
onSplitterMoved?: SplitterMoveHandler;
|
|
16
|
+
row?: true;
|
|
17
|
+
spacing?: number;
|
|
18
|
+
splitterSize?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface FlexboxLayoutProps extends FlexboxProps {
|
|
21
|
+
path?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SplitterHookProps {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
onSplitterMoved?: (content: ContentMeta[]) => void;
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface SplitterHookResult {
|
|
29
|
+
content: ReactElement[];
|
|
30
|
+
rootRef: MutableRefObject<HTMLDivElement | null>;
|
|
31
|
+
}
|
|
32
|
+
export type SplitterFactory = (index: number) => ReactElement<SplitterProps>;
|
|
33
|
+
export type ContentMeta = {
|
|
34
|
+
currentSize?: number;
|
|
35
|
+
flexOpen?: boolean;
|
|
36
|
+
flexBasis?: number;
|
|
37
|
+
intrinsicSize?: number;
|
|
38
|
+
minSize?: number;
|
|
39
|
+
placeholder?: boolean;
|
|
40
|
+
resizeable?: boolean;
|
|
41
|
+
shim?: boolean;
|
|
42
|
+
splitter?: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type FlexSize = {
|
|
45
|
+
size: number;
|
|
46
|
+
minSize: number;
|
|
47
|
+
};
|
|
48
|
+
export type BreakPoint = "xs" | "sm" | "md" | "lg" | "xl";
|
|
49
|
+
export type BreakPoints = BreakPoint[];
|
|
50
|
+
export type BreakPointsProp = {
|
|
51
|
+
[keys in BreakPoint]?: number;
|
|
52
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./dock-layout";
|
|
2
|
+
export { default as Component } from "./Component";
|
|
3
|
+
export * from "./drag-drop";
|
|
4
|
+
export * from "./LayoutContainer";
|
|
5
|
+
export * from "./flexbox";
|
|
6
|
+
export { Action } from "./layout-action";
|
|
7
|
+
export * from "./layout-header";
|
|
8
|
+
export * from "./layout-provider";
|
|
9
|
+
export * from "./layout-reducer";
|
|
10
|
+
export * from "./layout-view";
|
|
11
|
+
export * from "./layout-view-actions";
|
|
12
|
+
export * from "./palette";
|
|
13
|
+
export * from "./placeholder";
|
|
14
|
+
export * from "./responsive";
|
|
15
|
+
export * from "./stack";
|
|
16
|
+
export * from "./use-persistent-state";
|
|
17
|
+
export * from "./utils";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const Action: {
|
|
2
|
+
ADD: string;
|
|
3
|
+
BLUR: string;
|
|
4
|
+
BLUR_SPLITTER: string;
|
|
5
|
+
DRAG_START: string;
|
|
6
|
+
DRAG_STARTED: string;
|
|
7
|
+
DRAG_DROP: string;
|
|
8
|
+
FOCUS: string;
|
|
9
|
+
FOCUS_SPLITTER: string;
|
|
10
|
+
INITIALIZE: string;
|
|
11
|
+
LAYOUT_RESIZE: string;
|
|
12
|
+
MAXIMIZE: string;
|
|
13
|
+
MINIMIZE: string;
|
|
14
|
+
REMOVE: string;
|
|
15
|
+
REPLACE: string;
|
|
16
|
+
RESTORE: string;
|
|
17
|
+
SAVE: string;
|
|
18
|
+
SPLITTER_RESIZE: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLAttributes, MouseEvent } from "react";
|
|
2
|
+
export interface ActionButtonProps extends Omit<HTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
3
|
+
actionId: "maximize" | "minimize" | "restore" | "tearout";
|
|
4
|
+
iconName?: string;
|
|
5
|
+
onClick: (evt: MouseEvent, actionId: "maximize" | "minimize" | "restore" | "tearout") => void;
|
|
6
|
+
}
|
|
7
|
+
declare const ActionButton: ({ actionId, className, iconName, onClick, ...props }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default ActionButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { Contribution } from "../layout-view";
|
|
3
|
+
export interface HeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
allowRename?: boolean;
|
|
5
|
+
collapsed?: boolean;
|
|
6
|
+
contributions?: Contribution[];
|
|
7
|
+
expanded?: boolean;
|
|
8
|
+
closeable?: boolean;
|
|
9
|
+
onCollapse?: () => void;
|
|
10
|
+
onEditTitle?: (value: string) => void;
|
|
11
|
+
onExpand?: () => void;
|
|
12
|
+
orientation?: "horizontal" | "vertical";
|
|
13
|
+
tearOut?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const Header: ({ allowRename, className: classNameProp, contributions, collapsed, closeable, onCollapse, onEditTitle, onExpand, orientation: orientationProp, style, title, }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Header';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { KeyboardEvent, MouseEventHandler } from "react";
|
|
2
|
+
import type { HeaderProps } from "./Header";
|
|
3
|
+
export interface HeaderHookProps extends Pick<HeaderProps, "onCollapse" | "onEditTitle" | "onExpand"> {
|
|
4
|
+
debugString?: string;
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useHeader: ({ onCollapse, onEditTitle, onExpand, title, }: HeaderHookProps) => {
|
|
8
|
+
editing: boolean;
|
|
9
|
+
focusTitle: () => void;
|
|
10
|
+
labelFieldRef: import("react").RefObject<HTMLDivElement | null>;
|
|
11
|
+
onClickEdit: () => void;
|
|
12
|
+
onClose: MouseEventHandler;
|
|
13
|
+
onExitEditMode: (originalValue?: string, finalValue?: string, allowDeactivation?: boolean, editCancelled?: boolean) => void;
|
|
14
|
+
onMouseDown: MouseEventHandler;
|
|
15
|
+
onToggleCollapse: MouseEventHandler;
|
|
16
|
+
onToggleExpand: MouseEventHandler;
|
|
17
|
+
onTitleKeyDown: (evt: KeyboardEvent<HTMLDivElement>) => void;
|
|
18
|
+
setValue: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
19
|
+
value: string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LayoutJSON } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import { type ReactElement } from "react";
|
|
3
|
+
import { type LayoutChangeHandler } from "../layout-reducer";
|
|
4
|
+
import { LayoutProviderDispatch } from "./LayoutProviderContext";
|
|
5
|
+
export interface LayoutProviderProps {
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
createNewChild?: (index?: number) => ReactElement;
|
|
8
|
+
workspaceJSON?: LayoutJSON | LayoutJSON[];
|
|
9
|
+
onLayoutChange?: LayoutChangeHandler;
|
|
10
|
+
}
|
|
11
|
+
export declare const LayoutProviderVersion: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const LayoutProvider: (props: LayoutProviderProps) => ReactElement;
|
|
13
|
+
export declare const useLayoutProviderDispatch: () => LayoutProviderDispatch;
|
|
14
|
+
export declare const useLayoutOperation: () => {
|
|
15
|
+
addComponentToWorkspace: (component: ReactElement) => void;
|
|
16
|
+
showComponentInContextPanel: (component: ReactElement | LayoutJSON, title?: string, onContextPanelClose?: () => void) => void;
|
|
17
|
+
switchWorkspace: (idx: number) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const useLayoutCreateNewChild: () => (index?: number) => ReactElement;
|
|
20
|
+
export declare const useLayoutProviderVersion: () => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dispatch, ReactElement } from "react";
|
|
2
|
+
import { DragStartAction, LayoutReducerAction, QueryAction } from "../layout-reducer";
|
|
3
|
+
import { SaveAction } from "../layout-view";
|
|
4
|
+
import { LayoutJSON } from "@vuu-ui/vuu-utils";
|
|
5
|
+
export declare const isUnconfiguredProperty: (property: unknown) => boolean;
|
|
6
|
+
export type LayoutProviderDispatch = Dispatch<LayoutReducerAction | SaveAction | DragStartAction | QueryAction>;
|
|
7
|
+
export interface LayoutProviderContextProps {
|
|
8
|
+
addComponentToWorkspace: (component: ReactElement) => void;
|
|
9
|
+
createNewChild?: (index?: number) => ReactElement;
|
|
10
|
+
dispatchLayoutProvider: LayoutProviderDispatch;
|
|
11
|
+
showComponentInContextPanel: (component: ReactElement | LayoutJSON, title?: string, onContextPanelClose?: () => void) => void;
|
|
12
|
+
switchWorkspace: (idx: number) => void;
|
|
13
|
+
version: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const LayoutProviderContext: import("react").Context<LayoutProviderContextProps>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MutableRefObject, ReactElement } from "react";
|
|
2
|
+
import { DragStartAction } from "../layout-reducer";
|
|
3
|
+
import { LayoutProviderDispatch } from "./LayoutProviderContext";
|
|
4
|
+
export declare const useLayoutDragDrop: (rootLayoutRef: MutableRefObject<ReactElement>, dispatch: LayoutProviderDispatch, pathToDropTarget?: string) => (action: DragStartAction) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { dimension, rect, rectTuple } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import React, { CSSProperties, ReactElement, ReactNode } from "react";
|
|
3
|
+
import { DropPos } from "../drag-drop/dragDropTypes";
|
|
4
|
+
export type flexDirection = "row" | "column";
|
|
5
|
+
type contraDimension = dimension;
|
|
6
|
+
type flexDimensionTuple = [dimension, contraDimension, flexDirection];
|
|
7
|
+
export type position = {
|
|
8
|
+
height?: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const getFlexDimensions: (flexDirection?: flexDirection) => flexDimensionTuple;
|
|
12
|
+
export declare const getIntrinsicSize: (component: ReactElement) => {
|
|
13
|
+
height?: number;
|
|
14
|
+
width?: number;
|
|
15
|
+
} | undefined;
|
|
16
|
+
export declare function getFlexStyle(component: ReactElement, dimension: dimension, pos?: DropPos): any;
|
|
17
|
+
export declare function hasUnboundedFlexStyle(component: ReactElement): boolean;
|
|
18
|
+
export declare function getFlexOrIntrinsicStyle(component: ReactElement, dimension: dimension, pos: position): any;
|
|
19
|
+
export declare function wrapIntrinsicSizeComponentWithFlexbox(component: ReactElement, flexDirection: flexDirection, path: string, clientRect?: rect, dropRect?: rectTuple): React.FunctionComponentElement<any>;
|
|
20
|
+
export declare function createFlexbox(flexDirection: flexDirection, props: any, children: ReactNode, path: string): React.FunctionComponentElement<any>;
|
|
21
|
+
export declare function createPlaceHolder(path: string, size: number, style?: CSSProperties, props?: any): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LayoutModel } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { DropPos } from "../drag-drop";
|
|
4
|
+
type insertionPosition = "before" | "after";
|
|
5
|
+
export declare function getInsertTabBeforeAfter(stack: LayoutModel, pos: DropPos): any[];
|
|
6
|
+
export declare function insertIntoContainer(container: ReactElement, targetContainer: ReactElement, newComponent: ReactElement | ReactElement[]): ReactElement;
|
|
7
|
+
export declare function insertBesideChild(container: ReactElement, existingComponent: any, newComponent: any, insertionPosition: insertionPosition, pos?: DropPos, clientRect?: any, dropRect?: any): ReactElement;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { LayoutJSON } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { DragDropRect, DragInstructions } from "../drag-drop";
|
|
4
|
+
import { DropTarget } from "../drag-drop/DropTarget";
|
|
5
|
+
export type layoutType = "Flexbox" | "View" | "LayoutContainer" | "Stack";
|
|
6
|
+
export declare const LayoutActionType: {
|
|
7
|
+
readonly ADD: "add";
|
|
8
|
+
readonly DRAG_START: "drag-start";
|
|
9
|
+
readonly DRAG_DROP: "drag-drop";
|
|
10
|
+
readonly LAYOUT_RESIZE: "layout-resize";
|
|
11
|
+
readonly MAXIMIZE: "maximize";
|
|
12
|
+
readonly MINIMIZE: "minimize";
|
|
13
|
+
readonly MOVE_CHILD: "move-child";
|
|
14
|
+
readonly QUERY: "query";
|
|
15
|
+
readonly REMOVE: "remove";
|
|
16
|
+
readonly REPLACE: "replace";
|
|
17
|
+
readonly RESTORE: "restore";
|
|
18
|
+
readonly SET_PROP: "set-prop";
|
|
19
|
+
readonly SET_PROPS: "set-props";
|
|
20
|
+
readonly SET_TITLE: "set-title";
|
|
21
|
+
readonly SPLITTER_RESIZE: "splitter-resize";
|
|
22
|
+
readonly SWITCH_TAB: "switch-tab";
|
|
23
|
+
readonly TEAROUT: "tearout";
|
|
24
|
+
};
|
|
25
|
+
export type AddAction = {
|
|
26
|
+
component: any;
|
|
27
|
+
path: string;
|
|
28
|
+
type: typeof LayoutActionType.ADD;
|
|
29
|
+
};
|
|
30
|
+
export type DragDropAction = {
|
|
31
|
+
draggedReactElement: ReactElement;
|
|
32
|
+
dragInstructions: any;
|
|
33
|
+
dropTarget: Partial<DropTarget>;
|
|
34
|
+
type: typeof LayoutActionType.DRAG_DROP;
|
|
35
|
+
};
|
|
36
|
+
export type MaximizeAction = {
|
|
37
|
+
path?: string;
|
|
38
|
+
type: typeof LayoutActionType.MAXIMIZE;
|
|
39
|
+
};
|
|
40
|
+
export type CollapseAction = {
|
|
41
|
+
path?: string;
|
|
42
|
+
type: "collapse";
|
|
43
|
+
};
|
|
44
|
+
export type ExpandAction = {
|
|
45
|
+
path?: string;
|
|
46
|
+
type: "expand";
|
|
47
|
+
};
|
|
48
|
+
export type MoveChildAction = {
|
|
49
|
+
fromIndex: number;
|
|
50
|
+
toIndex: number;
|
|
51
|
+
path: string;
|
|
52
|
+
type: typeof LayoutActionType.MOVE_CHILD;
|
|
53
|
+
};
|
|
54
|
+
export type QueryAction = {
|
|
55
|
+
path?: string;
|
|
56
|
+
query: string;
|
|
57
|
+
type: typeof LayoutActionType.QUERY;
|
|
58
|
+
};
|
|
59
|
+
export type RemoveAction = {
|
|
60
|
+
path?: string;
|
|
61
|
+
type: typeof LayoutActionType.REMOVE;
|
|
62
|
+
};
|
|
63
|
+
export type ReplaceAction = {
|
|
64
|
+
replacement: any;
|
|
65
|
+
target: any;
|
|
66
|
+
type: typeof LayoutActionType.REPLACE;
|
|
67
|
+
};
|
|
68
|
+
export type RestoreAction = {
|
|
69
|
+
path?: string;
|
|
70
|
+
type: typeof LayoutActionType.RESTORE;
|
|
71
|
+
};
|
|
72
|
+
export type SetPropAction = {
|
|
73
|
+
path: string;
|
|
74
|
+
propName: string;
|
|
75
|
+
propValue: string | number | boolean;
|
|
76
|
+
type: typeof LayoutActionType.SET_PROP;
|
|
77
|
+
};
|
|
78
|
+
export type SetPropsAction = {
|
|
79
|
+
path: string;
|
|
80
|
+
props: {
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
};
|
|
83
|
+
type: typeof LayoutActionType.SET_PROPS;
|
|
84
|
+
};
|
|
85
|
+
export type SetTitleAction = {
|
|
86
|
+
path: string;
|
|
87
|
+
title: string;
|
|
88
|
+
type: typeof LayoutActionType.SET_TITLE;
|
|
89
|
+
};
|
|
90
|
+
export type SplitterResizeAction = {
|
|
91
|
+
path: string;
|
|
92
|
+
sizes: {
|
|
93
|
+
currentSize: number;
|
|
94
|
+
flexBasis: number;
|
|
95
|
+
}[];
|
|
96
|
+
type: typeof LayoutActionType.SPLITTER_RESIZE;
|
|
97
|
+
};
|
|
98
|
+
export type LayoutResizeAction = {
|
|
99
|
+
path: string;
|
|
100
|
+
size: number;
|
|
101
|
+
type: typeof LayoutActionType.LAYOUT_RESIZE;
|
|
102
|
+
};
|
|
103
|
+
export type SwitchTabAction = {
|
|
104
|
+
id?: string;
|
|
105
|
+
nextIdx: number;
|
|
106
|
+
path: string;
|
|
107
|
+
type: typeof LayoutActionType.SWITCH_TAB;
|
|
108
|
+
};
|
|
109
|
+
export type TearoutAction = {
|
|
110
|
+
path?: string;
|
|
111
|
+
type: typeof LayoutActionType.TEAROUT;
|
|
112
|
+
};
|
|
113
|
+
export type LayoutReducerAction = AddAction | DragDropAction | LayoutResizeAction | CollapseAction | ExpandAction | MoveChildAction | RemoveAction | ReplaceAction | RestoreAction | SetPropAction | SetPropsAction | SetTitleAction | SplitterResizeAction | SwitchTabAction;
|
|
114
|
+
export type MousedownViewAction = {
|
|
115
|
+
preDragActivity?: unknown;
|
|
116
|
+
index?: number;
|
|
117
|
+
type: "mousedown";
|
|
118
|
+
};
|
|
119
|
+
export type DragStartAction = {
|
|
120
|
+
payload?: ReactElement;
|
|
121
|
+
dragContainerPath?: string;
|
|
122
|
+
dragElement?: HTMLElement;
|
|
123
|
+
dragRect: DragDropRect;
|
|
124
|
+
dropTargets?: string[];
|
|
125
|
+
evt: MouseEvent;
|
|
126
|
+
instructions?: DragInstructions;
|
|
127
|
+
path: string;
|
|
128
|
+
type: typeof LayoutActionType.DRAG_START;
|
|
129
|
+
};
|
|
130
|
+
export type LayoutLevelChange = "add-component" | "drag-drop-operation" | "edit-feature-title" | "remove-component" | "resize-component" | "switch-active-tab" | "save-feature-props";
|
|
131
|
+
export type ApplicationLevelChange = "switch-active-layout" | "open-layout" | "close-layout" | "rename-layout" | "resize-application-chrome";
|
|
132
|
+
export type LayoutChangeReason = LayoutLevelChange | ApplicationLevelChange;
|
|
133
|
+
export type LayoutChangeHandler = (layout: LayoutJSON, layoutChangeReason: LayoutChangeReason) => void;
|
|
134
|
+
export declare const isApplicationLevelChange: (layoutChangeReason: LayoutChangeReason) => layoutChangeReason is ApplicationLevelChange;
|
|
135
|
+
export declare const isLayoutLevelChange: (layoutChangeReason: LayoutChangeReason) => layoutChangeReason is LayoutLevelChange;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LayoutJSON, LayoutModel, dimension } from "@vuu-ui/vuu-utils";
|
|
2
|
+
import React, { CSSProperties, ReactElement } from "react";
|
|
3
|
+
import { TabLabelFactory } from "../stack";
|
|
4
|
+
import { layoutType } from "./layoutTypes";
|
|
5
|
+
interface ComponentWithId {
|
|
6
|
+
id: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare const getManagedDimension: (style: CSSProperties) => [dimension, dimension];
|
|
10
|
+
export declare const applyLayoutProps: (component: ReactElement, path?: string) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
11
|
+
export interface LayoutProps extends ComponentWithId {
|
|
12
|
+
active?: number;
|
|
13
|
+
"data-path"?: string;
|
|
14
|
+
children?: ReactElement[];
|
|
15
|
+
column?: boolean;
|
|
16
|
+
dropTarget?: boolean;
|
|
17
|
+
key: string;
|
|
18
|
+
layout?: LayoutJSON;
|
|
19
|
+
path?: string;
|
|
20
|
+
resizeable?: boolean;
|
|
21
|
+
style: CSSProperties;
|
|
22
|
+
type?: string;
|
|
23
|
+
version?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* parse the declarative JSX and clone adding layout attributes
|
|
27
|
+
*/
|
|
28
|
+
export declare const cloneElementAddLayoutProps: (layoutElement: ReactElement, previousLayout?: ReactElement) => ReactElement;
|
|
29
|
+
export declare const applyLayout: (type: layoutType, props: LayoutProps, previousLayout?: LayoutModel) => LayoutModel;
|
|
30
|
+
export declare function layoutFromJson({ active, id, type, children, props, state }: LayoutJSON, path: string): ReactElement;
|
|
31
|
+
export declare function layoutToJSON(component: ReactElement): LayoutJSON<{
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function componentToJson(component: ReactElement): LayoutJSON;
|
|
35
|
+
export declare function serializeProps(props?: LayoutProps): {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
} | undefined;
|
|
38
|
+
export type LayoutQuery = "PARENT_CONTAINER";
|
|
39
|
+
export declare const layoutQuery: (query: LayoutQuery, path?: string, layoutRoot?: ReactElement) => {
|
|
40
|
+
parentContainerId: any;
|
|
41
|
+
parentContainerType: string | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
export declare const getDefaultTabLabel: TabLabelFactory;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { ReplaceAction } from "./layoutTypes";
|
|
3
|
+
import { LayoutProps } from "./layoutUtils";
|
|
4
|
+
export declare function replaceChild(model: ReactElement, { target, replacement }: ReplaceAction): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
5
|
+
export declare function _replaceChild(model: ReactElement, child: ReactElement, replacement: ReactElement<LayoutProps>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
6
|
+
export declare function swapChild(model: ReactElement, child: ReactElement, replacement: ReactElement, op?: "collapse" | "expand"): ReactElement;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { LayoutResizeAction, SplitterResizeAction } from "./layoutTypes";
|
|
3
|
+
export declare function resizeFlexChild(layoutRoot: ReactElement, { path, size }: LayoutResizeAction): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
4
|
+
export declare function resizeFlexChildren(layoutRoot: ReactElement, { path, sizes }: SplitterResizeAction): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { DropPos } from "../drag-drop/dragDropTypes";
|
|
3
|
+
import { DropTarget } from "../drag-drop/DropTarget";
|
|
4
|
+
export interface LayoutSpec {
|
|
5
|
+
type: "Stack" | "Flexbox";
|
|
6
|
+
flexDirection: "column" | "row";
|
|
7
|
+
showTabs?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function wrap(container: ReactElement, existingComponent: ReactElement, newComponent: any, pos: DropPos, clientRect?: DropTarget["clientRect"], dropRect?: DropTarget["dropRect"]): ReactElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ForwardedRef, ReactElement } from "react";
|
|
2
|
+
import { ViewProps } from "./viewTypes";
|
|
3
|
+
interface ViewComponentType {
|
|
4
|
+
(props: ViewProps & {
|
|
5
|
+
ref?: ForwardedRef<HTMLDivElement>;
|
|
6
|
+
}): ReactElement<ViewProps>;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const MemoView: ViewComponentType;
|
|
10
|
+
export { MemoView as View };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { ConfigChangeHandler } from "../layout-view-actions";
|
|
3
|
+
export interface ViewHookProps {
|
|
4
|
+
id: string;
|
|
5
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
6
|
+
path?: string;
|
|
7
|
+
dropTargets?: string[];
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const useView: ({ id, rootRef, path, dropTargets, title: titleProp, }: ViewHookProps) => {
|
|
11
|
+
contributions: import("./viewTypes").Contribution[] | undefined;
|
|
12
|
+
dispatchViewAction: import("../layout-view-actions").ViewDispatch;
|
|
13
|
+
load: (key?: string) => any;
|
|
14
|
+
loadSession: (key?: string) => any;
|
|
15
|
+
onConfigChange: ConfigChangeHandler;
|
|
16
|
+
onEditTitle: (title: string) => void;
|
|
17
|
+
purge: (key: string) => void;
|
|
18
|
+
restoredState: any;
|
|
19
|
+
save: (state: unknown, key: string) => void;
|
|
20
|
+
saveSession: (state: unknown, key: string) => void;
|
|
21
|
+
title: any;
|
|
22
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ViewBroadcastMessage {
|
|
2
|
+
path?: string;
|
|
3
|
+
targetId?: string;
|
|
4
|
+
type: "highlight-on" | "highlight-off" | "layout-closed";
|
|
5
|
+
}
|
|
6
|
+
export type BroadcastMessageHandler = (message: ViewBroadcastMessage) => void;
|
|
7
|
+
export declare const useViewBroadcastChannel: (id?: string, path?: string, onMessageReceived?: BroadcastMessageHandler) => (message: ViewBroadcastMessage) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export interface ViewResizeHookProps {
|
|
3
|
+
mainRef: RefObject<HTMLDivElement | null>;
|
|
4
|
+
resize?: "defer" | "responsive";
|
|
5
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useViewResize: ({ mainRef, resize, rootRef, }: ViewResizeHookProps) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CSSProperties, FunctionComponent, HTMLAttributes, ReactElement } from "react";
|
|
2
|
+
import { HeaderProps } from "../layout-header";
|
|
3
|
+
import { MaximizeAction, CollapseAction, ExpandAction, MousedownViewAction, QueryAction, RemoveAction, RestoreAction, TearoutAction } from "../layout-reducer";
|
|
4
|
+
import { ViewBroadcastMessage } from "./useViewBroadcastChannel";
|
|
5
|
+
export type SaveAction = {
|
|
6
|
+
type: "save";
|
|
7
|
+
};
|
|
8
|
+
export type ContributionLocation = "post-title" | "pre-title";
|
|
9
|
+
export type Contribution = {
|
|
10
|
+
index?: number;
|
|
11
|
+
location?: ContributionLocation;
|
|
12
|
+
content: ReactElement;
|
|
13
|
+
};
|
|
14
|
+
export type AddToolbarContributionViewAction = {
|
|
15
|
+
content: ReactElement;
|
|
16
|
+
location: ContributionLocation;
|
|
17
|
+
type: "add-toolbar-contribution";
|
|
18
|
+
};
|
|
19
|
+
export type RemoveToolbarContributionViewAction = {
|
|
20
|
+
location: ContributionLocation;
|
|
21
|
+
type: "remove-toolbar-contribution";
|
|
22
|
+
};
|
|
23
|
+
export type BroadcastMessageViewAction = {
|
|
24
|
+
type: "broadcast-message";
|
|
25
|
+
message: ViewBroadcastMessage;
|
|
26
|
+
};
|
|
27
|
+
export type ViewAction = BroadcastMessageViewAction | MaximizeAction | CollapseAction | ExpandAction | MousedownViewAction | QueryAction | RemoveAction | RestoreAction | TearoutAction | AddToolbarContributionViewAction | RemoveToolbarContributionViewAction;
|
|
28
|
+
export type ResizeStrategy = "defer" | "responsive";
|
|
29
|
+
export interface ViewProps extends HTMLAttributes<HTMLDivElement> {
|
|
30
|
+
Header?: FunctionComponent<HeaderProps>;
|
|
31
|
+
allowRename?: boolean;
|
|
32
|
+
closeable?: boolean;
|
|
33
|
+
collapsed?: boolean;
|
|
34
|
+
"data-path"?: string;
|
|
35
|
+
"data-resizeable"?: boolean;
|
|
36
|
+
dropTargets?: string[];
|
|
37
|
+
expanded?: boolean;
|
|
38
|
+
flexFill?: boolean;
|
|
39
|
+
header?: boolean | Partial<HeaderProps>;
|
|
40
|
+
onCollapse?: () => void;
|
|
41
|
+
onExpand?: () => void;
|
|
42
|
+
orientation?: "vertical" | "horizontal";
|
|
43
|
+
path?: string;
|
|
44
|
+
resize?: ResizeStrategy;
|
|
45
|
+
resizeable?: boolean;
|
|
46
|
+
restoreStyle?: CSSProperties;
|
|
47
|
+
tearOut?: boolean;
|
|
48
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { SyntheticEvent } from "react";
|
|
2
|
+
import type { ViewAction } from "../layout-view";
|
|
3
|
+
export type QueryReponse = {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
export type ConfigChangeHandler = (config: {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
type: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
export type ViewDispatch = <Action extends ViewAction = ViewAction>(action: Action, evt?: SyntheticEvent) => Promise<boolean | QueryReponse | void>;
|
|
11
|
+
/**
|
|
12
|
+
* This API is available to any Feature hosted within Vuu (as all Features are wrapped
|
|
13
|
+
* with View component). It offers metadata about the View as well as access to the
|
|
14
|
+
* Vuu persistencew API;
|
|
15
|
+
*/
|
|
16
|
+
export interface ViewContextAPI {
|
|
17
|
+
/**
|
|
18
|
+
* dispatcher for View actions. These are a subset of LayoutActions, specifically for
|
|
19
|
+
* View manipulation
|
|
20
|
+
*/
|
|
21
|
+
dispatch?: ViewDispatch | null;
|
|
22
|
+
id?: string;
|
|
23
|
+
load?: <T = unknown>(key?: string) => T;
|
|
24
|
+
loadSession?: (key?: string) => unknown;
|
|
25
|
+
onConfigChange?: ConfigChangeHandler;
|
|
26
|
+
path?: string;
|
|
27
|
+
purge?: (key: string) => void;
|
|
28
|
+
save?: (state: unknown, key: string) => void;
|
|
29
|
+
saveSession?: (state: unknown, key: string) => void;
|
|
30
|
+
setComponentProps: (props: {
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}) => void;
|
|
33
|
+
title?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const ViewContext: React.Context<ViewContextAPI>;
|
|
36
|
+
export declare const useViewDispatch: () => ViewDispatch | null;
|
|
37
|
+
export declare const useViewContext: () => ViewContextAPI;
|