// Types for kui's JSX runtime. Set in tsconfig: // "jsx": "react-jsx", "jsxImportSource": "@qxuken/kui" // -- generated from the core's event table; edit EVENTS in schema.rs, then `npm run gen` -- import type { HandlerMsg, WithKeySink, WithClick, WithDrag, WithKey, WithText, WithPreedit, WithSelect, WithSelectionRange, WithContextMenu, WithMenu, WithForceClick, WithButton, WithScroll, WithFocus, WithHover, WithDrop, WithFiles, WithLayout, WithRange, WithTypeahead, WithItemKey, WithQuery, WithEditChange, WithSliderChange, WithBoundary, WithSound, WithCapture, WithDismiss, WithResize, WithWindow, WithSystem, WithModifiers, WithOpen, } from './index.js'; // -- end generated -- import type { WindowDecl, WindowEvents } from './index.js'; /** Event message payloads: plain data, both directions (the Elm shape). * This is the wire type — anything JSON-shaped crosses; an app narrows it * to its own union with `KuiMsg` below. */ export type Msg = null | boolean | number | string | Msg[] | { [key: string]: Msg }; /** Declare the app's message type once, and the message props (`onClick`), * the handler props (`onDrag`, `onHover`, `onKey`, `onChange`, …) and * `createApp` / `runWindowed` take it instead of "any plain data": * * ```ts * type CounterMsg = * | { kind: 'add'; by: number } * | DragMsg<{ kind: 'pan' }> * | EditChangeMsg<{ kind: 'rename'; id: string }>; * * declare module '@qxuken/kui/jsx-runtime' { * interface KuiMsg { msg: CounterMsg } * } * ``` * * Register each message as it arrives (ADR 0047): a drag's message with * its `drag` field (`DragMsg`, `T & WithDrag`), an editor's with its * `change`. A handler prop takes the registered messages that carry its * field, as declared without it (`HandlerMsg`), so * `onDrag={{ kind: 'pan' }}` fits and `onDrag={{ kind: 'add', by: 1 }}` * does not. The window's own events are declared the same way (ADR * 0048): `windowEvents={{ onResize: { kind: 'resized' } }}` on the root * takes a registered `ResizeMsg<{ kind: 'resized' }>`. `update` sees the * registered messages and nothing else, and the loop types infer it from * there. * * A handler prop also takes `null`: `` is a key * sink whose events arrive as their field alone (`{ key: { … } }`), so a * sink that only needs the node key costs no member in the union. * * A payload typo then fails where it is written rather than in `update`. * Left un-augmented, payloads stay `Msg` and nothing changes. (One app per * tsconfig is the shape kui already has: one window, one event loop.) */ export interface KuiMsg {} /** The app's message type: whatever `KuiMsg` was augmented with, else `Msg`. */ export type AppMsg = KuiMsg extends { msg: infer M } ? M : Msg; export interface KuiElement { type: string; key?: string; props: Record; children: KuiNode[]; } export type KuiNode = | KuiElement | KuiNode[] | string | number | boolean | null | undefined; /** A reference to a colour token by name — `'$peach'` — as `defineTokens` * types it (`docs/adr/0027-tokens-beside-the-theme.md`). The string is * what rides; the brand is what tells a colour's reference from a * length's at the type level. Any colour prop takes one. */ export type ColorToken = `$${string}` & { readonly __kuiToken?: 'color' }; /** A reference to a length token by name — `'$sideW'` — for any length * prop: a size, a pad edge, a radius, a border width, a fixed width or * height. Resolved to logical px by the core's table. Every other number * prop takes one too, as the number itself: `opacity={roles.disabledOpacity}` * dims a node as a disabled stock control is dimmed (ADR 0049). A colour token in a * length slot is a type error here; a length token in a colour slot is * caught at encode time instead (`unknown-token`), since `ColorProp` * admits any string and narrowing it would refuse every helper that * returns one. */ export type LengthToken = `$${string}` & { readonly __kuiToken?: 'length' }; /** A reference to a family token by name — `'$code'` — for a `family` * prop: the face the token's fallback list picked * (`docs/adr/0049-the-disabled-opacity-and-font-families-by-token.md`). * `family` takes any string, so the brand documents rather than narrows; * it is what keeps a family token out of a length slot (a colour slot * takes any string, so there it is `unknown-token` at encode time). */ export type FamilyToken = `$${string}` & { readonly __kuiToken?: 'family' }; /** Logical px, or a length token. */ export type LengthProp = number | LengthToken; /** A size expression (backlog F109), resolved against the parent's content * box — the box a percentage takes its cut of: spelled as CSS spells it * (`"clamp(400px, 80%, 1000px)"`, `"min(720px, 100%)"`, nested), or as * data, which crosses to the addon as numbers and is never parsed: * `{ clamp: [400, "80%", 1000] }`, `{ min: [...] }`, `{ max: [...] }`, * `{ percent: 80 }`, `{ px: 12 }`. An expression with no percentage in * it is a length. */ export type SizeExpr = | number | `${number}%` | `${number}px` | `min(${string})` | `max(${string})` | `clamp(${string})` | { percent: number } | { px: number } | { min: SizeExpr[] } | { max: SizeExpr[] } | { clamp: [SizeExpr, SizeExpr, SizeExpr] }; /** number = fixed logical px; "N%" of parent (`{ percent: N }` is the same * number); grow soaks up leftover space; a size expression (`SizeExpr`); * a length token is a fixed px the core's table resolves. */ export type SizingProp = | 'fit' | 'grow' | { grow: number } | SizeExpr | LengthToken; /** A lower clamp: logical px, a size expression, or "fit" for the node's * own fit size on that axis — what lets a `grow` child keep a content * floor (a tab never narrower than its label). */ export type MinProp = 'fit' | SizeExpr | LengthToken; /** An upper clamp: logical px or a size expression (`"90%"`, a clamp). */ export type MaxProp = SizeExpr | LengthToken; /** 0xRRGGBBAA number, "#rgb" / "#rrggbb" / "#rrggbbaa", or a colour * token's reference (`'$peach'`, a theme role's `'$surface'`). */ export type ColorProp = number | string | ColorToken; export type AlignProp = 'start' | 'center' | 'end'; /** One CSS-style keyframe stop for `keyframes`. `at` is 0..1 and spreads * evenly when omitted (a lone stop sits at 1 and animates from the node's * own value); a slot a stop leaves out is left to its neighbours. Sizings * animate their amount only, in the form the prop itself declares. */ export interface KeyframeProp { at?: number; /** Logical px across from where layout put the node, at this stop (backlog F132): the node and its subtree are drawn and hit there. Left out, 0. */ dx?: number; /** Logical px down from where layout put the node, at this stop: `[{ dy: 0 }, { dy: -6 }]` with `repeat: 'alternate'` bobs it. Left out, 0. */ dy?: number; width?: SizingProp; height?: SizingProp; bg?: ColorProp; radius?: number; /** Group opacity, 0..1. */ opacity?: number; /** A turn in turns clockwise (ADR 0043). */ rotate?: number; /** A uniform scale about the node's pivot. */ scale?: number; /** A stretch across about the node's pivot, multiplying `scale` * (backlog C149). */ scaleX?: number; /** A stretch down about the node's pivot, multiplying `scale`. */ scaleY?: number; } /** Where a node starts the first frame it is seen, for `enter`: the slots * it names ease in from these values over `transition` ms instead of * snapping. `dx`/`dy` are logical px the node slides in from; the rest * take the forms the props themselves take. A node that leaves and comes * back enters again. */ export interface EnterProp { dx?: number; dy?: number; width?: SizingProp; height?: SizingProp; bg?: ColorProp; radius?: number; /** Group opacity, 0..1: `{ opacity: 0 }` fades the whole subtree in. */ opacity?: number; /** A turn in turns clockwise (ADR 0043): `{ rotate: -0.02 }` swings in. */ rotate?: number; /** A uniform scale about the node's pivot: `{ scale: 0.8 }` settles in. */ scale?: number; /** A stretch across about the node's pivot (backlog C149): `{ scaleX: 0 }` * grows a bar in from its pivot. */ scaleX?: number; /** A stretch down about the node's pivot: a chart's lines enter at the * old range's `{ scaleY, dy }` and settle. */ scaleY?: number; /** On an `exit` only: the node keeps its room until its exit ends, then * gives it up, so what follows moves in after it has gone (backlog * C110) — a toast leaving a stack. */ keepRoom?: boolean; } /** A gradient painted over a box's `bg`, under its border and children * (docs/adr/0042-a-gradient-is-an-image-the-core-paints.md). Linear * `to` a side or a corner (the default is `'bottom'`) or along `angle`, * or `radial` from `at`. Defined on the box's unit square and stretched * to it: a side or a corner is CSS's, and any other `angle` runs corner * to corner at an eighth of a turn whatever the box's aspect, where * CSS's `45deg` does not. Rasterized once per distinct gradient and * drawn as one image quad; it does not tween. */ export interface GradientProp { /** The side or corner a linear gradient runs to. */ to?: 'right' | 'bottom right' | 'bottom' | 'bottom left' | 'left' | 'top left' | 'top' | 'top right'; /** A linear gradient's direction in turns, clockwise from east: 0.25 * runs downwards. */ angle?: number; /** Out from `at` to the box's farthest corner instead of along a line. */ radial?: boolean; /** A radial gradient's centre as fractions of the box; the middle, * `[0.5, 0.5]`, without one. */ at?: [number, number]; /** Two or more colours, each alone or as `[colour, position]` with the * position 0 to 1. Stops without one are spaced evenly between those * with; two at one position are a hard edge. A `$token` that misses * is raised as `unknown-token` and its stop left out, so a gradient * left with fewer than two draws nothing over the `bg`. */ stops: (ColorProp | [ColorProp, number])[]; } /** One side of a threshold, or both, over a length (ADR 0069): `below` * holds under it, `above` at or over it, and a range that holds keeps * holding `band` past its threshold. */ export interface RangeProp { below?: LengthProp; above?: LengthProp; band?: LengthProp; } /** What a `when` entry or a `` tests: every condition named * must hold (ADR 0069). `width` and `height` are the node's own size — * in a ``, its parent's. */ export interface WhenConditions { width?: RangeProp; height?: RangeProp; window?: { width?: RangeProp; height?: RangeProp }; dark?: boolean; light?: boolean; reducedMotion?: boolean; contrast?: 'more' | 'normal'; platform?: 'macos' | 'windows' | 'linux' | 'other' | ('macos' | 'windows' | 'linux' | 'other')[]; scale?: RangeProp; hovered?: boolean; pressed?: boolean; focused?: boolean; focusVisible?: boolean; disabled?: boolean; selected?: boolean; /** The node's hover group's state (backlog C106): the pointer over a * member, a press held on one, focus on one, that focus shown. */ groupHovered?: boolean; groupPressed?: boolean; groupFocused?: boolean; groupFocusVisible?: boolean; } /** One entry of a node's `when` list (ADR 0069): the conditions it tests * and the props it sets while they hold. An entry over the node's own * size sets the layout of its children only, `hidden` there naming the * keyed children it hides. A `width` that is a range is a condition; one * that is a sizing is the prop. */ export type WhenEntry = Omit & { width?: RangeProp | SizingProp; height?: RangeProp | SizingProp; hidden?: boolean | string[]; dir?: 'row' | 'column'; } & Omit, 'width' | 'height' | 'hidden' | 'when'> & Omit, 'dir'>; /** ``'s props (ADR 0069): `needs` or `query`, the two builders and * the message the decision's changes arrive as. */ export interface LazyProps { /** The room the branch needs from its parent, in either axis or both. */ needs?: { w?: number; h?: number }; /** Or the conditions over the parent's size, the window's or the * environment's while which `render` is built. */ query?: Omit< WhenConditions, | 'hovered' | 'pressed' | 'focused' | 'focusVisible' | 'disabled' | 'selected' | 'groupHovered' | 'groupPressed' | 'groupFocused' | 'groupFocusVisible' >; render: () => KuiNode; fallback?: () => KuiNode; onQuery?: Msg; key?: string | number; } export interface FloatProp { /** The preset to start from; every key below overrides one of its * values and leaving one out keeps the preset's own, so * `{ anchor: 'below', dx: 4 }` still hangs below with its 6px gap. */ anchor?: 'parent' | 'viewport' | 'below' | 'above'; /** Attach point on the anchor, [x, y]. */ at?: [AlignProp, AlignProp]; /** Attach point on the floating node itself, [x, y]. */ self?: [AlignProp, AlignProp]; dx?: number; dy?: number; /** Flip across the anchor / clamp to stay inside the viewport. */ fit?: boolean; /** Leave every ancestor's clip (ADR 0074): what a menu, a popover or * a tooltip hung off a control in a scroller says, so it shows whole * past the scroller's edge. Without it a float anchored to its parent * (`parent`, `below`, `above`) is cut where a child of its parent would * be, by the nearest box above it that clips or scrolls, and hit only * there; still drawn as a layer over its in-flow siblings. A viewport * float leaves either way. A `line`, `polygon` or `path` in its * parent's box never escapes. */ escape?: boolean; /** @deprecated What a float anchored to its parent does now (ADR * 0074): not read. A float that must leave says `escape`. */ clip?: boolean; } // -- generated from the core's menu roles; edit MenuRole::ALL in crates/kui-core/src/menu.rs, then `npm run gen` -- /** What a menu row is: the app's own (`custom`), a divider, or one of * the standard rows the core performs itself. The same spelling a * `menu` message reports back. */ export type MenuItemRole = | 'custom' | 'separator' | 'cut' | 'copy' | 'paste' | 'selectAll' | 'lookUp' | 'about' | 'hide' | 'hideOthers' | 'showAll' | 'quit'; // -- end generated -- /** One row to put in a context menu (`Ctx.openMenu`). Everything but * `label` is optional, and a standard `role` takes its own wording when * `label` is empty — so `{ role: 'copy' }` is the platform's Copy. * `id` is what the row posts when chosen (its label, when absent). */ export interface MenuItemInput { label?: string; role?: MenuItemRole; enabled?: boolean; /** Draws a checkmark beside the row (and sets the platform's own check * state where a host renders the menu): a setting the row *is*, not a * command it runs. */ checked?: boolean; id?: unknown; /** Display only: the shortcut is the app's or the platform's — except in * a menu bar the platform draws, where a spelling kui can parse * (`'mod+s'`, `'⌘S'`, `'Ctrl+Shift+P'`) becomes the real key equivalent. * A declaration kui can parse is rewritten into the platform's own * spelling, so `'mod+s'` reads as `⌘S` on macOS and `Ctrl+S` elsewhere. */ accel?: string; /** The rows of a submenu: the row draws a chevron and opens them beside * itself — on hover, a click, Enter or the Right arrow; Left or Escape * closes it — and is never chosen itself. A chosen row inside posts its * own `menu` event, on the node the menu is about. */ items?: MenuItemInput[]; /** The row *is* its `accel`: chosen — by the pointer, or by the key * equivalent a platform menu bar binds — it plays that chord where the * keyboard is and posts no `menu` event, as the standard Edit menu's rows * do. A field with focus undoes or copies through its own key, a sink * that binds the chord hears it. A row whose `accel` kui cannot parse is * an ordinary row. */ replay?: boolean; } /** One menu of the application menu bar (the `` * element's prop): a title and the rows that drop out of it * (`docs/adr/0018-a-menu-bar-the-app-declares.md`). Its rows are the same * `MenuItemInput` a context menu takes, so a standard `role` is performed * by the core here too — an Edit menu's `{ role: 'copy' }` is the * right-click Copy. * * On macOS the first menu is the application menu, which the OS titles * with the app's own name whatever `label` says. */ export interface MenuInput { label: string; items: MenuItemInput[]; /** A disabled menu is dimmed and opens nothing. */ enabled?: boolean; } /** The whole bar, in order — the `` element's prop. * `[]` takes the menu away; a frame that draws no `` at all * leaves the last declaration in force. */ export type MenuBarInput = MenuInput[]; interface Keyed { /** Stable identity for retained state (scroll offsets, editors). */ key?: string | number; } // -- generated from the addon's prop schema; edit schema.rs, then `npm run gen` -- export interface GeneratedSpecProps { /** Paint this node's background in the OS accent colour — `env.system.accent` — keeping the declared `bg` on a host that cannot tell what it is. The one prop whose paint depends on the environment, which is why it is opt-in: the same tree is a different colour on two machines, and that is the point here and a surprise anywhere else. On the stock button it does the whole job — the hover and pressed shades are derived from the accent, and the label goes black or white by its luminance, so a yellow accent is still readable — which is what `