@opencode/ui 2.2.5 → 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 +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 +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 +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 +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/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/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/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
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
For,
|
|
3
3
|
Show,
|
|
4
|
+
createComputed,
|
|
4
5
|
createEffect,
|
|
6
|
+
createMemo,
|
|
5
7
|
createSignal,
|
|
6
8
|
on,
|
|
7
9
|
onCleanup,
|
|
8
10
|
onMount,
|
|
9
11
|
splitProps,
|
|
12
|
+
untrack,
|
|
10
13
|
type ComponentProps,
|
|
11
14
|
type JSX,
|
|
12
15
|
} from "solid-js"
|
|
13
16
|
import { FileIcon } from "@opencode/ui/file-icon"
|
|
14
17
|
import { useI18n } from "../../context/i18n"
|
|
15
|
-
import { useFilteredList } from "../../hooks"
|
|
16
18
|
import { Button } from "@opencode/ui/button"
|
|
17
19
|
import { Icon } from "@opencode/ui/icon"
|
|
18
20
|
import { IconButton } from "@opencode/ui/icon-button"
|
|
@@ -20,6 +22,16 @@ import { Keybind } from "@opencode/ui/keybind"
|
|
|
20
22
|
import { Tooltip } from "@opencode/ui/tooltip"
|
|
21
23
|
import { Loader } from "@opencode/ui/loader"
|
|
22
24
|
import { makeEventListener } from "@solid-primitives/event-listener"
|
|
25
|
+
import {
|
|
26
|
+
createLineCommentEditorState,
|
|
27
|
+
MENTION_TIMEOUT_MS,
|
|
28
|
+
parseMentionToken,
|
|
29
|
+
transitionLineCommentEditor,
|
|
30
|
+
viewLineCommentEditor,
|
|
31
|
+
type LineCommentEditorConfig,
|
|
32
|
+
type LineCommentEditorEffect,
|
|
33
|
+
type LineCommentEditorEvent,
|
|
34
|
+
} from "./machine"
|
|
23
35
|
import check from "./quote-check.svg"
|
|
24
36
|
import "./line-comment.css"
|
|
25
37
|
|
|
@@ -128,9 +140,8 @@ function pathDirectory(path: string) {
|
|
|
128
140
|
export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
129
141
|
const i18n = useI18n()
|
|
130
142
|
let textareaRef: HTMLTextAreaElement | undefined
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const [alternate, setAlternate] = createSignal(false)
|
|
143
|
+
let mentionTimer: ReturnType<typeof setTimeout> | undefined
|
|
144
|
+
const [editorState, setEditorState] = createSignal(createLineCommentEditorState())
|
|
134
145
|
|
|
135
146
|
const [local, rest] = splitProps(props, [
|
|
136
147
|
"label",
|
|
@@ -153,125 +164,133 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
153
164
|
"classList",
|
|
154
165
|
])
|
|
155
166
|
|
|
156
|
-
const
|
|
157
|
-
|
|
167
|
+
const readConfig = (): LineCommentEditorConfig => ({
|
|
168
|
+
value: local.value,
|
|
169
|
+
allowEmpty: !!local.allowEmpty,
|
|
170
|
+
variant: local.variant ?? "default",
|
|
171
|
+
alternateSubmit: local.alternateSubmit ? { disabled: !!local.alternateSubmit.disabled } : null,
|
|
172
|
+
submitting: !!local.submitting,
|
|
173
|
+
})
|
|
158
174
|
|
|
159
|
-
const
|
|
175
|
+
const view = createMemo(() => viewLineCommentEditor(editorState(), readConfig()))
|
|
160
176
|
|
|
161
177
|
const compactLabel = () =>
|
|
162
|
-
|
|
178
|
+
view().alternateActive
|
|
163
179
|
? local.alternateSubmit!.label
|
|
164
|
-
:
|
|
180
|
+
: view().compactCancel
|
|
165
181
|
? (local.cancelLabel ?? i18n.t("ui.lineComment.cancel"))
|
|
166
182
|
: (local.submitLabel ?? i18n.t("ui.lineComment.submit"))
|
|
167
183
|
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
const currentToken = () =>
|
|
185
|
+
local.mention && textareaRef
|
|
186
|
+
? parseMentionToken(textareaRef.value, textareaRef.selectionStart, textareaRef.selectionEnd)
|
|
187
|
+
: null
|
|
170
188
|
|
|
171
|
-
|
|
189
|
+
const dispatch = (event: LineCommentEditorEvent) => {
|
|
190
|
+
const transition = transitionLineCommentEditor(untrack(editorState), event)
|
|
191
|
+
setEditorState(transition.state)
|
|
172
192
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
makeEventListener(document, "keyup", update, { capture: true })
|
|
176
|
-
makeEventListener(window, "blur", () => setAlternate(false))
|
|
177
|
-
})
|
|
193
|
+
if (transition.state.status !== "mention-loading") clearTimeout(mentionTimer)
|
|
194
|
+
transition.effects.forEach(run)
|
|
178
195
|
|
|
179
|
-
|
|
180
|
-
setMentionOpen(false)
|
|
181
|
-
mention.clear()
|
|
196
|
+
return transition.handled
|
|
182
197
|
}
|
|
183
198
|
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
const run = (effect: LineCommentEditorEffect) => {
|
|
200
|
+
if (effect.type === "mention.load") {
|
|
201
|
+
const attempt = effect.attempt
|
|
202
|
+
clearTimeout(mentionTimer)
|
|
203
|
+
mentionTimer = setTimeout(() => dispatch({ type: "mention.timeout", attempt }), MENTION_TIMEOUT_MS)
|
|
204
|
+
const result = untrack(() => local.mention?.items(effect.query) ?? [])
|
|
188
205
|
|
|
189
|
-
|
|
206
|
+
if (Array.isArray(result)) return dispatch({ type: "mention.loaded", attempt, items: result })
|
|
207
|
+
void result.then(
|
|
208
|
+
(items) => dispatch({ type: "mention.loaded", attempt, items }),
|
|
209
|
+
() => dispatch({ type: "mention.failed", attempt }),
|
|
210
|
+
)
|
|
190
211
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const end = textarea.selectionStart
|
|
194
|
-
const match = textarea.value.slice(0, end).match(/@(\S*)$/)
|
|
195
|
-
|
|
196
|
-
if (!match) return
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
query: match[1] ?? "",
|
|
200
|
-
start: end - match[0].length,
|
|
201
|
-
end,
|
|
212
|
+
return
|
|
202
213
|
}
|
|
203
|
-
}
|
|
204
214
|
|
|
205
|
-
|
|
206
|
-
|
|
215
|
+
if (effect.type === "mention.insert") {
|
|
216
|
+
const textarea = textareaRef
|
|
207
217
|
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
if (!textarea) return
|
|
219
|
+
const value = `${textarea.value.slice(0, effect.token.start)}@${effect.path} ${textarea.value.slice(effect.token.end)}`
|
|
220
|
+
const cursor = effect.token.start + effect.path.length + 2
|
|
221
|
+
local.onInput(value)
|
|
222
|
+
requestAnimationFrame(() => {
|
|
223
|
+
if (untrack(editorState).status === "disposed") return
|
|
224
|
+
textarea.focus()
|
|
225
|
+
textarea.setSelectionRange(cursor, cursor)
|
|
226
|
+
})
|
|
210
227
|
|
|
211
|
-
|
|
228
|
+
return
|
|
229
|
+
}
|
|
212
230
|
|
|
213
|
-
|
|
214
|
-
|
|
231
|
+
if (effect.type === "submit") {
|
|
232
|
+
if (effect.mode === "alternate") return local.alternateSubmit?.onSubmit(effect.value)
|
|
215
233
|
|
|
216
|
-
|
|
217
|
-
|
|
234
|
+
return local.onSubmit(effect.value)
|
|
235
|
+
}
|
|
218
236
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
textarea.setSelectionRange(cursor, cursor)
|
|
222
|
-
})
|
|
237
|
+
if (effect.blur) textareaRef?.blur()
|
|
238
|
+
local.onCancel()
|
|
223
239
|
}
|
|
224
240
|
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
onSelect: selectMention,
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
const syncMention = () => {
|
|
241
|
-
const item = currentMention()
|
|
242
|
-
|
|
243
|
-
if (!item) {
|
|
244
|
-
closeMention()
|
|
245
|
-
|
|
246
|
-
return
|
|
247
|
-
}
|
|
241
|
+
const keyEvent = (event: KeyboardEvent, target: "textarea" | "action") =>
|
|
242
|
+
dispatch({
|
|
243
|
+
type: "key.down",
|
|
244
|
+
target,
|
|
245
|
+
key: event.key,
|
|
246
|
+
ctrl: event.ctrlKey,
|
|
247
|
+
meta: event.metaKey,
|
|
248
|
+
alt: event.altKey,
|
|
249
|
+
shift: event.shiftKey,
|
|
250
|
+
repeat: event.repeat,
|
|
251
|
+
config: readConfig(),
|
|
252
|
+
})
|
|
248
253
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
254
|
+
createComputed(
|
|
255
|
+
on(
|
|
256
|
+
[
|
|
257
|
+
() => local.submitting,
|
|
258
|
+
() => local.variant,
|
|
259
|
+
() => local.allowEmpty,
|
|
260
|
+
() => !!local.mention,
|
|
261
|
+
() => local.alternateSubmit?.disabled,
|
|
262
|
+
() => !!local.alternateSubmit,
|
|
263
|
+
],
|
|
264
|
+
() => dispatch({ type: "props.synced", config: readConfig(), token: currentToken() }),
|
|
265
|
+
),
|
|
266
|
+
)
|
|
252
267
|
|
|
253
|
-
|
|
254
|
-
|
|
268
|
+
// An owner that resets or rewrites the value closes a mention list the new text no longer has.
|
|
269
|
+
createEffect(
|
|
270
|
+
on(
|
|
271
|
+
() => local.value,
|
|
272
|
+
() => dispatch({ type: "props.synced", config: readConfig(), token: currentToken() }),
|
|
273
|
+
{ defer: true },
|
|
274
|
+
),
|
|
275
|
+
)
|
|
255
276
|
|
|
256
|
-
|
|
257
|
-
const active = mention.active()
|
|
258
|
-
selectMention(items.find((item) => item.path === active) ?? items[0])
|
|
259
|
-
}
|
|
277
|
+
onCleanup(() => dispatch({ type: "disposed" }))
|
|
260
278
|
|
|
261
|
-
const
|
|
262
|
-
if (local.submitting) return
|
|
263
|
-
const v = local.value.trim()
|
|
279
|
+
const trackModifiers = createMemo(() => view().trackModifiers)
|
|
264
280
|
|
|
265
|
-
|
|
281
|
+
createEffect(() => {
|
|
282
|
+
if (!trackModifiers()) return
|
|
266
283
|
|
|
267
|
-
|
|
268
|
-
|
|
284
|
+
const update = (event: KeyboardEvent) =>
|
|
285
|
+
dispatch({ type: "modifier.changed", active: modified(event), config: readConfig() })
|
|
269
286
|
|
|
270
|
-
|
|
271
|
-
}
|
|
287
|
+
// Capture modifier releases; the textarea stops key propagation.
|
|
288
|
+
makeEventListener(document, "keydown", update, { capture: true })
|
|
289
|
+
makeEventListener(document, "keyup", update, { capture: true })
|
|
290
|
+
makeEventListener(window, "blur", () => dispatch({ type: "window.blurred" }))
|
|
291
|
+
})
|
|
272
292
|
|
|
273
|
-
|
|
274
|
-
}
|
|
293
|
+
const syncMention = () => dispatch({ type: "mention.synced", token: currentToken() })
|
|
275
294
|
|
|
276
295
|
onMount(() => {
|
|
277
296
|
if (local.autofocus === false) return
|
|
@@ -316,7 +335,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
316
335
|
data-component="line-comment-v2"
|
|
317
336
|
data-variant="editor"
|
|
318
337
|
data-layout={local.variant ?? "default"}
|
|
319
|
-
aria-busy={
|
|
338
|
+
aria-busy={view().submitting || undefined}
|
|
320
339
|
classList={{
|
|
321
340
|
...local.classList,
|
|
322
341
|
[local.class ?? ""]: !!local.class,
|
|
@@ -333,13 +352,15 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
333
352
|
textareaRef = el
|
|
334
353
|
}}
|
|
335
354
|
data-slot="line-comment-v2-textarea"
|
|
355
|
+
// Escape here closes the mention list or cancels the comment, not a dialog or popover around the editor.
|
|
356
|
+
data-owns-escape
|
|
336
357
|
data-scrollable
|
|
337
358
|
aria-label={local.label ?? i18n.t("ui.lineComment.submit")}
|
|
338
359
|
dir="auto"
|
|
339
360
|
rows={local.rows ?? (local.variant === "compact" ? 1 : 4)}
|
|
340
361
|
placeholder={local.placeholder ?? i18n.t("ui.lineComment.contextPlaceholder")}
|
|
341
362
|
value={local.value}
|
|
342
|
-
readOnly={
|
|
363
|
+
readOnly={view().submitting}
|
|
343
364
|
style={{ "unicode-bidi": "plaintext", "text-align": "start" }}
|
|
344
365
|
onInput={(e) => {
|
|
345
366
|
local.onInput(e.currentTarget.value)
|
|
@@ -352,70 +373,26 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
352
373
|
|
|
353
374
|
if (e.isComposing || e.keyCode === 229) return
|
|
354
375
|
|
|
355
|
-
if (
|
|
356
|
-
if (e.key === "Escape") {
|
|
357
|
-
e.preventDefault()
|
|
358
|
-
closeMention()
|
|
359
|
-
|
|
360
|
-
return
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (e.key === "Tab") {
|
|
364
|
-
if (mention.flat().length === 0) return
|
|
365
|
-
e.preventDefault()
|
|
366
|
-
selectActiveMention()
|
|
367
|
-
|
|
368
|
-
return
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const nav = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Enter"
|
|
372
|
-
|
|
373
|
-
const ctrlNav =
|
|
374
|
-
e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && (e.key === "n" || e.key === "p")
|
|
375
|
-
|
|
376
|
-
if ((nav || ctrlNav) && mention.flat().length > 0) {
|
|
377
|
-
mention.onKeyDown(e)
|
|
378
|
-
e.preventDefault()
|
|
379
|
-
|
|
380
|
-
return
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (e.key === "Escape") {
|
|
385
|
-
e.preventDefault()
|
|
386
|
-
|
|
387
|
-
if (local.submitting) return
|
|
388
|
-
e.currentTarget.blur()
|
|
389
|
-
local.onCancel()
|
|
390
|
-
|
|
391
|
-
return
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
395
|
-
e.preventDefault()
|
|
396
|
-
|
|
397
|
-
if (e.repeat) return
|
|
398
|
-
submit(modified(e))
|
|
399
|
-
}
|
|
376
|
+
if (keyEvent(e, "textarea")) e.preventDefault()
|
|
400
377
|
}}
|
|
401
378
|
/>
|
|
402
|
-
<Show when={
|
|
379
|
+
<Show when={view().mentionItems.length > 0}>
|
|
403
380
|
<div data-slot="line-comment-v2-mention-list">
|
|
404
|
-
<For each={
|
|
405
|
-
{(
|
|
406
|
-
const directory =
|
|
407
|
-
const name =
|
|
381
|
+
<For each={view().mentionItems}>
|
|
382
|
+
{(path, index) => {
|
|
383
|
+
const directory = path.endsWith("/") ? path : pathDirectory(path)
|
|
384
|
+
const name = path.endsWith("/") ? "" : pathFilename(path)
|
|
408
385
|
|
|
409
386
|
return (
|
|
410
387
|
<button
|
|
411
388
|
type="button"
|
|
412
389
|
data-slot="line-comment-v2-mention-item"
|
|
413
|
-
data-active={
|
|
390
|
+
data-active={view().activeMentionPath === path ? "" : undefined}
|
|
414
391
|
onMouseDown={(event) => event.preventDefault()}
|
|
415
|
-
onMouseEnter={() => mention.
|
|
416
|
-
onClick={() =>
|
|
392
|
+
onMouseEnter={() => dispatch({ type: "mention.hovered", index: index() })}
|
|
393
|
+
onClick={() => dispatch({ type: "mention.selected", index: index() })}
|
|
417
394
|
>
|
|
418
|
-
<FileIcon node={{ path
|
|
395
|
+
<FileIcon node={{ path, type: "file" }} class="shrink-0 size-4" />
|
|
419
396
|
<div data-slot="line-comment-v2-mention-path">
|
|
420
397
|
<span data-slot="line-comment-v2-mention-dir">{directory}</span>
|
|
421
398
|
<Show when={name}>
|
|
@@ -436,11 +413,11 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
436
413
|
<div class="flex items-center gap-1.5">
|
|
437
414
|
{compactLabel()}
|
|
438
415
|
<Keybind
|
|
439
|
-
keys={
|
|
416
|
+
keys={view().alternateActive ? local.alternateSubmit!.keys : [view().compactCancel ? "Esc" : "⏎"]}
|
|
440
417
|
variant="neutral"
|
|
441
418
|
/>
|
|
442
419
|
</div>
|
|
443
|
-
<Show when={local.alternateSubmit && !
|
|
420
|
+
<Show when={local.alternateSubmit && !view().alternateActive}>
|
|
444
421
|
<div class="flex items-center gap-1.5">
|
|
445
422
|
{local.alternateSubmit!.label}
|
|
446
423
|
<Keybind keys={local.alternateSubmit!.keys} variant="neutral" />
|
|
@@ -452,18 +429,17 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
452
429
|
>
|
|
453
430
|
<IconButton
|
|
454
431
|
data-slot="line-comment-v2-submit"
|
|
432
|
+
data-owns-escape
|
|
455
433
|
type="button"
|
|
456
434
|
size="small"
|
|
457
|
-
variant={
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
disabled={local.submitting || (alternateActive() && local.alternateSubmit?.disabled)}
|
|
435
|
+
variant={view().compactVariant}
|
|
436
|
+
disabled={view().compactDisabled}
|
|
461
437
|
icon={
|
|
462
|
-
|
|
438
|
+
view().submitting ? (
|
|
463
439
|
<Loader />
|
|
464
|
-
) :
|
|
440
|
+
) : view().alternateActive ? (
|
|
465
441
|
<Icon name="arrow-up" />
|
|
466
|
-
) :
|
|
442
|
+
) : view().compactCancel ? (
|
|
467
443
|
<Icon name="close" />
|
|
468
444
|
) : (
|
|
469
445
|
<span
|
|
@@ -474,30 +450,21 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
474
450
|
)
|
|
475
451
|
}
|
|
476
452
|
aria-label={compactLabel()}
|
|
477
|
-
onPointerEnter={(event) =>
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
453
|
+
onPointerEnter={(event) =>
|
|
454
|
+
dispatch({ type: "modifier.changed", active: modified(event), config: readConfig() })
|
|
455
|
+
}
|
|
456
|
+
onPointerDown={(event) =>
|
|
457
|
+
dispatch({ type: "modifier.changed", active: modified(event), config: readConfig() })
|
|
458
|
+
}
|
|
459
|
+
onClick={(event) =>
|
|
460
|
+
dispatch({ type: "action.clicked", modified: modified(event), config: readConfig() })
|
|
461
|
+
}
|
|
484
462
|
onKeyDown={(event) => {
|
|
485
463
|
if (event.isComposing) return
|
|
486
464
|
|
|
487
|
-
if (event
|
|
488
|
-
event.preventDefault()
|
|
489
|
-
event.stopPropagation()
|
|
490
|
-
|
|
491
|
-
if (!event.repeat) submit(true)
|
|
492
|
-
|
|
493
|
-
return
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (event.key !== "Escape") return
|
|
465
|
+
if (!keyEvent(event, "action")) return
|
|
497
466
|
event.preventDefault()
|
|
498
467
|
event.stopPropagation()
|
|
499
|
-
|
|
500
|
-
if (!local.submitting) local.onCancel()
|
|
501
468
|
}}
|
|
502
469
|
/>
|
|
503
470
|
</Tooltip>
|
|
@@ -509,10 +476,22 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
509
476
|
{(selection) => <div data-slot="line-comment-v2-footer-meta">{selection()}</div>}
|
|
510
477
|
</Show>
|
|
511
478
|
<div data-slot="line-comment-v2-footer-actions">
|
|
512
|
-
<Button
|
|
479
|
+
<Button
|
|
480
|
+
type="button"
|
|
481
|
+
size="small"
|
|
482
|
+
variant="ghost"
|
|
483
|
+
disabled={view().submitting}
|
|
484
|
+
onClick={() => dispatch({ type: "cancel.requested" })}
|
|
485
|
+
>
|
|
513
486
|
{local.cancelLabel ?? i18n.t("ui.lineComment.cancel")}
|
|
514
487
|
</Button>
|
|
515
|
-
<Button
|
|
488
|
+
<Button
|
|
489
|
+
type="button"
|
|
490
|
+
size="small"
|
|
491
|
+
variant="contrast"
|
|
492
|
+
disabled={!view().canSubmit || view().submitting}
|
|
493
|
+
onClick={() => dispatch({ type: "submit.requested", config: readConfig() })}
|
|
494
|
+
>
|
|
516
495
|
{local.submitLabel ?? i18n.t("ui.lineComment.submit")}
|
|
517
496
|
</Button>
|
|
518
497
|
</div>
|