跳到主要内容

ui/behaviors

ui/behaviors

此内容目前仅提供英文版。

导入自 @norbital-ai/ui/behaviors

Single-source composable Svelte-5 headless behavior primitives. Used directly by @norbital-ai/ui built-in components AND exported for tenants to compose custom widgets with identical keyboard navigation, ARIA, overflow, resizing, dismissal, focus management, shortcuts, selection, pagination, clipboard, floating, portals, dates, direct manipulation, canvas gestures, live announcements and agent observability hooks.

behaviors

Accordion type

type Accordion = ReturnType<typeof create_accordion>;

Return value of create_accordion.

成员

名称类型说明
openreadonly string[]
is_open(key: string) => boolean
toggle(key: string) => void
expand(key: string) => void
collapse(key: string) => void
item(key: string) => import("svelte/attachments").Attachment<HTMLElement>
root_attrs() => { onkeydown: (event: KeyboardEvent) => void; }
trigger_attrs(key: string) => { type: "button"; id: string; "aria-expanded": boolean; "aria-controls": string; "data-state": "open" | "closed"; disabled: true | undefined; tabindex: number | undefined; onfocus: () => void; onclick: () => void; }
content_attrs(key: string) => { id: string; role: "region"; "aria-labelledby": string; hidden: boolean; "data-state": "open" | "closed"; }

源码: packages/ui/src/behaviors/accordion.svelte.ts:32

AccordionMode type

type AccordionMode = 'single' | 'multiple';

Single or multiple expanded sections mode for create_accordion.

源码: packages/ui/src/behaviors/accordion.svelte.ts:9

AccordionOptions type

type AccordionOptions = {
    /** Item keys in visual order. */
    items: () => readonly string[];
    /** Single or multiple expanded sections (default `'single'`). */
    mode?: AccordionMode;
    /** In single mode, allow collapsing the only open item (default `true`). */
    collapsible?: boolean;
    /** Controlled open keys; omit for internal state. */
    open?: () => readonly string[];
    /** Initial open keys when uncontrolled. */
    default_open?: readonly string[];
    /** Called whenever expanded keys change. */
    on_change?: (open: readonly string[]) => void;
    /** Disabled predicate per item key. */
    disabled?: (key: string) => boolean;
    /** Optional semantic control id/label for Norbius's `page` bridge. */
    control?: {
        id: string;
        label?: string;
    };
};

Options for create_accordion.

成员

名称类型说明
items() => readonly string[]

Item keys in visual order.

mode?AccordionMode

Single or multiple expanded sections (default 'single').

collapsible?boolean

In single mode, allow collapsing the only open item (default true).

open?() => readonly string[]

Controlled open keys; omit for internal state.

default_open?readonly string[]

Initial open keys when uncontrolled.

on_change?(open: readonly string[]) => void

Called whenever expanded keys change.

disabled?(key: string) => boolean

Disabled predicate per item key.

control?{ id: string; label?: string; }

Optional semantic control id/label for Norbius's page bridge.

源码: packages/ui/src/behaviors/accordion.svelte.ts:12

AnnounceOptions type

type AnnounceOptions = {
    /** Announcement urgency (default `'polite'`). */
    readonly priority?: AnnouncePriority;
    /** Target document (defaults to global `document`). */
    readonly doc?: Document;
};

Options for announce.

成员

名称类型说明
priority?AnnouncePriority

Announcement urgency (default 'polite').

doc?Document

Target document (defaults to global document).

源码: packages/ui/src/behaviors/announce.svelte.ts:9

AnnouncePriority type

type AnnouncePriority = 'polite' | 'assertive';

Urgency of a screen-reader announcement ('polite' waits for idle, 'assertive' interrupts).

源码: packages/ui/src/behaviors/announce.svelte.ts:6

AreaBehavior type

type AreaBehavior = ReturnType<typeof create_area>;

Return value of create_area.

成员

名称类型说明
valueAreaValue
percent_xnumber
percent_ynumber
draggingboolean
set(next: AreaValue, commitNow?: boolean) => void
surfaceAttachment<HTMLElement>
thumb_attrs() => { role: "slider"; tabindex: number; "aria-label": string | undefined; "aria-valuetext": string; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/canvas.svelte.ts:131

AreaOptions type

type AreaOptions = {
    readonly value?: () => AreaValue;
    readonly default_value?: AreaValue;
    readonly on_change?: (value: AreaValue) => void;
    readonly on_commit?: (value: AreaValue) => void;
    readonly min_x?: number;
    readonly max_x?: number;
    readonly min_y?: number;
    readonly max_y?: number;
    readonly step_x?: number;
    readonly step_y?: number;
    readonly label?: string;
};

Options for create_area.

成员

名称类型说明
value?() => AreaValue
default_value?AreaValue
on_change?(value: AreaValue) => void
on_commit?(value: AreaValue) => void
min_x?number
max_x?number
min_y?number
max_y?number
step_x?number
step_y?number
label?string

源码: packages/ui/src/behaviors/canvas.svelte.ts:116

AreaValue type

type AreaValue = {
    readonly x: number;
    readonly y: number;
};

2D slider coordinates { x, y }.

成员

名称类型说明
xnumber
ynumber

源码: packages/ui/src/behaviors/canvas.svelte.ts:113

AriaPattern type

type AriaPattern = 'dialog' | 'menu' | 'menubar' | 'listbox' | 'combobox' | 'tabs' | 'accordion' | 'tree' | 'grid' | 'radiogroup' | 'toolbar' | 'switch' | 'slider' | 'carousel';

Supported WAI-ARIA Authoring Practices Guide widget patterns verified by check_pattern.

源码: packages/ui/src/behaviors/testing.ts:4

AsyncOptions type

type AsyncOptions<T> = ReturnType<typeof create_async_options<T>>;

Return value of create_async_options.

成员

名称类型说明
querystring
itemsreadonly T[]
statusAsyncOptionsStatus
loadingboolean
errorunknown
has_moreboolean
set_query(next: string, opts?: { immediate?: boolean; }) => void
load_more() => void
reload() => void
reset() => void
cancel() => void

源码: packages/ui/src/behaviors/async-options.svelte.ts:38

AsyncOptionsContext type

type AsyncOptionsContext = {
    /** Aborted automatically when a newer query or reset supersedes this request. */
    readonly signal: AbortSignal;
    /** Zero-based page index (`0` for fresh query, incremented by `load_more()`). */
    readonly page: number;
};

Context passed to AsyncOptionsOptions.load.

成员

名称类型说明
signalAbortSignal

Aborted automatically when a newer query or reset supersedes this request.

pagenumber

Zero-based page index (0 for fresh query, incremented by load_more()).

源码: packages/ui/src/behaviors/async-options.svelte.ts:18

AsyncOptionsOptions type

type AsyncOptionsOptions<T> = {
    /** Fetches matching items for `query` and `ctx.page`, honoring `ctx.signal`. */
    readonly load: (query: string, ctx: AsyncOptionsContext) => Promise<AsyncOptionsPage<T>>;
    /** Initial query (default `''`). */
    readonly initial_query?: string;
    /** Typing debounce window in ms (default `200`). */
    readonly debounce_ms?: number;
    /** Fetch immediately for `initial_query` on mount (default `false`). */
    readonly immediate?: boolean;
};

Options for create_async_options.

成员

名称类型说明
load(query: string, ctx: AsyncOptionsContext) => Promise<AsyncOptionsPage<T>>

Fetches matching items for query and ctx.page, honoring ctx.signal.

initial_query?string

Initial query (default '').

debounce_ms?number

Typing debounce window in ms (default 200).

immediate?boolean

Fetch immediately for initial_query on mount (default false).

源码: packages/ui/src/behaviors/async-options.svelte.ts:26

AsyncOptionsPage type

type AsyncOptionsPage<T> = readonly T[] | {
    readonly items: readonly T[];
    readonly has_more?: boolean;
};

Page payload returned by AsyncOptionsOptions.load.

源码: packages/ui/src/behaviors/async-options.svelte.ts:10

AsyncOptionsStatus type

type AsyncOptionsStatus = 'idle' | 'loading' | 'error';

Load lifecycle state of create_async_options.

源码: packages/ui/src/behaviors/async-options.svelte.ts:7

AutoScroll type

type AutoScroll = ReturnType<typeof create_auto_scroll>;

Return value of create_auto_scroll.

成员

名称类型说明
update(x: number, y: number) => void
stop() => void

源码: packages/ui/src/behaviors/drag.svelte.ts:164

AutoScrollOptions type

type AutoScrollOptions = {
    /** Edge proximity threshold in px where scrolling begins (default `48`). */
    readonly edge?: number;
    /** Maximum scroll speed in px/frame at the edge (default `18`). */
    readonly speed?: number;
    /** Called after each scrolled frame so drag hit-testing updates under a stationary pointer. */
    readonly on_scroll?: () => void;
    /** Optional element to ignore when hit-testing scrollers underneath the pointer. */
    readonly ignore?: () => Element | null | undefined;
};

Options for create_auto_scroll.

成员

名称类型说明
edge?number

Edge proximity threshold in px where scrolling begins (default 48).

speed?number

Maximum scroll speed in px/frame at the edge (default 18).

on_scroll?() => void

Called after each scrolled frame so drag hit-testing updates under a stationary pointer.

ignore?() => Element | null | undefined

Optional element to ignore when hit-testing scrollers underneath the pointer.

源码: packages/ui/src/behaviors/drag.svelte.ts:152

BindDragOptions type

type BindDragOptions = {
    /** Movement in CSS px before `on_start`/`on_move` fire (default `DRAG_THRESHOLD`). */
    readonly threshold?: number;
    /** Return `false` to reject starting the drag. */
    readonly on_start?: (event: PointerEvent) => boolean | void;
    /** Called at most once per animation frame with latest pointer coordinates. */
    readonly on_move: (sample: PointerSample) => void;
    /** Called when the pointer lifts, cancels, or Escape aborts. */
    readonly on_end?: (event: PointerEvent | KeyboardEvent, canceled: boolean) => void;
    /** Cancel active drag on Escape (default `true`). */
    readonly cancel_on_escape?: boolean;
    /** Stop `pointerdown` propagation so nested drag surfaces do not both capture the gesture. */
    readonly stop_propagation?: boolean;
    /** Disable dragging reactively. */
    readonly disabled?: () => boolean;
};

Options for bind_drag.

成员

名称类型说明
threshold?number

Movement in CSS px before on_start/on_move fire (default DRAG_THRESHOLD).

on_start?(event: PointerEvent) => boolean | void

Return false to reject starting the drag.

on_move(sample: PointerSample) => void

Called at most once per animation frame with latest pointer coordinates.

on_end?(event: PointerEvent | KeyboardEvent, canceled: boolean) => void

Called when the pointer lifts, cancels, or Escape aborts.

cancel_on_escape?boolean

Cancel active drag on Escape (default true).

stop_propagation?boolean

Stop pointerdown propagation so nested drag surfaces do not both capture the gesture.

disabled?() => boolean

Disable dragging reactively.

源码: packages/ui/src/behaviors/drag.svelte.ts:21

BindHoldOptions type

type BindHoldOptions = {
    /** Hold duration in ms before `on_hold` fires (default `500`). */
    readonly delay?: number;
    /** Max pointer drift in px before canceling (default `8`). */
    readonly tolerance?: number;
    /** Keys that start a keyboard hold (default `[' ', 'Enter']`). */
    readonly keys?: readonly string[];
    /** Called when press starts. */
    readonly on_start?: (details: {
        readonly event: PointerEvent | KeyboardEvent;
        readonly input: HoldInput;
    }) => void;
    /** Called once the press crosses `delay`. */
    readonly on_hold: (details: {
        readonly event: PointerEvent | KeyboardEvent;
        readonly input: HoldInput;
    }) => void;
    /** Called when the press lifts or cancels. */
    readonly on_end?: (details: {
        readonly event: Event;
        readonly input: HoldInput;
        readonly held: boolean;
        readonly canceled: boolean;
    }) => void;
    /** Disable reactively. */
    readonly disabled?: () => boolean;
};

Options for bind_hold.

成员

名称类型说明
delay?number

Hold duration in ms before on_hold fires (default 500).

tolerance?number

Max pointer drift in px before canceling (default 8).

keys?readonly string[]

Keys that start a keyboard hold (default [' ', 'Enter']).

on_start?(details: { readonly event: PointerEvent | KeyboardEvent; readonly input: HoldInput; }) => void

Called when press starts.

on_hold(details: { readonly event: PointerEvent | KeyboardEvent; readonly input: HoldInput; }) => void

Called once the press crosses delay.

on_end?(details: { readonly event: Event; readonly input: HoldInput; readonly held: boolean; readonly canceled: boolean; }) => void

Called when the press lifts or cancels.

disabled?() => boolean

Disable reactively.

源码: packages/ui/src/behaviors/micro.svelte.ts:199

BindRepeatOptions type

type BindRepeatOptions = {
    /** Called immediately on press and repeatedly while held. */
    readonly on_step: (count: number) => void;
    /** Called when the repeating press stops. */
    readonly on_end?: (count: number) => void;
    /** Delay before repeating begins in ms (default `400`). */
    readonly delay?: number;
    /** Interval between repeated steps in ms (default `60`). */
    readonly interval?: number;
    /** Disable reactively. */
    readonly disabled?: () => boolean;
};

Options for bind_repeat.

成员

名称类型说明
on_step(count: number) => void

Called immediately on press and repeatedly while held.

on_end?(count: number) => void

Called when the repeating press stops.

delay?number

Delay before repeating begins in ms (default 400).

interval?number

Interval between repeated steps in ms (default 60).

disabled?() => boolean

Disable reactively.

源码: packages/ui/src/behaviors/micro.svelte.ts:334

CalendarBehavior type

type CalendarBehavior = ReturnType<typeof create_calendar>;

Return value of create_calendar.

成员

名称类型说明
placeholderCalendarDate
monthsreadonly CalendarMonth[]
weekdaysreadonly string[]
set_placeholder(next: DateValue) => void
prev_month() => void
next_month() => void
reset_pending() => void
focusedCalendarDate
focus_day(target: CalendarDate) => void
day_ref(date: CalendarDate) => Attachment<HTMLElement>
day_attrs(date: CalendarDate, month: CalendarDate) => { role: "button"; tabindex: number; "data-value": string; "data-selected": string | undefined; "data-selection-start": string | undefined; "data-selection-end": string | undefined; "data-today": string | undefined; "data-outside-month": string | undefined; "data-disabled": string | undefined; "aria-disabled": true | undefined; "aria-selected": boolean;…

源码: packages/ui/src/behaviors/date-time.svelte.ts:121

CalendarMode type

type CalendarMode = 'single' | 'range';

Selection mode for create_calendar.

源码: packages/ui/src/behaviors/date-time.svelte.ts:74

CalendarMonth type

type CalendarMonth = {
    /** First day of this month. */
    readonly value: CalendarDate;
    /** Rows of 7 `CalendarDate` cells (including leading/trailing outside-month days). */
    readonly weeks: readonly (readonly CalendarDate[])[];
};

One month grid returned by create_calendar.

成员

名称类型说明
valueCalendarDate

First day of this month.

weeksreadonly (readonly CalendarDate[])[]

Rows of 7 CalendarDate cells (including leading/trailing outside-month days).

源码: packages/ui/src/behaviors/date-time.svelte.ts:85

CalendarOptions type

type CalendarOptions = {
    /** Single-day or date-range selection mode (default `'single'`). */
    readonly mode?: CalendarMode | (() => CalendarMode);
    /** Selected single date when `mode === 'single'`. */
    readonly value?: () => DateValue | undefined;
    /** Selected range when `mode === 'range'`. */
    readonly range?: () => CalendarRange;
    /** Called on single-day selection. */
    readonly on_select?: (date: DateValue) => void;
    /** Called when range selection updates (with `{ start, end }`). */
    readonly on_range_change?: (range: CalendarRange) => void;
    /** Controlled visible anchor month. */
    readonly placeholder?: () => DateValue | undefined;
    /** Called when the visible month changes. */
    readonly on_placeholder_change?: (next: DateValue) => void;
    /** Number of side-by-side months to build (default `1`). */
    readonly number_of_months?: () => number;
    /** BCP-47 locale for weekday order and names (default `'en-US'`). */
    readonly locale?: () => string | undefined;
    /** Minimum selectable date. */
    readonly min?: () => DateValue | undefined;
    /** Maximum selectable date. */
    readonly max?: () => DateValue | undefined;
    /** Disabled state. */
    readonly disabled?: () => boolean;
};

Options for create_calendar.

成员

名称类型说明
mode?CalendarMode | (() => CalendarMode)

Single-day or date-range selection mode (default 'single').

value?() => DateValue | undefined

Selected single date when mode === 'single'.

range?() => CalendarRange

Selected range when mode === 'range'.

on_select?(date: DateValue) => void

Called on single-day selection.

on_range_change?(range: CalendarRange) => void

Called when range selection updates (with { start, end }).

placeholder?() => DateValue | undefined

Controlled visible anchor month.

on_placeholder_change?(next: DateValue) => void

Called when the visible month changes.

number_of_months?() => number

Number of side-by-side months to build (default 1).

locale?() => string | undefined

BCP-47 locale for weekday order and names (default 'en-US').

min?() => DateValue | undefined

Minimum selectable date.

max?() => DateValue | undefined

Maximum selectable date.

disabled?() => boolean

Disabled state.

源码: packages/ui/src/behaviors/date-time.svelte.ts:93

CalendarRange type

type CalendarRange = {
    /** First selected date, if any. */
    readonly start: DateValue | undefined;
    /** Last selected date, if any. */
    readonly end: DateValue | undefined;
};

Start and end of a calendar date range.

成员

名称类型说明
startDateValue | undefined

First selected date, if any.

endDateValue | undefined

Last selected date, if any.

源码: packages/ui/src/behaviors/date-time.svelte.ts:77

CarouselBehavior type

type CarouselBehavior = ReturnType<typeof create_carousel>;

Return value of create_carousel.

成员

名称类型说明
indexnumber
countnumber
can_prevboolean
can_nextboolean
pausedboolean
go_to(next: number) => void
next() => void
prev() => void
set_paused(p: boolean) => void
rootAttachment<HTMLElement>
trackAttachment<HTMLElement>
root_attrs() => { role: "region"; "aria-roledescription": string; "aria-label": string; onpointerenter: () => boolean; onpointerleave: () => boolean; onfocusin: () => boolean; onfocusout: () => boolean; onkeydown: (event: KeyboardEvent) => void; }
slide_attrs(i: number) => { role: "group"; "aria-roledescription": string; "aria-label": string; "aria-hidden": true | undefined; "data-active": string | undefined; }
dot_attrs(i: number) => { type: "button"; "aria-label": string; "aria-current": "true" | undefined; "data-active": string | undefined; onclick: () => void; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:240

CarouselOptions type

type CarouselOptions = {
    readonly count: () => number;
    readonly index?: () => number;
    readonly default_index?: number;
    readonly on_change?: (index: number) => void;
    readonly loop?: boolean;
    readonly autoplay_ms?: number;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_carousel.

成员

名称类型说明
count() => number
index?() => number
default_index?number
on_change?(index: number) => void
loop?boolean
autoplay_ms?number
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:228

CellBounds type

type CellBounds = {
    readonly top: number;
    readonly left: number;
    readonly bottom: number;
    readonly right: number;
};

Normalized inclusive rectangular bounds of a CellRange.

成员

名称类型说明
topnumber
leftnumber
bottomnumber
rightnumber

源码: packages/ui/src/behaviors/grid.svelte.ts:15

CellRange type

type CellRange = {
    readonly anchor: GridCell;
    readonly end: GridCell;
};

Rectangular cell range from anchor to end.

成员

名称类型说明
anchorGridCell
endGridCell

源码: packages/ui/src/behaviors/grid.svelte.ts:12

CellRangeBehavior type

type CellRangeBehavior = ReturnType<typeof create_cell_range>;

Return value of create_cell_range.

成员

名称类型说明
rangeCellRange | null
boundsCellBounds | null
draggingboolean
start(cell: GridCell) => void
extend(to: GridCell, from?: GridCell, notify?: boolean) => void
select_row(row: number) => void
select_col(col: number) => void
clear() => void
contains(cell: GridCell) => boolean
to_text(read: (cell: GridCell) => string) => string
cell_attrs(cell: GridCell) => { "aria-selected": boolean; "data-in-range": string | undefined; onpointerdown: (event: PointerEvent) => void; onpointerenter: () => void; }

源码: packages/ui/src/behaviors/grid.svelte.ts:253

CellRangeOptions type

type CellRangeOptions = {
    /** Total row count. */
    readonly rows: () => number;
    /** Total column count. */
    readonly cols: () => number;
    /** Controlled range; omit for internal state. */
    readonly range?: () => CellRange | null;
    /** Called when the selected cell range changes. */
    readonly on_change?: (range: CellRange | null) => void;
    /** Optional live-region message formatter on range updates. */
    readonly message?: (bounds: CellBounds) => string;
};

Options for create_cell_range.

成员

名称类型说明
rows() => number

Total row count.

cols() => number

Total column count.

range?() => CellRange | null

Controlled range; omit for internal state.

on_change?(range: CellRange | null) => void

Called when the selected cell range changes.

message?(bounds: CellBounds) => string

Optional live-region message formatter on range updates.

源码: packages/ui/src/behaviors/grid.svelte.ts:239

ChangeSource type

type ChangeSource = 'pointer' | 'keyboard' | 'agent' | 'programmatic';

Who initiated a UI change.

源码: packages/ui/src/behaviors/controls.svelte.ts:7

CheckboxGroup type

type CheckboxGroup = ReturnType<typeof create_checkbox_group>;

Return value of create_checkbox_group.

成员

名称类型说明
checkedreadonly string[]
all_stateboolean | "indeterminate"
is_checked(key: string) => boolean
toggle(key: string) => void
toggle_all() => void
group_attrs() => { role: "group"; "aria-label": string | undefined; }
all_attrs() => { type: "checkbox"; checked: boolean; "aria-checked": boolean | "mixed"; onchange: () => void; }
item_attrs(key: string) => { type: "checkbox"; checked: boolean; disabled: true | undefined; onchange: () => void; }

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:621

CheckboxGroupOptions type

type CheckboxGroupOptions = {
    /** All selectable item keys. */
    readonly items: () => readonly string[];
    /** Controlled checked keys; omit for internal state. */
    readonly value?: () => readonly string[];
    /** Initial checked keys when uncontrolled. */
    readonly default_value?: readonly string[];
    /** Called when checked keys change. */
    readonly on_change?: (next: readonly string[]) => void;
    /** Per-item disabled predicate. */
    readonly disabled?: (key: string) => boolean;
    /** Accessible label for the group. */
    readonly label?: string;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_checkbox_group.

成员

名称类型说明
items() => readonly string[]

All selectable item keys.

value?() => readonly string[]

Controlled checked keys; omit for internal state.

default_value?readonly string[]

Initial checked keys when uncontrolled.

on_change?(next: readonly string[]) => void

Called when checked keys change.

disabled?(key: string) => boolean

Per-item disabled predicate.

label?string

Accessible label for the group.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:603

Clipboard type

type Clipboard = ReturnType<typeof create_clipboard>;

Return value of create_clipboard.

成员

名称类型说明
copiedboolean
copy(override?: string) => Promise<boolean>
reset() => void

源码: packages/ui/src/behaviors/clipboard.svelte.ts:16

ClipboardOptions type

type ClipboardOptions = {
    /** Text to copy (reactive getter or static string). */
    text: string | (() => string);
    /** How long `copied` stays `true` in ms (default `1500`). */
    timeout_ms?: number;
    /** Optional callback after a copy attempt completes. */
    on_copy?: (ok: boolean, value: string) => void;
};

Options for create_clipboard.

成员

名称类型说明
textstring | (() => string)

Text to copy (reactive getter or static string).

timeout_ms?number

How long copied stays true in ms (default 1500).

on_copy?(ok: boolean, value: string) => void

Optional callback after a copy attempt completes.

源码: packages/ui/src/behaviors/clipboard.svelte.ts:6

ColorPickerBehavior type

type ColorPickerBehavior = ReturnType<typeof create_color_picker>;

Return value of create_color_picker.

成员

名称类型说明
valuestring
rgbaRgbaColor
hsvHsvaColor
plane{ readonly value: import("./canvas.svelte.js").AreaValue; readonly percent_x: number; readonly percent_y: number; readonly dragging: boolean; set: (next: import("./canvas.svelte.js").AreaValue, commitNow?: boolean) => void; surface: Attachment<HTMLElement>; thumb_attrs(): { role: "slider"; tabindex: number; 'aria-label': string | undefined; 'aria-valuetext': string; 'data-dragging': string | unde…
hue{ readonly value: number; readonly values: readonly number[]; readonly percent: number; readonly percents: number[]; readonly dragging: boolean; readonly active_thumb: number; set(next: number, index?: number): void; track: Attachment<HTMLElement>; thumb_attrs(index?: number): { role: "slider"; 'aria-orientation': "horizontal" | "vertical"; 'aria-label': string | undefined; 'aria-valuemin': numbe…
alpha{ readonly value: number; readonly values: readonly number[]; readonly percent: number; readonly percents: number[]; readonly dragging: boolean; readonly active_thumb: number; set(next: number, index?: number): void; track: Attachment<HTMLElement>; thumb_attrs(index?: number): { role: "slider"; 'aria-orientation': "horizontal" | "vertical"; 'aria-label': string | undefined; 'aria-valuemin': numbe…
set_text(text: string) => boolean
set_rgba(next: RgbaColor) => void

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:987

ColorPickerOptions type

type ColorPickerOptions = {
    readonly value?: () => string;
    readonly default_value?: string;
    readonly on_change?: (hex: string, rgba: RgbaColor) => void;
    readonly format?: 'hex' | 'rgb' | 'hsl';
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_color_picker.

成员

名称类型说明
value?() => string
default_value?string
on_change?(hex: string, rgba: RgbaColor) => void
format?'hex' | 'rgb' | 'hsl'
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:977

ColorSchemeOptions type

type ColorSchemeOptions = {
    readonly storage_key?: string;
    readonly default_value?: ColorSchemePreference;
    readonly apply_class?: boolean;
};

Options for create_color_scheme.

成员

名称类型说明
storage_key?string
default_value?ColorSchemePreference
apply_class?boolean

源码: packages/ui/src/behaviors/platform.svelte.ts:165

ColorSchemePreference type

type ColorSchemePreference = 'light' | 'dark' | 'system';

User color-scheme preference.

源码: packages/ui/src/behaviors/platform.svelte.ts:153

ConnectBehavior type

type ConnectBehavior = ReturnType<typeof create_connect>;

Return value of create_connect.

成员

名称类型说明
draftConnectDraft | null
pending_fromstring | null
port(id: string) => Attachment<HTMLElement>
port_attrs(id: string) => { tabindex: number; 'data-connecting': string | undefined; 'data-connect-target': string | undefined; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/canvas.svelte.ts:635

ConnectDraft type

type ConnectDraft = {
    readonly from: string;
    readonly x: number;
    readonly y: number;
    readonly over: string | null;
};

Active wire being dragged from a source port to pointer coordinates.

成员

名称类型说明
fromstring
xnumber
ynumber
overstring | null

源码: packages/ui/src/behaviors/canvas.svelte.ts:621

ConnectOptions type

type ConnectOptions = {
    readonly can_connect?: (from: string, to: string) => boolean;
    readonly on_connect: (from: string, to: string) => void;
};

Options for create_connect.

成员

名称类型说明
can_connect?(from: string, to: string) => boolean
on_connect(from: string, to: string) => void

源码: packages/ui/src/behaviors/canvas.svelte.ts:629

ControlAction type

type ControlAction = (...args: readonly unknown[]) => void;

Semantic action callback registered on a live UI control.

源码: packages/ui/src/behaviors/controls.svelte.ts:10

ControlChange type

type ControlChange = {
    readonly id: string;
    readonly kind: string;
    readonly label?: string;
    readonly key: string;
    readonly previous: unknown;
    readonly value: unknown;
    readonly source: ChangeSource;
    readonly reason: string;
    readonly redacted?: boolean;
    readonly committed: boolean;
};

Emitted change record for observe_controls and create_ui_history.

成员

名称类型说明
idstring
kindstring
label?string
keystring
previousunknown
valueunknown
sourceChangeSource
reasonstring
redacted?boolean
committedboolean

源码: packages/ui/src/behaviors/controls.svelte.ts:74

ControlChoice type

type ControlChoice = {
    readonly value: string;
    readonly label: string;
};

Choice exposed by a selectable control (tabs, combobox, menu, radio group, tree).

成员

名称类型说明
valuestring
labelstring

源码: packages/ui/src/behaviors/controls.svelte.ts:13

ControlDescriptor type

type ControlDescriptor = {
    /** Stable semantic identifier, e.g. `'tabs:settings'` or `'combobox:status'`. */
    readonly id: string;
    /** Component kind, e.g. `'tabs'`, `'combobox'`, `'dialog'`, `'input'`, `'checkbox'`, `'menu'`. */
    readonly kind: string;
    /** Optional human-readable label (falls back to accessible name of `element`). */
    readonly label?: string;
    /** Optional root/interactive DOM element for scope filtering and `data-agent-*` marks. */
    readonly element?: () => HTMLElement | null | undefined;
    /** Live snapshot of state (active tab, open state, value, selected count, etc.). */
    readonly state: () => Record<string, unknown>;
    /** Optional choices accepted by selection actions. */
    readonly items?: () => readonly ControlChoice[];
    /** Named semantic actions callable by the host/agent bridge. */
    readonly actions?: Readonly<Record<string, ControlAction>>;
    /** Whether the control is currently disabled or read-only (hides callable actions). */
    readonly disabled?: () => boolean;
    /** Explicit confirmation prompt describing why a person must approve agent actions. */
    readonly confirm?: string | (() => string | undefined);
    /** Marks values as secret (writable by agent, always redacted in snapshots/observations). */
    readonly secret?: boolean | (() => boolean);
    /** Hides this control from agent snapshots and invocation. */
    readonly hidden?: boolean | (() => boolean);
};

Registration descriptor for a live interactive UI control.

成员

名称类型说明
idstring

Stable semantic identifier, e.g. 'tabs:settings' or 'combobox:status'.

kindstring

Component kind, e.g. 'tabs', 'combobox', 'dialog', 'input', 'checkbox', 'menu'.

label?string

Optional human-readable label (falls back to accessible name of element).

element?() => HTMLElement | null | undefined

Optional root/interactive DOM element for scope filtering and data-agent-* marks.

state() => Record<string, unknown>

Live snapshot of state (active tab, open state, value, selected count, etc.).

items?() => readonly ControlChoice[]

Optional choices accepted by selection actions.

actions?Readonly<Record<string, ControlAction>>

Named semantic actions callable by the host/agent bridge.

disabled?() => boolean

Whether the control is currently disabled or read-only (hides callable actions).

confirm?string | (() => string | undefined)

Explicit confirmation prompt describing why a person must approve agent actions.

secret?boolean | (() => boolean)

Marks values as secret (writable by agent, always redacted in snapshots/observations).

hidden?boolean | (() => boolean)

Hides this control from agent snapshots and invocation.

源码: packages/ui/src/behaviors/controls.svelte.ts:16

ControlInvokeResult type

type ControlInvokeResult = {
    readonly ok: boolean;
    readonly id?: string;
    readonly label?: string;
    readonly confirm?: string;
    readonly error?: string;
};

Structured result returned by invoke_control.

成员

名称类型说明
okboolean
id?string
label?string
confirm?string
error?string

源码: packages/ui/src/behaviors/controls.svelte.ts:65

ControlSnapshot type

type ControlSnapshot = {
    readonly id: string;
    readonly kind: string;
    readonly label?: string;
    readonly state: Record<string, unknown>;
    readonly actions: readonly string[];
    readonly items?: readonly ControlChoice[];
    readonly confirm?: string;
    readonly secret?: boolean;
    readonly disabled?: boolean;
};

Read-only snapshot of a registered UI control's current state, safety marks and actions.

成员

名称类型说明
idstring
kindstring
label?string
stateRecord<string, unknown>
actionsreadonly string[]
items?readonly ControlChoice[]
confirm?string
secret?boolean
disabled?boolean

源码: packages/ui/src/behaviors/controls.svelte.ts:42

CookieStorageOptions type

type CookieStorageOptions = {
    readonly path?: string;
    readonly max_age?: number;
    readonly same_site?: 'Lax' | 'Strict' | 'None';
    readonly secure?: boolean;
};

Options for create_cookie_storage.

成员

名称类型说明
path?string
max_age?number
same_site?'Lax' | 'Strict' | 'None'
secure?boolean

源码: packages/ui/src/behaviors/platform.svelte.ts:398

CropRect type

type CropRect = {
    readonly x: number;
    readonly y: number;
    readonly width: number;
    readonly height: number;
};

Normalized (0..1) crop rectangle over an image.

成员

名称类型说明
xnumber
ynumber
widthnumber
heightnumber

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1086

DRAG_THRESHOLD const

const DRAG_THRESHOLD: 4

Default movement threshold in CSS px before a press becomes a drag.

源码: packages/ui/src/behaviors/drag.svelte.ts:7

DateFieldBehavior type

type DateFieldBehavior = ReturnType<typeof create_date_field>;

Return value of create_date_field.

成员

名称类型说明
segmentsreadonly DateTimeSegment[]
segment_ref(part: SegmentPart) => Attachment<HTMLElement>
segment_attrs(seg: DateTimeSegment) => { "aria-hidden": true; "data-segment": "literal"; role?: undefined; tabindex?: undefined; "aria-label"?: undefined; "aria-valuemin"?: undefined; "aria-valuemax"?: undefined; "aria-valuenow"?: undefined; "aria-valuetext"?: undefined; "aria-disabled"?: undefined; onkeydown?: undefined; onblur?: undefined; } | { role: "spinbutton"; tabindex: number | undefined; "data-segmen…

源码: packages/ui/src/behaviors/date-time.svelte.ts:56

DateFieldOptions type

type DateFieldOptions = {
    /** Controlled `DateValue` getter. */
    readonly value: () => DateValue | undefined;
    /** Called when the complete date/time value changes (or clears to `undefined`). */
    readonly on_change: (next: DateValue | undefined) => void;
    /** Editing precision: `'day'` (date only), `'hour'` (date + hour), or `'minute'` (date + hour + minute). */
    readonly granularity?: () => 'day' | 'hour' | 'minute';
    /** BCP-47 locale for segment order and separators (default `'en-US'`). */
    readonly locale?: () => string | undefined;
    /** Disabled state. */
    readonly disabled?: () => boolean;
    /** Minimum allowed date value. */
    readonly min?: () => DateValue | undefined;
    /** Maximum allowed date value. */
    readonly max?: () => DateValue | undefined;
};

Options for create_date_field.

成员

名称类型说明
value() => DateValue | undefined

Controlled DateValue getter.

on_change(next: DateValue | undefined) => void

Called when the complete date/time value changes (or clears to undefined).

granularity?() => 'day' | 'hour' | 'minute'

Editing precision: 'day' (date only), 'hour' (date + hour), or 'minute' (date + hour + minute).

locale?() => string | undefined

BCP-47 locale for segment order and separators (default 'en-US').

disabled?() => boolean

Disabled state.

min?() => DateValue | undefined

Minimum allowed date value.

max?() => DateValue | undefined

Maximum allowed date value.

源码: packages/ui/src/behaviors/date-time.svelte.ts:38

DateTimeSegment type

type DateTimeSegment = {
    /** Segment type (`'year'`, `'month'`, `'day'`, `'hour'`, `'minute'`, or `'literal'`). */
    readonly part: SegmentPart;
    /** Displayed text (zero-padded value, placeholder token or separator). */
    readonly value: string;
    /** Whether the segment is currently showing its placeholder rather than a set value. */
    readonly placeholder: boolean;
};

One rendered segment of a segmented date or time field.

成员

名称类型说明
partSegmentPart

Segment type ('year', 'month', 'day', 'hour', 'minute', or 'literal').

valuestring

Displayed text (zero-padded value, placeholder token or separator).

placeholderboolean

Whether the segment is currently showing its placeholder rather than a set value.

源码: packages/ui/src/behaviors/date-time.svelte.ts:28

Debounced class

class Debounced<T> {
    #private;
    constructor(getter: () => T, wait?: number | (() => number));
    /** The latest settled value. */
    get current(): T;
    /** Immediately sets the value and cancels any pending debounce timer. */
    updateImmediately: (value: T) => void;
    /** Cancels any pending scheduled update. */
    cancel: () => void;
}

Reactive debounced value mirroring getter() after wait ms of inactivity.

成员

名称类型说明
#privateany
currentT

The latest settled value.

updateImmediately(value: T) => void

Immediately sets the value and cancels any pending debounce timer.

cancel() => void

Cancels any pending scheduled update.

源码: packages/ui/src/behaviors/reactive.svelte.ts:112

Disclosure type

type Disclosure = ReturnType<typeof create_disclosure>;

Return value of create_disclosure.

成员

名称类型说明
openboolean
disabledboolean
state"open" | "closed"
set_open(next: boolean) => void
toggle() => void
show() => void
hide() => void
trigger_attrs() => { type: "button"; "aria-expanded": boolean; "aria-controls": string; "data-state": "open" | "closed"; disabled: true | undefined; onclick: () => void; }

Spread onto the trigger button (type, aria-expanded, aria-controls, data-state, disabled, onclick).

content_attrs() => { id: string; hidden: boolean; "data-state": "open" | "closed"; }

Spread onto the collapsible content element (id, hidden, data-state).

源码: packages/ui/src/behaviors/disclosure.svelte.ts:21

DisclosureOptions type

type DisclosureOptions = {
    /** Controlled open state; omit for internal state. */
    open?: () => boolean;
    /** Initial open state when uncontrolled (default `false`). */
    default_open?: boolean;
    /** Called whenever the disclosure opens or closes. */
    on_open_change?: (open: boolean) => void;
    /** Whether interaction is disabled. */
    disabled?: () => boolean;
    /** Stable id prefix for `aria-controls`; auto-generated when omitted. */
    id?: string;
};

Options for create_disclosure.

成员

名称类型说明
open?() => boolean

Controlled open state; omit for internal state.

default_open?boolean

Initial open state when uncontrolled (default false).

on_open_change?(open: boolean) => void

Called whenever the disclosure opens or closes.

disabled?() => boolean

Whether interaction is disabled.

id?string

Stable id prefix for aria-controls; auto-generated when omitted.

源码: packages/ui/src/behaviors/disclosure.svelte.ts:7

DismissLayer type

type DismissLayer = ReturnType<typeof create_dismiss>;

Return value of create_dismiss.

成员

名称类型说明
depthnumber
topmostboolean
surfaceAttachment<HTMLElement>

源码: packages/ui/src/behaviors/dismiss.svelte.ts:24

DismissOptions type

type DismissOptions = {
    /** Whether this layer is currently active/open. */
    open: () => boolean;
    /** Called when the topmost layer should close. */
    on_dismiss: (reason: DismissReason, event: KeyboardEvent | PointerEvent) => void;
    /** Close on Escape key (default `true`). */
    escape?: boolean | (() => boolean);
    /** Close on pointerdown outside the attached surface (default `true`). */
    outside?: boolean | (() => boolean);
    /** Extra elements treated as inside (e.g. an anchor trigger button). */
    ignore?: () => readonly (Element | null | undefined)[];
};

Options for create_dismiss.

成员

名称类型说明
open() => boolean

Whether this layer is currently active/open.

on_dismiss(reason: DismissReason, event: KeyboardEvent | PointerEvent) => void

Called when the topmost layer should close.

escape?boolean | (() => boolean)

Close on Escape key (default true).

outside?boolean | (() => boolean)

Close on pointerdown outside the attached surface (default true).

ignore?() => readonly (Element | null | undefined)[]

Extra elements treated as inside (e.g. an anchor trigger button).

源码: packages/ui/src/behaviors/dismiss.svelte.ts:10

DismissReason type

type DismissReason = 'escape' | 'outside';

Why a dismissible layer was closed ('escape' or 'outside').

源码: packages/ui/src/behaviors/dismiss.svelte.ts:7

DragPreviewOptions type

type DragPreviewOptions = {
    /** Reactive active drag coordinates (`null` when not dragging). */
    readonly point: () => {
        readonly x: number;
        readonly y: number;
    } | null;
    /** Offset in px relative to pointer (default `{ x: 12, y: 12 }`). */
    readonly offset?: {
        readonly x: number;
        readonly y: number;
    };
};

Options for bind_drag_preview.

成员

名称类型说明
point() => { readonly x: number; readonly y: number; } | null

Reactive active drag coordinates (null when not dragging).

offset?{ readonly x: number; readonly y: number; }

Offset in px relative to pointer (default { x: 12, y: 12 }).

源码: packages/ui/src/behaviors/platform.svelte.ts:294

DrawerBehavior type

type DrawerBehavior = ReturnType<typeof create_drawer>;

Return value of create_drawer.

成员

名称类型说明
openboolean
draggingboolean
offsetnumber
snap_indexnumber
snap_fractionnumber
set_open(next: boolean) => void
set_snap(idx: number) => void
surfaceAttachment<HTMLElement>
handleAttachment<HTMLElement>
surface_attrs() => { role: "dialog"; "aria-modal": true | undefined; "aria-label": string | undefined; "data-side": DrawerSide; "data-dragging": string | undefined; "data-state": "open" | "closed"; style: string | undefined; }

源码: packages/ui/src/behaviors/motion.svelte.ts:122

DrawerOptions type

type DrawerOptions = {
    /** Controlled open state; omit for internal state. */
    readonly open?: () => boolean;
    /** Called when open state changes. */
    readonly on_open_change?: (open: boolean) => void;
    /** Edge the drawer slides from (default `'bottom'`). */
    readonly side?: DrawerSide;
    /** Fractional snap points in `(0, 1]` (default `[1]`, e.g. `[0.4, 0.9]`). */
    readonly snap_points?: readonly number[];
    /** Active snap point index (0-based). */
    readonly active_snap?: () => number;
    /** Called when the active snap point changes. */
    readonly on_snap_change?: (index: number) => void;
    /** Whether dragging past the dismissal threshold closes the drawer (default `true`). */
    readonly dismissible?: boolean;
    /** Trap focus and mark background inert while open (default `true`). */
    readonly modal?: boolean;
    /** Accessible label for the drawer surface. */
    readonly label?: string;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_drawer.

成员

名称类型说明
open?() => boolean

Controlled open state; omit for internal state.

on_open_change?(open: boolean) => void

Called when open state changes.

side?DrawerSide

Edge the drawer slides from (default 'bottom').

snap_points?readonly number[]

Fractional snap points in (0, 1] (default [1], e.g. [0.4, 0.9]).

active_snap?() => number

Active snap point index (0-based).

on_snap_change?(index: number) => void

Called when the active snap point changes.

dismissible?boolean

Whether dragging past the dismissal threshold closes the drawer (default true).

modal?boolean

Trap focus and mark background inert while open (default true).

label?string

Accessible label for the drawer surface.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/motion.svelte.ts:98

DrawerSide type

type DrawerSide = 'bottom' | 'top' | 'left' | 'right';

Side from which a swipeable drawer slides in.

源码: packages/ui/src/behaviors/motion.svelte.ts:95

EnterKeyHint type

type EnterKeyHint = 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';

Label shown on mobile virtual keyboard Return keys (enterkeyhint).

源码: packages/ui/src/behaviors/micro.svelte.ts:432

FieldBehavior type

type FieldBehavior = ReturnType<typeof create_field>;

Return value of create_field.

成员

名称类型说明
idstring
invalidboolean
errorstring | undefined
label_attrs() => { for: string; "data-required": string | undefined; "data-invalid": string | undefined; "data-disabled": string | undefined; }
control_attrs() => { id: string; "aria-describedby": string | undefined; "aria-invalid": true | undefined; "aria-required": true | undefined; disabled: true | undefined; readonly: true | undefined; }
description_attrs() => { id: string; }
error_attrs() => { id: string; role: "alert"; }

源码: packages/ui/src/behaviors/field.svelte.ts:23

FieldBehaviorOptions type

type FieldBehaviorOptions = {
    /** Optional stable id prefix; auto-generated when omitted. */
    id?: string;
    /** Whether a helper description element is rendered. */
    has_description?: () => boolean;
    /** Current validation error message (non-empty marks the control invalid). */
    error?: () => string | undefined | null;
    /** Whether the field is required. */
    required?: () => boolean;
    /** Whether the field is disabled. */
    disabled?: () => boolean;
    /** Whether the field is read-only. */
    readonly?: () => boolean;
};

Options for create_field.

成员

名称类型说明
id?string

Optional stable id prefix; auto-generated when omitted.

has_description?() => boolean

Whether a helper description element is rendered.

error?() => string | undefined | null

Current validation error message (non-empty marks the control invalid).

required?() => boolean

Whether the field is required.

disabled?() => boolean

Whether the field is disabled.

readonly?() => boolean

Whether the field is read-only.

源码: packages/ui/src/behaviors/field.svelte.ts:7

FileDropzone type

type FileDropzone = ReturnType<typeof create_file_dropzone>;

Return value of create_file_dropzone.

成员

名称类型说明
draggingboolean
disabledboolean
open() => void
process(list: FileList | readonly File[]) => void
zoneAttachment<HTMLElement>
inputAttachment<HTMLInputElement>
input_attrs() => { type: "file"; accept: string | undefined; multiple: boolean | undefined; disabled: true | undefined; onchange: (event: Event) => void; }

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:740

FileDropzoneOptions type

type FileDropzoneOptions = {
    /** Accepted MIME types or extensions (e.g. `['image/*', '.pdf']`). */
    readonly accept?: readonly string[];
    /** Maximum file size in bytes. */
    readonly max_bytes?: number;
    /** Maximum number of files accepted in one drop/selection (default unlimited). */
    readonly max_files?: number;
    /** Disabled state. */
    readonly disabled?: () => boolean;
    /** Called with validated accepted and rejected files. */
    readonly on_files: (result: {
        readonly accepted: readonly File[];
        readonly rejected: readonly RejectedFile[];
    }) => void;
};

Options for create_file_dropzone.

成员

名称类型说明
accept?readonly string[]

Accepted MIME types or extensions (e.g. ['image/*', '.pdf']).

max_bytes?number

Maximum file size in bytes.

max_files?number

Maximum number of files accepted in one drop/selection (default unlimited).

disabled?() => boolean

Disabled state.

on_files(result: { readonly accepted: readonly File[]; readonly rejected: readonly RejectedFile[]; }) => void

Called with validated accepted and rejected files.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:726

FindableOptions type

type FindableOptions = {
    /** Whether the panel is currently open/visible. */
    readonly open: () => boolean;
    /** Whether closed content remains findable via browser Ctrl/Cmd+F (default `true`). */
    readonly findable?: () => boolean;
    /** Called when browser find-in-page matches text inside the closed panel (`beforematch`). */
    readonly on_reveal: (event: Event) => void;
};

Options for bind_findable.

成员

名称类型说明
open() => boolean

Whether the panel is currently open/visible.

findable?() => boolean

Whether closed content remains findable via browser Ctrl/Cmd+F (default true).

on_reveal(event: Event) => void

Called when browser find-in-page matches text inside the closed panel (beforematch).

源码: packages/ui/src/behaviors/presence.svelte.ts:217

FlatTreeRow type

type FlatTreeRow<T = unknown> = {
    readonly id: string;
    readonly label: string;
    readonly depth: number;
    readonly parent: string | null;
    readonly expandable: boolean;
    readonly expanded: boolean;
    readonly disabled: boolean;
    readonly node: TreeNode<T>;
};

Flattened visible row produced by create_tree with depth and expansion state.

成员

名称类型说明
idstring
labelstring
depthnumber
parentstring | null
expandableboolean
expandedboolean
disabledboolean
nodeTreeNode<T>

源码: packages/ui/src/behaviors/tree.svelte.ts:19

Floating type

type Floating = ReturnType<typeof create_floating>;

Return value of create_floating.

成员

名称类型说明
xnumber
ynumber
sideFloatingSide
anchor_widthnumber
available_widthnumber
available_heightnumber
positionedboolean
stylestring
set_anchor(next: FloatingAnchor | null) => void

Sets a programmatic element or virtual { x, y } / DOMRect anchor.

update() => void
anchorAttachment<HTMLElement>
contentAttachment<HTMLElement>

源码: packages/ui/src/behaviors/floating.svelte.ts:57

FloatingAlign type

type FloatingAlign = 'start' | 'center' | 'end';

Cross-axis alignment relative to the anchor edge.

源码: packages/ui/src/behaviors/floating.svelte.ts:10

FloatingAnchor type

type FloatingAnchor = HTMLElement | VirtualAnchor;

Either a live DOM element or a virtual point/rectangle anchor.

源码: packages/ui/src/behaviors/floating.svelte.ts:28

FloatingOptions type

type FloatingOptions = {
    /** Whether the floating surface is open. */
    readonly open: () => boolean;
    /** Called when Escape or an outside pointer press dismisses the surface. */
    readonly on_dismiss?: (reason: DismissReason) => void;
    /** Optional reactive anchor element or virtual anchor getter. */
    readonly anchor?: () => FloatingAnchor | null;
    /** Preferred side relative to the anchor (default `'bottom'`). */
    readonly side?: FloatingSide | (() => FloatingSide);
    /** Cross-axis alignment relative to the anchor (default `'center'`). */
    readonly align?: FloatingAlign | (() => FloatingAlign);
    /** Gap between anchor and floating surface in px (default `4`). */
    readonly side_offset?: number | (() => number);
    /** Shift along the cross axis in px (default `0`). */
    readonly align_offset?: number | (() => number);
    /** Viewport edge padding in px (default `8`). */
    readonly padding?: number | (() => number);
    /** Flip to the opposite side when viewport room is insufficient (default `true`). */
    readonly flip?: boolean | (() => boolean);
    /** Close on Escape key (default `true`). */
    readonly escape?: boolean | (() => boolean);
    /** Close on outside pointer press (default `true`). */
    readonly outside?: boolean | (() => boolean);
};

Options for create_floating.

成员

名称类型说明
open() => boolean

Whether the floating surface is open.

on_dismiss?(reason: DismissReason) => void

Called when Escape or an outside pointer press dismisses the surface.

anchor?() => FloatingAnchor | null

Optional reactive anchor element or virtual anchor getter.

side?FloatingSide | (() => FloatingSide)

Preferred side relative to the anchor (default 'bottom').

align?FloatingAlign | (() => FloatingAlign)

Cross-axis alignment relative to the anchor (default 'center').

side_offset?number | (() => number)

Gap between anchor and floating surface in px (default 4).

align_offset?number | (() => number)

Shift along the cross axis in px (default 0).

padding?number | (() => number)

Viewport edge padding in px (default 8).

flip?boolean | (() => boolean)

Flip to the opposite side when viewport room is insufficient (default true).

escape?boolean | (() => boolean)

Close on Escape key (default true).

outside?boolean | (() => boolean)

Close on outside pointer press (default true).

源码: packages/ui/src/behaviors/floating.svelte.ts:31

FloatingSide type

type FloatingSide = 'top' | 'bottom' | 'left' | 'right';

Preferred side of the anchor where the floating surface opens.

源码: packages/ui/src/behaviors/floating.svelte.ts:8

FocusRecovery type

type FocusRecovery<T = unknown> = ReturnType<typeof create_focus_recovery<T>>;

Return value of create_focus_recovery.

成员

名称类型说明
item(key: string, data?: T) => Attachment<HTMLElement>

源码: packages/ui/src/behaviors/focus-recovery.svelte.ts:23

FocusRecoveryOptions type

type FocusRecoveryOptions<T = unknown> = {
    /** Returns the next element to focus when a bound item unmounts with focus, or null/undefined. */
    readonly fallback: (lost: LostFocus<T>) => HTMLElement | null | undefined;
};

Options for create_focus_recovery.

成员

名称类型说明
fallback(lost: LostFocus<T>) => HTMLElement | null | undefined

Returns the next element to focus when a bound item unmounts with focus, or null/undefined.

源码: packages/ui/src/behaviors/focus-recovery.svelte.ts:17

FocusTrap type

type FocusTrap = ReturnType<typeof create_focus_trap>;

Return value of create_focus_trap.

成员

名称类型说明
containerAttachment<HTMLElement>

源码: packages/ui/src/behaviors/focus-trap.svelte.ts:48

FocusTrapOptions type

type FocusTrapOptions = {
    /** Whether focus trapping is active. */
    readonly active: () => boolean;
    /** Automatically move focus into the container when activated (default `true`). */
    readonly auto_focus?: boolean | (() => boolean);
    /** Restore focus to the previously active element on close (default `true`). */
    readonly restore_focus?: boolean | (() => boolean);
    /** Keep Tab / focusin strictly contained inside the container (default `true`). */
    readonly trap?: boolean | (() => boolean);
    /** Mark background siblings `inert` while active (default `false`; set `true` on modal dialogs). */
    readonly modal?: boolean | (() => boolean);
    /** Apply ref-counted document scroll lock while active (default `false`). */
    readonly prevent_scroll?: boolean | (() => boolean);
    /** Optional predicate gating focus-trap listeners to only the topmost stacked layer. */
    readonly topmost?: () => boolean;
    /** Cancelable hook invoked before initial autofocus runs. */
    readonly on_open_auto_focus?: (event: Event) => void;
    /** Cancelable hook invoked before focus returns to the previous element on close. */
    readonly on_close_auto_focus?: (event: Event) => void;
    /** Called when focus escapes outside the container while active. */
    readonly on_focus_outside?: (event: FocusEvent) => void;
};

Options for create_focus_trap.

成员

名称类型说明
active() => boolean

Whether focus trapping is active.

auto_focus?boolean | (() => boolean)

Automatically move focus into the container when activated (default true).

restore_focus?boolean | (() => boolean)

Restore focus to the previously active element on close (default true).

trap?boolean | (() => boolean)

Keep Tab / focusin strictly contained inside the container (default true).

modal?boolean | (() => boolean)

Mark background siblings inert while active (default false; set true on modal dialogs).

prevent_scroll?boolean | (() => boolean)

Apply ref-counted document scroll lock while active (default false).

topmost?() => boolean

Optional predicate gating focus-trap listeners to only the topmost stacked layer.

on_open_auto_focus?(event: Event) => void

Cancelable hook invoked before initial autofocus runs.

on_close_auto_focus?(event: Event) => void

Cancelable hook invoked before focus returns to the previous element on close.

on_focus_outside?(event: FocusEvent) => void

Called when focus escapes outside the container while active.

源码: packages/ui/src/behaviors/focus-trap.svelte.ts:24

GridCell type

type GridCell = {
    readonly row: number;
    readonly col: number;
};

Zero-based (row, col) coordinate in a 2D grid.

成员

名称类型说明
rownumber
colnumber

源码: packages/ui/src/behaviors/grid.svelte.ts:9

GridFocus type

type GridFocus = ReturnType<typeof create_grid_focus>;

Return value of create_grid_focus.

成员

名称类型说明
activeGridCell | null
focus(cell: GridCell, shift?: boolean) => void
cell(cell: GridCell) => Attachment<HTMLElement>
grid_attrs() => { role: "grid"; "aria-rowcount": number; "aria-colcount": number; onkeydown: (event: KeyboardEvent) => void; }
cell_attrs(cell: GridCell) => { role: "gridcell"; "aria-rowindex": number; "aria-colindex": number; "aria-disabled": true | undefined; "data-active": string | undefined; tabindex: number | undefined; onfocus: () => void; }

源码: packages/ui/src/behaviors/grid.svelte.ts:41

GridFocusOptions type

type GridFocusOptions = {
    /** Total row count. */
    readonly rows: () => number;
    /** Total column count. */
    readonly cols: () => number;
    /** Controlled active cell; omit for internal state. */
    readonly active?: () => GridCell | null;
    /** Called whenever the active cell moves. */
    readonly on_move?: (cell: GridCell, details: {
        readonly from: GridCell | null;
        readonly shift: boolean;
    }) => void;
    /** Rows skipped by PageUp / PageDown (default `10`). */
    readonly page_size?: number | (() => number);
    /** Skip cells matching this predicate. */
    readonly disabled?: (cell: GridCell) => boolean;
    /** Scroll an unrendered virtualized cell into view before focusing. */
    readonly reveal?: (cell: GridCell) => void;
};

Options for create_grid_focus.

成员

名称类型说明
rows() => number

Total row count.

cols() => number

Total column count.

active?() => GridCell | null

Controlled active cell; omit for internal state.

on_move?(cell: GridCell, details: { readonly from: GridCell | null; readonly shift: boolean; }) => void

Called whenever the active cell moves.

page_size?number | (() => number)

Rows skipped by PageUp / PageDown (default 10).

disabled?(cell: GridCell) => boolean

Skip cells matching this predicate.

reveal?(cell: GridCell) => void

Scroll an unrendered virtualized cell into view before focusing.

源码: packages/ui/src/behaviors/grid.svelte.ts:23

HoldInput type

type HoldInput = 'mouse' | 'touch' | 'pen' | 'keyboard';

Input modality that started a hold gesture.

源码: packages/ui/src/behaviors/micro.svelte.ts:196

HoverCardBehavior type

type HoverCardBehavior = ReturnType<typeof create_hover_card>;

Return value of create_hover_card.

成员

名称类型说明
openboolean
presentboolean
floating{ readonly x: number; readonly y: number; readonly side: FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: import("./floating.svelte.js").FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Attachment<HTMLElement>; }
set_open(next: boolean) => void
triggerAttachment<HTMLElement>
contentAttachment<HTMLElement>
trigger_attrs() => { "aria-expanded": boolean; onpointerenter: (e: PointerEvent) => void; onpointerleave: (e: PointerEvent) => void; onfocus: () => void; onblur: () => void; }
content_attrs() => { "data-state": "open" | "closed"; style: string; onpointerenter: (e: PointerEvent) => void; onpointerleave: (e: PointerEvent) => void; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:686

HoverCardOptions type

type HoverCardOptions = {
    readonly open?: () => boolean;
    readonly on_open_change?: (open: boolean) => void;
    readonly open_delay?: number;
    readonly close_delay?: number;
    readonly side?: FloatingSide;
    readonly align?: FloatingAlign;
    readonly group?: string;
};

Options for create_hover_card.

成员

名称类型说明
open?() => boolean
on_open_change?(open: boolean) => void
open_delay?number
close_delay?number
side?FloatingSide
align?FloatingAlign
group?string

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:675

HoverIntent type

type HoverIntent = ReturnType<typeof create_hover_intent>;

Return value of create_hover_intent.

成员

名称类型说明
enter(event?: PointerEvent, isTrigger?: boolean) => void
leave(event?: PointerEvent) => void
clear() => void
open_now() => void
close_now() => void

源码: packages/ui/src/behaviors/hover-intent.svelte.ts:116

HoverIntentOptions type

type HoverIntentOptions = {
    /** Trigger element getter. */
    readonly trigger: () => HTMLElement | null | undefined;
    /** Popup element getter. */
    readonly popup: () => HTMLElement | null | undefined;
    /** Whether the popup is currently open. */
    readonly open: () => boolean;
    /** Opens the popup. */
    readonly on_open: () => void;
    /** Closes the popup. */
    readonly on_close: () => void;
    /** Open delay in ms when cold (default `120`). */
    readonly open_delay?: number | (() => number);
    /** Close delay in ms after leaving the safe corridor (default `80`). */
    readonly close_delay?: number | (() => number);
    /** Shared warm-group key (default `'tooltip'`; pass `null` to opt out). */
    readonly group?: string | null;
    /** Warm window in ms during which sibling hovers open immediately (default `250`). */
    readonly warm_ms?: number;
    /** Allow pointer to travel into popup content without closing (default `true`). */
    readonly hoverable?: boolean | (() => boolean);
};

Options for create_hover_intent.

成员

名称类型说明
trigger() => HTMLElement | null | undefined

Trigger element getter.

popup() => HTMLElement | null | undefined

Popup element getter.

open() => boolean

Whether the popup is currently open.

on_open() => void

Opens the popup.

on_close() => void

Closes the popup.

open_delay?number | (() => number)

Open delay in ms when cold (default 120).

close_delay?number | (() => number)

Close delay in ms after leaving the safe corridor (default 80).

group?string | null

Shared warm-group key (default 'tooltip'; pass null to opt out).

warm_ms?number

Warm window in ms during which sibling hovers open immediately (default 250).

hoverable?boolean | (() => boolean)

Allow pointer to travel into popup content without closing (default true).

源码: packages/ui/src/behaviors/hover-intent.svelte.ts:92

HslaColor type

type HslaColor = {
    readonly h: number;
    readonly s: number;
    readonly l: number;
    readonly a: number;
};

HSLA color representation (h in 0..360, s,l in 0..100, a in 0..1).

成员

名称类型说明
hnumber
snumber
lnumber
anumber

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:789

HsvaColor type

type HsvaColor = {
    readonly h: number;
    readonly s: number;
    readonly v: number;
    readonly a: number;
};

HSVA color representation (h in 0..360, s,v in 0..100, a in 0..1).

成员

名称类型说明
hnumber
snumber
vnumber
anumber

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:797

ImageCropperBehavior type

type ImageCropperBehavior = ReturnType<typeof create_image_cropper>;

Return value of create_image_cropper.

成员

名称类型说明
cropCropRect
zoomnumber
rotationnumber
mover{ readonly dragging: boolean; handle: Attachment<HTMLElement>; handle_attrs(): { tabindex: number; 'aria-label': string | undefined; 'data-dragging': string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }
resizer{ readonly dragging: boolean; handle_attrs: (mode: "x" | "y" | "xy", label?: string) => { role: "separator"; tabindex: number; 'aria-label': string | undefined; 'data-dragging': string | undefined; onpointerdown: (down: PointerEvent) => void; onkeydown: (event: KeyboardEvent) => void; }; }
set_crop(next: CropRect) => void
set_zoom(next: number) => void
rotate(deg?: number) => void
pixel_crop(naturalWidth: number, naturalHeight: number) => { x: number; y: number; width: number; height: number; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1104

ImageCropperOptions type

type ImageCropperOptions = {
    readonly default_crop?: CropRect;
    readonly aspect?: () => number | undefined;
    readonly min_size?: number;
    readonly on_change?: (crop: CropRect, meta: {
        readonly zoom: number;
        readonly rotation: number;
    }) => void;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_image_cropper.

成员

名称类型说明
default_crop?CropRect
aspect?() => number | undefined
min_size?number
on_change?(crop: CropRect, meta: { readonly zoom: number; readonly rotation: number; }) => void
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1094

InertHandle type

type InertHandle = (() => void) & {
    /** Exempts an additional element (e.g. a popover portaled into `document.body`) while active. */
    readonly keep: (el: HTMLElement) => () => void;
};

Handle returned by inert_outside allowing portaled child popups to stay interactive.

成员

名称类型说明
keep(el: HTMLElement) => () => void

Exempts an additional element (e.g. a popover portaled into document.body) while active.

源码: packages/ui/src/behaviors/modal.svelte.ts:95

InlineEdit type

type InlineEdit = ReturnType<typeof create_inline_edit>;

Return value of create_inline_edit.

成员

名称类型说明
editingstring | null
draftstring
is_editing(id: string) => boolean
begin(id: string, reason: InlineEditReason, initial?: string, origin?: HTMLElement | null) => void
commit(reason?: InlineEditReason) => boolean
cancel(reason?: InlineEditReason) => void
inputAttachment<HTMLInputElement | HTMLTextAreaElement>
cell_attrs(id: string) => { "data-editing": string | undefined; ondblclick: (event: MouseEvent) => void; onkeydown: (event: KeyboardEvent) => void; }
input_attrs() => { value: string; oninput: (event: Event) => void; onkeydown: (event: KeyboardEvent) => void; onblur: () => void; }

源码: packages/ui/src/behaviors/grid.svelte.ts:387

InlineEditOptions type

type InlineEditOptions = {
    /** Reads the current text for `id` when editing starts. */
    readonly value: (id: string) => string;
    /** Persists the edited text; return `false` to keep editing (e.g. validation error). */
    readonly commit: (id: string, text: string, reason: InlineEditReason) => boolean | void;
    /** Optional disabled predicate per id. */
    readonly disabled?: (id: string) => boolean;
    /** Called when Tab commits so an enclosing grid can advance to the next/previous cell. */
    readonly on_tab?: (id: string, direction: 1 | -1) => void;
};

Options for create_inline_edit.

成员

名称类型说明
value(id: string) => string

Reads the current text for id when editing starts.

commit(id: string, text: string, reason: InlineEditReason) => boolean | void

Persists the edited text; return false to keep editing (e.g. validation error).

disabled?(id: string) => boolean

Optional disabled predicate per id.

on_tab?(id: string, direction: 1 | -1) => void

Called when Tab commits so an enclosing grid can advance to the next/previous cell.

源码: packages/ui/src/behaviors/grid.svelte.ts:375

InlineEditReason type

type InlineEditReason = 'edit-key' | 'type' | 'double-click' | 'enter-key' | 'escape-key' | 'focus-out' | 'tab-key' | 'imperative';

Why an inline edit started or finished.

源码: packages/ui/src/behaviors/grid.svelte.ts:364

InputHintKind type

type InputHintKind = 'search' | 'email' | 'tel' | 'url' | 'one-time-code' | 'numeric' | 'decimal' | 'name' | 'username' | 'current-password' | 'new-password' | 'postal-code' | 'message';

Supported semantic input hint presets.

源码: packages/ui/src/behaviors/micro.svelte.ts:435

InputHints type

type InputHints = {
    readonly inputmode?: 'search' | 'email' | 'tel' | 'url' | 'numeric' | 'decimal';
    readonly enterkeyhint?: EnterKeyHint;
    readonly autocomplete?: string;
    readonly autocapitalize?: 'none' | 'sentences' | 'words' | 'characters';
    readonly autocorrect?: 'on' | 'off';
    readonly spellcheck?: boolean;
};

HTML input hint attributes returned by input_hints.

成员

名称类型说明
inputmode?'search' | 'email' | 'tel' | 'url' | 'numeric' | 'decimal'
enterkeyhint?EnterKeyHint
autocomplete?string
autocapitalize?'none' | 'sentences' | 'words' | 'characters'
autocorrect?'on' | 'off'
spellcheck?boolean

源码: packages/ui/src/behaviors/micro.svelte.ts:451

InputHistory type

type InputHistory<T = string> = ReturnType<typeof create_input_history<T>>;

Return value of create_input_history.

成员

名称类型说明
indexnumber | null
browsingboolean
onkeydown(event: KeyboardEvent) => void
reset() => void

源码: packages/ui/src/behaviors/micro.svelte.ts:22

InputHistoryOptions type

type InputHistoryOptions<T = string> = {
    /** Past entries, oldest first. */
    readonly entries: () => readonly T[];
    /** Reads the current composer value. */
    readonly read: () => T;
    /** Writes a recalled value into the composer; return `false` to cancel navigation. */
    readonly write: (value: T, event: KeyboardEvent) => boolean | void;
    /** Custom edge detector; defaults to first/last line of `<textarea>` or anywhere in `<input>`. */
    readonly at_edge?: (direction: 'up' | 'down', event: KeyboardEvent) => boolean;
};

Options for create_input_history.

成员

名称类型说明
entries() => readonly T[]

Past entries, oldest first.

read() => T

Reads the current composer value.

write(value: T, event: KeyboardEvent) => boolean | void

Writes a recalled value into the composer; return false to cancel navigation.

at_edge?(direction: 'up' | 'down', event: KeyboardEvent) => boolean

Custom edge detector; defaults to first/last line of <textarea> or anywhere in <input>.

源码: packages/ui/src/behaviors/micro.svelte.ts:10

InputModality type

type InputModality = 'keyboard' | 'pointer';

Input interaction modality ('keyboard' vs 'pointer').

源码: packages/ui/src/behaviors/platform.svelte.ts:239

LassoBehavior type

type LassoBehavior = ReturnType<typeof create_lasso>;

Return value of create_lasso.

成员

名称类型说明
rectLassoRect | null
activeboolean
surfaceAttachment<HTMLElement>
item(key: string) => Attachment<HTMLElement>

源码: packages/ui/src/behaviors/canvas.svelte.ts:435

LassoOptions type

type LassoOptions = {
    /** Called continuously as the marquee rectangle changes with intersecting item keys. */
    readonly on_change: (keys: readonly string[], rect: LassoRect) => void;
    /** Called when the marquee drag finishes. */
    readonly on_commit?: (keys: readonly string[]) => void;
};

Options for create_lasso.

成员

名称类型说明
on_change(keys: readonly string[], rect: LassoRect) => void

Called continuously as the marquee rectangle changes with intersecting item keys.

on_commit?(keys: readonly string[]) => void

Called when the marquee drag finishes.

源码: packages/ui/src/behaviors/canvas.svelte.ts:427

LassoRect type

type LassoRect = {
    readonly x: number;
    readonly y: number;
    readonly width: number;
    readonly height: number;
};

Marquee rectangle in container-relative coordinates.

成员

名称类型说明
xnumber
ynumber
widthnumber
heightnumber

源码: packages/ui/src/behaviors/canvas.svelte.ts:424

Listbox type

type Listbox<T extends ListboxItem = ListboxItem> = ReturnType<typeof create_listbox<T>>;

Return value of create_listbox.

成员

名称类型说明
idstring
querystring
itemsreadonly T[]
activestring
active_idstring | undefined
selectedreadonly string[]
countnumber
is_selected(key: string) => boolean
choose(key: string) => void
toggle(key: string) => void
toggle_all() => void
clear() => void
focus(key: string) => void
highlight(key: string) => void
activate_active() => void
item(key: string) => import("svelte/attachments").Attachment<HTMLElement>
input_attrs(open?: boolean) => { role: "combobox"; "aria-autocomplete": "list"; "aria-expanded": boolean; "aria-controls": string; "aria-activedescendant": string | undefined; onkeydown: (event: KeyboardEvent) => void; }

Spread onto a search/combobox <input> in 'virtual' focus mode (aria-activedescendant, aria-controls, keyboard nav).

list_attrs() => { id: string; role: "listbox"; "aria-multiselectable": true | undefined; onkeydown: (event: KeyboardEvent) => void; }

Spread onto the listbox container (id, role="listbox", aria-multiselectable, keyboard handler).

option_attrs(value: string) => { id: string; role: "option"; "aria-selected": boolean; "aria-disabled": true | undefined; "data-selected": string | undefined; "data-highlighted": string | undefined; tabindex: number | undefined; onfocus: (() => void) | undefined; onpointerdown: ((event: PointerEvent) => void) | undefined; onpointermove: () => void; onclick: (event: MouseEvent) => void; }

Spread onto each option element (id, role="option", aria-selected, data-highlighted, click/hover/focus).

源码: packages/ui/src/behaviors/listbox.svelte.ts:47

ListboxFocusMode type

type ListboxFocusMode = 'dom' | 'virtual';

Focus strategy: 'dom' moves real focus across options; 'virtual' keeps focus in a search input via aria-activedescendant.

源码: packages/ui/src/behaviors/listbox.svelte.ts:18

ListboxItem type

type ListboxItem = {
    readonly value: string;
    readonly label: string;
    readonly keywords?: string;
    readonly disabled?: boolean;
};

One selectable option inside create_listbox.

成员

名称类型说明
valuestring
labelstring
keywords?string
disabled?boolean

源码: packages/ui/src/behaviors/listbox.svelte.ts:10

ListboxOptions type

type ListboxOptions<T extends ListboxItem = ListboxItem> = {
    /** All items in visual order. */
    readonly items: () => readonly T[];
    /** Selection mode (default `'single'`). */
    readonly mode?: SelectionMode | (() => SelectionMode);
    /** Focus strategy: `'dom'` (default) or `'virtual'` (`aria-activedescendant`). */
    readonly focus?: ListboxFocusMode;
    /** Controlled selected values; omit for internal state. */
    readonly selected?: () => readonly string[];
    /** Initial selected values when uncontrolled. */
    readonly default_selected?: readonly string[];
    /** Called when selection changes. */
    readonly on_change?: (values: readonly string[]) => void;
    /** Called when an item is explicitly activated (Enter / click in single mode). */
    readonly on_activate?: (item: T) => void;
    /** Optional custom filter; defaults to case-insensitive substring match on label + keywords. Pass `false` for externally filtered/async lists. */
    readonly filter?: false | ((item: T, query: string) => boolean);
    /** Enable incremental typeahead when not typing in a search input (default `true` in `'dom'` mode, `false` in `'virtual'` mode). */
    readonly typeahead?: boolean;
    /** Wrap arrow navigation at list ends (default `true`). */
    readonly loop?: boolean;
    /** Optional stable id prefix for `aria-controls` / `aria-activedescendant`. */
    readonly id?: string;
};

Options for create_listbox.

成员

名称类型说明
items() => readonly T[]

All items in visual order.

mode?SelectionMode | (() => SelectionMode)

Selection mode (default 'single').

focus?ListboxFocusMode

Focus strategy: 'dom' (default) or 'virtual' (aria-activedescendant).

selected?() => readonly string[]

Controlled selected values; omit for internal state.

default_selected?readonly string[]

Initial selected values when uncontrolled.

on_change?(values: readonly string[]) => void

Called when selection changes.

on_activate?(item: T) => void

Called when an item is explicitly activated (Enter / click in single mode).

filter?false | ((item: T, query: string) => boolean)

Optional custom filter; defaults to case-insensitive substring match on label + keywords. Pass false for externally filtered/async lists.

typeahead?boolean

Enable incremental typeahead when not typing in a search input (default true in 'dom' mode, false in 'virtual' mode).

loop?boolean

Wrap arrow navigation at list ends (default true).

id?string

Optional stable id prefix for aria-controls / aria-activedescendant.

源码: packages/ui/src/behaviors/listbox.svelte.ts:21

LostFocus type

type LostFocus<T = unknown> = {
    /** Stable key of the removed item. */
    readonly key: string;
    /** Optional caller metadata attached to the item. */
    readonly data: T | undefined;
    /** The removed DOM element. */
    readonly element: HTMLElement;
};

Info about a bound element that left the DOM while holding focus.

成员

名称类型说明
keystring

Stable key of the removed item.

dataT | undefined

Optional caller metadata attached to the item.

elementHTMLElement

The removed DOM element.

源码: packages/ui/src/behaviors/focus-recovery.svelte.ts:7

MatchRange type

type MatchRange = {
    readonly start: number;
    readonly end: number;
};

Half-open character range [start, end) inside the original text string.

成员

名称类型说明
startnumber
endnumber

源码: packages/ui/src/behaviors/text-match.ts:5

MatchSegment type

type MatchSegment = {
    readonly text: string;
    readonly matched: boolean;
};

One contiguous highlighted or plain text segment produced by match_segments.

成员

名称类型说明
textstring
matchedboolean

源码: packages/ui/src/behaviors/text-match.ts:11

MatchShortcutOptions type

type MatchShortcutOptions = {
    /** When `true`, `'mod'` only matches `Meta` on Apple platforms and `Control` elsewhere (default `false`). */
    readonly strict_platform?: boolean;
};

Options for matches_shortcut.

成员

名称类型说明
strict_platform?boolean

When true, 'mod' only matches Meta on Apple platforms and Control elsewhere (default false).

源码: packages/ui/src/behaviors/shortcuts.svelte.ts:81

type Menu<T extends MenuItem = MenuItem> = ReturnType<typeof create_menu<T>>;

Return value of create_menu.

成员

名称类型说明
openboolean
activestring
floating{ readonly x: number; readonly y: number; readonly side: FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: import("./floating.svelte.js").FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Attachment<HTMLElement>; }
open_at(point: { x: number; y: number; }) => void
open_menu() => void
close() => void
toggle() => void
triggerAttachment<HTMLElement>
contentAttachment<HTMLElement>
context_areaAttachment<HTMLElement>
item(key: string) => Attachment<HTMLElement>
trigger_attrs() => { type: "button"; "aria-haspopup": "menu"; "aria-expanded": boolean; "aria-controls": string | undefined; "data-state": "open" | "closed"; onclick: () => void; onkeydown: (event: KeyboardEvent) => void; }
menu_attrs() => { id: string; role: "menu"; "aria-label": string | undefined; "data-state": "open" | "closed"; "data-side": FloatingSide; style: string; onkeydown: (event: KeyboardEvent) => void; }
item_attrs(id: string) => { role: "menuitem" | "menuitemcheckbox" | "menuitemradio"; "aria-disabled": true | undefined; "aria-checked": boolean | undefined; "data-highlighted": string | undefined; "data-disabled": string | undefined; tabindex: number | undefined; onfocus: () => void; onpointermove: () => void; onclick: (event: MouseEvent) => void; }

源码: packages/ui/src/behaviors/menu.svelte.ts:45

type MenuItem = {
    readonly id: string;
    readonly label: string;
    readonly disabled?: boolean;
    readonly role?: 'menuitem' | 'menuitemcheckbox' | 'menuitemradio';
    readonly checked?: boolean;
    readonly on_select?: () => void;
};

One menu item descriptor for create_menu.

成员

名称类型说明
idstring
labelstring
disabled?boolean
role?'menuitem' | 'menuitemcheckbox' | 'menuitemradio'
checked?boolean
on_select?() => void

源码: packages/ui/src/behaviors/menu.svelte.ts:13

type MenuOptions<T extends MenuItem = MenuItem> = {
    /** Ordered menu items. */
    readonly items: () => readonly T[];
    /** Controlled open state; omit for internal state. */
    readonly open?: () => boolean;
    /** Called when open state changes. */
    readonly on_open_change?: (open: boolean) => void;
    /** Called when any enabled menu item is activated. */
    readonly on_select?: (item: T) => void;
    /** Close the menu after selecting a regular `menuitem` (default `true`). */
    readonly close_on_select?: boolean;
    /** Preferred side relative to trigger (default `'bottom'`). */
    readonly side?: FloatingSide;
    /** Cross-axis alignment relative to trigger (default `'start'`). */
    readonly align?: FloatingAlign;
    /** Accessible name for the menu. */
    readonly label?: string;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_menu.

成员

名称类型说明
items() => readonly T[]

Ordered menu items.

open?() => boolean

Controlled open state; omit for internal state.

on_open_change?(open: boolean) => void

Called when open state changes.

on_select?(item: T) => void

Called when any enabled menu item is activated.

close_on_select?boolean

Close the menu after selecting a regular menuitem (default true).

side?FloatingSide

Preferred side relative to trigger (default 'bottom').

align?FloatingAlign

Cross-axis alignment relative to trigger (default 'start').

label?string

Accessible name for the menu.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/menu.svelte.ts:23

type MenubarBehavior = ReturnType<typeof create_menubar>;

Return value of create_menubar.

成员

名称类型说明
open_menustring | null
is_open(id: string) => boolean
open(id: string) => void
close() => void
rootAttachment<HTMLElement>
item(key: string) => Attachment<HTMLElement>
root_attrs() => { role: "menubar"; "aria-label": string; onkeydown: (event: KeyboardEvent) => void; }
trigger_attrs(id: string) => { type: "button"; role: "menuitem"; "aria-haspopup": "menu"; "aria-expanded": boolean; "data-state": "open" | "closed"; tabindex: number | undefined; onfocus: () => void; onclick: () => void; onpointerenter: () => void; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:406

type MenubarOptions = {
    readonly menus: () => readonly string[];
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_menubar.

成员

名称类型说明
menus() => readonly string[]
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:399

MoveBehavior type

type MoveBehavior = ReturnType<typeof create_move>;

Return value of create_move.

成员

名称类型说明
draggingboolean
handleAttachment<HTMLElement>
handle_attrs() => { tabindex: number; "aria-label": string | undefined; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/canvas.svelte.ts:30

MoveOptions type

type MoveOptions = {
    readonly position: () => MovePoint;
    readonly on_change: (next: MovePoint) => void;
    readonly on_commit?: (final: MovePoint) => void;
    readonly step?: number;
    readonly grid?: number;
    readonly bounds?: () => {
        readonly min_x: number;
        readonly max_x: number;
        readonly min_y: number;
        readonly max_y: number;
    };
    readonly scale?: () => number;
    readonly label?: string;
};

Options for create_move.

成员

名称类型说明
position() => MovePoint
on_change(next: MovePoint) => void
on_commit?(final: MovePoint) => void
step?number
grid?number
bounds?() => { readonly min_x: number; readonly max_x: number; readonly min_y: number; readonly max_y: number; }
scale?() => number
label?string

源码: packages/ui/src/behaviors/canvas.svelte.ts:18

MovePoint type

type MovePoint = {
    readonly x: number;
    readonly y: number;
};

2D coordinate point.

成员

名称类型说明
xnumber
ynumber

源码: packages/ui/src/behaviors/canvas.svelte.ts:15

type NavigationMenuBehavior = ReturnType<typeof create_navigation_menu>;

Return value of create_navigation_menu.

成员

名称类型说明
activestring | null
is_open(id: string) => boolean
open(id: string) => void
close() => void
rootAttachment<HTMLElement>
item(key: string) => Attachment<HTMLElement>
root_attrs() => { "aria-label": string; onpointerleave: () => void; onkeydown: (event: KeyboardEvent) => void; }
trigger_attrs(id: string) => { type: "button"; "aria-expanded": boolean; "data-state": "open" | "closed"; tabindex: number | undefined; onfocus: () => void; onpointerenter: () => void; onclick: () => void; }
content_attrs() => { onpointerenter: () => void; onpointerleave: () => void; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:529

type NavigationMenuOptions = {
    readonly items: () => readonly string[];
    readonly open_delay?: number;
    readonly close_delay?: number;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_navigation_menu.

成员

名称类型说明
items() => readonly string[]
open_delay?number
close_delay?number
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:520

NumberInputOptions type

type NumberInputOptions = {
    readonly value?: () => number | null;
    readonly default_value?: number | null;
    readonly on_change?: (value: number | null) => void;
    readonly min?: number;
    readonly max?: number;
    readonly step?: number;
    readonly locale?: string;
    readonly disabled?: () => boolean;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_number_input.

成员

名称类型说明
value?() => number | null
default_value?number | null
on_change?(value: number | null) => void
min?number
max?number
step?number
locale?string
disabled?() => boolean
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:261

Overflow type

type Overflow<T> = ReturnType<typeof create_overflow<T>>;

Return value of create_overflow.

成员

名称类型说明
fitnumber
visiblereadonly T[]
hiddenreadonly T[]
has_overflowboolean
active_in_hiddenboolean
more_openboolean
listAttachment<HTMLElement>
measureAttachment<HTMLElement>

源码: packages/ui/src/behaviors/overflow.svelte.ts:18

OverflowOptions type

type OverflowOptions<T> = {
    /** All items in display order. */
    items: () => readonly T[];
    /** Key extractor for checking whether the active item is currently inside the overflow menu. */
    key?: (item: T) => string;
    /** Currently active key (optional). */
    active?: () => string | undefined;
};

Options for create_overflow.

成员

名称类型说明
items() => readonly T[]

All items in display order.

key?(item: T) => string

Key extractor for checking whether the active item is currently inside the overflow menu.

active?() => string | undefined

Currently active key (optional).

源码: packages/ui/src/behaviors/overflow.svelte.ts:8

OverlayEntry type

type OverlayEntry<Payload, Result = unknown> = {
    readonly id: string;
    readonly payload: Payload;
    readonly resolve: (result: Result | undefined) => void;
};

One entry in an imperative create_overlay_stack.

成员

名称类型说明
idstring
payloadPayload
resolve(result: Result | undefined) => void

源码: packages/ui/src/behaviors/platform.svelte.ts:448

PageControlsOptions type

type PageControlsOptions = {
    /** Only return controls whose `element()` sits inside this container. */
    readonly within?: Element | null;
    /** Optional substring filter over id, kind, or label. */
    readonly query?: string;
    /** Maximum number of controls to return. */
    readonly limit?: number;
};

Options for filtering page_controls.

成员

名称类型说明
within?Element | null

Only return controls whose element() sits inside this container.

query?string

Optional substring filter over id, kind, or label.

limit?number

Maximum number of controls to return.

源码: packages/ui/src/behaviors/controls.svelte.ts:55

Pagination type

type Pagination = ReturnType<typeof create_pagination>;

Return value of create_pagination.

成员

名称类型说明
pagenumber
pagesnumber | null
has_previousboolean
has_nextboolean
rangePaginationEntry[]
go(target: number) => void
previous() => void
next() => void
first() => void
last() => void

源码: packages/ui/src/behaviors/pagination.svelte.ts:29

PaginationEntry type

type PaginationEntry = number | 'ellipsis';

One entry in a compact pagination window: a 1-based page number or 'ellipsis'.

源码: packages/ui/src/behaviors/pagination.svelte.ts:6

PaginationOptions type

type PaginationOptions = {
    /** Current 1-based page number (controlled getter, or omit for internal state). */
    page?: () => number;
    /** Initial 1-based page when uncontrolled (default `1`). */
    default_page?: number;
    /** Total page count (`null` when unknown / keyset-paged). */
    total_pages: () => number | null;
    /** Explicit previous availability override (for cursor/keyset pagination). */
    has_previous?: () => boolean;
    /** Explicit next availability override (for cursor/keyset pagination). */
    has_next?: () => boolean;
    /** Called when the page changes. */
    on_page_change?: (page: number) => void;
    /** Sibling pages shown on each side of the current page in `range` (default `1`). */
    siblings?: number;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    control?: {
        id: string;
        label?: string;
    };
};

Options for create_pagination.

成员

名称类型说明
page?() => number

Current 1-based page number (controlled getter, or omit for internal state).

default_page?number

Initial 1-based page when uncontrolled (default 1).

total_pages() => number | null

Total page count (null when unknown / keyset-paged).

has_previous?() => boolean

Explicit previous availability override (for cursor/keyset pagination).

has_next?() => boolean

Explicit next availability override (for cursor/keyset pagination).

on_page_change?(page: number) => void

Called when the page changes.

siblings?number

Sibling pages shown on each side of the current page in range (default 1).

control?{ id: string; label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/pagination.svelte.ts:9

PanelGroup type

type PanelGroup = ReturnType<typeof create_panel_group>;

Return value of create_panel_group.

成员

名称类型说明
sizesreadonly number[]
draggingnumber | null
size_of(index: number) => number
reset() => void
containerAttachment<HTMLElement>
handle(handleIndex: number) => Attachment<HTMLElement>
handle_attrs(handleIndex: number) => { role: "separator"; tabindex: number; "aria-orientation": "horizontal" | "vertical"; "aria-valuenow": number; "aria-valuemin": number; "aria-valuemax": number; "data-dragging": string | undefined; ondblclick: () => void; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:42

PanelGroupOptions type

type PanelGroupOptions = {
    readonly panels: readonly PanelSpec[];
    readonly direction?: 'horizontal' | 'vertical';
    readonly storage_key?: string;
    readonly on_layout?: (sizes: readonly number[]) => void;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_panel_group.

成员

名称类型说明
panelsreadonly PanelSpec[]
direction?'horizontal' | 'vertical'
storage_key?string
on_layout?(sizes: readonly number[]) => void
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:33

PanelSpec type

type PanelSpec = {
    readonly id: string;
    readonly default_size: number;
    readonly min_size?: number;
    readonly max_size?: number;
    readonly collapsible?: boolean;
};

Configuration for one pane inside create_panel_group.

成员

名称类型说明
idstring
default_sizenumber
min_size?number
max_size?number
collapsible?boolean

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:24

PasswordInput type

type PasswordInput = ReturnType<typeof create_password_input>;

Return value of create_password_input.

成员

名称类型说明
visibleboolean
caps_lockboolean
toggle() => void
set_visible(next: boolean) => void
inputAttachment<HTMLInputElement>
input_attrs() => { type: "text" | "password"; "data-agent-secret": string; "aria-label": string | undefined; onkeydown: (event: KeyboardEvent) => void; onkeyup: (event: KeyboardEvent) => void; }
toggle_attrs() => { type: "button"; "aria-pressed": boolean; "aria-label": string; onclick: () => void; }

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:882

PasswordInputOptions type

type PasswordInputOptions = {
    /** Initial visibility (default `false`). */
    readonly default_visible?: boolean;
    /** Accessible label for the password input. */
    readonly label?: string;
    /** Optional semantic control registration (always marked `secret: true`). */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_password_input.

成员

名称类型说明
default_visible?boolean

Initial visibility (default false).

label?string

Accessible label for the password input.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration (always marked secret: true).

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:872

PatternViolation type

type PatternViolation = {
    readonly rule: string;
    readonly message: string;
    readonly element?: Element;
};

One contract violation detected by check_pattern or check_direction.

成员

名称类型说明
rulestring
messagestring
element?Element

源码: packages/ui/src/behaviors/testing.ts:21

PersistedState class

class PersistedState<T> {
    #private;
    constructor(key: string, initialValue: T, options?: PersistedStateOptions<T>);
    /** Current persisted value. */
    get current(): T;
    set current(value: T);
}

Reactive state synchronized with localStorage or sessionStorage with safe fallback when storage is unavailable or contains malformed JSON.

成员

名称类型说明
#privateany
currentT

Current persisted value.

源码: packages/ui/src/behaviors/reactive.svelte.ts:213

PersistedStateOptions type

type PersistedStateOptions<T> = {
    /** Browser storage backend (`'local'` default, or `'session'`). */
    readonly storage?: 'local' | 'session';
    /** Custom serializer; defaults to JSON. */
    readonly serializer?: {
        readonly serialize: (value: T) => string;
        readonly deserialize: (raw: string) => T;
    };
};

Storage options for PersistedState.

成员

名称类型说明
storage?'local' | 'session'

Browser storage backend ('local' default, or 'session').

serializer?{ readonly serialize: (value: T) => string; readonly deserialize: (raw: string) => T; }

Custom serializer; defaults to JSON.

源码: packages/ui/src/behaviors/reactive.svelte.ts:195

PinCell type

type PinCell = {
    /** Zero-based index of this cell. */
    readonly index: number;
    /** Character currently in this cell, or `null` when empty. */
    readonly char: string | null;
    /** Whether this cell holds the active caret position. */
    readonly is_active: boolean;
    /** Whether to draw a blinking caret inside this empty active cell. */
    readonly has_fake_caret: boolean;
};

One visual cell of a PIN / OTP code.

成员

名称类型说明
indexnumber

Zero-based index of this cell.

charstring | null

Character currently in this cell, or null when empty.

is_activeboolean

Whether this cell holds the active caret position.

has_fake_caretboolean

Whether to draw a blinking caret inside this empty active cell.

源码: packages/ui/src/behaviors/pin.svelte.ts:6

PinInputBehavior type

type PinInputBehavior = ReturnType<typeof create_pin_input>;

Return value of create_pin_input.

成员

名称类型说明
valuestring
cellsreadonly PinCell[]
focusedboolean
set_value(raw: string) => void
input_attrs() => { value: string; maxlength: number; disabled: true | undefined; onfocus: (event: FocusEvent) => void; onblur: () => void; oninput: (event: Event) => void; onkeyup: (event: KeyboardEvent) => void; onselect: (event: Event) => void; }

Spread onto the underlying <input> element that owns focus, typing, paste and autofill.

源码: packages/ui/src/behaviors/pin.svelte.ts:43

PinInputOptions type

type PinInputOptions = {
    /** Number of cells (e.g. `6`). */
    readonly length: number | (() => number);
    /** Controlled value getter; omit for internal state. */
    readonly value?: () => string;
    /** Initial value when uncontrolled. */
    readonly default_value?: string;
    /** Called whenever the sanitized value changes. */
    readonly on_value_change?: (value: string) => void;
    /** Called when the value reaches `length` characters. */
    readonly on_complete?: (value: string) => void;
    /** Allowed character filter regex (default digits only `/^\d+$/`). */
    readonly pattern?: RegExp;
    /** Disabled state. */
    readonly disabled?: () => boolean;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
        readonly secret?: boolean;
        readonly element?: () => HTMLElement | null;
    };
};

Options for create_pin_input.

成员

名称类型说明
lengthnumber | (() => number)

Number of cells (e.g. 6).

value?() => string

Controlled value getter; omit for internal state.

default_value?string

Initial value when uncontrolled.

on_value_change?(value: string) => void

Called whenever the sanitized value changes.

on_complete?(value: string) => void

Called when the value reaches length characters.

pattern?RegExp

Allowed character filter regex (default digits only /^\d+$/).

disabled?() => boolean

Disabled state.

control?{ readonly id: string; readonly label?: string; readonly secret?: boolean; readonly element?: () => HTMLElement | null; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/pin.svelte.ts:18

PointerKindState type

type PointerKindState = {
    readonly precision: PointerPrecision;
    readonly hover: boolean;
};

Current device pointer capabilities.

成员

名称类型说明
precisionPointerPrecision
hoverboolean

源码: packages/ui/src/behaviors/platform.svelte.ts:104

PointerPrecision type

type PointerPrecision = 'coarse' | 'fine';

Primary pointer precision ('coarse' touch vs 'fine' mouse/trackpad).

源码: packages/ui/src/behaviors/platform.svelte.ts:101

PointerSample type

type PointerSample = {
    readonly x: number;
    readonly y: number;
    readonly start_x: number;
    readonly start_y: number;
    readonly dx: number;
    readonly dy: number;
    readonly event: PointerEvent;
};

Live pointer position and delta reported by bind_drag.

成员

名称类型说明
xnumber
ynumber
start_xnumber
start_ynumber
dxnumber
dynumber
eventPointerEvent

源码: packages/ui/src/behaviors/drag.svelte.ts:10

PortalOptions type

type PortalOptions = {
    /** Mount element, CSS selector, or `null` to render in place. */
    readonly to?: PortalTarget;
    /** When `true`, keeps the element in place instead of teleporting it. */
    readonly disabled?: boolean;
};

Options object accepted by portal(...).

成员

名称类型说明
to?PortalTarget

Mount element, CSS selector, or null to render in place.

disabled?boolean

When true, keeps the element in place instead of teleporting it.

源码: packages/ui/src/behaviors/portal.svelte.ts:13

PortalTarget type

type PortalTarget = HTMLElement | string | null | undefined;

Target element, CSS selector or null to disable teleporting and render in place.

源码: packages/ui/src/behaviors/portal.svelte.ts:10

Presence type

type Presence = ReturnType<typeof create_presence>;

Return value of create_presence.

成员

名称类型说明
presentboolean
statePresenceState
exitingboolean
attachAttachment<HTMLElement>

源码: packages/ui/src/behaviors/presence.svelte.ts:18

PresenceOptions type

type PresenceOptions = {
    /** Reactive open getter. */
    readonly open: () => boolean;
    /** Called once enter or exit settles. */
    readonly on_complete?: (open: boolean) => void;
};

Options for create_presence.

成员

名称类型说明
open() => boolean

Reactive open getter.

on_complete?(open: boolean) => void

Called once enter or exit settles.

源码: packages/ui/src/behaviors/presence.svelte.ts:10

PresenceState type

type PresenceState = 'entering' | 'open' | 'exiting' | 'closed';

Lifecycle phase of a presence-managed element.

源码: packages/ui/src/behaviors/presence.svelte.ts:7

PreviewOptions type

type PreviewOptions<T> = {
    /** Committed authoritative value. */
    readonly value: () => T;
    /** Called when a preview is explicitly committed. */
    readonly on_commit: (value: T) => void;
};

Options for create_preview.

成员

名称类型说明
value() => T

Committed authoritative value.

on_commit(value: T) => void

Called when a preview is explicitly committed.

源码: packages/ui/src/behaviors/platform.svelte.ts:325

PreviewState type

type PreviewState<T> = ReturnType<typeof create_preview<T>>;

Return value of create_preview.

成员

名称类型说明
currentT
previewingboolean
update(next: T) => void
commit(finalValue?: T) => void
cancel() => void

源码: packages/ui/src/behaviors/platform.svelte.ts:333

RadioGroupOptions type

type RadioGroupOptions = {
    readonly items: () => readonly string[];
    readonly value?: () => string | undefined;
    readonly default_value?: string;
    readonly on_change?: (value: string) => void;
    readonly orientation?: RovingOrientation;
    readonly disabled?: (value: string) => boolean;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_radio_group.

成员

名称类型说明
items() => readonly string[]
value?() => string | undefined
default_value?string
on_change?(value: string) => void
orientation?RovingOrientation
disabled?(value: string) => boolean
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:86

RatingOptions type

type RatingOptions = {
    readonly max?: number;
    readonly value?: () => number;
    readonly default_value?: number;
    readonly on_change?: (value: number) => void;
    readonly disabled?: () => boolean;
    readonly label?: string;
};

Options for create_rating.

成员

名称类型说明
max?number
value?() => number
default_value?number
on_change?(value: number) => void
disabled?() => boolean
label?string

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:414

RejectedFile type

type RejectedFile = {
    readonly file: File;
    readonly reason: 'type' | 'size' | 'count';
};

One rejected file from create_file_dropzone validation.

成员

名称类型说明
fileFile
reason'type' | 'size' | 'count'

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:720

Reorder type

type Reorder = ReturnType<typeof create_reorder>;

Return value of create_reorder.

成员

名称类型说明
draggingstring | null
overstring | null
move(fromIndex: number, toIndex: number) => void
move_by(key: string, delta: number) => void
item(key: string) => Attachment<HTMLElement>

Optional pointer-capture drag attachment (works cleanly on touch & supports edge auto-scroll + Escape cancel).

item_attrs(key: string) => { draggable: boolean; "data-dragging": string | undefined; "data-drop-target": string | undefined; ondragstart: (event: DragEvent) => void; ondragover: (event: DragEvent) => void; ondragleave: () => void; ondrop: (event: DragEvent) => void; ondragend: () => void; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/reorder.svelte.ts:26

ReorderOptions type

type ReorderOptions = {
    /** Ordered item keys. */
    readonly items: () => readonly string[];
    /** Invoked with `(fromIndex, toIndex, nextOrder)` when an item moves. */
    readonly on_reorder: (from: number, to: number, next: readonly string[]) => void;
    /** Axis for movement (default `'vertical'`). */
    readonly orientation?: ReorderOrientation;
    /** Disable reordering globally or for a specific key. */
    readonly disabled?: boolean | ((key: string) => boolean);
    /** Optional human-readable label per key for live announcements. */
    readonly label?: (key: string) => string;
};

Options for create_reorder.

成员

名称类型说明
items() => readonly string[]

Ordered item keys.

on_reorder(from: number, to: number, next: readonly string[]) => void

Invoked with (fromIndex, toIndex, nextOrder) when an item moves.

orientation?ReorderOrientation

Axis for movement (default 'vertical').

disabled?boolean | ((key: string) => boolean)

Disable reordering globally or for a specific key.

label?(key: string) => string

Optional human-readable label per key for live announcements.

源码: packages/ui/src/behaviors/reorder.svelte.ts:12

ReorderOrientation type

type ReorderOrientation = 'vertical' | 'horizontal';

Axis for keyboard and pointer reordering ('vertical' or 'horizontal').

源码: packages/ui/src/behaviors/reorder.svelte.ts:9

Resize type

type Resize = ReturnType<typeof create_resize>;

Return value of create_resize.

成员

名称类型说明
draggingboolean
handle_attrs() => { role: "separator"; "aria-orientation": "horizontal" | "vertical"; "aria-label": string | undefined; "aria-valuenow": number; "aria-valuemin": number; "aria-valuemax": number | undefined; tabindex: number; "data-dragging": string | undefined; onpointerdown: (event: PointerEvent) => void; onkeydown: (event: KeyboardEvent) => void; }

Spread onto the resize handle element (role="separator", aria-value*, pointer & keyboard handlers).

源码: packages/ui/src/behaviors/resize.svelte.ts:36

ResizeAxis type

type ResizeAxis = 'horizontal' | 'vertical' | 'both';

Axis of pointer/keyboard resizing ('horizontal', 'vertical', or 2D 'both').

源码: packages/ui/src/behaviors/resize.svelte.ts:6

ResizeBox type

type ResizeBox = {
    readonly width: number;
    readonly height: number;
};

2D dimensions used when axis === 'both' or via create_resize_2d.

成员

名称类型说明
widthnumber
heightnumber

源码: packages/ui/src/behaviors/resize.svelte.ts:9

ResizeBoxOptions type

type ResizeBoxOptions = {
    readonly size: () => ResizeBox;
    readonly on_change: (next: ResizeBox) => void;
    readonly on_commit?: (final: ResizeBox) => void;
    readonly min_width?: number;
    readonly max_width?: number;
    readonly min_height?: number;
    readonly max_height?: number;
    readonly scale?: () => number;
    readonly step?: number;
};

Options for 2D create_resize_box (edge & corner handles for preview frames, cards, canvases).

成员

名称类型说明
size() => ResizeBox
on_change(next: ResizeBox) => void
on_commit?(final: ResizeBox) => void
min_width?number
max_width?number
min_height?number
max_height?number
scale?() => number
step?number

源码: packages/ui/src/behaviors/resize.svelte.ts:147

ResizeOptions type

type ResizeOptions = {
    /** Current size in pixels (reactive getter). */
    readonly value: () => number;
    /** Called with the clamped pixel size during drag and keyboard nudges. */
    readonly on_change: (next: number) => void;
    /** Called once when a pointer drag finishes. */
    readonly on_commit?: (final: number) => void;
    /** Axis of drag movement (default `'horizontal'`). */
    readonly axis?: 'horizontal' | 'vertical';
    /** Invert drag delta (e.g. dragging a right-docked sheet's left edge leftward widens it). */
    readonly invert?: boolean;
    /** Minimum size in pixels (default `120`). */
    readonly min?: number | (() => number);
    /** Maximum size in pixels (default `Infinity`). */
    readonly max?: number | (() => number);
    /** Optional zoom divisor for scaled canvases/preview frames (default `1`). */
    readonly scale?: number | (() => number);
    /** Keyboard Arrow nudge increment in pixels (default `24`). */
    readonly step?: number;
    /** Accessible label for the separator handle. */
    readonly label?: string;
};

Options for create_resize.

成员

名称类型说明
value() => number

Current size in pixels (reactive getter).

on_change(next: number) => void

Called with the clamped pixel size during drag and keyboard nudges.

on_commit?(final: number) => void

Called once when a pointer drag finishes.

axis?'horizontal' | 'vertical'

Axis of drag movement (default 'horizontal').

invert?boolean

Invert drag delta (e.g. dragging a right-docked sheet's left edge leftward widens it).

min?number | (() => number)

Minimum size in pixels (default 120).

max?number | (() => number)

Maximum size in pixels (default Infinity).

scale?number | (() => number)

Optional zoom divisor for scaled canvases/preview frames (default 1).

step?number

Keyboard Arrow nudge increment in pixels (default 24).

label?string

Accessible label for the separator handle.

源码: packages/ui/src/behaviors/resize.svelte.ts:12

ResolvedColorScheme type

type ResolvedColorScheme = 'light' | 'dark';

Resolved concrete color scheme.

源码: packages/ui/src/behaviors/platform.svelte.ts:156

RgbaColor type

type RgbaColor = {
    readonly r: number;
    readonly g: number;
    readonly b: number;
    readonly a: number;
};

RGBA color representation with channels r,g,b in 0..255 and alpha a in 0..1.

成员

名称类型说明
rnumber
gnumber
bnumber
anumber

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:781

RovingFocus type

type RovingFocus = ReturnType<typeof create_roving_focus>;

Return value of create_roving_focus.

成员

名称类型说明
activestring
focus(key: string) => void
next() => void
prev() => void
item(key: string) => Attachment<HTMLElement>

Attach to each focusable item for arrow focus & unmount focus recovery.

root_attrs() => { onkeydown: (event: KeyboardEvent) => void; }

Spread onto the container element to handle arrow/Home/End keyboard navigation.

item_attrs(key: string) => { tabindex: number | undefined; "data-roving-active": string | undefined; onfocus: () => void; }

Spread onto each item for roving tabindex, focus syncing and data-roving-active state.

源码: packages/ui/src/behaviors/roving-focus.svelte.ts:29

RovingFocusOptions type

type RovingFocusOptions = {
    /** Keys in navigation order. */
    readonly items: () => readonly string[];
    /** Controlled active key; omit for internal focus tracking. */
    readonly active?: () => string | undefined;
    /** Called when keyboard navigation moves focus to a key. */
    readonly on_active_change?: (key: string) => void;
    /** Axis of arrow navigation (default `'horizontal'`). */
    readonly orientation?: RovingOrientation | (() => RovingOrientation);
    /** Wrap from last back to first and vice versa (default `true`). */
    readonly loop?: boolean;
    /** Skip disabled keys during keyboard movement. */
    readonly disabled?: (key: string) => boolean;
    /** Optional callback invoked when Space or Enter activates the focused item. */
    readonly on_activate?: (key: string) => void;
};

Options for create_roving_focus.

成员

名称类型说明
items() => readonly string[]

Keys in navigation order.

active?() => string | undefined

Controlled active key; omit for internal focus tracking.

on_active_change?(key: string) => void

Called when keyboard navigation moves focus to a key.

orientation?RovingOrientation | (() => RovingOrientation)

Axis of arrow navigation (default 'horizontal').

loop?boolean

Wrap from last back to first and vice versa (default true).

disabled?(key: string) => boolean

Skip disabled keys during keyboard movement.

on_activate?(key: string) => void

Optional callback invoked when Space or Enter activates the focused item.

源码: packages/ui/src/behaviors/roving-focus.svelte.ts:11

RovingOrientation type

type RovingOrientation = 'horizontal' | 'vertical' | 'both';

Arrow-key navigation axis ('horizontal', 'vertical', or 'both').

源码: packages/ui/src/behaviors/roving-focus.svelte.ts:8

ScrollPickerOptions type

type ScrollPickerOptions = {
    /** Called when the centered option changes after scrolling settles. */
    readonly on_select: (index: number) => void;
    /** Scroll axis (default `'vertical'`). */
    readonly orientation?: 'vertical' | 'horizontal';
};

Options for bind_scroll_picker.

成员

名称类型说明
on_select(index: number) => void

Called when the centered option changes after scrolling settles.

orientation?'vertical' | 'horizontal'

Scroll axis (default 'vertical').

源码: packages/ui/src/behaviors/canvas.svelte.ts:835

SegmentPart type

type SegmentPart = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'literal';

Editable or literal segment kind inside a segmented date or time field.

源码: packages/ui/src/behaviors/date-time.svelte.ts:25

Selection type

type Selection = ReturnType<typeof create_selection>;

Return value of create_selection.

成员

名称类型说明
selectedreadonly string[]
countnumber
all_selectedboolean
some_selectedboolean
is_selected(key: string) => boolean
choose(key: string) => void
toggle(key: string) => void
extend(to: string, opts?: { from?: string | null; additive?: boolean; }) => void
toggle_all() => void
clear() => void
item_attrs(key: string) => { "aria-selected": boolean; "data-selected": string | undefined; "aria-disabled": true | undefined; onclick: (event: MouseEvent) => void; }

Spread onto each selectable item for aria-selected, data-selected and click/Shift/Cmd handling.

源码: packages/ui/src/behaviors/selection.svelte.ts:24

SelectionMode type

type SelectionMode = 'single' | 'multiple';

Single or multiple item selection mode.

源码: packages/ui/src/behaviors/selection.svelte.ts:5

SelectionOptions type

type SelectionOptions = {
    /** Keys in visual order (used for Shift ranges and select-all). */
    order: () => readonly string[];
    /** Single or multiple selection (default `'single'`). */
    mode?: SelectionMode | (() => SelectionMode);
    /** Controlled selected keys; omit for internal state. */
    selected?: () => readonly string[];
    /** Initial selected keys when uncontrolled. */
    default_selected?: readonly string[];
    /** Called with the next selection whenever it changes. */
    on_change?: (keys: readonly string[]) => void;
    /** Whether a key may be selected (default every key). */
    selectable?: (key: string) => boolean;
};

Options for create_selection.

成员

名称类型说明
order() => readonly string[]

Keys in visual order (used for Shift ranges and select-all).

mode?SelectionMode | (() => SelectionMode)

Single or multiple selection (default 'single').

selected?() => readonly string[]

Controlled selected keys; omit for internal state.

default_selected?readonly string[]

Initial selected keys when uncontrolled.

on_change?(keys: readonly string[]) => void

Called with the next selection whenever it changes.

selectable?(key: string) => boolean

Whether a key may be selected (default every key).

源码: packages/ui/src/behaviors/selection.svelte.ts:8

ShortcutBinding type

type ShortcutBinding = {
    /** Shortcut spec such as `'mod+k'`, `'escape'`, `'shift+alt+p'`, `'/'`, or chord `'g i'`. */
    readonly keys: string;
    /** Handler invoked when matched. */
    readonly handler: (event: KeyboardEvent) => void;
    /** Allow firing while focus is inside an input, textarea, select or contenteditable (default `false`). */
    readonly allow_in_input?: boolean;
    /** Call `event.preventDefault()` on match (default `true`). */
    readonly prevent_default?: boolean;
    /** Temporarily disable this shortcut. */
    readonly enabled?: boolean | (() => boolean);
};

One declarative keyboard shortcut binding for create_shortcuts.

成员

名称类型说明
keysstring

Shortcut spec such as 'mod+k', 'escape', 'shift+alt+p', '/', or chord 'g i'.

handler(event: KeyboardEvent) => void

Handler invoked when matched.

allow_in_input?boolean

Allow firing while focus is inside an input, textarea, select or contenteditable (default false).

prevent_default?boolean

Call event.preventDefault() on match (default true).

enabled?boolean | (() => boolean)

Temporarily disable this shortcut.

源码: packages/ui/src/behaviors/shortcuts.svelte.ts:6

Slider type

type Slider = ReturnType<typeof create_slider>;

Return value of create_slider.

成员

名称类型说明
valuenumber
valuesreadonly number[]
percentnumber
percentsnumber[]
draggingboolean
active_thumbnumber
set(next: number, index?: number) => void
trackAttachment<HTMLElement>
thumb_attrs(index?: number) => { role: "slider"; "aria-orientation": "horizontal" | "vertical"; "aria-label": string | undefined; "aria-valuemin": number; "aria-valuemax": number; "aria-valuenow": number; "aria-disabled": true | undefined; tabindex: number | undefined; "data-dragging": string | undefined; onfocus: () => void; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/slider.svelte.ts:42

SliderOptions type

type SliderOptions = {
    /** Controlled numeric value (single-thumb mode); omit for internal state. */
    readonly value?: () => number;
    /** Initial value when uncontrolled (default `min`). */
    readonly default_value?: number;
    /** Called when the quantized value changes (single-thumb mode). */
    readonly on_change?: (value: number) => void;
    /** Called once when a drag or key adjustment settles (single-thumb mode). */
    readonly on_commit?: (value: number) => void;
    /** Controlled multi-thumb values (range slider mode). */
    readonly values?: () => readonly number[];
    /** Initial multi-thumb values when uncontrolled. */
    readonly default_values?: readonly number[];
    /** Called when multi-thumb values change. */
    readonly on_values_change?: (values: readonly number[]) => void;
    /** Called once when a multi-thumb drag or key adjustment settles. */
    readonly on_values_commit?: (values: readonly number[]) => void;
    /** Minimum value (default `0`). */
    readonly min?: number | (() => number);
    /** Maximum value (default `100`). */
    readonly max?: number | (() => number);
    /** Step increment (default `1`). */
    readonly step?: number | (() => number);
    /** Orientation (`'horizontal'` default, or `'vertical'`). */
    readonly orientation?: 'horizontal' | 'vertical';
    /** Disabled state. */
    readonly disabled?: () => boolean;
    /** Accessible label. */
    readonly label?: string;
    /** Optional semantic contr…

Options for create_slider.

成员

名称类型说明
value?() => number

Controlled numeric value (single-thumb mode); omit for internal state.

default_value?number

Initial value when uncontrolled (default min).

on_change?(value: number) => void

Called when the quantized value changes (single-thumb mode).

on_commit?(value: number) => void

Called once when a drag or key adjustment settles (single-thumb mode).

values?() => readonly number[]

Controlled multi-thumb values (range slider mode).

default_values?readonly number[]

Initial multi-thumb values when uncontrolled.

on_values_change?(values: readonly number[]) => void

Called when multi-thumb values change.

on_values_commit?(values: readonly number[]) => void

Called once when a multi-thumb drag or key adjustment settles.

min?number | (() => number)

Minimum value (default 0).

max?number | (() => number)

Maximum value (default 100).

step?number | (() => number)

Step increment (default 1).

orientation?'horizontal' | 'vertical'

Orientation ('horizontal' default, or 'vertical').

disabled?() => boolean

Disabled state.

label?string

Accessible label.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/slider.svelte.ts:8

Span type

type Span = {
    readonly id: string;
    readonly track: string;
    readonly start: number;
    readonly end: number;
};

A range placed on a named track (calendar event, Gantt bar, room booking).

成员

名称类型说明
idstring
trackstring
startnumber
endnumber

源码: packages/ui/src/behaviors/canvas.svelte.ts:263

SpansBehavior type

type SpansBehavior<S extends Span = Span> = ReturnType<typeof create_spans<S>>;

Return value of create_spans.

成员

名称类型说明
spansreadonly S[]
activestring | null
update_span(id: string, patch: Partial<Pick<Span, "track" | "start" | "end">>, action: "move" | "resize", commitNow?: boolean) => void
create(track: string, start: number, end: number) => void
remove(id: string) => void
cancel() => void
span_attrs(span: S) => { tabindex: number; 'data-span-id': string; 'data-dragging': string | undefined; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/canvas.svelte.ts:318

SpansOptions type

type SpansOptions<S extends Span = Span> = {
    readonly tracks: () => readonly string[];
    readonly spans: () => readonly S[];
    readonly min: number;
    readonly max: number;
    readonly step?: number;
    readonly min_duration?: number;
    readonly on_commit: (next: readonly S[], action: 'draw' | 'move' | 'resize' | 'delete', id: string) => void;
    readonly create_span?: (draft: Span) => S;
};

Options for create_spans.

成员

名称类型说明
tracks() => readonly string[]
spans() => readonly S[]
minnumber
maxnumber
step?number
min_duration?number
on_commit(next: readonly S[], action: 'draw' | 'move' | 'resize' | 'delete', id: string) => void
create_span?(draft: Span) => S

源码: packages/ui/src/behaviors/canvas.svelte.ts:306

SpatialDirection type

type SpatialDirection = 'up' | 'down' | 'left' | 'right';

Cardinal direction for nearest_in_direction / spatial_move.

源码: packages/ui/src/behaviors/micro.svelte.ts:493

SpatialRect type

type SpatialRect = {
    readonly left: number;
    readonly top: number;
    readonly width: number;
    readonly height: number;
};

Bounding box used by geometric spatial navigation.

成员

名称类型说明
leftnumber
topnumber
widthnumber
heightnumber

源码: packages/ui/src/behaviors/micro.svelte.ts:485

SpringState type

type SpringState = {
    readonly position: number;
    readonly velocity: number;
    readonly settled: boolean;
};

Spring state for one-dimensional spring integration.

成员

名称类型说明
positionnumber
velocitynumber
settledboolean

源码: packages/ui/src/behaviors/motion.svelte.ts:69

StickToBottom type

type StickToBottom = ReturnType<typeof create_stick_to_bottom>;

Return value of create_stick_to_bottom.

成员

名称类型说明
stuckboolean
scroll_to_bottom(behavior?: ScrollBehavior) => void
viewportAttachment<HTMLElement>

源码: packages/ui/src/behaviors/stick-to-bottom.svelte.ts:15

StickToBottomOptions type

type StickToBottomOptions = {
    /** Pixel distance from the bottom edge still considered latched (default `32`). */
    threshold?: number;
    /** Start latched to the bottom (default `true`). */
    initial?: boolean;
};

Options for create_stick_to_bottom.

成员

名称类型说明
threshold?number

Pixel distance from the bottom edge still considered latched (default 32).

initial?boolean

Start latched to the bottom (default true).

源码: packages/ui/src/behaviors/stick-to-bottom.svelte.ts:7

SwipeActions type

type SwipeActions = ReturnType<typeof create_swipe_actions>;

Return value of create_swipe_actions.

成员

名称类型说明
openSwipeOpen | null
offset{ readonly key: string; readonly x: number; } | null
close() => void
row(key: string) => Attachment<HTMLElement>
row_attrs(key: string) => { 'data-swipe-open': SwipeSide | undefined; style: string; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/canvas.svelte.ts:741

SwipeActionsOptions type

type SwipeActionsOptions = {
    /** Width in px of revealed action tray (default `120`). */
    readonly tray_width?: number;
    /** Fraction of tray width needed to snap open (default `0.5`). */
    readonly open_ratio?: number;
    /** Distance in px triggering immediate full-swipe action (default `220`). */
    readonly full_swipe_px?: number;
    /** Optional full-swipe callback (e.g. archive/delete). */
    readonly on_full_swipe?: (key: string, side: SwipeSide) => void;
};

Options for create_swipe_actions.

成员

名称类型说明
tray_width?number

Width in px of revealed action tray (default 120).

open_ratio?number

Fraction of tray width needed to snap open (default 0.5).

full_swipe_px?number

Distance in px triggering immediate full-swipe action (default 220).

on_full_swipe?(key: string, side: SwipeSide) => void

Optional full-swipe callback (e.g. archive/delete).

源码: packages/ui/src/behaviors/canvas.svelte.ts:729

SwipeOpen type

type SwipeOpen = {
    readonly key: string;
    readonly side: SwipeSide;
};

Currently revealed swipe row.

成员

名称类型说明
keystring
sideSwipeSide

源码: packages/ui/src/behaviors/canvas.svelte.ts:726

SwipeSide type

type SwipeSide = 'start' | 'end';

Side on which row swipe actions sit.

源码: packages/ui/src/behaviors/canvas.svelte.ts:723

SwitchOptions type

type SwitchOptions = {
    readonly checked?: () => boolean;
    readonly default_checked?: boolean;
    readonly on_change?: (checked: boolean) => void;
    readonly disabled?: () => boolean;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_switch.

成员

名称类型说明
checked?() => boolean
default_checked?boolean
on_change?(checked: boolean) => void
disabled?() => boolean
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:13

TimeFieldBehavior type

type TimeFieldBehavior = ReturnType<typeof create_time_field>;

Return value of create_time_field.

成员

名称类型说明
segmentsreadonly DateTimeSegment[]
segment_ref(part: SegmentPart) => Attachment<HTMLElement>
segment_attrs(seg: DateTimeSegment) => { "aria-hidden": true; "data-segment": "literal"; role?: undefined; tabindex?: undefined; "aria-label"?: undefined; "aria-valuemin"?: undefined; "aria-valuemax"?: undefined; "aria-valuenow"?: undefined; "aria-valuetext"?: undefined; "aria-disabled"?: undefined; onkeydown?: undefined; onblur?: undefined; } | { role: "spinbutton"; tabindex: number | undefined; "data-segmen…

源码: packages/ui/src/behaviors/date-time.svelte.ts:71

TimeFieldOptions type

type TimeFieldOptions = {
    /** Controlled `Time` getter. */
    readonly value: () => Time | undefined;
    /** Called when the time value changes (or clears to `undefined`). */
    readonly on_change: (next: Time | undefined) => void;
    /** Editing precision: `'hour'` or `'minute'` (default `'minute'`). */
    readonly granularity?: () => 'hour' | 'minute';
    /** Disabled state. */
    readonly disabled?: () => boolean;
};

Options for create_time_field.

成员

名称类型说明
value() => Time | undefined

Controlled Time getter.

on_change(next: Time | undefined) => void

Called when the time value changes (or clears to undefined).

granularity?() => 'hour' | 'minute'

Editing precision: 'hour' or 'minute' (default 'minute').

disabled?() => boolean

Disabled state.

源码: packages/ui/src/behaviors/date-time.svelte.ts:59

TimelineBehavior type

type TimelineBehavior = ReturnType<typeof create_timeline>;

Return value of create_timeline.

成员

名称类型说明
expandedreadonly string[]
is_expanded(id: string) => boolean
toggle(id: string) => void
item(key: string) => Attachment<HTMLElement>
root_attrs() => { role: "feed"; "aria-label": string; onkeydown: (event: KeyboardEvent) => void; }
item_attrs(id: string) => { role: "article"; "aria-expanded": boolean; "data-expanded": string | undefined; tabindex: number | undefined; onfocus: () => void; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1344

TimelineOptions type

type TimelineOptions = {
    readonly items: () => readonly string[];
    readonly default_expanded?: readonly string[];
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_timeline.

成员

名称类型说明
items() => readonly string[]
default_expanded?readonly string[]
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1336

ToggleGroupOptions type

type ToggleGroupOptions = {
    readonly items: () => readonly string[];
    readonly mode?: 'single' | 'multiple';
    readonly value?: () => readonly string[];
    readonly default_value?: readonly string[];
    readonly on_change?: (values: readonly string[]) => void;
    readonly orientation?: RovingOrientation;
    readonly disabled?: (key: string) => boolean;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_toggle_group.

成员

名称类型说明
items() => readonly string[]
mode?'single' | 'multiple'
value?() => readonly string[]
default_value?readonly string[]
on_change?(values: readonly string[]) => void
orientation?RovingOrientation
disabled?(key: string) => boolean
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:170

TokenInput type

type TokenInput = ReturnType<typeof create_token_input>;

Return value of create_token_input.

成员

名称类型说明
valuesreadonly string[]
input_textstring
active_indexnumber | null
editing_indexnumber | null
editing_textstring
errorstring | null
add(raw: string) => boolean
remove_at(index: number) => void
commit_input() => void
start_edit(index: number) => void
commit_edit() => void
cancel_edit() => void
inputAttachment<HTMLInputElement>
chip(index: number) => Attachment<HTMLElement>
input_attrs() => { value: string; disabled: true | undefined; "aria-label": string | undefined; onfocus: () => void; oninput: (event: Event) => void; onpaste: (event: ClipboardEvent) => void; onkeydown: (event: KeyboardEvent) => void; onblur: () => void; }
chip_attrs(index: number) => { tabindex: number; "data-active": string | undefined; "data-editing": string | undefined; onfocus: () => void; ondblclick: () => void; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:38

TokenInputOptions type

type TokenInputOptions = {
    /** Controlled tokens; omit for internal state. */
    readonly value?: () => readonly string[];
    /** Initial tokens when uncontrolled. */
    readonly default_value?: readonly string[];
    /** Called whenever tokens change. */
    readonly on_change?: (next: readonly string[]) => void;
    /** Delimiter characters that split tokens (default `[',']`). */
    readonly delimiters?: readonly string[];
    /** Allow duplicate tokens (default `false`). */
    readonly allow_duplicates?: boolean;
    /** Maximum token count (optional). */
    readonly max?: number;
    /** Optional validator returning an error message string when rejected, or `null`/`undefined` if valid. */
    readonly validate?: (token: string) => string | null | undefined;
    /** Disabled state. */
    readonly disabled?: () => boolean;
    /** Accessible label. */
    readonly label?: string;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_token_input.

成员

名称类型说明
value?() => readonly string[]

Controlled tokens; omit for internal state.

default_value?readonly string[]

Initial tokens when uncontrolled.

on_change?(next: readonly string[]) => void

Called whenever tokens change.

delimiters?readonly string[]

Delimiter characters that split tokens (default [',']).

allow_duplicates?boolean

Allow duplicate tokens (default false).

max?number

Maximum token count (optional).

validate?(token: string) => string | null | undefined

Optional validator returning an error message string when rejected, or null/undefined if valid.

disabled?() => boolean

Disabled state.

label?string

Accessible label.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:14

ToolbarOptions type

type ToolbarOptions = {
    readonly items: () => readonly string[];
    readonly orientation?: RovingOrientation;
    readonly disabled?: (key: string) => boolean;
    readonly label?: string;
};

Options for create_toolbar.

成员

名称类型说明
items() => readonly string[]
orientation?RovingOrientation
disabled?(key: string) => boolean
label?string

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:493

Transfer type

type Transfer = ReturnType<typeof create_transfer>;

Return value of create_transfer.

成员

名称类型说明
listsReadonly<Record<string, readonly string[]>>
draftTransferDraft | null
draggingstring | null
move(key: string, to: string, index: number, commitNow?: boolean) => void
container(id: string) => Attachment<HTMLElement>
item(key: string) => Attachment<HTMLElement>
item_attrs(key: string) => { "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/drag.svelte.ts:281

TransferDraft type

type TransferDraft = {
    readonly key: string;
    readonly from: string;
    readonly lists: TransferLists;
};

Live draft while an item is being transferred across containers.

成员

名称类型说明
keystring
fromstring
listsTransferLists

源码: packages/ui/src/behaviors/drag.svelte.ts:258

TransferLists type

type TransferLists = Readonly<Record<string, readonly string[]>>;

Map of container keys to their ordered item keys.

源码: packages/ui/src/behaviors/drag.svelte.ts:255

TransferOptions type

type TransferOptions = {
    /** Ordered container keys (e.g. Kanban lane ids). */
    readonly containers: () => readonly string[];
    /** Current lists per container. */
    readonly lists: () => TransferLists;
    /** Called once on drop or keyboard commit with the next container map. */
    readonly on_commit: (next: TransferLists, move: {
        readonly key: string;
        readonly from: string;
        readonly to: string;
        readonly index: number;
    }) => void;
    /** Optional predicate rejecting moves into a container. */
    readonly can_drop?: (key: string, toContainer: string) => boolean;
    /** Human-readable item label for screen-reader announcements. */
    readonly item_label?: (key: string) => string;
    /** Human-readable container label for screen-reader announcements. */
    readonly container_label?: (container: string) => string;
};

Options for create_transfer.

成员

名称类型说明
containers() => readonly string[]

Ordered container keys (e.g. Kanban lane ids).

lists() => TransferLists

Current lists per container.

on_commit(next: TransferLists, move: { readonly key: string; readonly from: string; readonly to: string; readonly index: number; }) => void

Called once on drop or keyboard commit with the next container map.

can_drop?(key: string, toContainer: string) => boolean

Optional predicate rejecting moves into a container.

item_label?(key: string) => string

Human-readable item label for screen-reader announcements.

container_label?(container: string) => string

Human-readable container label for screen-reader announcements.

源码: packages/ui/src/behaviors/drag.svelte.ts:265

Tree type

type Tree<T = unknown> = ReturnType<typeof create_tree<T>>;

Return value of create_tree.

成员

名称类型说明
rowsFlatTreeRow<T>[]
expandedreadonly string[]
selectedreadonly string[]
activestring
expand(id: string) => void
collapse(id: string) => void
toggle_expand(id: string) => void
is_expanded(id: string) => boolean
is_selected(key: string) => boolean
item(key: string) => import("svelte/attachments").Attachment<HTMLElement>
root_attrs() => { role: "tree"; onkeydown: (event: KeyboardEvent) => void; }
item_attrs(id: string) => { role: "treeitem"; "aria-level": number; "aria-expanded": boolean | undefined; "aria-selected": boolean; "aria-disabled": true | undefined; "data-selected": string | undefined; "data-expanded": string | undefined; tabindex: number | undefined; onfocus: () => void; onclick: (event: MouseEvent) => void; }

源码: packages/ui/src/behaviors/tree.svelte.ts:57

TreeCheckStrategy type

type TreeCheckStrategy = 'leaf' | 'trunk' | 'branch' | 'independent';

Tri-state checkbox cascade strategy for hierarchical trees.

源码: packages/ui/src/behaviors/tree.svelte.ts:31

TreeCheckedState type

type TreeCheckedState = boolean | 'indeterminate';

Tri-state checkbox value for one tree node.

源码: packages/ui/src/behaviors/tree.svelte.ts:34

TreeNode type

type TreeNode<T = unknown> = {
    readonly id: string;
    readonly label: string;
    readonly children?: readonly TreeNode<T>[];
    readonly disabled?: boolean;
    readonly data?: T;
};

One hierarchical node supplied to create_tree.

成员

名称类型说明
idstring
labelstring
children?readonly TreeNode<T>[]
disabled?boolean
data?T

源码: packages/ui/src/behaviors/tree.svelte.ts:10

TreeOptions type

type TreeOptions<T = unknown> = {
    /** Root tree nodes. */
    readonly nodes: () => readonly TreeNode<T>[];
    /** Initial expanded node ids. */
    readonly default_expanded?: readonly string[];
    /** Controlled expanded node ids. */
    readonly expanded?: () => readonly string[];
    /** Called when expanded node ids change. */
    readonly on_expanded_change?: (ids: readonly string[]) => void;
    /** Selection mode (default `'single'`). */
    readonly mode?: SelectionMode;
    /** Controlled selected ids. */
    readonly selected?: () => readonly string[];
    /** Called when selection changes. */
    readonly on_select?: (ids: readonly string[]) => void;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_tree.

成员

名称类型说明
nodes() => readonly TreeNode<T>[]

Root tree nodes.

default_expanded?readonly string[]

Initial expanded node ids.

expanded?() => readonly string[]

Controlled expanded node ids.

on_expanded_change?(ids: readonly string[]) => void

Called when expanded node ids change.

mode?SelectionMode

Selection mode (default 'single').

selected?() => readonly string[]

Controlled selected ids.

on_select?(ids: readonly string[]) => void

Called when selection changes.

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/tree.svelte.ts:37

TreePlace type

type TreePlace = {
    readonly target: string;
    readonly position: 'before' | 'inside' | 'after';
};

Drop placement relative to a target tree row.

成员

名称类型说明
targetstring
position'before' | 'inside' | 'after'

源码: packages/ui/src/behaviors/drag.svelte.ts:466

TreeReorder type

type TreeReorder = ReturnType<typeof create_tree_reorder>;

Return value of create_tree_reorder.

成员

名称类型说明
draggingstring | null
dropTreePlace | null
commit(id: string, place: TreePlace) => void
item(id: string) => Attachment<HTMLElement>
item_attrs(id: string) => { "data-dragging": string | undefined; "data-drop-position": "before" | "inside" | "after" | undefined; onkeydown: (event: KeyboardEvent) => void; }

源码: packages/ui/src/behaviors/drag.svelte.ts:491

TreeReorderOptions type

type TreeReorderOptions = {
    /** Visible pre-order tree rows. */
    readonly rows: () => readonly TreeReorderRow[];
    /** Invoked when a node (with its subtree) moves to `place`. */
    readonly on_move: (id: string, place: TreePlace) => void;
    /** Optional predicate forbidding drops into/around a target. */
    readonly can_drop?: (id: string, place: TreePlace) => boolean;
};

Options for create_tree_reorder.

成员

名称类型说明
rows() => readonly TreeReorderRow[]

Visible pre-order tree rows.

on_move(id: string, place: TreePlace) => void

Invoked when a node (with its subtree) moves to place.

can_drop?(id: string, place: TreePlace) => boolean

Optional predicate forbidding drops into/around a target.

源码: packages/ui/src/behaviors/drag.svelte.ts:481

TreeReorderRow type

type TreeReorderRow = {
    readonly id: string;
    readonly depth: number;
    readonly parent: string | null;
    readonly label?: string;
};

One flattened row accepted by create_tree_reorder.

成员

名称类型说明
idstring
depthnumber
parentstring | null
label?string

源码: packages/ui/src/behaviors/drag.svelte.ts:458

TriggerMatch type

type TriggerMatch = {
    readonly trigger: string;
    readonly query: string;
    readonly start: number;
    readonly end: number;
};

Active trigger match inside a text field.

成员

名称类型说明
triggerstring
querystring
startnumber
endnumber

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:348

TriggerMenu type

type TriggerMenu<T extends TriggerMenuItem = TriggerMenuItem> = ReturnType<typeof create_trigger_menu<T>>;

Return value of create_trigger_menu.

成员

名称类型说明
openboolean
matchTriggerMatch | null
itemsreadonly T[]
pathreadonly T[]
active_indexnumber
floating{ readonly x: number; readonly y: number; readonly side: import("./floating.svelte.js").FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: import("./floating.svelte.js").FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Att…
close() => void
select(item: T) => void
pop_level() => void
fieldAttachment<HTMLInputElement | HTMLTextAreaElement>
contentAttachment<HTMLElement>
input_attrs() => { "aria-expanded": boolean; "aria-haspopup": "listbox"; "aria-activedescendant": string | undefined; oninput: (event: Event) => void; onkeyup: (event: KeyboardEvent) => void; onkeydown: (event: KeyboardEvent) => void; }
option_attrs(item: T, index: number) => { id: string; role: "option"; "aria-selected": boolean; "aria-disabled": true | undefined; "data-highlighted": string | undefined; onpointerenter: () => void; onmousedown: (event: MouseEvent) => void; onclick: () => void; }

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:368

TriggerMenuItem type

type TriggerMenuItem = {
    readonly id: string;
    readonly label: string;
    readonly keywords?: string;
    readonly insert?: string;
    readonly disabled?: boolean;
    readonly children?: readonly TriggerMenuItem[];
};

One item offered by create_trigger_menu.

成员

名称类型说明
idstring
labelstring
keywords?string
insert?string
disabled?boolean
children?readonly TriggerMenuItem[]

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:338

TriggerMenuOptions type

type TriggerMenuOptions<T extends TriggerMenuItem = TriggerMenuItem> = {
    /** Trigger prefixes that open the menu (e.g. `['@', '/']`). */
    readonly triggers: readonly string[];
    /** Returns items for the active trigger & nested level stack. */
    readonly items: (trigger: string, query: string, path: readonly T[]) => readonly T[];
    /** Called when a leaf item is picked (receives item and replacement range). */
    readonly on_select: (item: T, match: TriggerMatch, insertText: string) => void;
    /** Optional semantic control registration for Norbius's `page` bridge. */
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_trigger_menu.

成员

名称类型说明
triggersreadonly string[]

Trigger prefixes that open the menu (e.g. ['@', '/']).

items(trigger: string, query: string, path: readonly T[]) => readonly T[]

Returns items for the active trigger & nested level stack.

on_select(item: T, match: TriggerMatch, insertText: string) => void

Called when a leaf item is picked (receives item and replacement range).

control?{ readonly id: string; readonly label?: string; }

Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:356

Typeahead type

type Typeahead = ReturnType<typeof create_typeahead>;

Return value of create_typeahead.

成员

名称类型说明
onkeydown(event: KeyboardEvent) => void
reset() => void
querystring

源码: packages/ui/src/behaviors/typeahead.svelte.ts:20

TypeaheadItem type

type TypeaheadItem = {
    key: string;
    text: string;
    disabled?: boolean;
};

One searchable item supplied to create_typeahead.

成员

名称类型说明
keystring
textstring
disabled?boolean

源码: packages/ui/src/behaviors/typeahead.svelte.ts:5

TypeaheadOptions type

type TypeaheadOptions = {
    /** Candidate items in visual order. */
    items: () => readonly TypeaheadItem[];
    /** Currently active key (search wraps starting after this item). */
    active?: () => string | undefined;
    /** Invoked with the matched item's key. */
    on_match: (key: string) => void;
    /** Buffer reset delay in ms (default `500`). */
    timeout_ms?: number;
};

Options for create_typeahead.

成员

名称类型说明
items() => readonly TypeaheadItem[]

Candidate items in visual order.

active?() => string | undefined

Currently active key (search wraps starting after this item).

on_match(key: string) => void

Invoked with the matched item's key.

timeout_ms?number

Buffer reset delay in ms (default 500).

源码: packages/ui/src/behaviors/typeahead.svelte.ts:8

UiHistory type

type UiHistory = ReturnType<typeof create_ui_history>;

Return value of create_ui_history.

成员

名称类型说明
entriesreadonly UiHistoryEntry[]
positionnumber
can_undoboolean
can_redoboolean
undo() => boolean
redo() => boolean
undo_source(source: ChangeSource) => number
destroy() => void

源码: packages/ui/src/behaviors/controls.svelte.ts:420

UiHistoryEntry type

type UiHistoryEntry = ControlChange & {
    readonly seq: number;
    readonly reverted?: boolean;
};

Recorded entry inside create_ui_history.

成员

名称类型说明
idstring
kindstring
label?string
keystring
previousunknown
valueunknown
sourceChangeSource
reasonstring
redacted?boolean
committedboolean
seqnumber
reverted?boolean

源码: packages/ui/src/behaviors/controls.svelte.ts:405

UiHistoryOptions type

type UiHistoryOptions = {
    readonly within?: Element | (() => Element | null | undefined);
    /** Only record state keys in this list (defaults to all keys). */
    readonly keys?: readonly string[];
    /** Coalesce consecutive edits to the same `(id, key, source)` within 500ms (default `true`). */
    readonly coalesce?: boolean;
};

Options for create_ui_history.

成员

名称类型说明
within?Element | (() => Element | null | undefined)
keys?readonly string[]

Only record state keys in this list (defaults to all keys).

coalesce?boolean

Coalesce consecutive edits to the same (id, key, source) within 500ms (default true).

源码: packages/ui/src/behaviors/controls.svelte.ts:411

UndoStack type

type UndoStack<T> = ReturnType<typeof create_undo_stack<T>>;

Return value of create_undo_stack.

成员

名称类型说明
currentT
can_undoboolean
can_redoboolean
lengthnumber
record(next: T, opts?: { readonly group?: string; readonly time?: number; }) => void
undo() => T
redo() => T
reset(value: T) => void

源码: packages/ui/src/behaviors/micro.svelte.ts:109

UndoStackOptions type

type UndoStackOptions = {
    /** Maximum history depth (default `100`). */
    readonly limit?: number;
    /** Coalescing window in ms for edits sharing the same `group` (default `500`). */
    readonly group_delay_ms?: number;
};

Options for create_undo_stack.

成员

名称类型说明
limit?number

Maximum history depth (default 100).

group_delay_ms?number

Coalescing window in ms for edits sharing the same group (default 500).

源码: packages/ui/src/behaviors/micro.svelte.ts:101

ViewportBehavior type

type ViewportBehavior = ReturnType<typeof create_viewport>;

Return value of create_viewport.

成员

名称类型说明
xnumber
ynumber
zoomnumber
panningboolean
transformstring
set_camera(next: Partial<ViewportCamera>) => void
zoom_at(factor: number, originX: number, originY: number) => void
reset() => void
surfaceAttachment<HTMLElement>

源码: packages/ui/src/behaviors/canvas.svelte.ts:528

ViewportCamera type

type ViewportCamera = {
    readonly x: number;
    readonly y: number;
    readonly zoom: number;
};

Camera state of a pan/zoom canvas viewport.

成员

名称类型说明
xnumber
ynumber
zoomnumber

源码: packages/ui/src/behaviors/canvas.svelte.ts:517

ViewportOptions type

type ViewportOptions = {
    readonly initial?: ViewportCamera;
    readonly min_zoom?: number;
    readonly max_zoom?: number;
    readonly on_change?: (camera: ViewportCamera) => void;
};

Options for create_viewport.

成员

名称类型说明
initial?ViewportCamera
min_zoom?number
max_zoom?number
on_change?(camera: ViewportCamera) => void

源码: packages/ui/src/behaviors/canvas.svelte.ts:520

ViewportState type

type ViewportState = {
    readonly width: number;
    readonly height: number;
    readonly offset_top: number;
    readonly offset_left: number;
    readonly scale: number;
    /** Estimated height in px occluded by an on-screen mobile keyboard (`0` on desktop). */
    readonly keyboard_height: number;
};

Live visual viewport & software keyboard metrics from bind_viewport.

成员

名称类型说明
widthnumber
heightnumber
offset_topnumber
offset_leftnumber
scalenumber
keyboard_heightnumber

Estimated height in px occluded by an on-screen mobile keyboard (0 on desktop).

源码: packages/ui/src/behaviors/platform.svelte.ts:8

primitives

Virtual type

type Virtual = ReturnType<typeof virtual_list>;

A windowed list: the slice of items to render, the spacers around it and the measure attachment.

成员

名称类型说明
onboolean
startnumber
endnumber
beforenumber

The top spacer's height.

afternumber

The bottom spacer's height.

slice<T>(items: readonly T[]) => readonly T[]

The rendered items; index j of the slice is item start + j.

anchor(el: HTMLElement) => () => void

On the top spacer: finds the clipping ancestors and follows every scroll and resize (one read per frame).

measure(key: string) => Attachment<Element>

On each rendered item: its height, margins included, cached under key.

reveal(index: number) => void

Scrolls the nearest scrolling ancestor (else the window) so item index shows; for keyboard focus on an unmounted row.

源码: packages/ui/src/primitives/virtual/virtual.svelte.ts:29

behaviors

VirtualAnchor type

type VirtualAnchor = {
    readonly x: number;
    readonly y: number;
} | {
    readonly getBoundingClientRect: () => VirtualRect;
};

Virtual anchor: either a { x, y } pointer coordinate or a getBoundingClientRect() provider.

源码: packages/ui/src/behaviors/floating.svelte.ts:23

primitives

VirtualOptions type

type VirtualOptions = {
    count: () => number;
    /** Stable identity of item `i` (its id): measured heights follow it. */
    key: (index: number) => string;
    /** An unmeasured item's height in px. */
    estimate: number;
    /** Render every item at or below this count (default 60). */
    threshold?: number;
    /** Items rendered beyond each edge of the visible band (default 8). */
    overscan?: number;
    /** Window the last visible rows while a bottom-origin viewport is latched to its tail. */
    tail?: () => boolean;
};

What virtual_list windows: the item count, each item's stable key, the estimated height, the threshold and the overscan.

成员

名称类型说明
count() => number
key(index: number) => string

Stable identity of item i (its id): measured heights follow it.

estimatenumber

An unmeasured item's height in px.

threshold?number

Render every item at or below this count (default 60).

overscan?number

Items rendered beyond each edge of the visible band (default 8).

tail?() => boolean

Window the last visible rows while a bottom-origin viewport is latched to its tail.

源码: packages/ui/src/primitives/virtual/virtual.svelte.ts:15

behaviors

VirtualRect type

type VirtualRect = {
    readonly left: number;
    readonly top: number;
    readonly right: number;
    readonly bottom: number;
    readonly width: number;
    readonly height: number;
};

Rect subset needed to position against a non-element virtual anchor.

成员

名称类型说明
leftnumber
topnumber
rightnumber
bottomnumber
widthnumber
heightnumber

源码: packages/ui/src/behaviors/floating.svelte.ts:13

WatchOptions type

type WatchOptions = {
    /** Skip the initial effect run and only invoke on subsequent changes (default `false`). */
    readonly lazy?: boolean;
    /** Stop reacting after the first invocation (default `false`). */
    readonly once?: boolean;
};

Options controlling whether watch skips its initial run (lazy) or only runs once (once).

成员

名称类型说明
lazy?boolean

Skip the initial effect run and only invoke on subsequent changes (default false).

once?boolean

Stop reacting after the first invocation (default false).

源码: packages/ui/src/behaviors/reactive.svelte.ts:6

WaterfallBehavior type

type WaterfallBehavior<T extends WaterfallItem = WaterfallItem> = ReturnType<typeof create_waterfall<T>>;

Return value of create_waterfall.

成员

名称类型说明
rowsimport("./tree.svelte.js").FlatTreeRow<T>[]
minnumber
maxnumber
view_startnumber
view_endnumber
tree{ readonly rows: import("./tree.svelte.js").FlatTreeRow<T>[]; readonly expanded: readonly string[]; readonly selected: readonly string[]; readonly active: string; expand: (id: string) => void; collapse: (id: string) => void; toggle_expand: (id: string) => void; is_expanded(id: string): boolean; is_selected: (key: string) => boolean; item: (key: string) => Attachment<HTMLElement>; root_attrs(): { …
bar_rect(item: WaterfallItem) => { readonly left_pct: number; readonly width_pct: number; }
zoom(start: number, end: number) => void
reset_zoom() => void

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1238

WaterfallItem type

type WaterfallItem = {
    readonly id: string;
    readonly label: string;
    readonly parent?: string | null;
    readonly start: number;
    readonly end: number;
};

One timed span item in create_waterfall.

成员

名称类型说明
idstring
labelstring
parent?string | null
startnumber
endnumber

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1221

WaterfallOptions type

type WaterfallOptions<T extends WaterfallItem = WaterfallItem> = {
    readonly items: () => readonly T[];
    readonly on_select?: (id: string) => void;
    readonly label?: string;
    readonly control?: {
        readonly id: string;
        readonly label?: string;
    };
};

Options for create_waterfall.

成员

名称类型说明
items() => readonly T[]
on_select?(id: string) => void
label?string
control?{ readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1230

act_on_control function

function act_on_control(id: string, action: string, args?: readonly unknown[]): boolean

Invokes a named semantic action on a registered control by id or label; returns whether it ran.

参数

名称类型说明
idstring
actionstring
args?readonly unknown[]

源码: packages/ui/src/behaviors/controls.svelte.ts:381

announce function

function announce(text: string, options?: AnnounceOptions): void

Announces text to assistive technologies. Repeating identical text still triggers a fresh reading by clearing the region before writing.

参数

名称类型说明
textstring
options?AnnounceOptions

源码: packages/ui/src/behaviors/announce.svelte.ts:61

aria_keyshortcuts function

function aria_keyshortcuts(spec: string, platform?: "mac" | "other"): string

Converts a shortcut spec into a WAI-ARIA aria-keyshortcuts attribute value (e.g. 'Meta+K' or 'Control+K').

参数

名称类型说明
specstring
platform?'mac' | 'other'

源码: packages/ui/src/behaviors/shortcuts.svelte.ts:104

bind_avoid_keyboard function

function bind_avoid_keyboard(options?: { readonly mode?: "padding" | "translate"; }): Attachment<HTMLElement>

Shifts a fixed bottom bar, composer or sheet above the mobile software keyboard using visualViewport keyboard-height measurements (padding-bottom or transform).

参数

名称类型说明
options?{ readonly mode?: 'padding' | 'translate'; }

源码: packages/ui/src/behaviors/platform.svelte.ts:80

bind_drag function

function bind_drag(options: BindDragOptions): Attachment<HTMLElement>

Pointer-capture drag attachment ({@attach bind_drag(...)}) with movement threshold, animation-frame batching and optional Escape cancellation.

参数

名称类型说明
optionsBindDragOptions
  • threshold?: number

    Movement in CSS px before on_start/on_move fire (default DRAG_THRESHOLD).

  • on_start?: (event: PointerEvent) => boolean | void

    Return false to reject starting the drag.

  • on_move: (sample: PointerSample) => void

    Called at most once per animation frame with latest pointer coordinates.

  • on_end?: (event: PointerEvent | KeyboardEvent, canceled: boolean) => void

    Called when the pointer lifts, cancels, or Escape aborts.

  • cancel_on_escape?: boolean

    Cancel active drag on Escape (default true).

  • stop_propagation?: boolean

    Stop pointerdown propagation so nested drag surfaces do not both capture the gesture.

  • disabled?: () => boolean

    Disable dragging reactively.

源码: packages/ui/src/behaviors/drag.svelte.ts:42

bind_drag_preview function

function bind_drag_preview(options: DragPreviewOptions): Attachment<HTMLElement>

Positions a custom floating drag-ghost element under the pointer without HTML5 drag ghost clipping.

参数

名称类型说明
optionsDragPreviewOptions
  • point: () => { readonly x: number; readonly y: number; } | null

    Reactive active drag coordinates (null when not dragging).

  • offset?: { readonly x: number; readonly y: number; }

    Offset in px relative to pointer (default { x: 12, y: 12 }).

源码: packages/ui/src/behaviors/platform.svelte.ts:304

bind_findable function

function bind_findable(options: FindableOptions): Attachment<HTMLElement>

Attachment keeping a closed panel discoverable by browser find-in-page (hidden="until-found"). When the user searches text inside the closed panel, on_reveal fires so the panel opens cleanly.

参数

名称类型说明
optionsFindableOptions
  • open: () => boolean

    Whether the panel is currently open/visible.

  • findable?: () => boolean

    Whether closed content remains findable via browser Ctrl/Cmd+F (default true).

  • on_reveal: (event: Event) => void

    Called when browser find-in-page matches text inside the closed panel (beforematch).

源码: packages/ui/src/behaviors/presence.svelte.ts:230

bind_hold function

function bind_hold(options: BindHoldOptions): Attachment<HTMLElement>

Long-press attachment ({@attach bind_hold(...)}) with movement tolerance, Escape/blur cancel and automatic click suppression after a completed hold.

参数

名称类型说明
optionsBindHoldOptions
  • delay?: number

    Hold duration in ms before on_hold fires (default 500).

  • tolerance?: number

    Max pointer drift in px before canceling (default 8).

  • keys?: readonly string[]

    Keys that start a keyboard hold (default [' ', 'Enter']).

  • on_start?: (details: { readonly event: PointerEvent | KeyboardEvent; readonly input: HoldInput; }) => void

    Called when press starts.

  • on_hold: (details: { readonly event: PointerEvent | KeyboardEvent; readonly input: HoldInput; }) => void

    Called once the press crosses delay.

  • on_end?: (details: { readonly event: Event; readonly input: HoldInput; readonly held: boolean; readonly canceled: boolean; }) => void

    Called when the press lifts or cancels.

  • disabled?: () => boolean

    Disable reactively.

源码: packages/ui/src/behaviors/micro.svelte.ts:220

bind_repeat function

function bind_repeat(options: BindRepeatOptions): Attachment<HTMLElement>

Press-and-hold repeating attachment ({@attach bind_repeat(...)}) for number-input steppers and scrub buttons. Fires once immediately, waits delay, then repeats every interval.

参数

名称类型说明
optionsBindRepeatOptions
  • on_step: (count: number) => void

    Called immediately on press and repeatedly while held.

  • on_end?: (count: number) => void

    Called when the repeating press stops.

  • delay?: number

    Delay before repeating begins in ms (default 400).

  • interval?: number

    Interval between repeated steps in ms (default 60).

  • disabled?: () => boolean

    Disable reactively.

源码: packages/ui/src/behaviors/micro.svelte.ts:351

bind_scroll_picker function

function bind_scroll_picker(options: ScrollPickerOptions): Attachment<HTMLElement>

Scroll-snap wheel picker attachment ({@attach bind_scroll_picker(...)}) that writes --picker-offset (-1..1 normalized distance from center) on each child option and reports the centered index on scroll settle.

参数

名称类型说明
optionsScrollPickerOptions
  • on_select: (index: number) => void

    Called when the centered option changes after scrolling settles.

  • orientation?: 'vertical' | 'horizontal'

    Scroll axis (default 'vertical').

源码: packages/ui/src/behaviors/canvas.svelte.ts:847

bind_viewport function

function bind_viewport(on_change?: (state: ViewportState) => void): Attachment<HTMLElement>

Tracks window.visualViewport resize/scroll changes and writes --viewport-height, --keyboard-height and --keyboard-inset CSS custom properties onto the bound element (or document.documentElement).

参数

名称类型说明
on_change?(state: ViewportState) => void

源码: packages/ui/src/behaviors/platform.svelte.ts:49

bridge_between function

function bridge_between(trigger: Rect, popup: Rect, pad?: number): (x: number, y: number) => boolean

Returns a point-in-corridor predicate spanning the convex hull of trigger and popup (padded slightly so hairline gaps never drop hover during diagonal transit).

参数

名称类型说明
triggerRect
popupRect
pad?number

源码: packages/ui/src/behaviors/hover-intent.svelte.ts:55

cell_bounds function

function cell_bounds(range: CellRange): CellBounds

Normalizes any CellRange into { top, left, bottom, right } inclusive bounds.

参数

名称类型说明
rangeCellRange
  • anchor: GridCell
  • end: GridCell

源码: packages/ui/src/behaviors/grid.svelte.ts:207

cells_to_text function

function cells_to_text(bounds: CellBounds, read: (cell: GridCell) => string): string

Serializes a 2D cell range to spreadsheet-compatible tab-separated text (TSV).

参数

名称类型说明
boundsCellBounds
  • top: number
  • left: number
  • bottom: number
  • right: number
read(cell: GridCell) => string

源码: packages/ui/src/behaviors/grid.svelte.ts:217

check_direction function

function check_direction(root: Element, expected: "ltr" | "rtl"): readonly PatternViolation[]

Verifies that an element resolves to the expected writing direction ('ltr' or 'rtl') via inherited dir attribute / computed style.

参数

名称类型说明
rootElement
expected'ltr' | 'rtl'

源码: packages/ui/src/behaviors/testing.ts:192

check_pattern function

function check_pattern(root: Element, pattern: AriaPattern): readonly PatternViolation[]

Audits a rendered DOM subtree against WAI-ARIA APG structural, naming and keyboard focus requirements for pattern. Returns an array of violations (empty means compliant).

参数

名称类型说明
rootElement
patternAriaPattern

源码: packages/ui/src/behaviors/testing.ts:59

color_scheme_of function

function color_scheme_of(): ResolvedColorScheme

Reads the operating system's current preferred color scheme.

源码: packages/ui/src/behaviors/platform.svelte.ts:159

color_scheme_script function

function color_scheme_script(storageKey: string): string

Generates a minimal inline script body to apply stored color scheme before first paint (no FOUC).

参数

名称类型说明
storageKeystring

源码: packages/ui/src/behaviors/platform.svelte.ts:233

contrast_ratio function

function contrast_ratio(a: RgbaColor, b: RgbaColor): number

Computes WCAG 2.1 contrast ratio (1..21) between two colors.

参数

名称类型说明
aRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number
bRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:957

create_accordion function

function create_accordion(options: AccordionOptions): { readonly open: readonly string[]; is_open(key: string): boolean; toggle: (key: string) => void; expand: (key: string) => void; collapse: (key: string) => void; item: (key: string) => import("svelte/attachments").Attachment<HTMLElement>; root_attrs: () => { onkeydown: (event: KeyboardEvent) => void; }; trigger_attrs(key: string): { type: "button"; id: string; "aria-expanded": boolean; "aria-controls": string; "data-state": "open" | "closed"; disabled: true | undefined; tabindex: number | undefined; onfocus: () => void; onclick: () => void; }; content_attrs(key: string): { id: string; role: "region"; "aria-labelledby": string; hidden: boolean; "data-state": "open" | "closed"; }; }

Headless composable accordion built on create_roving_focus + register_control.

参数

名称类型说明
optionsAccordionOptions
  • items: () => readonly string[]

    Item keys in visual order.

  • mode?: AccordionMode

    Single or multiple expanded sections (default 'single').

  • collapsible?: boolean

    In single mode, allow collapsing the only open item (default true).

  • open?: () => readonly string[]

    Controlled open keys; omit for internal state.

  • default_open?: readonly string[]

    Initial open keys when uncontrolled.

  • on_change?: (open: readonly string[]) => void

    Called whenever expanded keys change.

  • disabled?: (key: string) => boolean

    Disabled predicate per item key.

  • control?: { id: string; label?: string; }

    Optional semantic control id/label for Norbius's page bridge.

源码: packages/ui/src/behaviors/accordion.svelte.ts:37

create_area function

function create_area(options?: AreaOptions): { readonly value: AreaValue; readonly percent_x: number; readonly percent_y: number; readonly dragging: boolean; set: (next: AreaValue, commitNow?: boolean) => void; surface: Attachment<HTMLElement>; thumb_attrs(): { role: "slider"; tabindex: number; "aria-label": string | undefined; "aria-valuetext": string; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }

Headless 2D XY slider plane (e.g. color saturation/lightness picker or 2D joystick control).

参数

名称类型说明
options?AreaOptions

源码: packages/ui/src/behaviors/canvas.svelte.ts:143

create_async_options function

function create_async_options<T>(options: AsyncOptionsOptions<T>): { query: string; readonly items: readonly T[]; readonly status: AsyncOptionsStatus; readonly loading: boolean; readonly error: unknown; readonly has_more: boolean; set_query: (next: string, opts?: { immediate?: boolean; }) => void; load_more: () => void; reload: () => void; reset: () => void; cancel: () => void; }

Headless debounced, abortable, paginated async option loader.

参数

名称类型说明
optionsAsyncOptionsOptions<T>
  • load: (query: string, ctx: AsyncOptionsContext) => Promise<AsyncOptionsPage<T>>

    Fetches matching items for query and ctx.page, honoring ctx.signal.

  • initial_query?: string

    Initial query (default '').

  • debounce_ms?: number

    Typing debounce window in ms (default 200).

  • immediate?: boolean

    Fetch immediately for initial_query on mount (default false).

源码: packages/ui/src/behaviors/async-options.svelte.ts:48

create_auto_scroll function

function create_auto_scroll(options?: AutoScrollOptions): { update: (x: number, y: number) => void; stop: () => void; }

Scrolls the innermost scrollable container under a dragging pointer (falling back to the window) when the pointer approaches its edges.

参数

名称类型说明
options?AutoScrollOptions

源码: packages/ui/src/behaviors/drag.svelte.ts:184

create_calendar function

function create_calendar(options: CalendarOptions): { readonly placeholder: CalendarDate; readonly months: readonly CalendarMonth[]; readonly weekdays: readonly string[]; set_placeholder: (next: DateValue) => void; prev_month(): void; next_month(): void; reset_pending(): void; readonly focused: CalendarDate; focus_day: (target: CalendarDate) => void; day_ref(date: CalendarDate): Attachment<HTMLElement>; day_attrs(date: CalendarDate, month: CalendarDate): { role: "button"; tabindex: number; "data-value": string; "data-selected": string | undefined; "data-selection-start": string | undefined; "data-selection-end": string | undefined; "data-today": string | undefined; "data-outside-month": string | undefined; "data-disabled": string | undefined; "aria-disabled": true | undefined; "aria-selected": boolean; onfocus: () => void; onclick: () => void; onpointerenter: () => void; onkeydown: (e: KeyboardEvent) => void; }; }

Headless single-day and date-range calendar grid behavior over @internationalized/date. Builds localized month grids, weekday headers, prev/next month controls, range hover previews and keyboard Arrow/PageUp/PageDown day navigation.

参数

名称类型说明
optionsCalendarOptions
  • mode?: CalendarMode | (() => CalendarMode)

    Single-day or date-range selection mode (default 'single').

  • value?: () => DateValue | undefined

    Selected single date when mode === 'single'.

  • range?: () => CalendarRange

    Selected range when mode === 'range'.

  • on_select?: (date: DateValue) => void

    Called on single-day selection.

  • on_range_change?: (range: CalendarRange) => void

    Called when range selection updates (with { start, end }).

  • placeholder?: () => DateValue | undefined

    Controlled visible anchor month.

  • on_placeholder_change?: (next: DateValue) => void

    Called when the visible month changes.

  • number_of_months?: () => number

    Number of side-by-side months to build (default 1).

  • locale?: () => string | undefined

    BCP-47 locale for weekday order and names (default 'en-US').

  • min?: () => DateValue | undefined

    Minimum selectable date.

  • max?: () => DateValue | undefined

    Maximum selectable date.

  • disabled?: () => boolean

    Disabled state.

源码: packages/ui/src/behaviors/date-time.svelte.ts:648

function create_carousel(options: CarouselOptions): { readonly index: number; readonly count: number; readonly can_prev: boolean; readonly can_next: boolean; readonly paused: boolean; go_to: (next: number) => void; next: () => void; prev: () => void; set_paused(p: boolean): void; root: Attachment<HTMLElement>; track: Attachment<HTMLElement>; root_attrs(): { role: "region"; "aria-roledescription": string; "aria-label": string; onpointerenter: () => boolean; onpointerleave: () => boolean; onfocusin: () => boolean; onfocusout: () => boolean; onkeydown: (event: KeyboardEvent) => void; }; slide_attrs(i: number): { role: "group"; "aria-roledescription": string; "aria-label": string; "aria-hidden": true | undefined; "data-active": string | undefined; }; dot_attrs(i: number): { type: "button"; "aria-label": string; "aria-current": "true" | undefined; "data-active": string | undefined; onclick: () => void; }; }

Accessible slide carousel (aria-roledescription="carousel") with Arrow/Home/End navigation, optional looping, indicator dots, autoplay that pauses on hover/focus/reduced-motion, and control registration.

参数

名称类型说明
optionsCarouselOptions
  • count: () => number
  • index?: () => number
  • default_index?: number
  • on_change?: (index: number) => void
  • loop?: boolean
  • autoplay_ms?: number
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:246

create_cell_range function

function create_cell_range(options: CellRangeOptions): { readonly range: CellRange | null; readonly bounds: CellBounds | null; readonly dragging: boolean; start: (cell: GridCell) => void; extend: (to: GridCell, from?: GridCell, notify?: boolean) => void; select_row: (row: number) => void; select_col: (col: number) => void; clear: () => void; contains: (cell: GridCell) => boolean; to_text(read: (cell: GridCell) => string): string; cell_attrs(cell: GridCell): { "aria-selected": boolean; "data-in-range": string | undefined; onpointerdown: (event: PointerEvent) => void; onpointerenter: () => void; }; }

Rectangular spreadsheet cell-range selection with pointer drag painting, Shift-click/arrow extension, Ctrl+Space column / Shift+Space row selection, TSV copy/paste and screen-reader announcements.

参数

名称类型说明
optionsCellRangeOptions
  • rows: () => number

    Total row count.

  • cols: () => number

    Total column count.

  • range?: () => CellRange | null

    Controlled range; omit for internal state.

  • on_change?: (range: CellRange | null) => void

    Called when the selected cell range changes.

  • message?: (bounds: CellBounds) => string

    Optional live-region message formatter on range updates.

源码: packages/ui/src/behaviors/grid.svelte.ts:259

create_checkbox_group function

function create_checkbox_group(options: CheckboxGroupOptions): { readonly checked: readonly string[]; readonly all_state: boolean | "indeterminate"; is_checked(key: string): boolean; toggle: (key: string) => void; toggle_all: () => void; group_attrs(): { role: "group"; "aria-label": string | undefined; }; all_attrs(): { type: "checkbox"; checked: boolean; "aria-checked": boolean | "mixed"; onchange: () => void; }; item_attrs(key: string): { type: "checkbox"; checked: boolean; disabled: true | undefined; onchange: () => void; }; }

Headless flat checkbox group with tri-state Select All parent (true | false | 'indeterminate') and Norbius control registration.

参数

名称类型说明
optionsCheckboxGroupOptions
  • items: () => readonly string[]

    All selectable item keys.

  • value?: () => readonly string[]

    Controlled checked keys; omit for internal state.

  • default_value?: readonly string[]

    Initial checked keys when uncontrolled.

  • on_change?: (next: readonly string[]) => void

    Called when checked keys change.

  • disabled?: (key: string) => boolean

    Per-item disabled predicate.

  • label?: string

    Accessible label for the group.

  • control?: { readonly id: string; readonly label?: string; }

    Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:627

create_clipboard function

function create_clipboard(options: ClipboardOptions): { readonly copied: boolean; copy: (override?: string) => Promise<boolean>; reset(): void; }

Headless clipboard copy behavior with transient copied indicator and embedded-frame fallback.

参数

名称类型说明
optionsClipboardOptions
  • text: string | (() => string)

    Text to copy (reactive getter or static string).

  • timeout_ms?: number

    How long copied stays true in ms (default 1500).

  • on_copy?: (ok: boolean, value: string) => void

    Optional callback after a copy attempt completes.

源码: packages/ui/src/behaviors/clipboard.svelte.ts:39

create_color_picker function

function create_color_picker(options?: ColorPickerOptions): { readonly value: string; readonly rgba: RgbaColor; readonly hsv: HsvaColor; readonly plane: { readonly value: import("./canvas.svelte.js").AreaValue; readonly percent_x: number; readonly percent_y: number; readonly dragging: boolean; set: (next: import("./canvas.svelte.js").AreaValue, commitNow?: boolean) => void; surface: Attachment<HTMLElement>; thumb_attrs(): { role: "slider"; tabindex: number; "aria-label": string | undefined; "aria-valuetext": string; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }; readonly hue: { readonly value: number; readonly values: readonly number[]; readonly percent: number; readonly percents: number[]; readonly dragging: boolean; readonly active_thumb: number; set(next: number, index?: number): void; track: Attachment<HTMLElement>; thumb_attrs(index?: number): { role: "slider"; "aria-orientation": "horizontal" | "vertical"; "aria-label": string | undefined; "aria-valuemin": number; "aria-valuemax": number; "aria-valuenow": number; "aria-disabled": true | undefined; tabindex: number | undefined; "data-dragging": string | undefined; onfocus: () => void; onkeydown: (event: KeyboardEvent) => void; }; }; readonly alpha: { readonly value: number; readonly values: readonly number[]; readonly percent: number; readonly percents: number[]; readonly dragging: boolean; readonly active_thumb: number; set(next: number, index?: number): void; track: Attachment<HTMLElement>; thumb_attrs(index?: number): { role: "slider"; "aria-orientation": "horizontal" | "vertical"; "aria-label": string | undefined; "aria-valuemin": number; "aria-valuemax": number; "aria-valuenow": number; "aria-disabled": true | undefined; tabindex: number | undefined; "data-dragging": string | undefined; onfocus: () => void; onkeydown: (event: KeyboardEvent) => void; }; }; set_text: (text: string) => boolean; set_rgba: (next: RgbaColor) => void; }

Headless color picker composing 2D saturation/brightness create_area, hue & alpha create_slider, color parsing/formatting and Norbius control registration.

参数

名称类型说明
options?ColorPickerOptions

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:993

create_color_scheme function

function create_color_scheme(options?: ColorSchemeOptions): { readonly preference: ColorSchemePreference; readonly system: ResolvedColorScheme; readonly resolved: ResolvedColorScheme; set: (next: ColorSchemePreference) => void; }

Reactive color-scheme preference ('light' | 'dark' | 'system') synced with OS and optional storage.

参数

名称类型说明
options?ColorSchemeOptions

源码: packages/ui/src/behaviors/platform.svelte.ts:172

create_connect function

function create_connect(options: ConnectOptions): { readonly draft: ConnectDraft | null; readonly pending_from: string | null; port: (id: string) => Attachment<HTMLElement>; port_attrs: (id: string) => { tabindex: number; "data-connecting": string | undefined; "data-connect-target": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }

Headless node-graph port wiring behavior (pointer drag from port to port + keyboard Enter pick/connect).

参数

名称类型说明
optionsConnectOptions
  • can_connect?: (from: string, to: string) => boolean
  • on_connect: (from: string, to: string) => void

源码: packages/ui/src/behaviors/canvas.svelte.ts:640

function create_cookie_storage(options?: CookieStorageOptions): { get: (name: string) => string | null; set: (name: string, value: string) => void; remove: (name: string) => void; }

Simple browser cookie storage adapter (get, set, remove) for SSR-readable UI preferences.

参数

名称类型说明
options?CookieStorageOptions

源码: packages/ui/src/behaviors/platform.svelte.ts:406

create_date_field function

function create_date_field(options: DateFieldOptions): { readonly segments: readonly DateTimeSegment[]; segment_ref(part: SegmentPart): Attachment<HTMLElement>; segment_attrs(seg: DateTimeSegment): { "aria-hidden": true; "data-segment": "literal"; role?: undefined; tabindex?: undefined; "aria-label"?: undefined; "aria-valuemin"?: undefined; "aria-valuemax"?: undefined; "aria-valuenow"?: undefined; "aria-valuetext"?: undefined; "aria-disabled"?: undefined; onkeydown?: undefined; onblur?: undefined; } | { role: "spinbutton"; tabindex: number | undefined; "data-segment": "day" | "month" | "year" | "hour" | "minute"; "aria-label": "day" | "month" | "year" | "hour" | "minute"; "aria-valuemin": number; "aria-valuemax": number; "aria-valuenow": number | undefined; "aria-valuetext": string; "aria-disabled": true | undefined; onkeydown: (e: KeyboardEvent) => void; onblur: () => void; "aria-hidden"?: undefined; }; }

Headless locale-aware segmented date/instant field behavior. Supports multi-digit buffered typing (waiting for the full digit count before committing), ArrowUp/Down stepping, ArrowLeft/Right segment focus and Backspace clearing.

参数

名称类型说明
optionsDateFieldOptions
  • value: () => DateValue | undefined

    Controlled DateValue getter.

  • on_change: (next: DateValue | undefined) => void

    Called when the complete date/time value changes (or clears to undefined).

  • granularity?: () => 'day' | 'hour' | 'minute'

    Editing precision: 'day' (date only), 'hour' (date + hour), or 'minute' (date + hour + minute).

  • locale?: () => string | undefined

    BCP-47 locale for segment order and separators (default 'en-US').

  • disabled?: () => boolean

    Disabled state.

  • min?: () => DateValue | undefined

    Minimum allowed date value.

  • max?: () => DateValue | undefined

    Maximum allowed date value.

源码: packages/ui/src/behaviors/date-time.svelte.ts:222

create_disclosure function

function create_disclosure(options?: DisclosureOptions): { readonly open: boolean; readonly disabled: boolean; readonly state: "open" | "closed"; set_open: (next: boolean) => void; toggle: () => void; show: () => void; hide: () => void; trigger_attrs(): { type: "button"; "aria-expanded": boolean; "aria-controls": string; "data-state": "open" | "closed"; disabled: true | undefined; onclick: () => void; }; content_attrs(): { id: string; hidden: boolean; "data-state": "open" | "closed"; }; }

Headless disclosure state + ARIA attribute getters (trigger_attrs, content_attrs). Composes directly onto any button/panel without wrapper elements.

参数

名称类型说明
options?DisclosureOptions

源码: packages/ui/src/behaviors/disclosure.svelte.ts:27

create_dismiss function

function create_dismiss(options: DismissOptions): { readonly depth: number; readonly topmost: boolean; surface: Attachment<HTMLElement>; }

Headless LIFO overlay dismissal behavior. Attach surface to the floating/dialog element so nested overlays dismiss one layer at a time on Escape or outside click.

参数

名称类型说明
optionsDismissOptions
  • open: () => boolean

    Whether this layer is currently active/open.

  • on_dismiss: (reason: DismissReason, event: KeyboardEvent | PointerEvent) => void

    Called when the topmost layer should close.

  • escape?: boolean | (() => boolean)

    Close on Escape key (default true).

  • outside?: boolean | (() => boolean)

    Close on pointerdown outside the attached surface (default true).

  • ignore?: () => readonly (Element | null | undefined)[]

    Extra elements treated as inside (e.g. an anchor trigger button).

源码: packages/ui/src/behaviors/dismiss.svelte.ts:43

create_drawer function

function create_drawer(options?: DrawerOptions): { readonly open: boolean; readonly dragging: boolean; readonly offset: number; readonly snap_index: number; readonly snap_fraction: number; set_open: (next: boolean) => void; set_snap: (idx: number) => void; surface: Attachment<HTMLElement>; handle: Attachment<HTMLElement>; surface_attrs(): { role: "dialog"; "aria-modal": true | undefined; "aria-label": string | undefined; "data-side": DrawerSide; "data-dragging": string | undefined; "data-state": "open" | "closed"; style: string | undefined; }; }

Swipeable snap-point drawer / mobile bottom sheet with rubber-band overdrag, velocity fling dismissal, LIFO Escape/backdrop dismiss, modal focus trap + inert background and control registration.

参数

名称类型说明
options?DrawerOptions

源码: packages/ui/src/behaviors/motion.svelte.ts:128

create_field function

function create_field(options?: FieldBehaviorOptions): { readonly id: string; readonly invalid: boolean; readonly error: string | undefined; label_attrs(): { for: string; "data-required": string | undefined; "data-invalid": string | undefined; "data-disabled": string | undefined; }; control_attrs(): { id: string; "aria-describedby": string | undefined; "aria-invalid": true | undefined; "aria-required": true | undefined; disabled: true | undefined; readonly: true | undefined; }; description_attrs(): { id: string; }; error_attrs(): { id: string; role: "alert"; }; }

Headless field ARIA wiring (label_attrs, control_attrs, description_attrs, error_attrs).

参数

名称类型说明
options?FieldBehaviorOptions

源码: packages/ui/src/behaviors/field.svelte.ts:28

create_file_dropzone function

function create_file_dropzone(options: FileDropzoneOptions): { readonly dragging: boolean; readonly disabled: boolean; open(): void; process: (list: FileList | readonly File[]) => void; zone: Attachment<HTMLElement>; input: Attachment<HTMLInputElement>; input_attrs(): { type: "file"; accept: string | undefined; multiple: boolean | undefined; disabled: true | undefined; onchange: (event: Event) => void; }; }

Headless file dropzone & batch validator: depth-counted drag-over state (zero child flicker), accept MIME/extension, max size and max count filtering, and file-input bridge.

参数

名称类型说明
optionsFileDropzoneOptions
  • accept?: readonly string[]

    Accepted MIME types or extensions (e.g. ['image/*', '.pdf']).

  • max_bytes?: number

    Maximum file size in bytes.

  • max_files?: number

    Maximum number of files accepted in one drop/selection (default unlimited).

  • disabled?: () => boolean

    Disabled state.

  • on_files: (result: { readonly accepted: readonly File[]; readonly rejected: readonly RejectedFile[]; }) => void

    Called with validated accepted and rejected files.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:764

create_floating function

function create_floating(options: FloatingOptions): { readonly x: number; readonly y: number; readonly side: FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Attachment<HTMLElement>; }

Headless anchor-relative floating behavior with flip/shift collision avoidance, virtual anchors, --available-height/--available-width CSS variables and LIFO dismiss.

参数

名称类型说明
optionsFloatingOptions
  • open: () => boolean

    Whether the floating surface is open.

  • on_dismiss?: (reason: DismissReason) => void

    Called when Escape or an outside pointer press dismisses the surface.

  • anchor?: () => FloatingAnchor | null

    Optional reactive anchor element or virtual anchor getter.

  • side?: FloatingSide | (() => FloatingSide)

    Preferred side relative to the anchor (default 'bottom').

  • align?: FloatingAlign | (() => FloatingAlign)

    Cross-axis alignment relative to the anchor (default 'center').

  • side_offset?: number | (() => number)

    Gap between anchor and floating surface in px (default 4).

  • align_offset?: number | (() => number)

    Shift along the cross axis in px (default 0).

  • padding?: number | (() => number)

    Viewport edge padding in px (default 8).

  • flip?: boolean | (() => boolean)

    Flip to the opposite side when viewport room is insufficient (default true).

  • escape?: boolean | (() => boolean)

    Close on Escape key (default true).

  • outside?: boolean | (() => boolean)

    Close on outside pointer press (default true).

源码: packages/ui/src/behaviors/floating.svelte.ts:117

create_focus_recovery function

function create_focus_recovery<T = undefined>(options: FocusRecoveryOptions<T>): { item: (key: string, data?: T) => Attachment<HTMLElement>; }

Tracks focus across dynamically mounted items ({@attach recovery.item(key, data)}). When the currently focused item unmounts, fallback runs after removal settles and restores keyboard focus.

参数

名称类型说明
optionsFocusRecoveryOptions<T>
  • fallback: (lost: LostFocus<T>) => HTMLElement | null | undefined

    Returns the next element to focus when a bound item unmounts with focus, or null/undefined.

源码: packages/ui/src/behaviors/focus-recovery.svelte.ts:29

create_focus_trap function

function create_focus_trap(options: FocusTrapOptions): { container: Attachment<HTMLElement>; }

Headless focus trap + focus restoration + optional modal inert_outside & ref-counted lock_scroll attachment ({@attach trap.container}).

参数

名称类型说明
optionsFocusTrapOptions
  • active: () => boolean

    Whether focus trapping is active.

  • auto_focus?: boolean | (() => boolean)

    Automatically move focus into the container when activated (default true).

  • restore_focus?: boolean | (() => boolean)

    Restore focus to the previously active element on close (default true).

  • trap?: boolean | (() => boolean)

    Keep Tab / focusin strictly contained inside the container (default true).

  • modal?: boolean | (() => boolean)

    Mark background siblings inert while active (default false; set true on modal dialogs).

  • prevent_scroll?: boolean | (() => boolean)

    Apply ref-counted document scroll lock while active (default false).

  • topmost?: () => boolean

    Optional predicate gating focus-trap listeners to only the topmost stacked layer.

  • on_open_auto_focus?: (event: Event) => void

    Cancelable hook invoked before initial autofocus runs.

  • on_close_auto_focus?: (event: Event) => void

    Cancelable hook invoked before focus returns to the previous element on close.

  • on_focus_outside?: (event: FocusEvent) => void

    Called when focus escapes outside the container while active.

源码: packages/ui/src/behaviors/focus-trap.svelte.ts:57

create_grid_focus function

function create_grid_focus(options: GridFocusOptions): { readonly active: GridCell | null; focus: (cell: GridCell, shift?: boolean) => void; cell(cell: GridCell): Attachment<HTMLElement>; grid_attrs(): { role: "grid"; "aria-rowcount": number; "aria-colcount": number; onkeydown: (event: KeyboardEvent) => void; }; cell_attrs(cell: GridCell): { role: "gridcell"; "aria-rowindex": number; "aria-colindex": number; "aria-disabled": true | undefined; "data-active": string | undefined; tabindex: number | undefined; onfocus: () => void; }; }

Headless WAI-ARIA 2D grid roving focus manager supporting Arrow keys (RTL-aware), Home/End, Ctrl/Cmd+Home/End, PageUp/PageDown and virtualized row reveal.

参数

名称类型说明
optionsGridFocusOptions
  • rows: () => number

    Total row count.

  • cols: () => number

    Total column count.

  • active?: () => GridCell | null

    Controlled active cell; omit for internal state.

  • on_move?: (cell: GridCell, details: { readonly from: GridCell | null; readonly shift: boolean; }) => void

    Called whenever the active cell moves.

  • page_size?: number | (() => number)

    Rows skipped by PageUp / PageDown (default 10).

  • disabled?: (cell: GridCell) => boolean

    Skip cells matching this predicate.

  • reveal?: (cell: GridCell) => void

    Scroll an unrendered virtualized cell into view before focusing.

源码: packages/ui/src/behaviors/grid.svelte.ts:51

create_hover_card function

function create_hover_card(options?: HoverCardOptions): { readonly open: boolean; readonly present: boolean; readonly floating: { readonly x: number; readonly y: number; readonly side: FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: import("./floating.svelte.js").FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Attachment<HTMLElement>; }; set_open: (next: boolean) => void; trigger: Attachment<HTMLElement>; content: Attachment<HTMLElement>; trigger_attrs(): { "aria-expanded": boolean; onpointerenter: (e: PointerEvent) => void; onpointerleave: (e: PointerEvent) => void; onfocus: () => void; onblur: () => void; }; content_attrs(): { "data-state": "open" | "closed"; style: string; onpointerenter: (e: PointerEvent) => void; onpointerleave: (e: PointerEvent) => void; }; }

Rich non-modal hover preview card composing create_hover_intent, create_floating, create_presence and Escape dismissal (pointer safe-corridor keeps the card open while moving into it).

参数

名称类型说明
options?HoverCardOptions

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:692

create_hover_intent function

function create_hover_intent(options: HoverIntentOptions): { enter: (event?: PointerEvent, isTrigger?: boolean) => void; leave: (event?: PointerEvent) => void; clear: () => void; open_now: () => void; close_now: () => void; }

Headless hover-intent manager with safe-polygon pointer corridor and warm-group delay sharing.

参数

名称类型说明
optionsHoverIntentOptions
  • trigger: () => HTMLElement | null | undefined

    Trigger element getter.

  • popup: () => HTMLElement | null | undefined

    Popup element getter.

  • open: () => boolean

    Whether the popup is currently open.

  • on_open: () => void

    Opens the popup.

  • on_close: () => void

    Closes the popup.

  • open_delay?: number | (() => number)

    Open delay in ms when cold (default 120).

  • close_delay?: number | (() => number)

    Close delay in ms after leaving the safe corridor (default 80).

  • group?: string | null

    Shared warm-group key (default 'tooltip'; pass null to opt out).

  • warm_ms?: number

    Warm window in ms during which sibling hovers open immediately (default 250).

  • hoverable?: boolean | (() => boolean)

    Allow pointer to travel into popup content without closing (default true).

源码: packages/ui/src/behaviors/hover-intent.svelte.ts:121

create_image_cropper function

function create_image_cropper(options?: ImageCropperOptions): { readonly crop: CropRect; readonly zoom: number; readonly rotation: number; readonly mover: { readonly dragging: boolean; handle: Attachment<HTMLElement>; handle_attrs(): { tabindex: number; "aria-label": string | undefined; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }; readonly resizer: { readonly dragging: boolean; handle_attrs: (mode: "x" | "y" | "xy", label?: string) => { role: "separator"; tabindex: number; "aria-label": string | undefined; "data-dragging": string | undefined; onpointerdown: (down: PointerEvent) => void; onkeydown: (event: KeyboardEvent) => void; }; }; set_crop: (next: CropRect) => void; set_zoom: (next: number) => void; rotate: (deg?: number) => void; pixel_crop(naturalWidth: number, naturalHeight: number): { x: number; y: number; width: number; height: number; }; }

Headless image cropper with aspect-locked move & resize, zoom, rotation, pixel-crop export and Norbius control registration.

参数

名称类型说明
options?ImageCropperOptions

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1110

create_inline_edit function

function create_inline_edit(options: InlineEditOptions): { readonly editing: string | null; draft: string; is_editing(id: string): boolean; begin: (id: string, reason: InlineEditReason, initial?: string, origin?: HTMLElement | null) => void; commit: (reason?: InlineEditReason) => boolean; cancel: (reason?: InlineEditReason) => void; input: Attachment<HTMLInputElement | HTMLTextAreaElement>; cell_attrs(id: string): { "data-editing": string | undefined; ondblclick: (event: MouseEvent) => void; onkeydown: (event: KeyboardEvent) => void; }; input_attrs(): { value: string; oninput: (event: Event) => void; onkeydown: (event: KeyboardEvent) => void; onblur: () => void; }; }

Headless edit-in-place behavior for table cells, card titles and tree labels: Enter/F2/double-click edits preserving value, printable key replaces value, Enter/blur/Tab commits, Escape reverts and focus restores to the originating cell.

参数

名称类型说明
optionsInlineEditOptions
  • value: (id: string) => string

    Reads the current text for id when editing starts.

  • commit: (id: string, text: string, reason: InlineEditReason) => boolean | void

    Persists the edited text; return false to keep editing (e.g. validation error).

  • disabled?: (id: string) => boolean

    Optional disabled predicate per id.

  • on_tab?: (id: string, direction: 1 | -1) => void

    Called when Tab commits so an enclosing grid can advance to the next/previous cell.

源码: packages/ui/src/behaviors/grid.svelte.ts:394

create_input_history function

function create_input_history<T = string>(options: InputHistoryOptions<T>): { readonly index: number | null; readonly browsing: boolean; onkeydown: (event: KeyboardEvent) => void; reset: () => void; }

Terminal / chat-composer ArrowUp & ArrowDown history recall that preserves the user's unsent draft and only triggers when the caret sits on the first (ArrowUp) or last (ArrowDown) line.

参数

名称类型说明
optionsInputHistoryOptions<T>
  • entries: () => readonly T[]

    Past entries, oldest first.

  • read: () => T

    Reads the current composer value.

  • write: (value: T, event: KeyboardEvent) => boolean | void

    Writes a recalled value into the composer; return false to cancel navigation.

  • at_edge?: (direction: 'up' | 'down', event: KeyboardEvent) => boolean

    Custom edge detector; defaults to first/last line of <textarea> or anywhere in <input>.

源码: packages/ui/src/behaviors/micro.svelte.ts:40

create_lasso function

function create_lasso(options: LassoOptions): { readonly rect: LassoRect | null; readonly active: boolean; surface: Attachment<HTMLElement>; item: (key: string) => Attachment<HTMLElement>; }

Headless marquee / rubber-band drag selection over spatially positioned items.

参数

名称类型说明
optionsLassoOptions
  • on_change: (keys: readonly string[], rect: LassoRect) => void

    Called continuously as the marquee rectangle changes with intersecting item keys.

  • on_commit?: (keys: readonly string[]) => void

    Called when the marquee drag finishes.

源码: packages/ui/src/behaviors/canvas.svelte.ts:440

create_listbox function

function create_listbox<T extends ListboxItem = ListboxItem>(options: ListboxOptions<T>): { readonly id: string; query: string; readonly items: readonly T[]; readonly active: string; readonly active_id: string | undefined; readonly selected: readonly string[]; readonly count: number; is_selected: (key: string) => boolean; choose: (key: string) => void; toggle: (key: string) => void; toggle_all: () => void; clear: () => void; focus: (key: string) => void; highlight: (key: string) => void; activate_active(): void; item: (key: string) => import("svelte/attachments").Attachment<HTMLElement>; input_attrs(open?: boolean): { role: "combobox"; "aria-autocomplete": "list"; "aria-expanded": boolean; "aria-controls": string; "aria-activedescendant": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; list_attrs(): { id: string; role: "listbox"; "aria-multiselectable": true | undefined; onkeydown: (event: KeyboardEvent) => void; }; option_attrs(value: string): { id: string; role: "option"; "aria-selected": boolean; "aria-disabled": true | undefined; "data-selected": string | undefined; "data-highlighted": string | undefined; tabindex: number | undefined; onfocus: (() => void) | undefined; onpointerdown: ((event: PointerEvent) => void) | undefined; onpointermove: () => void; onclick: (event: MouseEvent) => void; }; }

Headless composable listbox combining create_selection, create_roving_focus (or virtual aria-activedescendant highlighting), create_typeahead and live query filtering.

参数

名称类型说明
optionsListboxOptions<T>
  • items: () => readonly T[]

    All items in visual order.

  • mode?: SelectionMode | (() => SelectionMode)

    Selection mode (default 'single').

  • focus?: ListboxFocusMode

    Focus strategy: 'dom' (default) or 'virtual' (aria-activedescendant).

  • selected?: () => readonly string[]

    Controlled selected values; omit for internal state.

  • default_selected?: readonly string[]

    Initial selected values when uncontrolled.

  • on_change?: (values: readonly string[]) => void

    Called when selection changes.

  • on_activate?: (item: T) => void

    Called when an item is explicitly activated (Enter / click in single mode).

  • filter?: false | ((item: T, query: string) => boolean)

    Optional custom filter; defaults to case-insensitive substring match on label + keywords. Pass false for externally filtered/async lists.

  • typeahead?: boolean

    Enable incremental typeahead when not typing in a search input (default true in 'dom' mode, false in 'virtual' mode).

  • loop?: boolean

    Wrap arrow navigation at list ends (default true).

  • id?: string

    Optional stable id prefix for aria-controls / aria-activedescendant.

示例

const lb = create_listbox({
  items: () => items.map((i) => ({ value: i.id, label: i.title })),
  on_activate: (item) => openItem(item.value)
});
// <input bind:value={lb.query} />
// <div {...lb.list_attrs()}>
//   {#each lb.items as item (item.value)}
//     <div {...lb.option_attrs(item.value)}>{item.label}</div>
//   {/each}
// </div>

源码: packages/ui/src/behaviors/listbox.svelte.ts:71

create_menu function

function create_menu<T extends MenuItem = MenuItem>(options: MenuOptions<T>): { readonly open: boolean; readonly active: string; readonly floating: { readonly x: number; readonly y: number; readonly side: FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: import("./floating.svelte.js").FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Attachment<HTMLElement>; }; open_at: (point: { x: number; y: number; }) => void; open_menu: () => void; close: () => void; toggle: () => void; trigger: Attachment<HTMLElement>; content: Attachment<HTMLElement>; context_area: Attachment<HTMLElement>; item: (key: string) => Attachment<HTMLElement>; trigger_attrs(): { type: "button"; "aria-haspopup": "menu"; "aria-expanded": boolean; "aria-controls": string | undefined; "data-state": "open" | "closed"; onclick: () => void; onkeydown: (event: KeyboardEvent) => void; }; menu_attrs(): { id: string; role: "menu"; "aria-label": string | undefined; "data-state": "open" | "closed"; "data-side": FloatingSide; style: string; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(id: string): { role: "menuitem" | "menuitemcheckbox" | "menuitemradio"; "aria-disabled": true | undefined; "aria-checked": boolean | undefined; "data-highlighted": string | undefined; "data-disabled": string | undefined; tabindex: number | undefined; onfocus: () => void; onpointermove: () => void; onclick: (event: MouseEvent) => void; }; }

Headless WAI-ARIA menu & context-menu behavior built on create_floating, create_roving_focus and create_typeahead.

参数

名称类型说明
optionsMenuOptions<T>
  • items: () => readonly T[]

    Ordered menu items.

  • open?: () => boolean

    Controlled open state; omit for internal state.

  • on_open_change?: (open: boolean) => void

    Called when open state changes.

  • on_select?: (item: T) => void

    Called when any enabled menu item is activated.

  • close_on_select?: boolean

    Close the menu after selecting a regular menuitem (default true).

  • side?: FloatingSide

    Preferred side relative to trigger (default 'bottom').

  • align?: FloatingAlign

    Cross-axis alignment relative to trigger (default 'start').

  • label?: string

    Accessible name for the menu.

  • control?: { readonly id: string; readonly label?: string; }

    Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/menu.svelte.ts:51

create_menubar function

function create_menubar(options: MenubarOptions): { readonly open_menu: string | null; is_open(id: string): boolean; open(id: string): void; close(): void; root: Attachment<HTMLElement>; item: (key: string) => Attachment<HTMLElement>; root_attrs(): { role: "menubar"; "aria-label": string; onkeydown: (event: KeyboardEvent) => void; }; trigger_attrs(id: string): { type: "button"; role: "menuitem"; "aria-haspopup": "menu"; "aria-expanded": boolean; "data-state": "open" | "closed"; tabindex: number | undefined; onfocus: () => void; onclick: () => void; onpointerenter: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Desktop application role="menubar" coordinator: horizontal roving focus across top-level menu triggers, hover-switch when any menu is open, cross-menu ArrowLeft/ArrowRight handoff and Escape close.

参数

名称类型说明
optionsMenubarOptions
  • menus: () => readonly string[]
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:412

create_move function

function create_move(options: MoveOptions): { readonly dragging: boolean; handle: Attachment<HTMLElement>; handle_attrs(): { tabindex: number; "aria-label": string | undefined; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }

Headless 2D free-move behavior (pointer drag + Arrow keys, optional grid snap & bounds).

参数

名称类型说明
optionsMoveOptions
  • position: () => MovePoint
  • on_change: (next: MovePoint) => void
  • on_commit?: (final: MovePoint) => void
  • step?: number
  • grid?: number
  • bounds?: () => { readonly min_x: number; readonly max_x: number; readonly min_y: number; readonly max_y: number; }
  • scale?: () => number
  • label?: string

源码: packages/ui/src/behaviors/canvas.svelte.ts:40

create_navigation_menu function

function create_navigation_menu(options: NavigationMenuOptions): { readonly active: string | null; is_open(id: string): boolean; open(id: string): void; close(): void; root: Attachment<HTMLElement>; item: (key: string) => Attachment<HTMLElement>; root_attrs(): { "aria-label": string; onpointerleave: () => void; onkeydown: (event: KeyboardEvent) => void; }; trigger_attrs(id: string): { type: "button"; "aria-expanded": boolean; "data-state": "open" | "closed"; tabindex: number | undefined; onfocus: () => void; onpointerenter: () => void; onclick: () => void; }; content_attrs(): { onpointerenter: () => void; onpointerleave: () => void; }; }

Site/app mega-menu navigation behavior: hover-intent opening with shared warm group, click toggle, keyboard roving focus across top-level triggers and Escape/outside dismissal.

参数

名称类型说明
optionsNavigationMenuOptions
  • items: () => readonly string[]
  • open_delay?: number
  • close_delay?: number
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:535

create_number_input function

function create_number_input(options?: NumberInputOptions): { readonly value: number | null; readonly text: string; set: (next: number | null) => void; increment: () => void; decrement: () => void; increment_button: import("svelte/attachments").Attachment<HTMLElement>; decrement_button: import("svelte/attachments").Attachment<HTMLElement>; input_attrs(): { role: "spinbutton"; inputmode: "decimal" | "numeric"; value: string; disabled: true | undefined; "aria-label": string | undefined; "aria-valuemin": number | undefined; "aria-valuemax": number | undefined; "aria-valuenow": number | undefined; oninput: (event: Event) => void; onblur: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless WAI-ARIA spinbutton number input with clamped stepping, Arrow/Page/Home/End keys, press-and-hold increment/decrement attachments (bind_repeat) and clean empty/numeric parsing.

参数

名称类型说明
options?NumberInputOptions

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:278

create_overflow function

function create_overflow<T>(options: OverflowOptions<T>): { readonly fit: number; readonly visible: readonly T[]; readonly hidden: readonly T[]; readonly has_overflow: boolean; readonly active_in_hidden: boolean; more_open: boolean; list: Attachment<HTMLElement>; measure: Attachment<HTMLElement>; }

Headless ResizeObserver-backed overflow behavior. Attach list to the visible strip and measure to an off-screen mirror containing every item plus the trailing overflow trigger; read visible, hidden and active_in_hidden reactively.

参数

名称类型说明
optionsOverflowOptions<T>
  • items: () => readonly T[]

    All items in display order.

  • key?: (item: T) => string

    Key extractor for checking whether the active item is currently inside the overflow menu.

  • active?: () => string | undefined

    Currently active key (optional).

源码: packages/ui/src/behaviors/overflow.svelte.ts:25

create_overlay_stack function

function create_overlay_stack<Payload, Result = unknown>(): { readonly stack: readonly OverlayEntry<Payload, Result>[]; readonly top: OverlayEntry<Payload, Result> | null; readonly count: number; open: (payload: Payload) => { readonly id: string; readonly promise: Promise<Result | undefined>; }; close: (id: string, result?: Result) => void; close_top: (result?: Result) => void; close_all: () => void; }

Imperative LIFO overlay/modal stack manager: open(payload) returns a Promise that settles when close(id, result) or Escape dismisses that overlay layer.

源码: packages/ui/src/behaviors/platform.svelte.ts:458

create_pagination function

function create_pagination(options: PaginationOptions): { readonly page: number; readonly pages: number | null; readonly has_previous: boolean; readonly has_next: boolean; readonly range: PaginationEntry[]; go: (target: number) => void; previous: () => void; next: () => void; first: () => void; last: () => void; }

Headless pagination behavior supporting both offset (total_pages) and keyset (has_previous/has_next) views.

参数

名称类型说明
optionsPaginationOptions
  • page?: () => number

    Current 1-based page number (controlled getter, or omit for internal state).

  • default_page?: number

    Initial 1-based page when uncontrolled (default 1).

  • total_pages: () => number | null

    Total page count (null when unknown / keyset-paged).

  • has_previous?: () => boolean

    Explicit previous availability override (for cursor/keyset pagination).

  • has_next?: () => boolean

    Explicit next availability override (for cursor/keyset pagination).

  • on_page_change?: (page: number) => void

    Called when the page changes.

  • siblings?: number

    Sibling pages shown on each side of the current page in range (default 1).

  • control?: { id: string; label?: string; }

    Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/pagination.svelte.ts:61

create_panel_group function

function create_panel_group(options: PanelGroupOptions): { readonly sizes: readonly number[]; readonly dragging: number | null; size_of(index: number): number; reset: () => void; container: Attachment<HTMLElement>; handle: (handleIndex: number) => Attachment<HTMLElement>; handle_attrs(handleIndex: number): { role: "separator"; tabindex: number; "aria-orientation": "horizontal" | "vertical"; "aria-valuenow": number; "aria-valuemin": number; "aria-valuemax": number; "data-dragging": string | undefined; ondblclick: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Multi-pane percentage resizable layout group (role="separator" handles between adjacent panes) with min/max clamping, collapsible snap-to-zero, double-click reset, keyboard stepping and optional persistence.

参数

名称类型说明
optionsPanelGroupOptions
  • panels: readonly PanelSpec[]
  • direction?: 'horizontal' | 'vertical'
  • storage_key?: string
  • on_layout?: (sizes: readonly number[]) => void
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:48

create_password_input function

function create_password_input(options?: PasswordInputOptions): { readonly visible: boolean; readonly caps_lock: boolean; toggle: () => void; set_visible(next: boolean): void; input: Attachment<HTMLInputElement>; input_attrs(): { type: "text" | "password"; "data-agent-secret": string; "aria-label": string | undefined; onkeydown: (event: KeyboardEvent) => void; onkeyup: (event: KeyboardEvent) => void; }; toggle_attrs(): { type: "button"; "aria-pressed": boolean; "aria-label": string; onclick: () => void; }; }

Headless password input behavior: visibility toggle, CapsLock warning detection and automatic data-agent-secret protection so secret values never leak into agent snapshots.

参数

名称类型说明
options?PasswordInputOptions

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:888

create_pin_input function

function create_pin_input(options: PinInputOptions): { readonly value: string; readonly cells: readonly PinCell[]; readonly focused: boolean; set_value: (raw: string) => void; input_attrs(): { value: string; maxlength: number; disabled: true | undefined; onfocus: (event: FocusEvent) => void; onblur: () => void; oninput: (event: Event) => void; onkeyup: (event: KeyboardEvent) => void; onselect: (event: Event) => void; }; }

Headless PIN / OTP input behavior exposing reactive cells, value and native input_attrs().

参数

名称类型说明
optionsPinInputOptions
  • length: number | (() => number)

    Number of cells (e.g. 6).

  • value?: () => string

    Controlled value getter; omit for internal state.

  • default_value?: string

    Initial value when uncontrolled.

  • on_value_change?: (value: string) => void

    Called whenever the sanitized value changes.

  • on_complete?: (value: string) => void

    Called when the value reaches length characters.

  • pattern?: RegExp

    Allowed character filter regex (default digits only /^\d+$/).

  • disabled?: () => boolean

    Disabled state.

  • control?: { readonly id: string; readonly label?: string; readonly secret?: boolean; readonly element?: () => HTMLElement | null; }

    Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/pin.svelte.ts:48

create_pointer_kind function

function create_pointer_kind(): { readonly precision: PointerPrecision; readonly hover: boolean; readonly coarse: boolean; }

Reactive primary pointer precision (coarse/fine) and hover capability store.

源码: packages/ui/src/behaviors/platform.svelte.ts:120

create_presence function

function create_presence(options: PresenceOptions): { readonly present: boolean; readonly state: PresenceState; readonly exiting: boolean; attach: Attachment<HTMLElement>; }

Keeps an element mounted while closing until its CSS/WAAPI exit animation finishes. Writes data-starting-style on the first frame after mount and data-ending-style during exit. In environments without animations (or under reduced motion), unmounts synchronously.

参数

名称类型说明
optionsPresenceOptions
  • open: () => boolean

    Reactive open getter.

  • on_complete?: (open: boolean) => void

    Called once enter or exit settles.

源码: packages/ui/src/behaviors/presence.svelte.ts:115

create_preview function

function create_preview<T>(options: PreviewOptions<T>): { readonly current: T; readonly previewing: boolean; update: (next: T) => void; commit: (finalValue?: T) => void; cancel: () => void; }

Holds a live transient pointer-drag/scrub preview value over an authoritative value, with clean commit() and cancel() transitions.

参数

名称类型说明
optionsPreviewOptions<T>
  • value: () => T

    Committed authoritative value.

  • on_commit: (value: T) => void

    Called when a preview is explicitly committed.

源码: packages/ui/src/behaviors/platform.svelte.ts:339

create_radio_group function

function create_radio_group(options: RadioGroupOptions): { readonly value: string | undefined; select: (next: string) => void; item: (key: string) => import("svelte/attachments").Attachment<HTMLElement>; root_attrs(): { role: "radiogroup"; "aria-label": string | undefined; "aria-orientation": "horizontal" | "vertical"; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(key: string): { type: "button"; role: "radio"; "aria-checked": boolean; "aria-disabled": true | undefined; "data-state": "checked" | "unchecked"; tabindex: number | undefined; onfocus: () => void; onclick: () => void; }; }

Headless WAI-ARIA radiogroup (also powers Segmented Controls): single tab stop, arrow keys move focus and select simultaneously.

参数

名称类型说明
optionsRadioGroupOptions
  • items: () => readonly string[]
  • value?: () => string | undefined
  • default_value?: string
  • on_change?: (value: string) => void
  • orientation?: RovingOrientation
  • disabled?: (value: string) => boolean
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:101

create_rating function

function create_rating(options?: RatingOptions): { readonly value: number; readonly hovered: number | null; readonly display: number; items: number[]; rate: (next: number) => void; item: (score: number) => import("svelte/attachments").Attachment<HTMLElement>; root_attrs(): { role: "radiogroup"; "aria-label": string; onpointerleave: () => void; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(score: number): { type: "button"; role: "radio"; "aria-checked": boolean; "aria-label": string; "data-filled": string | undefined; disabled: true | undefined; tabindex: number | undefined; onfocus: () => void; onpointerenter: () => void; onclick: () => void; }; }

Headless star/score rating picker (radiogroup, hover preview, Arrow/Home/End keys).

参数

名称类型说明
options?RatingOptions

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:424

create_reorder function

function create_reorder(options: ReorderOptions): { readonly dragging: string | null; readonly over: string | null; move(fromIndex: number, toIndex: number): void; move_by: (key: string, delta: number) => void; item(key: string): Attachment<HTMLElement>; item_attrs(key: string): { draggable: boolean; "data-dragging": string | undefined; "data-drop-target": string | undefined; ondragstart: (event: DragEvent) => void; ondragover: (event: DragEvent) => void; ondragleave: () => void; ondrop: (event: DragEvent) => void; ondragend: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless pointer + keyboard reordering behavior for queues, lanes, checklists and columns.

参数

名称类型说明
optionsReorderOptions
  • items: () => readonly string[]

    Ordered item keys.

  • on_reorder: (from: number, to: number, next: readonly string[]) => void

    Invoked with (fromIndex, toIndex, nextOrder) when an item moves.

  • orientation?: ReorderOrientation

    Axis for movement (default 'vertical').

  • disabled?: boolean | ((key: string) => boolean)

    Disable reordering globally or for a specific key.

  • label?: (key: string) => string

    Optional human-readable label per key for live announcements.

源码: packages/ui/src/behaviors/reorder.svelte.ts:42

create_resize function

function create_resize(options: ResizeOptions): { readonly dragging: boolean; handle_attrs(): { role: "separator"; "aria-orientation": "horizontal" | "vertical"; "aria-label": string | undefined; "aria-valuenow": number; "aria-valuemin": number; "aria-valuemax": number | undefined; tabindex: number; "data-dragging": string | undefined; onpointerdown: (event: PointerEvent) => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless 1D pointer + keyboard resize handle behavior (handle_attrs()).

参数

名称类型说明
optionsResizeOptions
  • value: () => number

    Current size in pixels (reactive getter).

  • on_change: (next: number) => void

    Called with the clamped pixel size during drag and keyboard nudges.

  • on_commit?: (final: number) => void

    Called once when a pointer drag finishes.

  • axis?: 'horizontal' | 'vertical'

    Axis of drag movement (default 'horizontal').

  • invert?: boolean

    Invert drag delta (e.g. dragging a right-docked sheet's left edge leftward widens it).

  • min?: number | (() => number)

    Minimum size in pixels (default 120).

  • max?: number | (() => number)

    Maximum size in pixels (default Infinity).

  • scale?: number | (() => number)

    Optional zoom divisor for scaled canvases/preview frames (default 1).

  • step?: number

    Keyboard Arrow nudge increment in pixels (default 24).

  • label?: string

    Accessible label for the separator handle.

源码: packages/ui/src/behaviors/resize.svelte.ts:41

create_resize_box function

function create_resize_box(options: ResizeBoxOptions): { readonly dragging: boolean; handle_attrs: (mode: "x" | "y" | "xy", label?: string) => { role: "separator"; tabindex: number; "aria-label": string | undefined; "data-dragging": string | undefined; onpointerdown: (down: PointerEvent) => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless 2D edge & corner resize behavior supporting 'x', 'y' and 'xy' handles with zoom scaling.

参数

名称类型说明
optionsResizeBoxOptions
  • size: () => ResizeBox
  • on_change: (next: ResizeBox) => void
  • on_commit?: (final: ResizeBox) => void
  • min_width?: number
  • max_width?: number
  • min_height?: number
  • max_height?: number
  • scale?: () => number
  • step?: number

源码: packages/ui/src/behaviors/resize.svelte.ts:162

create_roving_focus function

function create_roving_focus(options: RovingFocusOptions): { readonly active: string; focus(key: string): void; next(): void; prev(): void; item(key: string): Attachment<HTMLElement>; root_attrs(): { onkeydown: (event: KeyboardEvent) => void; }; item_attrs(key: string): { tabindex: number | undefined; "data-roving-active": string | undefined; onfocus: () => void; }; }

Headless roving-tabindex focus manager with automatic focus recovery when items leave the DOM.

参数

名称类型说明
optionsRovingFocusOptions
  • items: () => readonly string[]

    Keys in navigation order.

  • active?: () => string | undefined

    Controlled active key; omit for internal focus tracking.

  • on_active_change?: (key: string) => void

    Called when keyboard navigation moves focus to a key.

  • orientation?: RovingOrientation | (() => RovingOrientation)

    Axis of arrow navigation (default 'horizontal').

  • loop?: boolean

    Wrap from last back to first and vice versa (default true).

  • disabled?: (key: string) => boolean

    Skip disabled keys during keyboard movement.

  • on_activate?: (key: string) => void

    Optional callback invoked when Space or Enter activates the focused item.

源码: packages/ui/src/behaviors/roving-focus.svelte.ts:34

create_selection function

function create_selection(options: SelectionOptions): { readonly selected: readonly string[]; readonly count: number; readonly all_selected: boolean; readonly some_selected: boolean; is_selected(key: string): boolean; choose: (key: string) => void; toggle: (key: string) => void; extend: (to: string, opts?: { from?: string | null; additive?: boolean; }) => void; toggle_all: () => void; clear: () => void; item_attrs(key: string): { "aria-selected": boolean; "data-selected": string | undefined; "aria-disabled": true | undefined; onclick: (event: MouseEvent) => void; }; }

Headless single/multi/range selection behavior for lists, tables, boards, timelines and pickers. Spread item_attrs(key) onto each item to get aria-selected, data-selected and native click / Shift+click / Cmd+click handling automatically.

参数

名称类型说明
optionsSelectionOptions
  • order: () => readonly string[]

    Keys in visual order (used for Shift ranges and select-all).

  • mode?: SelectionMode | (() => SelectionMode)

    Single or multiple selection (default 'single').

  • selected?: () => readonly string[]

    Controlled selected keys; omit for internal state.

  • default_selected?: readonly string[]

    Initial selected keys when uncontrolled.

  • on_change?: (keys: readonly string[]) => void

    Called with the next selection whenever it changes.

  • selectable?: (key: string) => boolean

    Whether a key may be selected (default every key).

源码: packages/ui/src/behaviors/selection.svelte.ts:58

create_shortcuts function

function create_shortcuts(bindings: readonly ShortcutBinding[] | (() => readonly ShortcutBinding[]), options?: { readonly target?: () => EventTarget | null; readonly chord_timeout_ms?: number; }): void

Binds one or more keyboard shortcuts (including multi-key chord sequences like 'g i') while mounted, cleaning up automatically when the enclosing component tears down.

参数

名称类型说明
bindingsreadonly ShortcutBinding[] | (() => readonly ShortcutBinding[])
options?{ readonly target?: () => EventTarget | null; readonly chord_timeout_ms?: number; }

源码: packages/ui/src/behaviors/shortcuts.svelte.ts:153

create_slider function

function create_slider(options?: SliderOptions): { readonly value: number; readonly values: readonly number[]; readonly percent: number; readonly percents: number[]; readonly dragging: boolean; readonly active_thumb: number; set(next: number, index?: number): void; track: Attachment<HTMLElement>; thumb_attrs(index?: number): { role: "slider"; "aria-orientation": "horizontal" | "vertical"; "aria-label": string | undefined; "aria-valuemin": number; "aria-valuemax": number; "aria-valuenow": number; "aria-disabled": true | undefined; tabindex: number | undefined; "data-dragging": string | undefined; onfocus: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless single- or multi-thumb slider behavior (track attachment + thumb_attrs(index?)).

参数

名称类型说明
options?SliderOptions

源码: packages/ui/src/behaviors/slider.svelte.ts:54

create_spans function

function create_spans<S extends Span = Span>(options: SpansOptions<S>): { readonly spans: readonly S[]; readonly active: string | null; update_span: (id: string, patch: Partial<Pick<Span, "track" | "start" | "end">>, action: "move" | "resize", commitNow?: boolean) => void; create: (track: string, start: number, end: number) => void; remove: (id: string) => void; cancel(): void; span_attrs: (span: S) => { tabindex: number; "data-span-id": string; "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }

Headless track-span editor (week calendars, Gantt charts, room schedulers): move along or across tracks, resize start/end edges, draw new spans and delete — all snapped to step with keyboard support.

参数

名称类型说明
optionsSpansOptions<S>
  • tracks: () => readonly string[]
  • spans: () => readonly S[]
  • min: number
  • max: number
  • step?: number
  • min_duration?: number
  • on_commit: (next: readonly S[], action: 'draw' | 'move' | 'resize' | 'delete', id: string) => void
  • create_span?: (draft: Span) => S

源码: packages/ui/src/behaviors/canvas.svelte.ts:324

create_stick_to_bottom function

function create_stick_to_bottom(options?: StickToBottomOptions): { readonly stuck: boolean; scroll_to_bottom: (behavior?: ScrollBehavior) => void; viewport: Attachment<HTMLElement>; }

Headless tail-latching scroll attachment ({@attach tail.viewport}).

参数

名称类型说明
options?StickToBottomOptions

源码: packages/ui/src/behaviors/stick-to-bottom.svelte.ts:20

create_swipe_actions function

function create_swipe_actions(options?: SwipeActionsOptions): { readonly open: SwipeOpen | null; readonly offset: { readonly key: string; readonly x: number; } | null; close: () => void; row: (key: string) => Attachment<HTMLElement>; row_attrs: (key: string) => { "data-swipe-open": SwipeSide | undefined; style: string; onkeydown: (event: KeyboardEvent) => void; }; }

Mail-style row swipe-to-reveal actions with rubber-band resistance, full-swipe trigger and ArrowLeft/ArrowRight/Escape keyboard parity.

参数

名称类型说明
options?SwipeActionsOptions

源码: packages/ui/src/behaviors/canvas.svelte.ts:747

create_switch function

function create_switch(options?: SwitchOptions): { readonly checked: boolean; readonly disabled: boolean; set_checked: (next: boolean) => void; toggle: () => void; attrs(): { type: "button"; role: "switch"; "aria-checked": boolean; "aria-label": string | undefined; "data-state": "checked" | "unchecked"; disabled: true | undefined; onclick: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless WAI-ARIA switch behavior (role="switch", aria-checked, Space/Enter toggle).

参数

名称类型说明
options?SwitchOptions

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:23

create_time_field function

function create_time_field(options: TimeFieldOptions): { readonly segments: readonly DateTimeSegment[]; segment_ref(part: SegmentPart): Attachment<HTMLElement>; segment_attrs(seg: DateTimeSegment): { "aria-hidden": true; "data-segment": "literal"; role?: undefined; tabindex?: undefined; "aria-label"?: undefined; "aria-valuemin"?: undefined; "aria-valuemax"?: undefined; "aria-valuenow"?: undefined; "aria-valuetext"?: undefined; "aria-disabled"?: undefined; onkeydown?: undefined; onblur?: undefined; } | { role: "spinbutton"; tabindex: number | undefined; "data-segment": "hour" | "minute"; "aria-label": "hour" | "minute"; "aria-valuemin": number; "aria-valuemax": number; "aria-valuenow": number | undefined; "aria-valuetext": string; "aria-disabled": true | undefined; onkeydown: (e: KeyboardEvent) => void; onblur: () => void; "aria-hidden"?: undefined; }; }

Headless 24-hour segmented time-of-day field behavior (hour and optional minute).

参数

名称类型说明
optionsTimeFieldOptions
  • value: () => Time | undefined

    Controlled Time getter.

  • on_change: (next: Time | undefined) => void

    Called when the time value changes (or clears to undefined).

  • granularity?: () => 'hour' | 'minute'

    Editing precision: 'hour' or 'minute' (default 'minute').

  • disabled?: () => boolean

    Disabled state.

源码: packages/ui/src/behaviors/date-time.svelte.ts:437

create_timeline function

function create_timeline(options: TimelineOptions): { readonly expanded: readonly string[]; is_expanded(id: string): boolean; toggle: (id: string) => void; item: (key: string) => Attachment<HTMLElement>; root_attrs(): { role: "feed"; "aria-label": string; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(id: string): { role: "article"; "aria-expanded": boolean; "data-expanded": string | undefined; tabindex: number | undefined; onfocus: () => void; }; }

Accessible activity timeline behavior (role="feed" / ordered expandable entries) with vertical keyboard navigation, per-entry expand/collapse and Norbius control registration.

参数

名称类型说明
optionsTimelineOptions
  • items: () => readonly string[]
  • default_expanded?: readonly string[]
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1350

create_toggle_group function

function create_toggle_group(options: ToggleGroupOptions): { readonly pressed: readonly string[]; is_pressed(key: string): boolean; toggle: (key: string) => void; item: (key: string) => import("svelte/attachments").Attachment<HTMLElement>; root_attrs(): { role: "group"; "aria-label": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(key: string): { type: "button"; "aria-pressed": boolean; "data-state": "on" | "off"; disabled: true | undefined; tabindex: number | undefined; onfocus: () => void; onclick: () => void; }; }

Headless toggle button group (aria-pressed, single or multi-select, roving focus).

参数

名称类型说明
optionsToggleGroupOptions
  • items: () => readonly string[]
  • mode?: 'single' | 'multiple'
  • value?: () => readonly string[]
  • default_value?: readonly string[]
  • on_change?: (values: readonly string[]) => void
  • orientation?: RovingOrientation
  • disabled?: (key: string) => boolean
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:183

create_token_input function

function create_token_input(options?: TokenInputOptions): { readonly values: readonly string[]; input_text: string; readonly active_index: number | null; readonly editing_index: number | null; editing_text: string; readonly error: string | null; add: (raw: string) => boolean; remove_at: (index: number) => void; commit_input: () => void; start_edit: (index: number) => void; commit_edit: () => void; cancel_edit: () => void; input: Attachment<HTMLInputElement>; chip: (index: number) => Attachment<HTMLElement>; input_attrs(): { value: string; disabled: true | undefined; "aria-label": string | undefined; onfocus: () => void; oninput: (event: Event) => void; onpaste: (event: ClipboardEvent) => void; onkeydown: (event: KeyboardEvent) => void; onblur: () => void; }; chip_attrs(index: number): { tabindex: number; "data-active": string | undefined; "data-editing": string | undefined; onfocus: () => void; ondblclick: () => void; onkeydown: (event: KeyboardEvent) => void; }; }

Headless chip/tag/recipient token input: splits on delimiters & paste, navigates chips with ArrowLeft/ArrowRight/Home/End, Backspace selects/deletes the last chip, supports inline chip editing and registers with Norbius's control bridge.

参数

名称类型说明
options?TokenInputOptions

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:45

create_toolbar function

function create_toolbar(options: ToolbarOptions): { readonly active: string; focus: (key: string) => void; item: (key: string) => import("svelte/attachments").Attachment<HTMLElement>; root_attrs(): { role: "toolbar"; "aria-label": string | undefined; "aria-orientation": "horizontal" | "vertical"; onkeydown: (event: KeyboardEvent) => void; }; item_attrs: (key: string) => { tabindex: number | undefined; "data-roving-active": string | undefined; onfocus: () => void; }; }

Headless WAI-ARIA role="toolbar" single-tab-stop roving container.

参数

名称类型说明
optionsToolbarOptions
  • items: () => readonly string[]
  • orientation?: RovingOrientation
  • disabled?: (key: string) => boolean
  • label?: string

源码: packages/ui/src/behaviors/controls-extra.svelte.ts:501

create_transfer function

function create_transfer(options: TransferOptions): { readonly lists: Readonly<Record<string, readonly string[]>>; readonly draft: TransferDraft | null; readonly dragging: string | null; move: (key: string, to: string, index: number, commitNow?: boolean) => void; container(id: string): Attachment<HTMLElement>; item(key: string): Attachment<HTMLElement>; item_attrs(key: string): { "data-dragging": string | undefined; onkeydown: (event: KeyboardEvent) => void; }; }

Headless cross-container drag-and-drop + keyboard transfer (Kanban boards, folder lists, team rosters) with live draft preview, edge auto-scrolling and screen-reader announcements.

参数

名称类型说明
optionsTransferOptions
  • containers: () => readonly string[]

    Ordered container keys (e.g. Kanban lane ids).

  • lists: () => TransferLists

    Current lists per container.

  • on_commit: (next: TransferLists, move: { readonly key: string; readonly from: string; readonly to: string; readonly index: number; }) => void

    Called once on drop or keyboard commit with the next container map.

  • can_drop?: (key: string, toContainer: string) => boolean

    Optional predicate rejecting moves into a container.

  • item_label?: (key: string) => string

    Human-readable item label for screen-reader announcements.

  • container_label?: (container: string) => string

    Human-readable container label for screen-reader announcements.

源码: packages/ui/src/behaviors/drag.svelte.ts:299

create_tree function

function create_tree<T = unknown>(options: TreeOptions<T>): { readonly rows: FlatTreeRow<T>[]; readonly expanded: readonly string[]; readonly selected: readonly string[]; readonly active: string; expand: (id: string) => void; collapse: (id: string) => void; toggle_expand: (id: string) => void; is_expanded(id: string): boolean; is_selected: (key: string) => boolean; item: (key: string) => import("svelte/attachments").Attachment<HTMLElement>; root_attrs(): { role: "tree"; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(id: string): { role: "treeitem"; "aria-level": number; "aria-expanded": boolean | undefined; "aria-selected": boolean; "aria-disabled": true | undefined; "data-selected": string | undefined; "data-expanded": string | undefined; tabindex: number | undefined; onfocus: () => void; onclick: (event: MouseEvent) => void; }; }

Headless WAI-ARIA tree behavior with ArrowRight expand/descend, ArrowLeft collapse/ascend, typeahead, roving tabindex, focus recovery on collapse, selection and optional agent control registration.

参数

名称类型说明
optionsTreeOptions<T>
  • nodes: () => readonly TreeNode<T>[]

    Root tree nodes.

  • default_expanded?: readonly string[]

    Initial expanded node ids.

  • expanded?: () => readonly string[]

    Controlled expanded node ids.

  • on_expanded_change?: (ids: readonly string[]) => void

    Called when expanded node ids change.

  • mode?: SelectionMode

    Selection mode (default 'single').

  • selected?: () => readonly string[]

    Controlled selected ids.

  • on_select?: (ids: readonly string[]) => void

    Called when selection changes.

  • control?: { readonly id: string; readonly label?: string; }

    Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/tree.svelte.ts:240

create_tree_reorder function

function create_tree_reorder(options: TreeReorderOptions): { readonly dragging: string | null; readonly drop: TreePlace | null; commit: (id: string, place: TreePlace) => void; item(id: string): Attachment<HTMLElement>; item_attrs(id: string): { "data-dragging": string | undefined; "data-drop-position": "before" | "inside" | "after" | undefined; onkeydown: (event: KeyboardEvent) => void; }; }

Headless hierarchical tree reordering (pointer drop zones: top 25% before, middle 50% inside, bottom 25% after; plus Alt+ArrowUp/Down/Left/Right keyboard reparenting) with subtree cycle guard.

参数

名称类型说明
optionsTreeReorderOptions
  • rows: () => readonly TreeReorderRow[]

    Visible pre-order tree rows.

  • on_move: (id: string, place: TreePlace) => void

    Invoked when a node (with its subtree) moves to place.

  • can_drop?: (id: string, place: TreePlace) => boolean

    Optional predicate forbidding drops into/around a target.

源码: packages/ui/src/behaviors/drag.svelte.ts:497

create_trigger_menu function

function create_trigger_menu<T extends TriggerMenuItem = TriggerMenuItem>(options: TriggerMenuOptions<T>): { readonly open: boolean; readonly match: TriggerMatch | null; readonly items: readonly T[]; readonly path: readonly T[]; readonly active_index: number; readonly floating: { readonly x: number; readonly y: number; readonly side: import("./floating.svelte.js").FloatingSide; readonly anchor_width: number; readonly available_width: number; readonly available_height: number; readonly positioned: boolean; readonly style: string; set_anchor(next: import("./floating.svelte.js").FloatingAnchor | null): void; update: () => void; anchor: Attachment<HTMLElement>; content: Attachment<HTMLElement>; }; close: () => void; select: (item: T) => void; pop_level(): void; field: Attachment<HTMLInputElement | HTMLTextAreaElement>; content: Attachment<HTMLElement>; input_attrs(): { "aria-expanded": boolean; "aria-haspopup": "listbox"; "aria-activedescendant": string | undefined; oninput: (event: Event) => void; onkeyup: (event: KeyboardEvent) => void; onkeydown: (event: KeyboardEvent) => void; }; option_attrs(item: T, index: number): { id: string; role: "option"; "aria-selected": boolean; "aria-disabled": true | undefined; "data-highlighted": string | undefined; onpointerenter: () => void; onmousedown: (event: MouseEvent) => void; onclick: () => void; }; }

Inline @mention / / slash-command trigger menu for <input> and <textarea>: tracks caret trigger matches, fuzzy-filters items, supports nested sub-menus (children), keyboard navigation (ArrowUp/ArrowDown/Enter/Tab/Escape), floating anchor positioning and Norbius control registration.

参数

名称类型说明
optionsTriggerMenuOptions<T>
  • triggers: readonly string[]

    Trigger prefixes that open the menu (e.g. ['@', '/']).

  • items: (trigger: string, query: string, path: readonly T[]) => readonly T[]

    Returns items for the active trigger & nested level stack.

  • on_select: (item: T, match: TriggerMatch, insertText: string) => void

    Called when a leaf item is picked (receives item and replacement range).

  • control?: { readonly id: string; readonly label?: string; }

    Optional semantic control registration for Norbius's page bridge.

源码: packages/ui/src/behaviors/inputs-extra.svelte.ts:397

create_typeahead function

function create_typeahead(options: TypeaheadOptions): { onkeydown: (event: KeyboardEvent) => void; reset: () => void; readonly query: string; }

Headless incremental typeahead behavior. Pass onkeydown to any listbox, menu, rail or tab strip (composes directly alongside create_roving_focus).

参数

名称类型说明
optionsTypeaheadOptions
  • items: () => readonly TypeaheadItem[]

    Candidate items in visual order.

  • active?: () => string | undefined

    Currently active key (search wraps starting after this item).

  • on_match: (key: string) => void

    Invoked with the matched item's key.

  • timeout_ms?: number

    Buffer reset delay in ms (default 500).

源码: packages/ui/src/behaviors/typeahead.svelte.ts:28

create_ui_history function

function create_ui_history(options?: UiHistoryOptions): { readonly entries: readonly UiHistoryEntry[]; readonly position: number; readonly can_undo: boolean; readonly can_redo: boolean; undo: () => boolean; redo: () => boolean; undo_source: (source: ChangeSource) => number; destroy: () => void; }

Records live control changes via observe_controls and supports stepping backward/forward or reverting every non-redacted change made by one source (e.g. history.undo_source('agent')).

参数

名称类型说明
options?UiHistoryOptions

源码: packages/ui/src/behaviors/controls.svelte.ts:436

create_undo_stack function

function create_undo_stack<T>(initial: T, options?: UndoStackOptions): { readonly current: T; readonly can_undo: boolean; readonly can_redo: boolean; readonly length: number; record: (next: T, opts?: { readonly group?: string; readonly time?: number; }) => void; undo: () => T; redo: () => T; reset: (value: T) => void; }

Grouped undo/redo stack for any immutable state value. Consecutive edits with the same group arriving within group_delay_ms coalesce into one undo entry.

参数

名称类型说明
initialT
options?UndoStackOptions

源码: packages/ui/src/behaviors/micro.svelte.ts:115

create_velocity_tracker function

function create_velocity_tracker(): { add(position: number, time?: number): void; velocity(): number; reset(): void; }

Exponentially weighted pointer velocity tracker (pixels per millisecond).

源码: packages/ui/src/behaviors/motion.svelte.ts:18

create_viewport function

function create_viewport(options?: ViewportOptions): { readonly x: number; readonly y: number; readonly zoom: number; readonly panning: boolean; readonly transform: string; set_camera: (next: Partial<ViewportCamera>) => void; zoom_at: (factor: number, originX: number, originY: number) => void; reset(): void; surface: Attachment<HTMLElement>; }

Headless pan/zoom canvas viewport with pointer panning, wheel-to-zoom around cursor, fit and reset.

参数

名称类型说明
options?ViewportOptions

源码: packages/ui/src/behaviors/canvas.svelte.ts:533

create_waterfall function

function create_waterfall<T extends WaterfallItem = WaterfallItem>(options: WaterfallOptions<T>): { readonly rows: import("./tree.svelte.js").FlatTreeRow<T>[]; readonly min: number; readonly max: number; readonly view_start: number; readonly view_end: number; readonly tree: { readonly rows: import("./tree.svelte.js").FlatTreeRow<T>[]; readonly expanded: readonly string[]; readonly selected: readonly string[]; readonly active: string; expand: (id: string) => void; collapse: (id: string) => void; toggle_expand: (id: string) => void; is_expanded(id: string): boolean; is_selected: (key: string) => boolean; item: (key: string) => Attachment<HTMLElement>; root_attrs(): { role: "tree"; onkeydown: (event: KeyboardEvent) => void; }; item_attrs(id: string): { role: "treeitem"; "aria-level": number; "aria-expanded": boolean | undefined; "aria-selected": boolean; "aria-disabled": true | undefined; "data-selected": string | undefined; "data-expanded": string | undefined; tabindex: number | undefined; onfocus: () => void; onclick: (event: MouseEvent) => void; }; }; bar_rect: (item: WaterfallItem) => { readonly left_pct: number; readonly width_pct: number; }; zoom(start: number, end: number): void; reset_zoom(): void; }

Hierarchical trace/Gantt waterfall behavior composing create_tree with automatic time-domain bounds, zoomable [view_start, view_end] window and percentage bar placement (bar_rect).

参数

名称类型说明
optionsWaterfallOptions<T>
  • items: () => readonly T[]
  • on_select?: (id: string) => void
  • label?: string
  • control?: { readonly id: string; readonly label?: string; }

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:1244

current_modality function

function current_modality(): InputModality

Returns the current global input modality ('keyboard' or 'pointer').

源码: packages/ui/src/behaviors/platform.svelte.ts:270

current_source function

function current_source(): ChangeSource

Returns the currently attributed change source ('pointer' | 'keyboard' | 'agent' | 'programmatic').

源码: packages/ui/src/behaviors/controls.svelte.ts:108

describe_controls function

function describe_controls(options?: PageControlsOptions): string

Concise one-line summary of registered controls for Norbius's pageScreen() context.

参数

名称类型说明
options?PageControlsOptions

源码: packages/ui/src/behaviors/controls.svelte.ts:390

format_color function

function format_color(color: RgbaColor, format?: "hex" | "rgb" | "hsl"): string

Formats an RgbaColor as 'hex', 'rgb' or 'hsl'.

参数

名称类型说明
colorRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number
format?'hex' | 'rgb' | 'hsl'

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:929

format_shortcut function

function format_shortcut(spec: string, platform?: "mac" | "other"): string

Formats a shortcut spec for human-readable UI badges (e.g. '⌘K' on macOS, 'Ctrl+K' elsewhere).

参数

名称类型说明
specstring
platform?'mac' | 'other'

源码: packages/ui/src/behaviors/shortcuts.svelte.ts:122

fuzzy_score function

function fuzzy_score(query: string, text: string): number

Accent- and case-insensitive fuzzy match score for query against text. Returns 0 when query does not match, or a positive relevance score (higher is better).

参数

名称类型说明
querystring
textstring

源码: packages/ui/src/behaviors/text-match.ts:125

get_portal_target function

function get_portal_target(): PortalTarget

Reads the inherited portal target from context, if configured.

源码: packages/ui/src/behaviors/portal.svelte.ts:29

hsl_to_rgb function

function hsl_to_rgb(color: HslaColor): RgbaColor

Converts HSL (h: 0..360, s: 0..100, l: 0..100) to RGBA (0..255).

参数

名称类型说明
colorHslaColor
  • h: number
  • s: number
  • l: number
  • a: number

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:828

hsv_to_rgb function

function hsv_to_rgb(color: HsvaColor): RgbaColor

Converts HSV (h: 0..360, s: 0..100, v: 0..100) to RGBA (0..255).

参数

名称类型说明
colorHsvaColor
  • h: number
  • s: number
  • v: number
  • a: number

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:867

inert_outside function

function inert_outside(keep: HTMLElement | readonly HTMLElement[]): InertHandle

Marks every sibling tree outside keep as inert (ref-counted across nested modals) while keeping live announcer regions active. Call .keep(el) to exempt a portaled overlay opened inside.

参数

名称类型说明
keepHTMLElement | readonly HTMLElement[]

源码: packages/ui/src/behaviors/modal.svelte.ts:145

input_hints function

function input_hints(kind: InputHintKind, overrides?: { readonly enterkeyhint?: EnterKeyHint; }): InputHints

Returns consistent mobile keyboard, autocomplete and spellcheck attributes for a semantic field kind.

参数

名称类型说明
kindInputHintKind
overrides?{ readonly enterkeyhint?: EnterKeyHint; }

源码: packages/ui/src/behaviors/micro.svelte.ts:461

invoke_control function

function invoke_control(ref: string, action: string, args?: readonly unknown[], options?: { readonly within?: Element | null; readonly allow_confirm?: boolean; }): ControlInvokeResult

Invokes a named semantic action on a registered control by id or accessible label, attributing the change to 'agent' and enforcing disabled/hidden/confirmation guards.

参数

名称类型说明
refstring
actionstring
args?readonly unknown[]
options?{ readonly within?: Element | null; readonly allow_confirm?: boolean; }

源码: packages/ui/src/behaviors/controls.svelte.ts:328

is_focus_from_keyboard function

function is_focus_from_keyboard(): boolean

Returns whether the most recent user interaction was keyboard-driven (for focus-visible heuristics).

源码: packages/ui/src/behaviors/platform.svelte.ts:264

is_span_free function

function is_span_free(spans: readonly Span[], track: string, start: number, end: number, ignoreId?: string): boolean

Returns whether [start, end) overlaps no existing span on track (excluding ignoreId).

参数

名称类型说明
spansreadonly Span[]
trackstring
startnumber
endnumber
ignoreId?string

源码: packages/ui/src/behaviors/canvas.svelte.ts:271

keep_focus function

function keep_focus(): Attachment<HTMLElement>

Attachment ({@attach keep_focus()}) that prevents pointerdown / mousedown on a button or toolbar control from stealing DOM focus away from an active text editor or input.

源码: packages/ui/src/behaviors/platform.svelte.ts:279

lock_scroll function

function lock_scroll(doc?: Document | undefined): () => void

Reference-counted document scroll lock. The first holder freezes the scroller without horizontal gutter shift; only the last release restores styles. Safe to call release multiple times.

参数

名称类型说明
doc?Document | undefined

源码: packages/ui/src/behaviors/modal.svelte.ts:70

match_ranges function

function match_ranges(query: string, text: string): readonly MatchRange[]

Returns sorted, non-overlapping [start, end) highlight spans where query matches text, or an empty array when query is blank or does not match.

参数

名称类型说明
querystring
textstring

源码: packages/ui/src/behaviors/text-match.ts:133

match_segments function

function match_segments(query: string, text: string): readonly MatchSegment[]

Splits text into alternating plain and matched segments for rendering search highlights without injecting raw HTML.

参数

名称类型说明
querystring
textstring

源码: packages/ui/src/behaviors/text-match.ts:141

matches_shortcut function

function matches_shortcut(event: KeyboardEvent, spec: string, options?: MatchShortcutOptions): boolean

Returns whether event matches a single-step shortcut string such as 'mod+k' or 'shift+escape'.

参数

名称类型说明
eventKeyboardEvent
specstring
options?MatchShortcutOptions

源码: packages/ui/src/behaviors/shortcuts.svelte.ts:87

mix_colors function

function mix_colors(a: RgbaColor, b: RgbaColor, t: number): RgbaColor

Linearly mixes two RGBA colors (t = 0 -> a, t = 1 -> b).

参数

名称类型说明
aRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number
bRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number
tnumber

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:966

move_item function

function move_item<T>(list: readonly T[], from: number, to: number): T[]

Returns a new array with the item at from moved to to.

参数

名称类型说明
listreadonly T[]
fromnumber
tonumber

源码: packages/ui/src/behaviors/reorder.svelte.ts:29

nearest_in_direction function

function nearest_in_direction(from: SpatialRect, candidates: readonly SpatialRect[], direction: SpatialDirection): number

Returns the index of the nearest candidate rectangle strictly in direction from from, or -1.

参数

名称类型说明
fromSpatialRect
  • left: number
  • top: number
  • width: number
  • height: number
candidatesreadonly SpatialRect[]
directionSpatialDirection

源码: packages/ui/src/behaviors/micro.svelte.ts:496

nearest_snap_point function

function nearest_snap_point(position: number, velocity: number, points: readonly number[], options?: { readonly projection_ms?: number; }): number

Projects a position using release velocity and returns the nearest snap point.

参数

名称类型说明
positionnumber
velocitynumber
pointsreadonly number[]
options?{ readonly projection_ms?: number; }

源码: packages/ui/src/behaviors/motion.svelte.ts:45

notify_control_change function

function notify_control_change(change: { readonly id: string; readonly kind?: string; readonly label?: string; readonly key: string; readonly previous: unknown; readonly value: unknown; readonly reason?: string; readonly source?: ChangeSource; readonly committed?: boolean; }): void

Emits a structured UI state change to every matching observe_controls listener.

参数

名称类型说明
change{ readonly id: string; readonly kind?: string; readonly label?: string; readonly key: string; readonly previous: unknown; readonly value: unknown; readonly reason?: string; readonly source?: ChangeSource; readonly committed?: boolean; }
  • id: string
  • kind?: string
  • label?: string
  • key: string
  • previous: unknown
  • value: unknown
  • reason?: string
  • source?: ChangeSource
  • committed?: boolean

源码: packages/ui/src/behaviors/controls.svelte.ts:207

observe_controls function

function observe_controls(listener: (change: ControlChange) => void, options?: { readonly within?: Element | (() => Element | null | undefined); readonly live?: boolean; }): () => void

Subscribes to structured control state changes (settled commits by default; live: true for drag steps).

参数

名称类型说明
listener(change: ControlChange) => void
options?{ readonly within?: Element | (() => Element | null | undefined); readonly live?: boolean; }

源码: packages/ui/src/behaviors/controls.svelte.ts:250

page_controls function

function page_controls(options?: PageControlsOptions): ControlSnapshot[]

Returns a deterministic snapshot of registered visible UI controls on the current page.

参数

名称类型说明
options?PageControlsOptions

源码: packages/ui/src/behaviors/controls.svelte.ts:263

page_range function

function page_range(current: number, total: number, siblings?: number): PaginationEntry[]

Computes a compact 1-based page range with 'ellipsis' gaps.

参数

名称类型说明
currentnumber
totalnumber
siblings?number

源码: packages/ui/src/behaviors/pagination.svelte.ts:32

parse_color function

function parse_color(input: string): RgbaColor | null

Parses CSS #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(...) or hsl(...) strings into RgbaColor.

参数

名称类型说明
inputstring

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:887

pointer_kind_of function

function pointer_kind_of(): PointerKindState

Reads current device pointer precision and hover support synchronously.

源码: packages/ui/src/behaviors/platform.svelte.ts:110

portal function

function portal(target?: PortalTarget | PortalOptions): Attachment<HTMLElement>

Svelte attachment that moves the element into the resolved portal container while mounted and restores or removes it cleanly on teardown.

参数

名称类型说明
target?PortalTarget | PortalOptions

源码: packages/ui/src/behaviors/portal.svelte.ts:55

prepare_announcements function

function prepare_announcements(doc?: Document | undefined): void

Pre-creates polite and assertive live regions so the very first announcement is never dropped.

参数

名称类型说明
doc?Document | undefined

源码: packages/ui/src/behaviors/announce.svelte.ts:49

register_control function

function register_control(descriptor: ControlDescriptor): () => void

Registers a live UI control while mounted and returns its cleanup function. Designed for use inside $effect or Svelte attachments ({@attach ...}).

参数

名称类型说明
descriptorControlDescriptor
  • id: string

    Stable semantic identifier, e.g. 'tabs:settings' or 'combobox:status'.

  • kind: string

    Component kind, e.g. 'tabs', 'combobox', 'dialog', 'input', 'checkbox', 'menu'.

  • label?: string

    Optional human-readable label (falls back to accessible name of element).

  • element?: () => HTMLElement | null | undefined

    Optional root/interactive DOM element for scope filtering and data-agent-* marks.

  • state: () => Record<string, unknown>

    Live snapshot of state (active tab, open state, value, selected count, etc.).

  • items?: () => readonly ControlChoice[]

    Optional choices accepted by selection actions.

  • actions?: Readonly<Record<string, ControlAction>>

    Named semantic actions callable by the host/agent bridge.

  • disabled?: () => boolean

    Whether the control is currently disabled or read-only (hides callable actions).

  • confirm?: string | (() => string | undefined)

    Explicit confirmation prompt describing why a person must approve agent actions.

  • secret?: boolean | (() => boolean)

    Marks values as secret (writable by agent, always redacted in snapshots/observations).

  • hidden?: boolean | (() => boolean)

    Hides this control from agent snapshots and invocation.

源码: packages/ui/src/behaviors/controls.svelte.ts:197

reset_hover_group function

function reset_hover_group(group?: string): void

Clears warm-group state (handy between tests).

参数

名称类型说明
group?string

源码: packages/ui/src/behaviors/hover-intent.svelte.ts:87

resolve_control function

function resolve_control(ref: string, options?: { readonly within?: Element | null; }): { readonly entry: ControlDescriptor; readonly snapshot: ControlSnapshot; } | { readonly error: string; }

Resolves a registered control by exact id, exact label (case-insensitive), or unique label substring.

参数

名称类型说明
refstring
options?{ readonly within?: Element | null; }

源码: packages/ui/src/behaviors/controls.svelte.ts:284

rgb_to_hsl function

function rgb_to_hsl(color: RgbaColor): HslaColor

Converts RGB (0..255) + alpha (0..1) to HSL (h: 0..360, s: 0..100, l: 0..100).

参数

名称类型说明
colorRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:808

rgb_to_hsv function

function rgb_to_hsv(color: RgbaColor): HsvaColor

Converts RGB (0..255) to HSV (h: 0..360, s: 0..100, v: 0..100).

参数

名称类型说明
colorRgbaColor
  • r: number
  • g: number
  • b: number
  • a: number

源码: packages/ui/src/behaviors/widgets-extra.svelte.ts:848

rubber_band function

function rubber_band(offset: number, dimension: number, constant?: number): number

Applies iOS-style asymptotic rubber-band resistance beyond [0, limit].

参数

名称类型说明
offsetnumber
dimensionnumber
constant?number

源码: packages/ui/src/behaviors/motion.svelte.ts:10

set_announcer function

function set_announcer(fn: CustomAnnouncer | undefined): void

Replaces live-region output (useful in headless unit tests); pass undefined to restore.

参数

名称类型说明
fnCustomAnnouncer | undefined

源码: packages/ui/src/behaviors/announce.svelte.ts:23

set_portal_target function

function set_portal_target(target: PortalTarget | PortalGetter): void

Sets the default portal mount target for every descendant overlay.

参数

名称类型说明
targetPortalTarget | PortalGetter

源码: packages/ui/src/behaviors/portal.svelte.ts:23

settle_draft function

function settle_draft<T>(current: Readonly<Record<string, T>>, submitted: Readonly<Record<string, T>>, equals?: (a: T, b: T) => boolean): Record<string, T>

Race-safe optimistic draft settler: removes keys whose current draft value still equals the snapshot that just committed, while preserving newer edits typed while the save was in flight.

参数

名称类型说明
currentReadonly<Record<string, T>>
submittedReadonly<Record<string, T>>
equals?(a: T, b: T) => boolean

源码: packages/ui/src/behaviors/platform.svelte.ts:378

spatial_move function

function spatial_move(current: HTMLElement, elements: readonly HTMLElement[], direction: SpatialDirection): HTMLElement | null

Finds the nearest focusable element in direction from current among elements.

参数

名称类型说明
currentHTMLElement
elementsreadonly HTMLElement[]
directionSpatialDirection

源码: packages/ui/src/behaviors/micro.svelte.ts:529

stack_spans function

function stack_spans<S extends Span>(spans: readonly S[]): readonly (S & { readonly lane: number; readonly lanes: number; })[]

Packs overlapping spans on one track into non-overlapping visual lanes (lane index & lanes total).

参数

名称类型说明
spansreadonly S[]

源码: packages/ui/src/behaviors/canvas.svelte.ts:286

step_spring function

function step_spring(state: { readonly position: number; readonly velocity: number; }, target: number, config?: { readonly stiffness?: number; readonly damping?: number; readonly mass?: number; readonly precision?: number; }, dt?: number): SpringState

Advances a 1D damped harmonic spring by dt seconds toward target.

参数

名称类型说明
state{ readonly position: number; readonly velocity: number; }
  • position: number
  • velocity: number
targetnumber
config?{ readonly stiffness?: number; readonly damping?: number; readonly mass?: number; readonly precision?: number; }
dt?number

源码: packages/ui/src/behaviors/motion.svelte.ts:76

subtree_end function

function subtree_end(rows: readonly TreeReorderRow[], index: number): number

Returns the exclusive index past the subtree rooted at index in a pre-order flat row array.

参数

名称类型说明
rowsreadonly TreeReorderRow[]
indexnumber

源码: packages/ui/src/behaviors/drag.svelte.ts:472

supports_hidden_until_found function

function supports_hidden_until_found(): boolean

Whether this browser supports find-in-page revelation via hidden="until-found" and beforematch.

源码: packages/ui/src/behaviors/presence.svelte.ts:212

tabbable_elements function

function tabbable_elements(root: HTMLElement): HTMLElement[]

Returns all visible, enabled tabbable descendants inside root.

参数

名称类型说明
rootHTMLElement

源码: packages/ui/src/behaviors/focus-trap.svelte.ts:17

text_to_cells function

function text_to_cells(text: string): string[][]

Parses tab-separated clipboard text (TSV) into a 2D matrix of strings.

参数

名称类型说明
textstring

源码: packages/ui/src/behaviors/grid.svelte.ts:231

toggle_tree_checked function

function toggle_tree_checked<T>(nodes: readonly TreeNode<T>[], checked: readonly string[], id: string, strategy?: TreeCheckStrategy): string[]

Toggles id in a hierarchical tree checkbox model and returns the normalized checked id array for strategy.

参数

名称类型说明
nodesreadonly TreeNode<T>[]
checkedreadonly string[]
idstring
strategy?TreeCheckStrategy

源码: packages/ui/src/behaviors/tree.svelte.ts:168

tree_checked_states function

function tree_checked_states<T>(nodes: readonly TreeNode<T>[], checked: readonly string[], strategy?: TreeCheckStrategy): ReadonlyMap<string, TreeCheckedState>

Computes checked / unchecked / 'indeterminate' state for every node in nodes.

参数

名称类型说明
nodesreadonly TreeNode<T>[]
checkedreadonly string[]
strategy?TreeCheckStrategy

源码: packages/ui/src/behaviors/tree.svelte.ts:129

tree_from_paths function

function tree_from_paths(paths: readonly string[]): TreeNode<{ readonly dir: boolean; readonly path: string; }>[]

Builds a sorted directory-first TreeNode[] from slash-delimited file paths (e.g. Studio files).

参数

名称类型说明
pathsreadonly string[]

源码: packages/ui/src/behaviors/tree.svelte.ts:60

use_debounce function

function use_debounce<A extends readonly unknown[]>(callback: (...args: A) => void, wait?: number | (() => number)): ((...args: A) => void) & { readonly cancel: () => void; }

Debounced callback wrapper with .cancel() support for input-driven queries.

参数

名称类型说明
callback(...args: A) => void
wait?number | (() => number)

源码: packages/ui/src/behaviors/reactive.svelte.ts:169

primitives

virtual_list function

function virtual_list(o: VirtualOptions): { readonly on: boolean; readonly start: number; readonly end: number; readonly before: number; readonly after: number; slice<T>(items: readonly T[]): readonly T[]; anchor: (el: HTMLElement) => () => void; measure(key: string): Attachment<Element>; reveal(index: number): void; }

Windows a long list to the rows in view (measuring each row's height), so a page renders only what is visible; a short list renders whole.

参数

名称类型说明
oVirtualOptions
  • count: () => number
  • key: (index: number) => string

    Stable identity of item i (its id): measured heights follow it.

  • estimate: number

    An unmeasured item's height in px.

  • threshold?: number

    Render every item at or below this count (default 60).

  • overscan?: number

    Items rendered beyond each edge of the visible band (default 8).

  • tail?: () => boolean

    Window the last visible rows while a bottom-origin viewport is latched to its tail.

源码: packages/ui/src/primitives/virtual/virtual.svelte.ts:37

behaviors

watch const

const watch: typeof watch

Reactively watches one or more getter sources and invokes callback(current, previous) without tracking reads inside callback. Supports { lazy: true } and watch.pre(...).

成员

名称类型说明
pre{ <T>(source: Getter<T>, callback: WatchCallback<T>, options?: WatchOptions): void; <const S extends readonly Getter<unknown>[]>(source: S, callback: WatchCallback<GetterValues<S>>, options?: WatchOptions): void; }

源码: packages/ui/src/behaviors/reactive.svelte.ts:70

watch_pre function

function watch_pre<T>(source: Getter<T>, callback: WatchCallback<T>, options?: WatchOptions): void
function watch_pre<const S extends readonly Getter<unknown>[]>(source: S, callback: WatchCallback<GetterValues<S>>, options?: WatchOptions): void

Pre-DOM variant of watch backed by $effect.pre.

参数

名称类型说明
sourceGetter<T>
callbackWatchCallback<T>
options?WatchOptions

源码: packages/ui/src/behaviors/reactive.svelte.ts:89

with_source function

function with_source<T>(source: ChangeSource, fn: () => T): T

Runs fn with source attributed to any UI control changes emitted synchronously inside it.

参数

名称类型说明
sourceChangeSource
fn() => T

源码: packages/ui/src/behaviors/controls.svelte.ts:97