@dxos/react-ui-chat 0.8.4-main.b97322e → 0.8.4-main.f5c0578
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 +12 -8
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +12 -8
- package/dist/lib/node-esm/index.mjs.map +3 -3
- 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 +1 -1
- package/dist/types/src/components/ChatDialog/ChatDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/ChatEditor.d.ts +1 -0
- package/dist/types/src/components/ChatEditor/ChatEditor.d.ts.map +1 -1
- package/dist/types/src/components/ChatEditor/ChatEditor.stories.d.ts +1 -1
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -24
- package/src/components/ChatDialog/ChatDialog.stories.tsx +4 -3
- package/src/components/ChatDialog/ChatDialog.tsx +2 -2
- package/src/components/ChatEditor/ChatEditor.stories.tsx +3 -2
- package/src/components/ChatEditor/ChatEditor.tsx +4 -2
- package/src/components/ChatEditor/autocomplete.ts +8 -6
- package/src/components/ChatEditor/references.ts +1 -1
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.f5c0578",
|
|
4
4
|
"description": "Chat components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,6 +9,7 @@
|
|
|
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
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -32,41 +33,41 @@
|
|
|
32
33
|
"@preact/signals-core": "^1.9.0",
|
|
33
34
|
"@radix-ui/react-accordion": "1.2.3",
|
|
34
35
|
"@radix-ui/react-context": "1.1.1",
|
|
35
|
-
"@dxos/async": "0.8.4-main.
|
|
36
|
-
"@dxos/debug": "0.8.4-main.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/react-ui
|
|
42
|
-
"@dxos/react-ui-
|
|
43
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
49
|
-
"@dxos/react-ui-types": "0.8.4-main.
|
|
50
|
-
"@dxos/util": "0.8.4-main.
|
|
36
|
+
"@dxos/async": "0.8.4-main.f5c0578",
|
|
37
|
+
"@dxos/debug": "0.8.4-main.f5c0578",
|
|
38
|
+
"@dxos/echo-schema": "0.8.4-main.f5c0578",
|
|
39
|
+
"@dxos/log": "0.8.4-main.f5c0578",
|
|
40
|
+
"@dxos/live-object": "0.8.4-main.f5c0578",
|
|
41
|
+
"@dxos/react-ui-components": "0.8.4-main.f5c0578",
|
|
42
|
+
"@dxos/react-ui": "0.8.4-main.f5c0578",
|
|
43
|
+
"@dxos/react-ui-dnd": "0.8.4-main.f5c0578",
|
|
44
|
+
"@dxos/react-ui-editor": "0.8.4-main.f5c0578",
|
|
45
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.f5c0578",
|
|
46
|
+
"@dxos/react-ui-sfx": "0.8.4-main.f5c0578",
|
|
47
|
+
"@dxos/react-ui-text-tooltip": "0.8.4-main.f5c0578",
|
|
48
|
+
"@dxos/invariant": "0.8.4-main.f5c0578",
|
|
49
|
+
"@dxos/react-ui-theme": "0.8.4-main.f5c0578",
|
|
50
|
+
"@dxos/react-ui-types": "0.8.4-main.f5c0578",
|
|
51
|
+
"@dxos/util": "0.8.4-main.f5c0578"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@types/react": "~18.2.0",
|
|
54
55
|
"@types/react-dom": "~18.2.0",
|
|
55
|
-
"effect": "3.17.
|
|
56
|
+
"effect": "3.17.7",
|
|
56
57
|
"react": "~18.2.0",
|
|
57
58
|
"react-dom": "~18.2.0",
|
|
58
59
|
"vite": "5.4.7",
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/react-client": "0.8.4-main.
|
|
60
|
+
"@dxos/echo": "0.8.4-main.f5c0578",
|
|
61
|
+
"@dxos/storybook-utils": "0.8.4-main.f5c0578",
|
|
62
|
+
"@dxos/random": "0.8.4-main.f5c0578",
|
|
63
|
+
"@dxos/react-client": "0.8.4-main.f5c0578"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"effect": "^3.13.3",
|
|
66
67
|
"react": "~18.2.0",
|
|
67
68
|
"react-dom": "~18.2.0",
|
|
68
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
69
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
69
|
+
"@dxos/react-ui": "0.8.4-main.f5c0578",
|
|
70
|
+
"@dxos/react-ui-theme": "0.8.4-main.f5c0578"
|
|
70
71
|
},
|
|
71
72
|
"publishConfig": {
|
|
72
73
|
"access": "public"
|
|
@@ -4,15 +4,16 @@
|
|
|
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
19
|
const meta: Meta<typeof ChatDialog.Root> = {
|
|
@@ -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,14 +4,15 @@
|
|
|
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
17
|
const meta: Meta<typeof ChatEditor> = {
|
|
17
18
|
title: 'ui/react-ui-chat/ChatEditor',
|
|
@@ -16,13 +16,14 @@ 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
|
|
19
|
+
import { type AutocompleteOptions, autocomplete } from './autocomplete';
|
|
20
|
+
import { type ReferencesOptions, references as referencesExtension } from './references';
|
|
21
21
|
|
|
22
22
|
// TODO(burdon): Handle object references.
|
|
23
23
|
|
|
24
24
|
export interface ChatEditorController {
|
|
25
25
|
focus(): void;
|
|
26
|
+
getText(): string;
|
|
26
27
|
setText(text: string): void;
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -66,6 +67,7 @@ export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
|
|
|
66
67
|
focus: () => {
|
|
67
68
|
view?.focus();
|
|
68
69
|
},
|
|
70
|
+
getText: () => view?.state.doc.toString() ?? '',
|
|
69
71
|
setText: (text: string) => {
|
|
70
72
|
view?.dispatch({
|
|
71
73
|
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,
|