Reference
jali-layout types
Every type jali-layout exports, with its fields, and every instance action: the layout tree, kinds and pages, the instance, the address, commands and keys.
On this page
- The layout tree
- Layout
- LayoutNode
- PaneNode
- SplitNode
- StackNode
- Size
- NodeId
- ObjectRef
- Axis
- Edge
- Direction
- Overlay
- TuckRecord
- ViewState
- Rect
- Writing a layout
- LayoutInput
- Draft
- PaneDraft
- SplitDraft
- TabsDraft
- RowOptions
- SizeOptions
- PaneNodeOptions
- TabsOptions
- Kinds and pages
- PaneOptions
- PaneWidth
- PaneHeight
- PaneDefinition
- PaneKindBase
- Params
- ParamValue
- ParamType
- ParamTypes
- ParamReader
- Identity
- ParamsDeclaration
- StandardSchemaV1
- OptionalParam
- ParamOptions
- AppOnlyParam
- OneOf
- ParamsOf
- FollowParams
- ParamProblem
- PaneCommand
- ItemId
- PaneActivity
- PaneErrorInfo
- ProfileBase
- RoleBase
- ViewMode
- PaneControl
- PaneAllow
- Allow
- AllowRule
- AllowContext
- PaneButton
- PaneButtons
- ButtonsContext
- PhoneOptions
- PresetOptions
- The instance
- Jali
- JaliEvents
- JaliEventBase
- JaliInput
- JaliOptions
- JaliState
- PageState
- Selection
- UrlWriter
- UrlState
- JaliModel
- ActionResult
- Done
- Refusal
- RefusalReason
- BeforeClose
- CloseReason
- CloseRequest
- Toast
- HistoryMode
- Settings
- ThemeChoice
- Theme
- OpenPageOptions
- OpenBesideOptions
- The address and storage
- UrlSyncOptions
- LinkSizes
- LocationPort
- NavigateMode
- StoragePort
- Commands and keys
- ListedCommand
- Rename
- TabMenu
- TabMenuItem
- Command
- Keymap
- KeymapOverrides
- KeymapOptions
- DefaultKeymapId
- KeyString
- Chord
- KeySequence
- Platform
- KeyWords
- Words
- Messages
- MessageOverrides
- ScreenDirection
- Actions
- PaneTarget
- ActionName
- ChooseOptions
- JaliActions
- JaliPage
- JaliDialogs
- Ref
- RefOf
- RefsOf
- PageOf
- AnyJali
- Register
- RegisteredJali
- JaliEvent
- DeepReadonly
- PaneOf
- KeyboardOptions
Import any of these with import type { … } from "jali-layout";. Functions that use them are on jali-layout.
The layout tree
Link to this section: The layout treeLayout
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
version1Required1.rootLayoutNodeRequiredoverlayOverlayOptionalLayoutNode
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 | SplitNodePaneNode
A pane: one object, shown by its kind's component.
interface PaneNode { type: "pane"; id; size; ref: ObjectRef; … }Fields
type"pane"RequiredidNodeIdRequiredsizeSizeRequiredrefObjectRefRequireduserSizedbooleanOptionalbaseSizeOptionallinkedToNodeIdOptionalfollowsbooleanOptionallinkedTo and changes in place when the selection moves. At most one per source and kind.keptbooleanOptionalpinnedbooleanOptionalbornnumberOptionalrolestringOptionalpriority"primary" | "supporting"OptionalSplitNode
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 = stringObjectRef
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[]RequiredfoldsNodeId[]RequiredshownRecord<NodeId, NodeId>RequiredhiddenNodeId[]OptionalTuckRecord
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
focusedNodeIdOptionalzoomedNodeIdOptionalzoom.scrollRecord<NodeId, number>Optionalscroll (week:732); a strip at its start writes nothing, and scrolling replaces the history entry.peekObjectRefOptionalfocusHistoryNodeId[]RequiredRect
A box in pixels, relative to the instance's inner area.
interface Rect { x: number; y: number; width: number; height: number }Writing a layout
Link to this section: Writing a layoutLayoutInput
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 | ObjectRefDraft
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 | TabsDraftSplitDraft
type SplitDraft = { type: Axis; options: RowOptions; children: Draft[] }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 }Kinds and pages
Link to this section: Kinds and pagesPaneOptions
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{ 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)RequiredwidthPaneWidthOptionalDefault { min: 240 }
Show width
minnumberOptionalDefault 240
comfortablenumberOptionalDefault min
maxnumberOptionalDefault none
heightPaneHeightOptionalDefault { min: 160 }
The same three as width, down a column.
Show height
minnumberOptionalDefault 160
comfortablenumberOptionalDefault min
maxnumberOptionalDefault none
showsstringOptionalDefault the kind
identity(params: P) => Identity | undefinedOptionalDefault every param, compared as text
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.scratchbooleanOptionalinRecent says otherwise.inRecentboolean | ((params: P) => boolean)OptionalDefault true (false for scratch kinds)
holdWhileResizingbooleanOptionalallowPaneAllowOptional{ fullScreen: false }. A kind can only turn controls off. See PaneAllow.buttonsPaneButtonsOptional(defaults) => defaults.filter((b) => b !== "tuck")). Leave it out for the instance's, or Jali's. See PaneButtons.phone{ stack?: boolean; place?: "top" | "bottom" }OptionalcreateJali({ 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> | undefinedOptionalundefined 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"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
type ParamValue = string | number | booleanParamType
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 | undefinedParamReader
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 | StandardSchemaV1Identity
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 | StandardSchemaV1StandardSchemaV1
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 }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 | numberPaneActivity
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?page=loan-review.namestringRequireditemNounstringRequiredrolesR[]RequiredhomestringRequiredbuild(item: I) => LayoutInputRequiredid and role are the role's id; those not shown at first are hidden.bind(item: I) => Record<string, ObjectRef>RequiredcreateJali (see Curated pages).firstItemIRequired"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 | voidAllowContext
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
belownumberOptional0 leaves it to the panes' minimum widths alone: one pane at a time only when even one pane can't fit.stackbooleanOptionalstackFloor and its kind's minimum height. While the on-screen keyboard is up, the focused pane shows alone. Default false.stackFloornumberOptionalfoldbooleanOptionaltrue.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 }The instance
Link to this section: The instanceJali
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. 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 withconsole.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 withconsole.errorand the others still hear it. SeeJaliEvents. getLayoutgetLayout(): DeepReadonly<Layout>- The layout on screen, to save. It is plain JSON, read-only;
structuredClonegives 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; asksbeforeCloselike 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:
enwithcreateJali({ messages })over it. Use it for your own UI in the same language. A curated page's own words (thepagearea, 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, whichactions.preset(id)takes, and itslabel. The preset in use isget().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. Afterdestroy()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
onorsubscribe, even an action's events not yet told. A question still open settles as"unavailable", and so does an action whosebeforeClosedestroyed the instance. Nothing is scheduled after it, andstart()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 }Requiredprevious is what it showed before. A launcher pane counts.close{ pane: NodeId; ref: R }Requiredpin{ pane: NodeId; pinned: boolean }RequiredsetPinned, 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 }RequiredtoastToastRequired<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"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 JaliOptionsJaliState
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>RequiredgetLayout() gives.pagePageState | nullRequirednull for the free layout.view{ focused?: NodeId; zoomed?: NodeId; peek?: R }RequiredpresetIdstring | undefinedRequiredselectionRecord<NodeId, Selection<R>>RequiredsettingsSettingsRequiredunsavedRecord<NodeId, string>RequiredactivityRecord<NodeId, PaneActivity>RequireduseActivity), merged across the components that report it. A pane nothing reports an activity for has no entry: it is idle.resizeModeNodeId | nullRequiredPageState
A curated page in use.
interface PageStateFields
profilestringRequireditemItemIdRequiredmodeViewModeRequiredtabstringRequiredSelection
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>[]Requiredpane(id: NodeId | undefined) => PaneOf<R> | undefinedRequiredpaneOf(ref: ObjectRef) => PaneOf<R> | undefinedRequiredref, 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 } | RefusalDone
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-foundOptionalinvalidOptionalmessage); or a layout that can't be shown. Nothing is stored as given, and it never throws.unavailableOptionalsingle-viewOptionalnot-allowedOptionalallow 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-paneOptionalblockedOptionalnothing-to-doOptionalunsavedOptionalsettled. (A linked detail that keeps its object because of its unsaved work doesn't ask, and has no settled.)keptOptionalbeforeClose 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).pendingOptionalbeforeClose 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
closeOptionalshowOptionalopenHere, a following detail, another item or view on a page.layoutOptionalsetLayout, undo, a page's mode.addressOptionalToast
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"RequiredDefault "swap"
paneCapnumberRequiredDefault 8
theme"system" | "light" | "dark"RequiredDefault "system"
boundary"tint" | "none"RequiredDefault "tint"
interface SettingsThemeChoice
type ThemeChoice = "system" | "light" | "dark"Theme
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
moveandsplit:"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.
The address and storage
Link to this section: The address and storageUrlSyncOptions
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
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 }Commands and keys
Link to this section: Commands and keysListedCommand
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[] | undefinedTabMenuItem
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 KeymapKeymapOverrides
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
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 = stringChord
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
type KeySequence = readonly Chord[]Platform
type Platform = "mac" | "other"KeyWords
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
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 | ObjectRefActionName
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
titlestringRequireditemsreadonly T[]Requiredlabel(item: T) => stringRequiredhint(item: T) => stringOptionalcurrentTOptionaldata-current, aria-current="true" and a tick). Compared with Object.is: pass one of items itself.placeholderstringOptionalDefault messages.chooser.choosePlaceholder
onChoose(item: T) => voidRequiredJaliActions
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
refbesidepane; focus stays inpane.{ edge: "bottom" }opens it belowpane(seeOpenBesideOptions); by default it opens afterpane.pane's selected item opens a following detail (kept if one already follows). A link never copies a pane of its own chain: whenref's object ispaneitself, a panepanewas opened from (up the chain), or one it opened, that pane is shown instead (panein 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.panein the result is the pane that showsref. Whereallowturnsopenoff forpane(in the free layout or on a curated page), no pane opens:refshows in the peek sheet instead, and the result is whatpeekreturns. openHereopenHere(pane: PaneTarget, ref: ObjectRef)- Show
refinpane. If it is open elsewhere, focus that pane (and closepanewhen it is a launcher). peekpeek(pane: PaneTarget, ref: ObjectRef)- Show
refin the peek sheet, forpane. Whenpane's following detail of that kind is on screen, the detail showsrefinstead. 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
paneand focus it. Withoutdirection: 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"whereallowturnsopenoff forpane. newTabnewTab(pane?: PaneTarget)- The launcher as a new tab of the pane's group.
"unavailable"without a launcher,"not-allowed"whereallowturnsopenoff for the pane. addTabaddTab(pane: PaneTarget, ref: ObjectRef)- Show
refas a new tab ofpane's group (or a new group), and focus it. It is one step: one entry in the history, and the tab takespane's slot, so nothing else folds or moves. Use it rather thanopenBesidethenmergeInto, which is two entries and can fold other panes in between. Ifrefis 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"whereallowturnsopenoff forpane.
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
removetook 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 (
beforeCloseand "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 withopenHere. 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)panejoinstarget'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:beforeCloseis 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
pinevent and no history entry. Each change firespin. 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"withoutcreateJali({ rename }), or whenrename.cansays 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 (apaneCapthat isn't a whole number from 1 to 64, athemeorcentreDropit 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 JaliDialogschoosechoose<T>(options: ChooseOptions<T>)- Ask the person for one of
options.itemsin 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 RegisteredJaliJaliEvent
The name of an event: "open", "close", "pin", "focus", "layout" or "toast".
type JaliEvent = keyof JaliEventsDeepReadonly
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
idNodeIdRequiredrefRRequiredtitlestringRequireduseTitle), else its kind's title.where"shown" | "tab" | "folded" | "tucked" | "hidden"Required"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.focusedbooleanRequiredboxRect | nullRequirednull while it isn't shown.selectedROptionalselect).linkedToNodeIdOptionalfollowsbooleanRequiredlinkedTo list selects.keptbooleanRequiredpinnedbooleanRequired// 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? }