@adea-ai/ui 0.151.0 → 0.151.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/README.md +5 -0
- package/dist/components/composites/action-button/action-button.d.ts.map +1 -1
- package/dist/components/composites/action-button/action-button.js +8 -2
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.d.ts.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.js +39 -36
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.d.ts.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.js +28 -4
- package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
- package/dist/components/conversation/paste-token-editor.d.ts.map +1 -1
- package/dist/components/conversation/paste-token-editor.js +127 -37
- package/dist/components/conversation/paste-token-editor.js.map +1 -1
- package/dist/components/conversation/scroll-follow-core.d.ts +13 -0
- package/dist/components/conversation/scroll-follow-core.d.ts.map +1 -1
- package/dist/components/conversation/scroll-follow-core.js +12 -1
- package/dist/components/conversation/scroll-follow-core.js.map +1 -1
- package/dist/components/conversation/scroll-follow.d.ts.map +1 -1
- package/dist/components/conversation/scroll-follow.js +52 -21
- package/dist/components/conversation/scroll-follow.js.map +1 -1
- package/dist/components/ui/calendar/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar/calendar.js +109 -115
- package/dist/components/ui/calendar/calendar.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/r/appearance-editor.json +1 -1
- package/dist/r/lib.json +1 -1
- package/dist/r/registry.json +3 -3
- package/dist/r/src/components/composites/action-button/action-button.tsx +11 -1
- package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +112 -105
- package/dist/r/src/components/conversation/internal/chat-composer-shell.tsx +36 -2
- package/dist/r/src/components/conversation/paste-token-editor.tsx +191 -49
- package/dist/r/src/components/conversation/scroll-follow-core.ts +23 -0
- package/dist/r/src/components/conversation/scroll-follow.ts +69 -17
- package/dist/r/src/components/ui/calendar/calendar.tsx +99 -104
- package/dist/r/theming.json +1 -1
- package/package.json +9 -3
- package/registry.json +3 -3
- package/src/components/composites/action-button/action-button.tsx +11 -1
- package/src/components/composites/inline-citation/inline-citation.tsx +112 -105
- package/src/components/conversation/internal/chat-composer-shell.tsx +36 -2
- package/src/components/conversation/paste-token-editor.tsx +191 -49
- package/src/components/conversation/scroll-follow-core.ts +23 -0
- package/src/components/conversation/scroll-follow.ts +69 -17
- package/src/components/ui/calendar/calendar.tsx +99 -104
- package/src/index.ts +1 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Show,
|
|
3
|
+
createRoot,
|
|
3
4
|
createSignal,
|
|
4
5
|
splitProps,
|
|
5
6
|
type ComponentProps,
|
|
@@ -66,7 +67,16 @@ function guardedClick(
|
|
|
66
67
|
onActivate: (event: MouseEvent) => void = () => {}
|
|
67
68
|
) {
|
|
68
69
|
return (event: MouseEvent) => {
|
|
69
|
-
|
|
70
|
+
// A polymorphic trigger can provide a getter that creates reactive work.
|
|
71
|
+
// Event callbacks have no owner, so dispose any such work after the read.
|
|
72
|
+
const isDisabled = createRoot((dispose) => {
|
|
73
|
+
try {
|
|
74
|
+
return disabled()
|
|
75
|
+
} finally {
|
|
76
|
+
dispose()
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
if (isDisabled) {
|
|
70
80
|
event.preventDefault()
|
|
71
81
|
event.stopImmediatePropagation()
|
|
72
82
|
return
|
|
@@ -157,116 +157,123 @@ export function InlineCitation(props: InlineCitationProps) {
|
|
|
157
157
|
if (wasPeeking) queueMicrotask(() => content?.focus())
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
// The badge and the popover's portal marker share one wrapper. Without it they
|
|
161
|
+
// are loose siblings in the host's node list, and when the portal marker comes
|
|
162
|
+
// and goes as the card opens and closes, a host that renders its inline nodes
|
|
163
|
+
// as one array (MessageText) reconciles that array and can move the badge,
|
|
164
|
+
// which drops keyboard focus to <body> on the badge the reader just reached.
|
|
160
165
|
return (
|
|
161
166
|
<Show when={count() > 0}>
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
placement="bottom"
|
|
168
|
-
gutter={6}
|
|
169
|
-
>
|
|
170
|
-
<PopoverTrigger
|
|
171
|
-
as={Button}
|
|
172
|
-
variant="subtle"
|
|
173
|
-
size="2xs"
|
|
174
|
-
touchTarget="comfortable"
|
|
175
|
-
data-slot="inline-citation"
|
|
176
|
-
aria-label={citationName(local.sources, local.index)}
|
|
177
|
-
class={cn('mx-0.5 align-baseline tabular-nums', local.class)}
|
|
178
|
-
onClick={onClick}
|
|
179
|
-
onPointerEnter={onPointerEnter}
|
|
180
|
-
onPointerLeave={onPointerLeave}
|
|
181
|
-
onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {
|
|
182
|
-
// Mouse focus follows the press; only keyboard focus peeks.
|
|
183
|
-
if (restoringFocus) return
|
|
184
|
-
if (event.currentTarget.matches(':focus-visible')) dispatch('focus')
|
|
167
|
+
<span data-slot="inline-citation-root">
|
|
168
|
+
<Popover
|
|
169
|
+
open={mode() !== 'closed'}
|
|
170
|
+
onOpenChange={(next) => {
|
|
171
|
+
if (!next && !pressing) dispatch('dismiss')
|
|
185
172
|
}}
|
|
186
|
-
|
|
173
|
+
placement="bottom"
|
|
174
|
+
gutter={6}
|
|
187
175
|
>
|
|
188
|
-
<
|
|
189
|
-
{
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
aria-
|
|
253
|
-
|
|
254
|
-
onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}
|
|
176
|
+
<PopoverTrigger
|
|
177
|
+
as={Button}
|
|
178
|
+
variant="subtle"
|
|
179
|
+
size="2xs"
|
|
180
|
+
touchTarget="comfortable"
|
|
181
|
+
data-slot="inline-citation"
|
|
182
|
+
aria-label={citationName(local.sources, local.index)}
|
|
183
|
+
class={cn('mx-0.5 align-baseline tabular-nums', local.class)}
|
|
184
|
+
onClick={onClick}
|
|
185
|
+
onPointerEnter={onPointerEnter}
|
|
186
|
+
onPointerLeave={onPointerLeave}
|
|
187
|
+
onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {
|
|
188
|
+
// Mouse focus follows the press; only keyboard focus peeks.
|
|
189
|
+
if (restoringFocus) return
|
|
190
|
+
if (event.currentTarget.matches(':focus-visible')) dispatch('focus')
|
|
191
|
+
}}
|
|
192
|
+
onBlur={() => dispatch('blur')}
|
|
193
|
+
>
|
|
194
|
+
<span aria-hidden="true" class="max-w-32 truncate">
|
|
195
|
+
{citationLabel(local.index, local.sources[0])}
|
|
196
|
+
</span>
|
|
197
|
+
<Show when={count() > 1}>
|
|
198
|
+
<span aria-hidden="true">+{count() - 1}</span>
|
|
199
|
+
</Show>
|
|
200
|
+
</PopoverTrigger>
|
|
201
|
+
<PopoverContent
|
|
202
|
+
ref={(element: HTMLElement) => (content = element)}
|
|
203
|
+
inert={keyboardPeek() || mode() === 'closed' || undefined}
|
|
204
|
+
class="w-72 max-w-full"
|
|
205
|
+
onOpenAutoFocus={(event: Event) => {
|
|
206
|
+
if (mode() === 'peek') event.preventDefault()
|
|
207
|
+
}}
|
|
208
|
+
onFocusIn={() => {
|
|
209
|
+
focusInCard = true
|
|
210
|
+
}}
|
|
211
|
+
onKeyDown={(event: KeyboardEvent) => {
|
|
212
|
+
if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return
|
|
213
|
+
dispatch('dismiss')
|
|
214
|
+
}}
|
|
215
|
+
onCloseAutoFocus={(event: Event) => {
|
|
216
|
+
const returnFocus = focusInCard
|
|
217
|
+
focusInCard = false
|
|
218
|
+
if (!returnFocus) {
|
|
219
|
+
event.preventDefault()
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
// The focus move that follows is synchronous; the microtask ends the window.
|
|
223
|
+
restoringFocus = true
|
|
224
|
+
queueMicrotask(() => {
|
|
225
|
+
restoringFocus = false
|
|
226
|
+
})
|
|
227
|
+
}}
|
|
228
|
+
onPointerEnter={(event: PointerEvent) => {
|
|
229
|
+
if (event.pointerType !== 'touch') clear()
|
|
230
|
+
}}
|
|
231
|
+
onPointerLeave={onPointerLeave}
|
|
232
|
+
>
|
|
233
|
+
<Show when={active()}>
|
|
234
|
+
{(source) => (
|
|
235
|
+
<div class="flex min-w-0 flex-col gap-1.5 px-2 py-1.5">
|
|
236
|
+
<Show when={count() > 1}>
|
|
237
|
+
<div class="flex items-center justify-between gap-2">
|
|
238
|
+
<span
|
|
239
|
+
role="status"
|
|
240
|
+
aria-live="polite"
|
|
241
|
+
class="text-xs text-muted-foreground tabular-nums"
|
|
255
242
|
>
|
|
256
|
-
|
|
257
|
-
</
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
243
|
+
Source {wrapIndex(position(), count()) + 1} of {count()}
|
|
244
|
+
</span>
|
|
245
|
+
<span class="flex items-center gap-0.5">
|
|
246
|
+
<ActionButton
|
|
247
|
+
variant="ghost"
|
|
248
|
+
size="icon-xs"
|
|
249
|
+
aria-label="Previous source"
|
|
250
|
+
tooltip="Previous source"
|
|
251
|
+
onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}
|
|
252
|
+
>
|
|
253
|
+
<ChevronLeft />
|
|
254
|
+
</ActionButton>
|
|
255
|
+
<ActionButton
|
|
256
|
+
variant="ghost"
|
|
257
|
+
size="icon-xs"
|
|
258
|
+
aria-label="Next source"
|
|
259
|
+
tooltip="Next source"
|
|
260
|
+
onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}
|
|
261
|
+
>
|
|
262
|
+
<ChevronRight />
|
|
263
|
+
</ActionButton>
|
|
264
|
+
</span>
|
|
265
|
+
</div>
|
|
266
|
+
</Show>
|
|
267
|
+
<PopoverTitle class="p-0 [overflow-wrap:anywhere]">
|
|
268
|
+
{sourceTitle(source())}
|
|
269
|
+
</PopoverTitle>
|
|
270
|
+
<CitationDetails source={source()} />
|
|
271
|
+
</div>
|
|
272
|
+
)}
|
|
273
|
+
</Show>
|
|
274
|
+
</PopoverContent>
|
|
275
|
+
</Popover>
|
|
276
|
+
</span>
|
|
270
277
|
</Show>
|
|
271
278
|
)
|
|
272
279
|
}
|
|
@@ -72,6 +72,7 @@ export function ChatComposerShell<Extra extends object>(props: ChatComposerShell
|
|
|
72
72
|
const [error, setError] = createSignal<string | null>(null)
|
|
73
73
|
let field: HTMLTextAreaElement | undefined
|
|
74
74
|
let restoreBar: HTMLButtonElement | undefined
|
|
75
|
+
let root: HTMLDivElement | undefined
|
|
75
76
|
let focusFrame: number | undefined
|
|
76
77
|
let focusTarget: 'input' | 'bar' | undefined
|
|
77
78
|
let selection:
|
|
@@ -89,9 +90,24 @@ export function ChatComposerShell<Extra extends object>(props: ChatComposerShell
|
|
|
89
90
|
const requestFocus = (target: 'input' | 'bar') => {
|
|
90
91
|
cancelFocus()
|
|
91
92
|
focusTarget = target
|
|
93
|
+
const requester = document.activeElement
|
|
92
94
|
focusFrame = requestAnimationFrame(() => {
|
|
93
95
|
focusFrame = undefined
|
|
94
96
|
if (!active || props.approvalFocus) return
|
|
97
|
+
// Focus that moved elsewhere since the request (another conversation,
|
|
98
|
+
// say, while a collapse or expand waited for this frame) is a newer
|
|
99
|
+
// owner; taking it back would also drop whatever is being typed there.
|
|
100
|
+
const current = document.activeElement
|
|
101
|
+
if (
|
|
102
|
+
current &&
|
|
103
|
+
current !== document.body &&
|
|
104
|
+
current !== requester &&
|
|
105
|
+
!root?.contains(current)
|
|
106
|
+
) {
|
|
107
|
+
focusTarget = undefined
|
|
108
|
+
if (target === 'input') selection = undefined
|
|
109
|
+
return
|
|
110
|
+
}
|
|
95
111
|
if (target === 'bar' && collapsed()) restoreBar?.focus()
|
|
96
112
|
if (target === 'input' && !collapsed() && !props.disabled && field) {
|
|
97
113
|
field.focus()
|
|
@@ -105,6 +121,16 @@ export function ChatComposerShell<Extra extends object>(props: ChatComposerShell
|
|
|
105
121
|
focusTarget = undefined
|
|
106
122
|
})
|
|
107
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* A press or key in the input before the deferred expand restore runs is a
|
|
126
|
+
* newer selection owner: the restore must not move its caret back.
|
|
127
|
+
*/
|
|
128
|
+
const yieldInputRestore = () => {
|
|
129
|
+
if (focusTarget !== 'input') return
|
|
130
|
+
cancelFocus()
|
|
131
|
+
focusTarget = undefined
|
|
132
|
+
selection = undefined
|
|
133
|
+
}
|
|
108
134
|
const changeCollapsed = (value: boolean) => {
|
|
109
135
|
if (!props.collapse || props.approvalFocus) return
|
|
110
136
|
if (value && field)
|
|
@@ -183,6 +209,7 @@ export function ChatComposerShell<Extra extends object>(props: ChatComposerShell
|
|
|
183
209
|
return first.length > 120 ? `${first.slice(0, 120)}…` : first
|
|
184
210
|
}
|
|
185
211
|
const handleInputKeyDown = (event: KeyboardEvent) => {
|
|
212
|
+
yieldInputRestore()
|
|
186
213
|
if (event.key === 'Escape' && error()) {
|
|
187
214
|
setError(null)
|
|
188
215
|
return
|
|
@@ -211,7 +238,11 @@ export function ChatComposerShell<Extra extends object>(props: ChatComposerShell
|
|
|
211
238
|
ime.onBlur()
|
|
212
239
|
}
|
|
213
240
|
return (
|
|
214
|
-
<div
|
|
241
|
+
<div
|
|
242
|
+
ref={(element) => (root = element)}
|
|
243
|
+
data-slot="chat-composer"
|
|
244
|
+
class="mx-auto flex w-full max-w-4xl flex-col px-4 pb-1"
|
|
245
|
+
>
|
|
215
246
|
<Show when={!props.approvalFocus}>
|
|
216
247
|
<Show when={props.knowledge}>
|
|
217
248
|
<div data-slot="composer-knowledge">{props.knowledge}</div>
|
|
@@ -287,10 +318,13 @@ export function ChatComposerShell<Extra extends object>(props: ChatComposerShell
|
|
|
287
318
|
{props.renderInput({
|
|
288
319
|
ref: (element) => {
|
|
289
320
|
field = element
|
|
290
|
-
if (element)
|
|
321
|
+
if (element) {
|
|
322
|
+
element.addEventListener('pointerdown', yieldInputRestore)
|
|
291
323
|
onCleanup(() => {
|
|
324
|
+
element.removeEventListener('pointerdown', yieldInputRestore)
|
|
292
325
|
if (field === element) field = undefined
|
|
293
326
|
})
|
|
327
|
+
}
|
|
294
328
|
},
|
|
295
329
|
value: () => props.value,
|
|
296
330
|
resetKey: () => props.resetKey,
|