@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.
@@ -2,22 +2,26 @@
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
- import { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';
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): Why is this exported?
14
- export const threadLayout = 'is-full place-self-start grid grid-cols-[var(--rail-size)_1fr]';
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<ComponentPropsWithRef<'div'>> & ThreadEntity & { current?: boolean };
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 = ThemedClassName<ComponentPropsWithRef<'div'>> & { detached?: boolean };
52
+ type ThreadHeaderProps = PropsWithChildren<{ detached?: boolean }>;
49
53
 
50
54
  const ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(
51
- ({ classNames, children, detached, ...props }, forwardedRef) => {
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<ComponentPropsWithRef<'div'>> & {
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 pie-2 text-xs text-description',
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='is-6 bs-4 invisible data-[visible=show]:visible animate-spin-slow'
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-is-0' aria-live='polite'>
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 to send message')}</span>
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 as ThreadHeadingProps, ThreadStatusProps };
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 { Button, Icon } from '@dxos/react-ui';
8
- import { hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';
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
- <Button
28
+ <IconButton
29
+ icon='ph--x--regular'
30
+ iconOnly
31
+ label='Delete'
29
32
  variant='ghost'
30
- classNames={['p-1.5 min-bs-0 mie-1 items-start transition-opacity', hoverableControlItem]}
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-is-full overflow-x-auto col-span-3'>
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>
@@ -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 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
  };