@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,4 +1,4 @@
|
|
|
1
|
-
import { For, Show, splitProps, type ComponentProps, type JSX } from 'solid-js'
|
|
1
|
+
import { createMemo, For, Show, splitProps, type ComponentProps, type JSX } from 'solid-js'
|
|
2
2
|
import Calendar, {
|
|
3
3
|
type RootProps as CorvuCalendarProps,
|
|
4
4
|
type RootSingleProps,
|
|
@@ -73,22 +73,6 @@ const EXTRAS = ['weekdayLabels', 'previousLabel', 'nextLabel', 'formatMonth', 'c
|
|
|
73
73
|
|
|
74
74
|
const MONTH_FORMAT: Intl.DateTimeFormatOptions = { month: 'long', year: 'numeric' }
|
|
75
75
|
|
|
76
|
-
function monthLabel(month: Date, format?: (month: Date) => string): string {
|
|
77
|
-
return format ? format(month) : new Intl.DateTimeFormat(undefined, MONTH_FORMAT).format(month)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* A day's accessible name: the full date, because the visible number is only
|
|
82
|
-
* meaningful next to its column heading.
|
|
83
|
-
*/
|
|
84
|
-
function dayLabel(day: Date): string {
|
|
85
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
86
|
-
day: 'numeric',
|
|
87
|
-
month: 'long',
|
|
88
|
-
year: 'numeric',
|
|
89
|
-
}).format(day)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
76
|
/** The locale's short weekday names, Sunday first — which is the order corvu's `weeks` use. */
|
|
93
77
|
function defaultWeekdays(): string[] {
|
|
94
78
|
const format = new Intl.DateTimeFormat(undefined, { weekday: 'short' })
|
|
@@ -108,82 +92,92 @@ function CalendarGrid(props: {
|
|
|
108
92
|
formatMonth?: (month: Date) => string
|
|
109
93
|
}) {
|
|
110
94
|
const context = Calendar.useContext()
|
|
111
|
-
const weekdays = () => props.weekdayLabels ?? defaultWeekdays()
|
|
112
|
-
|
|
113
95
|
return (
|
|
114
96
|
<For each={context.months()}>
|
|
115
|
-
{(month, index) =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
97
|
+
{(month, index) => {
|
|
98
|
+
const weekdays = createMemo(() => props.weekdayLabels ?? defaultWeekdays())
|
|
99
|
+
// Recreate per month so navigation picks up changed locale and time-zone defaults.
|
|
100
|
+
const dayFormatter = new Intl.DateTimeFormat(undefined, {
|
|
101
|
+
day: 'numeric',
|
|
102
|
+
month: 'long',
|
|
103
|
+
year: 'numeric',
|
|
104
|
+
})
|
|
105
|
+
const monthLabel = (date: Date) =>
|
|
106
|
+
props.formatMonth
|
|
107
|
+
? props.formatMonth(date)
|
|
108
|
+
: new Intl.DateTimeFormat(undefined, MONTH_FORMAT).format(date)
|
|
109
|
+
return (
|
|
110
|
+
<div class="flex flex-col gap-2">
|
|
111
|
+
<div class="flex items-center justify-between gap-2">
|
|
112
|
+
<Calendar.Nav
|
|
113
|
+
action="prev-month"
|
|
114
|
+
as={Button}
|
|
115
|
+
variant="ghost"
|
|
116
|
+
size="icon-sm"
|
|
117
|
+
aria-label={props.previousLabel}
|
|
118
|
+
>
|
|
119
|
+
<ChevronLeft aria-hidden="true" />
|
|
120
|
+
</Calendar.Nav>
|
|
121
|
+
<Calendar.Label index={index()} class="text-sm font-semibold text-foreground">
|
|
122
|
+
{monthLabel(month.month)}
|
|
123
|
+
</Calendar.Label>
|
|
124
|
+
<Calendar.Nav
|
|
125
|
+
action="next-month"
|
|
126
|
+
as={Button}
|
|
127
|
+
variant="ghost"
|
|
128
|
+
size="icon-sm"
|
|
129
|
+
aria-label={props.nextLabel}
|
|
130
|
+
>
|
|
131
|
+
<ChevronRight aria-hidden="true" />
|
|
132
|
+
</Calendar.Nav>
|
|
133
|
+
</div>
|
|
134
|
+
<Calendar.Table class="w-full border-collapse">
|
|
135
|
+
<thead>
|
|
136
|
+
<tr>
|
|
137
|
+
<For each={weekdays()}>
|
|
138
|
+
{(label) => (
|
|
139
|
+
<Calendar.HeadCell
|
|
140
|
+
as="th"
|
|
141
|
+
scope="col"
|
|
142
|
+
class="pb-1 text-2xs font-medium text-muted-foreground"
|
|
143
|
+
>
|
|
144
|
+
{label}
|
|
145
|
+
</Calendar.HeadCell>
|
|
146
|
+
)}
|
|
147
|
+
</For>
|
|
148
|
+
</tr>
|
|
149
|
+
</thead>
|
|
150
|
+
<tbody>
|
|
151
|
+
<For each={month.weeks}>
|
|
152
|
+
{(week) => (
|
|
153
|
+
<tr>
|
|
154
|
+
<For each={week}>
|
|
155
|
+
{(day) => (
|
|
156
|
+
<Calendar.Cell as="td" class="p-0.5 text-center">
|
|
157
|
+
<Calendar.CellTrigger
|
|
158
|
+
as="button"
|
|
159
|
+
day={day}
|
|
160
|
+
month={month.month}
|
|
161
|
+
class={cn(
|
|
162
|
+
'w-full rounded-md text-xs text-foreground transition-colors',
|
|
163
|
+
'min-h-control-xs',
|
|
164
|
+
'hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none',
|
|
165
|
+
// Styled from data states, so a day can be a range
|
|
166
|
+
// end and today at once without a prop per pair.
|
|
167
|
+
'data-selected:bg-primary data-selected:text-primary-foreground',
|
|
168
|
+
// corvu marks every day of a range selected, so the
|
|
169
|
+
// span between the ends steps back to the subtle
|
|
170
|
+
// fill and the ends take the solid one again.
|
|
171
|
+
'data-in-range:bg-primary-subtle data-in-range:text-foreground',
|
|
172
|
+
'data-range-start:bg-primary data-range-start:text-primary-foreground',
|
|
173
|
+
'data-range-end:bg-primary data-range-end:text-primary-foreground',
|
|
174
|
+
'data-range-start:rounded-r-none data-range-end:rounded-l-none',
|
|
175
|
+
'data-today:ring-1 data-today:ring-ring',
|
|
176
|
+
'data-disabled:text-muted-foreground data-disabled:line-through',
|
|
177
|
+
'data-disabled:hover:bg-transparent'
|
|
178
|
+
)}
|
|
179
|
+
>
|
|
180
|
+
{/*
|
|
187
181
|
The trigger renders no children of its own, so the
|
|
188
182
|
day number is the caller's — without it every cell
|
|
189
183
|
is an unnamed button (`button-name`).
|
|
@@ -194,19 +188,20 @@ function CalendarGrid(props: {
|
|
|
194
188
|
is hidden from the accessibility tree and the date
|
|
195
189
|
supplies the name.
|
|
196
190
|
*/}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
191
|
+
<span aria-hidden="true">{day.getDate()}</span>
|
|
192
|
+
<span class="visually-hidden">{dayFormatter.format(day)}</span>
|
|
193
|
+
</Calendar.CellTrigger>
|
|
194
|
+
</Calendar.Cell>
|
|
195
|
+
)}
|
|
196
|
+
</For>
|
|
197
|
+
</tr>
|
|
198
|
+
)}
|
|
199
|
+
</For>
|
|
200
|
+
</tbody>
|
|
201
|
+
</Calendar.Table>
|
|
202
|
+
</div>
|
|
203
|
+
)
|
|
204
|
+
}}
|
|
210
205
|
</For>
|
|
211
206
|
)
|
|
212
207
|
}
|
package/dist/r/theming.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/ui",
|
|
3
|
-
"version": "0.151.
|
|
3
|
+
"version": "0.151.7",
|
|
4
4
|
"description": "The Adea design system: Kobalte-backed Solid components, semantic OKLCH tokens, and the app-shell layout primitives shared by Adea and Cortana.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adea",
|
|
@@ -91,6 +91,12 @@
|
|
|
91
91
|
"development": "./src/components/theme/lazy.ts",
|
|
92
92
|
"import": "./dist/components/theme/lazy.js"
|
|
93
93
|
},
|
|
94
|
+
"./components/ui/kbd/platform-modifier": {
|
|
95
|
+
"types": "./dist/components/ui/kbd/platform-modifier.d.ts",
|
|
96
|
+
"solid": "./src/components/ui/kbd/platform-modifier.ts",
|
|
97
|
+
"development": "./src/components/ui/kbd/platform-modifier.ts",
|
|
98
|
+
"import": "./dist/components/ui/kbd/platform-modifier.js"
|
|
99
|
+
},
|
|
94
100
|
"./components/layout/split-layout/model": {
|
|
95
101
|
"types": "./dist/components/layout/split-layout/model.d.ts",
|
|
96
102
|
"solid": "./src/components/layout/split-layout/model.ts",
|
|
@@ -120,7 +126,7 @@
|
|
|
120
126
|
"build": "bun run cn:build && vite build && tsc -p tsconfig.json --emitDeclarationOnly",
|
|
121
127
|
"dev": "bun run cn:build && vite build --watch",
|
|
122
128
|
"lint": "oxlint",
|
|
123
|
-
"test": "bun run cn:check && bun test --conditions=browser --preload ./src/testing/solid-transform.ts tests src",
|
|
129
|
+
"test": "bun run cn:check && bun test --timeout=${ADEA_TEST_TIMEOUT_MS:-5000} --conditions=browser --preload ./src/testing/solid-transform.ts tests src",
|
|
124
130
|
"typecheck": "bun check -p tsconfig.check.json",
|
|
125
131
|
"cn:build": "bun scripts/build-cn-tables.ts",
|
|
126
132
|
"cn:check": "bun scripts/check-cn-tables.ts",
|
|
@@ -150,7 +156,7 @@
|
|
|
150
156
|
"check:packed-paste-model": "node scripts/check-packed-paste-model.mjs"
|
|
151
157
|
},
|
|
152
158
|
"dependencies": {
|
|
153
|
-
"@adea-ai/themes": "^0.11.
|
|
159
|
+
"@adea-ai/themes": "^0.11.7",
|
|
154
160
|
"@corvu/calendar": "^0.1.2",
|
|
155
161
|
"@corvu/drawer": "^0.2.4",
|
|
156
162
|
"@corvu/otp-field": "^0.1.4",
|
package/registry.json
CHANGED
|
@@ -2298,7 +2298,7 @@
|
|
|
2298
2298
|
"title": "Appearance Editor",
|
|
2299
2299
|
"description": "",
|
|
2300
2300
|
"dependencies": [
|
|
2301
|
-
"@adea-ai/themes@^0.11.
|
|
2301
|
+
"@adea-ai/themes@^0.11.7",
|
|
2302
2302
|
"@kobalte/core@^0.13.14",
|
|
2303
2303
|
"lucide-solid@^1.65.0"
|
|
2304
2304
|
],
|
|
@@ -3458,7 +3458,7 @@
|
|
|
3458
3458
|
"title": "Theming",
|
|
3459
3459
|
"description": "",
|
|
3460
3460
|
"dependencies": [
|
|
3461
|
-
"@adea-ai/themes@^0.11.
|
|
3461
|
+
"@adea-ai/themes@^0.11.7",
|
|
3462
3462
|
"@kobalte/core@^0.13.14",
|
|
3463
3463
|
"lucide-solid@^1.65.0"
|
|
3464
3464
|
],
|
|
@@ -3643,7 +3643,7 @@
|
|
|
3643
3643
|
"title": "Class-name and token helpers",
|
|
3644
3644
|
"description": "The private helpers the components import: the class-name merge, the variant recipes, the token manifest and the theme bridge. Installed automatically as a peer of any component that needs it.",
|
|
3645
3645
|
"dependencies": [
|
|
3646
|
-
"@adea-ai/themes@^0.11.
|
|
3646
|
+
"@adea-ai/themes@^0.11.7",
|
|
3647
3647
|
"class-variance-authority@^0.7.1",
|
|
3648
3648
|
"cn@^0.5.1"
|
|
3649
3649
|
],
|
|
@@ -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,
|