@vuu-ui/grid-layout 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +141 -0
  3. package/package.json +40 -0
  4. package/src/GridCommand.js +395 -0
  5. package/src/GridComponentSettings.js +163 -0
  6. package/src/GridController.js +359 -0
  7. package/src/GridDragCoordinator.js +293 -0
  8. package/src/GridGeometry.js +1298 -0
  9. package/src/GridLayout.css.js +119 -0
  10. package/src/GridLayout.js +120 -0
  11. package/src/GridLayoutContext.js +58 -0
  12. package/src/GridLayoutDocument.js +307 -0
  13. package/src/GridLayoutDocumentIds.js +110 -0
  14. package/src/GridLayoutItem.css.js +46 -0
  15. package/src/GridLayoutItem.js +147 -0
  16. package/src/GridLayoutLegacyCompatibility.js +66 -0
  17. package/src/GridLayoutModel.js +138 -0
  18. package/src/GridLayoutProvider.js +263 -0
  19. package/src/GridLayoutStackedItem.css.js +26 -0
  20. package/src/GridLayoutStackedtem.js +140 -0
  21. package/src/GridModel.js +1289 -0
  22. package/src/GridPlaceholder.css.js +9 -0
  23. package/src/GridPlaceholder.js +24 -0
  24. package/src/GridSnapshot.js +11 -0
  25. package/src/GridSplitter.css.js +62 -0
  26. package/src/GridSplitter.js +26 -0
  27. package/src/GridStack.js +277 -0
  28. package/src/Icon.css.js +8 -0
  29. package/src/Icon.js +26 -0
  30. package/src/IconButton.css.js +9 -0
  31. package/src/IconButton.js +28 -0
  32. package/src/TabDialog.css.js +10 -0
  33. package/src/TabDialog.js +77 -0
  34. package/src/TabMenu.css.js +8 -0
  35. package/src/TabMenu.js +78 -0
  36. package/src/componentToJson.js +41 -0
  37. package/src/drag-drop-next/DragContextNext.js +173 -0
  38. package/src/drag-drop-next/DragDropProviderNext.css.js +72 -0
  39. package/src/drag-drop-next/DragDropProviderNext.js +91 -0
  40. package/src/drag-drop-next/SpaceMan.js +256 -0
  41. package/src/drag-drop-next/TemplateDragSession.js +36 -0
  42. package/src/drag-drop-next/tabstrip-drag-drop.js +251 -0
  43. package/src/grid-dom-utils.js +57 -0
  44. package/src/grid-layout-utils.js +39 -0
  45. package/src/grid-snapshot-adapters.js +435 -0
  46. package/src/index.js +24 -0
  47. package/src/json-value.js +56 -0
  48. package/src/layoutFromJson.js +15 -0
  49. package/src/layoutToJson.js +5 -0
  50. package/src/propUtils.js +15 -0
  51. package/src/react-element-utils.js +15 -0
  52. package/src/typeOf.js +15 -0
  53. package/src/useAsDropTarget.js +229 -0
  54. package/src/useDraggable.js +46 -0
  55. package/src/useEditTabName.js +70 -0
  56. package/src/useGridChildProps.js +47 -0
  57. package/src/useGridControllerSnapshot.js +21 -0
  58. package/src/useGridLayout.js +727 -0
  59. package/src/useGridSplitterResizing.js +262 -0
  60. package/src/useNotDropTarget.js +2 -0
  61. package/types/AddTabDialog.d.ts +5 -0
  62. package/types/GridCommand.d.ts +146 -0
  63. package/types/GridComponentSettings.d.ts +71 -0
  64. package/types/GridController.d.ts +50 -0
  65. package/types/GridDragCoordinator.d.ts +80 -0
  66. package/types/GridGeometry.d.ts +331 -0
  67. package/types/GridLayout.d.ts +20 -0
  68. package/types/GridLayoutContext.d.ts +141 -0
  69. package/types/GridLayoutDocument.d.ts +61 -0
  70. package/types/GridLayoutDocumentIds.d.ts +15 -0
  71. package/types/GridLayoutItem.d.ts +28 -0
  72. package/types/GridLayoutLegacyCompatibility.d.ts +57 -0
  73. package/types/GridLayoutModel.d.ts +72 -0
  74. package/types/GridLayoutProvider.d.ts +59 -0
  75. package/types/GridLayoutStackedtem.d.ts +10 -0
  76. package/types/GridModel.d.ts +504 -0
  77. package/types/GridPlaceholder.d.ts +5 -0
  78. package/types/GridSnapshot.d.ts +49 -0
  79. package/types/GridSplitter.d.ts +10 -0
  80. package/types/GridStack.d.ts +160 -0
  81. package/types/Icon.d.ts +6 -0
  82. package/types/IconButton.d.ts +6 -0
  83. package/types/TabDialog.d.ts +9 -0
  84. package/types/TabMenu.d.ts +7 -0
  85. package/types/componentToJson.d.ts +38 -0
  86. package/types/drag-drop-next/DragContextNext.d.ts +92 -0
  87. package/types/drag-drop-next/DragDropProviderNext.d.ts +23 -0
  88. package/types/drag-drop-next/SpaceMan.d.ts +35 -0
  89. package/types/drag-drop-next/TemplateDragSession.d.ts +21 -0
  90. package/types/drag-drop-next/tabstrip-drag-drop.d.ts +3 -0
  91. package/types/grid-dom-utils.d.ts +17 -0
  92. package/types/grid-layout-utils.d.ts +18 -0
  93. package/types/grid-matrix.d.ts +5 -0
  94. package/types/grid-snapshot-adapters.d.ts +22 -0
  95. package/types/index.d.ts +24 -0
  96. package/types/json-value.d.ts +23 -0
  97. package/types/layoutFromJson.d.ts +4 -0
  98. package/types/layoutToJson.d.ts +3 -0
  99. package/types/propUtils.d.ts +5 -0
  100. package/types/react-element-utils.d.ts +3 -0
  101. package/types/src/AddTabDialog.d.ts +5 -0
  102. package/types/src/GridLayout.d.ts +14 -0
  103. package/types/src/GridLayoutContext.d.ts +88 -0
  104. package/types/src/GridLayoutItem.d.ts +28 -0
  105. package/types/src/GridLayoutModel.d.ts +59 -0
  106. package/types/src/GridLayoutProvider.d.ts +37 -0
  107. package/types/src/GridLayoutStackedtem.d.ts +10 -0
  108. package/types/src/GridModel.d.ts +350 -0
  109. package/types/src/GridPlaceholder.d.ts +5 -0
  110. package/types/src/GridSplitter.d.ts +9 -0
  111. package/types/src/Icon.d.ts +6 -0
  112. package/types/src/IconButton.d.ts +6 -0
  113. package/types/src/TabMenu.d.ts +6 -0
  114. package/types/src/componentToJson.d.ts +32 -0
  115. package/types/src/drag-drop-next/DragContextNext.d.ts +73 -0
  116. package/types/src/drag-drop-next/DragDropProviderNext.d.ts +20 -0
  117. package/types/src/drag-drop-next/SpaceMan.d.ts +35 -0
  118. package/types/src/drag-drop-next/tabstrip-drag-drop.d.ts +3 -0
  119. package/types/src/grid-dom-utils.d.ts +17 -0
  120. package/types/src/grid-layout-utils.d.ts +80 -0
  121. package/types/src/grid-matrix.d.ts +5 -0
  122. package/types/src/index.d.ts +10 -0
  123. package/types/src/layoutFromJson.d.ts +3 -0
  124. package/types/src/layoutToJson.d.ts +2 -0
  125. package/types/src/propUtils.d.ts +5 -0
  126. package/types/src/react-element-utils.d.ts +3 -0
  127. package/types/src/typeOf.d.ts +6 -0
  128. package/types/src/useAsDropTarget.d.ts +7 -0
  129. package/types/src/useDraggable.d.ts +23 -0
  130. package/types/src/useGridChildProps.d.ts +13 -0
  131. package/types/src/useGridLayout.d.ts +43 -0
  132. package/types/src/useGridSplitterResizing.d.ts +12 -0
  133. package/types/src/useNotDropTarget.d.ts +1 -0
  134. package/types/typeOf.d.ts +6 -0
  135. package/types/useAsDropTarget.d.ts +7 -0
  136. package/types/useDraggable.d.ts +24 -0
  137. package/types/useEditTabName.d.ts +11 -0
  138. package/types/useGridChildProps.d.ts +13 -0
  139. package/types/useGridControllerSnapshot.d.ts +7 -0
  140. package/types/useGridLayout.d.ts +53 -0
  141. package/types/useGridSplitterResizing.d.ts +14 -0
  142. package/types/useNotDropTarget.d.ts +1 -0
@@ -0,0 +1,73 @@
1
+ import { EventEmitter, type orientationType } from "@vuu-ui/vuu-utils";
2
+ import { DragSource } from "../GridLayoutContext";
3
+ type DragSourceDescriptor = {
4
+ dropTargets: string[];
5
+ orientation?: orientationType;
6
+ payloadType?: string;
7
+ };
8
+ export type DropPosition = {
9
+ position: "before" | "after";
10
+ target: string;
11
+ };
12
+ export type DragSources = {
13
+ [key: string]: DragSourceDescriptor;
14
+ };
15
+ export type DropProps<T extends DragSource = DragSource> = {
16
+ dragSource: T;
17
+ toId?: string;
18
+ tabsId?: string;
19
+ dropPosition?: DropPosition;
20
+ };
21
+ export type DropHandler<T extends DragSource = DragSource> = (dropProps: DropProps<T>) => void;
22
+ export type DragContextDropEvent = {
23
+ type: "drop";
24
+ dragSource: DragSource;
25
+ tabsId: string;
26
+ dropPosition: DropPosition;
27
+ };
28
+ export type DragContextDetachTabEvent = {
29
+ gridId: string;
30
+ type: "detach-tab";
31
+ tabsId: string;
32
+ value: string;
33
+ };
34
+ export type DragContextDropHandler = (evt: DragContextDropEvent) => void;
35
+ export type DragContextDetachTabHandler = (evt: DragContextDetachTabEvent) => void;
36
+ export type DragContextEvents = {
37
+ drop: DragContextDropHandler;
38
+ "detach-tab": DragContextDetachTabHandler;
39
+ };
40
+ /**
41
+ * This context is a global singleton. Even when DragDropProviders are nested,
42
+ * a single instance of this context object is always used.
43
+ */
44
+ export declare class DragContext extends EventEmitter<DragContextEvents> {
45
+ #private;
46
+ beginDrag(e: DragEvent, dragSource: DragSource): void;
47
+ endDrag(): void;
48
+ /**
49
+ * A 'detached' tab is one that has been dragged from its place in tabstrip
50
+ * but not yet dropped. If it is the selected tab, we want to avoid unmounting
51
+ * the react component in the associated TabPanel. By marking it as 'detached'
52
+ * the TabPanel is still rendered but not visible. When the tab is dropped, the
53
+ * TabPanel can be assigned its new location (might still be within tabstrip, might
54
+ * not be) and made visible, without ever having to unmount/remount.
55
+ */
56
+ detachTab(gridId: string, tabsId: string, value: string): void;
57
+ drop: ({ tabsId, dropPosition, }: Pick<DragContextDropEvent, "tabsId" | "dropPosition">) => void;
58
+ registerTabsForDragDrop: (id: string) => void;
59
+ get draggedElement(): HTMLElement;
60
+ get dragElementWidth(): number;
61
+ get dragLabelWidth(): number;
62
+ get dragSource(): DragSource | undefined;
63
+ get internalDragSources(): Map<string, DragSourceDescriptor>;
64
+ set dragSources(dragSources: DragSources);
65
+ set dropHandler(dropHandler: DropHandler);
66
+ get dropped(): boolean;
67
+ get x(): number;
68
+ set x(value: number);
69
+ get y(): number;
70
+ set y(value: number);
71
+ private buildDragSources;
72
+ }
73
+ export {};
@@ -0,0 +1,20 @@
1
+ import { ReactNode } from "react";
2
+ import { DragContext, DragContextDetachTabHandler, DragContextDropHandler, type DragSources } from "./DragContextNext";
3
+ export type DragDropRegistrationFn = (id: string) => void;
4
+ export type DragDropBeginDrag = (id: string, draggedElement: HTMLElement) => void;
5
+ export type DragDropEndDrag = (id: string) => void;
6
+ export type DragSourceRegistrationHandler = (id: string) => void;
7
+ export interface DragDropNextProviderProps {
8
+ children: ReactNode;
9
+ dragSources: DragSources;
10
+ onDetachTab: DragContextDetachTabHandler;
11
+ onDrop: DragContextDropHandler;
12
+ }
13
+ export type MeasuredTarget = {
14
+ bottom: number;
15
+ left: number;
16
+ right: number;
17
+ top: number;
18
+ };
19
+ export declare const DragDropProviderNext: ({ children, onDetachTab, onDrop, }: DragDropNextProviderProps) => import("react").JSX.Element;
20
+ export declare const useDragContext: () => DragContext;
@@ -0,0 +1,35 @@
1
+ import type { RefCallback } from "react";
2
+ import { type orientationType } from "@vuu-ui/vuu-utils";
3
+ import type { DragContext, DropPosition } from "./DragContextNext";
4
+ export type State = "initial" | "away" | "1spacer" | "2spacer";
5
+ type Direction = "fwd" | "bwd";
6
+ export declare class SpaceMan {
7
+ #private;
8
+ id: string;
9
+ constructor(dragContext: DragContext, id: string, orientation?: orientationType);
10
+ get mouseOffset(): {
11
+ x: number;
12
+ y: number;
13
+ };
14
+ set mouseOffset(offset: {
15
+ x: number;
16
+ y: number;
17
+ });
18
+ get dropPosition(): DropPosition | undefined;
19
+ get positionRelativeToTargetTab(): "before" | "after";
20
+ setDragContainer: RefCallback<HTMLElement>;
21
+ enterDragContainer(): void;
22
+ leaveDragContainer(): void;
23
+ dragStart(index: number | string): void;
24
+ dragEnter(index: number, direction: Direction): void;
25
+ insertSpacer(index: number | string, size: number): void;
26
+ private clearSpacers;
27
+ cleanup(): void;
28
+ drop(x: number, y: number): Promise<void>;
29
+ dragEnd(): void;
30
+ private getPositionOfDragContainer;
31
+ private getPositionOfDropTarget;
32
+ private setSpacerSizes;
33
+ private createDragSpacer;
34
+ }
35
+ export {};
@@ -0,0 +1,3 @@
1
+ import { orientationType } from "@vuu-ui/vuu-utils";
2
+ import { DragContext } from "./DragContextNext";
3
+ export declare function initializeDragContainer(containerEl: HTMLElement, dragContext: DragContext, orientation?: orientationType): () => void;
@@ -0,0 +1,17 @@
1
+ import { GridLayoutModelPosition, GridLayoutResizeDirection } from "./GridLayoutModel";
2
+ import { GridModelChildItem } from "./GridModel";
3
+ export declare const classNameLayoutItem = "vuuGridLayoutItem";
4
+ export declare const classNameGridSplitter = "vuuGridSplitter";
5
+ export type ResizeOrientation = "horizontal" | "vertical";
6
+ type GridPos = [number, number];
7
+ export declare const getGridSplitter: (el: HTMLElement) => HTMLElement;
8
+ export declare const getGridLayoutItem: (el: HTMLElement) => HTMLElement;
9
+ export declare const getColumn: (el: HTMLElement) => GridPos;
10
+ export declare const getRow: (el: HTMLElement | undefined) => GridPos;
11
+ export declare const getRowIndex: (el: HTMLElement) => number;
12
+ export declare const setGridColumn: (target: string | HTMLElement, { start, end }: GridLayoutModelPosition) => void;
13
+ export declare const setGridRow: (target: string | HTMLElement, { start, end }: GridLayoutModelPosition) => void;
14
+ export declare const spansMultipleTracks: (gridItem: GridModelChildItem, direction: GridLayoutResizeDirection) => boolean;
15
+ export declare function getClosestGridLayout(source: string): string;
16
+ export declare function getClosestGridLayout(source: HTMLElement): string;
17
+ export {};
@@ -0,0 +1,80 @@
1
+ import { GridLayoutDropPosition, GridLayoutSplitDirection } from "@vuu-ui/vuu-utils";
2
+ import { GridItemUpdate, GridLayoutModelPosition, GridLayoutResizeDirection } from "./GridLayoutModel";
3
+ import { GridLayoutChildItemDescriptor, GridLayoutModelCoordinates, GridModelChildItem, GridModelCoordinates, ISplitter, TrackType } from "./GridModel";
4
+ export declare const splitTrack: (tracks: number[], trackIndex: number) => number[];
5
+ export type ContrasAndSiblings = {
6
+ contras: GridModelChildItem[];
7
+ position: GridLayoutModelPosition;
8
+ siblings: GridModelChildItem[];
9
+ };
10
+ /**
11
+ * Siblings are gridLayoutItem(s) starting on same trackEdge as
12
+ * gridItem. Contras are gridLayoutItems ending on same trackEdge
13
+ * as gridItem.
14
+ * We are measuring here for a horizontal splitter,siblings are
15
+ * gridItems to the immediate right of gridItem, contras are
16
+ * gridItems ending in the row immediately above gridItem.
17
+ * @param gridLayoutItem
18
+ * @param siblings 0 or more siblings
19
+ * @param contras 1 or more contras
20
+ * @returns
21
+ */
22
+ export declare const getMatchingColspan: (targetGridItem: GridModelChildItem, siblings: GridModelChildItem[], contras: GridModelChildItem[]) => ContrasAndSiblings | undefined;
23
+ /**
24
+ * Siblings are gridLayoutItem(s) starting on same trackEdge as
25
+ * gridItem. Contras are gridLayoutItems ending on same trackEdge
26
+ * as gridItem.
27
+ * We are measuring here for a vertical splitter,siblings are
28
+ * gridItems immediately below gridItem, contras are
29
+ * gridItems ending in the col immediately left of gridItem.
30
+ * @param gridLayoutItem
31
+ * @param siblings 0 or more siblings
32
+ * @param contras 1 or more contras
33
+ * @returns
34
+ */
35
+ export declare const getMatchingRowspan: (gridItem: GridModelChildItem, siblings: GridModelChildItem[], contras: GridModelChildItem[]) => ContrasAndSiblings | undefined;
36
+ /**
37
+ * Resize requires new track if the splitter being used for resize is on the same
38
+ * trackEdge as another splitter
39
+ *
40
+ * @param splitters
41
+ * @param splitter
42
+ * @returns
43
+ */
44
+ export declare const doesResizeRequireNewTrack: (splitters: ISplitter[], splitter: ISplitter) => boolean;
45
+ /**
46
+ *
47
+ * @param moveBy positive or negative number
48
+ * @param adjustmentAmount positive number, never greater than abs(moveBy)
49
+ * @returns
50
+ */
51
+ export declare const adjustDistance: (moveBy: number, adjustmentAmount: number) => number;
52
+ export declare const byColumnStart: (item1: GridModelChildItem, item2: GridModelChildItem) => number;
53
+ export declare const byRowStart: (item1: GridModelChildItem, item2: GridModelChildItem) => number;
54
+ export declare const gridResizeDirectionFromDropPosition: (dropPosition: GridLayoutDropPosition) => GridLayoutResizeDirection;
55
+ export declare const byColumnPosition: ({ column: pos1 }: GridModelChildItem, { column: pos2 }: GridModelChildItem) => -1 | 0 | 1;
56
+ export declare const byRowPosition: ({ row: pos1 }: GridModelChildItem, { row: pos2 }: GridModelChildItem) => -1 | 0 | 1;
57
+ export declare const itemsFillColumn: (items: GridModelChildItem[], pos: GridLayoutModelPosition) => boolean;
58
+ export declare const itemsFillRow: (items: GridModelChildItem[], row: GridLayoutModelPosition) => boolean;
59
+ /**
60
+ * This assumes that tracks have already been prepared, such that 'position'
61
+ * spans at least two tracks in the split direction
62
+ *
63
+ * @param position
64
+ * @param splitDirection
65
+ * @returns [droppedItemPosition, targetPosition]
66
+ */
67
+ export declare const splitGridChildPosition: ({ column: { start: colStart, end: colEnd }, row: { start: rowStart, end: rowEnd }, }: GridLayoutModelCoordinates, splitDirection: GridLayoutSplitDirection, splitTrackIndex: number) => [GridLayoutModelCoordinates, GridLayoutModelCoordinates];
68
+ export declare const isFixedHeightChildItem: (item: GridModelChildItem) => boolean;
69
+ export declare const isFixedWidthChildItem: (item: GridModelChildItem) => boolean;
70
+ export declare const getGridArea: ({ column, row }: GridLayoutModelCoordinates) => string;
71
+ export declare const getActiveIndex: (childItems: GridModelChildItem[]) => number;
72
+ export declare const getSharedGridPosition: (childItems: GridModelChildItem[]) => GridLayoutModelCoordinates;
73
+ export declare const getGridPosition: (gridArea: GridLayoutChildItemDescriptor["gridArea"]) => GridModelCoordinates;
74
+ export declare const getTrackType: (splitter: ISplitter) => TrackType;
75
+ export declare const setTrackStart: (trackType: TrackType, gridItem: GridModelChildItem, adjustment?: number) => GridItemUpdate;
76
+ export declare const setTrackEnd: (trackType: TrackType, gridItem: GridModelChildItem, adjustment?: number) => GridItemUpdate;
77
+ export declare const setColumnEnd: (gridItem: GridModelChildItem) => GridItemUpdate;
78
+ export declare const setRowEnd: (gridItem: GridModelChildItem) => GridItemUpdate;
79
+ export declare const moveColumn: ({ id, column: { start, end }, }: GridModelChildItem) => GridItemUpdate;
80
+ export declare const moveRow: ({ id, row: { start, end }, }: GridModelChildItem) => GridItemUpdate;
@@ -0,0 +1,5 @@
1
+ import { GridModelChildItem } from "./GridModel";
2
+ export type GridMatrix = number[][];
3
+ export declare const getGridMatrix: (gridItems: GridModelChildItem[], rowCount: number, colCount: number) => GridMatrix;
4
+ export declare const printGrid: (grid: number[][]) => void;
5
+ export declare function getEmptyExtents(grid: GridMatrix): GridModelChildItem[];
@@ -0,0 +1,10 @@
1
+ export { GridLayout } from "./GridLayout";
2
+ export { GridLayoutItem } from "./GridLayoutItem";
3
+ export { GridLayoutStackedItem } from "./GridLayoutStackedtem";
4
+ export { GridLayoutProvider, type SerializedGridLayout, } from "./GridLayoutProvider";
5
+ export type { GridLayoutChangeHandler, GridLayoutDescriptor, TrackSize, } from "./GridModel";
6
+ export { layoutFromJson } from "./layoutFromJson";
7
+ export { type ComponentTemplate, type DragSource, type TemplateSource, useGridLayoutDispatch, useGridModel, useGridLayoutDragStartHandler, } from "./GridLayoutContext";
8
+ export { useDraggable } from "./useDraggable";
9
+ export { DragDropProviderNext } from "./drag-drop-next/DragDropProviderNext";
10
+ export type { DragSources, DropHandler, } from "./drag-drop-next/DragContextNext";
@@ -0,0 +1,3 @@
1
+ import { ReactElement } from "react";
2
+ import { LayoutJSON } from "./componentToJson";
3
+ export declare function layoutFromJson({ active, id, type, children, props, state }: LayoutJSON, path: string): ReactElement;
@@ -0,0 +1,2 @@
1
+ import { ReactElement } from "react";
2
+ export declare function layoutToJSON(component: ReactElement): import("./componentToJson").LayoutJSON<object>;
@@ -0,0 +1,5 @@
1
+ import { ReactElement } from "react";
2
+ import { LayoutModel } from "@vuu-ui/vuu-utils";
3
+ export declare const getProp: (component: LayoutModel | undefined, propName: string) => any;
4
+ export declare const getProps: (component?: LayoutModel) => {};
5
+ export declare const getChildProp: (container: LayoutModel) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | undefined;
@@ -0,0 +1,3 @@
1
+ import React, { ReactElement } from "react";
2
+ export declare const getGridItemChild: (gridItems: ReactElement[], gridItemId: string) => ReactElement;
3
+ export declare const addChildToStackedGridItem: (stackElement: ReactElement, childElement: ReactElement) => ReactElement<unknown, string | React.JSXElementConstructor<any>>;
@@ -0,0 +1,6 @@
1
+ import { LayoutModel, WithType } from "@vuu-ui/vuu-utils";
2
+ import { ReactElement } from "react";
3
+ import { LayoutJSON } from "./componentToJson";
4
+ export declare function typeOf(element?: LayoutModel | WithType): string | undefined;
5
+ export declare const isTypeOf: (element: ReactElement, type: string) => boolean;
6
+ export declare const isLayoutJSON: (layout: LayoutJSON) => layout is LayoutJSON;
@@ -0,0 +1,7 @@
1
+ import { DragEventHandler } from "react";
2
+ export declare const useAsDropTarget: () => {
3
+ onDragEnter: DragEventHandler;
4
+ onDragOver: DragEventHandler;
5
+ onDragLeave: DragEventHandler;
6
+ onDrop: DragEventHandler;
7
+ };
@@ -0,0 +1,23 @@
1
+ import { DragEvent, DragEventHandler } from "react";
2
+ import { GridLayoutDragEndHandler } from "./GridLayoutProvider";
3
+ import { DragSourceProvider } from "./GridLayoutContext";
4
+ import { LayoutJSON } from "./componentToJson";
5
+ export type DragStartIdOptions = {
6
+ id: string;
7
+ type: "text/plain";
8
+ };
9
+ export type DragStartJsonOptions = {
10
+ payload: LayoutJSON;
11
+ type: "text/json";
12
+ };
13
+ export type GridLayoutDragStartHandler = (evt: DragEvent<HTMLElement>, dragStartOptions: DragStartIdOptions | DragStartJsonOptions) => void;
14
+ export interface DraggableHookProps {
15
+ draggableClassName?: string;
16
+ getDragSource: DragSourceProvider;
17
+ onDragEnd?: GridLayoutDragEndHandler;
18
+ onDragStart?: GridLayoutDragStartHandler;
19
+ }
20
+ export declare const useDraggable: ({ getDragSource, onDragEnd, onDragStart, }: DraggableHookProps) => {
21
+ onDragEnd: DragEventHandler<HTMLElement>;
22
+ onDragStart: DragEventHandler<HTMLElement>;
23
+ };
@@ -0,0 +1,13 @@
1
+ import { GridModelChildItemProps } from "./GridModel";
2
+ export declare const useGridChildProps: ({ contentVisible, dropTarget, header, height, id, stackId, resizeable, style, title, type, width, }: GridModelChildItemProps) => {
3
+ contentDetached: boolean | undefined;
4
+ contentVisible: boolean | undefined;
5
+ dragging: boolean;
6
+ dropTarget: string | boolean | undefined;
7
+ gridArea: string;
8
+ header: boolean | undefined;
9
+ horizontalSplitter: boolean;
10
+ stacked: boolean;
11
+ title: string | undefined;
12
+ verticalSplitter: boolean;
13
+ };
@@ -0,0 +1,43 @@
1
+ import { ReactElement, ReactNode, RefCallback } from "react";
2
+ import { DragContextDetachTabHandler, DragContextDropHandler } from "./drag-drop-next/DragContextNext";
3
+ import { GridLayoutDispatch, GridLayoutDropHandler } from "./GridLayoutContext";
4
+ import { GridLayoutItemProps } from "./GridLayoutItem";
5
+ import { GridLayoutModel } from "./GridLayoutModel";
6
+ import { GridLayoutDragEndHandler } from "./GridLayoutProvider";
7
+ import { GridColumnsAndRows, GridLayoutChangeHandler, GridModel, GridModelChildItem, ISplitter } from "./GridModel";
8
+ import { GridLayoutDragStartHandler } from "./useDraggable";
9
+ export type GridLayoutHookProps = {
10
+ children: ReactNode;
11
+ id: string;
12
+ colsAndRows?: GridColumnsAndRows;
13
+ onChange?: GridLayoutChangeHandler;
14
+ };
15
+ type GridLayoutItemElements = Array<ReactElement<GridLayoutItemProps>>;
16
+ type NonContentGridItems = {
17
+ splitters: ISplitter[];
18
+ placeholders: GridModelChildItem[];
19
+ stackedItems: GridModelChildItem[];
20
+ };
21
+ /**
22
+ * Create the GridModel and bind model changes to DOM changes.
23
+ * The GridModel is constructed from a GridLayoutDescriptor, which may
24
+ * have been passed explicitly or extracted from GridLayoutItems.
25
+ *
26
+ * Create the list of GridLayoutItem elements to be rendered.
27
+ * The GridLayoutItem elements may be explicitly coded in JSX.
28
+ */
29
+ export declare const useGridLayout: ({ children: childrenProp, id, colsAndRows, onChange, }: GridLayoutHookProps) => {
30
+ children: GridLayoutItemElements;
31
+ containerCallback: RefCallback<HTMLDivElement>;
32
+ containerRef: import("react").RefObject<HTMLDivElement | null>;
33
+ dispatchGridLayoutAction: GridLayoutDispatch;
34
+ gridLayoutModel: GridLayoutModel;
35
+ gridModel: GridModel;
36
+ nonContentGridItems: NonContentGridItems;
37
+ onDetachTab: DragContextDetachTabHandler;
38
+ onDragEnd: GridLayoutDragEndHandler;
39
+ onDragStart: GridLayoutDragStartHandler;
40
+ onDrop: GridLayoutDropHandler;
41
+ onDropStackedItem: DragContextDropHandler;
42
+ };
43
+ export {};
@@ -0,0 +1,12 @@
1
+ import { MouseEventHandler } from "react";
2
+ import { GridLayoutProps } from "./GridLayout";
3
+ import { GridLayoutModel } from "./GridLayoutModel";
4
+ import { GridModel } from "./GridModel";
5
+ export type SplitterResizingHookProps = Pick<GridLayoutProps, "id" | "onClick"> & {
6
+ gridLayoutModel: GridLayoutModel;
7
+ gridModel: GridModel;
8
+ };
9
+ export declare const useGridSplitterResizing: ({ gridLayoutModel: layoutModel, gridModel, onClick: onClickProp, }: SplitterResizingHookProps) => {
10
+ onClick: MouseEventHandler<HTMLDivElement>;
11
+ onMouseDown: MouseEventHandler;
12
+ };
@@ -0,0 +1 @@
1
+ export declare const useNotDropTarget: () => {};
@@ -0,0 +1,6 @@
1
+ import { LayoutModel, WithType } from "@vuu-ui/vuu-utils";
2
+ import { ReactElement } from "react";
3
+ import { LayoutJSON } from "./componentToJson";
4
+ export declare function typeOf(element?: LayoutModel | WithType): string | undefined;
5
+ export declare const isTypeOf: (element: ReactElement, type: string) => boolean;
6
+ export declare const isLayoutJSON: (layout: LayoutJSON) => layout is LayoutJSON;
@@ -0,0 +1,7 @@
1
+ import { type DragEventHandler } from "react";
2
+ export declare const useAsDropTarget: () => {
3
+ onDragEnter: DragEventHandler;
4
+ onDragOver: DragEventHandler;
5
+ onDragLeave: DragEventHandler;
6
+ onDrop: DragEventHandler;
7
+ };
@@ -0,0 +1,24 @@
1
+ import { type DragEvent, type DragEventHandler } from "react";
2
+ import type { GridLayoutDragEndHandler } from "./GridLayoutProvider";
3
+ import { type DragSourceProvider } from "./GridLayoutContext";
4
+ import type { LayoutJSON } from "./componentToJson";
5
+ import type { JsonValue } from "./json-value";
6
+ export type DragStartIdOptions = {
7
+ id: string;
8
+ type: "text/plain";
9
+ };
10
+ export type DragStartJsonOptions = {
11
+ payload: JsonValue | LayoutJSON;
12
+ type: "text/json";
13
+ };
14
+ export type GridLayoutDragStartHandler = (evt: DragEvent<HTMLElement>, dragStartOptions: DragStartIdOptions | DragStartJsonOptions) => void;
15
+ export interface DraggableHookProps {
16
+ draggableClassName?: string;
17
+ getDragSource: DragSourceProvider;
18
+ onDragEnd?: GridLayoutDragEndHandler;
19
+ onDragStart?: GridLayoutDragStartHandler;
20
+ }
21
+ export declare const useDraggable: ({ getDragSource, onDragEnd, onDragStart, }: DraggableHookProps) => {
22
+ onDragEnd: DragEventHandler<HTMLElement>;
23
+ onDragStart: DragEventHandler<HTMLElement>;
24
+ };
@@ -0,0 +1,11 @@
1
+ import { type ComponentTemplateWithoutLabel } from "./GridLayoutContext";
2
+ export interface EditTabNameHookProps {
3
+ getNewComponent?: () => ComponentTemplateWithoutLabel;
4
+ id: string;
5
+ mode?: "add" | "edit";
6
+ tabLabel?: string;
7
+ }
8
+ export declare const useEditTabName: ({ getNewComponent, id, mode, tabLabel, }: EditTabNameHookProps) => {
9
+ dialog: import("react").JSX.Element | null;
10
+ showTabEditDialog: () => void;
11
+ };
@@ -0,0 +1,13 @@
1
+ import type { GridModelChildItemProps } from "./GridModel";
2
+ export declare const useGridChildProps: (props: GridModelChildItemProps) => {
3
+ contentDetached: boolean | undefined;
4
+ contentVisible: boolean | undefined;
5
+ dragging: boolean | undefined;
6
+ dropTarget: string | boolean | undefined;
7
+ gridArea: string;
8
+ header: boolean | undefined;
9
+ horizontalSplitter: boolean | undefined;
10
+ stacked: boolean;
11
+ title: string | undefined;
12
+ verticalSplitter: boolean | undefined;
13
+ };
@@ -0,0 +1,7 @@
1
+ import type { GridController } from "./GridController";
2
+ import type { GridSnapshot } from "./GridSnapshot";
3
+ /**
4
+ * Subscribe React to the canonical snapshot owned by a GridController.
5
+ * Revision-only transaction commits preserve the visible snapshot identity.
6
+ */
7
+ export declare const useGridControllerSnapshot: (controller: GridController) => GridSnapshot;
@@ -0,0 +1,53 @@
1
+ import { type ReactElement, type ReactNode, type RefCallback } from "react";
2
+ import type { DragContextCancelTabDragHandler, DragContextDetachTabHandler, DragContextDropHandler } from "./drag-drop-next/DragContextNext";
3
+ import { type GridLayoutDispatch, type GridLayoutDropHandler } from "./GridLayoutContext";
4
+ import { type GridLayoutItemProps } from "./GridLayoutItem";
5
+ import { GridLayoutModel } from "./GridLayoutModel";
6
+ import { type GridLayoutDragEndHandler } from "./GridLayoutProvider";
7
+ import { type GridColumnsAndRows, type GridLayoutChangeHandler, GridModel, type ISplitter } from "./GridModel";
8
+ import type { GridLayoutDragStartHandler } from "./useDraggable";
9
+ import { GridController } from "./GridController";
10
+ export type GridLayoutHookProps = {
11
+ children: ReactNode;
12
+ id: string;
13
+ colsAndRows?: GridColumnsAndRows;
14
+ onChange?: GridLayoutChangeHandler;
15
+ };
16
+ type NonContentGridItems = {
17
+ placeholders: Array<{
18
+ id: string;
19
+ snapshotId: string;
20
+ }>;
21
+ splitters: ISplitter[];
22
+ stackIds: string[];
23
+ };
24
+ /**
25
+ * Create the GridModel and bind model changes to DOM changes.
26
+ * The GridModel is constructed from a GridLayoutDescriptor, which may
27
+ * have been passed explicitly or extracted from GridLayoutItems.
28
+ *
29
+ * Create the list of GridLayoutItem elements to be rendered.
30
+ * The GridLayoutItem elements may be explicitly coded in JSX.
31
+ */
32
+ export declare const useGridLayout: ({ children: childrenProp, id, colsAndRows, onChange, }: GridLayoutHookProps) => {
33
+ children: ReactElement<GridLayoutItemProps, string | import("react").JSXElementConstructor<any>>[];
34
+ containerCallback: RefCallback<HTMLDivElement>;
35
+ containerRef: import("react").RefObject<HTMLDivElement | null>;
36
+ dispatchGridLayoutAction: GridLayoutDispatch;
37
+ gridController: GridController;
38
+ gridLayoutModel: GridLayoutModel;
39
+ gridModel: GridModel;
40
+ gridSnapshot: import("./GridSnapshot").GridSnapshot;
41
+ nonContentGridItems: NonContentGridItems;
42
+ onCancelDrag: () => void;
43
+ onCancelTabDrag: DragContextCancelTabDragHandler;
44
+ onDetachTab: DragContextDetachTabHandler;
45
+ onDragEnd: GridLayoutDragEndHandler;
46
+ onDragLeave: () => void;
47
+ onDragPreview: GridLayoutDropHandler;
48
+ onDragStart: GridLayoutDragStartHandler;
49
+ onDrop: GridLayoutDropHandler;
50
+ onDropStackedItem: DragContextDropHandler;
51
+ stackTemplates: Map<string, ReactElement<GridLayoutItemProps, string | import("react").JSXElementConstructor<any>>>;
52
+ };
53
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type MouseEventHandler } from "react";
2
+ import type { GridLayoutProps } from "./GridLayout";
3
+ import type { GridLayoutModel } from "./GridLayoutModel";
4
+ import { type GridModel } from "./GridModel";
5
+ import type { GridController } from "./GridController";
6
+ export type SplitterResizingHookProps = Pick<GridLayoutProps, "id" | "onClick" | "rowResizeDistribution"> & {
7
+ gridController: GridController;
8
+ gridLayoutModel: GridLayoutModel;
9
+ gridModel: GridModel;
10
+ };
11
+ export declare const useGridSplitterResizing: ({ gridController, gridLayoutModel: layoutModel, gridModel, onClick: onClickProp, rowResizeDistribution, }: SplitterResizingHookProps) => {
12
+ onClick: MouseEventHandler<HTMLDivElement>;
13
+ onMouseDown: MouseEventHandler;
14
+ };
@@ -0,0 +1 @@
1
+ export declare const useNotDropTarget: () => {};