@jupyter/chat 0.1.0 → 0.3.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 (55) hide show
  1. package/lib/active-cell-manager.d.ts +151 -0
  2. package/lib/active-cell-manager.js +201 -0
  3. package/lib/components/chat-input.d.ts +14 -4
  4. package/lib/components/chat-input.js +118 -10
  5. package/lib/components/chat-messages.d.ts +45 -15
  6. package/lib/components/chat-messages.js +237 -55
  7. package/lib/components/chat.d.ts +21 -6
  8. package/lib/components/chat.js +15 -45
  9. package/lib/components/code-blocks/code-toolbar.d.ts +13 -0
  10. package/lib/components/code-blocks/code-toolbar.js +70 -0
  11. package/lib/components/{copy-button.d.ts → code-blocks/copy-button.d.ts} +1 -0
  12. package/lib/components/code-blocks/copy-button.js +43 -0
  13. package/lib/components/mui-extras/contrasting-tooltip.d.ts +6 -0
  14. package/lib/components/mui-extras/contrasting-tooltip.js +21 -0
  15. package/lib/components/mui-extras/tooltipped-icon-button.d.ts +35 -0
  16. package/lib/components/mui-extras/tooltipped-icon-button.js +36 -0
  17. package/lib/components/rendermime-markdown.d.ts +2 -0
  18. package/lib/components/rendermime-markdown.js +29 -15
  19. package/lib/components/scroll-container.js +1 -19
  20. package/lib/icons.d.ts +2 -0
  21. package/lib/icons.js +10 -0
  22. package/lib/index.d.ts +2 -0
  23. package/lib/index.js +2 -0
  24. package/lib/model.d.ts +98 -14
  25. package/lib/model.js +197 -6
  26. package/lib/registry.d.ts +78 -0
  27. package/lib/registry.js +83 -0
  28. package/lib/types.d.ts +60 -4
  29. package/lib/widgets/chat-sidebar.d.ts +3 -4
  30. package/lib/widgets/chat-sidebar.js +2 -2
  31. package/lib/widgets/chat-widget.d.ts +2 -8
  32. package/lib/widgets/chat-widget.js +6 -6
  33. package/package.json +204 -200
  34. package/src/active-cell-manager.ts +318 -0
  35. package/src/components/chat-input.tsx +196 -50
  36. package/src/components/chat-messages.tsx +357 -95
  37. package/src/components/chat.tsx +43 -69
  38. package/src/components/code-blocks/code-toolbar.tsx +143 -0
  39. package/src/components/code-blocks/copy-button.tsx +68 -0
  40. package/src/components/mui-extras/contrasting-tooltip.tsx +27 -0
  41. package/src/components/mui-extras/tooltipped-icon-button.tsx +84 -0
  42. package/src/components/rendermime-markdown.tsx +44 -20
  43. package/src/components/scroll-container.tsx +1 -25
  44. package/src/icons.ts +12 -0
  45. package/src/index.ts +2 -0
  46. package/src/model.ts +275 -21
  47. package/src/registry.ts +129 -0
  48. package/src/types.ts +62 -4
  49. package/src/widgets/chat-sidebar.tsx +3 -15
  50. package/src/widgets/chat-widget.tsx +8 -21
  51. package/style/chat.css +40 -0
  52. package/style/icons/read.svg +11 -0
  53. package/style/icons/replace-cell.svg +8 -0
  54. package/lib/components/copy-button.js +0 -35
  55. package/src/components/copy-button.tsx +0 -55
package/style/chat.css CHANGED
@@ -2,6 +2,17 @@
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(:first-child):not(.jp-chat-message-stacked) {
6
+ border-top: 1px solid var(--jp-border-color2);
7
+ }
8
+
9
+ .jp-chat-message:not(.jp-chat-message-stacked) {
10
+ padding: 1em 1em 0 1em;
11
+ }
12
+
13
+ .jp-chat-message.jp-chat-message-stacked {
14
+ padding: 0 1em;
15
+ }
5
16
 
6
17
  .jp-chat-rendermime-markdown {
7
18
  position: relative;
@@ -51,3 +62,32 @@
51
62
  .jp-chat-toolbar > .jp-ToolbarButtonComponent {
52
63
  margin-top: 0px;
53
64
  }
65
+
66
+ .jp-chat-navigation {
67
+ position: absolute;
68
+ right: 10px;
69
+ width: 24px;
70
+ height: 24px;
71
+ border-radius: 50%;
72
+ min-width: 0;
73
+ }
74
+
75
+ .jp-chat-navigation-unread {
76
+ border: solid 2px var(--jp-cell-inprompt-font-color);
77
+ }
78
+
79
+ .jp-chat-navigation::part(control) {
80
+ padding: 0;
81
+ }
82
+
83
+ .jp-chat-navigation-top {
84
+ top: 10px;
85
+ }
86
+
87
+ .jp-chat-navigation-top svg {
88
+ transform: rotate(180deg);
89
+ }
90
+
91
+ .jp-chat-navigation-bottom {
92
+ bottom: 100px;
93
+ }
@@ -0,0 +1,11 @@
1
+ <svg height="24px" viewBox="0 0 24 24" width="24px" xmlns="http://www.w3.org/2000/svg">
2
+ <g>
3
+ <path
4
+ style="display:inline;fill:none;fill-opacity:1;stroke:#545454;stroke-width:1.54693;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:1.5;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
5
+ d="M 2.2734634,9 V 20.226537 H 21.726536 V 9" />
6
+ <path
7
+ style="display:inline;fill:none;stroke:#545454;stroke-width:1.54528;stroke-linecap:square;stroke-miterlimit:10"
8
+ transform="matrix(0.81805878,0.57513462,-0.81805878,0.57513462,0,0)"
9
+ d="M 9.5141659,-5.1535239 H 20.802967 V 6.1352773 H 9.5141659 Z" />
10
+ </g>
11
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd"
3
+ d="M12 4.71429V7H1.71429V4.71429H12ZM12.5714 3C13.2026 3 13.7143 3.51168 13.7143 4.14286V7.57143C13.7143 8.20263 13.2026 8.71429 12.5714 8.71429H1.14286C0.51168 8.71429 0 8.20263 0 7.57143V4.14286C0 3.51168 0.511669 3 1.14286 3H12.5714Z"
4
+ fill="#565656" />
5
+ <path fill-rule="evenodd" clip-rule="evenodd"
6
+ d="M14 8.71429V11H3.71429V8.71429H14ZM14.5714 7C15.2026 7 15.7143 7.51168 15.7143 8.14286V11.5714C15.7143 12.2026 15.2026 12.7143 14.5714 12.7143H3.14286C2.51168 12.7143 2 12.2026 2 11.5714V8.14286C2 7.51168 2.51167 7 3.14286 7H14.5714Z"
7
+ fill="#565656" />
8
+ </svg>
@@ -1,35 +0,0 @@
1
- /*
2
- * Copyright (c) Jupyter Development Team.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import React, { useState, useCallback } from 'react';
6
- import { Box, Button } from '@mui/material';
7
- var CopyStatus;
8
- (function (CopyStatus) {
9
- CopyStatus[CopyStatus["None"] = 0] = "None";
10
- CopyStatus[CopyStatus["Copied"] = 1] = "Copied";
11
- })(CopyStatus || (CopyStatus = {}));
12
- const COPYBTN_TEXT_BY_STATUS = {
13
- [CopyStatus.None]: 'Copy to Clipboard',
14
- [CopyStatus.Copied]: 'Copied!'
15
- };
16
- export function CopyButton(props) {
17
- const [copyStatus, setCopyStatus] = useState(CopyStatus.None);
18
- const copy = useCallback(async () => {
19
- try {
20
- await navigator.clipboard.writeText(props.value);
21
- }
22
- catch (err) {
23
- console.error('Failed to copy text: ', err);
24
- setCopyStatus(CopyStatus.None);
25
- return;
26
- }
27
- setCopyStatus(CopyStatus.Copied);
28
- setTimeout(() => setCopyStatus(CopyStatus.None), 1000);
29
- }, [props.value]);
30
- return (React.createElement(Box, { sx: { display: 'flex', flexDirection: 'column' } },
31
- React.createElement(Button, { onClick: copy, disabled: copyStatus !== CopyStatus.None, "aria-label": "Copy To Clipboard", sx: {
32
- alignSelf: 'flex-end',
33
- textTransform: 'none'
34
- } }, COPYBTN_TEXT_BY_STATUS[copyStatus])));
35
- }
@@ -1,55 +0,0 @@
1
- /*
2
- * Copyright (c) Jupyter Development Team.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
-
6
- import React, { useState, useCallback } from 'react';
7
-
8
- import { Box, Button } from '@mui/material';
9
-
10
- enum CopyStatus {
11
- None,
12
- Copied
13
- }
14
-
15
- const COPYBTN_TEXT_BY_STATUS: Record<CopyStatus, string> = {
16
- [CopyStatus.None]: 'Copy to Clipboard',
17
- [CopyStatus.Copied]: 'Copied!'
18
- };
19
-
20
- type CopyButtonProps = {
21
- value: string;
22
- };
23
-
24
- export function CopyButton(props: CopyButtonProps): JSX.Element {
25
- const [copyStatus, setCopyStatus] = useState<CopyStatus>(CopyStatus.None);
26
-
27
- const copy = useCallback(async () => {
28
- try {
29
- await navigator.clipboard.writeText(props.value);
30
- } catch (err) {
31
- console.error('Failed to copy text: ', err);
32
- setCopyStatus(CopyStatus.None);
33
- return;
34
- }
35
-
36
- setCopyStatus(CopyStatus.Copied);
37
- setTimeout(() => setCopyStatus(CopyStatus.None), 1000);
38
- }, [props.value]);
39
-
40
- return (
41
- <Box sx={{ display: 'flex', flexDirection: 'column' }}>
42
- <Button
43
- onClick={copy}
44
- disabled={copyStatus !== CopyStatus.None}
45
- aria-label="Copy To Clipboard"
46
- sx={{
47
- alignSelf: 'flex-end',
48
- textTransform: 'none'
49
- }}
50
- >
51
- {COPYBTN_TEXT_BY_STATUS[copyStatus]}
52
- </Button>
53
- </Box>
54
- );
55
- }