@opencode/ui 0.0.0-dev-750 → 0.0.0-dev-784
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.
- package/dist/components/animated-number-machine.d.ts +95 -0
- package/dist/components/popover-machine.d.ts +96 -0
- package/dist/components/popover.d.ts +2 -2
- package/dist/components/resize-handle-machine.d.ts +71 -0
- package/dist/components/scroll-view-machine.d.ts +66 -0
- package/dist/components/scroll-view.d.ts +2 -2
- package/dist/components/text-field-machine.d.ts +62 -0
- package/dist/components/text-reveal-machine.d.ts +90 -0
- package/dist/data-display/line-comment/machine.d.ts +157 -0
- package/dist/data-display/project-avatar/animation-machine.d.ts +62 -0
- package/dist/data-display/project-avatar/animation.d.ts +1 -1
- package/dist/feedback/toast/machine.d.ts +57 -0
- package/dist/feedback/toast/toast.d.ts +1 -1
- package/dist/forms/select/machine.d.ts +45 -0
- package/dist/forms/typeahead/machine.d.ts +85 -0
- package/dist/navigation/menu/machine.d.ts +49 -0
- package/dist/navigation/segmented-control/machine.d.ts +46 -0
- package/dist/theme/context.d.ts +20 -9
- package/dist/theme/machine.d.ts +174 -0
- package/package.json +2 -2
- package/src/components/animated-number-machine.ts +214 -0
- package/src/components/animated-number.tsx +134 -83
- package/src/components/popover-machine.ts +198 -0
- package/src/components/popover.tsx +157 -89
- package/src/components/resize-handle-machine.ts +174 -0
- package/src/components/resize-handle.tsx +113 -83
- package/src/components/scroll-view-machine.ts +231 -0
- package/src/components/scroll-view.tsx +163 -116
- package/src/components/text-field-machine.ts +102 -0
- package/src/components/text-field.tsx +78 -24
- package/src/components/text-reveal-machine.ts +184 -0
- package/src/components/text-reveal.tsx +96 -93
- package/src/data-display/line-comment/line-comment.tsx +154 -178
- package/src/data-display/line-comment/machine.ts +392 -0
- package/src/data-display/project-avatar/animation-machine.ts +182 -0
- package/src/data-display/project-avatar/animation.ts +67 -38
- package/src/feedback/toast/machine.ts +115 -0
- package/src/feedback/toast/toast.tsx +55 -59
- package/src/forms/select/machine.ts +81 -0
- package/src/forms/select/select.tsx +49 -27
- package/src/forms/typeahead/machine.ts +253 -0
- package/src/forms/typeahead/typeahead.tsx +70 -62
- package/src/navigation/menu/machine.ts +109 -0
- package/src/navigation/menu/menu.tsx +118 -20
- package/src/navigation/segmented-control/machine.ts +72 -0
- package/src/navigation/segmented-control/segmented-control.tsx +46 -46
- package/src/theme/context.tsx +134 -240
- package/src/theme/machine.ts +508 -0
|
@@ -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
|
|
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):
|
|
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
|
+
};
|
package/dist/theme/context.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { DesktopTheme } from "./types";
|
|
2
|
-
|
|
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: ()
|
|
7
|
-
mode
|
|
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
|
-
|
|
11
|
-
|
|
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: ()
|
|
34
|
-
mode
|
|
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
|
-
|
|
38
|
-
|
|
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;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { DesktopTheme } from "./types";
|
|
2
|
+
export type ColorScheme = "light" | "dark" | "system";
|
|
3
|
+
export type ResolvedMode = "light" | "dark";
|
|
4
|
+
export declare const DEFAULT_THEME_ID = "oc-2";
|
|
5
|
+
/** A bundled theme import that has not settled by then shows the default theme until it arrives. */
|
|
6
|
+
export declare const THEME_LOAD_TIMEOUT_MS = 5000;
|
|
7
|
+
export type ThemeSelection = {
|
|
8
|
+
readonly themeId: string;
|
|
9
|
+
readonly scheme: ColorScheme;
|
|
10
|
+
};
|
|
11
|
+
/** Overrides one or both axes of the committed selection; a preview with neither is `committed`. */
|
|
12
|
+
export type ThemePreview = {
|
|
13
|
+
readonly themeId?: string;
|
|
14
|
+
readonly scheme?: ColorScheme;
|
|
15
|
+
};
|
|
16
|
+
/** What the window shows. `preload` is a registered theme that may still arrive: the cached colors stay on screen. */
|
|
17
|
+
export type AppliedTheme = {
|
|
18
|
+
readonly kind: "theme";
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly theme: DesktopTheme;
|
|
21
|
+
readonly mode: ResolvedMode;
|
|
22
|
+
readonly scheme: ColorScheme;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "preload";
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly mode: ResolvedMode;
|
|
27
|
+
readonly scheme: ColorScheme;
|
|
28
|
+
};
|
|
29
|
+
/** The colors in localStorage that the next start paints before the app loads. `unknown` keeps the last run's. */
|
|
30
|
+
export type CachedTheme = {
|
|
31
|
+
readonly status: "unknown";
|
|
32
|
+
} | {
|
|
33
|
+
readonly status: "cleared";
|
|
34
|
+
} | {
|
|
35
|
+
readonly status: "cached";
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly theme: DesktopTheme;
|
|
38
|
+
};
|
|
39
|
+
type ThemeData = {
|
|
40
|
+
readonly committed: ThemeSelection;
|
|
41
|
+
readonly systemMode: ResolvedMode;
|
|
42
|
+
/** `settled` once every theme source has registered what it will: a missing registered theme is not coming. */
|
|
43
|
+
readonly registration: "pending" | "settled";
|
|
44
|
+
/** Loaded bundled themes and registered themes, by id. */
|
|
45
|
+
readonly themes: Readonly<Record<string, DesktopTheme>>;
|
|
46
|
+
/** The attempt of each bundled theme import in flight, including one that timed out and may still arrive. */
|
|
47
|
+
readonly loads: Readonly<Record<string, number>>;
|
|
48
|
+
/**
|
|
49
|
+
* Bundled themes the window shows the default theme for: the import failed, or timed out and may still arrive.
|
|
50
|
+
* Selecting, previewing or preloading one tries again.
|
|
51
|
+
*/
|
|
52
|
+
readonly failed: Readonly<Record<string, true>>;
|
|
53
|
+
readonly issued: number;
|
|
54
|
+
readonly applied: AppliedTheme | undefined;
|
|
55
|
+
readonly cached: CachedTheme;
|
|
56
|
+
};
|
|
57
|
+
export type ThemeMachineState = ({
|
|
58
|
+
readonly status: "committed";
|
|
59
|
+
} & ThemeData) | ({
|
|
60
|
+
readonly status: "previewing";
|
|
61
|
+
readonly preview: ThemePreview;
|
|
62
|
+
} & ThemeData) | ({
|
|
63
|
+
readonly status: "disposed";
|
|
64
|
+
} & ThemeData);
|
|
65
|
+
export type ThemeEvent = {
|
|
66
|
+
readonly type: "theme.selected";
|
|
67
|
+
readonly id: string;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "scheme.selected";
|
|
70
|
+
readonly scheme: ColorScheme;
|
|
71
|
+
} | {
|
|
72
|
+
readonly type: "preview.theme";
|
|
73
|
+
readonly id: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "preview.scheme";
|
|
76
|
+
readonly scheme: ColorScheme;
|
|
77
|
+
} | {
|
|
78
|
+
readonly type: "preview.committed";
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: "preview.cancelled";
|
|
81
|
+
} | {
|
|
82
|
+
readonly type: "theme.registered";
|
|
83
|
+
readonly theme: DesktopTheme;
|
|
84
|
+
} | {
|
|
85
|
+
readonly type: "theme.unregistered";
|
|
86
|
+
readonly theme: DesktopTheme;
|
|
87
|
+
} | {
|
|
88
|
+
readonly type: "settled";
|
|
89
|
+
} | {
|
|
90
|
+
readonly type: "themes.preload";
|
|
91
|
+
} | {
|
|
92
|
+
readonly type: "theme.loaded";
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly attempt: number;
|
|
95
|
+
readonly theme: DesktopTheme;
|
|
96
|
+
} | {
|
|
97
|
+
readonly type: "theme.load.failed";
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly attempt: number;
|
|
100
|
+
} | {
|
|
101
|
+
readonly type: "theme.load.timed-out";
|
|
102
|
+
readonly id: string;
|
|
103
|
+
readonly attempt: number;
|
|
104
|
+
} | {
|
|
105
|
+
readonly type: "system.mode.changed";
|
|
106
|
+
readonly mode: ResolvedMode;
|
|
107
|
+
} | {
|
|
108
|
+
readonly type: "storage.theme.changed";
|
|
109
|
+
readonly id: string;
|
|
110
|
+
} | {
|
|
111
|
+
readonly type: "storage.scheme.changed";
|
|
112
|
+
readonly scheme: ColorScheme;
|
|
113
|
+
} | {
|
|
114
|
+
readonly type: "disposed";
|
|
115
|
+
};
|
|
116
|
+
export type ThemeEffect = {
|
|
117
|
+
readonly type: "load-theme";
|
|
118
|
+
readonly id: string;
|
|
119
|
+
readonly attempt: number;
|
|
120
|
+
readonly timeoutMs: number;
|
|
121
|
+
} | {
|
|
122
|
+
readonly type: "cancel-load-timer";
|
|
123
|
+
readonly attempt: number;
|
|
124
|
+
} | {
|
|
125
|
+
readonly type: "cancel-all-loads";
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: "persist-theme";
|
|
128
|
+
readonly id: string;
|
|
129
|
+
} | {
|
|
130
|
+
readonly type: "persist-scheme";
|
|
131
|
+
readonly scheme: ColorScheme;
|
|
132
|
+
} | {
|
|
133
|
+
readonly type: "cache-theme";
|
|
134
|
+
readonly id: string;
|
|
135
|
+
readonly theme: DesktopTheme;
|
|
136
|
+
} | {
|
|
137
|
+
readonly type: "clear-cache";
|
|
138
|
+
} | {
|
|
139
|
+
readonly type: "apply-theme";
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly theme: DesktopTheme;
|
|
142
|
+
readonly mode: ResolvedMode;
|
|
143
|
+
readonly scheme: ColorScheme;
|
|
144
|
+
} | {
|
|
145
|
+
readonly type: "notify-applied";
|
|
146
|
+
readonly mode: ResolvedMode;
|
|
147
|
+
readonly scheme: ColorScheme;
|
|
148
|
+
} | {
|
|
149
|
+
readonly type: "warn-missing-theme";
|
|
150
|
+
readonly id: string;
|
|
151
|
+
};
|
|
152
|
+
export type ThemeTransition = {
|
|
153
|
+
readonly state: ThemeMachineState;
|
|
154
|
+
readonly effects: readonly ThemeEffect[];
|
|
155
|
+
};
|
|
156
|
+
export declare function parseColorScheme(value: string | null | undefined): ColorScheme;
|
|
157
|
+
export declare function createThemeState(input: {
|
|
158
|
+
readonly themeId: string;
|
|
159
|
+
readonly scheme: ColorScheme;
|
|
160
|
+
readonly systemMode: ResolvedMode;
|
|
161
|
+
readonly defaultTheme: DesktopTheme;
|
|
162
|
+
readonly bundled: ReadonlySet<string>;
|
|
163
|
+
}): ThemeTransition;
|
|
164
|
+
export declare function transitionTheme(state: ThemeMachineState, event: ThemeEvent, bundled: ReadonlySet<string>): ThemeTransition;
|
|
165
|
+
/** The theme the window should show when nothing is previewed. */
|
|
166
|
+
export declare function selectCommittedThemeId(state: ThemeMachineState, bundled: ReadonlySet<string>): string;
|
|
167
|
+
export declare function selectThemeId(state: ThemeMachineState, bundled: ReadonlySet<string>): string;
|
|
168
|
+
/** The scheme the user chose; a preview does not change it. */
|
|
169
|
+
export declare function selectColorScheme(state: ThemeMachineState): ColorScheme;
|
|
170
|
+
/** The light or dark mode the window shows, preview included. */
|
|
171
|
+
export declare function selectMode(state: ThemeMachineState): ResolvedMode;
|
|
172
|
+
/** An import is still within its timeout. */
|
|
173
|
+
export declare function selectThemesLoading(state: ThemeMachineState): boolean;
|
|
174
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencode/ui",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-784",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
"dependencies": {
|
|
289
289
|
"@kitlangton/solid-motion": "0.2.2",
|
|
290
290
|
"@kobalte/core": "0.13.13",
|
|
291
|
-
"@opencode/util": "0.0.0-dev-
|
|
291
|
+
"@opencode/util": "0.0.0-dev-784",
|
|
292
292
|
"@pierre/diffs": "1.6.1",
|
|
293
293
|
"@pierre/highlights": "0.2.0",
|
|
294
294
|
"@solid-primitives/event-listener": "2.4.6",
|