@dxos/react-ui-thread 0.8.4-main.5ea62a8 → 0.8.4-main.66e292d

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-thread",
3
- "version": "0.8.4-main.5ea62a8",
3
+ "version": "0.8.4-main.66e292d",
4
4
  "description": "A set of components to use with threads, including comments and messages.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -27,30 +27,30 @@
27
27
  "@preact-signals/safe-react": "^0.9.0",
28
28
  "@radix-ui/react-primitive": "2.0.2",
29
29
  "date-fns": "^3.3.1",
30
- "@dxos/react-ui-editor": "0.8.4-main.5ea62a8",
31
- "@dxos/util": "0.8.4-main.5ea62a8"
30
+ "@dxos/react-ui-editor": "0.8.4-main.66e292d",
31
+ "@dxos/util": "0.8.4-main.66e292d"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/react": "~18.2.0",
35
- "@types/react-dom": "~18.2.0",
36
- "react": "~18.2.0",
37
- "react-dom": "~18.2.0",
38
- "vite": "7.1.1",
39
- "@dxos/echo-db": "0.8.4-main.5ea62a8",
40
- "@dxos/echo-schema": "0.8.4-main.5ea62a8",
41
- "@dxos/live-object": "0.8.4-main.5ea62a8",
42
- "@dxos/keys": "0.8.4-main.5ea62a8",
43
- "@dxos/log": "0.8.4-main.5ea62a8",
44
- "@dxos/random": "0.8.4-main.5ea62a8",
45
- "@dxos/react-ui-theme": "0.8.4-main.5ea62a8",
46
- "@dxos/react-ui": "0.8.4-main.5ea62a8",
47
- "@dxos/storybook-utils": "0.8.4-main.5ea62a8"
34
+ "@types/react": "~19.2.2",
35
+ "@types/react-dom": "~19.2.2",
36
+ "react": "~19.2.0",
37
+ "react-dom": "~19.2.0",
38
+ "vite": "7.1.9",
39
+ "@dxos/echo": "0.8.4-main.66e292d",
40
+ "@dxos/keys": "0.8.4-main.66e292d",
41
+ "@dxos/live-object": "0.8.4-main.66e292d",
42
+ "@dxos/random": "0.8.4-main.66e292d",
43
+ "@dxos/echo-db": "0.8.4-main.66e292d",
44
+ "@dxos/log": "0.8.4-main.66e292d",
45
+ "@dxos/react-ui": "0.8.4-main.66e292d",
46
+ "@dxos/react-ui-theme": "0.8.4-main.66e292d",
47
+ "@dxos/storybook-utils": "0.8.4-main.66e292d"
48
48
  },
49
49
  "peerDependencies": {
50
- "react": "~18.2.0",
51
- "react-dom": "~18.2.0",
52
- "@dxos/react-ui": "0.8.4-main.5ea62a8",
53
- "@dxos/react-ui-theme": "0.8.4-main.5ea62a8"
50
+ "react": "^19.0.0",
51
+ "react-dom": "^19.0.0",
52
+ "@dxos/react-ui": "0.8.4-main.66e292d",
53
+ "@dxos/react-ui-theme": "0.8.4-main.66e292d"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -2,14 +2,12 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useState } from 'react';
9
7
 
10
8
  import { PublicKey } from '@dxos/keys';
9
+ import { withTheme } from '@dxos/react-ui/testing';
11
10
  import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
12
- import { withLayout, withTheme } from '@dxos/storybook-utils';
13
11
 
14
12
  import { type MessageEntity, MessageStoryText } from '../testing';
15
13
  import { Thread } from '../Thread';
@@ -41,8 +39,11 @@ const meta = {
41
39
  title: 'ui/react-ui-thread/Message',
42
40
  component: MessageRoot as any,
43
41
  render: DefaultStory,
44
- decorators: [withTheme, withLayout({ fullscreen: true })],
45
- parameters: { translations },
42
+ decorators: [withTheme],
43
+ parameters: {
44
+ layout: 'fullscreen',
45
+ translations,
46
+ },
46
47
  } satisfies Meta<typeof DefaultStory>;
47
48
 
48
49
  export default meta;
@@ -9,7 +9,7 @@ import React, { type ComponentPropsWithRef, type ComponentPropsWithoutRef, forwa
9
9
  import { Avatar, type ThemedClassName, useTranslation } from '@dxos/react-ui';
10
10
  import { type UseTextEditorProps, keymap, listener, useTextEditor } from '@dxos/react-ui-editor';
11
11
  import { focusRing, mx } from '@dxos/react-ui-theme';
12
- import { hexToEmoji, hexToHue, isNotFalsy } from '@dxos/util';
12
+ import { hexToEmoji, hexToHue, isTruthy } from '@dxos/util';
13
13
 
14
14
  import { translationKey } from '../translations';
15
15
  import { type MessageMetadata } from '../types';
@@ -149,14 +149,14 @@ export const MessageTextbox = ({
149
149
  extensions: [
150
150
  keymap.of(keyBindings({ onSend, onClear })),
151
151
  listener({
152
- onFocus: (focusing) => {
152
+ onFocus: ({ focusing }) => {
153
153
  if (focusing) {
154
154
  onEditorFocus?.();
155
155
  }
156
156
  },
157
157
  }),
158
158
  extensions,
159
- ].filter(isNotFalsy),
159
+ ].filter(isTruthy),
160
160
  ...editorProps,
161
161
  }),
162
162
  [id, extensions],
@@ -2,23 +2,19 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { type FC, useEffect, useMemo, useRef, useState } from 'react';
9
7
 
10
- import { createDocAccessor, createObject } from '@dxos/echo-db';
11
- import { Expando } from '@dxos/echo-schema';
8
+ import { Expando } from '@dxos/echo/internal';
12
9
  import { PublicKey } from '@dxos/keys';
13
- import { live } from '@dxos/live-object';
14
10
  import { log } from '@dxos/log';
15
11
  import { faker } from '@dxos/random';
16
- import { Button, Icon, useThemeContext } from '@dxos/react-ui';
12
+ import { Icon, IconButton, useThemeContext } from '@dxos/react-ui';
13
+ import { withTheme } from '@dxos/react-ui/testing';
17
14
  import {
18
15
  type Comment,
19
16
  type CommentsOptions,
20
17
  type Range,
21
- automerge,
22
18
  comments,
23
19
  createBasicExtensions,
24
20
  createThemeExtensions,
@@ -28,8 +24,8 @@ import {
28
24
  useTextEditor,
29
25
  } from '@dxos/react-ui-editor';
30
26
  import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
31
- import { withTheme } from '@dxos/storybook-utils';
32
27
 
28
+ import { Obj } from '../../../../core/echo/echo/src';
33
29
  import { MessageBody, MessageHeading, MessageRoot, MessageTextbox } from '../Message';
34
30
  import { type MessageEntity } from '../testing';
35
31
  import { translations } from '../translations';
@@ -73,7 +69,6 @@ const Editor: FC<{
73
69
  extensions: [
74
70
  createBasicExtensions(),
75
71
  createThemeExtensions({ themeMode }),
76
- automerge(createDocAccessor(item, ['content'])),
77
72
  comments({
78
73
  id,
79
74
  onCreate: onCreateComment,
@@ -116,19 +111,21 @@ const StoryThread: FC<{
116
111
  onSelect: () => void;
117
112
  onResolve: () => void;
118
113
  }> = ({ thread, selected, onSelect, onResolve }) => {
119
- const containerRef = useRef<HTMLDivElement>(null);
120
114
  const { themeMode } = useThemeContext();
115
+ const containerRef = useRef<HTMLDivElement>(null);
116
+
121
117
  // TODO(wittjosiah): This is a hack to reset the editor after a message is sent.
122
- const [_count, _setCount] = useState(0);
123
- const rerenderEditor = () => _setCount((count) => count + 1);
118
+ const [state, setState] = useState({});
124
119
  const messageRef = useRef('');
125
120
  const extensions = useMemo(
126
121
  () => [
127
122
  createBasicExtensions({ placeholder: 'Enter comment' }),
128
123
  createThemeExtensions({ themeMode }),
129
- listener({ onChange: (text) => (messageRef.current = text) }),
124
+ listener({
125
+ onChange: ({ text }) => (messageRef.current = text),
126
+ }),
130
127
  ],
131
- [themeMode, _count],
128
+ [themeMode, state],
132
129
  );
133
130
 
134
131
  const [autoFocus, setAutoFocus] = useState(false);
@@ -144,7 +141,7 @@ const StoryThread: FC<{
144
141
 
145
142
  const handleCreateMessage = () => {
146
143
  if (messageRef.current?.length) {
147
- const message = live(Expando, {
144
+ const message = Obj.make(Expando, {
148
145
  timestamp: new Date().toISOString(),
149
146
  sender: { identityKey: authorId },
150
147
  text: messageRef.current,
@@ -153,7 +150,7 @@ const StoryThread: FC<{
153
150
 
154
151
  messageRef.current = '';
155
152
  setAutoFocus(true);
156
- rerenderEditor();
153
+ setState({});
157
154
  }
158
155
  };
159
156
 
@@ -187,9 +184,14 @@ const StoryThread: FC<{
187
184
  onSend={handleCreateMessage}
188
185
  />
189
186
  <Thread.Status />
190
- <Button variant='ghost' classNames='px-1' title='Resolve' onClick={onResolve}>
191
- <Icon icon='ph--check--regular' />
192
- </Button>
187
+ <IconButton
188
+ variant='ghost'
189
+ icon='ph--check--regular'
190
+ iconOnly
191
+ classNames='pli-1'
192
+ label='Resolve'
193
+ onClick={onResolve}
194
+ />
193
195
  </div>
194
196
  </Thread.Root>
195
197
  );
@@ -234,7 +236,7 @@ type StoryProps = {
234
236
  };
235
237
 
236
238
  const DefaultStory = ({ text, autoCreate }: StoryProps) => {
237
- const [item] = useState(createObject(live(Expando, { content: text ?? '' })));
239
+ const [item] = useState(() => Obj.make(Expando, { content: text ?? '' }));
238
240
  const [threads, setThreads] = useState<StoryCommentThread[]>([]);
239
241
  const [selected, setSelected] = useState<string>();
240
242
 
@@ -355,7 +357,10 @@ const meta = {
355
357
  component: StoryThread as any,
356
358
  render: DefaultStory,
357
359
  decorators: [withTheme],
358
- parameters: { translations, layout: 'fullscreen' },
360
+ parameters: {
361
+ translations,
362
+ layout: 'fullscreen',
363
+ },
359
364
  } satisfies Meta<typeof DefaultStory>;
360
365
 
361
366
  export default meta;
@@ -2,16 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useMemo, useRef, useState } from 'react';
9
7
 
10
8
  import { PublicKey } from '@dxos/keys';
11
9
  import { faker } from '@dxos/random';
10
+ import { withTheme } from '@dxos/react-ui/testing';
12
11
  import { createBasicExtensions, createThemeExtensions } from '@dxos/react-ui-editor';
13
12
  import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
14
- import { withLayout, withTheme } from '@dxos/storybook-utils';
15
13
 
16
14
  import { MessageRoot, MessageTextbox } from '../Message';
17
15
  import { type MessageEntity, MessageStoryText } from '../testing';
@@ -87,8 +85,11 @@ const meta = {
87
85
  title: 'ui/react-ui-thread/Thread',
88
86
  component: Thread.Root,
89
87
  render: DefaultStory,
90
- decorators: [withTheme, withLayout({ fullscreen: true })],
91
- parameters: { translations },
88
+ decorators: [withTheme],
89
+ parameters: {
90
+ layout: 'fullscreen',
91
+ translations,
92
+ },
92
93
  } satisfies Meta<typeof Thread.Root>;
93
94
 
94
95
  export default meta;
@@ -45,10 +45,10 @@ const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
45
45
  // Heading
46
46
  //
47
47
 
48
- type ThreadHeaderProps = ThemedClassName<ComponentPropsWithRef<'div'>> & { detached?: boolean };
48
+ type ThreadHeaderProps = ComponentPropsWithRef<'div'> & { detached?: boolean };
49
49
 
50
50
  const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
51
- ({ classNames, children, detached, ...props }, forwardedRef) => {
51
+ ({ children, detached, ...props }, forwardedRef) => {
52
52
  return (
53
53
  <>
54
54
  <div role='none' className='flex items-center justify-center text-description'>
package/src/testing.tsx CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Button, Icon } from '@dxos/react-ui';
7
+ import { IconButton } from '@dxos/react-ui';
8
8
  import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';
9
9
 
10
10
  import { MessageBody, MessageHeading } from './Message';
@@ -25,13 +25,14 @@ export const MessageStoryText = ({ text, onDelete, authorName, timestamp }: Mess
25
25
  <>
26
26
  <MessageHeading authorName={authorName} timestamp={timestamp}>
27
27
  {onDelete && (
28
- <Button
28
+ <IconButton
29
+ icon='ph--x--regular'
30
+ iconOnly
31
+ label='Delete'
29
32
  variant='ghost'
30
33
  classNames={['p-1.5 min-bs-0 mie-1 items-start transition-opacity', hoverableControlItem]}
31
34
  onClick={() => onDelete()}
32
- >
33
- <Icon icon='ph--x--regular' />
34
- </Button>
35
+ />
35
36
  )}
36
37
  </MessageHeading>
37
38
  <MessageBody>{text}</MessageBody>