@dxos/react-ui-thread 0.8.4-main.e8ec1fe → 0.8.4-main.effb148878

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.
Files changed (34) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +120 -197
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/translations.mjs +25 -0
  6. package/dist/lib/browser/translations.mjs.map +7 -0
  7. package/dist/types/src/Message/Message.d.ts +2 -2
  8. package/dist/types/src/Message/Message.d.ts.map +1 -1
  9. package/dist/types/src/Message/Message.stories.d.ts +11 -11
  10. package/dist/types/src/Message/Message.stories.d.ts.map +1 -1
  11. package/dist/types/src/Thread/Comments.stories.d.ts +13 -13
  12. package/dist/types/src/Thread/Comments.stories.d.ts.map +1 -1
  13. package/dist/types/src/Thread/Thread.d.ts +25 -11
  14. package/dist/types/src/Thread/Thread.d.ts.map +1 -1
  15. package/dist/types/src/Thread/Thread.stories.d.ts +16 -12
  16. package/dist/types/src/Thread/Thread.stories.d.ts.map +1 -1
  17. package/dist/types/src/index.d.ts +0 -2
  18. package/dist/types/src/index.d.ts.map +1 -1
  19. package/dist/types/src/testing.d.ts.map +1 -1
  20. package/dist/types/src/translations.d.ts +12 -12
  21. package/dist/types/src/translations.d.ts.map +1 -1
  22. package/dist/types/src/types.d.ts +1 -0
  23. package/dist/types/src/types.d.ts.map +1 -1
  24. package/dist/types/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +37 -28
  26. package/src/Message/Message.stories.tsx +6 -6
  27. package/src/Message/Message.tsx +16 -19
  28. package/src/Thread/Comments.stories.tsx +52 -34
  29. package/src/Thread/Thread.stories.tsx +10 -10
  30. package/src/Thread/Thread.tsx +22 -20
  31. package/src/index.ts +0 -3
  32. package/src/testing.tsx +4 -7
  33. package/src/translations.ts +11 -11
  34. package/src/types.ts +1 -0
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -1,90 +1,52 @@
1
- // src/translations.ts
2
- var translationKey = "react-ui-thread";
3
- var translations = [
4
- {
5
- "en-US": {
6
- [translationKey]: {
7
- "plugin name": "Threads",
8
- "thread title placeholder": "New thread",
9
- "thread title label": "Title",
10
- "delete thread label": "Delete",
11
- "create thread label": "Create thread",
12
- "message placeholder": "Enter message...",
13
- "comment placeholder": "Enter comment...",
14
- "settings standalone label": "Enable standalone thread creation",
15
- "anonymous label": "Anonymous",
16
- "enter to send message": "Enter to add \u23CE"
17
- }
18
- }
19
- }
20
- ];
21
-
22
1
  // src/Thread/Thread.tsx
23
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
24
2
  import React, { forwardRef } from "react";
25
3
  import { Icon, useTranslation } from "@dxos/react-ui";
26
- import { hoverableControlItem, hoverableFocusedWithinControls, mx } from "@dxos/react-ui-theme";
27
- var threadLayout = "is-full place-self-start grid grid-cols-[var(--rail-size)_1fr]";
4
+ import { hoverableControlItem, hoverableFocusedWithinControls, mx } from "@dxos/ui-theme";
5
+ import { translationKey } from "#translations";
6
+ var threadLayout = "w-full place-self-start grid grid-cols-[var(--dx-rail-size)_1fr]";
28
7
  var ThreadRoot = /* @__PURE__ */ forwardRef(({ current, children, classNames, ...props }, forwardedRef) => {
29
- var _effect = _useSignals();
30
- try {
31
- return /* @__PURE__ */ React.createElement("div", {
32
- role: "group",
33
- "data-testid": "thread",
34
- ...current && {
35
- "aria-current": typeof current === "string" ? current : "location"
36
- },
37
- ...props,
38
- className: mx(threadLayout, hoverableFocusedWithinControls, "bg-[var(--surface-bg)] current-related attention-surface [--controls-opacity:0]", classNames),
39
- ref: forwardedRef
40
- }, children);
41
- } finally {
42
- _effect.f();
43
- }
8
+ return /* @__PURE__ */ React.createElement("div", {
9
+ role: "group",
10
+ "data-testid": "thread",
11
+ ...current && {
12
+ "aria-current": typeof current === "string" ? current : "location"
13
+ },
14
+ ...props,
15
+ className: mx(threadLayout, hoverableFocusedWithinControls, "bg-[var(--surface-bg)] current-related dx-attention-surface [--controls-opacity:0]", classNames),
16
+ ref: forwardedRef
17
+ }, children);
44
18
  });
45
19
  var ThreadHeader = /* @__PURE__ */ forwardRef(({ children, detached, ...props }, forwardedRef) => {
46
- var _effect = _useSignals();
47
- try {
48
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
49
- role: "none",
50
- className: "flex items-center justify-center text-description"
51
- }, /* @__PURE__ */ React.createElement(Icon, {
52
- icon: "ph--caret-double-right--regular"
53
- })), /* @__PURE__ */ React.createElement("div", {
54
- role: "none",
55
- className: "flex items-center overflow-hidden"
56
- }, /* @__PURE__ */ React.createElement("p", {
57
- role: "heading",
58
- "data-testid": "thread.heading",
59
- ...props,
60
- className: mx("mie-2 text-description font-medium truncate italic", detached && "line-through decoration-1"),
61
- ref: forwardedRef
62
- }, children)));
63
- } finally {
64
- _effect.f();
65
- }
20
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
21
+ className: "flex items-center justify-center text-description"
22
+ }, /* @__PURE__ */ React.createElement(Icon, {
23
+ icon: "ph--caret-double-right--regular"
24
+ })), /* @__PURE__ */ React.createElement("div", {
25
+ className: "flex items-center overflow-hidden"
26
+ }, /* @__PURE__ */ React.createElement("p", {
27
+ role: "heading",
28
+ "data-testid": "thread.heading",
29
+ ...props,
30
+ className: mx("me-2 text-description font-medium truncate italic", detached && "line-through decoration-1"),
31
+ ref: forwardedRef
32
+ }, children)));
66
33
  });
67
34
  var ThreadStatus = /* @__PURE__ */ forwardRef(({ activity, classNames, children, ...props }, forwardedRef) => {
68
- var _effect = _useSignals();
69
- try {
70
- const { t } = useTranslation(translationKey);
71
- return /* @__PURE__ */ React.createElement("div", {
72
- ...props,
73
- className: mx("col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2 pie-2 text-xs text-description", classNames),
74
- ref: forwardedRef
75
- }, /* @__PURE__ */ React.createElement(Icon, {
76
- icon: "ph--spinner--bold",
77
- classNames: "is-6 bs-4 invisible data-[visible=show]:visible animate-spin-slow",
78
- "data-visible": activity ? "show" : "hide"
79
- }), /* @__PURE__ */ React.createElement("span", {
80
- className: "truncate min-is-0",
81
- "aria-live": "polite"
82
- }, activity ? children : null), /* @__PURE__ */ React.createElement("span", {
83
- className: mx("text-end", hoverableControlItem)
84
- }, t("enter to send message")));
85
- } finally {
86
- _effect.f();
87
- }
35
+ const { t } = useTranslation(translationKey);
36
+ return /* @__PURE__ */ React.createElement("div", {
37
+ ...props,
38
+ className: mx("col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2 pe-2 text-xs text-description", classNames),
39
+ ref: forwardedRef
40
+ }, /* @__PURE__ */ React.createElement(Icon, {
41
+ icon: "ph--spinner--bold",
42
+ classNames: "w-6 h-4 invisible data-[visible=show]:visible animate-spin-slow",
43
+ "data-visible": activity ? "show" : "hide"
44
+ }), /* @__PURE__ */ React.createElement("span", {
45
+ className: "truncate min-w-0",
46
+ "aria-live": "polite"
47
+ }, activity ? children : null), /* @__PURE__ */ React.createElement("span", {
48
+ className: mx("text-end", hoverableControlItem)
49
+ }, t("enter-to-send.message")));
88
50
  });
89
51
  var Thread = {
90
52
  Root: ThreadRoot,
@@ -93,99 +55,67 @@ var Thread = {
93
55
  };
94
56
 
95
57
  // src/Message/Message.tsx
96
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
97
58
  import { formatDistanceToNow } from "date-fns/formatDistanceToNow";
98
59
  import React2, { forwardRef as forwardRef2 } from "react";
99
60
  import { Avatar, useTranslation as useTranslation2 } from "@dxos/react-ui";
100
- import { keymap, listener, useTextEditor } from "@dxos/react-ui-editor";
101
- import { focusRing, mx as mx2 } from "@dxos/react-ui-theme";
61
+ import { useTextEditor } from "@dxos/react-ui-editor";
62
+ import { keymap, listener } from "@dxos/ui-editor";
63
+ import { mx as mx2 } from "@dxos/ui-theme";
102
64
  import { hexToEmoji, hexToHue, isTruthy } from "@dxos/util";
65
+ import { translationKey as translationKey2 } from "#translations";
103
66
  var avatarSize = 7;
104
67
  var MessageRoot = /* @__PURE__ */ forwardRef2(({ authorImgSrc, authorId, authorName, authorAvatarProps, continues = true, children, classNames, ...rootProps }, forwardedRef) => {
105
- var _effect = _useSignals2();
106
- try {
107
- return (
108
- // Must wrap the message since Avatar.Label may be used in the content.
109
- /* @__PURE__ */ React2.createElement(Avatar.Root, null, /* @__PURE__ */ React2.createElement("div", {
110
- role: "none",
111
- "data-testid": "thread.message",
112
- ...rootProps,
113
- className: mx2("grid grid-cols-subgrid col-span-2", classNames),
114
- ref: forwardedRef
115
- }, /* @__PURE__ */ React2.createElement("div", {
116
- role: "none",
117
- className: "flex flex-col items-center gap-2 pbs-1"
118
- }, /* @__PURE__ */ React2.createElement(Avatar.Content, {
119
- size: avatarSize,
120
- hue: authorAvatarProps?.hue || hexToHue(authorId ?? "0"),
121
- fallback: authorAvatarProps?.emoji || hexToEmoji(authorId ?? "0"),
122
- ...authorImgSrc && {
123
- imgSrc: authorImgSrc
124
- }
125
- }), continues && /* @__PURE__ */ React2.createElement("div", {
126
- role: "none",
127
- className: "is-px grow bg-separator"
128
- })), /* @__PURE__ */ React2.createElement("div", {
129
- role: "none",
130
- className: "plb-1 min-is-0"
131
- }, children)))
132
- );
133
- } finally {
134
- _effect.f();
135
- }
68
+ return /* @__PURE__ */ React2.createElement(Avatar.Root, null, /* @__PURE__ */ React2.createElement("div", {
69
+ "data-testid": "thread.message",
70
+ ...rootProps,
71
+ className: mx2("grid grid-cols-subgrid col-span-2", classNames),
72
+ ref: forwardedRef
73
+ }, /* @__PURE__ */ React2.createElement("div", {
74
+ className: "flex flex-col items-center gap-2 pt-1"
75
+ }, /* @__PURE__ */ React2.createElement(Avatar.Content, {
76
+ size: avatarSize,
77
+ hue: authorAvatarProps?.hue || hexToHue(authorId ?? "0"),
78
+ fallback: authorAvatarProps?.emoji || hexToEmoji(authorId ?? "0"),
79
+ ...authorImgSrc && {
80
+ imgSrc: authorImgSrc
81
+ }
82
+ }), continues && /* @__PURE__ */ React2.createElement("div", {
83
+ className: "w-px grow bg-separator"
84
+ })), /* @__PURE__ */ React2.createElement("div", {
85
+ className: "py-1 min-w-0"
86
+ }, children)));
136
87
  });
137
88
  var MessageHeading = ({ children, classNames, timestamp, authorName, ...props }) => {
138
- var _effect = _useSignals2();
139
- try {
140
- return /* @__PURE__ */ React2.createElement("div", {
141
- role: "none",
142
- ...props,
143
- className: mx2("flex gap-2 items-start", classNames)
144
- }, /* @__PURE__ */ React2.createElement("p", {
145
- className: "grow"
146
- }, /* @__PURE__ */ React2.createElement(MessageAuthorName, {
147
- authorName
148
- }), timestamp && /* @__PURE__ */ React2.createElement(MessageTime, {
149
- timestamp
150
- })), children);
151
- } finally {
152
- _effect.f();
153
- }
89
+ return /* @__PURE__ */ React2.createElement("div", {
90
+ ...props,
91
+ className: mx2("flex gap-2 items-start", classNames)
92
+ }, /* @__PURE__ */ React2.createElement("p", {
93
+ className: "grow"
94
+ }, /* @__PURE__ */ React2.createElement(MessageAuthorName, {
95
+ authorName
96
+ }), timestamp && /* @__PURE__ */ React2.createElement(MessageTime, {
97
+ timestamp
98
+ })), children);
154
99
  };
155
100
  var MessageAuthorName = ({ authorName }) => {
156
- var _effect = _useSignals2();
157
- try {
158
- const { t } = useTranslation2(translationKey);
159
- return /* @__PURE__ */ React2.createElement(Avatar.Label, {
160
- classNames: "block truncate text-sm text-subdued"
161
- }, authorName ?? t("anonymous label"));
162
- } finally {
163
- _effect.f();
164
- }
101
+ const { t } = useTranslation2(translationKey2);
102
+ return /* @__PURE__ */ React2.createElement(Avatar.Label, {
103
+ classNames: "block truncate text-sm text-subdued"
104
+ }, authorName ?? t("anonymous.label"));
165
105
  };
166
106
  var MessageTime = ({ timestamp }) => {
167
- var _effect = _useSignals2();
168
- try {
169
- const { dtLocale } = useTranslation2(translationKey);
170
- const dt = timestamp ? new Date(timestamp) : void 0;
171
- return /* @__PURE__ */ React2.createElement("time", {
172
- className: "block text-subdued text-xs pbe-0.5",
173
- dateTime: dt?.toISOString()
174
- }, dt ? formatDistanceToNow(dt, {
175
- locale: dtLocale,
176
- addSuffix: true
177
- }) : "");
178
- } finally {
179
- _effect.f();
180
- }
107
+ const { dtLocale } = useTranslation2(translationKey2);
108
+ const dt = timestamp ? new Date(timestamp) : void 0;
109
+ return /* @__PURE__ */ React2.createElement("time", {
110
+ className: "block text-subdued text-xs pb-0.5",
111
+ dateTime: dt?.toISOString()
112
+ }, dt ? formatDistanceToNow(dt, {
113
+ locale: dtLocale,
114
+ addSuffix: true
115
+ }) : "");
181
116
  };
182
117
  var MessageBody = ({ children, ...props }) => {
183
- var _effect = _useSignals2();
184
- try {
185
- return /* @__PURE__ */ React2.createElement("p", props, children);
186
- } finally {
187
- _effect.f();
188
- }
118
+ return /* @__PURE__ */ React2.createElement("p", props, children);
189
119
  };
190
120
  var keyBindings = ({ onSend, onClear }) => [
191
121
  {
@@ -213,45 +143,39 @@ var keyBindings = ({ onSend, onClear }) => [
213
143
  }
214
144
  ];
215
145
  var MessageTextbox = ({ id, authorId, authorName, authorImgSrc, authorAvatarProps, disabled, extensions, onSend, onClear, onEditorFocus, ...editorProps }) => {
216
- var _effect = _useSignals2();
217
- try {
218
- const { parentRef, focusAttributes } = useTextEditor(() => ({
219
- id,
220
- extensions: [
221
- keymap.of(keyBindings({
222
- onSend,
223
- onClear
224
- })),
225
- listener({
226
- onFocus: ({ focusing }) => {
227
- if (focusing) {
228
- onEditorFocus?.();
229
- }
146
+ const { parentRef, focusAttributes } = useTextEditor(() => ({
147
+ id,
148
+ extensions: [
149
+ keymap.of(keyBindings({
150
+ onSend,
151
+ onClear
152
+ })),
153
+ listener({
154
+ onFocus: ({ focusing }) => {
155
+ if (focusing) {
156
+ onEditorFocus?.();
230
157
  }
231
- }),
232
- extensions
233
- ].filter(isTruthy),
234
- ...editorProps
235
- }), [
236
- id,
158
+ }
159
+ }),
237
160
  extensions
238
- ]);
239
- return /* @__PURE__ */ React2.createElement(MessageRoot, {
240
- id,
241
- authorId,
242
- authorName,
243
- authorImgSrc,
244
- authorAvatarProps,
245
- continues: false
246
- }, /* @__PURE__ */ React2.createElement("div", {
247
- role: "none",
248
- ref: parentRef,
249
- className: mx2("plb-0.5 mie-1 rounded-sm", focusRing, disabled && "opacity-50"),
250
- ...focusAttributes
251
- }));
252
- } finally {
253
- _effect.f();
254
- }
161
+ ].filter(isTruthy),
162
+ ...editorProps
163
+ }), [
164
+ id,
165
+ extensions
166
+ ]);
167
+ return /* @__PURE__ */ React2.createElement(MessageRoot, {
168
+ id,
169
+ authorId,
170
+ authorName,
171
+ authorImgSrc,
172
+ authorAvatarProps,
173
+ continues: false
174
+ }, /* @__PURE__ */ React2.createElement("div", {
175
+ ref: parentRef,
176
+ className: mx2("py-0.5 me-1 rounded-xs dx-focus-ring", disabled && "opacity-50"),
177
+ ...focusAttributes
178
+ }));
255
179
  };
256
180
  export {
257
181
  MessageAuthorName,
@@ -261,7 +185,6 @@ export {
261
185
  MessageTextbox,
262
186
  MessageTime,
263
187
  Thread,
264
- threadLayout,
265
- translations
188
+ threadLayout
266
189
  };
267
190
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/translations.ts", "../../../src/Thread/Thread.tsx", "../../../src/Message/Message.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nexport const translationKey = 'react-ui-thread';\n\nexport const translations = [\n {\n 'en-US': {\n [translationKey]: {\n 'plugin name': 'Threads',\n 'thread title placeholder': 'New thread',\n 'thread title label': 'Title',\n 'delete thread label': 'Delete',\n 'create thread label': 'Create thread',\n 'message placeholder': 'Enter message...',\n 'comment placeholder': 'Enter comment...',\n 'settings standalone label': 'Enable standalone thread creation',\n 'anonymous label': 'Anonymous',\n 'enter to send message': 'Enter to add ⏎',\n },\n },\n },\n] as const satisfies Resource[];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { Icon, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/react-ui-theme';\n\nimport { translationKey } from '../translations';\nimport type { ThreadEntity } from '../types';\n\n// TODO(burdon): Why is this exported?\nexport const threadLayout = 'is-full place-self-start grid grid-cols-[var(--rail-size)_1fr]';\n\n//\n// Root\n//\n\ntype ThreadRootProps = ThemedClassName<ComponentPropsWithRef<'div'>> & ThreadEntity & { current?: boolean };\n\nconst ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(\n ({ current, children, classNames, ...props }, forwardedRef) => {\n return (\n <div\n role='group'\n data-testid='thread'\n {...(current && { 'aria-current': typeof current === 'string' ? current : 'location' })}\n {...props}\n className={mx(\n threadLayout,\n hoverableFocusedWithinControls,\n 'bg-[var(--surface-bg)] current-related attention-surface [--controls-opacity:0]',\n classNames,\n )}\n ref={forwardedRef}\n >\n {children}\n </div>\n );\n },\n);\n\n//\n// Heading\n//\n\ntype ThreadHeaderProps = ComponentPropsWithRef<'div'> & { detached?: boolean };\n\nconst ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(\n ({ children, detached, ...props }, forwardedRef) => {\n return (\n <>\n <div role='none' className='flex items-center justify-center text-description'>\n <Icon icon='ph--caret-double-right--regular' />\n </div>\n <div role='none' className='flex items-center overflow-hidden'>\n <p\n role='heading'\n data-testid='thread.heading'\n {...props}\n className={mx(\n 'mie-2 text-description font-medium truncate italic',\n detached && 'line-through decoration-1',\n )}\n ref={forwardedRef}\n >\n {children}\n </p>\n </div>\n </>\n );\n },\n);\n\n//\n// Status\n//\n\ntype ThreadStatusProps = ThemedClassName<ComponentPropsWithRef<'div'>> & {\n activity?: boolean;\n};\n\nconst ThreadStatus = forwardRef<HTMLDivElement, ThreadStatusProps>(\n ({ activity, classNames, children, ...props }, forwardedRef) => {\n const { t } = useTranslation(translationKey);\n return (\n <div\n {...props}\n className={mx(\n 'col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2 pie-2 text-xs text-description',\n classNames,\n )}\n ref={forwardedRef}\n >\n <Icon\n icon='ph--spinner--bold'\n classNames='is-6 bs-4 invisible data-[visible=show]:visible animate-spin-slow'\n data-visible={activity ? 'show' : 'hide'}\n />\n <span className='truncate min-is-0' aria-live='polite'>\n {activity ? children : null}\n </span>\n <span className={mx('text-end', hoverableControlItem)}>{t('enter to send message')}</span>\n </div>\n );\n },\n);\n\nexport const Thread = {\n Root: ThreadRoot,\n Header: ThreadHeader,\n Status: ThreadStatus,\n};\n\nexport type { ThreadRootProps, ThreadHeaderProps as ThreadHeadingProps, ThreadStatusProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { formatDistanceToNow } from 'date-fns/formatDistanceToNow';\nimport React, { type ComponentPropsWithRef, type ComponentPropsWithoutRef, forwardRef } from 'react';\n\n// TODO(burdon): Remove dep.\nimport { Avatar, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type UseTextEditorProps, keymap, listener, useTextEditor } from '@dxos/react-ui-editor';\nimport { focusRing, mx } from '@dxos/react-ui-theme';\nimport { hexToEmoji, hexToHue, isTruthy } from '@dxos/util';\n\nimport { translationKey } from '../translations';\nimport { type MessageMetadata } from '../types';\n\nconst avatarSize = 7;\n\nexport type MessageRootProps = ThemedClassName<ComponentPropsWithRef<'div'>> &\n MessageMetadata &\n Partial<{ continues: boolean }>;\n\n// TODO(burdon): Show authorName on tooltip.\nexport const MessageRoot = forwardRef<HTMLDivElement, MessageRootProps>(\n (\n { authorImgSrc, authorId, authorName, authorAvatarProps, continues = true, children, classNames, ...rootProps },\n forwardedRef,\n ) => {\n return (\n // Must wrap the message since Avatar.Label may be used in the content.\n <Avatar.Root>\n <div\n role='none'\n data-testid='thread.message'\n {...rootProps}\n className={mx('grid grid-cols-subgrid col-span-2', classNames)}\n ref={forwardedRef}\n >\n <div role='none' className='flex flex-col items-center gap-2 pbs-1'>\n <Avatar.Content\n size={avatarSize}\n hue={authorAvatarProps?.hue || hexToHue(authorId ?? '0')}\n fallback={authorAvatarProps?.emoji || hexToEmoji(authorId ?? '0')}\n {...(authorImgSrc && { imgSrc: authorImgSrc })}\n />\n {continues && <div role='none' className='is-px grow bg-separator' />}\n </div>\n <div role='none' className='plb-1 min-is-0'>\n {children}\n </div>\n </div>\n </Avatar.Root>\n );\n },\n);\n\nexport type MessageHeadingProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> &\n Pick<MessageMetadata, 'authorName' | 'timestamp'>;\n\nexport const MessageHeading = ({ children, classNames, timestamp, authorName, ...props }: MessageHeadingProps) => {\n return (\n <div role='none' {...props} className={mx('flex gap-2 items-start', classNames)}>\n <p className='grow'>\n <MessageAuthorName authorName={authorName} />\n {timestamp && <MessageTime timestamp={timestamp} />}\n </p>\n {children}\n </div>\n );\n};\n\nexport type MessageAuthorNameProps = Pick<MessageMetadata, 'authorName'>;\n\nexport const MessageAuthorName = ({ authorName }: MessageAuthorNameProps) => {\n const { t } = useTranslation(translationKey);\n return (\n <Avatar.Label classNames='block truncate text-sm text-subdued'>{authorName ?? t('anonymous label')}</Avatar.Label>\n );\n};\n\nexport type MessageTimeProps = Pick<MessageMetadata, 'timestamp'>;\n\nexport const MessageTime = ({ timestamp }: MessageTimeProps) => {\n const { dtLocale } = useTranslation(translationKey);\n const dt = timestamp ? new Date(timestamp) : undefined;\n return (\n <time className='block text-subdued text-xs pbe-0.5' dateTime={dt?.toISOString()}>\n {dt ? formatDistanceToNow(dt, { locale: dtLocale, addSuffix: true }) : ''}\n </time>\n );\n};\n\nexport type MessageBodyProps = ComponentPropsWithoutRef<'p'>;\n\nexport const MessageBody = ({ children, ...props }: MessageBodyProps) => {\n return <p {...props}>{children}</p>;\n};\n\nexport type MessageTextboxProps = {\n disabled?: boolean;\n onSend?: () => void;\n onClear?: () => void;\n onEditorFocus?: () => void;\n} & MessageMetadata &\n UseTextEditorProps;\n\nconst keyBindings = ({ onSend, onClear }: Pick<MessageTextboxProps, 'onSend' | 'onClear'>) => [\n {\n key: 'Enter',\n run: () => {\n if (onSend) {\n onSend();\n return true;\n } else {\n return false;\n }\n },\n },\n {\n // TODO(burdon): Other key bindings.\n key: 'Meta+Backspace',\n run: () => {\n if (onClear) {\n onClear();\n return true;\n } else {\n return false;\n }\n },\n },\n];\n\nexport const MessageTextbox = ({\n id,\n authorId,\n authorName,\n authorImgSrc,\n authorAvatarProps,\n disabled,\n extensions,\n onSend,\n onClear,\n onEditorFocus,\n ...editorProps\n}: MessageTextboxProps) => {\n const { parentRef, focusAttributes } = useTextEditor(\n () => ({\n id,\n extensions: [\n keymap.of(keyBindings({ onSend, onClear })),\n listener({\n onFocus: ({ focusing }) => {\n if (focusing) {\n onEditorFocus?.();\n }\n },\n }),\n extensions,\n ].filter(isTruthy),\n ...editorProps,\n }),\n [id, extensions],\n );\n\n return (\n <MessageRoot {...{ id, authorId, authorName, authorImgSrc, authorAvatarProps }} continues={false}>\n <div\n role='none'\n ref={parentRef}\n className={mx('plb-0.5 mie-1 rounded-sm', focusRing, disabled && 'opacity-50')}\n {...focusAttributes}\n />\n </MessageRoot>\n );\n};\n"],
5
- "mappings": ";AAMO,IAAMA,iBAAiB;AAEvB,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACD,cAAAA,GAAiB;QAChB,eAAe;QACf,4BAA4B;QAC5B,sBAAsB;QACtB,uBAAuB;QACvB,uBAAuB;QACvB,uBAAuB;QACvB,uB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AAO;AACL,eAAO;MACT;IACF;EACF;EACA;;IAEEE,KAAK;IACLC,KAAK,MAAA;AACH,UAAIF,SAAS;AACXA,gBAAAA;AACA,eAAO;MACT,OAAO;AACL,eAAO;MACT;IACF;EACF;;AAGK,IAAMG,iBAAiB,CAAC,EAC7BC,IACApD,UACAC,YACAF,cACAG,mBACAmD,UACAC,YACAP,QACAC,SACAO,eACA,GAAGC,YAAAA,MACiB;;;AACpB,UAAM,EAAEC,WAAWC,gBAAe,IAAKC,cACrC,OAAO;MACLP;MACAE,YAAY;QACVM,OAAOC,GAAGf,YAAY;UAAEC;UAAQC;QAAQ,CAAA,CAAA;QACxCc,SAAS;UACPC,SAAS,CAAC,EAAEC,SAAQ,MAAE;AACpB,gBAAIA,UAAU;AACZT,8BAAAA;YACF;UACF;QACF,CAAA;QACAD;QACAW,OAAOC,QAAAA;MACT,GAAGV;IACL,IACA;MAACJ;MAAIE;KAAW;AAGlB,WACE,gBAAA9C,OAAA,cAACX,aAAAA;MAAkBuD;MAAIpD;MAAUC;MAAYF;MAAcG;MAAqBC,WAAW;OACzF,gBAAAK,OAAA,cAACG,OAAAA;MACCC,MAAK;MACLI,KAAKyC;MACL3C,WAAWC,IAAG,4BAA4BoD,WAAWd,YAAY,YAAA;MAChE,GAAGK;;;;;AAIZ;",
6
- "names": ["translationKey", "translations", "React", "forwardRef", "Icon", "useTranslation", "hoverableControlItem", "hoverableFocusedWithinControls", "mx", "threadLayout", "ThreadRoot", "forwardRef", "current", "children", "classNames", "props", "forwardedRef", "div", "role", "data-testid", "className", "mx", "hoverableFocusedWithinControls", "ref", "ThreadHeader", "detached", "Icon", "icon", "p", "ThreadStatus", "activity", "t", "useTranslation", "translationKey", "data-visible", "span", "aria-live", "hoverableControlItem", "Thread", "Root", "Header", "Status", "formatDistanceToNow", "React", "forwardRef", "Avatar", "useTranslation", "keymap", "listener", "useTextEditor", "focusRing", "mx", "hexToEmoji", "hexToHue", "isTruthy", "avatarSize", "MessageRoot", "forwardRef", "authorImgSrc", "authorId", "authorName", "authorAvatarProps", "continues", "children", "classNames", "rootProps", "forwardedRef", "React", "Avatar", "Root", "div", "role", "data-testid", "className", "mx", "ref", "Content", "size", "hue", "hexToHue", "fallback", "emoji", "hexToEmoji", "imgSrc", "MessageHeading", "timestamp", "props", "p", "MessageAuthorName", "MessageTime", "t", "useTranslation", "translationKey", "Label", "dtLocale", "dt", "Date", "undefined", "time", "dateTime", "toISOString", "formatDistanceToNow", "locale", "addSuffix", "MessageBody", "keyBindings", "onSend", "onClear", "key", "run", "MessageTextbox", "id", "disabled", "extensions", "onEditorFocus", "editorProps", "parentRef", "focusAttributes", "useTextEditor", "keymap", "of", "listener", "onFocus", "focusing", "filter", "isTruthy", "focusRing"]
3
+ "sources": ["../../../src/Thread/Thread.tsx", "../../../src/Message/Message.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { ComponentPropsWithRef, forwardRef, PropsWithChildren } from 'react';\n\nimport { Icon, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { hoverableControlItem, hoverableFocusedWithinControls, mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport type { ThreadEntity } from '../types';\n\n// TODO(burdon): Avoid exporting fragments.\nexport const threadLayout = 'w-full place-self-start grid grid-cols-[var(--dx-rail-size)_1fr]';\n\n//\n// Root\n//\n\ntype ThreadRootProps = ThemedClassName<\n PropsWithChildren<\n ThreadEntity & { current?: boolean } & Pick<ComponentPropsWithRef<'div'>, 'onClickCapture' | 'onFocusCapture'>\n >\n>;\n\nconst ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(\n ({ current, children, classNames, ...props }, forwardedRef) => {\n return (\n <div\n role='group'\n data-testid='thread'\n {...(current && { 'aria-current': typeof current === 'string' ? current : 'location' })}\n {...props}\n className={mx(\n threadLayout,\n hoverableFocusedWithinControls,\n 'bg-[var(--surface-bg)] current-related dx-attention-surface [--controls-opacity:0]',\n classNames,\n )}\n ref={forwardedRef}\n >\n {children}\n </div>\n );\n },\n);\n\n//\n// Heading\n//\n\ntype ThreadHeaderProps = PropsWithChildren<{ detached?: boolean }>;\n\nconst ThreadHeader = forwardRef<HTMLParagraphElement, ThreadHeaderProps>(\n ({ children, detached, ...props }, forwardedRef) => {\n return (\n <>\n <div className='flex items-center justify-center text-description'>\n <Icon icon='ph--caret-double-right--regular' />\n </div>\n <div className='flex items-center overflow-hidden'>\n <p\n role='heading'\n data-testid='thread.heading'\n {...props}\n className={mx('me-2 text-description font-medium truncate italic', detached && 'line-through decoration-1')}\n ref={forwardedRef}\n >\n {children}\n </p>\n </div>\n </>\n );\n },\n);\n\n//\n// Status\n//\n\ntype ThreadStatusProps = ThemedClassName<PropsWithChildren> & {\n activity?: boolean;\n};\n\nconst ThreadStatus = forwardRef<HTMLDivElement, ThreadStatusProps>(\n ({ activity, classNames, children, ...props }, forwardedRef) => {\n const { t } = useTranslation(translationKey);\n return (\n <div\n {...props}\n className={mx(\n 'col-start-2 grid grid-cols-[min-content_1fr_max-content] pb-2 pe-2 text-xs text-description',\n classNames,\n )}\n ref={forwardedRef}\n >\n <Icon\n icon='ph--spinner--bold'\n classNames='w-6 h-4 invisible data-[visible=show]:visible animate-spin-slow'\n data-visible={activity ? 'show' : 'hide'}\n />\n <span className='truncate min-w-0' aria-live='polite'>\n {activity ? children : null}\n </span>\n <span className={mx('text-end', hoverableControlItem)}>{t('enter-to-send.message')}</span>\n </div>\n );\n },\n);\n\nexport const Thread = {\n Root: ThreadRoot,\n Header: ThreadHeader,\n Status: ThreadStatus,\n};\n\nexport type { ThreadRootProps, ThreadHeaderProps, ThreadStatusProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { formatDistanceToNow } from 'date-fns/formatDistanceToNow';\nimport React, { type ComponentPropsWithRef, type ComponentPropsWithoutRef, forwardRef } from 'react';\n\nimport { Avatar, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type UseTextEditorProps, useTextEditor } from '@dxos/react-ui-editor';\nimport { keymap, listener } from '@dxos/ui-editor';\nimport { mx } from '@dxos/ui-theme';\nimport { hexToEmoji, hexToHue, isTruthy } from '@dxos/util';\n\nimport { translationKey } from '#translations';\n\nimport { type MessageMetadata } from '../types';\n\nconst avatarSize = 7;\n\nexport type MessageRootProps = ThemedClassName<\n ComponentPropsWithRef<'div'> & MessageMetadata & Partial<{ continues: boolean }>\n>;\n\n// TODO(burdon): Show authorName on tooltip.\nexport const MessageRoot = forwardRef<HTMLDivElement, MessageRootProps>(\n (\n { authorImgSrc, authorId, authorName, authorAvatarProps, continues = true, children, classNames, ...rootProps },\n forwardedRef,\n ) => {\n // Must wrap the message since Avatar.Label may be used in the content.\n return (\n <Avatar.Root>\n <div\n data-testid='thread.message'\n {...rootProps}\n className={mx('grid grid-cols-subgrid col-span-2', classNames)}\n ref={forwardedRef}\n >\n <div className='flex flex-col items-center gap-2 pt-1'>\n <Avatar.Content\n size={avatarSize}\n hue={authorAvatarProps?.hue || hexToHue(authorId ?? '0')}\n fallback={authorAvatarProps?.emoji || hexToEmoji(authorId ?? '0')}\n {...(authorImgSrc && { imgSrc: authorImgSrc })}\n />\n {continues && <div className='w-px grow bg-separator' />}\n </div>\n <div className='py-1 min-w-0'>{children}</div>\n </div>\n </Avatar.Root>\n );\n },\n);\n\nexport type MessageHeadingProps = ThemedClassName<ComponentPropsWithoutRef<'div'>> &\n Pick<MessageMetadata, 'authorName' | 'timestamp'>;\n\nexport const MessageHeading = ({ children, classNames, timestamp, authorName, ...props }: MessageHeadingProps) => {\n return (\n <div {...props} className={mx('flex gap-2 items-start', classNames)}>\n <p className='grow'>\n <MessageAuthorName authorName={authorName} />\n {timestamp && <MessageTime timestamp={timestamp} />}\n </p>\n {children}\n </div>\n );\n};\n\nexport type MessageAuthorNameProps = Pick<MessageMetadata, 'authorName'>;\n\nexport const MessageAuthorName = ({ authorName }: MessageAuthorNameProps) => {\n const { t } = useTranslation(translationKey);\n return (\n <Avatar.Label classNames='block truncate text-sm text-subdued'>{authorName ?? t('anonymous.label')}</Avatar.Label>\n );\n};\n\nexport type MessageTimeProps = Pick<MessageMetadata, 'timestamp'>;\n\nexport const MessageTime = ({ timestamp }: MessageTimeProps) => {\n const { dtLocale } = useTranslation(translationKey);\n const dt = timestamp ? new Date(timestamp) : undefined;\n return (\n <time className='block text-subdued text-xs pb-0.5' dateTime={dt?.toISOString()}>\n {dt ? formatDistanceToNow(dt, { locale: dtLocale, addSuffix: true }) : ''}\n </time>\n );\n};\n\nexport type MessageBodyProps = ComponentPropsWithoutRef<'p'>;\n\nexport const MessageBody = ({ children, ...props }: MessageBodyProps) => {\n return <p {...props}>{children}</p>;\n};\n\nexport type MessageTextboxProps = {\n disabled?: boolean;\n onSend?: () => void;\n onClear?: () => void;\n onEditorFocus?: () => void;\n} & MessageMetadata &\n UseTextEditorProps;\n\nconst keyBindings = ({ onSend, onClear }: Pick<MessageTextboxProps, 'onSend' | 'onClear'>) => [\n {\n key: 'Enter',\n run: () => {\n if (onSend) {\n onSend();\n return true;\n } else {\n return false;\n }\n },\n },\n {\n // TODO(burdon): Other key bindings.\n key: 'Meta+Backspace',\n run: () => {\n if (onClear) {\n onClear();\n return true;\n } else {\n return false;\n }\n },\n },\n];\n\nexport const MessageTextbox = ({\n id,\n authorId,\n authorName,\n authorImgSrc,\n authorAvatarProps,\n disabled,\n extensions,\n onSend,\n onClear,\n onEditorFocus,\n ...editorProps\n}: MessageTextboxProps) => {\n const { parentRef, focusAttributes } = useTextEditor(\n () => ({\n id,\n extensions: [\n keymap.of(keyBindings({ onSend, onClear })),\n listener({\n onFocus: ({ focusing }) => {\n if (focusing) {\n onEditorFocus?.();\n }\n },\n }),\n extensions,\n ].filter(isTruthy),\n ...editorProps,\n }),\n [id, extensions],\n );\n\n return (\n <MessageRoot {...{ id, authorId, authorName, authorImgSrc, authorAvatarProps }} continues={false}>\n <div\n ref={parentRef}\n className={mx('py-0.5 me-1 rounded-xs dx-focus-ring', disabled && 'opacity-50')}\n {...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A,gBAAAA;AACA,eAAO;MACT,OAAO;AACL,eAAO;MACT;IACF;EACF;;AAGK,IAAMG,iBAAiB,CAAC,EAC7BC,IACA3C,UACAC,YACAF,cACAG,mBACA0C,UACAC,YACAP,QACAC,SACAO,eACA,GAAGC,YAAAA,MACiB;AACpB,QAAM,EAAEC,WAAWC,gBAAe,IAAK5D,cACrC,OAAO;IACLsD;IACAE,YAAY;MACVvD,OAAO4D,GAAGb,YAAY;QAAEC;QAAQC;MAAQ,CAAA,CAAA;MACxChD,SAAS;QACP4D,SAAS,CAAC,EAAEC,SAAQ,MAAE;AACpB,cAAIA,UAAU;AACZN,4BAAAA;UACF;QACF;MACF,CAAA;MACAD;MACAQ,OAAO1D,QAAAA;IACT,GAAGoD;EACL,IACA;IAACJ;IAAIE;GAAW;AAGlB,SACE,gBAAA5D,OAAA,cAACa,aAAAA;IAAkB6C;IAAI3C;IAAUC;IAAYF;IAAcG;IAAqBC,WAAW;KACzF,gBAAAlB,OAAA,cAACwB,OAAAA;IACCG,KAAKoC;IACLrC,WAAWnB,IAAG,wCAAwCoD,YAAY,YAAA;IACjE,GAAGK;;AAIZ;",
6
+ "names": ["React", "forwardRef", "Icon", "useTranslation", "hoverableControlItem", "hoverableFocusedWithinControls", "mx", "translationKey", "threadLayout", "ThreadRoot", "current", "children", "classNames", "props", "forwardedRef", "div", "role", "data-testid", "className", "ref", "ThreadHeader", "detached", "icon", "p", "ThreadStatus", "activity", "t", "data-visible", "span", "aria-live", "Thread", "Root", "Header", "Status", "formatDistanceToNow", "React", "forwardRef", "Avatar", "useTranslation", "useTextEditor", "keymap", "listener", "mx", "hexToEmoji", "hexToHue", "isTruthy", "translationKey", "avatarSize", "MessageRoot", "authorImgSrc", "authorId", "authorName", "authorAvatarProps", "continues", "children", "classNames", "rootProps", "forwardedRef", "Root", "div", "data-testid", "className", "ref", "Content", "size", "hue", "fallback", "emoji", "imgSrc", "MessageHeading", "timestamp", "props", "p", "MessageAuthorName", "MessageTime", "t", "Label", "dtLocale", "dt", "Date", "undefined", "time", "dateTime", "toISOString", "locale", "addSuffix", "MessageBody", "keyBindings", "onSend", "onClear", "key", "run", "MessageTextbox", "id", "disabled", "extensions", "onEditorFocus", "editorProps", "parentRef", "focusAttributes", "of", "onFocus", "focusing", "filter"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/translations.ts":{"bytes":2466,"imports":[],"format":"esm"},"src/Thread/Thread.tsx":{"bytes":10297,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"../translations"}],"format":"esm"},"src/Thread/index.ts":{"bytes":459,"imports":[{"path":"src/Thread/Thread.tsx","kind":"import-statement","original":"./Thread"}],"format":"esm"},"src/Message/Message.tsx":{"bytes":17698,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"date-fns/formatDistanceToNow","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-editor","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/translations.ts","kind":"import-statement","original":"../translations"}],"format":"esm"},"src/Message/index.ts":{"bytes":461,"imports":[{"path":"src/Message/Message.tsx","kind":"import-statement","original":"./Message"}],"format":"esm"},"src/index.ts":{"bytes":839,"imports":[{"path":"src/translations.ts","kind":"import-statement","original":"./translations"},{"path":"src/Thread/index.ts","kind":"import-statement","original":"./Thread"},{"path":"src/Message/index.ts","kind":"import-statement","original":"./Message"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":15312},"dist/lib/browser/index.mjs":{"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"date-fns/formatDistanceToNow","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-editor","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["MessageAuthorName","MessageBody","MessageHeading","MessageRoot","MessageTextbox","MessageTime","Thread","threadLayout","translations"],"entryPoint":"src/index.ts","inputs":{"src/translations.ts":{"bytesInOutput":610},"src/Thread/Thread.tsx":{"bytesInOutput":2938},"src/Thread/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0},"src/Message/Message.tsx":{"bytesInOutput":4934},"src/Message/index.ts":{"bytesInOutput":0}},"bytes":8749}}}
1
+ {"inputs":{"src/Thread/Thread.tsx":{"bytes":9583,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true}],"format":"esm"},"src/Thread/index.ts":{"bytes":370,"imports":[{"path":"src/Thread/Thread.tsx","kind":"import-statement","original":"./Thread"}],"format":"esm"},"src/Message/Message.tsx":{"bytes":16171,"imports":[{"path":"date-fns/formatDistanceToNow","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-editor","kind":"import-statement","external":true},{"path":"@dxos/ui-editor","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true}],"format":"esm"},"src/Message/index.ts":{"bytes":375,"imports":[{"path":"src/Message/Message.tsx","kind":"import-statement","original":"./Message"}],"format":"esm"},"src/index.ts":{"bytes":497,"imports":[{"path":"src/Thread/index.ts","kind":"import-statement","original":"./Thread"},{"path":"src/Message/index.ts","kind":"import-statement","original":"./Message"}],"format":"esm"},"src/translations.ts":{"bytes":2395,"imports":[],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13727},"dist/lib/browser/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true},{"path":"date-fns/formatDistanceToNow","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-editor","kind":"import-statement","external":true},{"path":"@dxos/ui-editor","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"#translations","kind":"import-statement","external":true}],"exports":["MessageAuthorName","MessageBody","MessageHeading","MessageRoot","MessageTextbox","MessageTime","Thread","threadLayout"],"entryPoint":"src/index.ts","inputs":{"src/Thread/Thread.tsx":{"bytesInOutput":2561},"src/index.ts":{"bytesInOutput":0},"src/Message/Message.tsx":{"bytesInOutput":4076}},"bytes":6864},"dist/lib/browser/translations.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1151},"dist/lib/browser/translations.mjs":{"imports":[],"exports":["translationKey","translations"],"entryPoint":"src/translations.ts","inputs":{"src/translations.ts":{"bytesInOutput":616}},"bytes":726}}}