@dxos/react-ui-chat 0.8.4-main.fffef41 → 0.9.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/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +185 -142
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +14 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +185 -142
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +16 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/ChatDialog/ChatDialog.d.ts +17 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.stories.d.ts +2 -2
- package/dist/types/src/components/ChatDialog/ChatDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/ChatEditor.d.ts +3 -2
- package/dist/types/src/components/ChatEditor/ChatEditor.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/ChatEditor.stories.d.ts +3 -3
- package/dist/types/src/components/ChatEditor/ChatEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/references.d.ts.map +1 -1
- package/dist/types/src/components/ChatStatus/ChatStatus.d.ts +40 -0
- package/dist/types/src/components/ChatStatus/ChatStatus.d.ts.map +1 -0
- package/dist/types/src/components/ChatStatus/ChatStatus.stories.d.ts +27 -0
- package/dist/types/src/components/ChatStatus/ChatStatus.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatStatus/format.d.ts +7 -0
- package/dist/types/src/components/ChatStatus/format.d.ts.map +1 -0
- package/dist/types/src/components/ChatStatus/format.test.d.ts +2 -0
- package/dist/types/src/components/ChatStatus/format.test.d.ts.map +1 -0
- package/dist/types/src/components/ChatStatus/index.d.ts +3 -0
- package/dist/types/src/components/ChatStatus/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -44
- package/src/components/ChatDialog/ChatDialog.stories.tsx +4 -4
- package/src/components/ChatDialog/ChatDialog.tsx +29 -19
- package/src/components/ChatEditor/ChatEditor.stories.tsx +8 -8
- package/src/components/ChatEditor/ChatEditor.tsx +7 -7
- package/src/components/ChatEditor/references.ts +1 -1
- package/src/components/ChatStatus/ChatStatus.stories.tsx +130 -0
- package/src/components/ChatStatus/ChatStatus.tsx +183 -0
- package/src/components/ChatStatus/format.test.ts +48 -0
- package/src/components/ChatStatus/format.ts +27 -0
- package/src/components/ChatStatus/index.ts +6 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +0 -1
- package/src/translations.ts +1 -1
package/package.json
CHANGED
|
@@ -1,74 +1,81 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Chat components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"type": "module",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#translations": "./src/translations.ts"
|
|
16
|
+
},
|
|
10
17
|
"exports": {
|
|
11
18
|
".": {
|
|
12
19
|
"source": "./src/index.ts",
|
|
13
20
|
"types": "./dist/types/src/index.d.ts",
|
|
14
21
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
22
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./translations": {
|
|
25
|
+
"source": "./src/translations.ts",
|
|
26
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
27
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
28
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
16
29
|
}
|
|
17
30
|
},
|
|
18
31
|
"types": "dist/types/src/index.d.ts",
|
|
19
|
-
"typesVersions": {
|
|
20
|
-
"*": {}
|
|
21
|
-
},
|
|
22
32
|
"files": [
|
|
23
33
|
"dist",
|
|
24
34
|
"src"
|
|
25
35
|
],
|
|
26
36
|
"dependencies": {
|
|
27
|
-
"@codemirror/autocomplete": "^6.
|
|
28
|
-
"@codemirror/language": "^6.
|
|
29
|
-
"@codemirror/search": "^6.
|
|
30
|
-
"@codemirror/state": "^6.
|
|
31
|
-
"@codemirror/view": "^6.
|
|
32
|
-
"@fluentui/react-tabster": "
|
|
33
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
34
|
-
"@preact/signals-core": "^1.12.1",
|
|
37
|
+
"@codemirror/autocomplete": "^6.20.2",
|
|
38
|
+
"@codemirror/language": "^6.12.3",
|
|
39
|
+
"@codemirror/search": "^6.7.0",
|
|
40
|
+
"@codemirror/state": "^6.6.0",
|
|
41
|
+
"@codemirror/view": "^6.43.0",
|
|
42
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
35
43
|
"@radix-ui/react-accordion": "1.2.3",
|
|
36
44
|
"@radix-ui/react-context": "1.1.1",
|
|
37
|
-
"@dxos/echo": "0.
|
|
38
|
-
"@dxos/async": "0.
|
|
39
|
-
"@dxos/invariant": "0.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/react-ui-types": "0.8.4-main.fffef41"
|
|
45
|
+
"@dxos/echo": "0.9.0",
|
|
46
|
+
"@dxos/async": "0.9.0",
|
|
47
|
+
"@dxos/invariant": "0.9.0",
|
|
48
|
+
"@dxos/react-ui": "0.9.0",
|
|
49
|
+
"@dxos/debug": "0.9.0",
|
|
50
|
+
"@dxos/react-ui-components": "0.9.0",
|
|
51
|
+
"@dxos/log": "0.9.0",
|
|
52
|
+
"@dxos/react-ui-editor": "0.9.0",
|
|
53
|
+
"@dxos/react-ui-syntax-highlighter": "0.9.0",
|
|
54
|
+
"@dxos/react-ui-dnd": "0.9.0",
|
|
55
|
+
"@dxos/react-ui-text-tooltip": "0.9.0",
|
|
56
|
+
"@dxos/util": "0.9.0",
|
|
57
|
+
"@dxos/ui-types": "0.9.0",
|
|
58
|
+
"@dxos/ui-editor": "0.9.0",
|
|
59
|
+
"@dxos/ui-theme": "0.9.0"
|
|
53
60
|
},
|
|
54
61
|
"devDependencies": {
|
|
55
|
-
"@types/react": "~19.2.
|
|
56
|
-
"@types/react-dom": "~19.2.
|
|
57
|
-
"effect": "3.
|
|
58
|
-
"react": "~19.2.
|
|
59
|
-
"react-dom": "~19.2.
|
|
60
|
-
"vite": "
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
62
|
+
"@types/react": "~19.2.7",
|
|
63
|
+
"@types/react-dom": "~19.2.3",
|
|
64
|
+
"effect": "3.21.3",
|
|
65
|
+
"react": "~19.2.3",
|
|
66
|
+
"react-dom": "~19.2.3",
|
|
67
|
+
"vite": "^8.0.16",
|
|
68
|
+
"@dxos/random": "0.9.0",
|
|
69
|
+
"@dxos/echo": "0.9.0",
|
|
70
|
+
"@dxos/react-client": "0.9.0",
|
|
71
|
+
"@dxos/storybook-utils": "0.9.0"
|
|
65
72
|
},
|
|
66
73
|
"peerDependencies": {
|
|
67
|
-
"effect": "
|
|
68
|
-
"react": "
|
|
69
|
-
"react-dom": "
|
|
70
|
-
"@dxos/react-ui": "0.
|
|
71
|
-
"@dxos/
|
|
74
|
+
"effect": "3.21.3",
|
|
75
|
+
"react": "~19.2.3",
|
|
76
|
+
"react-dom": "~19.2.3",
|
|
77
|
+
"@dxos/react-ui": "0.9.0",
|
|
78
|
+
"@dxos/ui-theme": "0.9.0"
|
|
72
79
|
},
|
|
73
80
|
"publishConfig": {
|
|
74
81
|
"access": "public"
|
|
@@ -8,7 +8,7 @@ import React, { useState } from 'react';
|
|
|
8
8
|
import { Input, Toolbar } from '@dxos/react-ui';
|
|
9
9
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
10
|
|
|
11
|
-
import { translations } from '
|
|
11
|
+
import { translations } from '#translations';
|
|
12
12
|
|
|
13
13
|
import { ChatDialog } from './ChatDialog';
|
|
14
14
|
|
|
@@ -37,12 +37,12 @@ const meta = {
|
|
|
37
37
|
<ChatDialog.Header title='Chat' />
|
|
38
38
|
<ChatDialog.Content>
|
|
39
39
|
{items.map((item) => (
|
|
40
|
-
<div key={item} className='
|
|
40
|
+
<div key={item} className='ps-4 pb-1'>
|
|
41
41
|
{item}
|
|
42
42
|
</div>
|
|
43
43
|
))}
|
|
44
44
|
</ChatDialog.Content>
|
|
45
|
-
<ChatDialog.Footer classNames='
|
|
45
|
+
<ChatDialog.Footer classNames='px-2 items-center'>
|
|
46
46
|
<Input.Root>
|
|
47
47
|
<Input.TextInput classNames='border-none' placeholder='Test' />
|
|
48
48
|
</Input.Root>
|
|
@@ -51,7 +51,7 @@ const meta = {
|
|
|
51
51
|
</>
|
|
52
52
|
);
|
|
53
53
|
},
|
|
54
|
-
decorators: [withTheme, withLayout({
|
|
54
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
55
55
|
parameters: {
|
|
56
56
|
translations,
|
|
57
57
|
},
|
|
@@ -7,14 +7,16 @@ import React, { type Dispatch, type PropsWithChildren, type SetStateAction, useE
|
|
|
7
7
|
|
|
8
8
|
import { Dialog, Icon, IconButton, type ThemedClassName, useControlledState } from '@dxos/react-ui';
|
|
9
9
|
import { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';
|
|
10
|
-
import { mx } from '@dxos/
|
|
10
|
+
import { mx } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
12
|
const preventDefault = (event: Event) => event.preventDefault();
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Factor out.
|
|
15
15
|
const Endcap = ({ children }: PropsWithChildren) => {
|
|
16
16
|
return (
|
|
17
|
-
<div className='grid
|
|
17
|
+
<div className='grid w-[var(--dx-rail-action)] h-[var(--dx-rail-action)] items-center justify-center'>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
18
20
|
);
|
|
19
21
|
};
|
|
20
22
|
|
|
@@ -47,15 +49,15 @@ type ChatDialogRootProps = PropsWithChildren<{
|
|
|
47
49
|
|
|
48
50
|
const ChatDialogRoot = ({
|
|
49
51
|
children,
|
|
50
|
-
open:
|
|
51
|
-
expanded:
|
|
52
|
+
open: openProp = false,
|
|
53
|
+
expanded: expandedProp = false,
|
|
52
54
|
onOpenChange,
|
|
53
55
|
onExpandedChange,
|
|
54
56
|
onEscape,
|
|
55
57
|
}: ChatDialogRootProps) => {
|
|
56
58
|
const [size, setSize] = useState<Size>('min-content');
|
|
57
|
-
const [open, setOpen] = useControlledState<boolean>(
|
|
58
|
-
const [expanded, setExpanded] = useControlledState<boolean>(
|
|
59
|
+
const [open, setOpen] = useControlledState<boolean>(openProp, onOpenChange);
|
|
60
|
+
const [expanded, setExpanded] = useControlledState<boolean>(expandedProp, onExpandedChange);
|
|
59
61
|
|
|
60
62
|
// NOTE: We set the min size to 5rem (80px), and the header and prompt bar to 40px (i.e., the rail-size) each.
|
|
61
63
|
// The dialog has no vertical padding and has box-content so that when closed it collapses to the size of the header and prompt bar.
|
|
@@ -69,12 +71,12 @@ const ChatDialogRoot = ({
|
|
|
69
71
|
setSize={setSize}
|
|
70
72
|
>
|
|
71
73
|
<Dialog.Root modal={false} open={open} onOpenChange={setOpen}>
|
|
72
|
-
<div
|
|
74
|
+
<div className='dx-dialog__overlay bg-transparent pointer-events-none' data-block-align='end'>
|
|
73
75
|
<Dialog.Content
|
|
76
|
+
size='md'
|
|
74
77
|
inOverlayLayout
|
|
75
78
|
classNames={[
|
|
76
|
-
'grid grid-rows-[var(--rail-action)_1fr_min-content] p-0 overflow-hidden',
|
|
77
|
-
'box-content md:is-[35rem] md:max-is-none pointer-events-auto',
|
|
79
|
+
'grid grid-rows-[var(--dx-rail-action)_1fr_min-content] p-0 overflow-hidden box-content pointer-events-auto',
|
|
78
80
|
]}
|
|
79
81
|
onEscapeKeyDown={onEscape}
|
|
80
82
|
onInteractOutside={preventDefault}
|
|
@@ -93,22 +95,26 @@ ChatDialogRoot.displayName = 'ChatDialog.Root';
|
|
|
93
95
|
// Header
|
|
94
96
|
//
|
|
95
97
|
|
|
98
|
+
const CHAT_DIALOG_HEADER_NAME = 'ChatDialog.Header';
|
|
99
|
+
|
|
96
100
|
type ChatDialogHeaderProps = ThemedClassName<{
|
|
97
101
|
title?: string;
|
|
98
102
|
}>;
|
|
99
103
|
|
|
100
104
|
const ChatDialogHeader = ({ classNames, title }: ChatDialogHeaderProps) => {
|
|
101
|
-
const { expanded, setExpanded } = useChatDialogContext(
|
|
105
|
+
const { expanded, setExpanded } = useChatDialogContext(CHAT_DIALOG_HEADER_NAME);
|
|
102
106
|
|
|
103
107
|
return (
|
|
104
|
-
<div
|
|
108
|
+
<div
|
|
109
|
+
className={mx('grid grid-cols-[var(--dx-rail-action)_1fr_min-content] items-center overflow-hidden', classNames)}
|
|
110
|
+
>
|
|
105
111
|
<Endcap>
|
|
106
112
|
<Dialog.Close>
|
|
107
113
|
<Icon icon='ph--x--regular' />
|
|
108
114
|
</Dialog.Close>
|
|
109
115
|
</Endcap>
|
|
110
116
|
<Dialog.Title
|
|
111
|
-
classNames='flex
|
|
117
|
+
classNames='flex w-full justify-center text-sm text-subdued select-none cursor-pointer'
|
|
112
118
|
onClick={() => setExpanded((expanded) => !expanded)}
|
|
113
119
|
>
|
|
114
120
|
{title}
|
|
@@ -118,7 +124,7 @@ const ChatDialogHeader = ({ classNames, title }: ChatDialogHeaderProps) => {
|
|
|
118
124
|
variant='ghost'
|
|
119
125
|
icon='ph--caret-up--regular'
|
|
120
126
|
iconOnly
|
|
121
|
-
classNames={mx('
|
|
127
|
+
classNames={mx('p-1! [&>svg]:transition [&>svg]:duration-200', expanded && '[&>svg]:rotate-180')}
|
|
122
128
|
label={expanded ? 'Close' : 'Open'}
|
|
123
129
|
onClick={() => setExpanded((expanded) => !expanded)}
|
|
124
130
|
/>
|
|
@@ -127,16 +133,18 @@ const ChatDialogHeader = ({ classNames, title }: ChatDialogHeaderProps) => {
|
|
|
127
133
|
);
|
|
128
134
|
};
|
|
129
135
|
|
|
130
|
-
ChatDialogHeader.displayName =
|
|
136
|
+
ChatDialogHeader.displayName = CHAT_DIALOG_HEADER_NAME;
|
|
131
137
|
|
|
132
138
|
//
|
|
133
139
|
// Content
|
|
134
140
|
//
|
|
135
141
|
|
|
142
|
+
const CHAT_DIALOG_CONTENT_NAME = 'ChatDialog.Content';
|
|
143
|
+
|
|
136
144
|
type ChatDialogContentProps = ThemedClassName<PropsWithChildren>;
|
|
137
145
|
|
|
138
146
|
const ChatDialogContent = ({ children, classNames }: ChatDialogContentProps) => {
|
|
139
|
-
const { expanded, size, setSize } = useChatDialogContext(
|
|
147
|
+
const { expanded, size, setSize } = useChatDialogContext(CHAT_DIALOG_CONTENT_NAME);
|
|
140
148
|
useEffect(() => {
|
|
141
149
|
setSize(expanded ? 'min-content' : 0);
|
|
142
150
|
}, [expanded]);
|
|
@@ -144,8 +152,8 @@ const ChatDialogContent = ({ children, classNames }: ChatDialogContentProps) =>
|
|
|
144
152
|
return (
|
|
145
153
|
<div
|
|
146
154
|
className={mx(
|
|
147
|
-
'
|
|
148
|
-
'transition
|
|
155
|
+
'border-t border-b border-subdued-separator',
|
|
156
|
+
'transition ease-in-out duration-0 [&:not([data-dx-resizing="true"])]:duration-200',
|
|
149
157
|
classNames,
|
|
150
158
|
)}
|
|
151
159
|
style={{
|
|
@@ -167,19 +175,21 @@ const ChatDialogContent = ({ children, classNames }: ChatDialogContentProps) =>
|
|
|
167
175
|
);
|
|
168
176
|
};
|
|
169
177
|
|
|
170
|
-
ChatDialogContent.displayName =
|
|
178
|
+
ChatDialogContent.displayName = CHAT_DIALOG_CONTENT_NAME;
|
|
171
179
|
|
|
172
180
|
//
|
|
173
181
|
// Footer
|
|
174
182
|
//
|
|
175
183
|
|
|
184
|
+
const CHAT_DIALOG_FOOTER_NAME = 'ChatDialog.Footer';
|
|
185
|
+
|
|
176
186
|
type ChatDialogFooterProps = ThemedClassName<PropsWithChildren>;
|
|
177
187
|
|
|
178
188
|
const ChatDialogFooter = ({ children, classNames }: ChatDialogFooterProps) => {
|
|
179
189
|
return <div className={mx(classNames)}>{children}</div>;
|
|
180
190
|
};
|
|
181
191
|
|
|
182
|
-
ChatDialogFooter.displayName =
|
|
192
|
+
ChatDialogFooter.displayName = CHAT_DIALOG_FOOTER_NAME;
|
|
183
193
|
|
|
184
194
|
//
|
|
185
195
|
// ChatDialog
|
|
@@ -7,7 +7,7 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
9
|
|
|
10
|
-
import { translations } from '
|
|
10
|
+
import { translations } from '#translations';
|
|
11
11
|
|
|
12
12
|
import { ChatEditor } from './ChatEditor';
|
|
13
13
|
import { type ReferenceData } from './references';
|
|
@@ -15,7 +15,7 @@ import { type ReferenceData } from './references';
|
|
|
15
15
|
const meta = {
|
|
16
16
|
title: 'ui/react-ui-chat/ChatEditor',
|
|
17
17
|
component: ChatEditor,
|
|
18
|
-
decorators: [withTheme],
|
|
18
|
+
decorators: [withTheme()],
|
|
19
19
|
parameters: {
|
|
20
20
|
layout: 'centered',
|
|
21
21
|
translations,
|
|
@@ -24,13 +24,14 @@ const meta = {
|
|
|
24
24
|
|
|
25
25
|
export default meta;
|
|
26
26
|
|
|
27
|
-
const classNames = '
|
|
27
|
+
const classNames = 'w-[20rem] p-2 border border-separator';
|
|
28
28
|
|
|
29
29
|
type Story = StoryObj<typeof meta>;
|
|
30
30
|
|
|
31
31
|
export const Default: Story = {
|
|
32
32
|
args: {
|
|
33
33
|
classNames,
|
|
34
|
+
placeholder: 'Ask a question...',
|
|
34
35
|
},
|
|
35
36
|
};
|
|
36
37
|
|
|
@@ -41,12 +42,12 @@ export const WithSuggestions: Story = {
|
|
|
41
42
|
onSubmit: (text) => {
|
|
42
43
|
log('onSubmit', { text });
|
|
43
44
|
},
|
|
45
|
+
|
|
44
46
|
// onSuggest: (text) => {
|
|
45
47
|
// const trimmed = text.trim().toLowerCase();
|
|
46
48
|
// if (trimmed.length < 2) {
|
|
47
49
|
// return [];
|
|
48
50
|
// }
|
|
49
|
-
|
|
50
51
|
// const suggestions = [
|
|
51
52
|
// 'Create a kanban board',
|
|
52
53
|
// 'Create a new project',
|
|
@@ -54,7 +55,6 @@ export const WithSuggestions: Story = {
|
|
|
54
55
|
// "Let's play chess",
|
|
55
56
|
// 'Show me Paris on a map',
|
|
56
57
|
// ];
|
|
57
|
-
|
|
58
58
|
// return suggestions.filter((s) => s.toLowerCase().startsWith(text));
|
|
59
59
|
// },
|
|
60
60
|
},
|
|
@@ -63,15 +63,15 @@ export const WithSuggestions: Story = {
|
|
|
63
63
|
// TODO(burdon): Replace.
|
|
64
64
|
const references: ReferenceData[] = [
|
|
65
65
|
{
|
|
66
|
-
uri: '
|
|
66
|
+
uri: 'echo:/AAAAAAAA',
|
|
67
67
|
label: 'Meeting Notes',
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
-
uri: '
|
|
70
|
+
uri: 'echo:/BBBBBBBB',
|
|
71
71
|
label: 'Project Plan',
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
uri: '
|
|
74
|
+
uri: 'echo:/CCCCCCCC',
|
|
75
75
|
label: 'Meeting Plan',
|
|
76
76
|
},
|
|
77
77
|
];
|
|
@@ -6,16 +6,15 @@ import { type Extension } from '@codemirror/state';
|
|
|
6
6
|
import React, { forwardRef, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
9
|
+
import { Editor, type EditorController, type UseTextEditorProps } from '@dxos/react-ui-editor';
|
|
9
10
|
import {
|
|
10
11
|
type BasicExtensionsOptions,
|
|
11
|
-
Editor,
|
|
12
|
-
type EditorController,
|
|
13
12
|
type SubmitOptions,
|
|
14
|
-
type UseTextEditorProps,
|
|
15
13
|
createBasicExtensions,
|
|
16
14
|
createThemeExtensions,
|
|
17
15
|
submit,
|
|
18
|
-
|
|
16
|
+
xmlFormatting,
|
|
17
|
+
} from '@dxos/ui-editor';
|
|
19
18
|
import { isTruthy } from '@dxos/util';
|
|
20
19
|
|
|
21
20
|
import { type ReferencesOptions } from './references';
|
|
@@ -38,6 +37,7 @@ export const useChatExtensions = ({ extensions, lineWrapping = false, placeholde
|
|
|
38
37
|
[
|
|
39
38
|
createThemeExtensions({ themeMode }),
|
|
40
39
|
createBasicExtensions({ bracketMatching: false, lineWrapping, placeholder }),
|
|
40
|
+
xmlFormatting(),
|
|
41
41
|
submit({ onSubmit }),
|
|
42
42
|
extensions,
|
|
43
43
|
].filter(isTruthy),
|
|
@@ -46,13 +46,13 @@ export const useChatExtensions = ({ extensions, lineWrapping = false, placeholde
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
|
|
49
|
-
({ classNames, autoFocus, extensions:
|
|
50
|
-
const extensions = useChatExtensions({ extensions:
|
|
49
|
+
({ classNames, autoFocus, extensions: extensionsProp, lineWrapping = false, placeholder, onSubmit }, forwardRef) => {
|
|
50
|
+
const extensions = useChatExtensions({ extensions: extensionsProp, lineWrapping, placeholder, onSubmit });
|
|
51
51
|
|
|
52
52
|
// TODO(burdon): Popover.
|
|
53
53
|
return (
|
|
54
54
|
<Editor.Root ref={forwardRef}>
|
|
55
|
-
<Editor.
|
|
55
|
+
<Editor.View classNames={classNames} autoFocus={autoFocus} extensions={extensions} />
|
|
56
56
|
</Editor.Root>
|
|
57
57
|
);
|
|
58
58
|
},
|
|
@@ -130,7 +130,7 @@ export const references = ({ provider, triggerCharacter = '@', debug = false }:
|
|
|
130
130
|
}),
|
|
131
131
|
|
|
132
132
|
autocompletion({
|
|
133
|
-
tooltipClass: () => 'shadow rounded',
|
|
133
|
+
tooltipClass: () => 'shadow rounded-sm',
|
|
134
134
|
activateOnTyping: true,
|
|
135
135
|
aboveCursor: true,
|
|
136
136
|
closeOnBlur: !debug,
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useRef } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Button, Toolbar } from '@dxos/react-ui';
|
|
9
|
+
import { Matrix } from '@dxos/react-ui-components';
|
|
10
|
+
import { withTheme, withLayout } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { ChatStatus, type ChatStatusController, useChatStatusContext } from './ChatStatus';
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'ui/react-ui-chat/ChatStatus',
|
|
16
|
+
component: ChatStatus.Root,
|
|
17
|
+
decorators: [
|
|
18
|
+
withTheme(),
|
|
19
|
+
withLayout({ layout: 'centered', classNames: 'py-1 px-2 border border-separator rounded-sm' }),
|
|
20
|
+
],
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: 'centered',
|
|
23
|
+
},
|
|
24
|
+
} satisfies Meta<typeof ChatStatus.Root>;
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
type Story = StoryObj<typeof meta>;
|
|
29
|
+
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
render: () => (
|
|
32
|
+
<ChatStatus.Root>
|
|
33
|
+
<ChatStatus.Icon />
|
|
34
|
+
<ChatStatus.Stopwatch />
|
|
35
|
+
</ChatStatus.Root>
|
|
36
|
+
),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const WithMeta: Story = {
|
|
40
|
+
render: () => (
|
|
41
|
+
<ChatStatus.Root>
|
|
42
|
+
<ChatStatus.Icon />
|
|
43
|
+
<ChatStatus.Stopwatch />
|
|
44
|
+
<ChatStatus.Separator />
|
|
45
|
+
<ChatStatus.Text>↑ 234</ChatStatus.Text>
|
|
46
|
+
<ChatStatus.Separator />
|
|
47
|
+
<ChatStatus.Text>↓ 1.2k</ChatStatus.Text>
|
|
48
|
+
</ChatStatus.Root>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Reads the running flag from Status context and forwards it to the Matrix as
|
|
54
|
+
* the `active` prop, so the Matrix runs its own internal interval loop only
|
|
55
|
+
* while the Status tick is running. Pausing the Status freezes the dots.
|
|
56
|
+
*/
|
|
57
|
+
const MatrixIcon = () => {
|
|
58
|
+
const { running } = useChatStatusContext('MatrixIcon');
|
|
59
|
+
return (
|
|
60
|
+
<Matrix
|
|
61
|
+
classNames='mr-2'
|
|
62
|
+
dim={4}
|
|
63
|
+
dotSize={3}
|
|
64
|
+
// TODO(burdon): Change with activity?
|
|
65
|
+
count={10}
|
|
66
|
+
interval={500}
|
|
67
|
+
active={running}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const WithCustomIcon: Story = {
|
|
73
|
+
render: () => (
|
|
74
|
+
<ChatStatus.Root classNames='text-sm'>
|
|
75
|
+
<ChatStatus.Icon>
|
|
76
|
+
<MatrixIcon />
|
|
77
|
+
</ChatStatus.Icon>
|
|
78
|
+
<ChatStatus.Stopwatch />
|
|
79
|
+
<ChatStatus.Separator />
|
|
80
|
+
<ChatStatus.Text>↑ 234</ChatStatus.Text>
|
|
81
|
+
<ChatStatus.Separator />
|
|
82
|
+
<ChatStatus.Text>↓ 1.2k</ChatStatus.Text>
|
|
83
|
+
</ChatStatus.Root>
|
|
84
|
+
),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const LongRunning: Story = {
|
|
88
|
+
render: () => (
|
|
89
|
+
<ChatStatus.Root>
|
|
90
|
+
<ChatStatus.Icon />
|
|
91
|
+
<ChatStatus.Stopwatch offset={65 * 60} />
|
|
92
|
+
<ChatStatus.Separator />
|
|
93
|
+
<ChatStatus.Text>↑ 4.5k</ChatStatus.Text>
|
|
94
|
+
<ChatStatus.Separator />
|
|
95
|
+
<ChatStatus.Text>↓ 12.3k</ChatStatus.Text>
|
|
96
|
+
</ChatStatus.Root>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const TextOnly: Story = {
|
|
101
|
+
render: () => (
|
|
102
|
+
<ChatStatus.Root>
|
|
103
|
+
<ChatStatus.Icon />
|
|
104
|
+
<ChatStatus.Text>Connecting…</ChatStatus.Text>
|
|
105
|
+
</ChatStatus.Root>
|
|
106
|
+
),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Demonstrates the imperative controller — start/stop the 1Hz tick from the outside.
|
|
111
|
+
*/
|
|
112
|
+
export const Controller: Story = {
|
|
113
|
+
render: () => {
|
|
114
|
+
const ref = useRef<ChatStatusController>(null);
|
|
115
|
+
return (
|
|
116
|
+
<div className='flex flex-col gap-4'>
|
|
117
|
+
<Toolbar.Root>
|
|
118
|
+
<Button onClick={() => ref.current?.start()}>Start</Button>
|
|
119
|
+
<Button onClick={() => ref.current?.stop()}>Stop</Button>
|
|
120
|
+
</Toolbar.Root>
|
|
121
|
+
<ChatStatus.Root ref={ref}>
|
|
122
|
+
<ChatStatus.Icon>
|
|
123
|
+
<MatrixIcon />
|
|
124
|
+
</ChatStatus.Icon>
|
|
125
|
+
<ChatStatus.Stopwatch />
|
|
126
|
+
</ChatStatus.Root>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
};
|