@adea-ai/ui 0.120.0 → 0.121.0
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/components/conversation/composer-menu.d.ts +31 -0
- package/dist/components/conversation/composer-menu.d.ts.map +1 -0
- package/dist/components/conversation/composer-menu.js +63 -0
- package/dist/components/conversation/composer-menu.js.map +1 -0
- package/dist/components/conversation/conversation-pane.d.ts +38 -0
- package/dist/components/conversation/conversation-pane.d.ts.map +1 -0
- package/dist/components/conversation/conversation-pane.js +83 -0
- package/dist/components/conversation/conversation-pane.js.map +1 -0
- package/dist/components/conversation/conversation-surface.d.ts +6 -0
- package/dist/components/conversation/conversation-surface.d.ts.map +1 -1
- package/dist/components/conversation/conversation-surface.js +10 -4
- package/dist/components/conversation/conversation-surface.js.map +1 -1
- package/dist/components/conversation/index.d.ts +2 -0
- package/dist/components/conversation/index.d.ts.map +1 -1
- package/dist/components/conversation/index.js +3 -1
- package/dist/components/conversation/message-composer.d.ts +6 -0
- package/dist/components/conversation/message-composer.d.ts.map +1 -1
- package/dist/components/conversation/message-composer.js +10 -1
- package/dist/components/conversation/message-composer.js.map +1 -1
- package/dist/components/ui/kbd/index.d.ts +1 -0
- package/dist/components/ui/kbd/index.d.ts.map +1 -1
- package/dist/components/ui/kbd/index.js +2 -1
- package/dist/components/ui/kbd/platform-modifier.d.ts +28 -0
- package/dist/components/ui/kbd/platform-modifier.d.ts.map +1 -0
- package/dist/components/ui/kbd/platform-modifier.js +37 -0
- package/dist/components/ui/kbd/platform-modifier.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/r/conversation.json +10 -0
- package/dist/r/kbd.json +5 -0
- package/dist/r/registry.json +15 -0
- package/dist/r/src/components/conversation/composer-menu.tsx +67 -0
- package/dist/r/src/components/conversation/conversation-pane.tsx +111 -0
- package/dist/r/src/components/conversation/conversation-surface.tsx +12 -1
- package/dist/r/src/components/conversation/index.ts +7 -0
- package/dist/r/src/components/conversation/message-composer.tsx +8 -0
- package/dist/r/src/components/ui/kbd/index.ts +5 -0
- package/dist/r/src/components/ui/kbd/platform-modifier.ts +37 -0
- package/package.json +1 -1
- package/registry.json +15 -0
- package/src/components/conversation/composer-menu.tsx +67 -0
- package/src/components/conversation/conversation-pane.tsx +111 -0
- package/src/components/conversation/conversation-surface.tsx +12 -1
- package/src/components/conversation/index.ts +7 -0
- package/src/components/conversation/message-composer.tsx +8 -0
- package/src/components/ui/kbd/index.ts +5 -0
- package/src/components/ui/kbd/platform-modifier.ts +37 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { ComponentProps, JSX } from 'solid-js'
|
|
2
|
+
import { Show, splitProps } from 'solid-js'
|
|
3
|
+
import { cn } from '#lib/utils'
|
|
4
|
+
|
|
5
|
+
export type ConversationPaneProps = ComponentProps<'section'> & {
|
|
6
|
+
/** Above the transcript: the conversation's identity and its actions. */
|
|
7
|
+
header?: JSX.Element
|
|
8
|
+
/** The transcript — typically a `ConversationSurface` with `gutter`. */
|
|
9
|
+
children: JSX.Element
|
|
10
|
+
/** Below the transcript: the composer. */
|
|
11
|
+
composer?: JSX.Element
|
|
12
|
+
/**
|
|
13
|
+
* The thread side panel. Its presence opens the second column; at narrow
|
|
14
|
+
* widths the panel overlays the conversation instead of squeezing it, and
|
|
15
|
+
* the conversation chrome steps aside — out of the accessibility tree with
|
|
16
|
+
* it, which is why the overlay hides with `visibility` rather than paint.
|
|
17
|
+
*/
|
|
18
|
+
thread?: JSX.Element
|
|
19
|
+
/**
|
|
20
|
+
* Apply the shared page gutters to the composer, tracking the transcript's
|
|
21
|
+
* own gutter (`ConversationSurface`'s `gutter`) so the two read as one pane.
|
|
22
|
+
*/
|
|
23
|
+
gutter?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* ConversationPane.
|
|
28
|
+
*
|
|
29
|
+
* The frame a conversation lives in: a header above, the transcript, a composer
|
|
30
|
+
* below, and — while a thread is open — the thread panel beside all of it.
|
|
31
|
+
*
|
|
32
|
+
* The layout earns its place in the library because the thread is where
|
|
33
|
+
* applications get it wrong. Two impulses both fail: shrinking the transcript
|
|
34
|
+
* to make room turns a busy thread into a one-word-per-line stripe, and
|
|
35
|
+
* *hiding* the transcript with `display: none` unmounts it, losing scroll
|
|
36
|
+
* position and DOM. So the desktop layout gives the thread a fixed column and
|
|
37
|
+
* leaves the transcript fluid; below the collapse width the panel overlays the
|
|
38
|
+
* conversation in full and the conversation steps aside invisibly — still
|
|
39
|
+
* mounted, still in the DOM, gone from the accessibility tree.
|
|
40
|
+
*/
|
|
41
|
+
export function ConversationPane(props: ConversationPaneProps) {
|
|
42
|
+
const [local, rest] = splitProps(props, [
|
|
43
|
+
'class',
|
|
44
|
+
'header',
|
|
45
|
+
'composer',
|
|
46
|
+
'thread',
|
|
47
|
+
'gutter',
|
|
48
|
+
'children',
|
|
49
|
+
])
|
|
50
|
+
const threadOpen = () => local.thread !== undefined
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<section
|
|
54
|
+
data-slot="conversation-pane"
|
|
55
|
+
data-conversation-thread-open={threadOpen() || undefined}
|
|
56
|
+
class={cn(
|
|
57
|
+
'relative grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)_auto]',
|
|
58
|
+
threadOpen()
|
|
59
|
+
? 'grid-cols-1 md:grid-cols-[minmax(20rem,1fr)_minmax(18rem,22rem)] lg:grid-cols-[minmax(24rem,1fr)_minmax(20rem,26rem)]'
|
|
60
|
+
: 'grid-cols-1',
|
|
61
|
+
local.class
|
|
62
|
+
)}
|
|
63
|
+
{...rest}
|
|
64
|
+
>
|
|
65
|
+
<Show when={local.header}>
|
|
66
|
+
{(header) => (
|
|
67
|
+
<div class={cn('col-start-1 row-start-1 min-w-0', threadOpen() && 'max-md:invisible')}>
|
|
68
|
+
{header()}
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
</Show>
|
|
72
|
+
|
|
73
|
+
<div
|
|
74
|
+
class={cn(
|
|
75
|
+
'col-start-1 row-start-2 flex min-h-0 min-w-0 flex-col',
|
|
76
|
+
threadOpen() && 'max-md:invisible'
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
{local.children}
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<Show when={local.composer}>
|
|
83
|
+
{(composer) => (
|
|
84
|
+
<div
|
|
85
|
+
class={cn(
|
|
86
|
+
'col-start-1 row-start-3 min-w-0',
|
|
87
|
+
local.gutter && 'mx-[clamp(0.8rem,3vw,2.5rem)] mb-[1.15rem] max-[30rem]:mx-2',
|
|
88
|
+
threadOpen() && 'max-md:invisible'
|
|
89
|
+
)}
|
|
90
|
+
>
|
|
91
|
+
{composer()}
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</Show>
|
|
95
|
+
|
|
96
|
+
<Show when={local.thread}>
|
|
97
|
+
{(thread) => (
|
|
98
|
+
<div
|
|
99
|
+
class={cn(
|
|
100
|
+
'min-h-0 min-w-0',
|
|
101
|
+
threadOpen() &&
|
|
102
|
+
'max-md:absolute max-md:inset-0 max-md:z-(--z-docked) max-md:*:border-s-0 md:col-start-2 md:row-span-3 md:row-start-1'
|
|
103
|
+
)}
|
|
104
|
+
>
|
|
105
|
+
{thread()}
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
</Show>
|
|
109
|
+
</section>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -38,6 +38,12 @@ export type ConversationSurfaceProps = ComponentProps<'div'> & {
|
|
|
38
38
|
empty?: JSX.Element
|
|
39
39
|
/** A header that scrolls with the transcript, e.g. a day divider or a banner. */
|
|
40
40
|
header?: JSX.Element
|
|
41
|
+
/**
|
|
42
|
+
* The shared page gutter: reading padding inside the scroller plus a stable
|
|
43
|
+
* gutter, so the scrollbar never shifts the text when it appears. The page
|
|
44
|
+
* frame around the surface is `ConversationPane`'s job.
|
|
45
|
+
*/
|
|
46
|
+
gutter?: boolean
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
export function ConversationSurface(props: ConversationSurfaceProps) {
|
|
@@ -50,6 +56,7 @@ export function ConversationSurface(props: ConversationSurfaceProps) {
|
|
|
50
56
|
'onReadingPositionChange',
|
|
51
57
|
'empty',
|
|
52
58
|
'header',
|
|
59
|
+
'gutter',
|
|
53
60
|
'children',
|
|
54
61
|
'onScroll',
|
|
55
62
|
'ref',
|
|
@@ -84,7 +91,11 @@ export function ConversationSurface(props: ConversationSurfaceProps) {
|
|
|
84
91
|
}}
|
|
85
92
|
onScroll={onScroll}
|
|
86
93
|
tabindex={local.tabindex ?? 0}
|
|
87
|
-
class=
|
|
94
|
+
class={cn(
|
|
95
|
+
'min-h-0 flex-1 overflow-y-auto overscroll-contain',
|
|
96
|
+
local.gutter &&
|
|
97
|
+
'px-[clamp(0.8rem,3vw,2.5rem)] pt-[1.35rem] pb-[1.1rem] [scrollbar-gutter:stable] max-[30rem]:px-2'
|
|
98
|
+
)}
|
|
88
99
|
{...rest}
|
|
89
100
|
>
|
|
90
101
|
<div ref={follow.bindContent} data-slot="conversation-content">
|
|
@@ -10,6 +10,13 @@ export {
|
|
|
10
10
|
type ConversationSurfaceProps,
|
|
11
11
|
type ConversationReadingPosition,
|
|
12
12
|
} from './conversation-surface'
|
|
13
|
+
export { ConversationPane, type ConversationPaneProps } from './conversation-pane'
|
|
14
|
+
export {
|
|
15
|
+
ComposerMenu,
|
|
16
|
+
ComposerMenuItem,
|
|
17
|
+
type ComposerMenuProps,
|
|
18
|
+
type ComposerMenuItemProps,
|
|
19
|
+
} from './composer-menu'
|
|
13
20
|
export {
|
|
14
21
|
ComposerAttachmentButton,
|
|
15
22
|
ComposerHint,
|
|
@@ -71,6 +71,12 @@ export type MessageComposerProps = Omit<ComponentProps<'form'>, 'onSubmit'> & {
|
|
|
71
71
|
trailing?: JSX.Element
|
|
72
72
|
/** A menu rendered above the field, e.g. mention suggestions. */
|
|
73
73
|
menu?: JSX.Element
|
|
74
|
+
/**
|
|
75
|
+
* Host progress rendered in the composer's own live region, e.g. dictation
|
|
76
|
+
* state — plain paragraphs are progress, a `role="alert"` paragraph is a
|
|
77
|
+
* failure. Sending and send-failure copy stays the composer's own.
|
|
78
|
+
*/
|
|
79
|
+
status?: JSX.Element
|
|
74
80
|
/** The reply target, drawn as a strip above the field. */
|
|
75
81
|
replyTo?: { label: string; onDismiss: () => void }
|
|
76
82
|
/** Ref to the actual message textarea, for host focus and selection behavior. */
|
|
@@ -102,6 +108,7 @@ export function MessageComposer(props: MessageComposerProps) {
|
|
|
102
108
|
'leading',
|
|
103
109
|
'trailing',
|
|
104
110
|
'menu',
|
|
111
|
+
'status',
|
|
105
112
|
'replyTo',
|
|
106
113
|
'inputRef',
|
|
107
114
|
'inputId',
|
|
@@ -281,6 +288,7 @@ export function MessageComposer(props: MessageComposerProps) {
|
|
|
281
288
|
>
|
|
282
289
|
{pendingLabel()}…
|
|
283
290
|
</Show>
|
|
291
|
+
<Show when={local.status}>{local.status}</Show>
|
|
284
292
|
</div>
|
|
285
293
|
</form>
|
|
286
294
|
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which modifier a chord should advertise.
|
|
3
|
+
*
|
|
4
|
+
* Every global chord in the product binds `(metaKey || ctrlKey)`, so the
|
|
5
|
+
* working key is the platform's command modifier wherever the app runs — but
|
|
6
|
+
* Apple platforms draw it as ⌘ and everyone else spells it Ctrl. A chord
|
|
7
|
+
* label drawn from anything else (a hardcoded ⌘, say) advertises a key that
|
|
8
|
+
* does not work as drawn on Windows and Linux.
|
|
9
|
+
*
|
|
10
|
+
* These helpers are the one place that decides the glyph, so every surface
|
|
11
|
+
* that draws or announces a shortcut — rail rows, menus, a pane's search
|
|
12
|
+
* field — draws the same one. They sit next to the `Kbd` caps because the
|
|
13
|
+
* glyph is a property of the drawing, not of the feature that shows it: a
|
|
14
|
+
* spelled-out `Ctrl` needs one cap per word (a `KbdGroup`), while `⌘K` can
|
|
15
|
+
* ride `KbdChord`'s one-cap-per-character split.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** The modifier glyph the running OS renders for Meta: ⌘ on Apple platforms, Ctrl elsewhere. */
|
|
19
|
+
export function platformModifierKey(platform?: string): '⌘' | 'Ctrl' {
|
|
20
|
+
// The guard keeps server renders honest: no navigator means no Apple
|
|
21
|
+
// platform string, so they fall back to the spelled-out modifier.
|
|
22
|
+
const browserPlatform = platform ?? (typeof navigator === 'undefined' ? '' : navigator.platform)
|
|
23
|
+
return /Mac|iPhone|iPad|iPod/i.test(browserPlatform) ? '⌘' : 'Ctrl'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The workspace search chord label as the rail's hover text draws it: the
|
|
27
|
+
* platform modifier plus K (`⌘K`, or `Ctrl+K` where ⌘ does not exist). */
|
|
28
|
+
export function searchShortcutLabel(platform?: string): string {
|
|
29
|
+
return platformModifierKey(platform) === '⌘' ? '⌘K' : 'Ctrl+K'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The `aria-keyshortcuts` for the search chord. The binding accepts Meta and
|
|
34
|
+
* Ctrl alike, so the announced shortcuts name both: a hardcoded `Meta+K`
|
|
35
|
+
* would promise a key the row does not keep on non-Apple platforms.
|
|
36
|
+
*/
|
|
37
|
+
export const searchShortcutKeyshortcuts = 'Meta+K Control+K'
|