@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
|
@@ -1,23 +1,37 @@
|
|
|
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"
|
|
19
21
|
import { Keybind } from "@opencode/ui/keybind"
|
|
20
22
|
import { Tooltip } from "@opencode/ui/tooltip"
|
|
23
|
+
import { Loader } from "@opencode/ui/loader"
|
|
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"
|
|
21
35
|
import check from "./quote-check.svg"
|
|
22
36
|
import "./line-comment.css"
|
|
23
37
|
|
|
@@ -100,6 +114,15 @@ export interface LineCommentEditorProps extends Omit<ComponentProps<"div">, "chi
|
|
|
100
114
|
/** Submit an empty value too, such as to clear a comment that exists (default: false). Compact empty actions otherwise cancel. */
|
|
101
115
|
allowEmpty?: boolean
|
|
102
116
|
mention?: LineCommentEditorMention
|
|
117
|
+
/** Compact editor action on Mod+Enter or modifier-click. */
|
|
118
|
+
alternateSubmit?: {
|
|
119
|
+
label: string
|
|
120
|
+
keys: string[]
|
|
121
|
+
disabled?: boolean
|
|
122
|
+
onSubmit: (value: string) => void
|
|
123
|
+
}
|
|
124
|
+
/** Keep the draft read-only and prevent duplicate actions while its submission settles. */
|
|
125
|
+
submitting?: boolean
|
|
103
126
|
}
|
|
104
127
|
|
|
105
128
|
function pathFilename(path: string) {
|
|
@@ -117,7 +140,8 @@ function pathDirectory(path: string) {
|
|
|
117
140
|
export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
118
141
|
const i18n = useI18n()
|
|
119
142
|
let textareaRef: HTMLTextAreaElement | undefined
|
|
120
|
-
|
|
143
|
+
let mentionTimer: ReturnType<typeof setTimeout> | undefined
|
|
144
|
+
const [editorState, setEditorState] = createSignal(createLineCommentEditorState())
|
|
121
145
|
|
|
122
146
|
const [local, rest] = splitProps(props, [
|
|
123
147
|
"label",
|
|
@@ -134,106 +158,139 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
134
158
|
"autofocus",
|
|
135
159
|
"allowEmpty",
|
|
136
160
|
"mention",
|
|
161
|
+
"alternateSubmit",
|
|
162
|
+
"submitting",
|
|
137
163
|
"class",
|
|
138
164
|
"classList",
|
|
139
165
|
])
|
|
140
166
|
|
|
141
|
-
const
|
|
142
|
-
|
|
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
|
+
})
|
|
143
174
|
|
|
144
|
-
const
|
|
145
|
-
compactCancel()
|
|
146
|
-
? (local.cancelLabel ?? i18n.t("ui.lineComment.cancel"))
|
|
147
|
-
: (local.submitLabel ?? i18n.t("ui.lineComment.submit"))
|
|
175
|
+
const view = createMemo(() => viewLineCommentEditor(editorState(), readConfig()))
|
|
148
176
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
177
|
+
const compactLabel = () =>
|
|
178
|
+
view().alternateActive
|
|
179
|
+
? local.alternateSubmit!.label
|
|
180
|
+
: view().compactCancel
|
|
181
|
+
? (local.cancelLabel ?? i18n.t("ui.lineComment.cancel"))
|
|
182
|
+
: (local.submitLabel ?? i18n.t("ui.lineComment.submit"))
|
|
153
183
|
|
|
154
|
-
const
|
|
155
|
-
|
|
184
|
+
const currentToken = () =>
|
|
185
|
+
local.mention && textareaRef
|
|
186
|
+
? parseMentionToken(textareaRef.value, textareaRef.selectionStart, textareaRef.selectionEnd)
|
|
187
|
+
: null
|
|
156
188
|
|
|
157
|
-
|
|
189
|
+
const dispatch = (event: LineCommentEditorEvent) => {
|
|
190
|
+
const transition = transitionLineCommentEditor(untrack(editorState), event)
|
|
191
|
+
setEditorState(transition.state)
|
|
158
192
|
|
|
159
|
-
if (
|
|
193
|
+
if (transition.state.status !== "mention-loading") clearTimeout(mentionTimer)
|
|
194
|
+
transition.effects.forEach(run)
|
|
160
195
|
|
|
161
|
-
|
|
196
|
+
return transition.handled
|
|
197
|
+
}
|
|
162
198
|
|
|
163
|
-
|
|
164
|
-
|
|
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) ?? [])
|
|
165
205
|
|
|
166
|
-
|
|
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
|
+
)
|
|
167
211
|
|
|
168
|
-
|
|
169
|
-
query: match[1] ?? "",
|
|
170
|
-
start: end - match[0].length,
|
|
171
|
-
end,
|
|
212
|
+
return
|
|
172
213
|
}
|
|
173
|
-
}
|
|
174
214
|
|
|
175
|
-
|
|
176
|
-
|
|
215
|
+
if (effect.type === "mention.insert") {
|
|
216
|
+
const textarea = textareaRef
|
|
177
217
|
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
})
|
|
180
227
|
|
|
181
|
-
|
|
228
|
+
return
|
|
229
|
+
}
|
|
182
230
|
|
|
183
|
-
|
|
184
|
-
|
|
231
|
+
if (effect.type === "submit") {
|
|
232
|
+
if (effect.mode === "alternate") return local.alternateSubmit?.onSubmit(effect.value)
|
|
185
233
|
|
|
186
|
-
|
|
187
|
-
|
|
234
|
+
return local.onSubmit(effect.value)
|
|
235
|
+
}
|
|
188
236
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
textarea.setSelectionRange(cursor, cursor)
|
|
192
|
-
})
|
|
237
|
+
if (effect.blur) textareaRef?.blur()
|
|
238
|
+
local.onCancel()
|
|
193
239
|
}
|
|
194
240
|
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
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
|
+
})
|
|
198
253
|
|
|
199
|
-
|
|
200
|
-
|
|
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
|
+
)
|
|
201
267
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
+
)
|
|
209
276
|
|
|
210
|
-
|
|
211
|
-
const item = currentMention()
|
|
277
|
+
onCleanup(() => dispatch({ type: "disposed" }))
|
|
212
278
|
|
|
213
|
-
|
|
214
|
-
closeMention()
|
|
279
|
+
const trackModifiers = createMemo(() => view().trackModifiers)
|
|
215
280
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
setMentionOpen(true)
|
|
220
|
-
mention.onInput(item.query)
|
|
221
|
-
}
|
|
281
|
+
createEffect(() => {
|
|
282
|
+
if (!trackModifiers()) return
|
|
222
283
|
|
|
223
|
-
|
|
224
|
-
|
|
284
|
+
const update = (event: KeyboardEvent) =>
|
|
285
|
+
dispatch({ type: "modifier.changed", active: modified(event), config: readConfig() })
|
|
225
286
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
+
})
|
|
230
292
|
|
|
231
|
-
const
|
|
232
|
-
const v = local.value.trim()
|
|
233
|
-
|
|
234
|
-
if (!v && !local.allowEmpty) return
|
|
235
|
-
local.onSubmit(v)
|
|
236
|
-
}
|
|
293
|
+
const syncMention = () => dispatch({ type: "mention.synced", token: currentToken() })
|
|
237
294
|
|
|
238
295
|
onMount(() => {
|
|
239
296
|
if (local.autofocus === false) return
|
|
@@ -278,6 +335,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
278
335
|
data-component="line-comment-v2"
|
|
279
336
|
data-variant="editor"
|
|
280
337
|
data-layout={local.variant ?? "default"}
|
|
338
|
+
aria-busy={view().submitting || undefined}
|
|
281
339
|
classList={{
|
|
282
340
|
...local.classList,
|
|
283
341
|
[local.class ?? ""]: !!local.class,
|
|
@@ -294,12 +352,15 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
294
352
|
textareaRef = el
|
|
295
353
|
}}
|
|
296
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
|
|
297
357
|
data-scrollable
|
|
298
358
|
aria-label={local.label ?? i18n.t("ui.lineComment.submit")}
|
|
299
359
|
dir="auto"
|
|
300
360
|
rows={local.rows ?? (local.variant === "compact" ? 1 : 4)}
|
|
301
361
|
placeholder={local.placeholder ?? i18n.t("ui.lineComment.contextPlaceholder")}
|
|
302
362
|
value={local.value}
|
|
363
|
+
readOnly={view().submitting}
|
|
303
364
|
style={{ "unicode-bidi": "plaintext", "text-align": "start" }}
|
|
304
365
|
onInput={(e) => {
|
|
305
366
|
local.onInput(e.currentTarget.value)
|
|
@@ -312,66 +373,26 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
312
373
|
|
|
313
374
|
if (e.isComposing || e.keyCode === 229) return
|
|
314
375
|
|
|
315
|
-
if (
|
|
316
|
-
if (e.key === "Escape") {
|
|
317
|
-
e.preventDefault()
|
|
318
|
-
closeMention()
|
|
319
|
-
|
|
320
|
-
return
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (e.key === "Tab") {
|
|
324
|
-
if (mention.flat().length === 0) return
|
|
325
|
-
e.preventDefault()
|
|
326
|
-
selectActiveMention()
|
|
327
|
-
|
|
328
|
-
return
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const nav = e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Enter"
|
|
332
|
-
|
|
333
|
-
const ctrlNav =
|
|
334
|
-
e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && (e.key === "n" || e.key === "p")
|
|
335
|
-
|
|
336
|
-
if ((nav || ctrlNav) && mention.flat().length > 0) {
|
|
337
|
-
mention.onKeyDown(e)
|
|
338
|
-
e.preventDefault()
|
|
339
|
-
|
|
340
|
-
return
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (e.key === "Escape") {
|
|
345
|
-
e.preventDefault()
|
|
346
|
-
e.currentTarget.blur()
|
|
347
|
-
local.onCancel()
|
|
348
|
-
|
|
349
|
-
return
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
353
|
-
e.preventDefault()
|
|
354
|
-
submit()
|
|
355
|
-
}
|
|
376
|
+
if (keyEvent(e, "textarea")) e.preventDefault()
|
|
356
377
|
}}
|
|
357
378
|
/>
|
|
358
|
-
<Show when={
|
|
379
|
+
<Show when={view().mentionItems.length > 0}>
|
|
359
380
|
<div data-slot="line-comment-v2-mention-list">
|
|
360
|
-
<For each={
|
|
361
|
-
{(
|
|
362
|
-
const directory =
|
|
363
|
-
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)
|
|
364
385
|
|
|
365
386
|
return (
|
|
366
387
|
<button
|
|
367
388
|
type="button"
|
|
368
389
|
data-slot="line-comment-v2-mention-item"
|
|
369
|
-
data-active={
|
|
390
|
+
data-active={view().activeMentionPath === path ? "" : undefined}
|
|
370
391
|
onMouseDown={(event) => event.preventDefault()}
|
|
371
|
-
onMouseEnter={() => mention.
|
|
372
|
-
onClick={() =>
|
|
392
|
+
onMouseEnter={() => dispatch({ type: "mention.hovered", index: index() })}
|
|
393
|
+
onClick={() => dispatch({ type: "mention.selected", index: index() })}
|
|
373
394
|
>
|
|
374
|
-
<FileIcon node={{ path
|
|
395
|
+
<FileIcon node={{ path, type: "file" }} class="shrink-0 size-4" />
|
|
375
396
|
<div data-slot="line-comment-v2-mention-path">
|
|
376
397
|
<span data-slot="line-comment-v2-mention-dir">{directory}</span>
|
|
377
398
|
<Show when={name}>
|
|
@@ -388,19 +409,37 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
388
409
|
<Show when={local.variant === "compact"}>
|
|
389
410
|
<Tooltip
|
|
390
411
|
value={
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
412
|
+
<div class="flex flex-col gap-1.5">
|
|
413
|
+
<div class="flex items-center gap-1.5">
|
|
414
|
+
{compactLabel()}
|
|
415
|
+
<Keybind
|
|
416
|
+
keys={view().alternateActive ? local.alternateSubmit!.keys : [view().compactCancel ? "Esc" : "⏎"]}
|
|
417
|
+
variant="neutral"
|
|
418
|
+
/>
|
|
419
|
+
</div>
|
|
420
|
+
<Show when={local.alternateSubmit && !view().alternateActive}>
|
|
421
|
+
<div class="flex items-center gap-1.5">
|
|
422
|
+
{local.alternateSubmit!.label}
|
|
423
|
+
<Keybind keys={local.alternateSubmit!.keys} variant="neutral" />
|
|
424
|
+
</div>
|
|
425
|
+
</Show>
|
|
426
|
+
</div>
|
|
394
427
|
}
|
|
395
428
|
placement="top"
|
|
396
429
|
>
|
|
397
430
|
<IconButton
|
|
398
431
|
data-slot="line-comment-v2-submit"
|
|
432
|
+
data-owns-escape
|
|
399
433
|
type="button"
|
|
400
434
|
size="small"
|
|
401
|
-
variant={
|
|
435
|
+
variant={view().compactVariant}
|
|
436
|
+
disabled={view().compactDisabled}
|
|
402
437
|
icon={
|
|
403
|
-
|
|
438
|
+
view().submitting ? (
|
|
439
|
+
<Loader />
|
|
440
|
+
) : view().alternateActive ? (
|
|
441
|
+
<Icon name="arrow-up" />
|
|
442
|
+
) : view().compactCancel ? (
|
|
404
443
|
<Icon name="close" />
|
|
405
444
|
) : (
|
|
406
445
|
<span
|
|
@@ -411,12 +450,21 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
411
450
|
)
|
|
412
451
|
}
|
|
413
452
|
aria-label={compactLabel()}
|
|
414
|
-
|
|
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
|
+
}
|
|
415
462
|
onKeyDown={(event) => {
|
|
416
|
-
if (event.
|
|
463
|
+
if (event.isComposing) return
|
|
464
|
+
|
|
465
|
+
if (!keyEvent(event, "action")) return
|
|
417
466
|
event.preventDefault()
|
|
418
467
|
event.stopPropagation()
|
|
419
|
-
local.onCancel()
|
|
420
468
|
}}
|
|
421
469
|
/>
|
|
422
470
|
</Tooltip>
|
|
@@ -428,10 +476,22 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
428
476
|
{(selection) => <div data-slot="line-comment-v2-footer-meta">{selection()}</div>}
|
|
429
477
|
</Show>
|
|
430
478
|
<div data-slot="line-comment-v2-footer-actions">
|
|
431
|
-
<Button
|
|
479
|
+
<Button
|
|
480
|
+
type="button"
|
|
481
|
+
size="small"
|
|
482
|
+
variant="ghost"
|
|
483
|
+
disabled={view().submitting}
|
|
484
|
+
onClick={() => dispatch({ type: "cancel.requested" })}
|
|
485
|
+
>
|
|
432
486
|
{local.cancelLabel ?? i18n.t("ui.lineComment.cancel")}
|
|
433
487
|
</Button>
|
|
434
|
-
<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
|
+
>
|
|
435
495
|
{local.submitLabel ?? i18n.t("ui.lineComment.submit")}
|
|
436
496
|
</Button>
|
|
437
497
|
</div>
|
|
@@ -441,3 +501,7 @@ export function LineCommentEditor(props: LineCommentEditorProps) {
|
|
|
441
501
|
</div>
|
|
442
502
|
)
|
|
443
503
|
}
|
|
504
|
+
|
|
505
|
+
function modified(event: Pick<KeyboardEvent, "metaKey" | "ctrlKey" | "altKey" | "shiftKey">) {
|
|
506
|
+
return (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey
|
|
507
|
+
}
|