@dxos/react-ui-thread 0.8.3 → 0.8.4-main.f9ba587
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 +15 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +268 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/Message/Message.stories.d.ts +14 -14
- package/dist/types/src/Thread/Comments.stories.d.ts +14 -14
- package/dist/types/src/Thread/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/Thread/Thread.d.ts +10 -7
- package/dist/types/src/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/Thread/Thread.stories.d.ts +4 -26
- package/dist/types/src/Thread/Thread.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +1 -2
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +15 -16
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/Message/Message.stories.tsx +7 -7
- package/src/Thread/Comments.stories.tsx +13 -15
- package/src/Thread/Thread.stories.tsx +15 -11
- package/src/Thread/Thread.tsx +29 -9
- package/src/index.ts +1 -1
- package/src/testing.tsx +1 -5
- package/src/translations.ts +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-thread",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.f9ba587",
|
|
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",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@preact-signals/safe-react": "^0.9.0",
|
|
27
27
|
"@radix-ui/react-primitive": "2.0.2",
|
|
28
28
|
"date-fns": "^3.3.1",
|
|
29
|
-
"@dxos/react-ui-editor": "0.8.
|
|
30
|
-
"@dxos/util": "0.8.
|
|
29
|
+
"@dxos/react-ui-editor": "0.8.4-main.f9ba587",
|
|
30
|
+
"@dxos/util": "0.8.4-main.f9ba587"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"react": "~18.2.0",
|
|
37
37
|
"react-dom": "~18.2.0",
|
|
38
38
|
"vite": "5.4.7",
|
|
39
|
-
"@dxos/echo-
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/react-ui": "0.8.
|
|
46
|
-
"@dxos/react-ui-theme": "0.8.
|
|
47
|
-
"@dxos/storybook-utils": "0.8.
|
|
39
|
+
"@dxos/echo-db": "0.8.4-main.f9ba587",
|
|
40
|
+
"@dxos/echo-schema": "0.8.4-main.f9ba587",
|
|
41
|
+
"@dxos/keys": "0.8.4-main.f9ba587",
|
|
42
|
+
"@dxos/live-object": "0.8.4-main.f9ba587",
|
|
43
|
+
"@dxos/log": "0.8.4-main.f9ba587",
|
|
44
|
+
"@dxos/random": "0.8.4-main.f9ba587",
|
|
45
|
+
"@dxos/react-ui": "0.8.4-main.f9ba587",
|
|
46
|
+
"@dxos/react-ui-theme": "0.8.4-main.f9ba587",
|
|
47
|
+
"@dxos/storybook-utils": "0.8.4-main.f9ba587"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@phosphor-icons/react": "^2.1.5",
|
|
51
51
|
"react": "~18.2.0",
|
|
52
52
|
"react-dom": "~18.2.0",
|
|
53
|
-
"@dxos/react-ui": "0.8.
|
|
54
|
-
"@dxos/react-ui-theme": "0.8.
|
|
53
|
+
"@dxos/react-ui": "0.8.4-main.f9ba587",
|
|
54
|
+
"@dxos/react-ui-theme": "0.8.4-main.f9ba587"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
@@ -11,9 +11,9 @@ import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-u
|
|
|
11
11
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
13
|
import { MessageRoot } from './Message';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import translations from '../translations';
|
|
14
|
+
import { Thread } from '../Thread';
|
|
15
|
+
import { MessageStoryText, type MessageEntity } from '../testing';
|
|
16
|
+
import { translations } from '../translations';
|
|
17
17
|
|
|
18
18
|
const DefaultStory = () => {
|
|
19
19
|
const [identityKey] = useState(PublicKey.random());
|
|
@@ -25,13 +25,13 @@ const DefaultStory = () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
28
|
+
<div className='mli-auto is-96 overflow-y-auto'>
|
|
29
|
+
<Thread.Root id='t1'>
|
|
30
30
|
<MessageRoot {...message} classNames={[hoverableControls, hoverableFocusedWithinControls]}>
|
|
31
31
|
<MessageStoryText {...message} onDelete={() => console.log('delete')} />
|
|
32
32
|
</MessageRoot>
|
|
33
|
-
</
|
|
34
|
-
</
|
|
33
|
+
</Thread.Root>
|
|
34
|
+
</div>
|
|
35
35
|
);
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
|
|
31
31
|
import { withTheme } from '@dxos/storybook-utils';
|
|
32
32
|
|
|
33
|
-
import { Thread
|
|
33
|
+
import { Thread } from './Thread';
|
|
34
34
|
import { MessageBody, MessageHeading, MessageRoot, MessageTextbox } from '../Message';
|
|
35
35
|
import { type MessageEntity } from '../testing';
|
|
36
|
-
import translations from '../translations';
|
|
36
|
+
import { translations } from '../translations';
|
|
37
37
|
|
|
38
38
|
faker.seed(101);
|
|
39
39
|
|
|
@@ -157,7 +157,7 @@ const StoryThread: FC<{
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
return (
|
|
160
|
-
<Thread current={selected} onClickCapture={onSelect}>
|
|
160
|
+
<Thread.Root current={selected} onClickCapture={onSelect}>
|
|
161
161
|
<div className='col-start-2 flex gap-1 text-xs text-description'>
|
|
162
162
|
<span>id:{thread.id.slice(0, 4)}</span>
|
|
163
163
|
<span>y:{thread.yPos}</span>
|
|
@@ -165,9 +165,9 @@ const StoryThread: FC<{
|
|
|
165
165
|
{!thread.cursor && <Trash />}
|
|
166
166
|
</div>
|
|
167
167
|
|
|
168
|
-
<
|
|
168
|
+
<Thread.Header>
|
|
169
169
|
{thread.range?.from} – {thread.range?.to}
|
|
170
|
-
</
|
|
170
|
+
</Thread.Header>
|
|
171
171
|
|
|
172
172
|
{thread.messages.map((message) => (
|
|
173
173
|
<MessageRoot key={message.id} classNames={[hoverableControls, hoverableFocusedWithinControls]} {...message}>
|
|
@@ -185,12 +185,12 @@ const StoryThread: FC<{
|
|
|
185
185
|
onEditorFocus={onSelect}
|
|
186
186
|
onSend={handleCreateMessage}
|
|
187
187
|
/>
|
|
188
|
-
<
|
|
188
|
+
<Thread.Status />
|
|
189
189
|
<Button variant='ghost' classNames='px-1' title='Resolve' onClick={onResolve}>
|
|
190
190
|
<Check />
|
|
191
191
|
</Button>
|
|
192
192
|
</div>
|
|
193
|
-
</Thread>
|
|
193
|
+
</Thread.Root>
|
|
194
194
|
);
|
|
195
195
|
};
|
|
196
196
|
|
|
@@ -359,15 +359,13 @@ export default {
|
|
|
359
359
|
|
|
360
360
|
const str = (...lines: string[]) => lines.join('\n');
|
|
361
361
|
|
|
362
|
-
const document = str(
|
|
363
|
-
'# Comments',
|
|
364
|
-
'',
|
|
365
|
-
str(...faker.helpers.multiple(() => [faker.lorem.paragraph({ min: 5, max: 10 }), ''], { count: 20 }).flat()),
|
|
366
|
-
'',
|
|
367
|
-
);
|
|
368
|
-
|
|
369
362
|
export const Default = {
|
|
370
363
|
args: {
|
|
371
|
-
text:
|
|
364
|
+
text: str(
|
|
365
|
+
'# Comments',
|
|
366
|
+
'',
|
|
367
|
+
str(...faker.helpers.multiple(() => [faker.lorem.paragraph({ min: 5, max: 10 }), ''], { count: 20 }).flat()),
|
|
368
|
+
'',
|
|
369
|
+
),
|
|
372
370
|
},
|
|
373
371
|
};
|
|
@@ -10,12 +10,12 @@ import { PublicKey } from '@dxos/keys';
|
|
|
10
10
|
import { faker } from '@dxos/random';
|
|
11
11
|
import { createBasicExtensions, createThemeExtensions } from '@dxos/react-ui-editor';
|
|
12
12
|
import { hoverableControls, hoverableFocusedWithinControls } from '@dxos/react-ui-theme';
|
|
13
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
13
|
+
import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
14
|
|
|
15
|
-
import { Thread
|
|
15
|
+
import { Thread } from './Thread';
|
|
16
16
|
import { MessageRoot, MessageTextbox } from '../Message';
|
|
17
|
-
import {
|
|
18
|
-
import translations from '../translations';
|
|
17
|
+
import { MessageStoryText, type MessageEntity } from '../testing';
|
|
18
|
+
import { translations } from '../translations';
|
|
19
19
|
|
|
20
20
|
faker.seed(1);
|
|
21
21
|
|
|
@@ -59,13 +59,14 @@ const DefaultStory = () => {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
|
-
<
|
|
63
|
-
<Thread id='t1'>
|
|
62
|
+
<div className='mli-auto is-96 overflow-y-auto'>
|
|
63
|
+
<Thread.Root id='t1'>
|
|
64
64
|
{messages.map((message) => (
|
|
65
65
|
<MessageRoot key={message.id} classNames={[hoverableControls, hoverableFocusedWithinControls]} {...message}>
|
|
66
66
|
<MessageStoryText {...message} text={message.text} onDelete={() => console.log('delete')} />
|
|
67
67
|
</MessageRoot>
|
|
68
68
|
))}
|
|
69
|
+
|
|
69
70
|
<MessageTextbox
|
|
70
71
|
id={String(_count)}
|
|
71
72
|
authorId={identityKey1.toHex()}
|
|
@@ -73,18 +74,21 @@ const DefaultStory = () => {
|
|
|
73
74
|
extensions={extensions}
|
|
74
75
|
onSend={handleSend}
|
|
75
76
|
/>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
|
|
78
|
+
<Thread.Status activity>Processing...</Thread.Status>
|
|
79
|
+
</Thread.Root>
|
|
80
|
+
</div>
|
|
79
81
|
);
|
|
80
82
|
};
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
const meta: Meta<typeof Thread.Root> = {
|
|
83
85
|
title: 'ui/react-ui-thread/Thread',
|
|
84
|
-
component: Thread,
|
|
86
|
+
component: Thread.Root,
|
|
85
87
|
render: DefaultStory,
|
|
86
88
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
87
89
|
parameters: { translations },
|
|
88
90
|
};
|
|
89
91
|
|
|
92
|
+
export default meta;
|
|
93
|
+
|
|
90
94
|
export const Default = {};
|
package/src/Thread/Thread.tsx
CHANGED
|
@@ -11,11 +11,16 @@ import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/
|
|
|
11
11
|
import { translationKey } from '../translations';
|
|
12
12
|
import type { ThreadEntity } from '../types';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// TODO(burdon): Why is this exported?
|
|
16
15
|
export const threadLayout = 'is-full place-self-start grid grid-cols-[var(--rail-size)_1fr]';
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
//
|
|
18
|
+
// Root
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
type ThreadRootProps = ThemedClassName<ComponentPropsWithRef<'div'>> & ThreadEntity & { current?: boolean };
|
|
22
|
+
|
|
23
|
+
const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
|
|
19
24
|
({ current, children, classNames, ...props }, forwardedRef) => {
|
|
20
25
|
return (
|
|
21
26
|
<div
|
|
@@ -26,8 +31,7 @@ export const Thread = forwardRef<HTMLDivElement, ThreadProps>(
|
|
|
26
31
|
className={mx(
|
|
27
32
|
threadLayout,
|
|
28
33
|
hoverableFocusedWithinControls,
|
|
29
|
-
'
|
|
30
|
-
'current-related attention-surface [--controls-opacity:0]',
|
|
34
|
+
'bg-[var(--surface-bg)] current-related attention-surface [--controls-opacity:0]',
|
|
31
35
|
classNames,
|
|
32
36
|
)}
|
|
33
37
|
ref={forwardedRef}
|
|
@@ -38,9 +42,13 @@ export const Thread = forwardRef<HTMLDivElement, ThreadProps>(
|
|
|
38
42
|
},
|
|
39
43
|
);
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
//
|
|
46
|
+
// Heading
|
|
47
|
+
//
|
|
48
|
+
|
|
49
|
+
type ThreadHeaderProps = ThemedClassName<ComponentPropsWithRef<'div'>> & { detached?: boolean };
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
44
52
|
({ classNames, children, detached, ...props }, forwardedRef) => {
|
|
45
53
|
return (
|
|
46
54
|
<>
|
|
@@ -66,11 +74,15 @@ export const ThreadHeading = forwardRef<HTMLParagraphElement, ThreadHeadingProps
|
|
|
66
74
|
},
|
|
67
75
|
);
|
|
68
76
|
|
|
69
|
-
|
|
77
|
+
//
|
|
78
|
+
// Status
|
|
79
|
+
//
|
|
80
|
+
|
|
81
|
+
type ThreadStatusProps = ThemedClassName<ComponentPropsWithRef<'div'>> & {
|
|
70
82
|
activity?: boolean;
|
|
71
83
|
};
|
|
72
84
|
|
|
73
|
-
|
|
85
|
+
const ThreadStatus = forwardRef<HTMLDivElement, ThreadStatusProps>(
|
|
74
86
|
({ activity, classNames, children, ...props }, forwardedRef) => {
|
|
75
87
|
const { t } = useTranslation(translationKey);
|
|
76
88
|
return (
|
|
@@ -95,3 +107,11 @@ export const ThreadFooter = forwardRef<HTMLDivElement, ThreadFooterProps>(
|
|
|
95
107
|
);
|
|
96
108
|
},
|
|
97
109
|
);
|
|
110
|
+
|
|
111
|
+
export const Thread = {
|
|
112
|
+
Root: ThreadRoot,
|
|
113
|
+
Header: ThreadHeader,
|
|
114
|
+
Status: ThreadStatus,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type { ThreadRootProps, ThreadHeaderProps as ThreadHeadingProps, ThreadStatusProps };
|
package/src/index.ts
CHANGED
package/src/testing.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { X } from '@phosphor-icons/react';
|
|
6
|
-
import React
|
|
6
|
+
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { Button } from '@dxos/react-ui';
|
|
9
9
|
import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';
|
|
@@ -56,7 +56,3 @@ export const MessageStoryBlock = <PartValue,>({ part }: MessagePartProps<PartVal
|
|
|
56
56
|
</div>
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
export const ThreadStoryContainer = ({ children }: PropsWithChildren) => {
|
|
61
|
-
return <div className={mx('bg-white dark:bg-black mli-auto is-96 overflow-y-auto')}>{children}</div>;
|
|
62
|
-
};
|
package/src/translations.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export const translationKey = 'react-ui-thread';
|
|
8
|
+
|
|
9
|
+
export const translations = [
|
|
8
10
|
{
|
|
9
11
|
'en-US': {
|
|
10
12
|
[translationKey]: {
|
|
@@ -21,4 +23,4 @@ export default [
|
|
|
21
23
|
},
|
|
22
24
|
},
|
|
23
25
|
},
|
|
24
|
-
];
|
|
26
|
+
] as const satisfies Resource[];
|