@opencode/ui 0.0.0-dev-735 → 0.0.0-dev-767

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/components/animated-number-machine.d.ts +95 -0
  2. package/dist/components/image-flight-machine.d.ts +135 -0
  3. package/dist/components/image-zoom-machine.d.ts +95 -0
  4. package/dist/components/image-zoom.d.ts +6 -3
  5. package/dist/components/popover-machine.d.ts +96 -0
  6. package/dist/components/popover.d.ts +2 -2
  7. package/dist/components/resize-handle-machine.d.ts +71 -0
  8. package/dist/components/scroll-view-machine.d.ts +66 -0
  9. package/dist/components/scroll-view.d.ts +2 -2
  10. package/dist/components/text-field-machine.d.ts +62 -0
  11. package/dist/components/text-reveal-machine.d.ts +90 -0
  12. package/dist/data-display/line-comment/machine.d.ts +157 -0
  13. package/dist/data-display/project-avatar/animation-machine.d.ts +62 -0
  14. package/dist/data-display/project-avatar/animation.d.ts +1 -1
  15. package/dist/feedback/toast/machine.d.ts +57 -0
  16. package/dist/feedback/toast/toast.d.ts +1 -1
  17. package/dist/forms/select/machine.d.ts +45 -0
  18. package/dist/forms/typeahead/machine.d.ts +85 -0
  19. package/dist/navigation/menu/machine.d.ts +49 -0
  20. package/dist/navigation/segmented-control/machine.d.ts +46 -0
  21. package/dist/theme/context.d.ts +20 -9
  22. package/dist/theme/machine.d.ts +174 -0
  23. package/package.json +3 -3
  24. package/src/components/animated-number-machine.ts +214 -0
  25. package/src/components/animated-number.tsx +134 -83
  26. package/src/components/image-flight-machine.ts +247 -0
  27. package/src/components/image-preview.css +5 -2
  28. package/src/components/image-preview.tsx +390 -252
  29. package/src/components/image-zoom-machine.ts +191 -0
  30. package/src/components/image-zoom.ts +22 -14
  31. package/src/components/popover-machine.ts +198 -0
  32. package/src/components/popover.tsx +157 -89
  33. package/src/components/resize-handle-machine.ts +174 -0
  34. package/src/components/resize-handle.tsx +113 -83
  35. package/src/components/scroll-view-machine.ts +231 -0
  36. package/src/components/scroll-view.tsx +163 -116
  37. package/src/components/text-field-machine.ts +102 -0
  38. package/src/components/text-field.tsx +78 -24
  39. package/src/components/text-reveal-machine.ts +184 -0
  40. package/src/components/text-reveal.tsx +96 -93
  41. package/src/data-display/line-comment/line-comment.tsx +154 -178
  42. package/src/data-display/line-comment/machine.ts +392 -0
  43. package/src/data-display/project-avatar/animation-machine.ts +182 -0
  44. package/src/data-display/project-avatar/animation.ts +67 -38
  45. package/src/feedback/toast/machine.ts +115 -0
  46. package/src/feedback/toast/toast.tsx +55 -59
  47. package/src/forms/select/machine.ts +81 -0
  48. package/src/forms/select/select.tsx +49 -27
  49. package/src/forms/typeahead/machine.ts +253 -0
  50. package/src/forms/typeahead/typeahead.tsx +70 -62
  51. package/src/navigation/menu/machine.ts +109 -0
  52. package/src/navigation/menu/menu.tsx +118 -20
  53. package/src/navigation/segmented-control/machine.ts +72 -0
  54. package/src/navigation/segmented-control/segmented-control.tsx +46 -46
  55. package/src/theme/context.tsx +134 -240
  56. package/src/theme/machine.ts +508 -0
@@ -0,0 +1,90 @@
1
+ /** Fonts that never settle must not keep the reveal from animating. */
2
+ export declare const TEXT_REVEAL_READY_TIMEOUT_MS = 1000;
3
+ /**
4
+ * `measuring` waits for fonts and one painted frame before transitions turn on, so the first text never animates in.
5
+ * It only moves forward, so its results match on the phase. `swapping` holds a replaced text in place for one frame,
6
+ * then the wipe runs. `leaving` is always text that was on screen, so text replaced within one frame never wipes out.
7
+ */
8
+ export type TextRevealState = {
9
+ readonly status: "measuring";
10
+ readonly current: string | undefined;
11
+ readonly widthPx: number;
12
+ } | {
13
+ readonly status: "idle";
14
+ readonly issued: number;
15
+ readonly current: string | undefined;
16
+ readonly leaving: string | undefined;
17
+ readonly widthPx: number;
18
+ } | {
19
+ readonly status: "swapping";
20
+ readonly attempt: number;
21
+ readonly current: string | undefined;
22
+ readonly leaving: string | undefined;
23
+ readonly widthPx: number;
24
+ } | {
25
+ readonly status: "disposed";
26
+ };
27
+ type Measured = {
28
+ readonly widthPx: number;
29
+ readonly growOnly: boolean;
30
+ };
31
+ export type TextRevealEvent = {
32
+ readonly type: "text.changed";
33
+ readonly text: string | undefined;
34
+ } | ({
35
+ readonly type: "width.measured";
36
+ } & Measured) | ({
37
+ readonly type: "fonts.settled";
38
+ } & Measured) | ({
39
+ readonly type: "ready.settled";
40
+ } & Measured) | ({
41
+ readonly type: "ready.timed-out";
42
+ } & Measured) | ({
43
+ readonly type: "swap.settled";
44
+ readonly attempt: number;
45
+ } & Measured) | {
46
+ readonly type: "disposed";
47
+ };
48
+ export type TextRevealEffect = {
49
+ readonly type: "measure.entering";
50
+ } | {
51
+ readonly type: "ready.frame";
52
+ } | {
53
+ readonly type: "swap.frame";
54
+ readonly attempt: number;
55
+ } | {
56
+ readonly type: "cancel.frame";
57
+ } | {
58
+ readonly type: "cancel.ready-timer";
59
+ };
60
+ export type TextRevealTransition = {
61
+ readonly state: TextRevealState;
62
+ readonly effects: readonly TextRevealEffect[];
63
+ };
64
+ export declare function createTextRevealState(text: string | undefined): TextRevealState;
65
+ export declare function transitionTextReveal(state: TextRevealState, event: TextRevealEvent): TextRevealTransition;
66
+ /** Transitions turn on once the first text has painted. */
67
+ export declare function selectTextRevealReady(state: TextRevealState): state is {
68
+ readonly status: "idle";
69
+ readonly issued: number;
70
+ readonly current: string | undefined;
71
+ readonly leaving: string | undefined;
72
+ readonly widthPx: number;
73
+ } | {
74
+ readonly status: "swapping";
75
+ readonly attempt: number;
76
+ readonly current: string | undefined;
77
+ readonly leaving: string | undefined;
78
+ readonly widthPx: number;
79
+ };
80
+ export declare function selectTextRevealSwapping(state: TextRevealState): state is {
81
+ readonly status: "swapping";
82
+ readonly attempt: number;
83
+ readonly current: string | undefined;
84
+ readonly leaving: string | undefined;
85
+ readonly widthPx: number;
86
+ };
87
+ export declare function selectTextRevealEntering(state: TextRevealState): string;
88
+ export declare function selectTextRevealLeaving(state: TextRevealState): string;
89
+ export declare function selectTextRevealTrackWidth(state: TextRevealState, truncate: boolean | undefined): string;
90
+ export {};
@@ -0,0 +1,157 @@
1
+ export declare const MENTION_LIMIT = 10;
2
+ /** A file search that never answers stops holding Enter and Tab after this long. */
3
+ export declare const MENTION_TIMEOUT_MS = 5000;
4
+ /** The `@query` the caret sits at the end of, and where it starts and ends in the value. */
5
+ export type MentionToken = {
6
+ readonly query: string;
7
+ readonly start: number;
8
+ readonly end: number;
9
+ };
10
+ /** The editor props the machine reads, captured when the event happens. */
11
+ export type LineCommentEditorConfig = {
12
+ readonly value: string;
13
+ readonly allowEmpty: boolean;
14
+ readonly variant: "default" | "compact";
15
+ readonly alternateSubmit: {
16
+ readonly disabled: boolean;
17
+ } | null;
18
+ readonly submitting: boolean;
19
+ };
20
+ /**
21
+ * `alternate` is whether Mod is held over a compact editor with an alternate submit. `attempt` counts mention
22
+ * searches; only the search a `mention-loading` state started may settle it.
23
+ */
24
+ export type LineCommentEditorState = {
25
+ readonly status: "editing";
26
+ readonly attempt: number;
27
+ readonly alternate: boolean;
28
+ /** A token the user closed with Escape, or that found nothing, stays closed while the caret stays on it. */
29
+ readonly dismissed: {
30
+ readonly start: number;
31
+ readonly query: string;
32
+ } | null;
33
+ } | {
34
+ readonly status: "mention-loading";
35
+ readonly attempt: number;
36
+ readonly alternate: boolean;
37
+ readonly token: MentionToken;
38
+ /** The previous results while the user refines the same token, so the list does not flash between keystrokes. */
39
+ readonly items: readonly string[];
40
+ readonly activeIndex: number;
41
+ } | {
42
+ readonly status: "mention-open";
43
+ readonly attempt: number;
44
+ readonly alternate: boolean;
45
+ readonly token: MentionToken;
46
+ /** Never empty, and at most `MENTION_LIMIT`: every item is on screen. */
47
+ readonly items: readonly string[];
48
+ readonly activeIndex: number;
49
+ }
50
+ /** The owner set `submitting`: the draft is read-only until it clears. */
51
+ | {
52
+ readonly status: "submitting";
53
+ readonly attempt: number;
54
+ readonly alternate: boolean;
55
+ } | {
56
+ readonly status: "disposed";
57
+ };
58
+ export type LineCommentEditorKey = {
59
+ readonly key: string;
60
+ readonly ctrl: boolean;
61
+ readonly meta: boolean;
62
+ readonly alt: boolean;
63
+ readonly shift: boolean;
64
+ readonly repeat: boolean;
65
+ };
66
+ export type LineCommentEditorEvent =
67
+ /** Props changed, or the owner replaced the value; `token` is read from the textarea after the change. */
68
+ {
69
+ readonly type: "props.synced";
70
+ readonly config: LineCommentEditorConfig;
71
+ readonly token: MentionToken | null;
72
+ }
73
+ /** The user typed or moved the caret. `token` is null without a `mention` prop. */
74
+ | {
75
+ readonly type: "mention.synced";
76
+ readonly token: MentionToken | null;
77
+ } | {
78
+ readonly type: "mention.loaded";
79
+ readonly attempt: number;
80
+ readonly items: readonly string[];
81
+ } | {
82
+ readonly type: "mention.failed";
83
+ readonly attempt: number;
84
+ } | {
85
+ readonly type: "mention.timeout";
86
+ readonly attempt: number;
87
+ } | {
88
+ readonly type: "mention.hovered";
89
+ readonly index: number;
90
+ } | {
91
+ readonly type: "mention.selected";
92
+ readonly index: number;
93
+ } | {
94
+ readonly type: "modifier.changed";
95
+ readonly active: boolean;
96
+ readonly config: LineCommentEditorConfig;
97
+ } | {
98
+ readonly type: "window.blurred";
99
+ }
100
+ /** A key outside an IME composition, in the textarea or on the compact action. */
101
+ | (LineCommentEditorKey & {
102
+ readonly type: "key.down";
103
+ readonly target: "textarea" | "action";
104
+ readonly config: LineCommentEditorConfig;
105
+ }) | {
106
+ readonly type: "action.clicked";
107
+ readonly modified: boolean;
108
+ readonly config: LineCommentEditorConfig;
109
+ }
110
+ /** The default layout's Submit button. */
111
+ | {
112
+ readonly type: "submit.requested";
113
+ readonly config: LineCommentEditorConfig;
114
+ }
115
+ /** The default layout's Cancel button. */
116
+ | {
117
+ readonly type: "cancel.requested";
118
+ } | {
119
+ readonly type: "disposed";
120
+ };
121
+ export type LineCommentEditorEffect = {
122
+ readonly type: "mention.load";
123
+ readonly attempt: number;
124
+ readonly query: string;
125
+ } | {
126
+ readonly type: "mention.insert";
127
+ readonly path: string;
128
+ readonly token: MentionToken;
129
+ } | {
130
+ readonly type: "submit";
131
+ readonly mode: "primary" | "alternate";
132
+ readonly value: string;
133
+ } | {
134
+ readonly type: "cancel";
135
+ readonly blur: boolean;
136
+ };
137
+ export type LineCommentEditorTransition = {
138
+ readonly state: LineCommentEditorState;
139
+ readonly effects: readonly LineCommentEditorEffect[];
140
+ /** The key event belongs to the editor: the driver calls `preventDefault()`. */
141
+ readonly handled: boolean;
142
+ };
143
+ export declare function createLineCommentEditorState(): LineCommentEditorState;
144
+ /** The mention token the caret sits at the end of, or null for a selection, a bare `@`, or no `@` at all. */
145
+ export declare function parseMentionToken(value: string, selectionStart: number | null, selectionEnd: number | null): MentionToken | null;
146
+ export declare function transitionLineCommentEditor(state: LineCommentEditorState, event: LineCommentEditorEvent): LineCommentEditorTransition;
147
+ export declare function viewLineCommentEditor(state: LineCommentEditorState, config: LineCommentEditorConfig): {
148
+ readonly submitting: boolean;
149
+ readonly canSubmit: boolean;
150
+ readonly compactCancel: boolean;
151
+ readonly alternateActive: boolean;
152
+ readonly trackModifiers: boolean;
153
+ readonly compactVariant: "ghost-muted" | "neutral" | "submit";
154
+ readonly compactDisabled: boolean;
155
+ readonly mentionItems: readonly string[];
156
+ readonly activeMentionPath: string | null;
157
+ };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * A hovered generated avatar's animation. It runs once per frame, so it never allocates: every state and transition is
3
+ * a frozen module singleton, events are reused by the driver, and the continuous time lives in an `AvatarClock` that
4
+ * only `transitionAvatarAnimation` writes.
5
+ */
6
+ export declare const AVATAR_REST_MS = 150;
7
+ export declare const AVATAR_MAX_STEP_S = 0.1;
8
+ export declare const AVATAR_DECAY_BASE = 0.002;
9
+ export declare const AVATAR_SETTLE_EPSILON = 0.01;
10
+ export type AvatarAnimationState = {
11
+ readonly status: "static";
12
+ }
13
+ /** Hovered, waiting out the rest delay before the first animated frame. */
14
+ | {
15
+ readonly status: "resting";
16
+ } | {
17
+ readonly status: "animating";
18
+ }
19
+ /** The pointer left; the animation slows back to the static frame. */
20
+ | {
21
+ readonly status: "easing";
22
+ } | {
23
+ readonly status: "disposed";
24
+ };
25
+ export type AvatarClock = {
26
+ entered: number;
27
+ last: number;
28
+ time: number;
29
+ };
30
+ export type AvatarAnimationEvent = {
31
+ readonly type: "pointer.entered";
32
+ now: number;
33
+ reduced: boolean;
34
+ } | {
35
+ readonly type: "pointer.left";
36
+ } | {
37
+ readonly type: "frame";
38
+ now: number;
39
+ } | {
40
+ readonly type: "motion.changed";
41
+ reduced: boolean;
42
+ } | {
43
+ readonly type: "refresh";
44
+ } | {
45
+ readonly type: "disposed";
46
+ };
47
+ export type AvatarAnimationEffect = "none" | "paint-static" | "paint-frame";
48
+ export type AvatarAnimationTransition = {
49
+ readonly state: AvatarAnimationState;
50
+ readonly effect: AvatarAnimationEffect;
51
+ };
52
+ export declare const INITIAL_AVATAR_ANIMATION_STATE: {
53
+ readonly status: "static";
54
+ };
55
+ export declare const AVATAR_POINTER_LEFT: AvatarAnimationEvent;
56
+ export declare const AVATAR_REFRESH: AvatarAnimationEvent;
57
+ export declare const AVATAR_DISPOSED: AvatarAnimationEvent;
58
+ export declare function createAvatarClock(): AvatarClock;
59
+ export declare function transitionAvatarAnimation(state: AvatarAnimationState, clock: AvatarClock, event: AvatarAnimationEvent): AvatarAnimationTransition;
60
+ /** Hovered or easing: the driver runs the frame loop and follows the reduce motion setting. */
61
+ export declare function selectAvatarRunning(state: AvatarAnimationState): boolean;
62
+ export declare function selectAvatarPaintTime(state: AvatarAnimationState, clock: Readonly<AvatarClock>): number;
@@ -1,6 +1,6 @@
1
1
  import { type GeneratedProjectIcon } from "./generated";
2
2
  export declare function attachGeneratedAvatar(canvas: HTMLCanvasElement, icon: () => GeneratedProjectIcon): {
3
3
  /** Repaints the static frame unless the avatar is animating, e.g. after the icon changed. */
4
- refresh: () => void | false;
4
+ refresh: () => void;
5
5
  dispose: () => void;
6
6
  };
@@ -0,0 +1,57 @@
1
+ export type ToastRegistryEntry<O> = {
2
+ readonly id: number;
3
+ /** Same title, description, variant, timing and action labels coalesce into one toast. */
4
+ readonly key: string;
5
+ readonly options: O;
6
+ };
7
+ /**
8
+ * The toasts `showToast` and `toaster` have published and not yet seen close. Each entry lives from its publish
9
+ * until solid-sonner reports it closed (`onDismiss`, `onAutoClose`), `toaster.dismiss` closes it, or a later show
10
+ * finds it missing from solid-sonner's live toasts.
11
+ */
12
+ export type ToastRegistryState<O> = {
13
+ /** Last allocated id. IDs count down from `-1`: solid-sonner treats a falsy id as "dismiss every toast". */
14
+ readonly nextId: number;
15
+ readonly entries: readonly ToastRegistryEntry<O>[];
16
+ };
17
+ export type ToastShownEvent<O> = {
18
+ readonly type: "toast.shown";
19
+ readonly key: string;
20
+ readonly options: O;
21
+ /** IDs solid-sonner still holds, from `toast.getToasts()`, which also lists toasts other code shows. */
22
+ readonly liveIds: ReadonlySet<number | string>;
23
+ /** The newest of them, shown in front. */
24
+ readonly topmostLiveId: number | string | undefined;
25
+ };
26
+ export type ToastRegistryEvent<O> = {
27
+ readonly type: "custom.shown";
28
+ } | ToastShownEvent<O> | {
29
+ readonly type: "toast.released";
30
+ readonly id: number;
31
+ } | {
32
+ readonly type: "toast.dismissed";
33
+ readonly id?: number;
34
+ };
35
+ export type ToastRegistryEffect<O> = {
36
+ readonly type: "sonner.publish";
37
+ readonly id: number;
38
+ readonly options: O;
39
+ } | {
40
+ readonly type: "sonner.dismiss";
41
+ readonly id?: number;
42
+ } | {
43
+ readonly type: "dom.pulse";
44
+ readonly id: number;
45
+ };
46
+ export type ToastRegistryTransition<O> = {
47
+ readonly state: ToastRegistryState<O>;
48
+ /** The toast a `toast.shown` event showed. */
49
+ readonly id?: number;
50
+ readonly effects: readonly ToastRegistryEffect<O>[];
51
+ };
52
+ export declare function createToastRegistryState<O>(): ToastRegistryState<O>;
53
+ export declare function transitionToastRegistry<O>(state: ToastRegistryState<O>, event: ToastShownEvent<O>): ToastRegistryTransition<O> & {
54
+ readonly id: number;
55
+ };
56
+ export declare function transitionToastRegistry<O>(state: ToastRegistryState<O>, event: ToastRegistryEvent<O>): ToastRegistryTransition<O>;
57
+ export declare function selectToastOptions<O>(state: ToastRegistryState<O>, id: number): O | undefined;
@@ -34,7 +34,7 @@ export declare const toaster: {
34
34
  /** Reactive value the toast's height depends on; sonner re-measures when it changes. */
35
35
  resize?: () => void;
36
36
  }): number;
37
- dismiss(toastId?: number): string | number | undefined;
37
+ dismiss(toastId?: number): number | undefined;
38
38
  };
39
39
  export interface ToastAction {
40
40
  label: string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The preview a `<Select>` shows for its highlighted option (`onHighlight`, which may return an undo). Unlike a one-shot
3
+ * palette, a select opens and closes repeatedly: choosing the previewed option keeps its preview, choosing another
4
+ * reverts it first, and closing without a choice reverts it. Nothing previews while the menu is closed or closing.
5
+ */
6
+ export type SelectHighlightState = {
7
+ readonly status: "closed";
8
+ } | {
9
+ readonly status: "idle";
10
+ } | {
11
+ readonly status: "previewing";
12
+ readonly key: string;
13
+ } | {
14
+ readonly status: "committed";
15
+ } | {
16
+ readonly status: "disposed";
17
+ };
18
+ export type SelectHighlightEvent = {
19
+ readonly type: "open.changed";
20
+ readonly open: boolean;
21
+ } | {
22
+ readonly type: "highlight.changed";
23
+ readonly key: string;
24
+ readonly previewable: boolean;
25
+ }
26
+ /** `closing` is whether the menu closes on this choice (`closeOnSelection`). */
27
+ | {
28
+ readonly type: "option.selected";
29
+ readonly key: string | undefined;
30
+ readonly closing: boolean;
31
+ } | {
32
+ readonly type: "disposed";
33
+ };
34
+ export type SelectHighlightEffect = {
35
+ readonly type: "preview.apply";
36
+ readonly key: string;
37
+ } | {
38
+ readonly type: "preview.revert";
39
+ };
40
+ export type SelectHighlightTransition = {
41
+ readonly state: SelectHighlightState;
42
+ readonly effects: readonly SelectHighlightEffect[];
43
+ };
44
+ export declare function createSelectHighlightState(open: boolean): SelectHighlightState;
45
+ export declare function transitionSelectHighlight(state: SelectHighlightState, event: SelectHighlightEvent): SelectHighlightTransition;
@@ -0,0 +1,85 @@
1
+ export declare const TYPEAHEAD_REQUEST_TIMEOUT_MS = 15000;
2
+ export type TypeaheadInitial<T> = {
3
+ readonly items: T[];
4
+ readonly failed?: boolean;
5
+ };
6
+ type TypeaheadLive<T> = {
7
+ /** The input's text; the query is this text trimmed. */
8
+ readonly input: string;
9
+ /** The user has typed, so later result changes animate the list height. */
10
+ readonly searched: boolean;
11
+ /** Some answer has arrived, so the empty row may show. */
12
+ readonly answered: boolean;
13
+ /** The parent's opening results, shown for the empty query. */
14
+ readonly initial: TypeaheadInitial<T> | undefined;
15
+ readonly cache: ReadonlyMap<string, T[]>;
16
+ readonly shown: T[];
17
+ /** `shown` holds rows the pending query does not match; they stay dimmed instead of collapsing the list. */
18
+ readonly stale: boolean;
19
+ /** The last attempt issued, so the next request gets a fresh one. */
20
+ readonly issued: number;
21
+ };
22
+ /**
23
+ * `debouncing` waits for typing to pause; `loading` has a request in flight. Both name their `attempt`, and a timer or
24
+ * result from another attempt is ignored. `failed` is the current query's failure only.
25
+ */
26
+ export type TypeaheadState<T> = (TypeaheadLive<T> & {
27
+ readonly status: "ready" | "failed";
28
+ }) | (TypeaheadLive<T> & {
29
+ readonly status: "debouncing" | "loading";
30
+ readonly attempt: number;
31
+ }) | {
32
+ readonly status: "disposed";
33
+ };
34
+ export type TypeaheadEvent<T> = {
35
+ readonly type: "initial.synced";
36
+ readonly initial: TypeaheadInitial<T> | undefined;
37
+ } | {
38
+ readonly type: "input.changed";
39
+ readonly input: string;
40
+ readonly delayMs: number;
41
+ readonly match: (item: T, query: string) => boolean;
42
+ } | {
43
+ readonly type: "debounce.elapsed";
44
+ readonly attempt: number;
45
+ } | {
46
+ readonly type: "retry.requested";
47
+ } | {
48
+ readonly type: "request.succeeded";
49
+ readonly attempt: number;
50
+ readonly items: T[];
51
+ } | {
52
+ readonly type: "request.failed";
53
+ readonly attempt: number;
54
+ } | {
55
+ readonly type: "request.timed-out";
56
+ readonly attempt: number;
57
+ } | {
58
+ readonly type: "disposed";
59
+ };
60
+ /** Each effect first cancels the pending debounce or request, then starts its own work. */
61
+ export type TypeaheadEffect = {
62
+ readonly type: "cancel";
63
+ } | {
64
+ readonly type: "debounce";
65
+ readonly attempt: number;
66
+ readonly delayMs: number;
67
+ } | {
68
+ readonly type: "request";
69
+ readonly attempt: number;
70
+ readonly query: string;
71
+ };
72
+ export type TypeaheadTransition<T> = {
73
+ readonly state: TypeaheadState<T>;
74
+ readonly effects: readonly TypeaheadEffect[];
75
+ };
76
+ export declare function createTypeaheadState<T>(initial: TypeaheadInitial<T> | undefined): TypeaheadTransition<T>;
77
+ export declare function transitionTypeahead<T>(state: TypeaheadState<T>, event: TypeaheadEvent<T>): TypeaheadTransition<T>;
78
+ export declare function selectTypeaheadInput<T>(state: TypeaheadState<T>): string;
79
+ export declare function selectTypeaheadPending<T>(state: TypeaheadState<T>): boolean;
80
+ export declare function selectTypeaheadFailed<T>(state: TypeaheadState<T>): boolean;
81
+ export declare function selectTypeaheadItems<T>(state: TypeaheadState<T>): T[];
82
+ export declare function selectTypeaheadStale<T>(state: TypeaheadState<T>): boolean;
83
+ export declare function selectTypeaheadAnimateHeight<T>(state: TypeaheadState<T>): boolean;
84
+ export declare function selectTypeaheadAnswered<T>(state: TypeaheadState<T>): boolean;
85
+ export {};
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Every dropdown menu runs this machine, so each reachable state and event is a frozen module singleton, and an event
3
+ * that changes nothing returns the state it was given.
4
+ */
5
+ export type MenuInputGesture = "pointer" | "keyboard" | "none";
6
+ /** How the menu opened. An open without an input gesture (a shortcut handler, an async action) is `programmatic`. */
7
+ export type MenuOpenModality = "pointer" | "keyboard" | "programmatic";
8
+ export type MenuState = {
9
+ readonly status: "closed";
10
+ } | {
11
+ readonly status: "open";
12
+ readonly modality: MenuOpenModality;
13
+ readonly outsideInteracted: boolean;
14
+ }
15
+ /**
16
+ * Kobalte reports the close first and restores focus a task later, so the modality outlives the open state until
17
+ * that focus restore has run.
18
+ */
19
+ | {
20
+ readonly status: "closing";
21
+ readonly modality: MenuOpenModality;
22
+ readonly outsideInteracted: boolean;
23
+ } | {
24
+ readonly status: "disposed";
25
+ };
26
+ export type MenuEvent = {
27
+ readonly type: "open.changed";
28
+ readonly open: boolean;
29
+ readonly gesture: MenuInputGesture;
30
+ }
31
+ /** A press outside a non-modal menu, or a context menu anywhere, dismissed it and keeps focus where it landed. */
32
+ | {
33
+ readonly type: "outside.interacted";
34
+ } | {
35
+ readonly type: "close.autofocus";
36
+ } | {
37
+ readonly type: "disposed";
38
+ };
39
+ export declare const MENU_OUTSIDE_INTERACTED: MenuEvent;
40
+ export declare const MENU_CLOSE_AUTOFOCUS: MenuEvent;
41
+ export declare const MENU_DISPOSED: MenuEvent;
42
+ export declare function openChangedEvent(isOpen: boolean, gesture: MenuInputGesture): MenuEvent;
43
+ export declare function createMenuState(initialOpen: boolean): MenuState;
44
+ export declare function transitionMenu(state: MenuState, event: MenuEvent): MenuState;
45
+ /**
46
+ * Restore focus to the trigger without a focus ring: Escape counts as keyboard use, so Chromium would ring a trigger
47
+ * the pointer opened. After an outside press, focus stays where that press put it.
48
+ */
49
+ export declare function selectMenuRestoreTriggerWithoutRing(state: MenuState): boolean;
@@ -0,0 +1,46 @@
1
+ export type IndicatorBox = {
2
+ readonly x: number;
3
+ readonly width: number;
4
+ };
5
+ /**
6
+ * The pill behind the selected segment. It is `placed` only while the selected segment has a measurable box, so a
7
+ * selection that changes while the control is hidden (`display: none`) jumps to its segment once it shows instead
8
+ * of springing from the previous segment's stale position.
9
+ */
10
+ export type SegmentedIndicatorState = {
11
+ readonly status: "hidden";
12
+ } | {
13
+ readonly status: "placed";
14
+ readonly value: string;
15
+ readonly box: IndicatorBox;
16
+ } | {
17
+ readonly status: "disposed";
18
+ };
19
+ export type SegmentedIndicatorEvent = {
20
+ readonly type: "measured";
21
+ readonly value: string | null;
22
+ readonly box: IndicatorBox | null;
23
+ readonly reducedMotion: boolean;
24
+ } | {
25
+ readonly type: "disposed";
26
+ };
27
+ export type SegmentedIndicatorEffect = {
28
+ readonly type: "jump";
29
+ readonly box: IndicatorBox;
30
+ } | {
31
+ readonly type: "animate";
32
+ readonly box: IndicatorBox;
33
+ } | {
34
+ readonly type: "stop";
35
+ };
36
+ export type SegmentedIndicatorTransition = {
37
+ readonly state: SegmentedIndicatorState;
38
+ readonly effect: SegmentedIndicatorEffect | null;
39
+ };
40
+ export declare const HIDDEN_INDICATOR: SegmentedIndicatorState;
41
+ export declare function transitionSegmentedIndicator(state: SegmentedIndicatorState, event: SegmentedIndicatorEvent): SegmentedIndicatorTransition;
42
+ export declare function selectIndicatorReady(state: SegmentedIndicatorState): state is {
43
+ readonly status: "placed";
44
+ readonly value: string;
45
+ readonly box: IndicatorBox;
46
+ };
@@ -1,14 +1,18 @@
1
1
  import type { DesktopTheme } from "./types";
2
- export type ColorScheme = "light" | "dark" | "system";
2
+ import { type ColorScheme } from "./machine";
3
+ export type { ColorScheme } from "./machine";
3
4
  export declare const { use: useTheme, provider: ThemeProvider }: {
4
5
  context: import("solid-js").Context<{
6
+ /** The theme the window shows: a previewed one, the selected one, or the default while that one is not coming. */
5
7
  themeId: import("solid-js").Accessor<string>;
6
- colorScheme: () => ColorScheme;
7
- mode: () => "dark" | "light";
8
+ colorScheme: import("solid-js").Accessor<ColorScheme>;
9
+ /** The mode the window shows, a previewed scheme included. */
10
+ mode: import("solid-js").Accessor<import("./machine").ResolvedMode>;
8
11
  ids: () => string[];
9
12
  name: (id: string) => string;
10
- loadThemes: () => Promise<Record<string, DesktopTheme>>;
11
- themes: () => Record<string, DesktopTheme>;
13
+ /** Loads every bundled theme; resolves once each import has loaded, failed or timed out. */
14
+ loadThemes: () => Promise<Readonly<Record<string, DesktopTheme>>>;
15
+ themes: () => Readonly<Record<string, DesktopTheme>>;
12
16
  setTheme: (id: string) => void;
13
17
  setColorScheme: (scheme: ColorScheme) => void;
14
18
  /** Lists a theme beside the bundled ones until the returned function withdraws it. */
@@ -18,7 +22,9 @@ export declare const { use: useTheme, provider: ThemeProvider }: {
18
22
  * window shows the default theme and keeps the choice for when it returns.
19
23
  */
20
24
  settle: () => void;
25
+ /** Shows a theme without saving it, until `commitPreview` or `cancelPreview`. */
21
26
  previewTheme: (id: string) => void;
27
+ /** Shows a color scheme without saving it, until `commitPreview` or `cancelPreview`. */
22
28
  previewColorScheme: (scheme: ColorScheme) => void;
23
29
  commitPreview: () => void;
24
30
  cancelPreview: () => void;
@@ -29,13 +35,16 @@ export declare const { use: useTheme, provider: ThemeProvider }: {
29
35
  onThemeApplied?: (mode: "light" | "dark", scheme: ColorScheme) => void;
30
36
  }>) => import("solid-js").JSX.Element;
31
37
  use(): {
38
+ /** The theme the window shows: a previewed one, the selected one, or the default while that one is not coming. */
32
39
  themeId: import("solid-js").Accessor<string>;
33
- colorScheme: () => ColorScheme;
34
- mode: () => "dark" | "light";
40
+ colorScheme: import("solid-js").Accessor<ColorScheme>;
41
+ /** The mode the window shows, a previewed scheme included. */
42
+ mode: import("solid-js").Accessor<import("./machine").ResolvedMode>;
35
43
  ids: () => string[];
36
44
  name: (id: string) => string;
37
- loadThemes: () => Promise<Record<string, DesktopTheme>>;
38
- themes: () => Record<string, DesktopTheme>;
45
+ /** Loads every bundled theme; resolves once each import has loaded, failed or timed out. */
46
+ loadThemes: () => Promise<Readonly<Record<string, DesktopTheme>>>;
47
+ themes: () => Readonly<Record<string, DesktopTheme>>;
39
48
  setTheme: (id: string) => void;
40
49
  setColorScheme: (scheme: ColorScheme) => void;
41
50
  /** Lists a theme beside the bundled ones until the returned function withdraws it. */
@@ -45,7 +54,9 @@ export declare const { use: useTheme, provider: ThemeProvider }: {
45
54
  * window shows the default theme and keeps the choice for when it returns.
46
55
  */
47
56
  settle: () => void;
57
+ /** Shows a theme without saving it, until `commitPreview` or `cancelPreview`. */
48
58
  previewTheme: (id: string) => void;
59
+ /** Shows a color scheme without saving it, until `commitPreview` or `cancelPreview`. */
49
60
  previewColorScheme: (scheme: ColorScheme) => void;
50
61
  commitPreview: () => void;
51
62
  cancelPreview: () => void;