@dxos/react-ui-chat 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-chat",
3
- "version": "0.8.4-main.f9ba587",
3
+ "version": "0.8.4-main.fd6878d",
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.f9ba587",
36
- "@dxos/debug": "0.8.4-main.f9ba587",
37
- "@dxos/echo-schema": "0.8.4-main.f9ba587",
38
- "@dxos/invariant": "0.8.4-main.f9ba587",
39
- "@dxos/live-object": "0.8.4-main.f9ba587",
40
- "@dxos/log": "0.8.4-main.f9ba587",
41
- "@dxos/react-ui": "0.8.4-main.f9ba587",
42
- "@dxos/react-ui-components": "0.8.4-main.f9ba587",
43
- "@dxos/react-ui-editor": "0.8.4-main.f9ba587",
44
- "@dxos/react-ui-dnd": "0.8.4-main.f9ba587",
45
- "@dxos/react-ui-sfx": "0.8.4-main.f9ba587",
46
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.f9ba587",
47
- "@dxos/react-ui-text-tooltip": "0.8.4-main.f9ba587",
48
- "@dxos/react-ui-theme": "0.8.4-main.f9ba587",
49
- "@dxos/react-ui-types": "0.8.4-main.f9ba587",
50
- "@dxos/util": "0.8.4-main.f9ba587"
36
+ "@dxos/async": "0.8.4-main.fd6878d",
37
+ "@dxos/debug": "0.8.4-main.fd6878d",
38
+ "@dxos/echo-schema": "0.8.4-main.fd6878d",
39
+ "@dxos/live-object": "0.8.4-main.fd6878d",
40
+ "@dxos/log": "0.8.4-main.fd6878d",
41
+ "@dxos/invariant": "0.8.4-main.fd6878d",
42
+ "@dxos/react-ui": "0.8.4-main.fd6878d",
43
+ "@dxos/react-ui-components": "0.8.4-main.fd6878d",
44
+ "@dxos/react-ui-dnd": "0.8.4-main.fd6878d",
45
+ "@dxos/react-ui-editor": "0.8.4-main.fd6878d",
46
+ "@dxos/react-ui-sfx": "0.8.4-main.fd6878d",
47
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.fd6878d",
48
+ "@dxos/react-ui-theme": "0.8.4-main.fd6878d",
49
+ "@dxos/react-ui-text-tooltip": "0.8.4-main.fd6878d",
50
+ "@dxos/react-ui-types": "0.8.4-main.fd6878d",
51
+ "@dxos/util": "0.8.4-main.fd6878d"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@types/react": "~18.2.0",
54
55
  "@types/react-dom": "~18.2.0",
55
- "effect": "3.14.21",
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/echo": "0.8.4-main.f9ba587",
60
- "@dxos/random": "0.8.4-main.f9ba587",
61
- "@dxos/react-client": "0.8.4-main.f9ba587",
62
- "@dxos/storybook-utils": "0.8.4-main.f9ba587"
60
+ "@dxos/echo": "0.8.4-main.fd6878d",
61
+ "@dxos/random": "0.8.4-main.fd6878d",
62
+ "@dxos/react-client": "0.8.4-main.fd6878d",
63
+ "@dxos/storybook-utils": "0.8.4-main.fd6878d"
63
64
  },
64
65
  "peerDependencies": {
65
- "effect": "3.13.3",
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.f9ba587",
69
- "@dxos/react-ui-theme": "0.8.4-main.f9ba587"
69
+ "@dxos/react-ui": "0.8.4-main.fd6878d",
70
+ "@dxos/react-ui-theme": "0.8.4-main.fd6878d"
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 StoryObj, type Meta } from '@storybook/react-vite';
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 { withTheme, withLayout } from '@dxos/storybook-utils';
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, useControlledState, type ThemedClassName } from '@dxos/react-ui';
9
- import { resizeAttributes, ResizeHandle, type Size, sizeStyle } from '@dxos/react-ui-dnd';
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 StoryObj, type Meta } from '@storybook/react-vite';
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 { autocomplete, type AutocompleteOptions } from './autocomplete';
20
- import { references as referencesExtension, type ReferencesOptions } from './references';
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
 
@@ -61,30 +62,27 @@ export const ChatEditor = forwardRef<ChatEditorController, ChatEditorProps>(
61
62
  );
62
63
 
63
64
  // Expose editor view.
64
- useImperativeHandle(
65
- forwardRef,
66
- () => {
67
- return {
68
- focus: () => {
69
- view?.focus();
70
- },
71
- setText: (text: string) => {
72
- view?.dispatch({
73
- changes: {
74
- from: 0,
75
- to: view.state.doc.length,
76
- insert: text,
77
- },
78
- selection: {
79
- anchor: text.length,
80
- head: text.length,
81
- },
82
- });
83
- },
84
- };
85
- },
86
- [view, onSubmit],
87
- );
65
+ useImperativeHandle(forwardRef, () => {
66
+ return {
67
+ focus: () => {
68
+ view?.focus();
69
+ },
70
+ getText: () => view?.state.doc.toString() ?? '',
71
+ setText: (text: string) => {
72
+ view?.dispatch({
73
+ changes: {
74
+ from: 0,
75
+ to: view.state.doc.length,
76
+ insert: text,
77
+ },
78
+ selection: {
79
+ anchor: text.length,
80
+ head: text.length,
81
+ },
82
+ });
83
+ },
84
+ };
85
+ }, [view, onSubmit]);
88
86
 
89
87
  return <div ref={parentRef} className={mx('is-full', classNames)} />;
90
88
  },
@@ -2,18 +2,20 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Prec, type Extension } from '@codemirror/state';
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 && onSubmit) {
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, type CompletionResult } from '@codemirror/autocomplete';
5
+ import { type CompletionResult, autocompletion, completionKeymap } from '@codemirror/autocomplete';
6
6
  import { type Extension, RangeSet } from '@codemirror/state';
7
7
  import {
8
8
  Decoration,