On this page

Import any of these with import type { … } from "jali-layout";. Functions that use them are on jali-layout.

Layout

An instance's arrangement: a tree of rows, columns and tab stacks of panes. The tree is the arrangement the person made; folds, tucks, tab choices and hidden panes are recorded in overlay, so they can be undone without losing a slot. This is what ?l= holds.

interface Layout { version: 1; root: LayoutNode; overlay?: Overlay }

Fields

version1Required
Always 1.
rootLayoutNodeRequired
The top node. A single pane is a valid root.
overlayOverlayOptional
What the layout and the person did on top of the tree. Written by the operations; leave it out when you build a layout.

LayoutNode

One node of the tree. Every node has an id (unique in the layout), a size, and optionally userSized (the person dragged it) and base (the size a divider reset returns to).

type LayoutNode = PaneNode | StackNode | SplitNode

PaneNode

A pane: one object, shown by its kind's component.

interface PaneNode { type: "pane"; id; size; ref: ObjectRef; … }

Fields

type"pane"Required
idNodeIdRequired
Unique in the layout. In a curated page a role's pane id equals its role id.
sizeSizeRequired
Its share of its split.
refObjectRefRequired
What it shows.
userSizedbooleanOptional
The person sized it with a divider.
baseSizeOptional
The size a divider reset returns to. Carried in the layout and the URL.
linkedToNodeIdOptional
The pane it was opened from. Closing that pane drops the link.
followsbooleanOptional
It shows the object selected in linkedTo and changes in place when the selection moves. At most one per source and kind.
keptbooleanOptional
Kept by the person: never reused for another object, never following, the last to fold.
pinnedbooleanOptional
A pinned tab: first in its tab group, left open by Close other tabs and Close tabs to the right, and still pinned if it leaves the group and joins another.
bornnumberOptional
Its age, rising with each open; older panes fold first when over the cap. Panes without one come before new ones.
rolestringOptional
The view of a curated page it fills ("borrower"). Panes without a role were opened by the person.
priority"primary" | "supporting"Optional
Supporting panes give way first when room runs out; a primary pane never folds while another can.

SplitNode

Children side by side ("row") or one above another ("column"), sharing the space by their sizes. Splits nobody sized share by the panes' comfortable and maximum widths; once the person sizes a child, the split keeps its proportions exactly.

interface SplitNode { type: "row" | "column"; id; size; children: LayoutNode[] }

StackNode

A tab group the person made (by merging, a centre drop or a new tab). Groups made by folding are not in the tree; they exist in overlay. active is the shown tab; origin is optional ("user" when set); leave it out in hand-written layouts.

interface StackNode { type: "stack"; id; size; children: PaneNode[]; active: NodeId; origin?: "user" }

Size

A share of a split (weight, relative to the siblings) or a fixed length in pixels. Divider drags store weights, scaled so the ones a drag sets average 1.

type Size = { px: number } | { weight: number }

NodeId

A node's id: 1 to 128 letters, digits, _, ., : or - (orders, pane-3, detail:7). Every id Jali and the builders make fits; a layout from outside with any other id is refused. So are __proto__, constructor and prototype, which name something on every object: pane(ref, { id }) throws in development, setLayout answers "invalid", and a saved layout, a preset or a link holding one is not used (a link is unreadable, and the instance opens its fallback).

type NodeId = string

ObjectRef

What a pane shows: a kind and the params that name the object ({ kind: "order", params: { id: 1041 } }). Params must be strings, finite numbers or booleans.

interface ObjectRef { kind: string; params: Record<string, string | number | boolean> }

Axis

The direction of a split.

type Axis = "row" | "column"

Edge

A side of a pane: where to open or drop. In actions and commands it is a side of the screen, in either reading direction.

type Edge = "left" | "right" | "top" | "bottom"

Direction

The reading direction an instance lays its panes out in (createJali({ dir }), else the page's). Right to left, a row's first child is at the right: the same tree, mirrored on screen.

type Direction = "ltr" | "rtl"

Overlay

What sits on top of the tree. Written by the operations; read it, don't write it.

interface Overlay { tucks; folds; shown; hidden? }

Fields

tucksTuckRecord[]Required
Panes tucked into another pane (their home), in order.
foldsNodeId[]Required
Slots folded for room, in order. The ids are opaque.
shownRecord<NodeId, NodeId>Required
The chosen tab of each folded or tucked group, keyed by the group's home pane.
hiddenNodeId[]Optional
Panes taken off screen with no tab and no slot (a curated page's views in the tabs).

TuckRecord

One tucked pane in Overlay: the pane, the pane it is tucked into (its home), and its place in the order it was tucked. Every tucked pane is here, shown or not; jali.model() says where each pane is now.

interface TuckRecord { pane: NodeId; home: NodeId; seq: number }

ViewState

What the person is looking at, apart from the layout.

interface ViewState { focused?: NodeId; zoomed?: NodeId; scroll?: Record<NodeId, number>; peek?: ObjectRef; focusHistory: NodeId[] }

Fields

focusedNodeIdOptional
The pane with focus (the accent edge).
zoomedNodeIdOptional
The maximised pane. In the URL as zoom.
scrollRecord<NodeId, number>Optional
How far each row that scrolls has scrolled, by the row's id, in px along its content, set where the row comes to rest. In the URL as scroll (week:732); a strip at its start writes nothing, and scrolling replaces the history entry.
peekObjectRefOptional
What the peek sheet shows. Never in the address: a reload closes it.
focusHistoryNodeId[]Required
Panes most recently focused first.

Rect

A box in pixels, relative to the instance's inner area.

interface Rect { x: number; y: number; width: number; height: number }

LayoutInput

Anything that stands for a layout: a builder's result (row(...)), a single ref (a one-pane layout), or a whole Layout. createJali({ layout }), a preset's layout and a page's build all take one.

type LayoutInput = Layout | Draft | ObjectRef

Draft

What the builders return: a layout not yet given ids. Pass it wherever a LayoutInput goes; Jali turns it into a Layout. Name it in a function of your own that builds part of a layout.

type Draft = PaneDraft | SplitDraft | TabsDraft

PaneDraft

What pane returns: one pane, with its options.

type PaneDraft = { type: "pane"; ref: ObjectRef; options: PaneNodeOptions }

SplitDraft

What row and column return: children side by side ("row") or one above the other ("column").

type SplitDraft = { type: Axis; options: RowOptions; children: Draft[] }

TabsDraft

What tabs returns: panes as tabs of one group.

type TabsDraft = { type: "stack"; options: TabsOptions; children: PaneDraft[] }

RowOptions

A row's options. scroll: "x" makes a row that scrolls sideways: each child keeps its own width (its comfortable width until the person sizes it) and the row scrolls to the rest, so nothing folds. To its parent it needs one child's room; to the pane cap it is one slot. Focusing a pane in it scrolls it into view.

interface RowOptions extends SizeOptions { scroll?: "x" }

SizeOptions

A builder node's id and size: a share of its parent (weight, default 1) or a fixed length (px). See row.

interface SizeOptions { id?: NodeId; weight?: number; px?: number }

PaneNodeOptions

The options of pane.

interface PaneNodeOptions extends SizeOptions {
  linkedTo?; follows?; kept?; pinned?; role?; priority?; hidden?: boolean;
}

TabsOptions

The options of tabs.

interface TabsOptions extends SizeOptions { active?: NodeId }

PaneOptions

What a kind says about itself, apart from how it renders. In React, definePane(kind, options) takes these with Component and icon.

interface PaneOptions<P = Params> { params?; title; width?; height?; … }

Fields

paramsParamTypesOptional
What a ref of the kind holds, and how to read each param back from a link, which can turn values into text: { id: Number, tab: optional(String) } gives the component and title { id: number; tab?: string }. A ref missing a required param, or holding a value its type can't read, never reaches the component (see ParamProblem). Without params, params are plain values.
titlestring | ((params: P) => string)Required
The pane's title in its header, its tab and the palette.
widthPaneWidthOptional

Default { min: 240 }

Show width
minnumberOptional

Default 240

The narrowest the content works at, once it adapts. Below it the pane folds into a tab; it is never squeezed past it.
comfortablenumberOptional

Default min

Where spare space takes the pane first, before any sibling grows past its own.
maxnumberOptional

Default none

The widest the content usefully uses. Spare space past it goes to siblings that can use it; only when every sibling is at its maximum does the pane grow on, and the content keeps its measure. Leave it out for tables and charts.
heightPaneHeightOptional

Default { min: 160 }

The same three as width, down a column.

Show height
minnumberOptional

Default 160

The shortest the content works at. Below it the pane folds into a tab.
comfortablenumberOptional

Default min

Where spare height takes the pane first, before any pane above or below grows past its own.
maxnumberOptional

Default none

The tallest the content usefully uses. Spare height past it goes to the panes above and below first; only when every one is at its maximum does the pane grow on. A short, wide pane such as a timeline sets it.
showsstringOptional

Default the kind

The type of object shown, shared by kinds that show the same objects differently. Two panes show the same object when this and their identities match.
identity(params: P) => Identity | undefinedOptional

Default every param, compared as text

What makes two panes of this kind the same object (one object, one pane): a value compared as JSON (text, a number, a flag, or a list or record of those). 1 and "1" are the same by default. One it can't give (it throws, or gives what JSON can't write, such as a bigint) falls back to the default; undefined matches no other pane.
scratchbooleanOptional
Every pane is new (a scratch note, a launcher): never matched against an open pane, and left out of Recent unless inRecent says otherwise.
inRecentboolean | ((params: P) => boolean)Optional

Default true (false for scratch kinds)

Whether opened objects of this kind go in Recent.
holdWhileResizingbooleanOptional
Keep the content as it is during a divider drag and reflow once, on release: for long lists and charts.
allowPaneAllowOptional
What may happen to panes of this kind, for what its content can handle: { fullScreen: false }. A kind can only turn controls off. See PaneAllow.
buttonsPaneButtonsOptional
The buttons in this kind's header, replacing the instance's: a list, or a function that adjusts them ((defaults) => defaults.filter((b) => b !== "tuck")). Leave it out for the instance's, or Jali's. See PaneButtons.
phone{ stack?: boolean; place?: "top" | "bottom" }Optional
Phones only, in stacked view (createJali({ phone: { stack: true } })). stack: false keeps panes of this kind out of it, so they show alone. place asks for the top or the bottom half; otherwise the pane others were opened from goes above.
follow(selected: ObjectRef) => FollowParams<P> | undefinedOptional
What a following pane of this kind shows when its list selects an object of another kind: the params for it, or undefined to keep what it shows. follow: (selected) => ({ symbol: selected.params.symbol }) lets a chart follow a watchlist that selects quotes. A follower of the selected object's own kind shows that object without it. Params given as undefined are left out; if the kind can't read the result (a required param missing), the pane keeps what it shows. See Following a list.
selectsstringOptional
For a list: the kind of the objects it selects ("quote" for a watchlist that reports select(quote(...))). A pane of this kind with no selection starts on what its follower of that kind shows, when the layout gives it one: at start-up, on a link, after a preset or setLayout, in the same change. A follower of another kind gives nothing. See Following a list.

PaneWidth

A kind's widths in px; see width under PaneOptions.

interface PaneWidth { min?: number; comfortable?: number; max?: number }

PaneHeight

A kind's heights in px; see height under PaneOptions.

interface PaneHeight { min?: number; comfortable?: number; max?: number }

PaneDefinition

A defined kind, callable to make its refs. In React, Pane<P>.

type PaneDefinition<P, D> = D & { (params: P): ObjectRef; readonly kind: string }

PaneKindBase

A kind as an instance keeps it: its name and its options. What createJali({ panes }) takes.

interface PaneKindBase extends PaneOptions { kind: string }

Params

A ref's params: plain data, so they fit in a link.

type Params = Record<string, ParamValue>

ParamValue

One param's value.
type ParamValue = string | number | boolean

ParamType

How to read one param back: Number, String, Boolean, oneOf, or your own function. Number reads text that is a finite number; Boolean reads true, false, "true", "false", 1 and 0. Your function says it can't read a value by returning undefined or NaN, or by throwing.

type ParamType = (value: ParamValue) => ParamValue | undefined

ParamTypes

A kind's
type ParamTypes = Record<string, ParamReader | OptionalParam>
params, one by one.

ParamReader

How to read one param: one of Jali's (Number, String, Boolean, oneOf(...), a function), or a Standard Schema of the value from any library that implements it (z.number(), v.picklist([...])). A schema whose output may be undefined (v.optional(…)) lets a ref leave the param out, as optional does.

type ParamReader = ParamType | StandardSchemaV1

Identity

What a kind's
type Identity = string | number | boolean | null | readonly Identity[] | { readonly [key: string]: Identity }
identity gives for one object: any value JSON writes as it is. Two panes show the same object when their kinds' shows and these values, written as JSON, match.

ParamsDeclaration

What params takes: params one by one, or one Standard Schema of the whole object (v.object({ id: v.number() })). A schema decides what is valid, and its output is what the pane gets (ParamsOf infers it); Jali's codec still decides how values are written in a link, and a value a link carries as text is read as a number or a flag when the schema wants one. A value the schema refuses is a ParamProblem, as for Jali's own types. A schema may transform values, but its output must still be params (text, numbers and flags): a field it gives as anything else (an object, a list, a date) is a problem of that param, and the ref keeps what it was given. A schema must validate synchronously. appOnly and link: false are Jali's own: declare params one by one to use them.

type ParamsDeclaration = ParamTypes | StandardSchemaV1

StandardSchemaV1

The Standard Schema interface that Zod, Valibot, ArkType and Effect Schema implement, copied into Jali as the spec asks, so Jali depends on none of them.

interface StandardSchemaV1<Input = unknown, Output = Input> { readonly "~standard": StandardSchemaV1.Props<Input, Output> }

OptionalParam

A param a ref may leave out, made by optional. link: false when it stays out of the address.

interface OptionalParam<T extends ParamReader = ParamReader> { readonly optional: T; readonly link?: false }

ParamOptions

How an optional param travels, the second argument of optional. link: false keeps it out of the address while it stays part of what the pane shows.

interface ParamOptions { link?: false }

AppOnlyParam

A param only your app sets, from appOnly: optional, and never carried or set by a link.

interface AppOnlyParam<T extends ParamType = ParamType> extends OptionalParam<T> { readonly appOnly: true }

OneOf

A param that is one of a few values, made by oneOf.

type OneOf<V extends string | number> = ((value: ParamValue) => V | undefined) & { readonly values: readonly V[] }

ParamsOf

The params a kind's code sees, from its declaration: ParamsOf<{ id: NumberConstructor; tab: OptionalParam<StringConstructor> }> is { id: number; tab?: string }. Use it as ParamsOf<typeof orderParams> to name the type of params declared apart from the kind. Without a declaration, Params.

type ParamsOf<T extends ParamTypes> = { [K in Required]: Read<T[K]> } & { [K in Optional]?: Read<T[K]> }

FollowParams

What a kind's follow returns: its params, any of which may be missing. Jali checks them against the kind's params before the pane shows them.

type FollowParams<P> = { [K in keyof P]?: ParamValue | undefined }

ParamProblem

A param a ref is missing (value is undefined), or holds a value its type can't read. A ref with one never reaches the component: a layout link or saved layout holding it opens as broken, a page's opened pane with it is left out of the link, and a pane your code opens with it shows a message naming the param.

interface ParamProblem { param: string; value?: ParamValue }

PaneCommand

A command a pane adds to the palette while it is focused (useCommands). keys is only a label: the content handles its own keys. disabled greys it out; its text is the reason.

interface PaneCommand { id: string; title: string; run: () => void; keys?: string; disabled?: string | false }

ItemId

A curated page's item id: a number, or a string such as a UUID or a slug. See firstItem under ProfileBase.

type ItemId = string | number

PaneActivity

What a pane reports about itself (useActivity), shown in its header, its tab, the shelf and the status line. On the shelf, loading reads as working. "live" is ongoing, healthy work meant to go on (recording, streaming, playback): a dot rather than a spinner, read as "Live", and the least pressing on the "N folded" chip.

type PaneActivity = "idle" | "loading" | "working" | "live" | "needs-you" | "error"

PaneErrorInfo

Which pane failed, for createJali({ onPaneError }): its id (null in the peek sheet) and the ref it was showing.

interface PaneErrorInfo { pane: NodeId | null; ref: ObjectRef }

ProfileBase

A curated page about one item (a loan application), framework-free. In React, definePage makes a Page, which adds the rail and header.

interface ProfileBase<R extends RoleBase = RoleBase, I extends ItemId = ItemId>

Fields

idstringRequired
What a link names: ?page=loan-review.
namestringRequired
The page's name, in titles and commands ("Back to Loan review").
itemNounstringRequired
The singular noun for an item ("application").
rolesR[]Required
The views, in tab order.
homestringRequired
The view Single opens on.
build(item: I) => LayoutInputRequired
Split view's designed layout. Every role is in the tree, as a pane whose id and role are the role's id; those not shown at first are hidden.
bind(item: I) => Record<string, ObjectRef>Required
What each role shows for an item. Another item swaps these in place. It runs inside every page action, so it answers at once: it names objects, and their panes load them. Ids only your data knows are read before createJali (see Curated pages).
firstItemIRequired
The item the page opens on. Its type (number or string) is the type of every item id the page is given: a link's "4" comes back as 4 when firstItem is a number.

RoleBase

One view of a curated page. In React, PageView adds its icon.

interface RoleBase { id: string; label: string; priority: "primary" | "supporting" }

ViewMode

How a curated page is shown: one view at a time (Single) or side by side (Split view). The person's choice, kept on their device and never in a link.

type ViewMode = "single" | "split"

PaneControl

Something that can happen to a pane. open covers opening new panes from it (off, a link opens in the peek sheet instead); move covers dragging it, the move keys, swapping, merging into tabs, pulling a tab out and reordering tabs; resize the dividers beside it. Restoring a maximised pane and leaving full screen are always allowed.

type PaneControl = "open" | "close" | "tuck" | "maximise" | "fullScreen" | "move" | "resize" | "pin" | "popOut"

PaneAllow

Controls turned off with false. Leaving one out, or true, leaves it to the other levels. A kind's allow and an instance's are both one.

type PaneAllow = Partial<Record<PaneControl, boolean>>

Allow

createJali({ allow }): the instance's defaults, and when for rules that depend on context. popOut is off until this says true.

type Allow = PaneAllow & { when?: AllowRule }

AllowRule

Asked before each action on a pane, after the kind's allow: false refuses it; anything else allows it.

type AllowRule = (ctx: AllowContext) => boolean | undefined | void

AllowContext

What when is asked about: the action, the pane (its id, kind and params, role, pins and links), the preset the layout came from, and the curated page while one is open.

interface AllowContext { action: PaneControl; pane: PaneNode; presetId?: string; page?: { mode: ViewMode; item?: string } | null }

PaneButton

A button a pane's header can show. maximise is Restore while the pane is maximised; fullScreen is Exit full screen while it is full screen; popOut is Bring back while it is popped out.

type PaneButton = "tuck" | "maximise" | "fullScreen" | "popOut" | "close"

PaneButtons

A header's buttons, in order: a list that replaces the defaults, or a function that adjusts them ((defaults) => defaults.filter((b) => b !== "tuck")). Jali's defaults are ["tuck", "maximise", "popOut", "close"] (Pop out only where allow.popOut turns it on), with fullScreen in Maximise's place on a lone pane. allow and Jali's own rules still filter the list, and Restore and Exit full screen always show while the pane is in that state. A ⋯ button opens the pane's menu whenever it offers more than the buttons do.

type PaneButtons = readonly PaneButton[] | ((defaults: readonly PaneButton[], ctx: ButtonsContext) => readonly PaneButton[])

ButtonsContext

What a buttons function is told: the pane, the preset the layout came from, and the curated page while one is open.

interface ButtonsContext { pane: PaneNode; presetId?: string; page?: { mode: ViewMode; item?: string } | null }

PhoneOptions

How the instance behaves on a phone (createJali({ phone })).

interface PhoneOptions { below?: number; stack?: boolean; stackFloor?: number; fold?: boolean }

Fields

belownumberOptional
Below this width of Jali's root, in CSS pixels, Jali shows one pane at a time, with a switcher at the top. Default 600, Android's compact width, which covers portrait phones. 0 leaves it to the panes' minimum widths alone: one pane at a time only when even one pane can't fit.
stackbooleanOptional
On a portrait phone, show two linked panes one above the other instead of one at a time: the focused pane and the pane it was opened from (a list above its detail), else one opened from it. Only with room for both: the instance at least 480 pixels tall, and each pane at least stackFloor and its kind's minimum height. While the on-screen keyboard is up, the focused pane shows alone. Default false.
stackFloornumberOptional
The shortest a stacked pane may be, in CSS pixels. Default 200.
foldbooleanOptional
On a screen that folds into two (a half-open Galaxy Fold or Pixel Fold, a Flip in flex mode, a dual-screen phone), put a pane each side of the fold so none straddles the hinge: the focused pane and the pane it was opened from, else the next pane. Read from the browser's viewport segments, in Chrome and Edge 138 and later; elsewhere nothing changes. Default true.

PresetOptions

A preset, as createJali({ presets }) takes it. saved, if given, is asked each time the preset is chosen: a layout it returns is shown instead of layout, so the preset comes back as the person left it. "Reset layout" always builds layout. See Start from presets.

interface PresetOptions { id: string; label: string; layout: LayoutInput | (() => LayoutInput); saved?: () => LayoutInput | undefined }

Jali

An instance, from createJali. It is frozen: these members are all it has. R is the refs of its kinds (from createJali), so actions, events and the model are typed by kind; P is its page's actions, or undefined without a page.

interface Jali<R extends ObjectRef = ObjectRef, P = JaliPage | undefined>
actionsactions: JaliActions<R>
What an app asks the instance to do with panes and layouts. See JaliActions.
pagepage: P
The curated page's actions; there only with createJali({ page }). See JaliPage.
dialogsdialogs: JaliDialogs
The palette, settings and the chooser. See JaliDialogs.
getget(): JaliState<R>
The state now, read-only; the same object while nothing in it changed. See JaliState.
subscribesubscribe(fn: () => void): () => void
Called once after each change of state, before the change's events. Returns the unsubscribe. To hear what changed, use on. A subscriber that throws is reported with console.error; the others, and the action that made the change, carry on.
modelmodel(): JaliModel<R>
The layout as it is on screen: every pane, with its title and where it is. Read-only; the same object while nothing in it changed. See JaliModel.
onon(event: keyof JaliEvents, handler: (e) => void): () => void
Hear one kind of change: "open", "close", "pin", "focus", "layout" or "toast". Returns the unsubscribe. A change's events come once it is done, in this order: close, open, pin, focus, layout, then its toasts. A handler that throws is reported with console.error and the others still hear it. See JaliEvents.
getLayoutgetLayout(): DeepReadonly<Layout>
The layout on screen, to save. It is plain JSON, read-only; structuredClone gives a copy to edit.
setLayoutsetLayout(layout: LayoutInput): ActionResult
Show a layout: anything createJali({ layout }) takes. It is fitted to the room, focus stays on a pane that is still there, and the address gets a new entry, so Back returns to the layout before. A curated page that is open closes. Refused with "invalid" for a pane kind the instance doesn't have; held with "unsaved" when a pane that would go has unsaved work; asks beforeClose like a close. The layout is copied as it is given: editing your object afterwards changes nothing.
keymapkeymap: Keymap
This instance's keys: label(id) for a tooltip, sequences(id), platform.
messagesmessages: Messages
Every word it shows or says: en with createJali({ messages }) over it. Use it for your own UI in the same language. A curated page's own words (the page area, and the announcements, commands and toast only a page uses) are there when the instance has a page.
presetspresets: readonly { id: string; label: string }[]
Its presets, in menu order, for your own menu: each one's id, which actions.preset(id) takes, and its label. The preset in use is get().presetId.
hrefhref(): string
The address to share: the URL writer's, else location.href, else "".
startstart(): () => void
Starts its listeners (keys, Back and Forward, theme, saving) and returns their stop; after the stop, start() starts them again. <JaliRoot> starts it while mounted and stops it on unmount; calling it while started does nothing. The stop saves pane state still waiting to be saved. After destroy() it does nothing.
destroydestroy(): void
Stops the instance for good, when it goes away (a route change, a test's end): its listeners stop, a drag in progress ends without a drop, pane state still waiting to be saved is saved, a follow waiting for the selection to rest and an address write still waiting are dropped (so nothing lands on the next route's address), and the kind registry stops being listened to. Nothing more is told to on or subscribe, even an action's events not yet told. A question still open settles as "unavailable", and so does an action whose beforeClose destroyed the instance. Nothing is scheduled after it, and start() does nothing. Its state can still be read. Calling it again does nothing. <JaliRoot> doesn't call it: the instance is yours, and may outlive one mount.

To save a person's layout, listen for "layout" and store getLayout(). To restore it, pass it as createJali({ layout }): a link in the address still wins, so shared links keep working. A layout that arrives later goes through setLayout.

JaliEvents

What jali.on (and useJaliEvent in React) tells you. ref.kind says which of the instance's kinds, and narrows ref.params. Each fires once per change, after the change is made, and never for the steps inside one action (a drag before it drops, the steps of a preset switch). In one change they come in this order: close, open, pin, focus, layout.

interface JaliEvents<R extends ObjectRef = ObjectRef> { open; close; pin; focus; layout; toast }

Every event also carries input, where the change came from (JaliInput), so you can tell a person's close from your own code's:

import { analytics } from "./analytics";​jali.on("close", ({ pane, input }) => analytics.track("pane closed", { pane, by: input }));

Events

open{ pane: NodeId; ref: R; previous?: R }Required
A pane was added to the layout, or now shows another object. previous is what it showed before. A launcher pane counts.
close{ pane: NodeId; ref: R }Required
A pane left the layout. A tucked, folded or tabbed pane is still in it.
pin{ pane: NodeId; pinned: boolean }Required
A pane's tab was pinned or unpinned, however it happened: the tab menu, setPinned, setLayout, Back or a link. Not for a pane that arrives pinned, which is an open. Pinning a pinned tab is no change, so it says nothing.
focus{ pane: NodeId | undefined; previous: NodeId | undefined }Required
Another pane is focused.
toastToastRequired
A toast to show (a close offers Undo). Jali draws none: put your toaster in <JaliRoot overlays> and hear it with useJaliEvent("toast", show). Toasts sent before anyone listens are kept until someone does.
layout{ layout: DeepReadonly<Layout>; source: "action" | "address"; action?: ActionName }Required
The layout changed. "action": an action, a gesture, a key or setLayout. "address": Back, Forward or a link. Fitting to a new window size does not fire it. action names the action that made it (ActionName), whoever ran it: your code, or the person from Jali's buttons, menus, keys or ⌘K. A change made after a question (Discard, or a later yes from beforeClose) names the action that asked. It is undefined for a change no action names: a drag, a divider, a linked pane following its list, and anything from the address.
import { forgetSavedLayouts } from "./saved-layouts";​jali.on("layout", ({ action }) => {  if (action === "resetLayout") forgetSavedLayouts();});

JaliEventBase

What every event in JaliEvents carries, beside its own fields.

interface JaliEventBase { input: JaliInput }

JaliInput

Where a change came from. mouse, touch and pen are a person's pointer; keyboard a key; virtual a click with no pointer or key behind it, as a screen reader sends; code your own code, with nothing a person did behind it.

type JaliInput = "mouse" | "touch" | "pen" | "keyboard" | "virtual" | "code"

A person's input is noted from the page while the instance is started (<JaliRoot> starts it), and lasts until the event that caused it is handled. A change your code makes after a timer or an await reads as code, even if a click started it. Use it for analytics and to tell changes apart, not to make Jali behave differently.

JaliOptions

The options of createJali. Each one, with its default, is under createJali.

interface JaliOptions

JaliState

What an instance holds that an app reads, read-only. Read it with jali.get() or useJaliState(select); change it through actions. It is the same object until one of its fields changes, and each field keeps its object while it is the same, so a selector re-renders only for what it picked.

interface JaliState<R extends ObjectRef = ObjectRef>

Fields

layoutDeepReadonly<Layout>Required
The arrangement: what getLayout() gives.
pagePageState | nullRequired
The curated page in use, or null for the free layout.
view{ focused?: NodeId; zoomed?: NodeId; peek?: R }Required
The focused pane, the maximised one, and what the peek shows.
presetIdstring | undefinedRequired
The preset last chosen; "Reset layout" rebuilds it.
selectionRecord<NodeId, Selection<R>>Required
Each list pane's selected item.
settingsSettingsRequired
The person's settings.
unsavedRecord<NodeId, string>Required
Panes with unsaved work, and what it is.
activityRecord<NodeId, PaneActivity>Required
What each pane reports (useActivity), merged across the components that report it. A pane nothing reports an activity for has no entry: it is idle.
resizeModeNodeId | nullRequired
The pane in keyboard resize mode.

PageState

A curated page in use.

interface PageState

Fields

profilestringRequired
The profile's id.
itemItemIdRequired
The item shown.
modeViewModeRequired
Single or Split view.
tabstringRequired
The view Single shows (in Split view, the last role focused).

Selection

A list's selected item. inResults: false: the list's filter no longer shows it; the following detail keeps it.

interface Selection { ref: ObjectRef; inResults: boolean }

UrlWriter

Where an instance writes its address. Pass one as url to write it somewhere of your own. write gets a function, so a debounced write reads the latest state: the address's share of it (UrlState), as a link carries it, without params only your app sets (appOnly). cancel, when given, drops a write still waiting: jali.destroy() calls it.

interface UrlWriter { write(state: () => UrlState, mode: HistoryMode): void; href?(): string; cancel?(): void }

UrlState

What a UrlWriter reads: the layout on screen, the view (focus, the maximised pane, where rows that scroll came to rest; never the peek), the preset the layout came from, and the curated page open, if any. Refs in it are as a link carries them: without appOnly params.

interface UrlState { layout: Layout; view: ViewState; presetId: string | undefined; page: PageState | null }

JaliModel

The layout as it is on screen (jali.model(), useJaliModel()): every pane, with its title and where it is. Read-only. It is the same object until a pane changes, and each pane keeps its object while it is the same, so useJaliModel((m) => m.pane(id)) re-renders only for that pane. A title is read again each time, since a kind's title can read your own data.

interface JaliModel<R extends ObjectRef = ObjectRef>

Fields

panesreadonly PaneOf<R>[]Required
Every pane in tree order, wherever it is: shown, a tab, folded, tucked or hidden.
pane(id: NodeId | undefined) => PaneOf<R> | undefinedRequired
A pane by id.
paneOf(ref: ObjectRef) => PaneOf<R> | undefinedRequired
The first pane showing the same object as ref, whatever its kind: the same object type (a kind's shows, else its name) and identity, as Jali decides whether an object is already open. A ref of a scratch kind matches none.
// The pane showing an order, brought to the front; else opened beside the focused pane.const shown = jali.model().paneOf(order({ id: 7 }));if (shown) jali.actions.focus(shown.id);else jali.actions.openBeside(jali.get().view.focused ?? "orders", order({ id: 7 }));

ActionResult

What every action and setLayout return. ok: true when it happened, or when what it asks for is already so. pane is the pane it opened, else the pane it acted on. pane is undefined on a refusal, and reason, message and settled are undefined on success, so result.pane and result.reason read without checking ok first.

type ActionResult = { ok: true; pane?: NodeId } | Refusal

Done

An action that happened (or was already so): the ok: true side of ActionResult. Its reason, message and settled are always undefined.

interface Done { ok: true; pane?: NodeId }

Refusal

An action that did not happen. message is what Jali read out to screen readers, when it said anything; a refusal it did not say is silent, as before.

interface Refusal { ok: false; reason: RefusalReason; message?: string; settled?: Promise<ActionResult> }

A refusal that asks a question carries settled, a promise of how the question ended: with reason: "unsaved", once the person answers "Discard unsaved changes?"; with reason: "pending", once beforeClose answers. It resolves with { ok: true, pane } when the action went ahead, or with a refusal when it didn't ("kept" after Keep editing, or when a newer question took its place). It never rejects. A host's yes that leads to Jali's own question resolves with that "unsaved" refusal, whose settled says how the person answered.

import { forgetSavedLayouts } from "./saved-layouts";​const result = jali.actions.resetLayout();if (result.ok) forgetSavedLayouts();else void result.settled?.then((end) => end.ok && forgetSavedLayouts());

RefusalReason

Reasons

not-foundOptional
The pane (by id or by what it shows), preset or view named is not there.
invalidOptional
What the action was given won't do. Every argument of every action is checked before anything happens, so JavaScript and an agent get the same answer TypeScript would give: a mode, edge, index or flag its type doesn't allow; a pane named by something that is neither an id nor a ref; a ref of a kind the instance doesn't have, or with params that aren't text, numbers or flags (these say why in message); or a layout that can't be shown. Nothing is stored as given, and it never throws.
unavailableOptional
The instance can't do this: no launcher (split, new tab), no curated page, no free layout to go back to, or it was destroyed.
single-viewOptional
A curated page in Single view has no layout to change.
not-allowedOptional
The app's allow turns that control off for the pane: the kind's, the instance's, or its when (for a divider, a pane beside it). See Choose what people can do with panes.
last-paneOptional
The last pane, or a page's last view on screen, stays.
blockedOptional
The pane can't go there: past the edge, tucking the only pane or a tab. Also a change whose link no instance could reopen: more than a link holds (256 nodes, 128 levels, a curated page's 32 opened panes), or, where the instance writes an address, more text than a reader reads (one very long param). A layout already larger (an app's own, at start-up) still opens and may shrink, but its address is left unwritten until it fits.
nothing-to-doOptional
Nothing to undo, put back, close, resize or unmerge.
unsavedOptional
A pane that would go has unsaved work. Jali asks the person ("Discard unsaved changes?") and makes the change if they discard. See settled. (A linked detail that keeps its object because of its unsaved work doesn't ask, and has no settled.)
keptOptional
beforeClose kept the panes, or the person chose Keep editing, or what a held action was made from is gone by the time it is answered (a newer Back or Forward).
pendingOptional
beforeClose has not answered yet. See settled.
type RefusalReason = "not-found" | "invalid" | "unavailable" | "single-view" | "not-allowed" | "last-pane" | "blocked" | "nothing-to-do" | "unsaved" | "kept" | "pending"

BeforeClose

The host's close guard, createJali({ beforeClose }). Jali asks it before a change removes panes or makes a pane show another object. true lets the change happen; false keeps the panes (reason: "kept"). A promise holds the change (reason: "pending") until it answers; a yes makes it against the state then, and asks again if it would now remove or replace other panes. Nothing of the change is written while the guard decides, so an action the guard runs meanwhile happens at once, with its real result. A guard that throws or rejects keeps the panes.

type BeforeClose = (request: CloseRequest) => boolean | Promise<boolean>

It is asked first. If it says yes and a pane still reports unsaved work (useUnsaved), Jali's own "Discard unsaved changes?" follows; Discard does not ask the guard again. It is not asked while the instance is made, or for changes that remove nothing (focus, tuck, open beside). A later yes makes the change against the instance as it is then; if the panes it would remove or replace are no longer the ones asked about, the guard is asked again. When Back or Forward is not made in the end (the guard keeps the panes, or the person keeps editing), the address goes back to what is on screen.

CloseReason

Why panes would go, in a CloseRequest: its reason, listed there.

type CloseReason = "close" | "show" | "layout" | "address"

CloseRequest

What beforeClose is asked about: every pane the change would remove or point at another object, with what it shows now.

interface CloseRequest { panes: { pane: NodeId; ref: ObjectRef }[]; reason: CloseReason }

reason

closeOptional
A close, close others, Back to the page, or a launcher dismissed.
showOptional
The pane would show another object: openHere, a following detail, another item or view on a page.
layoutOptional
A new layout: a preset, setLayout, undo, a page's mode.
addressOptional
Back, Forward or a link.

Toast

A toast for the host to render (jali.on("toast"), useJaliEvent("toast")). undo: offer Undo (run jali.actions.undo()).

interface Toast { title: string; description?: string; undo?: boolean; error?: boolean }

HistoryMode

How a change reaches the address: a new entry, in place, in place 120 ms after the last call, or not at all. An action's parts make one write, the strongest of their modes (push, then replace, then debounce).

type HistoryMode = "push" | "replace" | "debounce" | "none"

Settings

Fields

centreDrop"swap" | "tab"Required

Default "swap"

What a drop on a pane's centre does.
paneCapnumberRequired

Default 8

The most panes on screen; past it the oldest pane that is not kept or focused folds. A whole number from 1 to 64; the Settings dialog offers 2 to 16.
theme"system" | "light" | "dark"Required

Default "system"

The theme choice.
boundary"tint" | "none"Required

Default "tint"

How a curated page marks the panes opened from its views.
interface Settings

ThemeChoice

The theme setting.
type ThemeChoice = "system" | "light" | "dark"

Theme

The theme shown.
type Theme = "light" | "dark"

OpenPageOptions

The options of jali.page.open: the item to show (default: the last one, else the page's firstItem) and the view Single view shows (a role id; default: the last one, else the home view).

interface OpenPageOptions { item?: ItemId; tab?: string }

OpenBesideOptions

The options of actions.openBeside and a pane's openBeside. edge is the side of the source pane the new pane opens on: "left", "right", "top" or "bottom". Default: after the source in reading order (its right, or its left right to left).

interface OpenBesideOptions { edge?: Edge }
  • It is a side on screen, as for move and split: "right" is the right in either reading direction.
  • It only places a new pane. Everything else is as without it: the new pane is linked to its source, focus stays in the source, it is one history entry and it is announced the same way. A link that replaces the source's earlier link of the same kind shows in that pane, where it is; an object already open is shown where it is.
  • With no room on that edge, the new pane becomes a tab of its source, as without one. On a phone it goes on that edge in the layout, which shows one pane at a time until the screen is wider.
  • On a curated page, panes opened from the page's views stay together, after the views. The first one starts it there whatever the edge; later ones open on that edge of the opened panes' last column. A pane opened from an opened pane opens on that edge of it. In Single view a link peeks, as always.

UrlSyncOptions

The url option of createJali: location (a LocationPort, default the browser's history), prefix (for two instances in one address: "b." writes b.l, b.zoom), sizes (LinkSizes) and storage (default: the instance's own).

interface UrlSyncOptions { location?; storage?; prefix?; sizes? }

LinkSizes

What a layout link carries about sizes. "local" (the default): the layout as designed, with the sizes the person dragged kept on their device (for up to 12 layouts), so a colleague opens the link at the designed proportions. "link": everything, so the link reopens exactly.

type LinkSizes = "link" | "local"

LocationPort

The address, as a port a router can implement. Jali reads and writes only its own search params. navigate goes to the same address with a new search string; subscribe hears changes made any other way. An adapter for React Router calls navigate({ search }, { replace: mode === "replace" }); for TanStack Router, router.navigate and router.subscribe("onResolved", fn).

interface LocationPort {
  search(): string;
  href(): string;
  navigate(search: string, mode: NavigateMode): void;
  subscribe(fn: () => void): () => void;
}

NavigateMode

A new history entry, or in place.
type NavigateMode = "push" | "replace"

StoragePort

What one person keeps on one device. Keys Jali uses: settings, pane-state, a curated page's preferences, broken-layout, and (from the address) sizes.

interface StoragePort { get(key: string): string | null; set(key: string, value: string): void }

ListedCommand

One entry of a command menu, from listCommands. key is unique in the list; id is the command id, undefined for a pane's own commands. group is the pane's title for those. Close your menu before run: some commands move focus.

interface ListedCommand {
  key: string; id?: string; title: string; group: string;
  keys: string; disabled: boolean; reason?: string; run(): void;
}

Rename

Renaming in place, from createJali({ rename }). Double-click or F2 on a tab, or on a lone pane's title, the tab menu's Rename…, or actions.startRename opens a field there with the title selected. Enter or leaving the field calls run with the trimmed text, for the object the field was opened on; the field closes, text dropped, if its pane shows another object; Esc keeps the old name, and an empty or unchanged name calls nothing. Jali stores no name: your app saves it and the pane shows it, usually with useTitle. Return false, throw or reject to keep the field open with the text, marked invalid; a promise keeps it busy until it settles. can says which panes may be renamed; leave it out for all.

interface Rename {
  can?(pane: { id: NodeId; ref: ObjectRef }): boolean;
  run(pane: { id: NodeId; ref: ObjectRef }, text: string): void | false | Promise<void | false>;
}

TabMenu

Your items for a tab's menu, from createJali({ tabMenu }). Called each time a tab's menu opens (right-click, Shift+F10 or the menu key on the tab), with that tab's pane. They come after Jali's own, after a separator. Return undefined or [] for a pane that has none.

type TabMenu = (pane: { id: NodeId; ref: ObjectRef }) => readonly TabMenuItem[] | undefined

TabMenuItem

One item in a tab's menu. disabled greys it out but keeps it reachable from the keyboard; give a reason as text and screen readers read it. checked makes it a checkbox item, ticked when true. keys is a hint shown beside the title, such as keyHint("Mod+D"); the key itself is yours to handle. The menu closes, and focus returns to the tab, before run runs. run gets the pane as it is when the item is chosen, which may show another object than when the menu opened; once the pane has closed, it isn't called. Act on that pane, not on what the menu was built from: Jali's own items do (Move right moves the tab one place from where it is now; Pin pins, never toggles).

interface TabMenuItem {
  id: string; title: string; run(pane: { id: NodeId; ref: ObjectRef }): void;
  disabled?: boolean | string; checked?: boolean; keys?: string;
}

Command

A command. run gets the instance. Your own commands go in createJali({ commands }), with a group of your own if you like. keys binds your command, written as keyboard.keymap writes keys ("Mod+B", or several). They are bound as written, and keyboard.keymap can rebind or unbind them. disabled is asked each time ⌘K lists commands and each time the command's key is pressed: return true while it can't run, or the reason as text. Whether any command can run now is in listCommands (disabled, reason).

interface Command {
  id: string; title: string;
  group: "Focus" | "Pane" | "Move" | "Tabs" | "Layout" | "Peek" | "Settings";
  run: (jali: Jali) => void;
  keys?: KeyString | readonly KeyString[];
  disabled?: (jali: Jali) => boolean | string;
}

Keymap

An instance's resolved keys (jali.keymap): the defaults with its keymap overrides applied, with platform, entries, sequences(id), label(id), format(seq), find(match, prefix?), isPrefix(match) and forPlatform(platform). label and format print keys in the instance's words (messages.keys). forPlatform gives the same bindings matched and printed for another platform (the same object for its own), for labels a server prerenders: jali-layout/react prints "other" until the page has hydrated.

interface Keymap

KeymapOverrides

A host's key changes: a binding, several, or null to unbind.

type KeymapOverrides = Partial<Record<DefaultKeymapId | (string & {}), KeyString | readonly KeyString[] | null>>

KeymapOptions

Part of createJali's keyboard (KeyboardOptions): platform to match and print keys for, prefix and reserved, and onInvalid, called for each refused binding (default console.warn). words defaults to the instance's messages.keys.

interface KeymapOptions {
  platform?: Platform; prefix?: KeyString; reserved?: readonly KeyString[];
  onInvalid?: (id: string, binding: KeyString, reason: string) => void; words?: KeyWords;
}

DefaultKeymapId

The ids bound by default.
type DefaultKeymapId = "palette.toggle" | "pane.focus.next" | …

KeyString

A binding as text: chords separated by a space, keys in a chord by + (Mod+K Mod+ArrowLeft, F6, Mod+\). Modifiers: Mod (⌘ on a Mac, Ctrl elsewhere; Cmd and Meta mean the same), Ctrl, Alt (Option), Shift. Keys: a letter, a digit, punctuation, F1 to F24, or a name (Enter, Esc, Space, Tab, Backspace, Delete, Home, End, PageUp, PageDown, the arrows). Letters, digits and punctuation match the physical key.

type KeyString = string

Chord

One key press. key is KeyboardEvent.code ("KeyM", "Backslash") or, for named keys, KeyboardEvent.key ("ArrowLeft", "F6"). mod is ⌘ on a Mac and Ctrl elsewhere; ctrl is the Control key itself.

interface Chord { key: string; mod?: boolean; ctrl?: boolean; alt?: boolean; shift?: boolean }

KeySequence

One binding: a chord, or a prefix chord then a second chord (⌘K ⌘M).
type KeySequence = readonly Chord[]

Platform

The platform keys are matched and printed for.
type Platform = "mac" | "other"

KeyWords

The words printed keys use: modifier names elsewhere than a Mac, and Esc, Space and the arrows.
interface KeyWords { ctrl; alt; shift; escape; space; left; right; up; down: string }
messages.keys is one.

Messages

Every word Jali uses, by area, with the same keys and shapes as en. A full translation is a Messages: a missing area or key, or a message of the wrong shape, is a type error. See Translate Jali.

type Messages = { announcements: …; toasts: …; commands: …; … }

MessageOverrides

What createJali({ messages }) takes: any areas, and any keys in them. Keys you leave out stay English. A misspelt key is a type error.

type MessageOverrides = { [Area in keyof Messages]?: Partial<Messages[Area]> }

ScreenDirection

A direction on screen (right to left too), as command ids name it (
type ScreenDirection = "left" | "right" | "up" | "down"
pane.focus.left), passed to commands.focusDirection and commands.moveDirection.

PaneTarget

A pane, by its id or by the object it shows. A ref means the pane showing that object: the focused pane if it does, else the first in the layout. close(order({ id: 7 })) closes the pane showing order 7, whatever its id.

type PaneTarget = NodeId | ObjectRef

ActionName

An action by its name in JaliActions ("openBeside", "resetLayout"), or "setLayout". The layout event names the action that made a change with it. A person's click, key or ⌘K command counts as the action it is a form of: a click on a tab is "focus", Split is "split", Close on a tab is "close".

type ActionName = keyof JaliActions | "setLayout"

ChooseOptions

What JaliActions choose asks the person for. T is whatever your items are.

interface ChooseOptions<T> { title: string; items: readonly T[]; label(item: T): string; hint?(item: T): string; current?: T; placeholder?: string; onChoose(item: T): void }

Parameters

titlestringRequired
What the choice is for: the dialog's name, its heading and its field's label ("Open chart for…").
itemsreadonly T[]Required
What to choose from, in order. Typing keeps the items whose label or hint has the text, labels that start with it first.
label(item: T) => stringRequired
An item's name in the list.
hint(item: T) => stringOptional
Words beside the name, matched too.
currentTOptional
The item in use. The chooser opens with it selected, and its row is marked (data-current, aria-current="true" and a tick). Compared with Object.is: pass one of items itself.
placeholderstringOptional

Default messages.chooser.choosePlaceholder

The field's placeholder.
onChoose(item: T) => voidRequired
Gets the chosen item once the chooser has closed and focus is back where it was. Not called when the person closes it with Esc or a click outside.

JaliActions

jali.actions (in React, useJali().actions): panes and layouts. A curated page's actions are JaliPage, the dialogs' JaliDialogs. R is the refs of the instance's kinds: a ref of another kind is a type error. Each one reads the state now, makes its change once and returns an ActionResult. They follow one rule:

interface JaliActions<R extends ObjectRef = ObjectRef>
  • Refs, params and layouts are copied as the action is called. Editing a ref afterwards (even while the action waits for beforeClose) changes nothing Jali holds.
  • The pane comes first, as a PaneTarget. It is optional (?), meaning the focused pane, only when nothing required follows it.
  • What the action uses comes next; options come last, in an object.

A pane that is not there gives reason: "not-found". What a refusal reads out to screen readers is the same as before; message holds it.

Focus

focusfocus(pane: PaneTarget)
Focus a pane and show it. A pane that is folded, tucked or behind another tab has its tab chosen; nothing else on screen moves. While another pane is maximised, this one is maximised instead.
toggleZoomtoggleZoom(pane?: PaneTarget)
Maximise or restore. Refused with "single-view" in a curated page's Single view, with "blocked" for a pane the layout hides (it has no place on screen to fill), and with "nothing-to-do" with one pane.

Open

openBesideopenBeside(pane: PaneTarget, ref: ObjectRef, options?: OpenBesideOptions)
Open ref beside pane; focus stays in pane. { edge: "bottom" } opens it below pane (see OpenBesideOptions); by default it opens after pane. pane's selected item opens a following detail (kept if one already follows). A link never copies a pane of its own chain: when ref's object is pane itself, a pane pane was opened from (up the chain), or one it opened, that pane is shown instead (pane in the result), focus stays, and it is announced "Already open". Outside a curated page, another chain may still show the same object. In a curated page: a peek in Single view, and an object already on the page is focused instead. pane in the result is the pane that shows ref. Where allow turns open off for pane (in the free layout or on a curated page), no pane opens: ref shows in the peek sheet instead, and the result is what peek returns.
openHereopenHere(pane: PaneTarget, ref: ObjectRef)
Show ref in pane. If it is open elsewhere, focus that pane (and close pane when it is a launcher).
peekpeek(pane: PaneTarget, ref: ObjectRef)
Show ref in the peek sheet, for pane. When pane's following detail of that kind is on screen, the detail shows ref instead.
closePeekclosePeek()
Close the peek sheet. "nothing-to-do" when none is open.
selectselect(pane: PaneTarget, ref: ObjectRef | null, options?: { inResults?: boolean })
Report a list's selection (null: none). An open peek from it follows at once; its following detail after 150 ms of rest. inResults: false: the list's filter no longer shows it.
setKeptsetKept(pane: PaneTarget, kept: boolean)
Keep a linked pane on what it shows, or let it go. A kept follower stops following its list; a kept plain link is no longer replaced by the next link from its source, which opens beside it instead. Let go, a detail of a list (its source reports a selection) follows the selection again and catches up; a plain link goes back to being replaced. "nothing-to-do" for a pane with no link.
splitsplit(pane?: PaneTarget, direction?: "right" | "bottom")
Open the launcher beside pane and focus it. Without direction: right of a wide pane, below a tall one. "unavailable" without a launcher, or on a curated page (its layout is its design; links open panes there). "not-allowed" where allow turns open off for pane.
newTabnewTab(pane?: PaneTarget)
The launcher as a new tab of the pane's group. "unavailable" without a launcher, "not-allowed" where allow turns open off for the pane.
addTabaddTab(pane: PaneTarget, ref: ObjectRef)
Show ref as a new tab of pane's group (or a new group), and focus it. It is one step: one entry in the history, and the tab takes pane's slot, so nothing else folds or moves. Use it rather than openBeside then mergeInto, which is two entries and can fold other panes in between. If ref is already open, that pane is shown instead. "invalid" for a kind the instance doesn't have, as for every action that takes a ref. "not-allowed" where allow turns open off for pane.

Close

closeclose(pane?: PaneTarget)
Close a pane, with an Undo toast. The last pane stays ("last-pane"). A curated page's view goes back to the tabs.
closeOtherscloseOthers(pane?: PaneTarget)
Close every other pane. In a curated page, jali.page.back().
undoundo()
Undo the last close, close others or tuck. It reverses that change in the layout as it is now: each closed pane goes back to its place (the same parent, position, size and tab group, with its pane state), else beside the neighbour it had, else at the end, and everything done since stays. A closed pane whose object is open again, or that remove took away, is not brought back. "nothing-to-do" when there is none.
removeremove(pane: PaneTarget)
Take away a pane whose object your app closed elsewhere. It is quiet: no Undo, no toast, nothing read out, and nothing asked (beforeClose and "Discard unsaved changes?" are skipped, since the object is gone). The address is replaced, so Back does not bring it back. The last pane becomes the launcher; without a launcher it stays ("last-pane"), so show something else in it with openHere. A curated page's views are refused ("unavailable"). An object that is closed but could still come back with Undo (named by its pane's id or by the object) is taken out of Undo instead.

Tuck, move and tabs

tucktuck(pane?: PaneTarget)
Tuck a pane into its neighbour. Without pane, the focused pane or the one focused last.
putBackputBack(pane?: PaneTarget)
Put a tucked pane back where it was. Without pane, the focused pane if it is tucked, else the most recently tucked.
movemove(pane: PaneTarget, direction: Edge)
Move a pane past its neighbour. "blocked" at the edge.
swapWithNextswapWithNext(pane?: PaneTarget)
Swap with the next pane on screen (or the previous, for the last).
mergeIntomergeInto(pane: PaneTarget, target: PaneTarget)
pane joins target's tab group.
unmergeunmerge(pane?: PaneTarget)
Move a tab out of its group, to the right of it.
moveOutOfRowmoveOutOfRow(pane?: PaneTarget)
Take a pane (default: the focused one) out of the row that scrolls sideways holding it, beside the row on the side the pane is nearer on screen. Also in the pane's menu and ⌘K ("Move out of the row"). "unavailable" for a pane in no such row.
closeTabscloseTabs(pane: PaneTarget, which: "others" | "after")
Close the other tabs of pane's group, or the tabs after it in reading order (to its right, or its left right to left). One change: beforeClose is asked once, listing them all, and one Undo brings them back. Refused with "nothing-to-do" when there are none. The tab menu's Close other tabs and Close tabs to the right.
setPinnedsetPinned(pane: PaneTarget, pinned: boolean)
Pin a pane's tab, or unpin it. A pinned tab goes to the end of its group's pinned tabs, at the start of the group; unpinned, it goes to the start of the rest. Close other tabs and Close tabs to the right leave it open; Close, middle-click and ⌘W still close it. Already as asked: nothing happens, with no pin event and no history entry. Each change fires pin.
startRenamestartRename(pane?: PaneTarget)
Open the rename field on pane's tab, or its title when it is alone (default: the focused pane). For an app that owns its own rename key or menu item. "unavailable" without createJali({ rename }), or when rename.can says no.
moveTabmoveTab(pane: PaneTarget, index: number)
Move a tab to position index (from 0) among its group's tabs, clamped to the group and to its part of it (a pinned tab among the pinned tabs, any other after them); the group keeps its place and size, and its shown tab. Announced as "Orders moved to position 2 of 4". Refused with "nothing-to-do" for a pane that is not a tab in a group the person or the app made (a folded or tucked tab is placed by the layout).

Layouts

presetpreset(id: string)
Switch to a preset. "not-found" for an id the instance doesn't have.
toggleFullScreentoggleFullScreen(pane?)
Put a pane (default: the focused one) on the whole screen: maximised, with the page in the browser's full screen. Again, Escape, or leaving the browser's full screen puts it back as it was. Where the browser has no full screen (an iPhone), the pane still covers the page. "blocked" for a pane the layout hides. ⌘K: "Full screen pane, or exit full screen".
resetLayoutresetLayout()
Rebuild the preset last chosen.
autoLayoutautoLayout()
Arrange every pane from the room there is and each kind's size hints: columns at the kinds' comfortable widths, a second row when the height allows, the rest as tabs beside the pane they were opened from. The same panes, so nothing reloads; tucked and folded panes are placed too. Back returns to the arrangement before. "unavailable" on a curated page, "nothing-to-do" with one pane. ⌘K: "Arrange panes automatically".

Settings

changeSettingschangeSettings(patch: Partial<Settings>)
Change the person's settings. They are saved on this device; a new theme is applied and a new pane cap refits the layout. "invalid", changing nothing, when a value is one its setting can't take (a paneCap that isn't a whole number from 1 to 64, a theme or centreDrop it doesn't know). A saved value like that is never used either: that one setting starts on its default.

What drags, keys and panes report (dividers, drops, focus keys, useUnsaved, useCommands, usePaneState, the discard dialog) runs through the engine's own steps, which are not part of jali.actions.

JaliPage

jali.page: the curated page's actions, there (and typed) only when createJali({ page }) was given one. I is the page's item type, its firstItem's.

interface JaliPage<I extends ItemId = ItemId>
openopen(options?: OpenPageOptions<I>)
Open the curated page. "nothing-to-do" when it is open already and no item or view is asked for.
leaveleave()
Back to the free layout's preset. The page's mode and layout are kept. "unavailable" in a page-only app; "nothing-to-do" with no page open.
setModesetMode(mode: ViewMode)
Single view or Split view. "nothing-to-do" in that mode already.
showViewshowView(view: string)
What a click on a page tab does. It never reshapes: Single view swaps the view; Split view focuses it, chooses its tab, or puts it in place of the view you're in.
showItemshowItem(item: I)
Show another item; the previous item's opened panes close.
backback()
Close every opened pane, with Undo. The views keep their sizes and what was done to them meanwhile; Undo reopens only the opened panes.
resetreset()
Split view back to the design; opened panes stay.

JaliDialogs

jali.dialogs: Jali's palette, settings and chooser.

interface JaliDialogs
choosechoose<T>(options: ChooseOptions<T>)
Ask the person for one of options.items in Jali's chooser: type to filter, arrows, Enter, Esc. options.onChoose(item) runs once it has closed and focus is back. Closes ⌘K if it is open.
openPaletteopenPalette()
Open the command palette.
closePaletteclosePalette()
Close it.
openSettingsopenSettings()
Open Settings.
closeSettingscloseSettings()
Close it.

Ref

An object of the kind K, with its params typed: what a kind's call returns (note({ id: 2 }) is a Ref<"note", { id: number }>). It is an ObjectRef too, the wide type links and agents use; kind tells one kind's refs from another's, so checking it narrows params.

interface Ref<K extends string = string, P = Params> { readonly kind: K; readonly params: P }

RefOf

The refs of kinds D: each defined kind's Ref, and ObjectRef for a kind without a call. createJali uses it to type the instance.

type RefOf<D>

RefsOf

The refs of instance J's kinds.

type RefsOf<J extends AnyJali>

PageOf

The page's actions an instance made with page P has: JaliPage for its item type, or undefined.

type PageOf<P>

AnyJali

Any instance, whatever its kinds and page: for a function that takes one.

type AnyJali = Jali<any, any>

Register

One declaration types the app's instance everywhere, React's hooks included (the full example is on Installation):

interface Register { jali?: AnyJali }
declare module "jali-layout" {  interface Register {    jali: typeof jali;  }}

RegisteredJali

The app's instance type from Register, or any instance when nothing is registered. The React hooks default to it.

type RegisteredJali

JaliEvent

The name of an event: "open", "close", "pin", "focus", "layout" or "toast".

type JaliEvent = keyof JaliEvents

DeepReadonly

T, read-only all the way down: what an instance gives an app to read (its state, layout, model and events). An edit would change the instance behind its back, with no history and no event; in development it throws. Refs and params in it are frozen too. structuredClone gives a copy to edit; a read-only layout goes back into setLayout and createJali({ layout }) as it is.

type DeepReadonly<T>

PaneOf

A pane as the model gives it, read-only, with its ref typed by the instance's kinds.

interface PaneOf<R extends ObjectRef = ObjectRef>

Fields

idNodeIdRequired
Its id in the layout.
refRRequired
What it shows.
titlestringRequired
Its name: its role on a curated page, else the title its content set (useTitle), else its kind's title.
where"shown" | "tab" | "folded" | "tucked" | "hidden"Required
Where it is. "shown": on screen, its content visible. "tab": behind another tab of its group, or, while one pane shows at a time, another pane's turn. "folded": folded for room, behind its place's "N folded" chip. "tucked": the person tucked it onto the shelf. "hidden": nowhere to be seen: hidden by a curated page, behind a maximised pane, or scrolled out of its row's window. Focusing a tab, a folded or a tucked pane shows it.
focusedbooleanRequired
It has focus.
boxRect | nullRequired
Where it is drawn while shown, in CSS pixels from the top left of Jali's root: in stacked view, after the divider the person moved; a maximised pane fills the room; a pane on the whole screen has the root's whole box. null while it isn't shown.
selectedROptional
A list pane's selected item, when it has one (select).
linkedToNodeIdOptional
The pane it was opened from.
followsbooleanRequired
It shows what its linkedTo list selects.
keptbooleanRequired
The person kept it: it never shows another object by itself.
pinnedbooleanRequired
Its tab is pinned.
// Bring the following detail forward, if it isn't on screen.const detail = jali.model().panes.find((p) => p.linkedTo === "orders" && p.follows);if (detail && detail.where !== "shown") jali.actions.focus(detail.id);

KeyboardOptions

createJali({ keyboard }): Jali's keys in one place. scope ("page" or "local"), keymap, and the KeymapOptions prefix, reserved, platform, onInvalid and words. See createJali.

interface KeyboardOptions extends KeymapOptions { scope?; keymap? }