@opencode/ui 2.2.5 → 2.2.7
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 +9 -3
- 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/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/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 +128 -111
- 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 +19 -8
- package/src/components/menu-scroll.tsx +111 -34
- 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 +157 -178
- 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 +59 -59
- package/src/forms/checkbox/checkbox-compact.css +169 -0
- package/src/forms/checkbox/checkbox.tsx +93 -31
- package/src/forms/inline-input/inline-input.css +0 -1
- package/src/forms/search-list/search-list.css +5 -1
- package/src/forms/search-list/search-list.tsx +18 -10
- package/src/forms/select/machine.ts +81 -0
- package/src/forms/select/select.css +59 -17
- package/src/forms/select/select.tsx +74 -32
- package/src/forms/typeahead/machine.ts +253 -0
- package/src/forms/typeahead/typeahead.tsx +70 -62
- 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/i18n/uk.ts +3 -3
- package/src/icons/catalog.ts +8 -0
- package/src/navigation/menu/machine.ts +109 -0
- package/src/navigation/menu/menu.tsx +133 -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 +159 -92
- package/src/styles/theme.css +10 -2
- package/src/theme/context.tsx +192 -269
- package/src/theme/machine.ts +508 -0
- 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,247 @@
|
|
|
1
|
+
import type { FlightFrame } from "./image-flight"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How long the preview waits for its image to decode before it opens anyway. Decoding first keeps the flight's first
|
|
5
|
+
* frames smooth; a decode that hangs, such as the stand-in's on a slow second fetch, must not keep the preview hidden.
|
|
6
|
+
*/
|
|
7
|
+
export const DECODE_TIMEOUT_MS = 1000
|
|
8
|
+
|
|
9
|
+
/** What `data-stage` tells the stylesheet: hidden, a stand-in flying, the preview at rest, or fading out after a close. */
|
|
10
|
+
export type PreviewFlightStage = "pending" | "flying" | "rest" | "closing"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The preview's life from load to close. `attempt` counts image loads, so a decode that settles after the image
|
|
14
|
+
* changed or loaded again is ignored. `borrowed` says the preview holds the page's video, which it hands back once the
|
|
15
|
+
* close lands. `originHidden` says the origin on the page is hidden because the image flew out of it.
|
|
16
|
+
*
|
|
17
|
+
* A close flies home when the origin still shows, then fades the stand-in over the page's image (`veil`). It only
|
|
18
|
+
* fades when the origin is gone, out of sight, or motion is reduced (`fade`).
|
|
19
|
+
*/
|
|
20
|
+
export type PreviewFlightState =
|
|
21
|
+
| { readonly status: "pending"; readonly attempt: number }
|
|
22
|
+
| { readonly status: "decoding"; readonly attempt: number }
|
|
23
|
+
| { readonly status: "opening"; readonly mode: "flight" | "fade"; readonly borrowed: boolean }
|
|
24
|
+
| { readonly status: "open"; readonly originHidden: boolean; readonly borrowed: boolean }
|
|
25
|
+
| { readonly status: "closing"; readonly mode: "flight" | "veil" | "fade"; readonly borrowed: boolean }
|
|
26
|
+
| { readonly status: "closed" }
|
|
27
|
+
| { readonly status: "disposed" }
|
|
28
|
+
|
|
29
|
+
/** `origin` is the origin's frame to fly from or to, or nothing when it is gone, out of sight, or motion is reduced. */
|
|
30
|
+
export type PreviewFlightEvent =
|
|
31
|
+
| { readonly type: "src.changed" }
|
|
32
|
+
| { readonly type: "image.loaded" }
|
|
33
|
+
| { readonly type: "image.failed" }
|
|
34
|
+
| { readonly type: "decode.ready"; readonly attempt: number; readonly origin: FlightFrame | undefined }
|
|
35
|
+
| { readonly type: "video.ready"; readonly origin: FlightFrame | undefined }
|
|
36
|
+
| { readonly type: "close.started"; readonly origin: FlightFrame | undefined }
|
|
37
|
+
/** The flight landed with the backdrop at rest, or, without a flight, the backdrop and the veil came to rest. */
|
|
38
|
+
| { readonly type: "motion.settled" }
|
|
39
|
+
| { readonly type: "disposed" }
|
|
40
|
+
|
|
41
|
+
export type PreviewFlightEffect =
|
|
42
|
+
| { readonly type: "decode.start"; readonly attempt: number }
|
|
43
|
+
| { readonly type: "decode.cancel" }
|
|
44
|
+
| { readonly type: "video.borrow" }
|
|
45
|
+
| { readonly type: "video.return" }
|
|
46
|
+
| { readonly type: "origin.hide" }
|
|
47
|
+
| { readonly type: "origin.show" }
|
|
48
|
+
| { readonly type: "open.flight"; readonly from: FlightFrame }
|
|
49
|
+
| { readonly type: "open.fade" }
|
|
50
|
+
/** `turn` turns the opening flight around where it is, keeping its velocity, instead of starting from rest. */
|
|
51
|
+
| { readonly type: "close.flight"; readonly to: FlightFrame; readonly turn: boolean }
|
|
52
|
+
| { readonly type: "close.veil" }
|
|
53
|
+
| { readonly type: "close.fade" }
|
|
54
|
+
/** A video eases back to its whole frame on the way home; an image stops where it is and flies as it is shown. */
|
|
55
|
+
| { readonly type: "zoom.fit" }
|
|
56
|
+
| { readonly type: "zoom.settle" }
|
|
57
|
+
| { readonly type: "body.closing.acquire" }
|
|
58
|
+
| { readonly type: "body.closing.release" }
|
|
59
|
+
| { readonly type: "loop.stop" }
|
|
60
|
+
|
|
61
|
+
export type PreviewFlightTransition = {
|
|
62
|
+
readonly state: PreviewFlightState
|
|
63
|
+
readonly effects: readonly PreviewFlightEffect[]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const INITIAL_PREVIEW_FLIGHT_STATE: PreviewFlightState = Object.freeze({ status: "pending", attempt: 0 })
|
|
67
|
+
|
|
68
|
+
const CLOSED: PreviewFlightState = Object.freeze({ status: "closed" })
|
|
69
|
+
|
|
70
|
+
const DISPOSED: PreviewFlightState = Object.freeze({ status: "disposed" })
|
|
71
|
+
|
|
72
|
+
const NONE: readonly PreviewFlightEffect[] = Object.freeze([])
|
|
73
|
+
|
|
74
|
+
export function transitionPreviewFlight(state: PreviewFlightState, event: PreviewFlightEvent): PreviewFlightTransition {
|
|
75
|
+
if (state.status === "disposed") return { state, effects: NONE }
|
|
76
|
+
|
|
77
|
+
if (event.type === "disposed") return { state: DISPOSED, effects: teardown(state) }
|
|
78
|
+
|
|
79
|
+
if (event.type === "close.started") return close(state, event.origin)
|
|
80
|
+
|
|
81
|
+
if (state.status === "pending" || state.status === "decoding") return reveal(state, event)
|
|
82
|
+
|
|
83
|
+
if (event.type !== "motion.settled") return { state, effects: NONE }
|
|
84
|
+
|
|
85
|
+
return settle(state)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function selectFlightStage(state: PreviewFlightState): PreviewFlightStage {
|
|
89
|
+
if (state.status === "pending" || state.status === "decoding") return "pending"
|
|
90
|
+
|
|
91
|
+
if (state.status === "opening") return state.mode === "flight" ? "flying" : "rest"
|
|
92
|
+
|
|
93
|
+
if (state.status === "open") return "rest"
|
|
94
|
+
|
|
95
|
+
if (state.status === "closing" && state.mode !== "fade") return "flying"
|
|
96
|
+
|
|
97
|
+
return "closing"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Whether the preview takes zoom, pan and keyboard input: from the moment it reveals until a close starts. */
|
|
101
|
+
export function selectFlightInteractive(state: PreviewFlightState) {
|
|
102
|
+
return state.status === "opening" || state.status === "open"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Whether the preview, its controls and a borrowed video fade with the backdrop rather than flying. */
|
|
106
|
+
export function selectFlightFading(state: PreviewFlightState) {
|
|
107
|
+
return (state.status === "opening" || state.status === "closing") && state.mode === "fade"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Whether a borrowed video sits fitted in the preview, not flying, so a resize moves it with the preview. */
|
|
111
|
+
export function selectVideoAtRest(state: PreviewFlightState) {
|
|
112
|
+
if (state.status === "open") return state.borrowed
|
|
113
|
+
|
|
114
|
+
return (state.status === "opening" || state.status === "closing") && state.borrowed && state.mode === "fade"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Whether the preview still waits to reveal, so it is worth measuring where it would fly from. */
|
|
118
|
+
export function selectAwaitingReveal(state: PreviewFlightState) {
|
|
119
|
+
return state.status === "pending" || state.status === "decoding"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Whether a decode of image load `attempt` is still the one the preview waits for. */
|
|
123
|
+
export function selectDecodeCurrent(state: PreviewFlightState, attempt: number) {
|
|
124
|
+
return state.status === "decoding" && state.attempt === attempt
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function reveal(
|
|
128
|
+
state: Extract<PreviewFlightState, { status: "pending" | "decoding" }>,
|
|
129
|
+
event: Exclude<PreviewFlightEvent, { type: "close.started" | "disposed" }>,
|
|
130
|
+
): PreviewFlightTransition {
|
|
131
|
+
const cancel: readonly PreviewFlightEffect[] = state.status === "decoding" ? [{ type: "decode.cancel" }] : []
|
|
132
|
+
const attempt = state.attempt + 1
|
|
133
|
+
|
|
134
|
+
if (event.type === "src.changed") return { state: { status: "pending", attempt }, effects: cancel }
|
|
135
|
+
|
|
136
|
+
if (event.type === "image.loaded") {
|
|
137
|
+
return { state: { status: "decoding", attempt }, effects: [...cancel, { type: "decode.start", attempt }] }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (event.type === "image.failed") return open(cancel, undefined, false)
|
|
141
|
+
|
|
142
|
+
if (event.type === "decode.ready" && state.status === "decoding" && event.attempt === state.attempt) {
|
|
143
|
+
return open(cancel, event.origin, false)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (event.type === "video.ready" && state.status === "pending") {
|
|
147
|
+
return open([{ type: "video.borrow" }], event.origin, true)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return { state, effects: NONE }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function open(
|
|
154
|
+
before: readonly PreviewFlightEffect[],
|
|
155
|
+
origin: FlightFrame | undefined,
|
|
156
|
+
borrowed: boolean,
|
|
157
|
+
): PreviewFlightTransition {
|
|
158
|
+
if (!origin)
|
|
159
|
+
return { state: { status: "opening", mode: "fade", borrowed }, effects: [...before, { type: "open.fade" }] }
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
state: { status: "opening", mode: "flight", borrowed },
|
|
163
|
+
effects: [...before, { type: "origin.hide" }, { type: "open.flight", from: origin }],
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function close(state: PreviewFlightState, origin: FlightFrame | undefined): PreviewFlightTransition {
|
|
168
|
+
if (state.status === "pending" || state.status === "decoding") {
|
|
169
|
+
return {
|
|
170
|
+
state: CLOSED,
|
|
171
|
+
effects: [
|
|
172
|
+
...(state.status === "decoding" ? [{ type: "decode.cancel" } as const] : []),
|
|
173
|
+
{ type: "body.closing.acquire" },
|
|
174
|
+
],
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (state.status !== "opening" && state.status !== "open") return { state, effects: NONE }
|
|
179
|
+
const hidden = originHidden(state)
|
|
180
|
+
|
|
181
|
+
const start: PreviewFlightEffect[] = [
|
|
182
|
+
{ type: "body.closing.acquire" },
|
|
183
|
+
{ type: state.borrowed ? "zoom.fit" : "zoom.settle" },
|
|
184
|
+
]
|
|
185
|
+
|
|
186
|
+
if (!origin) {
|
|
187
|
+
return {
|
|
188
|
+
state: { status: "closing", mode: "fade", borrowed: state.borrowed },
|
|
189
|
+
effects: [...start, ...(hidden ? [{ type: "origin.show" } as const] : []), { type: "close.fade" }],
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
state: { status: "closing", mode: "flight", borrowed: state.borrowed },
|
|
195
|
+
effects: [
|
|
196
|
+
...start,
|
|
197
|
+
...(hidden ? [] : [{ type: "origin.hide" } as const]),
|
|
198
|
+
{ type: "close.flight", to: origin, turn: state.status === "opening" && state.mode === "flight" },
|
|
199
|
+
],
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function settle(state: PreviewFlightState): PreviewFlightTransition {
|
|
204
|
+
if (state.status === "opening") {
|
|
205
|
+
return {
|
|
206
|
+
state: { status: "open", originHidden: state.mode === "flight", borrowed: state.borrowed },
|
|
207
|
+
effects: NONE,
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (state.status !== "closing") return { state, effects: NONE }
|
|
212
|
+
|
|
213
|
+
// A video is the surface and goes straight back; an image's stand-in fades over the page's image once it lands.
|
|
214
|
+
if (state.mode === "flight" && state.borrowed) {
|
|
215
|
+
return { state: CLOSED, effects: [{ type: "origin.show" }, { type: "video.return" }] }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (state.mode === "flight") {
|
|
219
|
+
return {
|
|
220
|
+
state: { status: "closing", mode: "veil", borrowed: false },
|
|
221
|
+
effects: [{ type: "origin.show" }, { type: "close.veil" }],
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return { state: CLOSED, effects: state.borrowed ? [{ type: "video.return" }] : NONE }
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function teardown(state: PreviewFlightState): readonly PreviewFlightEffect[] {
|
|
229
|
+
if (state.status === "pending" || state.status === "disposed") return NONE
|
|
230
|
+
|
|
231
|
+
if (state.status === "decoding") return [{ type: "decode.cancel" }]
|
|
232
|
+
|
|
233
|
+
if (state.status === "closed") return [{ type: "body.closing.release" }]
|
|
234
|
+
|
|
235
|
+
return [
|
|
236
|
+
{ type: "loop.stop" },
|
|
237
|
+
...(originHidden(state) ? [{ type: "origin.show" } as const] : []),
|
|
238
|
+
...(state.borrowed ? [{ type: "video.return" } as const] : []),
|
|
239
|
+
...(state.status === "closing" ? [{ type: "body.closing.release" } as const] : []),
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function originHidden(state: Extract<PreviewFlightState, { status: "opening" | "open" | "closing" }>) {
|
|
244
|
+
if (state.status === "open") return state.originHidden
|
|
245
|
+
|
|
246
|
+
return state.mode === "flight"
|
|
247
|
+
}
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
pointer-events: auto;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
/* A video fading out after a close, rather than flying home, must not take the page's clicks either. */
|
|
75
|
+
&:is([data-stage="flying"], [data-stage="closing"]) > video {
|
|
75
76
|
pointer-events: none;
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -79,7 +80,9 @@
|
|
|
79
80
|
visibility: hidden;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
/* A preview closed before it revealed never painted its backdrop; one that did paints over this inline. */
|
|
84
|
+
&:is([data-stage="pending"], [data-stage="closing"])
|
|
85
|
+
:is([data-slot="image-preview-scrim"], [data-slot="image-preview-content"]) {
|
|
83
86
|
opacity: 0;
|
|
84
87
|
}
|
|
85
88
|
|