@opencode/ui 2.2.4 → 2.2.6
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/actions/button/button.d.ts +2 -2
- package/dist/actions/icon-button/icon-button.d.ts +1 -1
- package/dist/components/animated-number-machine.d.ts +95 -0
- package/dist/components/file-icon-machine.d.ts +40 -0
- package/dist/components/file-icon.d.ts +0 -2
- package/dist/components/file-icons/choose-icon-name.d.ts +2 -0
- package/dist/components/image-flight-machine.d.ts +135 -0
- package/dist/components/image-zoom-machine.d.ts +95 -0
- package/dist/components/image-zoom.d.ts +6 -3
- package/dist/components/list.d.ts +2 -6
- package/dist/components/menu-scroll.d.ts +12 -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/resize-handle.d.ts +2 -0
- package/dist/components/scroll-view-machine.d.ts +68 -0
- package/dist/components/scroll-view.d.ts +2 -2
- package/dist/components/spinner.d.ts +11 -3
- package/dist/components/text-field-machine.d.ts +62 -0
- package/dist/components/text-reveal-machine.d.ts +90 -0
- package/dist/components/typewriter-machine.d.ts +62 -0
- package/dist/context/dialog-machine.d.ts +125 -0
- package/dist/context/dialog.d.ts +17 -16
- package/dist/data-display/line-comment/line-comment.d.ts +9 -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/activity-ring/activity-ring.d.ts +2 -1
- package/dist/feedback/toast/machine.d.ts +57 -0
- package/dist/feedback/toast/toast.d.ts +1 -1
- package/dist/forms/checkbox/checkbox.d.ts +6 -1
- package/dist/forms/select/machine.d.ts +45 -0
- package/dist/forms/select/select.d.ts +4 -0
- package/dist/forms/text-input/text-input.d.ts +4 -2
- package/dist/forms/textarea/textarea.d.ts +1 -0
- package/dist/forms/typeahead/machine.d.ts +85 -0
- package/dist/hooks/auto-scroll-machine.d.ts +89 -0
- package/dist/hooks/create-auto-scroll.d.ts +1 -1
- package/dist/hooks/list-machine.d.ts +150 -0
- package/dist/hooks/use-filtered-list.d.ts +21 -35
- package/dist/i18n/en.d.ts +5 -0
- package/dist/icons/catalog.d.ts +8 -0
- package/dist/navigation/menu/machine.d.ts +49 -0
- package/dist/navigation/menu/menu.d.ts +5 -3
- package/dist/navigation/segmented-control/machine.d.ts +46 -0
- package/dist/overlays/mcp-sign-in/machine.d.ts +184 -0
- package/dist/overlays/mcp-sign-in/mcp-sign-in.d.ts +40 -0
- package/dist/overlays/tooltip/machine.d.ts +146 -0
- package/dist/theme/context.d.ts +38 -14
- package/dist/theme/machine.d.ts +174 -0
- package/dist/typography/text-shimmer/machine.d.ts +48 -0
- package/package.json +19 -3
- package/src/actions/button/button.tsx +11 -6
- package/src/actions/icon-button/icon-button.tsx +17 -4
- package/src/components/animated-number-machine.ts +214 -0
- package/src/components/animated-number.tsx +134 -83
- package/src/components/file-icon-machine.ts +78 -0
- package/src/components/file-icon.tsx +96 -579
- package/src/components/file-icons/choose-icon-name.ts +574 -0
- package/src/components/image-flight-machine.ts +247 -0
- package/src/components/image-preview.css +5 -2
- package/src/components/image-preview.tsx +390 -252
- package/src/components/image-zoom-machine.ts +191 -0
- package/src/components/image-zoom.ts +22 -14
- package/src/components/list.tsx +46 -137
- package/src/components/menu-scroll.css +70 -0
- package/src/components/menu-scroll.tsx +161 -0
- 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 +116 -67
- package/src/components/scroll-view-machine.ts +244 -0
- package/src/components/scroll-view.tsx +163 -116
- package/src/components/spinner.css +18 -5
- package/src/components/spinner.tsx +28 -14
- 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/components/typewriter-machine.ts +134 -0
- package/src/components/typewriter.tsx +50 -39
- package/src/context/dialog-machine.ts +280 -0
- package/src/context/dialog.tsx +168 -177
- package/src/data-display/line-comment/line-comment.tsx +196 -132
- package/src/data-display/line-comment/machine.ts +391 -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/activity-ring/activity-ring.tsx +1 -1
- package/src/feedback/toast/machine.ts +115 -0
- package/src/feedback/toast/toast.tsx +55 -59
- package/src/forms/checkbox/checkbox-compact.css +169 -0
- package/src/forms/checkbox/checkbox.tsx +93 -31
- package/src/forms/search-list/search-list.css +5 -1
- package/src/forms/search-list/search-list.tsx +4 -4
- package/src/forms/select/machine.ts +81 -0
- package/src/forms/select/select.css +59 -17
- package/src/forms/select/select.tsx +67 -31
- package/src/forms/text-input/text-input.css +30 -16
- package/src/forms/text-input/text-input.tsx +6 -2
- package/src/forms/textarea/textarea.css +13 -8
- package/src/forms/textarea/textarea.tsx +3 -1
- package/src/forms/typeahead/machine.ts +253 -0
- package/src/forms/typeahead/typeahead.tsx +75 -66
- package/src/hooks/auto-scroll-machine.ts +261 -0
- package/src/hooks/create-auto-scroll.tsx +110 -205
- package/src/hooks/list-machine.ts +359 -0
- package/src/hooks/use-filtered-list.tsx +101 -112
- package/src/i18n/en.ts +6 -1
- package/src/icons/catalog.ts +8 -0
- package/src/navigation/menu/machine.ts +109 -0
- package/src/navigation/menu/menu.tsx +130 -22
- package/src/navigation/segmented-control/machine.ts +72 -0
- package/src/navigation/segmented-control/segmented-control.tsx +46 -46
- package/src/overlays/dialog/dialog.tsx +7 -1
- package/src/overlays/mcp-sign-in/machine.ts +343 -0
- package/src/overlays/mcp-sign-in/mcp-sign-in.ts +159 -0
- package/src/overlays/tooltip/machine.ts +303 -0
- package/src/overlays/tooltip/tooltip.tsx +157 -92
- package/src/styles/theme.css +10 -2
- package/src/styles/tokens/theme.css +13 -0
- package/src/theme/context.tsx +192 -269
- package/src/theme/machine.ts +508 -0
- package/src/theme/themes/oc-2.json +2 -0
- package/src/theme/v2/mapping.ts +12 -8
- package/src/typography/text-shimmer/machine.ts +90 -0
- package/src/typography/text-shimmer/text-shimmer.css +71 -39
- package/src/typography/text-shimmer/text-shimmer.tsx +41 -24
|
@@ -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
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type ComponentProps } from "solid-js";
|
|
2
|
+
import { Spinner } from "../../components/spinner";
|
|
2
3
|
import "./activity-ring.css";
|
|
3
|
-
export declare function ActivityRing(props: ComponentProps<
|
|
4
|
+
export declare function ActivityRing(props: ComponentProps<typeof Spinner>): import("solid-js").JSX.Element;
|
|
@@ -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;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Root } from "@kobalte/core/checkbox";
|
|
2
2
|
import type { ComponentProps, JSX, ParentProps } from "solid-js";
|
|
3
|
+
import "./checkbox-compact.css";
|
|
3
4
|
export interface CheckboxProps extends ParentProps<ComponentProps<typeof Root>> {
|
|
5
|
+
/** `compact` is the design system checkbox; `standard` keeps the legacy look. */
|
|
6
|
+
appearance?: "standard" | "compact";
|
|
7
|
+
/** Background of the compact control. */
|
|
8
|
+
surface?: "base" | "layer-1";
|
|
4
9
|
hideLabel?: boolean;
|
|
5
|
-
description?:
|
|
10
|
+
description?: JSX.Element;
|
|
6
11
|
icon?: JSX.Element;
|
|
7
12
|
}
|
|
8
13
|
export declare function Checkbox(props: CheckboxProps): JSX.Element;
|
|
@@ -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;
|
|
@@ -16,6 +16,10 @@ export type SelectProps<T> = Omit<ComponentProps<typeof Root<T, {
|
|
|
16
16
|
onHighlight?: (value: T | undefined) => void | (() => void);
|
|
17
17
|
invalid?: boolean;
|
|
18
18
|
numeric?: boolean;
|
|
19
|
+
/** `inline` is the borderless settings trigger; `small`, `base` and `large` are 24px, 28px and 32px input fields. */
|
|
20
|
+
appearance?: "inline" | "small" | "base" | "large";
|
|
21
|
+
/** Background surface of an input field; invisible gains a fill on hover. */
|
|
22
|
+
surface?: "base" | "layer-1" | "invisible";
|
|
19
23
|
children?: (item: T) => JSX.Element;
|
|
20
24
|
valueClass?: string;
|
|
21
25
|
contentClass?: string;
|
|
@@ -22,8 +22,10 @@ export interface TextInputProps extends Omit<ComponentProps<"input">, "type"> {
|
|
|
22
22
|
numeric?: boolean;
|
|
23
23
|
/** Error styling for the field and value text. */
|
|
24
24
|
invalid?: boolean;
|
|
25
|
-
/** `base` is 28px tall; `large` is 32px tall. */
|
|
26
|
-
appearance?: "base" | "large";
|
|
25
|
+
/** `small` is 24px tall; `base` is 28px tall; `large` is 32px tall. */
|
|
26
|
+
appearance?: "small" | "base" | "large";
|
|
27
|
+
/** Background surface; invisible gains a fill on hover. */
|
|
28
|
+
surface?: "base" | "layer-1" | "invisible";
|
|
27
29
|
type?: ComponentProps<"input">["type"];
|
|
28
30
|
}
|
|
29
31
|
export declare function TextInput(props: TextInputProps): JSX.Element;
|
|
@@ -3,5 +3,6 @@ import "./textarea.css";
|
|
|
3
3
|
export interface TextareaProps extends ComponentProps<"textarea"> {
|
|
4
4
|
/** Error styling for the field and value text. */
|
|
5
5
|
invalid?: boolean;
|
|
6
|
+
surface?: "base" | "layer-1";
|
|
6
7
|
}
|
|
7
8
|
export declare function Textarea(props: TextareaProps): import("solid-js").JSX.Element;
|
|
@@ -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,89 @@
|
|
|
1
|
+
export declare const SETTLE_MS = 300;
|
|
2
|
+
export declare const END_EPSILON = 0.5;
|
|
3
|
+
export type OverflowAnchorMode = "none" | "auto" | "dynamic";
|
|
4
|
+
/**
|
|
5
|
+
* `idle`, `following` and `settling` stay pinned to the bottom; `settling` is the tail after work ends, while a text
|
|
6
|
+
* selection still pauses. `detached` is set while `<Suspense>` holds the viewport outside the document. `flight` is the
|
|
7
|
+
* `scrollTop` our own write produced; the next `scroll` event consumes it.
|
|
8
|
+
*/
|
|
9
|
+
export type AutoScrollState = {
|
|
10
|
+
readonly status: "idle" | "following";
|
|
11
|
+
readonly detached: boolean;
|
|
12
|
+
readonly flight: number | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
readonly status: "settling";
|
|
15
|
+
readonly attempt: number;
|
|
16
|
+
readonly detached: boolean;
|
|
17
|
+
readonly flight: number | undefined;
|
|
18
|
+
} | {
|
|
19
|
+
readonly status: "paused";
|
|
20
|
+
readonly working: boolean;
|
|
21
|
+
readonly detached: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
readonly status: "disposed";
|
|
24
|
+
};
|
|
25
|
+
export type AutoScrollEvent = {
|
|
26
|
+
readonly type: "working.changed";
|
|
27
|
+
readonly working: boolean;
|
|
28
|
+
readonly attempt: number;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "settle.elapsed";
|
|
31
|
+
readonly attempt: number;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: "scroller.changed";
|
|
34
|
+
readonly overflow: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "scroller.detached";
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "scroller.reattached";
|
|
39
|
+
readonly overflow: boolean;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "resize";
|
|
42
|
+
readonly overflow: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "scroll";
|
|
45
|
+
readonly overflow: boolean;
|
|
46
|
+
readonly scrollTop: number;
|
|
47
|
+
readonly maxScroll: number;
|
|
48
|
+
readonly threshold: number;
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: "pause";
|
|
51
|
+
readonly overflow: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "scroll.bottom";
|
|
54
|
+
readonly force: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: "flight.started";
|
|
57
|
+
readonly top: number;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "disposed";
|
|
60
|
+
};
|
|
61
|
+
export type AutoScrollEffect = {
|
|
62
|
+
readonly type: "pin.bottom";
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: "notify.interacted";
|
|
65
|
+
} | {
|
|
66
|
+
readonly type: "settle.start";
|
|
67
|
+
readonly attempt: number;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "settle.stop";
|
|
70
|
+
};
|
|
71
|
+
export type AutoScrollTransition = {
|
|
72
|
+
readonly state: AutoScrollState;
|
|
73
|
+
readonly effects: readonly AutoScrollEffect[];
|
|
74
|
+
};
|
|
75
|
+
export declare const IDLE: AutoScrollState;
|
|
76
|
+
export declare const FOLLOWING: AutoScrollState;
|
|
77
|
+
export declare const PAUSED_IDLE: AutoScrollState;
|
|
78
|
+
export declare const PAUSED_WORKING: AutoScrollState;
|
|
79
|
+
export declare const DISPOSED: AutoScrollState;
|
|
80
|
+
export declare function createAutoScrollState(working: boolean): AutoScrollState;
|
|
81
|
+
export declare function transitionAutoScroll(state: AutoScrollState, event: AutoScrollEvent): AutoScrollTransition;
|
|
82
|
+
export declare function selectUserScrolled(state: AutoScrollState): state is {
|
|
83
|
+
readonly status: "paused";
|
|
84
|
+
readonly working: boolean;
|
|
85
|
+
readonly detached: boolean;
|
|
86
|
+
};
|
|
87
|
+
export declare function selectOverflowAnchor(state: AutoScrollState, mode?: OverflowAnchorMode): "auto" | "none";
|
|
88
|
+
/** Selecting text pauses only while content still moves under the selection. */
|
|
89
|
+
export declare function selectPausesOnSelection(state: AutoScrollState): boolean;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/** How long an async `items(query)` may run before the list reports it failed rather than loading forever. */
|
|
2
|
+
export declare const LIST_LOAD_TIMEOUT_MS = 15000;
|
|
3
|
+
export type ListGroup<T> = {
|
|
4
|
+
category: string;
|
|
5
|
+
items: T[];
|
|
6
|
+
};
|
|
7
|
+
export type ListConfig<T> = {
|
|
8
|
+
readonly key: (item: T) => string;
|
|
9
|
+
readonly filterKeys?: string[];
|
|
10
|
+
readonly skipFilter?: (item: T) => boolean;
|
|
11
|
+
readonly groupBy?: (item: T) => string;
|
|
12
|
+
readonly sortBy?: (a: T, b: T) => number;
|
|
13
|
+
readonly sortGroupsBy?: (a: ListGroup<T>, b: ListGroup<T>) => number;
|
|
14
|
+
};
|
|
15
|
+
/** The one copy of the query. A `controlled` list shows the parent's `filter` prop and only reports edits. */
|
|
16
|
+
export type ListFilter = {
|
|
17
|
+
readonly type: "uncontrolled" | "controlled";
|
|
18
|
+
readonly query: string;
|
|
19
|
+
};
|
|
20
|
+
/** `mouse` while the pointer drives the highlight, so the list does not scroll under it. */
|
|
21
|
+
export type ListHighlight = {
|
|
22
|
+
readonly mode: "keyboard" | "mouse";
|
|
23
|
+
readonly activeKey: string | null;
|
|
24
|
+
};
|
|
25
|
+
type ListData<T> = {
|
|
26
|
+
readonly filter: ListFilter;
|
|
27
|
+
readonly groups: ListGroup<T>[];
|
|
28
|
+
readonly rows: T[];
|
|
29
|
+
readonly keys: string[];
|
|
30
|
+
readonly highlight: ListHighlight;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* `loading` keeps the last rows on screen; `epoch` is the last attempt that settled. `failed` means the current
|
|
34
|
+
* query's async load rejected or timed out, which the list reports instead of "No results". `disposed` keeps the last
|
|
35
|
+
* data for readers that run during cleanup and ignores every event.
|
|
36
|
+
*/
|
|
37
|
+
export type ListState<T> = (ListData<T> & {
|
|
38
|
+
readonly status: "ready" | "failed";
|
|
39
|
+
readonly epoch: number;
|
|
40
|
+
}) | (ListData<T> & {
|
|
41
|
+
readonly status: "loading";
|
|
42
|
+
readonly attempt: number;
|
|
43
|
+
}) | (ListData<T> & {
|
|
44
|
+
readonly status: "disposed";
|
|
45
|
+
});
|
|
46
|
+
export type ListKeyDown = {
|
|
47
|
+
readonly type: "key.down";
|
|
48
|
+
readonly key: string;
|
|
49
|
+
readonly ctrl: boolean;
|
|
50
|
+
readonly alt: boolean;
|
|
51
|
+
readonly meta: boolean;
|
|
52
|
+
readonly shift: boolean;
|
|
53
|
+
readonly composing: boolean;
|
|
54
|
+
/** A search input keeps Home, End and Tab for the text field. */
|
|
55
|
+
readonly search: boolean;
|
|
56
|
+
/** Escape, or a key the caller's `onKeyEvent` already handled. */
|
|
57
|
+
readonly claimed: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type ListEvent<T> = {
|
|
60
|
+
readonly type: "query.change";
|
|
61
|
+
readonly value: string;
|
|
62
|
+
readonly force?: boolean;
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: "filter.controlled";
|
|
65
|
+
readonly value: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "filter.uncontrolled";
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "items.reload";
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "load.resolved";
|
|
72
|
+
readonly attempt: number;
|
|
73
|
+
readonly items: T[];
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "load.failed";
|
|
76
|
+
readonly attempt: number;
|
|
77
|
+
} | {
|
|
78
|
+
readonly type: "load.timed-out";
|
|
79
|
+
readonly attempt: number;
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: "pointer.move";
|
|
82
|
+
readonly key: string;
|
|
83
|
+
readonly moved: boolean;
|
|
84
|
+
} | {
|
|
85
|
+
readonly type: "pointer.leave";
|
|
86
|
+
} | {
|
|
87
|
+
readonly type: "active.set";
|
|
88
|
+
readonly key: string | null;
|
|
89
|
+
} | {
|
|
90
|
+
readonly type: "active.reset";
|
|
91
|
+
} | {
|
|
92
|
+
readonly type: "disposed";
|
|
93
|
+
} | ListKeyDown;
|
|
94
|
+
export type ListEffect<T> = {
|
|
95
|
+
readonly type: "load";
|
|
96
|
+
readonly attempt: number;
|
|
97
|
+
readonly query: string;
|
|
98
|
+
}
|
|
99
|
+
/** Stops the settled or abandoned attempt's timeout. */
|
|
100
|
+
| {
|
|
101
|
+
readonly type: "cancel.load";
|
|
102
|
+
} | {
|
|
103
|
+
readonly type: "notify.filter";
|
|
104
|
+
readonly value: string;
|
|
105
|
+
} | {
|
|
106
|
+
readonly type: "select";
|
|
107
|
+
readonly item: T;
|
|
108
|
+
readonly index: number;
|
|
109
|
+
};
|
|
110
|
+
export type ListEmptyState = {
|
|
111
|
+
readonly type: "loading";
|
|
112
|
+
} | {
|
|
113
|
+
readonly type: "failed";
|
|
114
|
+
} | {
|
|
115
|
+
readonly type: "empty";
|
|
116
|
+
readonly query: string;
|
|
117
|
+
};
|
|
118
|
+
export type ListTransition<T> = {
|
|
119
|
+
readonly state: ListState<T>;
|
|
120
|
+
readonly effects: ListEffect<T>[];
|
|
121
|
+
readonly handled: boolean;
|
|
122
|
+
};
|
|
123
|
+
export declare function createListState<T>(filter?: string): ListState<T>;
|
|
124
|
+
export declare function transitionList<T>(state: ListState<T>, event: ListEvent<T>, config: ListConfig<T>): ListTransition<T>;
|
|
125
|
+
export declare function selectListLoading<T>(state: ListState<T>): state is ListData<T> & {
|
|
126
|
+
readonly status: "loading";
|
|
127
|
+
readonly attempt: number;
|
|
128
|
+
};
|
|
129
|
+
export declare function selectListFailed<T>(state: ListState<T>): boolean;
|
|
130
|
+
/** What the list says when it has no rows to show. */
|
|
131
|
+
export declare function selectListEmptyState<T>(state: ListState<T>): ListEmptyState;
|
|
132
|
+
/** The highlighted row and its index among all rows. */
|
|
133
|
+
export declare function listActive<T>(state: Pick<ListState<T>, "rows" | "keys" | "highlight">): {
|
|
134
|
+
item: T;
|
|
135
|
+
index: number;
|
|
136
|
+
} | undefined;
|
|
137
|
+
/** Where the list scrolls to keep the keyboard highlight in view; the pointer never scrolls it. */
|
|
138
|
+
export declare function listScrollTarget<T>(state: Pick<ListState<T>, "keys" | "highlight">): {
|
|
139
|
+
type: "none";
|
|
140
|
+
} | {
|
|
141
|
+
type: "top";
|
|
142
|
+
} | {
|
|
143
|
+
type: "item";
|
|
144
|
+
key: string;
|
|
145
|
+
};
|
|
146
|
+
export declare function groupItems<T>(items: T[], config: Pick<ListConfig<T>, "groupBy" | "sortBy" | "sortGroupsBy">): {
|
|
147
|
+
category: string;
|
|
148
|
+
items: T[];
|
|
149
|
+
}[];
|
|
150
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ListEvent, type ListGroup } from "./list-machine";
|
|
2
|
+
export { groupItems } from "./list-machine";
|
|
1
3
|
export interface FilteredListProps<T> {
|
|
2
4
|
items: T[] | ((filter: string) => T[] | Promise<T[]>);
|
|
3
5
|
key: (item: T) => string;
|
|
@@ -5,47 +7,31 @@ export interface FilteredListProps<T> {
|
|
|
5
7
|
current?: T;
|
|
6
8
|
groupBy?: (x: T) => string;
|
|
7
9
|
sortBy?: (a: T, b: T) => number;
|
|
8
|
-
sortGroupsBy?: (a:
|
|
9
|
-
category: string;
|
|
10
|
-
items: T[];
|
|
11
|
-
}, b: {
|
|
12
|
-
category: string;
|
|
13
|
-
items: T[];
|
|
14
|
-
}) => number;
|
|
10
|
+
sortGroupsBy?: (a: ListGroup<T>, b: ListGroup<T>) => number;
|
|
15
11
|
skipFilter?: (item: T) => boolean;
|
|
16
12
|
onSelect?: (value: T | undefined, index: number) => void;
|
|
13
|
+
/** Makes the query parent-owned: the list shows this value and reports edits through `onFilter`. */
|
|
14
|
+
filter?: string;
|
|
15
|
+
onFilter?: (value: string) => void;
|
|
17
16
|
}
|
|
18
|
-
export declare function groupItems<T>(items: T[], props: Pick<FilteredListProps<T>, "groupBy" | "sortBy" | "sortGroupsBy">): {
|
|
19
|
-
category: string;
|
|
20
|
-
items: T[];
|
|
21
|
-
}[];
|
|
22
17
|
export declare function useFilteredList<T>(props: FilteredListProps<T>): {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
filter: ()
|
|
18
|
+
state: import("solid-js").Accessor<import("./list-machine").ListState<T>>;
|
|
19
|
+
dispatch: (event: ListEvent<T>, keyboard?: KeyboardEvent) => void;
|
|
20
|
+
grouped: {
|
|
21
|
+
readonly latest: ListGroup<T>[];
|
|
22
|
+
readonly loading: boolean;
|
|
23
|
+
readonly state: "ready" | "refreshing" | "errored";
|
|
24
|
+
};
|
|
25
|
+
filter: import("solid-js").Accessor<string>;
|
|
31
26
|
flat: import("solid-js").Accessor<T[]>;
|
|
27
|
+
active: import("solid-js").Accessor<string | null>;
|
|
32
28
|
reset: () => void;
|
|
33
|
-
refetch: (
|
|
34
|
-
category: string;
|
|
35
|
-
items: [T, ...T[]];
|
|
36
|
-
}[] | {
|
|
37
|
-
category: string;
|
|
38
|
-
items: T[];
|
|
39
|
-
}[] | Promise<{
|
|
40
|
-
category: string;
|
|
41
|
-
items: [T, ...T[]];
|
|
42
|
-
}[] | {
|
|
43
|
-
category: string;
|
|
44
|
-
items: T[];
|
|
45
|
-
}[]> | null | undefined;
|
|
29
|
+
refetch: () => void;
|
|
46
30
|
clear: () => void;
|
|
47
|
-
onKeyDown: (event: KeyboardEvent) => void;
|
|
48
31
|
onInput: (value: string) => void;
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
setActive: (key: string | null) => void;
|
|
33
|
+
onKeyDown: (event: KeyboardEvent, options?: {
|
|
34
|
+
search?: boolean;
|
|
35
|
+
claimed?: boolean;
|
|
36
|
+
}) => void;
|
|
51
37
|
};
|