@lonli-lokli/react-mosaic-component
Version:
A React Tiling Window Manager
64 lines (61 loc) • 2.68 kB
text/typescript
import { d as MosaicDirection } from '../../types-D_JoxNST.mjs';
import 'immutability-helper';
import 'react';
/**
* Each of these values is like the CSS property of the same name, but in percentages.
* A BoundingBox of { top: 0, right: 0, bottom: 0, left: 0 } represents the entire viewport.
*/
interface BoundingBox {
top: number;
right: number;
bottom: number;
left: number;
}
/**
* Returns an "empty" BoundingBox that covers the entire viewport.
*/
declare function emptyBoundingBox(): BoundingBox;
/**
* Represents the CSS styles for a BoundingBox.
*/
interface BoundingBoxStyles {
top: string;
right: string;
bottom: string;
left: string;
}
/**
* Splits a BoundingBox into N sub-boxes based on an array of percentages.
*
* @param box The parent BoundingBox to split.
* @param percentages An array of numbers (0-100) that must sum to 100.
* @param direction The direction to split in.
* @returns An array of BoundingBox objects.
*/
declare function splitBoundingBox(box: BoundingBox, percentages: number[], direction: MosaicDirection): BoundingBox[];
/**
* Converts a BoundingBox to a set of CSS styles.
*/
declare function boundingBoxAsStyles({ top, right, bottom, left, }: BoundingBox): BoundingBoxStyles;
/**
* Converts a percentage relative to a bounding box to a percentage relative to the viewport.
* This is used by the `Split` component to calculate its absolute CSS `left` or `top` style.
*
* @param boundingBox The container the percentage is relative to.
* @param relativeSplitPercentage The percentage (0-100) within the container.
* @param direction The direction of the split.
* @returns The absolute percentage (0-100) relative to the viewport.
*/
declare function getAbsoluteSplitPercentage(boundingBox: BoundingBox, relativeSplitPercentage: number, direction: MosaicDirection): number;
/**
* Converts a percentage relative to the viewport (e.g., a mouse coordinate)
* to a percentage relative to a bounding box.
* This is used by the `Split` component to calculate the new relative percentage during a drag.
*
* @param boundingBox The container to make the percentage relative to.
* @param absoluteSplitPercentage The absolute percentage (0-100) from the viewport.
* @param direction The direction of the split.
* @returns The percentage (0-100) relative to the given boundingBox.
*/
declare function getRelativeSplitPercentage(boundingBox: BoundingBox, absoluteSplitPercentage: number, direction: MosaicDirection): number;
export { type BoundingBox, type BoundingBoxStyles, boundingBoxAsStyles, emptyBoundingBox, getAbsoluteSplitPercentage, getRelativeSplitPercentage, splitBoundingBox };