@jupyter/chat 0.20.0-alpha.3 → 0.20.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.
@@ -3,10 +3,11 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  import CloseIcon from '@mui/icons-material/Close';
6
- import { Box, Button, Tooltip } from '@mui/material';
6
+ import { Box, Tooltip } from '@mui/material';
7
7
  import React from 'react';
8
8
  import { PathExt } from '@jupyterlab/coreutils';
9
9
  import { UUID } from '@lumino/coreutils';
10
+ import { TooltippedIconButton } from './mui-extras';
10
11
  import { useChatContext } from '../context';
11
12
  const ATTACHMENT_CLASS = 'jp-chat-attachment';
12
13
  const ATTACHMENT_CLICKABLE_CLASS = 'jp-chat-attachment-clickable';
@@ -79,17 +80,11 @@ export function AttachmentPreview(props) {
79
80
  }
80
81
  : {}
81
82
  } }, getAttachmentDisplayName(props.attachment))),
82
- props.onRemove && (React.createElement(Tooltip, { title: remove_tooltip, placement: "top", arrow: true },
83
- React.createElement("span", null,
84
- React.createElement(Button, { onClick: () => props.onRemove(props.attachment), size: "small", className: REMOVE_BUTTON_CLASS, "aria-label": remove_tooltip, sx: {
85
- minWidth: 'unset',
86
- padding: 0,
87
- lineHeight: 0,
88
- color: 'var(--jp-ui-font-color2)',
89
- '&:hover': {
90
- color: 'var(--jp-ui-font-color0)',
91
- backgroundColor: 'transparent'
92
- }
93
- } },
94
- React.createElement(CloseIcon, { fontSize: "small" })))))));
83
+ props.onRemove && (React.createElement(TooltippedIconButton, { tooltip: remove_tooltip, onClick: () => props.onRemove(props.attachment), className: REMOVE_BUTTON_CLASS, inputToolbar: false, sx: {
84
+ width: 'unset',
85
+ minWidth: 'unset',
86
+ height: 'unset',
87
+ padding: 0
88
+ } },
89
+ React.createElement(CloseIcon, { fontSize: "small" })))));
95
90
  }
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './active-cell-manager';
2
2
  export * from './components';
3
+ export * from './context';
3
4
  export * from './icons';
4
5
  export * from './input-model';
5
6
  export * from './model';
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export * from './active-cell-manager';
6
6
  export * from './components';
7
+ export * from './context';
7
8
  export * from './icons';
8
9
  export * from './input-model';
9
10
  export * from './model';
package/lib/message.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { IRenderMime } from '@jupyterlab/rendermime';
2
1
  import { ISignal } from '@lumino/signaling';
3
- import { IAttachment, IMessageContent, IMessage, IMessageMetadata, IUser } from './types';
2
+ import { IAttachment, IMessageContent, IMessage, IMessageMetadata, IUser, IMimeModelBody } from './types';
4
3
  /**
5
4
  * The message object.
6
5
  */
@@ -19,7 +18,7 @@ export declare class Message implements IMessage {
19
18
  * Getters for each attribute individually.
20
19
  */
21
20
  get type(): string;
22
- get body(): string | (Partial<IRenderMime.IMimeModel> & Pick<IRenderMime.IMimeModel, 'data'>);
21
+ get body(): string | IMimeModelBody;
23
22
  get id(): string;
24
23
  get time(): number;
25
24
  get sender(): IUser;
@@ -159,10 +159,6 @@ export async function getJupyterLabTheme() {
159
159
  }
160
160
  },
161
161
  palette: {
162
- background: {
163
- paper: getCSSVariable('--jp-layout-color1'),
164
- default: getCSSVariable('--jp-layout-color1')
165
- },
166
162
  mode: light ? 'light' : 'dark',
167
163
  primary: {
168
164
  main: getCSSVariable(`--jp-brand-color${light ? '1' : '2'}`),
package/lib/tokens.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { IWidgetTracker, MainAreaWidget } from '@jupyterlab/apputils';
2
2
  import { Token } from '@lumino/coreutils';
3
3
  import { ChatWidget } from './widgets';
4
+ import { IChatModel } from './model';
5
+ /**
6
+ * The main area chat widget type.
7
+ */
8
+ export type MainAreaChat = MainAreaWidget<ChatWidget> & {
9
+ model: IChatModel;
10
+ };
4
11
  /**
5
12
  * the chat tracker type.
6
13
  */
7
- export type IChatTracker = IWidgetTracker<ChatWidget | MainAreaWidget<ChatWidget>>;
14
+ export type IChatTracker = IWidgetTracker<ChatWidget | MainAreaChat>;
8
15
  /**
9
16
  * A chat tracker token.
10
17
  */
package/lib/types.d.ts CHANGED
@@ -53,6 +53,10 @@ export interface IConfig {
53
53
  */
54
54
  showDeleted?: boolean;
55
55
  }
56
+ /**
57
+ * Mime model body type, a partial mime bundle model containing at least the data.
58
+ */
59
+ export type IMimeModelBody = Partial<IRenderMime.IMimeModel> & Pick<IRenderMime.IMimeModel, 'data'>;
56
60
  /**
57
61
  * An empty interface to describe optional metadata attached to a chat message.
58
62
  * Extensions can augment this interface to add custom fields:
@@ -72,7 +76,7 @@ export interface IMessageMetadata {
72
76
  */
73
77
  export type IMessageContent<T = IUser, U = IAttachment> = {
74
78
  type: string;
75
- body: string | (Partial<IRenderMime.IMimeModel> & Pick<IRenderMime.IMimeModel, 'data'>);
79
+ body: string | IMimeModelBody;
76
80
  id: string;
77
81
  time: number;
78
82
  sender: T;
@@ -277,7 +277,7 @@ function ChatSelectorList({ names, selectedName, loadedModels, onSelect, onUpdat
277
277
  onClose(name);
278
278
  };
279
279
  if (names.length === 0) {
280
- return React.createElement("div", { className: POPUP_EMPTY_CLASS }, "No chats found");
280
+ return React.createElement("div", { className: POPUP_EMPTY_CLASS }, "No chat found");
281
281
  }
282
282
  return (React.createElement("ul", { ref: listRef, className: POPUP_LIST_CLASS }, names.map(name => {
283
283
  const isLoaded = loadedModels.has(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/chat",
3
- "version": "0.20.0-alpha.3",
3
+ "version": "0.20.0",
4
4
  "description": "A package that provides UI components that can be used to create a chat in a Jupyterlab extension.",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -4,11 +4,12 @@
4
4
  */
5
5
 
6
6
  import CloseIcon from '@mui/icons-material/Close';
7
- import { Box, Button, Tooltip } from '@mui/material';
7
+ import { Box, Tooltip } from '@mui/material';
8
8
  import React from 'react';
9
9
  import { PathExt } from '@jupyterlab/coreutils';
10
10
  import { UUID } from '@lumino/coreutils';
11
11
 
12
+ import { TooltippedIconButton } from './mui-extras';
12
13
  import { useChatContext } from '../context';
13
14
  import { IAttachment } from '../types';
14
15
 
@@ -131,28 +132,20 @@ export function AttachmentPreview(props: AttachmentProps): JSX.Element {
131
132
  </Box>
132
133
  </Tooltip>
133
134
  {props.onRemove && (
134
- <Tooltip title={remove_tooltip} placement="top" arrow>
135
- <span>
136
- <Button
137
- onClick={() => props.onRemove!(props.attachment)}
138
- size="small"
139
- className={REMOVE_BUTTON_CLASS}
140
- aria-label={remove_tooltip}
141
- sx={{
142
- minWidth: 'unset',
143
- padding: 0,
144
- lineHeight: 0,
145
- color: 'var(--jp-ui-font-color2)',
146
- '&:hover': {
147
- color: 'var(--jp-ui-font-color0)',
148
- backgroundColor: 'transparent'
149
- }
150
- }}
151
- >
152
- <CloseIcon fontSize="small" />
153
- </Button>
154
- </span>
155
- </Tooltip>
135
+ <TooltippedIconButton
136
+ tooltip={remove_tooltip}
137
+ onClick={() => props.onRemove!(props.attachment)}
138
+ className={REMOVE_BUTTON_CLASS}
139
+ inputToolbar={false}
140
+ sx={{
141
+ width: 'unset',
142
+ minWidth: 'unset',
143
+ height: 'unset',
144
+ padding: 0
145
+ }}
146
+ >
147
+ <CloseIcon fontSize="small" />
148
+ </TooltippedIconButton>
156
149
  )}
157
150
  </Box>
158
151
  );
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  export * from './active-cell-manager';
7
7
  export * from './components';
8
+ export * from './context';
8
9
  export * from './icons';
9
10
  export * from './input-model';
10
11
  export * from './model';
package/src/message.ts CHANGED
@@ -3,14 +3,14 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
- import { IRenderMime } from '@jupyterlab/rendermime';
7
6
  import { ISignal, Signal } from '@lumino/signaling';
8
7
  import {
9
8
  IAttachment,
10
9
  IMessageContent,
11
10
  IMessage,
12
11
  IMessageMetadata,
13
- IUser
12
+ IUser,
13
+ IMimeModelBody
14
14
  } from './types';
15
15
 
16
16
  /**
@@ -39,9 +39,7 @@ export class Message implements IMessage {
39
39
  get type(): string {
40
40
  return this._content.type;
41
41
  }
42
- get body():
43
- | string
44
- | (Partial<IRenderMime.IMimeModel> & Pick<IRenderMime.IMimeModel, 'data'>) {
42
+ get body(): string | IMimeModelBody {
45
43
  return this._content.body;
46
44
  }
47
45
  get id(): string {
@@ -184,10 +184,6 @@ export async function getJupyterLabTheme(): Promise<Theme> {
184
184
  }
185
185
  },
186
186
  palette: {
187
- background: {
188
- paper: getCSSVariable('--jp-layout-color1'),
189
- default: getCSSVariable('--jp-layout-color1')
190
- },
191
187
  mode: light ? 'light' : 'dark',
192
188
  primary: {
193
189
  main: getCSSVariable(`--jp-brand-color${light ? '1' : '2'}`),
package/src/tokens.ts CHANGED
@@ -7,13 +7,19 @@ import { IWidgetTracker, MainAreaWidget } from '@jupyterlab/apputils';
7
7
  import { Token } from '@lumino/coreutils';
8
8
 
9
9
  import { ChatWidget } from './widgets';
10
+ import { IChatModel } from './model';
11
+
12
+ /**
13
+ * The main area chat widget type.
14
+ */
15
+ export type MainAreaChat = MainAreaWidget<ChatWidget> & {
16
+ model: IChatModel;
17
+ };
10
18
 
11
19
  /**
12
20
  * the chat tracker type.
13
21
  */
14
- export type IChatTracker = IWidgetTracker<
15
- ChatWidget | MainAreaWidget<ChatWidget>
16
- >;
22
+ export type IChatTracker = IWidgetTracker<ChatWidget | MainAreaChat>;
17
23
 
18
24
  /**
19
25
  * A chat tracker token.
package/src/types.ts CHANGED
@@ -61,6 +61,12 @@ export interface IConfig {
61
61
  showDeleted?: boolean;
62
62
  }
63
63
 
64
+ /**
65
+ * Mime model body type, a partial mime bundle model containing at least the data.
66
+ */
67
+ export type IMimeModelBody = Partial<IRenderMime.IMimeModel> &
68
+ Pick<IRenderMime.IMimeModel, 'data'>;
69
+
64
70
  /**
65
71
  * An empty interface to describe optional metadata attached to a chat message.
66
72
  * Extensions can augment this interface to add custom fields:
@@ -80,10 +86,7 @@ export interface IMessageMetadata {} /* eslint-disable-line @typescript-eslint/n
80
86
  */
81
87
  export type IMessageContent<T = IUser, U = IAttachment> = {
82
88
  type: string;
83
- body:
84
- | string
85
- // Should contain at least the data of the mime model.
86
- | (Partial<IRenderMime.IMimeModel> & Pick<IRenderMime.IMimeModel, 'data'>);
89
+ body: string | IMimeModelBody;
87
90
  id: string;
88
91
  time: number;
89
92
  sender: T;
@@ -388,7 +388,7 @@ function ChatSelectorList({
388
388
  };
389
389
 
390
390
  if (names.length === 0) {
391
- return <div className={POPUP_EMPTY_CLASS}>No chats found</div>;
391
+ return <div className={POPUP_EMPTY_CLASS}>No chat found</div>;
392
392
  }
393
393
 
394
394
  return (