@adea-ai/ui 0.151.2 → 0.151.8
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/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/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/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/package.json +8 -2
- 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/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
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
evaluateAutoPin,
|
|
24
24
|
isScrollUpIntent,
|
|
25
25
|
isSelfScroll,
|
|
26
|
+
isViewportGrowthClamp,
|
|
26
27
|
resolveUserScrollStick,
|
|
27
28
|
SELF_SCROLL_EPSILON,
|
|
28
29
|
type ReaderInput,
|
|
@@ -52,6 +53,7 @@ export function createScrollFollow(options: {
|
|
|
52
53
|
let stick = true
|
|
53
54
|
let lastWriteTop = -1
|
|
54
55
|
let lastWriteClientHeight = -1
|
|
56
|
+
let readerMovedSinceWrite = false
|
|
55
57
|
let previousTop = -1
|
|
56
58
|
let lastScrollClientHeight = 0
|
|
57
59
|
let pendingRestore: { frame: number; fromTop: number; target: number } | undefined
|
|
@@ -88,13 +90,29 @@ export function createScrollFollow(options: {
|
|
|
88
90
|
}
|
|
89
91
|
onCleanup(reportPosition)
|
|
90
92
|
|
|
93
|
+
const rememberPosition = (element: HTMLDivElement) => {
|
|
94
|
+
lastWriteTop = element.scrollTop
|
|
95
|
+
lastWriteClientHeight = element.clientHeight
|
|
96
|
+
previousTop = element.scrollTop
|
|
97
|
+
readerMovedSinceWrite = false
|
|
98
|
+
}
|
|
91
99
|
const writePin = (element: HTMLDivElement, target: number) => {
|
|
92
100
|
// Instant writes keep the self-scroll reference synchronized. A smooth
|
|
93
101
|
// animation would produce intermediate positions that resemble user input.
|
|
94
102
|
element.scrollTop = target
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
rememberPosition(element)
|
|
104
|
+
}
|
|
105
|
+
const acceptViewportClamp = (element: HTMLDivElement) => {
|
|
106
|
+
if (
|
|
107
|
+
stick &&
|
|
108
|
+
isViewportGrowthClamp({
|
|
109
|
+
geom: geometry(element),
|
|
110
|
+
lastWriteTop,
|
|
111
|
+
lastWriteClientHeight,
|
|
112
|
+
readerMovedSinceWrite,
|
|
113
|
+
})
|
|
114
|
+
)
|
|
115
|
+
rememberPosition(element)
|
|
98
116
|
}
|
|
99
117
|
const pinHeld = (element: HTMLDivElement) => {
|
|
100
118
|
const geom = geometry(element)
|
|
@@ -102,11 +120,7 @@ export function createScrollFollow(options: {
|
|
|
102
120
|
if (distanceFromBottom(geom) > atBottomEpsilon()) writePin(element, bottomTarget(geom))
|
|
103
121
|
// An end the engine already clamped to is accepted as it stands, and is the reference
|
|
104
122
|
// from here on: the write before it is further down than the content now reaches.
|
|
105
|
-
else
|
|
106
|
-
lastWriteTop = element.scrollTop
|
|
107
|
-
lastWriteClientHeight = element.clientHeight
|
|
108
|
-
previousTop = element.scrollTop
|
|
109
|
-
}
|
|
123
|
+
else rememberPosition(element)
|
|
110
124
|
holdTop = element.scrollTop
|
|
111
125
|
setAtBottom(computeAtBottom(geometry(element), options.threshold()))
|
|
112
126
|
reportPosition()
|
|
@@ -114,6 +128,7 @@ export function createScrollFollow(options: {
|
|
|
114
128
|
const pinAuto = () => {
|
|
115
129
|
if (!scroller || !options.enabled() || pendingRestore) return
|
|
116
130
|
if (holdsPosition(scroller)) return pinHeld(scroller)
|
|
131
|
+
acceptViewportClamp(scroller)
|
|
117
132
|
const geom = geometry(scroller)
|
|
118
133
|
const result = evaluateAutoPin({
|
|
119
134
|
stick,
|
|
@@ -123,10 +138,7 @@ export function createScrollFollow(options: {
|
|
|
123
138
|
})
|
|
124
139
|
stick = result.stick
|
|
125
140
|
if (result.pin) writePin(scroller, result.target)
|
|
126
|
-
else if (result.stick)
|
|
127
|
-
lastWriteTop = result.target
|
|
128
|
-
lastWriteClientHeight = geom.clientHeight
|
|
129
|
-
}
|
|
141
|
+
else if (result.stick) rememberPosition(scroller)
|
|
130
142
|
setAtBottom(computeAtBottom(geometry(scroller), options.threshold()))
|
|
131
143
|
reportPosition()
|
|
132
144
|
}
|
|
@@ -157,6 +169,7 @@ export function createScrollFollow(options: {
|
|
|
157
169
|
return
|
|
158
170
|
}
|
|
159
171
|
if (holdsPosition(scroller)) return pinHeld(scroller)
|
|
172
|
+
acceptViewportClamp(scroller)
|
|
160
173
|
const geom = geometry(scroller)
|
|
161
174
|
setAtBottom(computeAtBottom(geom, options.threshold()))
|
|
162
175
|
if (!isSelfScroll(geom.scrollTop, lastWriteTop)) {
|
|
@@ -173,6 +186,9 @@ export function createScrollFollow(options: {
|
|
|
173
186
|
lastWriteClientHeight = -1
|
|
174
187
|
}
|
|
175
188
|
}
|
|
189
|
+
// A content-collapse clamp can arrive before ResizeObserver. Keep its new
|
|
190
|
+
// bottom as our reference if viewport growth and more output follow next.
|
|
191
|
+
if (stick && distanceFromBottom(geom) <= atBottomEpsilon()) rememberPosition(scroller)
|
|
176
192
|
previousTop = geom.scrollTop
|
|
177
193
|
// This baseline belongs only to scroll events, not observer callbacks.
|
|
178
194
|
// Advancing it during resize would erase the viewport-clamp evidence.
|
|
@@ -219,15 +235,20 @@ export function createScrollFollow(options: {
|
|
|
219
235
|
}
|
|
220
236
|
}
|
|
221
237
|
const noteHoldInput = (event: Event) => {
|
|
222
|
-
if (holds === 0 || holdIntent) return
|
|
223
238
|
let input: ReaderInput | undefined
|
|
224
239
|
if (event instanceof WheelEvent) input = { kind: 'wheel', deltaY: event.deltaY }
|
|
225
|
-
else if (event instanceof KeyboardEvent)
|
|
240
|
+
else if (event instanceof KeyboardEvent) {
|
|
241
|
+
// Descendant controls own their keys; only the focused transcript can
|
|
242
|
+
// signal native keyboard scrolling, just as for snapshot restoration.
|
|
243
|
+
if (event.target !== scroller) return
|
|
226
244
|
input = { kind: 'key', key: event.key, shiftKey: event.shiftKey }
|
|
227
|
-
else if (event.type === 'touchmove') input = { kind: 'touchmove' }
|
|
245
|
+
} else if (event.type === 'touchmove') input = { kind: 'touchmove' }
|
|
228
246
|
else if (event.type === 'pointerdown')
|
|
229
247
|
input = { kind: 'pointerdown', onScroller: event.target === scroller }
|
|
230
|
-
if (input && isScrollUpIntent(input))
|
|
248
|
+
if (input && isScrollUpIntent(input)) {
|
|
249
|
+
readerMovedSinceWrite = true
|
|
250
|
+
if (holds > 0) holdIntent = true
|
|
251
|
+
}
|
|
231
252
|
}
|
|
232
253
|
|
|
233
254
|
createEffect(() => {
|
|
@@ -239,6 +260,7 @@ export function createScrollFollow(options: {
|
|
|
239
260
|
candidate && Number.isFinite(candidate.top) && candidate.top >= 0 ? candidate : undefined
|
|
240
261
|
let scheduledRestore: typeof pendingRestore
|
|
241
262
|
let observer: ResizeObserver | undefined
|
|
263
|
+
let contentObserver: MutationObserver | undefined
|
|
242
264
|
onCleanup(() => {
|
|
243
265
|
if (scheduledRestore) {
|
|
244
266
|
cancelAnimationFrame(scheduledRestore.frame)
|
|
@@ -248,6 +270,7 @@ export function createScrollFollow(options: {
|
|
|
248
270
|
removeRestoreIntentListeners()
|
|
249
271
|
removeRestoreIntentListeners = noop
|
|
250
272
|
observer?.disconnect()
|
|
273
|
+
contentObserver?.disconnect()
|
|
251
274
|
})
|
|
252
275
|
stick = true
|
|
253
276
|
holdGeneration += 1
|
|
@@ -256,6 +279,7 @@ export function createScrollFollow(options: {
|
|
|
256
279
|
holdIntent = false
|
|
257
280
|
lastWriteTop = -1
|
|
258
281
|
lastWriteClientHeight = -1
|
|
282
|
+
readerMovedSinceWrite = false
|
|
259
283
|
previousTop = -1
|
|
260
284
|
lastScrollClientHeight = 0
|
|
261
285
|
setAtBottom(true)
|
|
@@ -270,7 +294,35 @@ export function createScrollFollow(options: {
|
|
|
270
294
|
if (!enabled || typeof ResizeObserver === 'undefined') return
|
|
271
295
|
observer = new ResizeObserver(pinAuto)
|
|
272
296
|
observer.observe(scroller!)
|
|
273
|
-
if (content)
|
|
297
|
+
if (content) {
|
|
298
|
+
observer.observe(content)
|
|
299
|
+
if (typeof MutationObserver !== 'undefined') {
|
|
300
|
+
contentObserver = new MutationObserver(() => {
|
|
301
|
+
// A collapsed turn can clamp the offset before any scroll/resize
|
|
302
|
+
// callback. Remember that bottom at the mutation boundary, before
|
|
303
|
+
// a later task grows the viewport or streams more content. This is
|
|
304
|
+
// bookkeeping only: never pin, re-arm, or compete with another owner.
|
|
305
|
+
if (
|
|
306
|
+
!scroller ||
|
|
307
|
+
!options.enabled() ||
|
|
308
|
+
pendingRestore ||
|
|
309
|
+
holds > 0 ||
|
|
310
|
+
!stick ||
|
|
311
|
+
readerMovedSinceWrite ||
|
|
312
|
+
lastWriteTop < 0
|
|
313
|
+
)
|
|
314
|
+
return
|
|
315
|
+
// Read the offset once per mutation batch. This can flush pending
|
|
316
|
+
// layout, but deferring it loses a collapse clamp before a later task
|
|
317
|
+
// grows the viewport/output. Ordinary growth needs no other geometry.
|
|
318
|
+
const top = scroller.scrollTop
|
|
319
|
+
if (top >= lastWriteTop - SELF_SCROLL_EPSILON) return
|
|
320
|
+
if (scroller.scrollHeight - top - scroller.clientHeight <= atBottomEpsilon())
|
|
321
|
+
rememberPosition(scroller)
|
|
322
|
+
})
|
|
323
|
+
contentObserver.observe(content, { childList: true, characterData: true, subtree: true })
|
|
324
|
+
}
|
|
325
|
+
}
|
|
274
326
|
}
|
|
275
327
|
|
|
276
328
|
const watchRestoreIntent = () => {
|
|
@@ -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/src/index.ts
CHANGED
|
@@ -95,6 +95,7 @@ export * from './components/layout/virtual-window'
|
|
|
95
95
|
export * from './components/layout/app-shell'
|
|
96
96
|
export * from './components/layout/page'
|
|
97
97
|
export * from './components/layout/panel'
|
|
98
|
+
export * from './components/layout/pixel-pane'
|
|
98
99
|
export * from './components/layout/side-rail'
|
|
99
100
|
export * from './components/layout/sidebar-nav'
|
|
100
101
|
export * from './components/layout/contextual-sidebar'
|