@dxos/react-ui-chat 0.8.4-main.5acf9ea → 0.8.4-main.5ea62a8
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/lib/browser/index.mjs +71 -31
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +71 -31
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.stories.d.ts +35 -4
- 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 +20 -4
- package/dist/types/src/components/ChatEditor/ChatEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/autocomplete.d.ts +2 -1
- package/dist/types/src/components/ChatEditor/autocomplete.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -34
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -27
- package/src/components/ChatDialog/ChatDialog.stories.tsx +7 -6
- package/src/components/ChatDialog/ChatDialog.tsx +2 -2
- package/src/components/ChatEditor/ChatEditor.stories.tsx +6 -5
- package/src/components/ChatEditor/ChatEditor.tsx +9 -8
- package/src/components/ChatEditor/autocomplete.ts +8 -6
- package/src/components/ChatEditor/references.ts +1 -1
- package/src/index.ts +1 -0
- package/src/translations.ts +1 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-chat",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.5ea62a8",
|
|
4
4
|
"description": "Chat components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"source": "./src/index.ts",
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
|
-
"source": "./src/index.ts"
|
|
15
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -33,41 +33,41 @@
|
|
|
33
33
|
"@preact/signals-core": "^1.9.0",
|
|
34
34
|
"@radix-ui/react-accordion": "1.2.3",
|
|
35
35
|
"@radix-ui/react-context": "1.1.1",
|
|
36
|
-
"@dxos/async": "0.8.4-main.
|
|
37
|
-
"@dxos/debug": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/live-object": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
36
|
+
"@dxos/async": "0.8.4-main.5ea62a8",
|
|
37
|
+
"@dxos/debug": "0.8.4-main.5ea62a8",
|
|
38
|
+
"@dxos/invariant": "0.8.4-main.5ea62a8",
|
|
39
|
+
"@dxos/log": "0.8.4-main.5ea62a8",
|
|
40
|
+
"@dxos/live-object": "0.8.4-main.5ea62a8",
|
|
41
|
+
"@dxos/react-ui-components": "0.8.4-main.5ea62a8",
|
|
42
|
+
"@dxos/react-ui-dnd": "0.8.4-main.5ea62a8",
|
|
43
|
+
"@dxos/echo-schema": "0.8.4-main.5ea62a8",
|
|
44
|
+
"@dxos/react-ui-sfx": "0.8.4-main.5ea62a8",
|
|
45
|
+
"@dxos/react-ui-editor": "0.8.4-main.5ea62a8",
|
|
46
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.5ea62a8",
|
|
47
|
+
"@dxos/react-ui-text-tooltip": "0.8.4-main.5ea62a8",
|
|
48
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8",
|
|
49
|
+
"@dxos/react-ui-types": "0.8.4-main.5ea62a8",
|
|
50
|
+
"@dxos/util": "0.8.4-main.5ea62a8",
|
|
51
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "~18.2.0",
|
|
55
55
|
"@types/react-dom": "~18.2.0",
|
|
56
|
-
"effect": "3.17.
|
|
56
|
+
"effect": "3.17.7",
|
|
57
57
|
"react": "~18.2.0",
|
|
58
58
|
"react-dom": "~18.2.0",
|
|
59
|
-
"vite": "
|
|
60
|
-
"@dxos/echo": "0.8.4-main.
|
|
61
|
-
"@dxos/random": "0.8.4-main.
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
59
|
+
"vite": "7.1.1",
|
|
60
|
+
"@dxos/echo": "0.8.4-main.5ea62a8",
|
|
61
|
+
"@dxos/random": "0.8.4-main.5ea62a8",
|
|
62
|
+
"@dxos/storybook-utils": "0.8.4-main.5ea62a8",
|
|
63
|
+
"@dxos/react-client": "0.8.4-main.5ea62a8"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"effect": "^3.13.3",
|
|
67
67
|
"react": "~18.2.0",
|
|
68
68
|
"react-dom": "~18.2.0",
|
|
69
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
70
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
69
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
|
70
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { Input, Toolbar } from '@dxos/react-ui';
|
|
11
|
-
import {
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
|
-
import { ChatDialog } from './ChatDialog';
|
|
14
13
|
import { translations } from '../../translations';
|
|
15
14
|
|
|
15
|
+
import { ChatDialog } from './ChatDialog';
|
|
16
|
+
|
|
16
17
|
const items = Array.from({ length: 100 }, (_, i) => `Item ${i}`);
|
|
17
18
|
|
|
18
|
-
const meta
|
|
19
|
+
const meta = {
|
|
19
20
|
title: 'ui/react-ui-chat/ChatDialog',
|
|
20
21
|
component: ChatDialog.Root,
|
|
21
22
|
render: (args) => {
|
|
@@ -56,10 +57,10 @@ const meta: Meta<typeof ChatDialog.Root> = {
|
|
|
56
57
|
parameters: {
|
|
57
58
|
translations,
|
|
58
59
|
},
|
|
59
|
-
}
|
|
60
|
+
} satisfies Meta<typeof ChatDialog.Root>;
|
|
60
61
|
|
|
61
62
|
export default meta;
|
|
62
63
|
|
|
63
|
-
type Story = StoryObj<typeof
|
|
64
|
+
type Story = StoryObj<typeof meta>;
|
|
64
65
|
|
|
65
66
|
export const Default: Story = {};
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { createContext } from '@radix-ui/react-context';
|
|
6
6
|
import React, { type Dispatch, type PropsWithChildren, type SetStateAction, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { Dialog, Icon, IconButton,
|
|
9
|
-
import {
|
|
8
|
+
import { Dialog, Icon, IconButton, type ThemedClassName, useControlledState } from '@dxos/react-ui';
|
|
9
|
+
import { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';
|
|
10
10
|
import { mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
12
|
const preventDefault = (event: Event) => event.preventDefault();
|
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { withTheme } from '@dxos/storybook-utils';
|
|
11
11
|
|
|
12
|
+
import { translations } from '../../translations';
|
|
13
|
+
|
|
12
14
|
import { ChatEditor } from './ChatEditor';
|
|
13
15
|
import { type ReferenceData } from './references';
|
|
14
|
-
import { translations } from '../../translations';
|
|
15
16
|
|
|
16
|
-
const meta
|
|
17
|
+
const meta = {
|
|
17
18
|
title: 'ui/react-ui-chat/ChatEditor',
|
|
18
19
|
component: ChatEditor,
|
|
19
20
|
decorators: [withTheme],
|
|
@@ -21,13 +22,13 @@ const meta: Meta<typeof ChatEditor> = {
|
|
|
21
22
|
layout: 'centered',
|
|
22
23
|
translations,
|
|
23
24
|
},
|
|
24
|
-
}
|
|
25
|
+
} satisfies Meta<typeof ChatEditor>;
|
|
25
26
|
|
|
26
27
|
export default meta;
|
|
27
28
|
|
|
28
29
|
const classNames = 'w-[20rem] p-2 border border-separator';
|
|
29
30
|
|
|
30
|
-
type Story = StoryObj<typeof
|
|
31
|
+
type Story = StoryObj<typeof meta>;
|
|
31
32
|
|
|
32
33
|
export const Default: Story = {
|
|
33
34
|
args: {
|
|
@@ -16,13 +16,12 @@ import {
|
|
|
16
16
|
import { mx } from '@dxos/react-ui-theme';
|
|
17
17
|
import { isNonNullable } from '@dxos/util';
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
import { references as referencesExtension
|
|
21
|
-
|
|
22
|
-
// TODO(burdon): Handle object references.
|
|
19
|
+
import { type AutocompleteOptions, autocomplete } from './autocomplete';
|
|
20
|
+
import { type ReferencesOptions, references as referencesExtension } from './references';
|
|
23
21
|
|
|
24
22
|
export interface ChatEditorController {
|
|
25
23
|
focus(): void;
|
|
24
|
+
getText(): string;
|
|
26
25
|
setText(text: string): void;
|
|
27
26
|
}
|
|
28
27
|
|
|
@@ -31,7 +30,7 @@ export type ChatEditorProps = ThemedClassName<
|
|
|
31
30
|
extensions?: Extension;
|
|
32
31
|
references?: ReferencesOptions;
|
|
33
32
|
} & AutocompleteOptions &
|
|
34
|
-
Pick<UseTextEditorProps, 'autoFocus'> &
|
|
33
|
+
Pick<UseTextEditorProps, 'id' | 'autoFocus'> &
|
|
35
34
|
Pick<BasicExtensionsOptions, 'lineWrapping' | 'placeholder'>
|
|
36
35
|
>;
|
|
37
36
|
|
|
@@ -41,8 +40,9 @@ export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
|
|
|
41
40
|
forwardRef,
|
|
42
41
|
) => {
|
|
43
42
|
const { themeMode } = useThemeContext();
|
|
43
|
+
|
|
44
44
|
const { parentRef, view } = useTextEditor(
|
|
45
|
-
{
|
|
45
|
+
() => ({
|
|
46
46
|
debug: true,
|
|
47
47
|
autoFocus,
|
|
48
48
|
extensions: [
|
|
@@ -56,8 +56,8 @@ export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
|
|
|
56
56
|
}),
|
|
57
57
|
extensions,
|
|
58
58
|
].filter(isNonNullable),
|
|
59
|
-
},
|
|
60
|
-
[themeMode, extensions, onSubmit, onSuggest],
|
|
59
|
+
}),
|
|
60
|
+
[themeMode, extensions, onSubmit, onSuggest, onCancel],
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
// Expose editor view.
|
|
@@ -66,6 +66,7 @@ export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
|
|
|
66
66
|
focus: () => {
|
|
67
67
|
view?.focus();
|
|
68
68
|
},
|
|
69
|
+
getText: () => view?.state.doc.toString() ?? '',
|
|
69
70
|
setText: (text: string) => {
|
|
70
71
|
view?.dispatch({
|
|
71
72
|
changes: {
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Extension, Prec } from '@codemirror/state';
|
|
6
6
|
import {
|
|
7
|
-
EditorView,
|
|
8
7
|
Decoration,
|
|
9
|
-
ViewPlugin,
|
|
10
|
-
keymap,
|
|
11
8
|
type DecorationSet,
|
|
9
|
+
EditorView,
|
|
10
|
+
ViewPlugin,
|
|
12
11
|
type ViewUpdate,
|
|
13
12
|
WidgetType,
|
|
13
|
+
keymap,
|
|
14
14
|
} from '@codemirror/view';
|
|
15
15
|
|
|
16
16
|
export type AutocompleteOptions = {
|
|
17
|
+
fireIfEmpty?: boolean;
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* Callback triggered when Enter is pressed.
|
|
19
21
|
* @param text The current text in the editor
|
|
@@ -39,7 +41,7 @@ export type AutocompleteOptions = {
|
|
|
39
41
|
* Pressing Tab will complete the suggestion.
|
|
40
42
|
*/
|
|
41
43
|
// TODO(burdon): Move to react-ui-editor.
|
|
42
|
-
export const autocomplete = ({ onSubmit, onSuggest, onCancel }: AutocompleteOptions): Extension => {
|
|
44
|
+
export const autocomplete = ({ fireIfEmpty, onSubmit, onSuggest, onCancel }: AutocompleteOptions): Extension => {
|
|
43
45
|
const suggest = ViewPlugin.fromClass(
|
|
44
46
|
class {
|
|
45
47
|
_decorations: DecorationSet;
|
|
@@ -144,7 +146,7 @@ export const autocomplete = ({ onSubmit, onSuggest, onCancel }: AutocompleteOpti
|
|
|
144
146
|
preventDefault: true,
|
|
145
147
|
run: (view) => {
|
|
146
148
|
const text = view.state.doc.toString().trim();
|
|
147
|
-
if (text.length > 0
|
|
149
|
+
if (onSubmit && (fireIfEmpty || text.length > 0)) {
|
|
148
150
|
const reset = onSubmit(text);
|
|
149
151
|
|
|
150
152
|
// Clear the document after calling onEnter.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { autocompletion, completionKeymap
|
|
5
|
+
import { type CompletionResult, autocompletion, completionKeymap } from '@codemirror/autocomplete';
|
|
6
6
|
import { type Extension, RangeSet } from '@codemirror/state';
|
|
7
7
|
import {
|
|
8
8
|
Decoration,
|
package/src/index.ts
CHANGED
package/src/translations.ts
CHANGED
|
@@ -9,46 +9,7 @@ export const translationKey = 'react-ui-chat';
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
|
-
[translationKey]: {
|
|
13
|
-
'templates label': 'Templates',
|
|
14
|
-
'open ambient chat label': 'Open Assistant',
|
|
15
|
-
'assistant chat label': 'Assistant',
|
|
16
|
-
'plugin name': 'Assistant',
|
|
17
|
-
'object placeholder': 'New prompt',
|
|
18
|
-
'create object label': 'Create prompt',
|
|
19
|
-
'create trigger label': 'Create trigger',
|
|
20
|
-
'create stack section label': 'Create prompt',
|
|
21
|
-
'command placeholder': 'Enter slash command...',
|
|
22
|
-
'template placeholder': 'Enter template...',
|
|
23
|
-
'value placeholder': 'Enter value...',
|
|
24
|
-
'prompt rules label': 'Prompt Rules',
|
|
25
|
-
'typename placeholder': 'Enter typename of objects which this template is for',
|
|
26
|
-
'description placeholder': 'Enter description of when this template should be used',
|
|
27
|
-
'select preset template placeholder': 'Select preset',
|
|
28
|
-
'service registry label': 'Service Registry',
|
|
29
|
-
|
|
30
|
-
'sequence logs label': 'Logs',
|
|
31
|
-
|
|
32
|
-
'assistant dialog title': 'Assistant',
|
|
33
|
-
'open assistant label': 'Open assistant',
|
|
34
|
-
|
|
35
|
-
'search input placeholder': 'Search...',
|
|
36
|
-
'chat input placeholder': 'Ask a question...',
|
|
37
|
-
'chat stop': 'Cancel request.',
|
|
38
|
-
|
|
39
|
-
'button save': 'Save',
|
|
40
|
-
'button run': 'Run',
|
|
41
|
-
|
|
42
|
-
'prompt placeholder': 'Ask a question...',
|
|
43
|
-
'microphone button': 'Click to speak',
|
|
44
|
-
'cancel processing button': 'Stop processing',
|
|
45
|
-
|
|
46
|
-
'settings default label': 'Default',
|
|
47
|
-
'settings custom prompts label': 'Use custom prompts',
|
|
48
|
-
'settings llm provider label': 'LLM provider',
|
|
49
|
-
'settings edge llm model label': 'Remote language model',
|
|
50
|
-
'settings ollama llm model label': 'Ollama language model',
|
|
51
|
-
},
|
|
12
|
+
[translationKey]: {},
|
|
52
13
|
},
|
|
53
14
|
},
|
|
54
15
|
] as const satisfies Resource[];
|