@jupyter/chat 0.20.0-alpha.2 → 0.20.0-alpha.3

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,69 +1,92 @@
1
- import { PanelWithToolbar, SidePanel } from '@jupyterlab/ui-components';
1
+ import { PanelWithToolbar } from '@jupyterlab/ui-components';
2
+ import { Message } from '@lumino/messaging';
2
3
  import { ISignal } from '@lumino/signaling';
3
- import { Panel } from '@lumino/widgets';
4
4
  import { ChatWidget } from './chat-widget';
5
5
  import { Chat, IInputToolbarRegistryFactory } from '../components';
6
6
  import { IChatModel } from '../model';
7
7
  /**
8
8
  * Generic sidepanel widget including multiple chats and the add chat button.
9
9
  */
10
- export declare class MultiChatPanel extends SidePanel {
10
+ export declare class MultiChatPanel extends PanelWithToolbar {
11
+ /**
12
+ * The constructor of the multichat panel.
13
+ */
11
14
  constructor(options: MultiChatPanel.IOptions);
12
15
  /**
13
- * The sections of the side panel.
16
+ * The currently displayed chat widget.
14
17
  */
15
- get sections(): ChatSection[];
18
+ get current(): SidePanelWidget | undefined;
16
19
  /**
17
- * A signal emitting when a section is added to the panel.
20
+ * A signal emitting when a chat widget is opened in the panel.
18
21
  */
19
- get sectionAdded(): ISignal<MultiChatPanel, ChatSection>;
22
+ get chatOpened(): ISignal<MultiChatPanel, ChatWidget>;
20
23
  /**
21
- * Add a new widget to the chat panel.
24
+ * A signal emitting when the panel visibility changed.
25
+ */
26
+ get visibilityChanged(): ISignal<MultiChatPanel, boolean>;
27
+ /**
28
+ * Add a chat to the panel by creating or showing its widget.
22
29
  *
23
- * @param model - the model of the chat widget
24
- * @param displayName - the name of the chat.
30
+ * @param args - the chat args including model and display name.
31
+ */
32
+ open(args: MultiChatPanel.IOpenChatArgs): ChatWidget | undefined;
33
+ /**
34
+ * Get a loaded model by name, or undefined if not loaded.
35
+ */
36
+ getLoadedModel(name: string): IChatModel | undefined;
37
+ /**
38
+ * Get all loaded model names.
39
+ */
40
+ getLoadedModelNames(): string[];
41
+ /**
42
+ * Dispose a model, removing it from loaded models.
25
43
  */
26
- addChat(args: MultiChatPanel.IAddChatArgs): ChatWidget | undefined;
44
+ disposeLoadedModel(name: string): void;
45
+ /**
46
+ * Emit a signal when the panel visibility changed.
47
+ */
48
+ protected onAfterShow(msg: Message): void;
49
+ protected onBeforeHide(msg: Message): void;
50
+ /**
51
+ * Open a specific chat by name, creating a new sidepanel widget.
52
+ */
53
+ private _open;
27
54
  /**
28
55
  * Invoke the update of the list of available chats.
29
56
  */
30
- updateChatList(): void;
57
+ updateChatList: () => void;
31
58
  /**
32
59
  * Update the list of available chats.
33
60
  */
34
61
  private _updateChatList;
35
62
  /**
36
- * Open a chat if it exists in the side panel.
63
+ * Open a chat if its model is already loaded.
37
64
  *
38
65
  * @param name - the name of the chat.
39
- * @returns a boolean, whether the chat existed in the side panel or not.
66
+ * @returns a boolean, whether the chat model was already loaded or not.
40
67
  */
41
- openIfExists(name: string): boolean;
68
+ openIfLoaded(name: string): boolean;
42
69
  /**
43
70
  * A message handler invoked on an `'after-attach'` message.
44
71
  */
45
72
  protected onAfterAttach(): void;
46
73
  /**
47
- * Return the index of the chat in the list (-1 if not opened).
48
- *
49
- * @param name - the chat name.
74
+ * A message handler invoked on an `'before-detach'` message.
50
75
  */
51
- private _getChatIndex;
76
+ protected onBeforeDetach(): void;
52
77
  /**
53
- * Expand the chat from its index.
78
+ * Dispose of the resources held by the widget.
54
79
  */
55
- private _expandChat;
80
+ dispose(): void;
56
81
  /**
57
- * Handle `change` events for the HTMLSelect component.
82
+ * Update loaded model when the current widget updates its name.
58
83
  */
59
- private _chatSelected;
84
+ private _modelNameChanged;
60
85
  /**
61
- * Triggered when a section is toggled. If the section is opened, all others
62
- * sections are closed.
86
+ * Handle chat selection from the popup.
63
87
  */
64
- private _onExpansionToggled;
65
- private _chatNamesChanged;
66
- private _sectionAdded;
88
+ private _onSelectChat;
89
+ private _chatOpened;
67
90
  private _chatOptions;
68
91
  private _inputToolbarFactory?;
69
92
  private _updateChatListDebouncer;
@@ -72,6 +95,11 @@ export declare class MultiChatPanel extends SidePanel {
72
95
  private _openInMain?;
73
96
  private _renameChat?;
74
97
  private _openChatWidget?;
98
+ private _chatSelectorPopup?;
99
+ private _loadedModels;
100
+ private _currentWidget?;
101
+ private _chatNames;
102
+ private _visibilityChanged;
75
103
  }
76
104
  /**
77
105
  * The chat panel namespace.
@@ -80,7 +108,7 @@ export declare namespace MultiChatPanel {
80
108
  /**
81
109
  * Options of the constructor of the chat panel.
82
110
  */
83
- interface IOptions extends SidePanel.IOptions, Omit<Chat.IOptions, 'model' | 'inputToolbarRegistry'> {
111
+ interface IOptions extends PanelWithToolbar.IOptions, Omit<Chat.IOptions, 'model' | 'inputToolbarRegistry'> {
84
112
  /**
85
113
  * The input toolbar factory;
86
114
  */
@@ -89,13 +117,13 @@ export declare namespace MultiChatPanel {
89
117
  * An optional callback to create a chat model.
90
118
  *
91
119
  * @param name - the name of the chat, optional.
92
- * @return an object that can be passed to add a chat section.
120
+ * @return an object that can be passed to open the chat.
93
121
  */
94
- createModel?: (name?: string) => Promise<IAddChatArgs>;
122
+ createModel?: (name?: string) => Promise<IOpenChatArgs>;
95
123
  /**
96
124
  * An optional callback to get the list of existing chats.
97
125
  *
98
- * @returns an object with display name as key and the "full" name as value.
126
+ * @returns an object mapping chat display names to identifiers.
99
127
  */
100
128
  getChatNames?: () => Promise<{
101
129
  [name: string]: string;
@@ -113,95 +141,94 @@ export declare namespace MultiChatPanel {
113
141
  * @param newName - the new name of the chat.
114
142
  * @returns - a boolean, whether the chat has been renamed or not.
115
143
  */
116
- renameChat?: (oldName: string, newName: string) => Promise<boolean>;
144
+ renameChat?: boolean | ((oldName: string) => Promise<string | null>);
117
145
  }
118
146
  /**
119
147
  * The options for the add chat method.
120
148
  */
121
- interface IAddChatArgs {
149
+ interface IOpenChatArgs {
122
150
  /**
123
151
  * The model of the chat.
124
- * No-op id undefined.
152
+ * No-op if undefined.
125
153
  */
126
154
  model?: IChatModel;
127
155
  /**
128
- * The display name of the chat in the section title.
156
+ * The display name of the chat, shown in the toolbar.
129
157
  */
130
158
  displayName?: string;
131
159
  }
132
160
  }
133
161
  /**
134
- * The chat section containing a chat widget.
162
+ * A widget containing the chat and its toolbar.
135
163
  */
136
- export declare class ChatSection extends PanelWithToolbar {
164
+ declare class SidePanelWidget extends PanelWithToolbar {
165
+ constructor(options: SidePanelWidget.IOptions);
137
166
  /**
138
- * Constructor of the chat section.
167
+ * The chat widget embedded in the sidepanel widget.
139
168
  */
140
- constructor(options: ChatSection.IOptions);
169
+ get widget(): ChatWidget;
141
170
  /**
142
- * The display name.
171
+ * The model of the widget.
143
172
  */
144
- get displayName(): string;
145
- set displayName(value: string);
173
+ get model(): IChatModel;
146
174
  /**
147
- * The chat widget of the section.
175
+ * The displayed name of the widget.
148
176
  */
149
- get widget(): ChatWidget;
177
+ get name(): string;
178
+ set name(value: string);
150
179
  /**
151
- * The model of the widget.
180
+ * A signal emitting when the name has changed.
152
181
  */
153
- get model(): IChatModel;
182
+ get nameChanged(): ISignal<SidePanelWidget, {
183
+ old: string;
184
+ new: string;
185
+ }>;
154
186
  /**
155
187
  * Dispose of the resources held by the widget.
156
188
  */
157
189
  dispose(): void;
158
190
  /**
159
- * * Update the section’s title based on the chat name.
160
- * */
191
+ * Update the title based on the chat name.
192
+ */
161
193
  private _updateTitle;
162
194
  /**
163
- * Change the title when messages are unread.
164
- *
165
- * TODO: fix it upstream in @jupyterlab/ui-components.
166
- * Updating the title create a new Title widget, but does not attach again the
167
- * toolbar. The toolbar is attached only when the title widget is attached the first
168
- * time.
195
+ * Enable/disable unread icon.
169
196
  */
170
197
  private _unreadChanged;
171
198
  private _chatWidget;
172
199
  private _markAsRead;
173
- private _spinner;
174
200
  private _displayName;
201
+ private _titleWidget;
202
+ private _nameChanged;
175
203
  }
176
204
  /**
177
- * The chat section namespace.
205
+ * The sidepanel widget namespace.
178
206
  */
179
- export declare namespace ChatSection {
207
+ declare namespace SidePanelWidget {
180
208
  /**
181
- * Options to build a chat section.
209
+ * The sidepanel widget constructor options.
182
210
  */
183
- interface IOptions extends Panel.IOptions {
211
+ interface IOptions {
184
212
  /**
185
- * The widget to display in the section.
213
+ * The chat widget.
186
214
  */
187
215
  widget: ChatWidget;
188
216
  /**
189
- * An optional callback to open the chat in the main area.
190
- *
191
- * @param name - the name of the chat to move.
217
+ * The callback when closing the chat.
192
218
  */
193
- openInMain?: (name: string) => Promise<boolean>;
219
+ onClose: (name: string) => void;
194
220
  /**
195
- * An optional callback to rename a chat.
196
- *
197
- * @param oldName - the old name of the chat.
198
- * @param newName - the new name of the chat.
199
- * @returns - a boolean, whether the chat has been renamed or not.
221
+ * The displayed name of the chat.
200
222
  */
201
- renameChat?: (oldName: string, newName: string) => Promise<boolean>;
223
+ displayName?: string;
202
224
  /**
203
- * The name to display in the section title.
225
+ * The callback to open the chat in main area.
204
226
  */
205
- displayName?: string;
227
+ openInMain?: (name: string) => Promise<boolean>;
228
+ /**
229
+ * The callback to rename the chat.
230
+ */
231
+ renameChat?: boolean | ((oldName: string) => Promise<string | null>);
206
232
  }
207
233
  }
234
+ export {};