@jupyter/chat 0.18.0 → 0.18.2

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.
@@ -1,3 +1,3 @@
1
- import { ReactWidget } from '@jupyterlab/apputils';
2
1
  import { Chat } from '../components/chat';
3
- export declare function buildChatSidebar(options: Chat.IOptions): ReactWidget;
2
+ import { ChatWidget } from './chat-widget';
3
+ export declare function buildChatSidebar(options: Chat.IOptions): ChatWidget;
@@ -2,14 +2,12 @@
2
2
  * Copyright (c) Jupyter Development Team.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- import { ReactWidget } from '@jupyterlab/apputils';
6
- import React from 'react';
7
- import { Chat } from '../components/chat';
8
5
  import { chatIcon } from '../icons';
6
+ import { ChatWidget } from './chat-widget';
9
7
  export function buildChatSidebar(options) {
10
- const ChatWidget = ReactWidget.create(React.createElement(Chat, { ...options }));
11
- ChatWidget.id = 'jupyter-chat::side-panel';
12
- ChatWidget.title.icon = chatIcon;
13
- ChatWidget.title.caption = 'Jupyter Chat'; // TODO: i18n
14
- return ChatWidget;
8
+ const widget = new ChatWidget(options);
9
+ widget.id = 'jupyter-chat::side-panel';
10
+ widget.title.icon = chatIcon;
11
+ widget.title.caption = 'Jupyter Chat'; // TODO: i18n
12
+ return widget;
15
13
  }
@@ -110,7 +110,7 @@ export declare namespace MultiChatPanel {
110
110
  *
111
111
  * @param name - the name of the chat to move.
112
112
  */
113
- openInMain?: (name: string) => void;
113
+ openInMain?: (name: string) => Promise<boolean>;
114
114
  /**
115
115
  * An optional callback to rename a chat.
116
116
  *
@@ -195,7 +195,7 @@ export declare namespace ChatSection {
195
195
  *
196
196
  * @param name - the name of the chat to move.
197
197
  */
198
- openInMain?: (name: string) => void;
198
+ openInMain?: (name: string) => Promise<boolean>;
199
199
  /**
200
200
  * An optional callback to rename a chat.
201
201
  *
@@ -280,12 +280,13 @@ export class ChatSection extends PanelWithToolbar {
280
280
  icon: launchIcon,
281
281
  iconLabel: 'Move the chat to the main area',
282
282
  className: 'jp-mod-styled',
283
- onClick: () => {
283
+ onClick: async () => {
284
284
  var _a;
285
285
  const name = this.model.name;
286
- this.model.dispose();
287
- (_a = options.openInMain) === null || _a === void 0 ? void 0 : _a.call(options, name);
288
- this.dispose();
286
+ if (await ((_a = options.openInMain) === null || _a === void 0 ? void 0 : _a.call(options, name))) {
287
+ this.model.dispose();
288
+ this.dispose();
289
+ }
289
290
  }
290
291
  });
291
292
  this.toolbar.addItem('moveMain', moveToMain);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/chat",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
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",
@@ -3,16 +3,14 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
- import { ReactWidget } from '@jupyterlab/apputils';
7
- import React from 'react';
8
-
9
6
  import { Chat } from '../components/chat';
10
7
  import { chatIcon } from '../icons';
8
+ import { ChatWidget } from './chat-widget';
11
9
 
12
- export function buildChatSidebar(options: Chat.IOptions): ReactWidget {
13
- const ChatWidget = ReactWidget.create(<Chat {...options} />);
14
- ChatWidget.id = 'jupyter-chat::side-panel';
15
- ChatWidget.title.icon = chatIcon;
16
- ChatWidget.title.caption = 'Jupyter Chat'; // TODO: i18n
17
- return ChatWidget;
10
+ export function buildChatSidebar(options: Chat.IOptions): ChatWidget {
11
+ const widget = new ChatWidget(options);
12
+ widget.id = 'jupyter-chat::side-panel';
13
+ widget.title.icon = chatIcon;
14
+ widget.title.caption = 'Jupyter Chat'; // TODO: i18n
15
+ return widget;
18
16
  }
@@ -279,7 +279,7 @@ export class MultiChatPanel extends SidePanel {
279
279
  name?: string
280
280
  ) => Promise<MultiChatPanel.IAddChatArgs>;
281
281
  private _getChatNames?: () => Promise<{ [name: string]: string }>;
282
- private _openInMain?: (name: string) => void;
282
+ private _openInMain?: (name: string) => Promise<boolean>;
283
283
  private _renameChat?: (oldName: string, newName: string) => Promise<boolean>;
284
284
 
285
285
  private _openChatWidget?: ReactWidget;
@@ -317,7 +317,7 @@ export namespace MultiChatPanel {
317
317
  *
318
318
  * @param name - the name of the chat to move.
319
319
  */
320
- openInMain?: (name: string) => void;
320
+ openInMain?: (name: string) => Promise<boolean>;
321
321
  /**
322
322
  * An optional callback to rename a chat.
323
323
  *
@@ -406,11 +406,12 @@ export class ChatSection extends PanelWithToolbar {
406
406
  icon: launchIcon,
407
407
  iconLabel: 'Move the chat to the main area',
408
408
  className: 'jp-mod-styled',
409
- onClick: () => {
409
+ onClick: async () => {
410
410
  const name = this.model.name;
411
- this.model.dispose();
412
- options.openInMain?.(name);
413
- this.dispose();
411
+ if (await options.openInMain?.(name)) {
412
+ this.model.dispose();
413
+ this.dispose();
414
+ }
414
415
  }
415
416
  });
416
417
  this.toolbar.addItem('moveMain', moveToMain);
@@ -521,7 +522,7 @@ export namespace ChatSection {
521
522
  *
522
523
  * @param name - the name of the chat to move.
523
524
  */
524
- openInMain?: (name: string) => void;
525
+ openInMain?: (name: string) => Promise<boolean>;
525
526
  /**
526
527
  * An optional callback to rename a chat.
527
528
  *
package/style/chat.css CHANGED
@@ -194,7 +194,7 @@
194
194
  }
195
195
 
196
196
  .jp-chat-navigation-bottom {
197
- bottom: 100px;
197
+ bottom: 120px;
198
198
  }
199
199
 
200
200
  .jp-chat-attachments {
package/style/input.css CHANGED
@@ -12,7 +12,7 @@
12
12
  display: flex;
13
13
  flex-direction: column;
14
14
  justify-content: center;
15
- min-height: 56px;
15
+ flex: 0 0 auto;
16
16
  }
17
17
 
18
18
  .jp-chat-input-container.jp-chat-drag-hover::after {