Options
All
  • Public
  • Public/Protected
  • All
Menu

@lbfalvy/pro-ui

Index

ContextMenu Interfaces

Other Interfaces

Splits Interfaces

TabSplits Interfaces

Tabs Interfaces

ContextMenu Type aliases

Other Type aliases

ContextMenu Variables

ContextMenu Functions

Other Functions

Splits Functions

TabSplits Functions

Tabs Functions

ContextMenu Type aliases

ContextMenuOption

ContextMenuOption: [React.ReactNode, (() => void) | ContextMenuOption[] | undefined | null | false]

The first element is the title, the second is the action. If the action is a function, it is executed. If it is an array, it is rendered as a submenu. If it is falsy, it is treated as a disabled menu item.

Other Type aliases

Axis

Axis: "y" | "x"

Specifies one of the two axes.

ID

ID: string | number

An identifier that is unique to some context. Assignable to React's key.

Side

Side: "top" | "left" | "bottom" | "right"

Specifies one of the four sides.

ContextMenu Variables

Const MenuCtx

MenuCtx: Context<MenuContext> = ...

The context menu context. You can use it directly to set the submenu timeout, create a menu provider that doesn't inherit the parent's options, or provide an alternative means of displaying the menu.

ContextMenu Functions

ContextMenu

  • A context menu component. Use it like a context provider, pass the context menu entries in options. It will add them to the menu, but it will also show all options from enclosing ContextMenu instances. Also note that this inserts a new div into the DOM, any props other than options and children are passed directly to that div.

    The menu is rendered with DropdownMenu but you can also call it directly.

    Parameters

    Returns React.ReactElement

DropdownMenu

Other Functions

useDimensions

  • useDimensions<T>(): [React.Ref<T>, Dimensions, boolean]
  • Determines the dimensions of the element, effectively a hook for getBoundingClientRect. Unlike every other implementation online, this one does actually seem to catch every movement and size change, even those caused by only moving or resizing the element with JavaScript.

    WARNING: This hook is not debounced or rate limited. Do not use it to track continuous motion.

    Type parameters

    • T: HTMLElement

    Returns [React.Ref<T>, Dimensions, boolean]

    ref, size of the value of ref, whether anything is visible

Splits Functions

Splits

  • Splits<T>(__namedParameters: SplitsProps<T>): Element
  • A drag and drop split container inspired by Visual Studio and the Unity Editor. It supports resizing by dragging if onResize is defined and a SplitsLayer component covers the whole container, and supports reorganising by drag and drop if onSplit and splitTypes are set.

    If you want to use it with Tabs, check out TabSplits.

    Type parameters

    • T

    Parameters

    Returns Element

SplitsLayer

  • SplitsLayer(): React.ReactElement | null
  • A component to attach position data to Splits borders while dragging. It also renders a nice constrained overlay blue line.

    Returns React.ReactElement | null

editSplitData

fixSplitSizes

  • fixSplitSizes<T>(def: SplitData<T>, minSize: number, box: { x: number; y: number }, border?: number): SplitData<T>
  • fixSplitSizes<T>(def: T, minSize: number, box: { x: number; y: number }, border?: number): T
  • Fixes the sizes in a split tree to negate problems like negative width that emerge from naiive implementations of other transformations.

    Type parameters

    • T

    Parameters

    • def: SplitData<T>
    • minSize: number

      Minimum allowed size of a split

    • box: { x: number; y: number }

      Bounding box of def

      • x: number
      • y: number
    • Optional border: number

      Border width

    Returns SplitData<T>

  • Type parameters

    • T

    Parameters

    • def: T
    • minSize: number
    • box: { x: number; y: number }
      • x: number
      • y: number
    • Optional border: number

    Returns T

fixSplitTree

  • Inline children of the same axis and remove empty containers from the tree.

    Type parameters

    • T

    Parameters

    • def: SplitData<T>
    • Optional filterLeaves: (t: T) => boolean
        • (t: T): boolean
        • Parameters

          • t: T

          Returns boolean

    Returns SplitData<T>

  • Type parameters

    • T

    Parameters

    • def: T | SplitData<T>
    • Optional filterLeaves: (t: T) => boolean
        • (t: T): boolean
        • Parameters

          • t: T

          Returns boolean

    Returns T | SplitData<T>

getSplitData

  • Create a node for the Splits definition tree.

    Type parameters

    • T

    Parameters

    • axis: Axis

      In which direction to lay out the children

    • children: SplitChild<T>[]

      Sub-elements or subcontainers and their relative sizes.

    Returns SplitData<T>

isSplitData

  • Identifies subcontainer definitions in contrast to other objects. It uses a TYPE_ID field so that it works in scenarios where runtime type assertions like instanceof, in and Object methods don't, like Immer drafts.

    Type parameters

    • T = ReactNode

    Parameters

    Returns x is SplitData<T>

    whether x is a subcontainer definition

resizeSplit

  • resizeSplit<T>(data: SplitData<T>, path: number[], index: number, amount: number): SplitData<T>
  • Moves a border in the grid. This may leave negative sized cells and other artifacts so call fixSplitSizes on the result.

    Type parameters

    • T

    Parameters

    • data: SplitData<T>
    • path: number[]
    • index: number

      Index of the node before (left/up) the moved border

    • amount: number

      Change, in relation to the parent's appropriate dimension

    Returns SplitData<T>

subdivideSplit

  • Splits a tree node. This may leave parallel child containers and other artifacts on the tree, so call fixSplitTree after you're finished with the transformations. Additionally, because it moves a subtree, use transposeSplitTree to update all affected if you are storing the access paths in the nodes.

    Type parameters

    • T

    Parameters

    Returns SplitData<T>

transposeSplitTree

  • transposeSplitTree<T, U>(data: SplitData<T>, path: null, callback: (fullPath: number[], leaf: T) => U): SplitData<U>
  • transposeSplitTree<T, U>(data: SplitData<T>, path: number[], callback: (fullPath: number[], leaf: T) => U): SplitData<T | U>
  • transposeSplitTree<T, U>(data: T | SplitData<T>, path: null, callback: (fullPath: number[], leaf: T) => U): U | SplitData<U>
  • transposeSplitTree<T, U>(data: T | SplitData<T>, path: number[], callback: (fullPath: number[], leaf: T) => U): T | U | SplitData<T | U>
  • Recursively visits every node in the specified subtree with the correct full path and the old node. Use this to update any stored instances of the access path after tree transformations like executeSplit and fixTopology

    Type parameters

    • T

    • U

    Parameters

    • data: SplitData<T>
    • path: null
    • callback: (fullPath: number[], leaf: T) => U
        • (fullPath: number[], leaf: T): U
        • Parameters

          • fullPath: number[]
          • leaf: T

          Returns U

    Returns SplitData<U>

  • Type parameters

    • T

    • U

    Parameters

    • data: SplitData<T>
    • path: number[]
    • callback: (fullPath: number[], leaf: T) => U
        • (fullPath: number[], leaf: T): U
        • Parameters

          • fullPath: number[]
          • leaf: T

          Returns U

    Returns SplitData<T | U>

  • Type parameters

    • T

    • U

    Parameters

    • data: T | SplitData<T>
    • path: null
    • callback: (fullPath: number[], leaf: T) => U
        • (fullPath: number[], leaf: T): U
        • Parameters

          • fullPath: number[]
          • leaf: T

          Returns U

    Returns U | SplitData<U>

  • Type parameters

    • T

    • U

    Parameters

    • data: T | SplitData<T>
    • path: number[]
    • callback: (fullPath: number[], leaf: T) => U
        • (fullPath: number[], leaf: T): U
        • Parameters

          • fullPath: number[]
          • leaf: T

          Returns U

    Returns T | U | SplitData<T | U>

traverseSplitTree

  • Traverses the tree and returns the node at the end of the path Use for reading and with immer

    Type parameters

    • T

    Parameters

    Returns T | SplitData<T>

TabSplits Functions

TabSplits

  • A component that combines Tabs and Splits into an easy to use, ready-made package. With this and a reducer that calls the provided utility functions, you can set up a functioning tabbed split view in a matter of minutes.

    Parameters

    Returns React.ReactElement

moveTab

splitWithTab

  • Moves a tab to a brand new leaf created by splitting a container

    Parameters

    • data: TabData<number[]>[] | SplitData<TabData<number[]>[]>
    • path: number[]

      Leaf to split

    • side: Side

      Which side the new item goes

    • id: ID

      ID of the moved tab

    • from: number[]

      Leaf the tab was moved from

    Returns SplitData<TabData<number[]>[]>

Tabs Functions

Tabs

  • Tabs<T>(__namedParameters: TabsProps<T>): React.ReactElement
  • Tabbed view component with the ability to reorder tabs by drag and drop and to move them across containers. Use removeTab in an appropriate event handler to achieve this functionality.

    Type parameters

    • T

      type of the metadata field

    Parameters

    Returns React.ReactElement

removeTab

  • Removes and returns the tab with the given ID from the collection. Use this to retrieve the dragged tab and insert it in the new location with a simple data.splice(0, tab) to execute a tab drag action.

    Type parameters

    • T

    Parameters

    • tabs: TabData<T>[]

      Tabs state

    • id: ID

      Tab to be removed

    Returns TabData<T> | undefined

    The removed tab

Generated using TypeDoc