@dxos/react-ui-thread 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5
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 +141 -187
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/Message/Message.d.ts +2 -2
- package/dist/types/src/Message/Message.d.ts.map +1 -1
- package/dist/types/src/Message/Message.stories.d.ts +18 -16
- package/dist/types/src/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/Thread/Comments.stories.d.ts +19 -36
- package/dist/types/src/Thread/Comments.stories.d.ts.map +1 -1
- package/dist/types/src/Thread/Thread.d.ts +25 -11
- package/dist/types/src/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/Thread/Thread.stories.d.ts +33 -5
- package/dist/types/src/Thread/Thread.stories.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +12 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -24
- package/src/Message/Message.stories.tsx +17 -12
- package/src/Message/Message.tsx +16 -15
- package/src/Thread/Comments.stories.tsx +79 -48
- package/src/Thread/Thread.stories.tsx +18 -15
- package/src/Thread/Thread.tsx +19 -18
- package/src/testing.tsx +9 -8
- package/src/translations.ts +11 -11
- package/src/types.ts +1 -0
package/src/Thread/Thread.tsx
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { ComponentPropsWithRef, forwardRef, PropsWithChildren } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Icon, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/
|
|
8
|
+
import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
10
|
import { translationKey } from '../translations';
|
|
11
11
|
import type { ThreadEntity } from '../types';
|
|
12
12
|
|
|
13
|
-
// TODO(burdon):
|
|
14
|
-
export const threadLayout = '
|
|
13
|
+
// TODO(burdon): Avoid exporting fragments.
|
|
14
|
+
export const threadLayout = 'w-full place-self-start grid grid-cols-[var(--dx-rail-size)_1fr]';
|
|
15
15
|
|
|
16
16
|
//
|
|
17
17
|
// Root
|
|
18
18
|
//
|
|
19
19
|
|
|
20
|
-
type ThreadRootProps = ThemedClassName<
|
|
20
|
+
type ThreadRootProps = ThemedClassName<
|
|
21
|
+
PropsWithChildren<
|
|
22
|
+
ThreadEntity & { current?: boolean } & Pick<ComponentPropsWithRef<'div'>, 'onClickCapture' | 'onFocusCapture'>
|
|
23
|
+
>
|
|
24
|
+
>;
|
|
21
25
|
|
|
22
26
|
const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
|
|
23
27
|
({ current, children, classNames, ...props }, forwardedRef) => {
|
|
@@ -30,7 +34,7 @@ const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
|
|
|
30
34
|
className={mx(
|
|
31
35
|
threadLayout,
|
|
32
36
|
hoverableFocusedWithinControls,
|
|
33
|
-
'bg-[var(--surface-bg)] current-related attention-surface [--controls-opacity:0]',
|
|
37
|
+
'bg-[var(--surface-bg)] current-related dx-attention-surface [--controls-opacity:0]',
|
|
34
38
|
classNames,
|
|
35
39
|
)}
|
|
36
40
|
ref={forwardedRef}
|
|
@@ -45,10 +49,10 @@ const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
|
|
|
45
49
|
// Heading
|
|
46
50
|
//
|
|
47
51
|
|
|
48
|
-
type ThreadHeaderProps =
|
|
52
|
+
type ThreadHeaderProps = PropsWithChildren<{ detached?: boolean }>;
|
|
49
53
|
|
|
50
54
|
const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
51
|
-
({
|
|
55
|
+
({ children, detached, ...props }, forwardedRef) => {
|
|
52
56
|
return (
|
|
53
57
|
<>
|
|
54
58
|
<div role='none' className='flex items-center justify-center text-description'>
|
|
@@ -59,10 +63,7 @@ const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
|
59
63
|
role='heading'
|
|
60
64
|
data-testid='thread.heading'
|
|
61
65
|
{...props}
|
|
62
|
-
className={mx(
|
|
63
|
-
'mie-2 text-description font-medium truncate italic',
|
|
64
|
-
detached && 'line-through decoration-1',
|
|
65
|
-
)}
|
|
66
|
+
className={mx('me-2 text-description font-medium truncate italic', detached && 'line-through decoration-1')}
|
|
66
67
|
ref={forwardedRef}
|
|
67
68
|
>
|
|
68
69
|
{children}
|
|
@@ -77,7 +78,7 @@ const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
|
77
78
|
// Status
|
|
78
79
|
//
|
|
79
80
|
|
|
80
|
-
type ThreadStatusProps = ThemedClassName<
|
|
81
|
+
type ThreadStatusProps = ThemedClassName<PropsWithChildren> & {
|
|
81
82
|
activity?: boolean;
|
|
82
83
|
};
|
|
83
84
|
|
|
@@ -88,20 +89,20 @@ const ThreadStatus = forwardRef<HTMLDivElement, ThreadStatusProps>(
|
|
|
88
89
|
<div
|
|
89
90
|
{...props}
|
|
90
91
|
className={mx(
|
|
91
|
-
'col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2
|
|
92
|
+
'col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2 pe-2 text-xs text-description',
|
|
92
93
|
classNames,
|
|
93
94
|
)}
|
|
94
95
|
ref={forwardedRef}
|
|
95
96
|
>
|
|
96
97
|
<Icon
|
|
97
98
|
icon='ph--spinner--bold'
|
|
98
|
-
classNames='
|
|
99
|
+
classNames='w-6 h-4 invisible data-[visible=show]:visible animate-spin-slow'
|
|
99
100
|
data-visible={activity ? 'show' : 'hide'}
|
|
100
101
|
/>
|
|
101
|
-
<span className='truncate min-
|
|
102
|
+
<span className='truncate min-w-0' aria-live='polite'>
|
|
102
103
|
{activity ? children : null}
|
|
103
104
|
</span>
|
|
104
|
-
<span className={mx('text-end', hoverableControlItem)}>{t('enter
|
|
105
|
+
<span className={mx('text-end', hoverableControlItem)}>{t('enter-to-send.message')}</span>
|
|
105
106
|
</div>
|
|
106
107
|
);
|
|
107
108
|
},
|
|
@@ -113,4 +114,4 @@ export const Thread = {
|
|
|
113
114
|
Status: ThreadStatus,
|
|
114
115
|
};
|
|
115
116
|
|
|
116
|
-
export type { ThreadRootProps, ThreadHeaderProps
|
|
117
|
+
export type { ThreadRootProps, ThreadHeaderProps, ThreadStatusProps };
|
package/src/testing.tsx
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/
|
|
7
|
+
import { IconButton } from '@dxos/react-ui';
|
|
8
|
+
import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
10
|
import { MessageBody, MessageHeading } from './Message';
|
|
11
11
|
import { type MessageMetadata } from './types';
|
|
@@ -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
|
-
<
|
|
28
|
+
<IconButton
|
|
29
|
+
icon='ph--x--regular'
|
|
30
|
+
iconOnly
|
|
31
|
+
label='Delete'
|
|
29
32
|
variant='ghost'
|
|
30
|
-
classNames={['p-1.5 min-
|
|
33
|
+
classNames={['p-1.5 min-h-0 me-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>
|
|
@@ -49,7 +50,7 @@ export const MessageStoryBlock = <PartValue,>({ part }: MessagePartProps<PartVal
|
|
|
49
50
|
role='none'
|
|
50
51
|
className={mx('grid grid-cols-subgrid col-span-3', hoverableControls, hoverableFocusedWithinControls)}
|
|
51
52
|
>
|
|
52
|
-
<pre className='font-mono max-
|
|
53
|
+
<pre className='font-mono max-w-full overflow-x-auto col-span-3'>
|
|
53
54
|
<code>{JSON.stringify(part, undefined, 2)}</code>
|
|
54
55
|
</pre>
|
|
55
56
|
</div>
|
package/src/translations.ts
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
export const translationKey = 'react-ui-thread';
|
|
7
|
+
export const translationKey = '@dxos/react-ui-thread';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
12
|
[translationKey]: {
|
|
13
|
-
'plugin
|
|
14
|
-
'thread
|
|
15
|
-
'thread
|
|
16
|
-
'delete
|
|
17
|
-
'create
|
|
18
|
-
'message
|
|
19
|
-
'comment
|
|
20
|
-
'settings
|
|
21
|
-
'anonymous
|
|
22
|
-
'enter
|
|
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
|
},
|