@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,95 @@
|
|
|
1
|
+
export declare const ANIMATED_NUMBER_TRACK_LENGTH = 30;
|
|
2
|
+
/** Added to the measured transition time before a roll or resize that never reported its end settles anyway. */
|
|
3
|
+
export declare const ANIMATED_NUMBER_FALLBACK_PAD_MS = 100;
|
|
4
|
+
/**
|
|
5
|
+
* `resizing` eases the width to `targetDigits` while extra leading places stay mounted to roll in or out. `attempt`
|
|
6
|
+
* names each eased change, so a fallback timer from an earlier one cannot cut the current one short.
|
|
7
|
+
*/
|
|
8
|
+
export type AnimatedNumberState = {
|
|
9
|
+
readonly status: "static";
|
|
10
|
+
readonly attempt: number;
|
|
11
|
+
readonly value: number;
|
|
12
|
+
readonly direction: 1 | -1;
|
|
13
|
+
readonly places: number;
|
|
14
|
+
} | {
|
|
15
|
+
readonly status: "resizing";
|
|
16
|
+
readonly attempt: number;
|
|
17
|
+
readonly value: number;
|
|
18
|
+
readonly direction: 1 | -1;
|
|
19
|
+
readonly places: number;
|
|
20
|
+
readonly targetDigits: number;
|
|
21
|
+
} | {
|
|
22
|
+
readonly status: "disposed";
|
|
23
|
+
};
|
|
24
|
+
/** `canAnimate` is false while detached or under reduced motion, where no transition runs to report its end. */
|
|
25
|
+
export type AnimatedNumberEvent = {
|
|
26
|
+
readonly type: "value.changed";
|
|
27
|
+
readonly value: number;
|
|
28
|
+
readonly canAnimate: boolean;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "resize.ended";
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "resize.timed-out";
|
|
33
|
+
readonly attempt: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "disposed";
|
|
36
|
+
};
|
|
37
|
+
export type AnimatedDigitState = {
|
|
38
|
+
readonly status: "static";
|
|
39
|
+
readonly attempt: number;
|
|
40
|
+
readonly digit: number;
|
|
41
|
+
readonly step: number;
|
|
42
|
+
} | {
|
|
43
|
+
readonly status: "rolling";
|
|
44
|
+
readonly attempt: number;
|
|
45
|
+
readonly digit: number;
|
|
46
|
+
readonly step: number;
|
|
47
|
+
} | {
|
|
48
|
+
readonly status: "disposed";
|
|
49
|
+
};
|
|
50
|
+
export type AnimatedDigitEvent = {
|
|
51
|
+
readonly type: "digit.changed";
|
|
52
|
+
readonly digit: number;
|
|
53
|
+
readonly direction: 1 | -1;
|
|
54
|
+
readonly canAnimate: boolean;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: "roll.ended";
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: "roll.timed-out";
|
|
59
|
+
readonly attempt: number;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "disposed";
|
|
62
|
+
};
|
|
63
|
+
/** `watch` arms the fallback for an eased change; `clear` drops it once the change has settled. */
|
|
64
|
+
export type AnimatedNumberEffect = {
|
|
65
|
+
readonly type: "watch";
|
|
66
|
+
readonly attempt: number;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "clear";
|
|
69
|
+
};
|
|
70
|
+
export type AnimatedNumberTransition<State> = {
|
|
71
|
+
readonly state: State;
|
|
72
|
+
readonly effects: readonly AnimatedNumberEffect[];
|
|
73
|
+
};
|
|
74
|
+
export declare function createAnimatedNumberState(value: number): AnimatedNumberState;
|
|
75
|
+
export declare function transitionAnimatedNumber(state: AnimatedNumberState, event: AnimatedNumberEvent): AnimatedNumberTransition<AnimatedNumberState>;
|
|
76
|
+
export declare function createAnimatedDigitState(digit: number): AnimatedDigitState;
|
|
77
|
+
export declare function transitionAnimatedDigit(state: AnimatedDigitState, event: AnimatedDigitEvent): AnimatedNumberTransition<AnimatedDigitState>;
|
|
78
|
+
export declare function selectAnimatedNumberValue(state: AnimatedNumberState): number;
|
|
79
|
+
export declare function selectAnimatedNumberDirection(state: AnimatedNumberState): -1 | 1;
|
|
80
|
+
export declare function selectAnimatedNumberPlaces(state: AnimatedNumberState): number;
|
|
81
|
+
export declare function selectAnimatedNumberResizing(state: AnimatedNumberState): state is {
|
|
82
|
+
readonly status: "resizing";
|
|
83
|
+
readonly attempt: number;
|
|
84
|
+
readonly value: number;
|
|
85
|
+
readonly direction: 1 | -1;
|
|
86
|
+
readonly places: number;
|
|
87
|
+
readonly targetDigits: number;
|
|
88
|
+
};
|
|
89
|
+
export declare function selectAnimatedDigitRolling(state: AnimatedDigitState): state is {
|
|
90
|
+
readonly status: "rolling";
|
|
91
|
+
readonly attempt: number;
|
|
92
|
+
readonly digit: number;
|
|
93
|
+
readonly step: number;
|
|
94
|
+
};
|
|
95
|
+
export declare function selectAnimatedDigitStep(state: AnimatedDigitState): number;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export type PopoverCloseReason = "escape" | "outside" | "control";
|
|
2
|
+
/**
|
|
3
|
+
* One popover's open state. `controlled` follows the `open` prop; `uncontrolled` owns it. A controlled popover that
|
|
4
|
+
* asked its owner to close stays open with `pendingDismiss` until the owner answers, so a refused close leaves no
|
|
5
|
+
* reason behind for a later close to read.
|
|
6
|
+
*/
|
|
7
|
+
export type PopoverState = {
|
|
8
|
+
readonly status: "closed";
|
|
9
|
+
readonly mode: "controlled" | "uncontrolled";
|
|
10
|
+
/** Why it closed, until Kobalte decides where focus returns. Focus stays put after an outside press. */
|
|
11
|
+
readonly closeReason: PopoverCloseReason | null;
|
|
12
|
+
} | {
|
|
13
|
+
readonly status: "open";
|
|
14
|
+
readonly mode: "uncontrolled";
|
|
15
|
+
} | {
|
|
16
|
+
readonly status: "open";
|
|
17
|
+
readonly mode: "controlled";
|
|
18
|
+
readonly pendingDismiss: PopoverCloseReason | null;
|
|
19
|
+
} | {
|
|
20
|
+
readonly status: "disposed";
|
|
21
|
+
};
|
|
22
|
+
export type PopoverEvent =
|
|
23
|
+
/** The `open` prop, read again right after every `onOpenChange` call: a controlled `true` refuses a close. */
|
|
24
|
+
{
|
|
25
|
+
readonly type: "props.synced";
|
|
26
|
+
readonly open: boolean | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The shared listener dismissed this popover. */
|
|
29
|
+
| {
|
|
30
|
+
readonly type: "dismiss";
|
|
31
|
+
readonly reason: "escape" | "outside";
|
|
32
|
+
}
|
|
33
|
+
/** Kobalte asked to open or close, from the trigger or the close button. */
|
|
34
|
+
| {
|
|
35
|
+
readonly type: "kobalte.changed";
|
|
36
|
+
readonly open: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "close-auto-focus.handled";
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "disposed";
|
|
41
|
+
};
|
|
42
|
+
export type PopoverEffect = {
|
|
43
|
+
readonly type: "notify.open";
|
|
44
|
+
readonly open: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type PopoverTransition = {
|
|
47
|
+
readonly state: PopoverState;
|
|
48
|
+
readonly effects: readonly PopoverEffect[];
|
|
49
|
+
};
|
|
50
|
+
export declare function createPopoverState(open: boolean | undefined, defaultOpen: boolean | undefined): PopoverState;
|
|
51
|
+
export declare function transitionPopover(state: PopoverState, event: PopoverEvent): PopoverTransition;
|
|
52
|
+
export declare function selectPopoverOpen(state: PopoverState): state is {
|
|
53
|
+
readonly status: "open";
|
|
54
|
+
readonly mode: "uncontrolled";
|
|
55
|
+
} | {
|
|
56
|
+
readonly status: "open";
|
|
57
|
+
readonly mode: "controlled";
|
|
58
|
+
readonly pendingDismiss: PopoverCloseReason | null;
|
|
59
|
+
};
|
|
60
|
+
/** An outside press already moved focus where the user wanted it, so closing does not pull it back to the trigger. */
|
|
61
|
+
export declare function selectPreventCloseAutoFocus(state: PopoverState): boolean;
|
|
62
|
+
/** One open popover, and the popover it opened inside (portaled content is outside its parent in the DOM). */
|
|
63
|
+
export type PopoverStackEntry = {
|
|
64
|
+
readonly id: number;
|
|
65
|
+
readonly parentId: number | null;
|
|
66
|
+
};
|
|
67
|
+
/** Every open popover, in the order they opened. One shared set of window listeners routes Escape and outside presses. */
|
|
68
|
+
export type PopoverStackState = {
|
|
69
|
+
readonly entries: readonly PopoverStackEntry[];
|
|
70
|
+
};
|
|
71
|
+
export type PopoverStackEvent = {
|
|
72
|
+
readonly type: "layer.opened";
|
|
73
|
+
readonly id: number;
|
|
74
|
+
readonly parentId: number | null;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "layer.closed";
|
|
77
|
+
readonly id: number;
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: "escape.pressed";
|
|
80
|
+
}
|
|
81
|
+
/** A press or focus landed; `insideIds` are the open popovers whose trigger or content contains it. */
|
|
82
|
+
| {
|
|
83
|
+
readonly type: "outside.interacted";
|
|
84
|
+
readonly insideIds: ReadonlySet<number>;
|
|
85
|
+
};
|
|
86
|
+
export type PopoverStackEffect = {
|
|
87
|
+
readonly type: "dismiss.layer";
|
|
88
|
+
readonly id: number;
|
|
89
|
+
readonly reason: "escape" | "outside";
|
|
90
|
+
};
|
|
91
|
+
export type PopoverStackTransition = {
|
|
92
|
+
readonly state: PopoverStackState;
|
|
93
|
+
readonly effects: readonly PopoverStackEffect[];
|
|
94
|
+
};
|
|
95
|
+
export declare const EMPTY_POPOVER_STACK: PopoverStackState;
|
|
96
|
+
export declare function transitionPopoverStack(state: PopoverStackState, event: PopoverStackEvent): PopoverStackTransition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Root } from "@kobalte/core/popover";
|
|
2
2
|
import { ComponentProps, JSXElement, ParentProps, ValidComponent } from "solid-js";
|
|
3
|
-
export interface PopoverProps<T extends ValidComponent = "div"> extends ParentProps, Omit<ComponentProps<typeof
|
|
3
|
+
export interface PopoverProps<T extends ValidComponent = "div"> extends ParentProps, Omit<ComponentProps<typeof Root>, "children"> {
|
|
4
4
|
trigger?: JSXElement;
|
|
5
5
|
triggerAs?: T;
|
|
6
6
|
triggerProps?: ComponentProps<T>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type ResizeDirection = "horizontal" | "vertical";
|
|
2
|
+
export type ResizeEdge = "start" | "end";
|
|
3
|
+
/** Fixed for one press: where it started, which way the size grows, and the limits it resizes within. */
|
|
4
|
+
export type ResizeSession = {
|
|
5
|
+
readonly pointerId: number;
|
|
6
|
+
readonly direction: ResizeDirection;
|
|
7
|
+
readonly sign: 1 | -1;
|
|
8
|
+
readonly startPos: number;
|
|
9
|
+
readonly startSize: number;
|
|
10
|
+
readonly min: number;
|
|
11
|
+
readonly max: number;
|
|
12
|
+
readonly threshold: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `pressed` holds the pointer before it moves, so a click never reports a drag. `dragging` reports the size on each
|
|
16
|
+
* move; `collapsed` is set while the raw size sits below the collapse threshold.
|
|
17
|
+
*/
|
|
18
|
+
export type ResizeHandleState = {
|
|
19
|
+
readonly status: "idle";
|
|
20
|
+
} | {
|
|
21
|
+
readonly status: "pressed";
|
|
22
|
+
readonly session: ResizeSession;
|
|
23
|
+
} | {
|
|
24
|
+
readonly status: "dragging";
|
|
25
|
+
readonly session: ResizeSession;
|
|
26
|
+
readonly collapsed: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
readonly status: "disposed";
|
|
29
|
+
};
|
|
30
|
+
export type ResizeHandleEvent = {
|
|
31
|
+
readonly type: "pointer.down";
|
|
32
|
+
readonly button: number;
|
|
33
|
+
readonly ctrlKey: boolean;
|
|
34
|
+
readonly detail: number;
|
|
35
|
+
readonly session: ResizeSession;
|
|
36
|
+
} | {
|
|
37
|
+
type: "pointer.moved";
|
|
38
|
+
pointerId: number;
|
|
39
|
+
pos: number;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "pointer.up";
|
|
42
|
+
readonly pointerId: number;
|
|
43
|
+
}
|
|
44
|
+
/** Blur, `pointercancel` or lost capture; no `pointerId` cancels whichever pointer holds the handle. */
|
|
45
|
+
| {
|
|
46
|
+
readonly type: "drag.cancelled";
|
|
47
|
+
readonly pointerId?: number;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "disposed";
|
|
50
|
+
};
|
|
51
|
+
export type ResizeHandleEffect = "lock-body" | "unlock-body" | "dragging-true" | "dragging-false" | "collapse-true" | "collapse-false" | "collapse-commit" | "resize";
|
|
52
|
+
export type ResizeHandleTransition = {
|
|
53
|
+
readonly state: ResizeHandleState;
|
|
54
|
+
readonly effects: readonly ResizeHandleEffect[];
|
|
55
|
+
};
|
|
56
|
+
export declare const INITIAL_RESIZE_HANDLE_STATE: ResizeHandleState;
|
|
57
|
+
export declare const RESIZE_HANDLE_DISPOSED: ResizeHandleEvent;
|
|
58
|
+
export declare const RESIZE_DRAG_CANCELLED: ResizeHandleEvent;
|
|
59
|
+
export declare function resizeSign(direction: ResizeDirection, edge: ResizeEdge, rtl: boolean): 1 | -1;
|
|
60
|
+
/** The size before clamping, which decides collapse, so dragging past `min` can still collapse the panel. */
|
|
61
|
+
export declare function rawResizeSize(session: ResizeSession, pos: number): number;
|
|
62
|
+
export declare function resizeSize(session: ResizeSession, pos: number): number;
|
|
63
|
+
export declare function transitionResizeHandle(state: ResizeHandleState, event: ResizeHandleEvent): ResizeHandleTransition;
|
|
64
|
+
export declare function selectResizeHandleActive(state: ResizeHandleState): state is {
|
|
65
|
+
readonly status: "pressed";
|
|
66
|
+
readonly session: ResizeSession;
|
|
67
|
+
} | {
|
|
68
|
+
readonly status: "dragging";
|
|
69
|
+
readonly session: ResizeSession;
|
|
70
|
+
readonly collapsed: boolean;
|
|
71
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare const SCROLL_IDLE_MS = 800;
|
|
2
|
+
export type ScrollAxis = "vertical" | "horizontal";
|
|
3
|
+
/**
|
|
4
|
+
* `scrolling` shows the thumb until `SCROLL_IDLE_MS` after the last scroll. `dragging` holds the pointer on one thumb;
|
|
5
|
+
* `scrolled` records a scroll during the drag, so its release keeps the thumb up for the idle delay. A thumb exists
|
|
6
|
+
* only while its axis overflows, so losing that overflow ends a drag on it.
|
|
7
|
+
*/
|
|
8
|
+
export type ScrollThumbState = {
|
|
9
|
+
readonly status: "idle" | "scrolling";
|
|
10
|
+
readonly hovered: boolean;
|
|
11
|
+
readonly verticalOverflow: boolean;
|
|
12
|
+
readonly horizontalOverflow: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
readonly status: "dragging";
|
|
15
|
+
readonly axis: ScrollAxis;
|
|
16
|
+
readonly pointerId: number;
|
|
17
|
+
readonly grabOffset: number;
|
|
18
|
+
readonly rtl: boolean;
|
|
19
|
+
readonly hovered: boolean;
|
|
20
|
+
readonly scrolled: boolean;
|
|
21
|
+
readonly verticalOverflow: boolean;
|
|
22
|
+
readonly horizontalOverflow: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
readonly status: "disposed";
|
|
25
|
+
};
|
|
26
|
+
export type ScrollThumbEvent = {
|
|
27
|
+
readonly type: "hover.changed";
|
|
28
|
+
readonly hovered: boolean;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "scrolled";
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "idle.elapsed";
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: "overflow.changed";
|
|
35
|
+
readonly vertical: boolean;
|
|
36
|
+
readonly horizontal: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "drag.started";
|
|
39
|
+
readonly axis: ScrollAxis;
|
|
40
|
+
readonly pointerId: number;
|
|
41
|
+
readonly grabOffset: number;
|
|
42
|
+
readonly rtl: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "drag.ended";
|
|
45
|
+
readonly pointerId: number;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "disposed";
|
|
48
|
+
};
|
|
49
|
+
export type ScrollThumbEffect = "reset-idle-timer" | "clear-idle-timer" | "release-capture";
|
|
50
|
+
export type ScrollThumbTransition = {
|
|
51
|
+
readonly state: ScrollThumbState;
|
|
52
|
+
readonly effects: readonly ScrollThumbEffect[];
|
|
53
|
+
};
|
|
54
|
+
export declare const INITIAL_SCROLL_THUMB_STATE: ScrollThumbState;
|
|
55
|
+
export declare const SCROLLED: ScrollThumbEvent;
|
|
56
|
+
export declare const SCROLL_IDLE_ELAPSED: ScrollThumbEvent;
|
|
57
|
+
export declare const HOVER_ENTERED: ScrollThumbEvent;
|
|
58
|
+
export declare const HOVER_LEFT: ScrollThumbEvent;
|
|
59
|
+
export declare const SCROLL_THUMB_DISPOSED: ScrollThumbEvent;
|
|
60
|
+
export declare function overflowChanged(vertical: boolean, horizontal: boolean): ScrollThumbEvent;
|
|
61
|
+
export declare function transitionScrollThumb(state: ScrollThumbState, event: ScrollThumbEvent): ScrollThumbTransition;
|
|
62
|
+
export declare function selectShowVerticalThumb(state: ScrollThumbState): boolean;
|
|
63
|
+
export declare function selectShowHorizontalThumb(state: ScrollThumbState): boolean;
|
|
64
|
+
export declare function selectDraggingAxis(state: ScrollThumbState): ScrollAxis | undefined;
|
|
65
|
+
/** `hoverReveals` is the `hover` visibility mode; in `scroll` mode only scrolling and dragging show the thumb. */
|
|
66
|
+
export declare function selectThumbVisible(state: ScrollThumbState, hoverReveals: boolean): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComponentProps } from "solid-js";
|
|
1
|
+
import { type ComponentProps, type JSX } from "solid-js";
|
|
2
2
|
export type ScrollViewThumbVisibility = "hover" | "scroll";
|
|
3
3
|
export interface ScrollViewProps extends ComponentProps<"div"> {
|
|
4
4
|
viewportRef?: (el: HTMLDivElement) => void;
|
|
@@ -47,4 +47,4 @@ export declare function scrollOffsetFromThumbPointer(input: {
|
|
|
47
47
|
* A scroll container that draws its own thumb, for a thumb in an external track or one corrected for virtualized
|
|
48
48
|
* rows. Everything else scrolls with a plain `overflow: auto` element, which `styles/scrollbar.css` already styles.
|
|
49
49
|
*/
|
|
50
|
-
export declare function ScrollView(props: ScrollViewProps):
|
|
50
|
+
export declare function ScrollView(props: ScrollViewProps): JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const TEXT_FIELD_COPIED_MS = 2000;
|
|
2
|
+
/** A clipboard write that never settles gives up, so the button can copy again. */
|
|
3
|
+
export declare const TEXT_FIELD_COPY_TIMEOUT_MS = 2000;
|
|
4
|
+
export type TextFieldCopyKind = "clipboard" | "link";
|
|
5
|
+
/**
|
|
6
|
+
* The copy button's feedback. `copying` claims the click before the write starts, so a second click waits for it;
|
|
7
|
+
* `keepCopied` keeps the checkmark of an earlier copy while a repeat copy settles. `attempt` lets only the latest
|
|
8
|
+
* write, its timeout and its own reset timer move the button.
|
|
9
|
+
*/
|
|
10
|
+
export type TextFieldCopyState = {
|
|
11
|
+
readonly status: "idle";
|
|
12
|
+
readonly issued: number;
|
|
13
|
+
} | {
|
|
14
|
+
readonly status: "copying";
|
|
15
|
+
readonly attempt: number;
|
|
16
|
+
readonly keepCopied: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
readonly status: "copied";
|
|
19
|
+
readonly attempt: number;
|
|
20
|
+
} | {
|
|
21
|
+
readonly status: "disposed";
|
|
22
|
+
};
|
|
23
|
+
export type TextFieldCopyEvent = {
|
|
24
|
+
readonly type: "copy.requested";
|
|
25
|
+
readonly value: string;
|
|
26
|
+
readonly enabled: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "copy.succeeded";
|
|
29
|
+
readonly attempt: number;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "copy.failed";
|
|
32
|
+
readonly attempt: number;
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: "copy.timed-out";
|
|
35
|
+
readonly attempt: number;
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "reset.elapsed";
|
|
38
|
+
readonly attempt: number;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "disposed";
|
|
41
|
+
};
|
|
42
|
+
export type TextFieldCopyEffect = {
|
|
43
|
+
readonly type: "clipboard.write";
|
|
44
|
+
readonly attempt: number;
|
|
45
|
+
readonly value: string;
|
|
46
|
+
readonly timeoutMs: number;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "reset.schedule";
|
|
49
|
+
readonly attempt: number;
|
|
50
|
+
readonly delayMs: number;
|
|
51
|
+
} | {
|
|
52
|
+
readonly type: "timer.clear";
|
|
53
|
+
};
|
|
54
|
+
export type TextFieldCopyTransition = {
|
|
55
|
+
readonly state: TextFieldCopyState;
|
|
56
|
+
readonly effects: readonly TextFieldCopyEffect[];
|
|
57
|
+
};
|
|
58
|
+
export declare const INITIAL_TEXT_FIELD_COPY_STATE: TextFieldCopyState;
|
|
59
|
+
export declare function transitionTextFieldCopy(state: TextFieldCopyState, event: TextFieldCopyEvent): TextFieldCopyTransition;
|
|
60
|
+
export declare function selectTextFieldCopied(state: TextFieldCopyState): boolean;
|
|
61
|
+
export declare function selectTextFieldCopyLabelKey(state: TextFieldCopyState, kind: TextFieldCopyKind | undefined): "ui.textField.copied" | "ui.textField.copyLink" | "ui.textField.copyToClipboard";
|
|
62
|
+
export declare function selectTextFieldCopyIcon(state: TextFieldCopyState, kind: TextFieldCopyKind | undefined): "check" | "copy" | "link";
|
|
@@ -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
|
+
};
|