@jupyter/chat 0.18.1 → 0.19.0-alpha.0

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 (78) hide show
  1. package/lib/components/attachments.js +47 -21
  2. package/lib/components/chat.d.ts +5 -0
  3. package/lib/components/chat.js +7 -6
  4. package/lib/components/code-blocks/code-toolbar.js +29 -10
  5. package/lib/components/code-blocks/copy-button.js +11 -3
  6. package/lib/components/index.d.ts +0 -1
  7. package/lib/components/index.js +0 -1
  8. package/lib/components/input/buttons/attach-button.js +7 -2
  9. package/lib/components/input/buttons/cancel-button.js +12 -10
  10. package/lib/components/input/buttons/index.d.ts +2 -0
  11. package/lib/components/input/buttons/index.js +2 -0
  12. package/lib/components/input/buttons/save-edit-button.d.ts +6 -0
  13. package/lib/components/input/buttons/save-edit-button.js +51 -0
  14. package/lib/components/input/buttons/send-button.d.ts +1 -1
  15. package/lib/components/input/buttons/send-button.js +35 -122
  16. package/lib/components/input/buttons/stop-button.d.ts +6 -0
  17. package/lib/components/input/buttons/stop-button.js +63 -0
  18. package/lib/components/input/chat-input.d.ts +15 -0
  19. package/lib/components/input/chat-input.js +109 -46
  20. package/lib/components/input/index.d.ts +1 -0
  21. package/lib/components/input/index.js +1 -0
  22. package/lib/components/input/toolbar-registry.d.ts +10 -0
  23. package/lib/components/input/toolbar-registry.js +10 -1
  24. package/lib/components/input/use-chat-commands.js +9 -4
  25. package/lib/components/input/writing-indicator.d.ts +15 -0
  26. package/lib/components/input/writing-indicator.js +50 -0
  27. package/lib/components/messages/header.d.ts +4 -0
  28. package/lib/components/messages/header.js +4 -0
  29. package/lib/components/messages/index.d.ts +0 -1
  30. package/lib/components/messages/index.js +0 -1
  31. package/lib/components/messages/message.js +1 -1
  32. package/lib/components/messages/messages.d.ts +5 -0
  33. package/lib/components/messages/messages.js +24 -14
  34. package/lib/components/messages/toolbar.js +37 -15
  35. package/lib/input-model.d.ts +14 -0
  36. package/lib/input-model.js +12 -4
  37. package/lib/model.d.ts +8 -0
  38. package/lib/model.js +6 -0
  39. package/lib/types.d.ts +4 -0
  40. package/lib/widgets/chat-sidebar.d.ts +2 -2
  41. package/lib/widgets/chat-sidebar.js +6 -8
  42. package/lib/widgets/chat-widget.d.ts +4 -0
  43. package/lib/widgets/chat-widget.js +36 -11
  44. package/lib/widgets/multichat-panel.d.ts +2 -2
  45. package/lib/widgets/multichat-panel.js +7 -5
  46. package/package.json +1 -1
  47. package/src/components/attachments.tsx +70 -33
  48. package/src/components/chat.tsx +13 -4
  49. package/src/components/code-blocks/code-toolbar.tsx +56 -28
  50. package/src/components/code-blocks/copy-button.tsx +21 -12
  51. package/src/components/index.ts +0 -1
  52. package/src/components/input/buttons/attach-button.tsx +8 -2
  53. package/src/components/input/buttons/cancel-button.tsx +20 -15
  54. package/src/components/input/buttons/index.ts +2 -0
  55. package/src/components/input/buttons/save-edit-button.tsx +75 -0
  56. package/src/components/input/buttons/send-button.tsx +50 -167
  57. package/src/components/input/buttons/stop-button.tsx +88 -0
  58. package/src/components/input/chat-input.tsx +188 -83
  59. package/src/components/input/index.ts +1 -0
  60. package/src/components/input/toolbar-registry.tsx +25 -1
  61. package/src/components/input/use-chat-commands.tsx +25 -5
  62. package/src/components/input/writing-indicator.tsx +83 -0
  63. package/src/components/messages/header.tsx +8 -0
  64. package/src/components/messages/index.ts +0 -1
  65. package/src/components/messages/message.tsx +1 -0
  66. package/src/components/messages/messages.tsx +63 -39
  67. package/src/components/messages/toolbar.tsx +51 -21
  68. package/src/input-model.ts +21 -0
  69. package/src/model.ts +12 -0
  70. package/src/types.ts +5 -0
  71. package/src/widgets/chat-sidebar.tsx +7 -9
  72. package/src/widgets/chat-widget.tsx +43 -12
  73. package/src/widgets/multichat-panel.tsx +10 -8
  74. package/style/chat.css +13 -141
  75. package/style/input.css +0 -58
  76. package/lib/components/messages/writers.d.ts +0 -16
  77. package/lib/components/messages/writers.js +0 -39
  78. package/src/components/messages/writers.tsx +0 -81
package/style/chat.css CHANGED
@@ -2,20 +2,18 @@
2
2
  * Copyright (c) Jupyter Development Team.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- .jp-chat-message:not(.jp-chat-message-stacked) {
6
- padding: 1em 1em 0;
7
- }
8
5
 
9
- .jp-chat-message:not(:first-child, .jp-chat-message-stacked) {
10
- border-top: 1px solid var(--jp-border-color2);
6
+ .jp-chat-rendered-markdown {
7
+ position: relative;
11
8
  }
12
9
 
13
- .jp-chat-message.jp-chat-message-stacked {
14
- padding: 0 1em;
10
+ .jp-chat-rendered-markdown hr {
11
+ color: #00000026;
12
+ background-color: transparent;
15
13
  }
16
14
 
17
- .jp-chat-rendered-markdown {
18
- position: relative;
15
+ .jp-chat-rendered-markdown .jp-RenderedHTMLCommon > :last-child {
16
+ margin-bottom: 0;
19
17
  }
20
18
 
21
19
  /*
@@ -38,7 +36,7 @@
38
36
  overflow-x: auto;
39
37
  white-space: pre;
40
38
  margin: 0;
41
- padding: 4px 2px 0 6px;
39
+ padding: 4px 6px;
42
40
  border: var(--jp-border-width) solid var(--jp-cell-editor-border-color);
43
41
  }
44
42
 
@@ -53,7 +51,7 @@
53
51
  }
54
52
 
55
53
  .jp-chat-toolbar {
56
- display: none;
54
+ visibility: hidden;
57
55
  position: absolute;
58
56
  right: 2px;
59
57
  top: 2px;
@@ -67,107 +65,13 @@
67
65
  }
68
66
 
69
67
  .jp-chat-rendered-markdown:hover .jp-chat-toolbar {
70
- display: inherit;
68
+ visibility: visible;
71
69
  }
72
70
 
73
71
  .jp-chat-toolbar > .jp-ToolbarButtonComponent {
74
72
  margin-top: 0;
75
73
  }
76
74
 
77
- .jp-chat-writers {
78
- display: flex;
79
- flex-wrap: wrap;
80
- position: sticky;
81
- bottom: 0;
82
- padding: 8px;
83
- background-color: var(--jp-layout-color0);
84
- border-top: 1px solid var(--jp-border-color2);
85
- z-index: 1;
86
- }
87
-
88
- .jp-chat-writers-content {
89
- display: flex;
90
- align-items: center;
91
- gap: 4px;
92
- flex-wrap: wrap;
93
- }
94
-
95
- .jp-chat-writer-item {
96
- display: flex;
97
- align-items: center;
98
- gap: 6px;
99
- }
100
-
101
- .jp-chat-writer-name {
102
- color: var(--jp-ui-font-color1);
103
- font-weight: 500;
104
- }
105
-
106
- .jp-chat-writer-separator {
107
- color: var(--jp-ui-font-color2);
108
- }
109
-
110
- .jp-chat-writing-status {
111
- display: flex;
112
- align-items: center;
113
- gap: 8px;
114
- }
115
-
116
- .jp-chat-writing-text {
117
- color: var(--jp-ui-font-color2);
118
- }
119
-
120
- /* Animated typing indicator */
121
- .jp-chat-typing-indicator {
122
- display: flex;
123
- align-items: center;
124
- gap: 2px;
125
- padding: 2px 4px;
126
- }
127
-
128
- .jp-chat-typing-dot {
129
- width: 4px;
130
- height: 4px;
131
- border-radius: 50%;
132
- background-color: var(--jp-brand-color1);
133
- animation: jp-chat-typing-bounce 1.4s infinite ease-in-out;
134
- }
135
-
136
- .jp-chat-typing-dot:nth-child(1) {
137
- animation-delay: -0.32s;
138
- }
139
-
140
- .jp-chat-typing-dot:nth-child(2) {
141
- animation-delay: -0.16s;
142
- }
143
-
144
- .jp-chat-typing-dot:nth-child(3) {
145
- animation-delay: 0s;
146
- }
147
-
148
- /* Keyframe animations */
149
- @keyframes jp-chat-typing-bounce {
150
- 0%,
151
- 80%,
152
- 100% {
153
- transform: scale(0.8);
154
- opacity: 0.5;
155
- }
156
-
157
- 40% {
158
- transform: scale(1.2);
159
- opacity: 1;
160
- }
161
- }
162
-
163
- .jp-chat-writers > div {
164
- display: flex;
165
- align-items: center;
166
- gap: 0.2em;
167
- white-space: pre;
168
- padding-left: 0.5em;
169
- }
170
-
171
75
  .jp-chat-navigation {
172
76
  position: absolute;
173
77
  right: 10px;
@@ -197,40 +101,8 @@
197
101
  bottom: 120px;
198
102
  }
199
103
 
200
- .jp-chat-attachments {
201
- display: flex;
202
- gap: 4px;
203
- flex-wrap: wrap;
204
- min-height: 1.5em;
205
- padding: 4px 0;
206
- }
207
-
208
- .jp-chat-attachment {
209
- border: solid 1px;
210
- border-radius: 10px;
211
- margin: 0 0.2em;
212
- padding: 0 0.3em;
213
- align-content: center;
214
- background-color: var(--jp-border-color3);
215
- flex-shrink: 0;
216
- }
217
-
218
- .jp-chat-attachment .jp-chat-attachment-clickable:hover {
219
- cursor: pointer;
220
- }
221
-
222
- .jp-chat-command-name {
223
- font-weight: normal;
224
- margin: 5px;
225
- }
226
-
227
- .jp-chat-command-description {
228
- color: gray;
229
- margin: 5px;
230
- }
231
-
232
104
  .jp-chat-mention {
233
- border-radius: 10px;
234
- padding: 0 0.2em;
235
- background-color: var(--jp-brand-color4);
105
+ border-radius: 4px;
106
+ padding: 2px 0;
107
+ font-weight: bold;
236
108
  }
package/style/input.css CHANGED
@@ -42,64 +42,6 @@
42
42
  white-space: nowrap;
43
43
  }
44
44
 
45
- /*
46
- * INPUT TEXT FIELD
47
- */
48
- .jp-chat-input-component {
49
- border: 1px solid var(--jp-ui-font-color3);
50
- border-radius: 4px;
51
- }
52
-
53
- .jp-chat-input-textfield .jp-chat-input-component::before,
54
- .jp-chat-input-textfield .jp-chat-input-component::after {
55
- border-bottom: unset !important;
56
- }
57
-
58
- /* Use the textfield label below the input. */
59
- .jp-chat-input-textfield .jp-chat-input-component {
60
- padding-top: 8px !important;
61
- padding-bottom: 15px !important;
62
- background-color: unset !important;
63
- }
64
-
65
- .jp-chat-input-textfield label {
66
- top: unset;
67
- left: unset;
68
- bottom: 0;
69
- right: 0;
70
- color: var(--jp-ui-font-color2) !important;
71
- }
72
-
73
- /*
74
- * INPUT TOOLBAR
75
- */
76
- .jp-chat-input-toolbar {
77
- gap: 1px;
78
- align-self: flex-end;
79
- min-height: unset !important;
80
- margin-bottom: 4px;
81
- }
82
-
83
- .jp-chat-input-toolbar .jp-chat-tooltipped-wrap button {
84
- border-radius: 0;
85
- min-width: unset;
86
- }
87
-
88
- .jp-chat-input-toolbar .jp-chat-tooltipped-wrap:first-child button {
89
- border-top-left-radius: 2px;
90
- border-bottom-left-radius: 2px;
91
- }
92
-
93
- .jp-chat-input-toolbar .jp-chat-tooltipped-wrap:last-child button {
94
- border-top-right-radius: 2px;
95
- border-bottom-right-radius: 2px;
96
- }
97
-
98
- .jp-chat-input-toolbar .jp-chat-attach-button,
99
- .jp-chat-input-toolbar .jp-chat-cancel-button {
100
- padding: 4px;
101
- }
102
-
103
45
  .jp-chat-input-toolbar .jp-chat-send-include-opener {
104
46
  padding: 4px 0;
105
47
  }
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import { IUser } from '../../types';
3
- /**
4
- * The writers component props.
5
- */
6
- type writersProps = {
7
- /**
8
- * The list of users currently writing.
9
- */
10
- writers: IUser[];
11
- };
12
- /**
13
- * The writers component, displaying the current writers.
14
- */
15
- export declare function WritingUsersList(props: writersProps): JSX.Element | null;
16
- export {};
@@ -1,39 +0,0 @@
1
- /*
2
- * Copyright (c) Jupyter Development Team.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { Box, Typography } from '@mui/material';
6
- import React, { useMemo } from 'react';
7
- import { Avatar } from '../avatar';
8
- const WRITERS_CLASS = 'jp-chat-writers';
9
- /**
10
- * Animated typing indicator component
11
- */
12
- const TypingIndicator = () => (React.createElement(Box, { className: "jp-chat-typing-indicator" },
13
- React.createElement("span", { className: "jp-chat-typing-dot" }),
14
- React.createElement("span", { className: "jp-chat-typing-dot" }),
15
- React.createElement("span", { className: "jp-chat-typing-dot" })));
16
- /**
17
- * The writers component, displaying the current writers.
18
- */
19
- export function WritingUsersList(props) {
20
- const { writers } = props;
21
- // Don't render if no writers
22
- if (writers.length === 0) {
23
- return null;
24
- }
25
- const writersText = writers.length > 1 ? ' are writing' : ' is writing';
26
- const writingUsers = useMemo(() => writers.map((writer, index) => {
27
- var _a, _b;
28
- return (React.createElement(Box, { key: writer.username || index, className: "jp-chat-writer-item" },
29
- React.createElement(Avatar, { user: writer, small: true }),
30
- React.createElement(Typography, { variant: "body2", className: "jp-chat-writer-name" }, (_b = (_a = writer.display_name) !== null && _a !== void 0 ? _a : writer.name) !== null && _b !== void 0 ? _b : (writer.username || 'User undefined')),
31
- index < writers.length - 1 && (React.createElement(Typography, { variant: "body2", className: "jp-chat-writer-separator" }, index < writers.length - 2 ? ', ' : ' and '))));
32
- }), [writers]);
33
- return (React.createElement(Box, { className: `${WRITERS_CLASS}` },
34
- React.createElement(Box, { className: "jp-chat-writers-content" },
35
- writingUsers,
36
- React.createElement(Box, { className: "jp-chat-writing-status" },
37
- React.createElement(Typography, { variant: "body2", className: "jp-chat-writing-text" }, writersText),
38
- React.createElement(TypingIndicator, null)))));
39
- }
@@ -1,81 +0,0 @@
1
- /*
2
- * Copyright (c) Jupyter Development Team.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
-
6
- import { Box, Typography } from '@mui/material';
7
- import React, { useMemo } from 'react';
8
-
9
- import { Avatar } from '../avatar';
10
- import { IUser } from '../../types';
11
-
12
- const WRITERS_CLASS = 'jp-chat-writers';
13
-
14
- /**
15
- * The writers component props.
16
- */
17
- type writersProps = {
18
- /**
19
- * The list of users currently writing.
20
- */
21
- writers: IUser[];
22
- };
23
-
24
- /**
25
- * Animated typing indicator component
26
- */
27
- const TypingIndicator = (): JSX.Element => (
28
- <Box className="jp-chat-typing-indicator">
29
- <span className="jp-chat-typing-dot"></span>
30
- <span className="jp-chat-typing-dot"></span>
31
- <span className="jp-chat-typing-dot"></span>
32
- </Box>
33
- );
34
-
35
- /**
36
- * The writers component, displaying the current writers.
37
- */
38
- export function WritingUsersList(props: writersProps): JSX.Element | null {
39
- const { writers } = props;
40
-
41
- // Don't render if no writers
42
- if (writers.length === 0) {
43
- return null;
44
- }
45
-
46
- const writersText = writers.length > 1 ? ' are writing' : ' is writing';
47
-
48
- const writingUsers: JSX.Element[] = useMemo(
49
- () =>
50
- writers.map((writer, index) => (
51
- <Box key={writer.username || index} className="jp-chat-writer-item">
52
- <Avatar user={writer} small />
53
- <Typography variant="body2" className="jp-chat-writer-name">
54
- {writer.display_name ??
55
- writer.name ??
56
- (writer.username || 'User undefined')}
57
- </Typography>
58
- {index < writers.length - 1 && (
59
- <Typography variant="body2" className="jp-chat-writer-separator">
60
- {index < writers.length - 2 ? ', ' : ' and '}
61
- </Typography>
62
- )}
63
- </Box>
64
- )),
65
- [writers]
66
- );
67
-
68
- return (
69
- <Box className={`${WRITERS_CLASS}`}>
70
- <Box className="jp-chat-writers-content">
71
- {writingUsers}
72
- <Box className="jp-chat-writing-status">
73
- <Typography variant="body2" className="jp-chat-writing-text">
74
- {writersText}
75
- </Typography>
76
- <TypingIndicator />
77
- </Box>
78
- </Box>
79
- </Box>
80
- );
81
- }