Files
Trilium/packages/splitjs/index.d.ts

101 lines
3.0 KiB
TypeScript
Raw Permalink Normal View History

2020-06-10 18:39:30 +02:00
// Type definitions for Split.js
// Project: https://github.com/nathancahill/split/tree/master/packages/splitjs
2018-11-04 14:32:14 -07:00
// Definitions by: Ilia Choly <https://github.com/icholy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// Global variable outside module loader
2020-06-10 18:39:30 +02:00
export as namespace Split
2018-11-04 14:32:14 -07:00
// Module loader
2020-06-10 18:39:30 +02:00
export = Split
2018-11-04 14:32:14 -07:00
declare function Split(
2020-06-10 18:39:30 +02:00
elements: Array<string | HTMLElement>,
options?: Split.Options,
): Split.Instance
2018-11-04 14:32:14 -07:00
declare namespace Split {
2020-06-10 18:39:30 +02:00
type Partial<T> = { [P in keyof T]?: T[P] }
type CSSStyleDeclarationPartial = Partial<CSSStyleDeclaration>
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
interface Options {
// Initial sizes of each element in percents or CSS values.
sizes?: number[]
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Minimum size of each element.
minSize?: number | number[]
2018-11-04 14:32:14 -07:00
2021-04-05 08:57:28 -04:00
// Maximum size of each element.
maxSize?: number | number[]
2020-06-10 18:39:30 +02:00
expandToMin?: boolean
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Gutter size in pixels.
gutterSize?: number
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
gutterAlign?: string
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Snap to minimum size offset in pixels.
snapOffset?: number | number[]
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
dragInterval?: number
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Direction to split: horizontal or vertical.
direction?: 'horizontal' | 'vertical'
2018-11-04 14:32:14 -07:00
// If the UI is right-to-left. Affects the drag direction.
rtl?: boolean
2020-06-10 18:39:30 +02:00
// Cursor to display while dragging.
cursor?: string
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Callback on drag.
2020-06-15 14:49:22 -04:00
onDrag?(sizes: number[]): void
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Callback on drag start.
2020-06-15 14:49:22 -04:00
onDragStart?(sizes: number[]): void
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Callback on drag end.
2020-06-15 14:49:22 -04:00
onDragEnd?(sizes: number[]): void
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Called to create each gutter element
gutter?(
index: number,
direction: 'horizontal' | 'vertical',
): HTMLElement
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Called to set the style of each element.
elementStyle?(
dimension: 'width' | 'height',
elementSize: number,
gutterSize: number,
index: number,
): CSSStyleDeclarationPartial
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Called to set the style of the gutter.
gutterStyle?(
dimension: 'width' | 'height',
gutterSize: number,
index: number,
): CSSStyleDeclarationPartial
}
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
interface Instance {
// setSizes behaves the same as the sizes configuration option, passing an array of percents or CSS values.
// It updates the sizes of the elements in the split.
setSizes(sizes: number[]): void
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// getSizes returns an array of percents, suitable for using with setSizes or creation.
getSizes(): number[]
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// collapse changes the size of element at index to 0.
// Every element except the last is collapsed towards the front (left or top).
// The last is collapsed towards the back.
collapse(index: number): void
2018-11-04 14:32:14 -07:00
2020-06-10 18:39:30 +02:00
// Destroy the instance. It removes the gutter elements, and the size CSS styles Split.js set.
destroy(preserveStyles?: boolean, preserveGutters?: boolean): void
}
2018-11-04 14:32:14 -07:00
}