@dxos/react-ui-thread 0.8.4-main.f5c0578 → 0.8.4-main.fcc0d83b33
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 +133 -199
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +25 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- 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/index.d.ts +0 -2
- package/dist/types/src/index.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 +36 -27
- package/src/Message/Message.stories.tsx +19 -13
- package/src/Message/Message.tsx +18 -16
- package/src/Thread/Comments.stories.tsx +82 -51
- package/src/Thread/Thread.stories.tsx +20 -16
- package/src/Thread/Thread.tsx +21 -19
- package/src/index.ts +0 -3
- 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,27 @@
|
|
|
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
|
+
|
|
10
|
+
import { translationKey } from '#translations';
|
|
9
11
|
|
|
10
|
-
import { translationKey } from '../translations';
|
|
11
12
|
import type { ThreadEntity } from '../types';
|
|
12
13
|
|
|
13
|
-
// TODO(burdon):
|
|
14
|
-
export const threadLayout = '
|
|
14
|
+
// TODO(burdon): Avoid exporting fragments.
|
|
15
|
+
export const threadLayout = 'w-full place-self-start grid grid-cols-[var(--dx-rail-size)_1fr]';
|
|
15
16
|
|
|
16
17
|
//
|
|
17
18
|
// Root
|
|
18
19
|
//
|
|
19
20
|
|
|
20
|
-
type ThreadRootProps = ThemedClassName<
|
|
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) => {
|
|
@@ -30,7 +35,7 @@ const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
|
|
|
30
35
|
className={mx(
|
|
31
36
|
threadLayout,
|
|
32
37
|
hoverableFocusedWithinControls,
|
|
33
|
-
'bg-[var(--surface-bg)] current-related attention-surface [--controls-opacity:0]',
|
|
38
|
+
'bg-[var(--surface-bg)] current-related dx-attention-surface [--controls-opacity:0]',
|
|
34
39
|
classNames,
|
|
35
40
|
)}
|
|
36
41
|
ref={forwardedRef}
|
|
@@ -45,10 +50,10 @@ const ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(
|
|
|
45
50
|
// Heading
|
|
46
51
|
//
|
|
47
52
|
|
|
48
|
-
type ThreadHeaderProps =
|
|
53
|
+
type ThreadHeaderProps = PropsWithChildren<{ detached?: boolean }>;
|
|
49
54
|
|
|
50
55
|
const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
51
|
-
({
|
|
56
|
+
({ children, detached, ...props }, forwardedRef) => {
|
|
52
57
|
return (
|
|
53
58
|
<>
|
|
54
59
|
<div role='none' className='flex items-center justify-center text-description'>
|
|
@@ -59,10 +64,7 @@ const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
|
59
64
|
role='heading'
|
|
60
65
|
data-testid='thread.heading'
|
|
61
66
|
{...props}
|
|
62
|
-
className={mx(
|
|
63
|
-
'mie-2 text-description font-medium truncate italic',
|
|
64
|
-
detached && 'line-through decoration-1',
|
|
65
|
-
)}
|
|
67
|
+
className={mx('me-2 text-description font-medium truncate italic', detached && 'line-through decoration-1')}
|
|
66
68
|
ref={forwardedRef}
|
|
67
69
|
>
|
|
68
70
|
{children}
|
|
@@ -77,7 +79,7 @@ const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
|
|
|
77
79
|
// Status
|
|
78
80
|
//
|
|
79
81
|
|
|
80
|
-
type ThreadStatusProps = ThemedClassName<
|
|
82
|
+
type ThreadStatusProps = ThemedClassName<PropsWithChildren> & {
|
|
81
83
|
activity?: boolean;
|
|
82
84
|
};
|
|
83
85
|
|
|
@@ -88,20 +90,20 @@ const ThreadStatus = forwardRef<HTMLDivElement, ThreadStatusProps>(
|
|
|
88
90
|
<div
|
|
89
91
|
{...props}
|
|
90
92
|
className={mx(
|
|
91
|
-
'col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2
|
|
93
|
+
'col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2 pe-2 text-xs text-description',
|
|
92
94
|
classNames,
|
|
93
95
|
)}
|
|
94
96
|
ref={forwardedRef}
|
|
95
97
|
>
|
|
96
98
|
<Icon
|
|
97
99
|
icon='ph--spinner--bold'
|
|
98
|
-
classNames='
|
|
100
|
+
classNames='w-6 h-4 invisible data-[visible=show]:visible animate-spin-slow'
|
|
99
101
|
data-visible={activity ? 'show' : 'hide'}
|
|
100
102
|
/>
|
|
101
|
-
<span className='truncate min-
|
|
103
|
+
<span className='truncate min-w-0' aria-live='polite'>
|
|
102
104
|
{activity ? children : null}
|
|
103
105
|
</span>
|
|
104
|
-
<span className={mx('text-end', hoverableControlItem)}>{t('enter
|
|
106
|
+
<span className={mx('text-end', hoverableControlItem)}>{t('enter-to-send.message')}</span>
|
|
105
107
|
</div>
|
|
106
108
|
);
|
|
107
109
|
},
|
|
@@ -113,4 +115,4 @@ export const Thread = {
|
|
|
113
115
|
Status: ThreadStatus,
|
|
114
116
|
};
|
|
115
117
|
|
|
116
|
-
export type { ThreadRootProps, ThreadHeaderProps
|
|
118
|
+
export type { ThreadRootProps, ThreadHeaderProps, ThreadStatusProps };
|
package/src/index.ts
CHANGED
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
|
},
|