npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@flexboard/core

v0.1.2

Published

Headless recursive split-layout engine for FlexBoard

Readme

@flexboard/core

Headless recursive split-layout engine for FlexBoard.

@flexboard/core provides the framework-agnostic layout engine behind FlexBoard. It represents layouts as recursive split trees and provides utilities for geometry calculation, panel tree operations, drag-and-drop targeting, and divider resizing.

It has no dependency on React, Vue, or the DOM.

Installation

pnpm add @flexboard/core
npm install @flexboard/core

Layout Model

FlexBoard represents a layout as a recursive tree composed of two node types:

  • ActualNode — a leaf node representing a panel.
  • SplitNode — a branch that recursively divides an area into two child nodes.

For example:

import type { LayoutNode } from "@flexboard/core";

const layout: LayoutNode = {
  type: "split",
  id: "root",
  orientation: "H",
  size: 0.6,

  first: {
    type: "actual",
    id: "chart",
  },

  second: {
    type: "split",
    id: "right",
    orientation: "V",
    size: 0.5,

    first: {
      type: "actual",
      id: "orders",
    },

    second: {
      type: "actual",
      id: "info",
    },
  },
};

Conceptually, the tree above represents:

┌─────────────────────┬───────────────┐
│                     │    orders     │
│        chart        ├───────────────┤
│                     │     info      │
└─────────────────────┴───────────────┘

Because the layout is recursive, nested split layouts can be represented without coupling the engine to a specific UI framework.

Geometry

calculateLayout

Calculates panel and divider rectangles from a layout tree and container size.

import { calculateLayout, type LayoutNode } from "@flexboard/core";

const result = calculateLayout(
  layout,
  {
    width: 1200,
    height: 800,
  },
  8,
);

console.log(result.panels);
console.log(result.dividers);

The resulting geometry can be consumed by any renderer.

Exported geometry types include:

Size;
Point;
PanelRect;
DividerRect;
LayoutRects;

Tree Operations

FlexBoard provides immutable tree operations for manipulating layouts.

addPanelToLayout

Adds a panel to a layout.

import { addPanelToLayout } from "@flexboard/core";

removePanel

Removes a panel from the layout tree.

import { removePanel } from "@flexboard/core";

const nextLayout = removePanel(layout, "orders");

if (nextLayout) {
  // use nextLayout
}

Removing a panel may collapse its surrounding split structure as the recursive tree is rebuilt.

insertPanelNear

Inserts a panel next to an existing target panel.

import { insertPanelNear } from "@flexboard/core";

const nextLayout = insertPanelNear(layout, "chart", "new-panel", "right");

This is useful for implementing panel insertion and external drag-and-drop.

movePanel

Moves an existing panel to another position in the layout tree.

import { movePanel } from "@flexboard/core";

This operation can be used as the basis for internal panel drag-and-drop.

Drag and Drop

getDropDirection

Determines a drop direction.

import { getDropDirection } from "@flexboard/core";

detectDropTarget

Detects a drop target from the current panel geometry.

import { detectDropTarget } from "@flexboard/core";

Exported drag-and-drop types include:

DropDirection;
DropTarget;
DropTargetOptions;

Resize

resizeSplit

Updates the ratio of a split node.

import { resizeSplit } from "@flexboard/core";

The associated options type is also exported:

import type { ResizeSplitOptions } from "@flexboard/core";

Public API

Layout

ActualNode;
SplitNode;
LayoutNode;

Geometry

Size;
Point;
PanelRect;
DividerRect;
LayoutRects;

calculateLayout;

Tree Operations

addPanelToLayout;
removePanel;
insertPanelNear;
movePanel;

Drag and Drop

DropDirection;
DropTarget;
DropTargetOptions;

getDropDirection;
detectDropTarget;

Resize

ResizeSplitOptions;

resizeSplit;

Framework Adapters

Most application developers will want to use one of the framework adapters instead of interacting with the core engine directly:

pnpm add @flexboard/react

or:

pnpm add @flexboard/vue

The adapters provide framework-specific rendering and interaction while using @flexboard/core as the underlying layout engine.

Use @flexboard/core directly when building a custom renderer, integrating FlexBoard with another framework, or working with the layout tree independently of a UI.

License

MIT