@dxos/react-ui-thread 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963

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.c85a9c8dae",
3
+ "version": "0.8.4-main.cb12b3f963",
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",
@@ -12,48 +12,54 @@
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": false,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#translations": "./src/translations.ts"
17
+ },
15
18
  "exports": {
16
19
  ".": {
17
20
  "source": "./src/index.ts",
18
21
  "types": "./dist/types/src/index.d.ts",
19
22
  "browser": "./dist/lib/browser/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"
20
29
  }
21
30
  },
22
31
  "types": "dist/types/src/index.d.ts",
23
- "typesVersions": {
24
- "*": {}
25
- },
26
32
  "files": [
27
33
  "dist",
28
34
  "src"
29
35
  ],
30
36
  "dependencies": {
31
37
  "@radix-ui/react-primitive": "2.0.2",
32
- "date-fns": "^3.3.1",
33
- "@dxos/react-ui-editor": "0.8.4-main.c85a9c8dae",
34
- "@dxos/ui-editor": "0.8.4-main.c85a9c8dae",
35
- "@dxos/util": "0.8.4-main.c85a9c8dae"
38
+ "date-fns": "^3.6.0",
39
+ "@dxos/react-ui-editor": "0.8.4-main.cb12b3f963",
40
+ "@dxos/util": "0.8.4-main.cb12b3f963",
41
+ "@dxos/ui-editor": "0.8.4-main.cb12b3f963"
36
42
  },
37
43
  "devDependencies": {
38
44
  "@types/react": "~19.2.7",
39
45
  "@types/react-dom": "~19.2.3",
40
46
  "react": "~19.2.3",
41
47
  "react-dom": "~19.2.3",
42
- "vite": "^7.1.11",
43
- "@dxos/echo": "0.8.4-main.c85a9c8dae",
44
- "@dxos/echo-db": "0.8.4-main.c85a9c8dae",
45
- "@dxos/random": "0.8.4-main.c85a9c8dae",
46
- "@dxos/log": "0.8.4-main.c85a9c8dae",
47
- "@dxos/react-ui": "0.8.4-main.c85a9c8dae",
48
- "@dxos/storybook-utils": "0.8.4-main.c85a9c8dae",
49
- "@dxos/keys": "0.8.4-main.c85a9c8dae",
50
- "@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
48
+ "vite": "^8.0.10",
49
+ "@dxos/keys": "0.8.4-main.cb12b3f963",
50
+ "@dxos/log": "0.8.4-main.cb12b3f963",
51
+ "@dxos/echo": "0.8.4-main.cb12b3f963",
52
+ "@dxos/echo-db": "0.8.4-main.cb12b3f963",
53
+ "@dxos/react-ui": "0.8.4-main.cb12b3f963",
54
+ "@dxos/ui-theme": "0.8.4-main.cb12b3f963",
55
+ "@dxos/storybook-utils": "0.8.4-main.cb12b3f963",
56
+ "@dxos/random": "0.8.4-main.cb12b3f963"
51
57
  },
52
58
  "peerDependencies": {
53
59
  "react": "~19.2.3",
54
60
  "react-dom": "~19.2.3",
55
- "@dxos/react-ui": "0.8.4-main.c85a9c8dae",
56
- "@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
61
+ "@dxos/react-ui": "0.8.4-main.cb12b3f963",
62
+ "@dxos/ui-theme": "0.8.4-main.cb12b3f963"
57
63
  },
58
64
  "publishConfig": {
59
65
  "access": "public"
@@ -9,10 +9,10 @@ import { PublicKey } from '@dxos/keys';
9
9
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
10
10
  import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/ui-theme';
11
11
 
12
+ import { translations } from '#translations';
13
+
12
14
  import { type MessageEntity, MessageStoryText } from '../testing';
13
15
  import { Thread } from '../Thread';
14
- import { translations } from '../translations';
15
-
16
16
  import { MessageRoot } from './Message';
17
17
 
18
18
  const DefaultStory = () => {
@@ -8,10 +8,11 @@ import React, { type ComponentPropsWithRef, type ComponentPropsWithoutRef, forwa
8
8
  import { Avatar, type ThemedClassName, useTranslation } from '@dxos/react-ui';
9
9
  import { type UseTextEditorProps, useTextEditor } from '@dxos/react-ui-editor';
10
10
  import { keymap, listener } from '@dxos/ui-editor';
11
- import { focusRing, mx } from '@dxos/ui-theme';
11
+ import { mx } from '@dxos/ui-theme';
12
12
  import { hexToEmoji, hexToHue, isTruthy } from '@dxos/util';
13
13
 
14
- import { translationKey } from '../translations';
14
+ import { translationKey } from '#translations';
15
+
15
16
  import { type MessageMetadata } from '../types';
16
17
 
17
18
  const avatarSize = 7;
@@ -26,8 +27,8 @@ export const MessageRoot = forwardRef<HTMLDivElement, MessageRootProps>(
26
27
  { authorImgSrc, authorId, authorName, authorAvatarProps, continues = true, children, classNames, ...rootProps },
27
28
  forwardedRef,
28
29
  ) => {
30
+ // Must wrap the message since Avatar.Label may be used in the content.
29
31
  return (
30
- // Must wrap the message since Avatar.Label may be used in the content.
31
32
  <Avatar.Root>
32
33
  <div
33
34
  role='none'
@@ -74,7 +75,7 @@ export type MessageAuthorNameProps = Pick<MessageMetadata, 'authorName'>;
74
75
  export const MessageAuthorName = ({ authorName }: MessageAuthorNameProps) => {
75
76
  const { t } = useTranslation(translationKey);
76
77
  return (
77
- <Avatar.Label classNames='block truncate text-sm text-subdued'>{authorName ?? t('anonymous label')}</Avatar.Label>
78
+ <Avatar.Label classNames='block truncate text-sm text-subdued'>{authorName ?? t('anonymous.label')}</Avatar.Label>
78
79
  );
79
80
  };
80
81
 
@@ -167,7 +168,7 @@ export const MessageTextbox = ({
167
168
  <div
168
169
  role='none'
169
170
  ref={parentRef}
170
- className={mx('py-0.5 me-1 rounded-xs', focusRing, disabled && 'opacity-50')}
171
+ className={mx('py-0.5 me-1 rounded-xs dx-focus-ring', disabled && 'opacity-50')}
171
172
  {...focusAttributes}
172
173
  />
173
174
  </MessageRoot>
@@ -9,15 +9,13 @@ import { Obj } from '@dxos/echo';
9
9
  import { TestSchema } from '@dxos/echo/testing';
10
10
  import { PublicKey } from '@dxos/keys';
11
11
  import { log } from '@dxos/log';
12
- import { faker } from '@dxos/random';
12
+ import { random } from '@dxos/random';
13
13
  import { Icon, IconButton, useThemeContext } from '@dxos/react-ui';
14
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
15
14
  import { useTextEditor } from '@dxos/react-ui-editor';
15
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
16
16
  import {
17
- type Comment,
18
17
  type CommentsOptions,
19
18
  type EditorView,
20
- type Range,
21
19
  comments,
22
20
  createBasicExtensions,
23
21
  createThemeExtensions,
@@ -26,15 +24,16 @@ import {
26
24
  scrollThreadIntoView,
27
25
  setComments,
28
26
  } from '@dxos/ui-editor';
27
+ import { type Comment, type Range } from '@dxos/ui-editor/types';
29
28
  import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/ui-theme';
30
29
 
30
+ import { translations } from '#translations';
31
+
31
32
  import { MessageBody, MessageHeading, MessageRoot, MessageTextbox } from '../Message';
32
33
  import { type MessageEntity } from '../testing';
33
- import { translations } from '../translations';
34
-
35
34
  import { Thread } from './Thread';
36
35
 
37
- faker.seed(101);
36
+ random.seed(101);
38
37
 
39
38
  const authorId = PublicKey.random().toHex();
40
39
 
@@ -252,12 +251,12 @@ const Sidebar = ({ threads, selected, onSelect, onResolve }: SidebarProps) => {
252
251
  // Story container.
253
252
  //
254
253
 
255
- type StoryProps = {
254
+ type DefaultStoryProps = {
256
255
  text?: string;
257
256
  autoCreate?: boolean;
258
257
  };
259
258
 
260
- const DefaultStory = ({ text, autoCreate }: StoryProps) => {
259
+ const DefaultStory = ({ text, autoCreate }: DefaultStoryProps) => {
261
260
  const [item] = useState(() => Obj.make(TestSchema.Expando, { content: text ?? '' }));
262
261
  const [threads, setThreads] = useState<StoryCommentThread[]>([]);
263
262
  const [selected, setSelected] = useState<string>();
@@ -277,12 +276,12 @@ const DefaultStory = ({ text, autoCreate }: StoryProps) => {
277
276
  cursor,
278
277
  yPos: location ? Math.floor(location.top) : undefined,
279
278
  messages: autoCreate
280
- ? faker.helpers.multiple(
279
+ ? random.helpers.multiple(
281
280
  () => ({
282
281
  id: PublicKey.random().toHex(),
283
282
  timestamp: new Date().toISOString(),
284
283
  authorId: PublicKey.random().toHex(),
285
- text: faker.lorem.sentence(),
284
+ text: random.lorem.sentence(),
286
285
  }),
287
286
  { count: { min: 1, max: 3 } },
288
287
  )
@@ -396,7 +395,7 @@ export const Default: Story = {
396
395
  text: str(
397
396
  '# Comments',
398
397
  '',
399
- str(...faker.helpers.multiple(() => [faker.lorem.paragraph({ min: 5, max: 10 }), ''], { count: 20 }).flat()),
398
+ str(...random.helpers.multiple(() => [random.lorem.paragraph({ min: 5, max: 10 }), ''], { count: 20 }).flat()),
400
399
  '',
401
400
  ),
402
401
  },
@@ -6,18 +6,18 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useMemo, useRef, useState } from 'react';
7
7
 
8
8
  import { PublicKey } from '@dxos/keys';
9
- import { faker } from '@dxos/random';
9
+ import { random } from '@dxos/random';
10
10
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
11
  import { createBasicExtensions, createThemeExtensions } from '@dxos/ui-editor';
12
12
  import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/ui-theme';
13
13
 
14
+ import { translations } from '#translations';
15
+
14
16
  import { MessageRoot, MessageTextbox } from '../Message';
15
17
  import { type MessageEntity, MessageStoryText } from '../testing';
16
- import { translations } from '../translations';
17
-
18
18
  import { Thread } from './Thread';
19
19
 
20
- faker.seed(1);
20
+ random.seed(1);
21
21
 
22
22
  const DefaultStory = () => {
23
23
  const [pending, setPending] = useState(false);
@@ -28,7 +28,7 @@ const DefaultStory = () => {
28
28
  id: `m${i + 1}`,
29
29
  timestamp: new Date().toISOString(),
30
30
  authorId: [identityKey1.toHex(), identityKey2.toHex()][i % 2],
31
- text: faker.lorem.paragraph(),
31
+ text: random.lorem.paragraph(),
32
32
  })),
33
33
  );
34
34
 
@@ -2,12 +2,13 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { type ComponentPropsWithRef, forwardRef } from 'react';
5
+ import React, { ComponentPropsWithRef, forwardRef, PropsWithChildren } from 'react';
6
6
 
7
7
  import { Icon, type ThemedClassName, useTranslation } from '@dxos/react-ui';
8
8
  import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/ui-theme';
9
9
 
10
- import { translationKey } from '../translations';
10
+ import { translationKey } from '#translations';
11
+
11
12
  import type { ThreadEntity } from '../types';
12
13
 
13
14
  // TODO(burdon): Avoid exporting fragments.
@@ -17,7 +18,11 @@ export const threadLayout = 'w-full place-self-start grid grid-cols-[var(--dx-ra
17
18
  // Root
18
19
  //
19
20
 
20
- type ThreadRootProps = ThemedClassName<ComponentPropsWithRef<'div'>> & ThreadEntity & { current?: boolean };
21
+ type ThreadRootProps = ThemedClassName<
22
+ PropsWithChildren<
23
+ ThreadEntity & { current?: boolean } & Pick<ComponentPropsWithRef<'div'>, 'onClickCapture' | 'onFocusCapture'>
24
+ >
25
+ >;
21
26
 
22
27
  const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
23
28
  ({ current, children, classNames, ...props }, forwardedRef) => {
@@ -45,7 +50,7 @@ const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
45
50
  // Heading
46
51
  //
47
52
 
48
- type ThreadHeaderProps = ComponentPropsWithRef<'div'> & { detached?: boolean };
53
+ type ThreadHeaderProps = PropsWithChildren<{ detached?: boolean }>;
49
54
 
50
55
  const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
51
56
  ({ children, detached, ...props }, forwardedRef) => {
@@ -74,7 +79,7 @@ const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
74
79
  // Status
75
80
  //
76
81
 
77
- type ThreadStatusProps = ThemedClassName<ComponentPropsWithRef<'div'>> & {
82
+ type ThreadStatusProps = ThemedClassName<PropsWithChildren> & {
78
83
  activity?: boolean;
79
84
  };
80
85
 
@@ -98,7 +103,7 @@ const ThreadStatus = forwardRef<HTMLDivElement, ThreadStatusProps>(
98
103
  <span className='truncate min-w-0' aria-live='polite'>
99
104
  {activity ? children : null}
100
105
  </span>
101
- <span className={mx('text-end', hoverableControlItem)}>{t('enter to send message')}</span>
106
+ <span className={mx('text-end', hoverableControlItem)}>{t('enter-to-send.message')}</span>
102
107
  </div>
103
108
  );
104
109
  },
package/src/index.ts CHANGED
@@ -2,9 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { translations } from './translations';
6
-
7
5
  export * from './Thread';
8
6
  export * from './Message';
9
7
  export type * from './types';
10
- export { translations };
@@ -10,16 +10,16 @@ export const translations = [
10
10
  {
11
11
  'en-US': {
12
12
  [translationKey]: {
13
- 'plugin name': 'Threads',
14
- 'thread title placeholder': 'New thread',
15
- 'thread title label': 'Title',
16
- 'delete thread label': 'Delete',
17
- 'create thread label': 'Create thread',
18
- 'message placeholder': 'Enter message...',
19
- 'comment placeholder': 'Enter comment...',
20
- 'settings standalone label': 'Enable standalone thread creation',
21
- 'anonymous label': 'Anonymous',
22
- 'enter to send message': 'Enter to add ⏎',
13
+ 'plugin.name': 'Threads',
14
+ 'thread-title.placeholder': 'New thread',
15
+ 'thread-title.label': 'Title',
16
+ 'delete-thread.label': 'Delete',
17
+ 'create-thread.label': 'Create thread',
18
+ 'message.placeholder': 'Enter message...',
19
+ 'comment.placeholder': 'Enter comment...',
20
+ 'settings-standalone.label': 'Enable standalone thread creation',
21
+ 'anonymous.label': 'Anonymous',
22
+ 'enter-to-send.message': 'Enter to add ⏎',
23
23
  },
24
24
  },
25
25
  },
package/src/types.ts CHANGED
@@ -16,6 +16,7 @@ export type MessageMetadata = {
16
16
  };
17
17
 
18
18
  export type ThreadEntity = {
19
+ id?: string;
19
20
  topicId?: string;
20
21
  topicTitle?: string;
21
22
  };