@vuu-ui/vuu-layout 0.8.8-debug → 0.8.9-debug

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 (35) hide show
  1. package/cjs/index.js +35111 -4306
  2. package/cjs/index.js.map +4 -4
  3. package/esm/index.js +35538 -4414
  4. package/esm/index.js.map +4 -4
  5. package/index.css +2326 -264
  6. package/index.css.map +3 -3
  7. package/package.json +3 -5
  8. package/types/drag-drop/Draggable.d.ts +3 -2
  9. package/types/drag-drop/DropTarget.d.ts +1 -1
  10. package/types/drag-drop/dragDropTypes.d.ts +2 -2
  11. package/types/index.d.ts +2 -1
  12. package/types/layout-provider/LayoutProvider.d.ts +4 -3
  13. package/types/layout-provider/LayoutProviderContext.d.ts +3 -2
  14. package/types/layout-provider/useLayoutDragDrop.d.ts +1 -1
  15. package/types/layout-reducer/flexUtils.d.ts +1 -1
  16. package/types/layout-reducer/layoutTypes.d.ts +7 -0
  17. package/types/layout-reducer/layoutUtils.d.ts +4 -1
  18. package/types/layout-view/ViewContext.d.ts +12 -3
  19. package/types/measured-container/MeasuredContainer.d.ts +9 -0
  20. package/types/measured-container/index.d.ts +2 -0
  21. package/types/measured-container/useMeasuredContainer.d.ts +22 -0
  22. package/types/measured-container/useResizeObserver.d.ts +15 -0
  23. package/types/overflow-container/OverflowContainer.d.ts +3 -0
  24. package/types/overflow-container/overflow-utils.d.ts +1 -1
  25. package/types/overflow-container/useOverflowContainer.d.ts +11 -4
  26. package/types/palette/Palette.d.ts +4 -3
  27. package/types/toolbar/Toolbar.d.ts +11 -0
  28. package/types/toolbar/index.d.ts +1 -0
  29. package/types/toolbar/tabstrip-dom-utils.d.ts +2 -0
  30. package/types/toolbar/useKeyboardNavigation.d.ts +29 -0
  31. package/types/toolbar/useSelection.d.ts +22 -0
  32. package/types/toolbar/useToolbar.d.ts +22 -0
  33. package/types/utils/pathUtils.d.ts +14 -1
  34. package/types/utils/propUtils.d.ts +1 -1
  35. package/types/common-types.d.ts +0 -8
@@ -1,4 +1,4 @@
1
1
  import { MutableRefObject, ReactElement } from "react";
2
2
  import { DragStartAction } from "../layout-reducer";
3
3
  import { LayoutProviderDispatch } from "./LayoutProviderContext";
4
- export declare const useLayoutDragDrop: (rootLayoutRef: MutableRefObject<ReactElement>, dispatch: LayoutProviderDispatch) => (action: DragStartAction) => void;
4
+ export declare const useLayoutDragDrop: (rootLayoutRef: MutableRefObject<ReactElement>, dispatch: LayoutProviderDispatch, pathToDropTarget?: string) => (action: DragStartAction) => void;
@@ -1,5 +1,5 @@
1
+ import { dimension, rect, rectTuple } from "@vuu-ui/vuu-utils";
1
2
  import React, { CSSProperties, ReactElement, ReactNode } from "react";
2
- import { dimension, rect, rectTuple } from "../common-types";
3
3
  import { DropPos } from "../drag-drop/dragDropTypes";
4
4
  export type flexDirection = "row" | "column";
5
5
  type contraDimension = dimension;
@@ -120,6 +120,7 @@ export type LayoutResizeAction = {
120
120
  type: typeof LayoutActionType.LAYOUT_RESIZE;
121
121
  };
122
122
  export type SwitchTabAction = {
123
+ id?: string;
123
124
  nextIdx: number;
124
125
  path: string;
125
126
  type: typeof LayoutActionType.SWITCH_TAB;
@@ -157,3 +158,9 @@ export type DragStartAction = {
157
158
  path: string;
158
159
  type: typeof LayoutActionType.DRAG_START;
159
160
  };
161
+ export type LayoutLevelChange = "switch-active-tab" | "edit-feature-title" | "save-feature-props" | "resize-component" | "remove-component" | "drag-drop-operation";
162
+ export type ApplicationLevelChange = "switch-active-layout" | "open-layout" | "close-layout" | "rename-layout";
163
+ export type LayoutChangeReason = LayoutLevelChange | ApplicationLevelChange;
164
+ export type LayoutChangeHandler = (layout: LayoutJSON, layoutChangeReason: LayoutChangeReason) => void;
165
+ export declare const isApplicationLevelChange: (layoutChangeReason: LayoutChangeReason) => layoutChangeReason is ApplicationLevelChange;
166
+ export declare const isLayoutLevelChange: (layoutChangeReason: LayoutChangeReason) => layoutChangeReason is LayoutLevelChange;
@@ -1,5 +1,5 @@
1
+ import { dimension } from "@vuu-ui/vuu-utils";
1
2
  import React, { CSSProperties, ReactElement } from "react";
2
- import { dimension } from "../common-types";
3
3
  import { ComponentWithId } from "../registry/ComponentRegistry";
4
4
  import { LayoutJSON, LayoutModel, layoutType } from "./layoutTypes";
5
5
  export declare const getManagedDimension: (style: CSSProperties) => [dimension, dimension];
@@ -18,6 +18,9 @@ export interface LayoutProps extends ComponentWithId {
18
18
  type?: string;
19
19
  version?: number;
20
20
  }
21
+ /**
22
+ * parse the declarative JSX and clone adding layout attributes
23
+ */
21
24
  export declare const processLayoutElement: (layoutElement: ReactElement, previousLayout?: ReactElement) => ReactElement;
22
25
  export declare const applyLayout: (type: layoutType, props: LayoutProps, previousLayout?: LayoutModel) => LayoutModel;
23
26
  export declare function layoutFromJson({ id, type, children, props, state }: LayoutJSON, path: string): ReactElement;
@@ -1,7 +1,16 @@
1
1
  import React, { SyntheticEvent } from "react";
2
2
  import { ViewAction } from "./viewTypes";
3
3
  export type ViewDispatch = <Action extends ViewAction = ViewAction>(action: Action, evt?: SyntheticEvent) => Promise<boolean | void>;
4
- export interface ViewContextProps {
4
+ /**
5
+ * This API is available to any Feature hosted within Vuu (as all Features are wrapped
6
+ * with View component). It offers metadata about the View as well as access to the
7
+ * Vuu persistencew API;
8
+ */
9
+ export interface ViewContextAPI {
10
+ /**
11
+ * disdpatcher for View actions. These are a subset of LayoutActions, specifically for
12
+ * View manipulation
13
+ */
5
14
  dispatch?: ViewDispatch | null;
6
15
  id?: string;
7
16
  load?: (key?: string) => unknown;
@@ -16,6 +25,6 @@ export interface ViewContextProps {
16
25
  }) => void;
17
26
  title?: string;
18
27
  }
19
- export declare const ViewContext: React.Context<ViewContextProps>;
28
+ export declare const ViewContext: React.Context<ViewContextAPI>;
20
29
  export declare const useViewDispatch: () => ViewDispatch | null;
21
- export declare const useViewContext: () => ViewContextProps;
30
+ export declare const useViewContext: () => ViewContextAPI;
@@ -0,0 +1,9 @@
1
+ import { HTMLAttributes } from "react";
2
+ import { MeasuredSize } from "./useMeasuredContainer";
3
+ import "./MeasuredContainer.css";
4
+ export interface MeasuredContainerProps extends HTMLAttributes<HTMLDivElement> {
5
+ height?: number | string;
6
+ onResize?: (size: MeasuredSize) => void;
7
+ width?: number | string;
8
+ }
9
+ export declare const MeasuredContainer: import("react").ForwardRefExoticComponent<MeasuredContainerProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ export * from "./MeasuredContainer";
2
+ export * from "./useMeasuredContainer";
@@ -0,0 +1,22 @@
1
+ import { CSSProperties, RefObject } from "react";
2
+ import { MeasuredContainerProps } from "./MeasuredContainer";
3
+ export interface ClientSize {
4
+ clientHeight: number;
5
+ clientWidth: number;
6
+ }
7
+ export interface MeasuredProps extends Pick<MeasuredContainerProps, "height" | "onResize" | "width"> {
8
+ defaultHeight?: number;
9
+ defaultWidth?: number;
10
+ }
11
+ export type CssSize = Pick<CSSProperties, "height" | "width">;
12
+ export interface MeasuredSize {
13
+ height: number;
14
+ width: number;
15
+ }
16
+ export interface MeasuredContainerHookResult {
17
+ containerRef: RefObject<HTMLDivElement>;
18
+ cssSize: CssSize;
19
+ outerSize: CssSize;
20
+ innerSize?: MeasuredSize;
21
+ }
22
+ export declare const useMeasuredContainer: ({ defaultHeight, defaultWidth, height, onResize: onResizeProp, width, }: MeasuredProps) => MeasuredContainerHookResult;
@@ -0,0 +1,15 @@
1
+ import { RefObject } from "react";
2
+ export declare const WidthHeight: string[];
3
+ export declare const WidthOnly: string[];
4
+ export type measurements<T = string | number> = {
5
+ height?: T;
6
+ clientHeight?: number;
7
+ clientWidth?: number;
8
+ contentHeight?: number;
9
+ contentWidth?: number;
10
+ scrollHeight?: number;
11
+ scrollWidth?: number;
12
+ width?: T;
13
+ };
14
+ export type ResizeHandler = (measurements: measurements<number>) => void;
15
+ export declare function useResizeObserver(ref: RefObject<Element | HTMLElement | null>, dimensions: readonly string[], onResize: ResizeHandler, reportInitialSize?: boolean): void;
@@ -3,10 +3,13 @@ import React, { HTMLAttributes } from "react";
3
3
  import { OverflowItem } from "./overflow-utils";
4
4
  import "./OverflowContainer.css";
5
5
  export interface OverflowContainerProps extends HTMLAttributes<HTMLDivElement> {
6
+ allowDragDrop?: boolean;
6
7
  debugId?: string;
7
8
  height: number;
9
+ onMoveItem?: (fromIndex: number, toIndex: number) => void;
8
10
  onSwitchWrappedItemIntoView?: (overflowItem: OverflowItem) => void;
9
11
  orientation?: orientationType;
10
12
  overflowIcon?: string;
13
+ overflowPosition?: "start" | "end" | number;
11
14
  }
12
15
  export declare const OverflowContainer: React.ForwardRefExoticComponent<OverflowContainerProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,4 @@
1
- import { orientationType } from "@salt-ds/lab";
1
+ import { orientationType } from "@vuu-ui/vuu-utils";
2
2
  export type OverflowItem = {
3
3
  index: string;
4
4
  label: string;
@@ -1,13 +1,20 @@
1
+ /// <reference types="react" />
1
2
  import { MenuActionHandler, MenuBuilder } from "@vuu-ui/vuu-data-types";
2
- import { orientationType } from "@vuu-ui/vuu-utils";
3
3
  import { OverflowItem } from "./overflow-utils";
4
- export interface OverflowContainerHookProps {
4
+ import { OverflowContainerProps } from "./OverflowContainer";
5
+ export interface OverflowContainerHookProps extends Pick<OverflowContainerProps, "allowDragDrop" | "onMoveItem" | "orientation"> {
5
6
  itemCount: number;
6
7
  onSwitchWrappedItemIntoView?: (overflowItem: OverflowItem) => void;
7
- orientation?: orientationType;
8
8
  }
9
- export declare const useOverflowContainer: ({ itemCount, onSwitchWrappedItemIntoView, orientation, }: OverflowContainerHookProps) => {
9
+ export declare const useOverflowContainer: ({ allowDragDrop, itemCount, onMoveItem, onSwitchWrappedItemIntoView, orientation, }: OverflowContainerHookProps) => {
10
+ draggable?: JSX.Element | undefined;
11
+ dropIndicator?: JSX.Element | undefined;
12
+ draggedItemIndex?: number | undefined;
13
+ isDragging: boolean;
14
+ isScrolling: import("react").RefObject<boolean>;
15
+ revealOverflowedItems: boolean;
10
16
  menuActionHandler: MenuActionHandler;
11
17
  menuBuilder: MenuBuilder<string, unknown>;
18
+ onItemMouseDown: import("react").MouseEventHandler<Element> | undefined;
12
19
  rootRef: (el: HTMLDivElement | null) => void;
13
20
  };
@@ -1,4 +1,4 @@
1
- import { ListItemProps } from "@salt-ds/lab";
1
+ import { ListItemProps } from "@vuu-ui/vuu-ui-controls";
2
2
  import { HTMLAttributes, ReactElement } from "react";
3
3
  import { ViewProps } from "../layout-view";
4
4
  import "./Palette.css";
@@ -11,10 +11,11 @@ export interface PaletteItemProps extends ListItemProps {
11
11
  resizeable?: boolean;
12
12
  }
13
13
  export declare const PaletteItem: import("react").MemoExoticComponent<({ className, children: component, idx, resizeable, header, closeable, ...props }: PaletteItemProps) => JSX.Element>;
14
- export interface PaletteProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
14
+ export interface PaletteProps extends Omit<HTMLAttributes<HTMLDivElement>, "onDragStart" | "onDrop" | "onSelect"> {
15
15
  children: ReactElement[];
16
+ itemHeight?: number;
16
17
  orientation: "horizontal" | "vertical";
17
18
  selection?: string;
18
19
  ViewProps?: Partial<ViewProps>;
19
20
  }
20
- export declare const Palette: ({ children, className, orientation, ViewProps, ...props }: PaletteProps) => JSX.Element;
21
+ export declare const Palette: ({ children, className, itemHeight, orientation, ViewProps, ...props }: PaletteProps) => JSX.Element;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { OverflowContainerProps } from "../overflow-container";
3
+ import { SelectionStrategy, SpecialKeyMultipleSelection } from "@vuu-ui/vuu-ui-controls";
4
+ import "./Toolbar.css";
5
+ export interface ToolbarProps extends OverflowContainerProps {
6
+ activeItemIndex?: number[];
7
+ defaultActiveItemIndex?: number[];
8
+ onActiveChange?: (tabIndex: number[]) => void;
9
+ selectionStrategy?: SelectionStrategy | SpecialKeyMultipleSelection;
10
+ }
11
+ export declare const Toolbar: ({ activeItemIndex: activeItemIndexProp, defaultActiveItemIndex, children, className: classNameProp, id: idProp, onActiveChange, orientation, selectionStrategy, ...props }: ToolbarProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Toolbar";
@@ -0,0 +1,2 @@
1
+ export declare const getIndexOfSelectedTab: (container: HTMLElement | null) => number;
2
+ export declare const getIndexOfEditedItem: (container: HTMLElement | null) => number;
@@ -0,0 +1,29 @@
1
+ import { orientationType } from "@vuu-ui/vuu-utils";
2
+ import { FocusEvent, FocusEventHandler, KeyboardEvent, MouseEvent as ReactMouseEvent, MouseEventHandler, RefObject } from "react";
3
+ export interface ContainerNavigationProps {
4
+ onBlur: FocusEventHandler;
5
+ onFocus: FocusEventHandler;
6
+ onMouseDownCapture: MouseEventHandler;
7
+ onMouseLeave: MouseEventHandler;
8
+ }
9
+ interface TabstripNavigationHookProps {
10
+ containerRef: RefObject<HTMLElement>;
11
+ defaultHighlightedIdx?: number;
12
+ highlightedIdx?: number;
13
+ keyBoardActivation?: "manual" | "automatic";
14
+ orientation: orientationType;
15
+ selectedIndex: number[];
16
+ }
17
+ interface TabstripNavigationHookResult {
18
+ containerProps: ContainerNavigationProps;
19
+ highlightedIdx: number;
20
+ focusItem: (itemIndex: number, immediateFocus?: boolean, withKeyboard?: boolean, delay?: number) => void;
21
+ focusVisible: number;
22
+ focusIsWithinComponent: boolean;
23
+ onClick: (evt: ReactMouseEvent, tabIndex: number) => void;
24
+ onFocus: (evt: FocusEvent<HTMLElement>) => void;
25
+ onKeyDown: (evt: KeyboardEvent) => void;
26
+ setHighlightedIdx: (highlightedIndex: number) => void;
27
+ }
28
+ export declare const useKeyboardNavigation: ({ containerRef, defaultHighlightedIdx, highlightedIdx: highlightedIdxProp, keyBoardActivation, orientation, selectedIndex: selectedItemIndex, }: TabstripNavigationHookProps) => TabstripNavigationHookResult;
29
+ export {};
@@ -0,0 +1,22 @@
1
+ import { SelectionStrategy, SpecialKeyMultipleSelection } from "@vuu-ui/vuu-ui-controls";
2
+ import { MouseEvent, RefObject } from "react";
3
+ export interface SelectionHookProps {
4
+ containerRef: RefObject<HTMLElement>;
5
+ defaultSelected?: number[];
6
+ highlightedIdx: number;
7
+ itemQuery: string;
8
+ onSelectionChange?: (selectedIndices: number[]) => void;
9
+ selected?: number[];
10
+ selectionStrategy: SelectionStrategy | SpecialKeyMultipleSelection;
11
+ }
12
+ export interface ItemHandlers {
13
+ onClick?: (e: MouseEvent, itemIndex: number) => void;
14
+ onKeyDown?: (event: React.KeyboardEvent) => void;
15
+ }
16
+ export interface SelectionHookResult {
17
+ activateItem: (tabIndex: number) => void;
18
+ itemHandlers: ItemHandlers;
19
+ isControlled: boolean;
20
+ selected: number[];
21
+ }
22
+ export declare const useSelection: ({ containerRef, defaultSelected, highlightedIdx, itemQuery, onSelectionChange, selected: selectedProp, selectionStrategy, }: SelectionHookProps) => SelectionHookResult;
@@ -0,0 +1,22 @@
1
+ import type { OverflowItem, ToolbarProps } from "@vuu-ui/vuu-layout";
2
+ import { KeyboardEvent, MouseEvent as ReactMouseEvent, RefObject } from "react";
3
+ export interface ToolbarHookProps extends Pick<ToolbarProps, "activeItemIndex" | "defaultActiveItemIndex" | "onActiveChange">, Required<Pick<ToolbarProps, "orientation" | "selectionStrategy">> {
4
+ containerRef: RefObject<HTMLElement>;
5
+ itemQuery?: string;
6
+ }
7
+ export declare const useToolbar: ({ activeItemIndex: activeItemIndexProp, defaultActiveItemIndex, containerRef, itemQuery, onActiveChange, orientation, selectionStrategy, }: ToolbarHookProps) => {
8
+ activeItemIndex: number[];
9
+ focusVisible: number;
10
+ containerProps: {
11
+ onSwitchWrappedItemIntoView: (item: OverflowItem) => void;
12
+ onBlur: import("react").FocusEventHandler<Element>;
13
+ onFocus: import("react").FocusEventHandler<Element>;
14
+ onMouseDownCapture: import("react").MouseEventHandler<Element>;
15
+ onMouseLeave: import("react").MouseEventHandler<Element>;
16
+ };
17
+ itemProps: {
18
+ onClick: (evt: ReactMouseEvent<HTMLElement>) => void;
19
+ onFocus: (evt: import("react").FocusEvent<HTMLElement, Element>) => void;
20
+ onKeyDown: (evt: KeyboardEvent) => void;
21
+ };
22
+ };
@@ -1,5 +1,18 @@
1
1
  import React, { ReactElement } from "react";
2
- import { LayoutModel } from "../layout-reducer";
2
+ import { LayoutJSON, LayoutModel } from "../layout-reducer";
3
+ /**
4
+ * This is a very specific function at the moment. It resolves a path of the form
5
+ * '#{componentid}.ACTIVE_CHILD'
6
+ * It allows a templated path to be resolved to a concrete path at runtime.
7
+ * The above pattern is used to identify a layout drop target. Further patterns
8
+ * will be added if needed.
9
+ */
10
+ export declare const resolvePath: (source: ReactElement, path?: string) => string;
11
+ /**
12
+ * Similar to resolvePath but operates on a JSON
13
+ * layout structure and returns the matching JSON node.
14
+ */
15
+ export declare const resolveJSONPath: (source: LayoutJSON, path?: string) => LayoutJSON | undefined;
3
16
  export declare function followPathToParent(source: ReactElement, path: string): ReactElement | null;
4
17
  export declare function findTarget(source: LayoutModel, test: (props: any) => boolean): LayoutModel | undefined;
5
18
  export declare function containerOf(source: LayoutModel, target: LayoutModel): LayoutModel | null;
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from "react";
2
2
  import { LayoutModel } from "../layout-reducer";
3
- export declare const getProp: (component: LayoutModel, propName: string) => any;
3
+ export declare const getProp: (component: LayoutModel | undefined, propName: string) => any;
4
4
  export declare const getProps: (component?: LayoutModel) => any;
5
5
  export declare const getChildProp: (container: LayoutModel) => ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
@@ -1,8 +0,0 @@
1
- export interface rect {
2
- bottom: number;
3
- left: number;
4
- right: number;
5
- top: number;
6
- }
7
- export type rectTuple = [number, number, number, number];
8
- export type dimension = 'width' | 'height';