@zeyos/zx 5.5.0 → 5.6.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.
- package/CHANGELOG.md +56 -0
- package/dist/types/components/agent-thread/agent-thread.d.ts +583 -0
- package/dist/types/components/approval-card/approval-card.d.ts +596 -0
- package/dist/types/components/avatar/avatar.d.ts +91 -4
- package/dist/types/components/block-view/block-view.d.ts +205 -0
- package/dist/types/components/composer/composer.d.ts +736 -0
- package/dist/types/components/run-status/run-status.d.ts +393 -0
- package/dist/types/components/run-trace/run-trace.d.ts +624 -0
- package/dist/types/components/source-list/source-list.d.ts +177 -0
- package/dist/types/core/messages.d.ts +135 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/internal/agent-model.d.ts +587 -0
- package/dist/types/internal/highlight.d.ts +24 -0
- package/dist/types/internal/presence-loop.d.ts +148 -0
- package/dist/zx-zeyos.esm.js +4648 -4513
- package/dist/zx-zeyos.esm.min.js +2 -2
- package/dist/zx.css +1927 -1
- package/dist/zx.esm.js +15769 -9194
- package/dist/zx.esm.min.js +27 -8
- package/dist/zx.global.js +15769 -9194
- package/dist/zx.global.min.js +27 -8
- package/dist/zx.min.css +1 -1
- package/docs/api.json +1166 -5
- package/docs/llms.md +455 -2
- package/docs/llms.txt +10 -1
- package/package.json +1 -1
- package/src/components/agent-thread/agent-thread.css +417 -0
- package/src/components/agent-thread/agent-thread.js +1365 -0
- package/src/components/approval-card/approval-card.css +289 -0
- package/src/components/approval-card/approval-card.js +1377 -0
- package/src/components/avatar/avatar.css +56 -1
- package/src/components/avatar/avatar.js +148 -26
- package/src/components/block-view/block-view.css +300 -0
- package/src/components/block-view/block-view.js +523 -0
- package/src/components/composer/composer.css +403 -0
- package/src/components/composer/composer.js +1441 -0
- package/src/components/run-status/run-status.css +208 -0
- package/src/components/run-status/run-status.js +782 -0
- package/src/components/run-trace/run-trace.css +443 -0
- package/src/components/run-trace/run-trace.js +1209 -0
- package/src/components/source-list/source-list.css +208 -0
- package/src/components/source-list/source-list.js +355 -0
- package/src/core/messages.js +143 -0
- package/src/index.js +8 -0
- package/src/internal/agent-model.js +488 -0
- package/src/internal/highlight.js +104 -0
- package/src/internal/presence-loop.js +343 -0
- package/styles/zx.css +7 -0
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
import { Component } from '../../core/component.js';
|
|
2
|
+
import { Launcher } from '../launcher/launcher.js';
|
|
3
|
+
export type LauncherItem = import('../launcher/launcher.js').LauncherItem;
|
|
4
|
+
export type MentionItem = {
|
|
5
|
+
/**
|
|
6
|
+
* Stable identifier.
|
|
7
|
+
*/
|
|
8
|
+
id: string | number;
|
|
9
|
+
/**
|
|
10
|
+
* Visible name; picking the item writes `@<label> ` into the text.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* Secondary line in the suggestion list.
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Icon name drawn before the label.
|
|
19
|
+
*/
|
|
20
|
+
icon?: string;
|
|
21
|
+
};
|
|
22
|
+
export type MentionSource = {
|
|
23
|
+
/**
|
|
24
|
+
* Character that starts a mention.
|
|
25
|
+
*/
|
|
26
|
+
trigger?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The
|
|
29
|
+
* items, filtered by the composer as the query changes, or a function that answers a query itself.
|
|
30
|
+
*/
|
|
31
|
+
items: MentionItem[] | ((query: string) => MentionItem[] | Promise<MentionItem[]>);
|
|
32
|
+
};
|
|
33
|
+
export type ContextChip = {
|
|
34
|
+
/**
|
|
35
|
+
* Stable identifier.
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
/**
|
|
39
|
+
* Visible label.
|
|
40
|
+
*/
|
|
41
|
+
label: string;
|
|
42
|
+
/**
|
|
43
|
+
* Icon name drawn before the label.
|
|
44
|
+
*/
|
|
45
|
+
icon?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Application data handed back in `send`; the composer never reads it.
|
|
48
|
+
*/
|
|
49
|
+
ref?: unknown;
|
|
50
|
+
};
|
|
51
|
+
export type ComposerTool = {
|
|
52
|
+
/**
|
|
53
|
+
* Stable identifier, handed back in `tool`.
|
|
54
|
+
*/
|
|
55
|
+
id: string;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible name and tooltip; the button shows only the icon.
|
|
58
|
+
*/
|
|
59
|
+
label: string;
|
|
60
|
+
/**
|
|
61
|
+
* Icon name: a built-in glyph or one the application registered.
|
|
62
|
+
*/
|
|
63
|
+
icon: string;
|
|
64
|
+
/**
|
|
65
|
+
* Makes the tool a toggle, drawn with `aria-pressed`. Leave it out for
|
|
66
|
+
* a plain button. The composer never changes it on its own: call `setToolPressed()`.
|
|
67
|
+
*/
|
|
68
|
+
pressed?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the tool takes no clicks.
|
|
71
|
+
*/
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Makes the tool a disclosure, drawn with `aria-expanded`: a panel
|
|
75
|
+
* of settings it opens. Like `pressed`, the application sets it.
|
|
76
|
+
*/
|
|
77
|
+
expanded?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Id of what the tool opens, drawn as `aria-controls`.
|
|
80
|
+
*/
|
|
81
|
+
controls?: string;
|
|
82
|
+
};
|
|
83
|
+
export type ComposerToolDetail = {
|
|
84
|
+
/**
|
|
85
|
+
* The tool's id.
|
|
86
|
+
*/
|
|
87
|
+
id: string;
|
|
88
|
+
/**
|
|
89
|
+
* A copy of the tool as it stands, `pressed` included.
|
|
90
|
+
*/
|
|
91
|
+
tool: ComposerTool;
|
|
92
|
+
};
|
|
93
|
+
export type ComposerUpdate = {
|
|
94
|
+
/**
|
|
95
|
+
* Accessible name; null resolves `composer.label` again.
|
|
96
|
+
*/
|
|
97
|
+
label?: string | null;
|
|
98
|
+
/**
|
|
99
|
+
* Placeholder of the text; empty removes it.
|
|
100
|
+
*/
|
|
101
|
+
placeholder?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Quiet text beside Send, as `setHint()`.
|
|
104
|
+
*/
|
|
105
|
+
hint?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Line under the composer, as `setNote()`.
|
|
108
|
+
*/
|
|
109
|
+
note?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The key that sends.
|
|
112
|
+
*/
|
|
113
|
+
submitKey?: 'enter' | 'mod+enter';
|
|
114
|
+
/**
|
|
115
|
+
* Visible text on Send; null or empty makes it icon-only.
|
|
116
|
+
*/
|
|
117
|
+
sendLabel?: string | null;
|
|
118
|
+
/**
|
|
119
|
+
* As `setDisabled()`.
|
|
120
|
+
*/
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* As `setBusy()`.
|
|
124
|
+
*/
|
|
125
|
+
busy?: boolean;
|
|
126
|
+
};
|
|
127
|
+
export type ComposerSendDetail = {
|
|
128
|
+
/**
|
|
129
|
+
* The message, trimmed.
|
|
130
|
+
*/
|
|
131
|
+
text: string;
|
|
132
|
+
/**
|
|
133
|
+
* Attached files, in the order they were added.
|
|
134
|
+
*/
|
|
135
|
+
files: File[];
|
|
136
|
+
/**
|
|
137
|
+
* The picked mentions whose `@<label>` is still in the text.
|
|
138
|
+
*/
|
|
139
|
+
mentions: MentionItem[];
|
|
140
|
+
/**
|
|
141
|
+
* The context chips.
|
|
142
|
+
*/
|
|
143
|
+
context: ContextChip[];
|
|
144
|
+
};
|
|
145
|
+
export type ComposerRemoveDetail = {
|
|
146
|
+
/**
|
|
147
|
+
* What was removed.
|
|
148
|
+
*/
|
|
149
|
+
kind: 'file' | 'context';
|
|
150
|
+
/**
|
|
151
|
+
* The attachment's or chip's id.
|
|
152
|
+
*/
|
|
153
|
+
id: string;
|
|
154
|
+
/**
|
|
155
|
+
* The removed file, for `kind: 'file'`.
|
|
156
|
+
*/
|
|
157
|
+
file?: File;
|
|
158
|
+
/**
|
|
159
|
+
* The removed chip, for `kind: 'context'`.
|
|
160
|
+
*/
|
|
161
|
+
chip?: ContextChip;
|
|
162
|
+
};
|
|
163
|
+
export type ComposerOptions = {
|
|
164
|
+
/**
|
|
165
|
+
* Accessible name of the text and of the group around it.
|
|
166
|
+
* Omitted resolves `composer.label`, English `Message`.
|
|
167
|
+
*/
|
|
168
|
+
label?: string | null;
|
|
169
|
+
/**
|
|
170
|
+
* Placeholder of the text.
|
|
171
|
+
*/
|
|
172
|
+
placeholder?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Initial text. Without it, a saved draft is restored.
|
|
175
|
+
*/
|
|
176
|
+
value?: string;
|
|
177
|
+
/**
|
|
178
|
+
* `'enter'`: Enter sends and Shift+Enter breaks
|
|
179
|
+
* the line. `'mod+enter'`: Cmd+Enter (Ctrl+Enter elsewhere) sends and Enter breaks the line.
|
|
180
|
+
*/
|
|
181
|
+
submitKey?: 'enter' | 'mod+enter';
|
|
182
|
+
/**
|
|
183
|
+
* Whether an agent is working: Send becomes Stop.
|
|
184
|
+
*/
|
|
185
|
+
busy?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Whether the composer takes no input.
|
|
188
|
+
*/
|
|
189
|
+
disabled?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Whether files can be attached: an Attach button, paste,
|
|
192
|
+
* and drop.
|
|
193
|
+
*/
|
|
194
|
+
attachments?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* File types accepted, in the `<input type="file">` syntax
|
|
197
|
+
* (`'image/*,.pdf'`). Empty accepts every file.
|
|
198
|
+
*/
|
|
199
|
+
accept?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Most files one message carries.
|
|
202
|
+
*/
|
|
203
|
+
maxFiles?: number;
|
|
204
|
+
/**
|
|
205
|
+
* Enables `@` mentions.
|
|
206
|
+
*/
|
|
207
|
+
mentions?: MentionSource | null;
|
|
208
|
+
/**
|
|
209
|
+
* Commands opened by `/` on an empty text, in a
|
|
210
|
+
* Launcher; an item with `items` opens a page of further commands.
|
|
211
|
+
*/
|
|
212
|
+
commands?: LauncherItem[] | null;
|
|
213
|
+
/**
|
|
214
|
+
* Initial context chips.
|
|
215
|
+
*/
|
|
216
|
+
context?: ContextChip[];
|
|
217
|
+
/**
|
|
218
|
+
* Quiet text in the bar beside Send.
|
|
219
|
+
*/
|
|
220
|
+
hint?: string;
|
|
221
|
+
/**
|
|
222
|
+
* Quiet line under the composer.
|
|
223
|
+
*/
|
|
224
|
+
note?: string;
|
|
225
|
+
/**
|
|
226
|
+
* Key the unsent text is kept under (through `storage()`),
|
|
227
|
+
* restored on create and cleared on send.
|
|
228
|
+
*/
|
|
229
|
+
draftKey?: string | null;
|
|
230
|
+
/**
|
|
231
|
+
* Rows the text never shrinks below, even when empty. Capped at
|
|
232
|
+
* `maxRows`.
|
|
233
|
+
*/
|
|
234
|
+
minRows?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Rows the text grows to before it scrolls.
|
|
237
|
+
*/
|
|
238
|
+
maxRows?: number;
|
|
239
|
+
/**
|
|
240
|
+
* Glyph names for the Attach and Commands
|
|
241
|
+
* buttons (a paperclip, a book) where the application registered its own.
|
|
242
|
+
*/
|
|
243
|
+
icons?: {
|
|
244
|
+
attach?: string;
|
|
245
|
+
commands?: string;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Further icon buttons in the bar, after Attach and Commands.
|
|
249
|
+
* An entry without `id`, `label` or `icon` is left out, as is a repeated id.
|
|
250
|
+
*/
|
|
251
|
+
tools?: ComposerTool[];
|
|
252
|
+
/**
|
|
253
|
+
* Visible text beside the Send glyph (`'Start task'`), which
|
|
254
|
+
* is then also its accessible name; while busy the button reads `composer.stop`. Null keeps Send
|
|
255
|
+
* icon-only. In a composer narrower than 24rem the text is visually hidden and stays the name.
|
|
256
|
+
*/
|
|
257
|
+
sendLabel?: string | null;
|
|
258
|
+
/**
|
|
259
|
+
* Localized messages.
|
|
260
|
+
*/
|
|
261
|
+
msg?: Record<string, string> | Record<string, Record<string, string>>;
|
|
262
|
+
/**
|
|
263
|
+
* Preventable send listener.
|
|
264
|
+
*/
|
|
265
|
+
onsend?: (event: CustomEvent<ComposerSendDetail>) => void;
|
|
266
|
+
/**
|
|
267
|
+
* Stop listener.
|
|
268
|
+
*/
|
|
269
|
+
onstop?: (event: CustomEvent<Record<string, never>>) => void;
|
|
270
|
+
/**
|
|
271
|
+
* Text listener.
|
|
272
|
+
*/
|
|
273
|
+
oninput?: (event: CustomEvent<{
|
|
274
|
+
text: string;
|
|
275
|
+
}>) => void;
|
|
276
|
+
/**
|
|
277
|
+
* Preventable attach listener.
|
|
278
|
+
*/
|
|
279
|
+
onattach?: (event: CustomEvent<{
|
|
280
|
+
files: File[];
|
|
281
|
+
}>) => void;
|
|
282
|
+
/**
|
|
283
|
+
* Chip removal listener.
|
|
284
|
+
*/
|
|
285
|
+
onremove?: (event: CustomEvent<ComposerRemoveDetail>) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Mention listener.
|
|
288
|
+
*/
|
|
289
|
+
onmention?: (event: CustomEvent<{
|
|
290
|
+
item: MentionItem;
|
|
291
|
+
}>) => void;
|
|
292
|
+
/**
|
|
293
|
+
* Command listener.
|
|
294
|
+
*/
|
|
295
|
+
oncommand?: (event: CustomEvent<{
|
|
296
|
+
item: LauncherItem;
|
|
297
|
+
}>) => void;
|
|
298
|
+
/**
|
|
299
|
+
* Tool listener.
|
|
300
|
+
*/
|
|
301
|
+
ontool?: (event: CustomEvent<ComposerToolDetail>) => void;
|
|
302
|
+
/**
|
|
303
|
+
* Listener for
|
|
304
|
+
* ArrowUp on an empty text.
|
|
305
|
+
*/
|
|
306
|
+
onhistoryprevious?: (event: CustomEvent<Record<string, never>>) => void;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Where a mention starts and what has been typed of it: the text after the trigger up to the caret,
|
|
310
|
+
* when the trigger opens a word and the query holds no whitespace.
|
|
311
|
+
* @param {string} text The whole text.
|
|
312
|
+
* @param {number} caret Caret offset.
|
|
313
|
+
* @param {string} [trigger='@'] Character that starts a mention.
|
|
314
|
+
* @returns {{start: number, query: string}|null}
|
|
315
|
+
*/
|
|
316
|
+
export declare function mentionQuery(text: string, caret: number, trigger?: string): {
|
|
317
|
+
start: number;
|
|
318
|
+
query: string;
|
|
319
|
+
} | null;
|
|
320
|
+
/**
|
|
321
|
+
* The items that match a mention query, best first: a label that starts with it, then a word in
|
|
322
|
+
* the label that does, then a label or description that contains it. Case and accents are ignored;
|
|
323
|
+
* items that rank the same keep their order. An empty query keeps every item.
|
|
324
|
+
* @param {MentionItem[]} items
|
|
325
|
+
* @param {string} query
|
|
326
|
+
* @returns {MentionItem[]}
|
|
327
|
+
*/
|
|
328
|
+
export declare function filterMentions(items: MentionItem[], query: string): MentionItem[];
|
|
329
|
+
/**
|
|
330
|
+
* The picked mentions whose `@<label>` is still in the text, each once.
|
|
331
|
+
* @param {string} text
|
|
332
|
+
* @param {MentionItem[]} mentions Mentions in the order they were picked.
|
|
333
|
+
* @param {string} [trigger='@']
|
|
334
|
+
* @returns {MentionItem[]}
|
|
335
|
+
*/
|
|
336
|
+
export declare function mentionsInText(text: string, mentions: MentionItem[], trigger?: string): MentionItem[];
|
|
337
|
+
/**
|
|
338
|
+
* Whether a key press sends. A press during an IME composition never does.
|
|
339
|
+
* @param {{key: string, shiftKey?: boolean, metaKey?: boolean, ctrlKey?: boolean, altKey?: boolean,
|
|
340
|
+
* isComposing?: boolean, keyCode?: number}} event Key event, or its fields.
|
|
341
|
+
* @param {'enter'|'mod+enter'} [submitKey='enter']
|
|
342
|
+
* @param {{apple?: boolean}} [platform] `apple`: whether Mod is Cmd (otherwise Ctrl). Read from the
|
|
343
|
+
* browser when omitted.
|
|
344
|
+
* @returns {boolean}
|
|
345
|
+
*/
|
|
346
|
+
export declare function isSubmitKey(event: {
|
|
347
|
+
key: string;
|
|
348
|
+
shiftKey?: boolean;
|
|
349
|
+
metaKey?: boolean;
|
|
350
|
+
ctrlKey?: boolean;
|
|
351
|
+
altKey?: boolean;
|
|
352
|
+
isComposing?: boolean;
|
|
353
|
+
keyCode?: number;
|
|
354
|
+
}, submitKey?: 'enter' | 'mod+enter', { apple }?: {
|
|
355
|
+
apple?: boolean;
|
|
356
|
+
}): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Whether a file matches an `accept` list in the `<input type="file">` syntax: extensions
|
|
359
|
+
* (`.pdf`), whole MIME types (`application/json`), and MIME groups (`image/*`).
|
|
360
|
+
* @param {{name?: string, type?: string}} file
|
|
361
|
+
* @param {string} [accept='']
|
|
362
|
+
* @returns {boolean}
|
|
363
|
+
*/
|
|
364
|
+
export declare function acceptsFile(file: {
|
|
365
|
+
name?: string;
|
|
366
|
+
type?: string;
|
|
367
|
+
}, accept?: string): boolean;
|
|
368
|
+
/**
|
|
369
|
+
* The rows the text spans at least and at most: whole numbers of one or more, the least never above
|
|
370
|
+
* the most.
|
|
371
|
+
* @param {number} [minRows=1]
|
|
372
|
+
* @param {number} [maxRows=10]
|
|
373
|
+
* @returns {{min: number, max: number}}
|
|
374
|
+
*/
|
|
375
|
+
export declare function rowRange(minRows?: number, maxRows?: number): {
|
|
376
|
+
min: number;
|
|
377
|
+
max: number;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* The height an auto-growing text area takes for its content: at least `minRows` lines, at most
|
|
381
|
+
* `maxRows`, scrolling beyond that.
|
|
382
|
+
* @param {number} scrollHeight The content height, padding included (`textarea.scrollHeight`).
|
|
383
|
+
* @param {{lineHeight: number, padding?: number, border?: number, minRows?: number, maxRows?: number}} metrics
|
|
384
|
+
* Line height and the block padding and border, in pixels.
|
|
385
|
+
* @returns {{height: number, scrolls: boolean}} The border-box height, and whether the content
|
|
386
|
+
* overflows it.
|
|
387
|
+
*/
|
|
388
|
+
export declare function autosizeHeight(scrollHeight: number, { lineHeight, padding, border, minRows, maxRows }: {
|
|
389
|
+
lineHeight: number;
|
|
390
|
+
padding?: number;
|
|
391
|
+
border?: number;
|
|
392
|
+
minRows?: number;
|
|
393
|
+
maxRows?: number;
|
|
394
|
+
}): {
|
|
395
|
+
height: number;
|
|
396
|
+
scrolls: boolean;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* The bar's extra tools as the composer draws them: entries without an `id`, a non-empty `label`
|
|
400
|
+
* or an `icon` are left out, a repeated id keeps its first entry, `id`, `label` and `icon` become
|
|
401
|
+
* strings, `disabled` a boolean, and `pressed` stays only when it is a boolean. Any other field the
|
|
402
|
+
* application put on a tool is kept, and handed back in `tool`.
|
|
403
|
+
* @param {unknown} tools
|
|
404
|
+
* @returns {ComposerTool[]}
|
|
405
|
+
*/
|
|
406
|
+
export declare function normalizeTools(tools: unknown): ComposerTool[];
|
|
407
|
+
/**
|
|
408
|
+
* A message box for talking to an agent: a text that grows with what is written, Send (Stop while
|
|
409
|
+
* the agent works), attachments, `@` mentions, `/` commands, and context chips. It keeps nothing
|
|
410
|
+
* but the unsent message: sending hands the text, files, mentions and context to the application,
|
|
411
|
+
* which owns the conversation.
|
|
412
|
+
*
|
|
413
|
+
* @fires Composer#send
|
|
414
|
+
* @fires Composer#stop
|
|
415
|
+
* @fires Composer#input
|
|
416
|
+
* @fires Composer#attach
|
|
417
|
+
* @fires Composer#remove
|
|
418
|
+
* @fires Composer#mention
|
|
419
|
+
* @fires Composer#command
|
|
420
|
+
* @fires Composer#tool
|
|
421
|
+
* @fires Composer#historyprevious
|
|
422
|
+
* @extends {Component<ComposerOptions>}
|
|
423
|
+
*/
|
|
424
|
+
export declare class Composer extends Component<ComposerOptions> {
|
|
425
|
+
_original: import("../../core/dom.js").TargetSnapshot;
|
|
426
|
+
/** @type {{id: string, file: File}[]} */
|
|
427
|
+
_files: {
|
|
428
|
+
id: string;
|
|
429
|
+
file: File;
|
|
430
|
+
}[];
|
|
431
|
+
/** @type {ContextChip[]} */
|
|
432
|
+
_context: ContextChip[];
|
|
433
|
+
/** @type {MentionItem[]} */
|
|
434
|
+
_mentions: MentionItem[];
|
|
435
|
+
/** @type {{start: number, end: number, items: MentionItem[], index: number}|null} */
|
|
436
|
+
_mention: {
|
|
437
|
+
start: number;
|
|
438
|
+
end: number;
|
|
439
|
+
items: MentionItem[];
|
|
440
|
+
index: number;
|
|
441
|
+
} | null;
|
|
442
|
+
_mentionSequence: number;
|
|
443
|
+
/** @type {import('../../core/position.js').PositionController|null} */
|
|
444
|
+
_position: import('../../core/position.js').PositionController | null;
|
|
445
|
+
/** @type {Launcher|null} */
|
|
446
|
+
_launcher: Launcher | null;
|
|
447
|
+
_announced: any;
|
|
448
|
+
_busy: boolean;
|
|
449
|
+
_disabled: boolean;
|
|
450
|
+
_destroyed: boolean;
|
|
451
|
+
_width: any;
|
|
452
|
+
/** What the Send button last drew: mode, send key and label, so it redraws only on a change. */
|
|
453
|
+
_sendDrawn: any;
|
|
454
|
+
_mentionSource: {
|
|
455
|
+
trigger: string;
|
|
456
|
+
items: MentionSource['items'];
|
|
457
|
+
};
|
|
458
|
+
_commands: import("../launcher/launcher.js").LauncherItem[];
|
|
459
|
+
_draft: import("../../core/storage.js").NamespacedStorage;
|
|
460
|
+
_tools: ComposerTool[];
|
|
461
|
+
_sendLabel: string;
|
|
462
|
+
_rows: {
|
|
463
|
+
min: number;
|
|
464
|
+
max: number;
|
|
465
|
+
};
|
|
466
|
+
/** @type {'enter'|'mod+enter'} */
|
|
467
|
+
_submitKey: 'enter' | 'mod+enter';
|
|
468
|
+
_input: HTMLTextAreaElement;
|
|
469
|
+
_observer: ResizeObserver;
|
|
470
|
+
static cssName: string;
|
|
471
|
+
/** @type {Readonly<ComposerOptions>} */
|
|
472
|
+
static defaults: Readonly<ComposerOptions>;
|
|
473
|
+
/** @returns {HTMLElement} */
|
|
474
|
+
render(): HTMLElement;
|
|
475
|
+
/** Focuses the text. @returns {this} */
|
|
476
|
+
focus(): this;
|
|
477
|
+
/** @returns {string} The text as written. */
|
|
478
|
+
getValue(): string;
|
|
479
|
+
/**
|
|
480
|
+
* Replaces the text, keeps the draft in step, and puts the caret at the end. Emits nothing.
|
|
481
|
+
* @param {string} text
|
|
482
|
+
* @returns {this}
|
|
483
|
+
*/
|
|
484
|
+
setValue(text: string): this;
|
|
485
|
+
/**
|
|
486
|
+
* Types text at the caret, replacing any selection, as if the person had typed it: the draft
|
|
487
|
+
* follows, and text ending in the mention trigger (`'@'`) opens the suggestions. Emits `input`.
|
|
488
|
+
* Use it for a button that starts a mention or inserts a snippet.
|
|
489
|
+
* @param {string} text
|
|
490
|
+
* @returns {this}
|
|
491
|
+
*/
|
|
492
|
+
insertText(text: string): this;
|
|
493
|
+
/**
|
|
494
|
+
* Empties the text, the attachments and the draft. Context chips stay. Emits nothing.
|
|
495
|
+
* @returns {this}
|
|
496
|
+
*/
|
|
497
|
+
clear(): this;
|
|
498
|
+
/**
|
|
499
|
+
* Shows Stop in place of Send while an agent works; Escape in the text then emits `stop`.
|
|
500
|
+
* @param {boolean} busy
|
|
501
|
+
* @returns {this}
|
|
502
|
+
*/
|
|
503
|
+
setBusy(busy: boolean): this;
|
|
504
|
+
/** @returns {boolean} Whether Stop is showing. */
|
|
505
|
+
isBusy(): boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Changes the quiet text in the bar beside Send — what Enter does now, or why sending waits.
|
|
508
|
+
* An empty text hides it.
|
|
509
|
+
* @param {string} text
|
|
510
|
+
* @returns {this}
|
|
511
|
+
*/
|
|
512
|
+
setHint(text: string): this;
|
|
513
|
+
/**
|
|
514
|
+
* Changes the line under the composer, which also describes the text box. An empty text hides
|
|
515
|
+
* it.
|
|
516
|
+
* @param {string} text
|
|
517
|
+
* @returns {this}
|
|
518
|
+
*/
|
|
519
|
+
setNote(text: string): this;
|
|
520
|
+
/**
|
|
521
|
+
* Turns input on or off.
|
|
522
|
+
* @param {boolean} disabled
|
|
523
|
+
* @returns {this}
|
|
524
|
+
*/
|
|
525
|
+
setDisabled(disabled: boolean): this;
|
|
526
|
+
/**
|
|
527
|
+
* Changes the composer in place: the text, its caret and selection, the focus, the attachments,
|
|
528
|
+
* the context chips and the draft all stay. This is how a placeholder follows the model picked
|
|
529
|
+
* beside the composer. Keys left out (or `undefined`) are kept; other keys are ignored. Emits
|
|
530
|
+
* nothing.
|
|
531
|
+
* @param {ComposerUpdate} [partial={}]
|
|
532
|
+
* @returns {this}
|
|
533
|
+
*/
|
|
534
|
+
update(partial?: ComposerUpdate): this;
|
|
535
|
+
/**
|
|
536
|
+
* Replaces the bar's extra tools. A tool that held the focus keeps it when a tool with the same
|
|
537
|
+
* id is still there (and enabled); otherwise the focus moves to the text. Emits nothing.
|
|
538
|
+
* @param {ComposerTool[]} tools
|
|
539
|
+
* @returns {this}
|
|
540
|
+
*/
|
|
541
|
+
setTools(tools: ComposerTool[]): this;
|
|
542
|
+
/**
|
|
543
|
+
* Presses or releases a tool, which makes it a toggle if it was a plain button. Emits nothing.
|
|
544
|
+
* @param {string} id
|
|
545
|
+
* @param {boolean} pressed
|
|
546
|
+
* @returns {this}
|
|
547
|
+
*/
|
|
548
|
+
setToolPressed(id: string, pressed: boolean): this;
|
|
549
|
+
/**
|
|
550
|
+
* Attaches files, as far as `accept` and `maxFiles` allow. Emits `attach` with the files taken.
|
|
551
|
+
* @param {FileList|File[]} files
|
|
552
|
+
* @returns {this}
|
|
553
|
+
*/
|
|
554
|
+
addFiles(files: FileList | File[]): this;
|
|
555
|
+
/** @returns {File[]} The attached files. */
|
|
556
|
+
getFiles(): File[];
|
|
557
|
+
/**
|
|
558
|
+
* Adds a context chip, or replaces the chip with the same id. Emits nothing.
|
|
559
|
+
* @param {ContextChip} chip
|
|
560
|
+
* @returns {this}
|
|
561
|
+
*/
|
|
562
|
+
addContext(chip: ContextChip): this;
|
|
563
|
+
/**
|
|
564
|
+
* Removes a context chip. Emits nothing.
|
|
565
|
+
* @param {string} id
|
|
566
|
+
* @returns {this}
|
|
567
|
+
*/
|
|
568
|
+
removeContext(id: string): this;
|
|
569
|
+
/** @returns {ContextChip[]} The context chips. */
|
|
570
|
+
getContext(): ContextChip[];
|
|
571
|
+
/** Removes what the composer drew and the launcher it opened, and stops listening. @returns {void} */
|
|
572
|
+
destroy(): void;
|
|
573
|
+
/** @private @returns {void} */
|
|
574
|
+
private _onInput;
|
|
575
|
+
/** @private @returns {void} */
|
|
576
|
+
private _afterTextChange;
|
|
577
|
+
/** @private @returns {void} */
|
|
578
|
+
private _saveDraft;
|
|
579
|
+
/** Grows the text with its content, between `minRows` and `maxRows`. @private @returns {void} */
|
|
580
|
+
private _autosize;
|
|
581
|
+
/**
|
|
582
|
+
* @private
|
|
583
|
+
* @param {KeyboardEvent} event
|
|
584
|
+
* @returns {void}
|
|
585
|
+
*/
|
|
586
|
+
private _onKeydown;
|
|
587
|
+
/** @private @returns {void} @fires Composer#send */
|
|
588
|
+
private _send;
|
|
589
|
+
/** @private @returns {void} @fires Composer#stop */
|
|
590
|
+
private _stop;
|
|
591
|
+
/**
|
|
592
|
+
* The Send button's glyph, text, name and readiness. With `sendLabel` the text is visible and is
|
|
593
|
+
* the name; without it the button is a glyph named by `aria-label` alone.
|
|
594
|
+
* @private
|
|
595
|
+
* @returns {void}
|
|
596
|
+
*/
|
|
597
|
+
private _syncSend;
|
|
598
|
+
/** Disabled state on the text and the buttons. @private @returns {void} */
|
|
599
|
+
private _syncState;
|
|
600
|
+
/**
|
|
601
|
+
* The accessible name for a `label` option: the text given, or the `composer.label` message.
|
|
602
|
+
* @private
|
|
603
|
+
* @param {string|null|undefined} label
|
|
604
|
+
* @returns {string}
|
|
605
|
+
*/
|
|
606
|
+
private _labelText;
|
|
607
|
+
/**
|
|
608
|
+
* Draws the extra tools, and puts the focus back on the tool that held it.
|
|
609
|
+
* @private
|
|
610
|
+
* @returns {void}
|
|
611
|
+
*/
|
|
612
|
+
private _renderTools;
|
|
613
|
+
/**
|
|
614
|
+
* @private
|
|
615
|
+
* @param {string} id
|
|
616
|
+
* @returns {HTMLButtonElement|null}
|
|
617
|
+
*/
|
|
618
|
+
private _toolButton;
|
|
619
|
+
/**
|
|
620
|
+
* @private
|
|
621
|
+
* @param {MouseEvent} event
|
|
622
|
+
* @returns {void}
|
|
623
|
+
* @fires Composer#tool
|
|
624
|
+
*/
|
|
625
|
+
private _onToolClick;
|
|
626
|
+
/**
|
|
627
|
+
* Opens, filters or closes the suggestions from the word the caret is in.
|
|
628
|
+
* @private
|
|
629
|
+
* @returns {void}
|
|
630
|
+
*/
|
|
631
|
+
private _updateMentions;
|
|
632
|
+
/**
|
|
633
|
+
* @private
|
|
634
|
+
* @param {number} start Offset of the trigger.
|
|
635
|
+
* @param {number} end Caret offset.
|
|
636
|
+
* @param {MentionItem[]} items
|
|
637
|
+
* @returns {void}
|
|
638
|
+
*/
|
|
639
|
+
private _showMentions;
|
|
640
|
+
/**
|
|
641
|
+
* @private
|
|
642
|
+
* @param {number} index
|
|
643
|
+
* @returns {void}
|
|
644
|
+
*/
|
|
645
|
+
private _highlight;
|
|
646
|
+
/** @private @returns {void} */
|
|
647
|
+
private _closeMentions;
|
|
648
|
+
/**
|
|
649
|
+
* Writes `@<label> ` where the mention was typed and records the item.
|
|
650
|
+
* @private
|
|
651
|
+
* @param {number} index
|
|
652
|
+
* @returns {void}
|
|
653
|
+
* @fires Composer#mention
|
|
654
|
+
*/
|
|
655
|
+
private _pickMention;
|
|
656
|
+
/**
|
|
657
|
+
* Sets the polite status, once per change.
|
|
658
|
+
* @private
|
|
659
|
+
* @param {string} text
|
|
660
|
+
* @returns {void}
|
|
661
|
+
*/
|
|
662
|
+
private _announce;
|
|
663
|
+
/**
|
|
664
|
+
* Opens the commands in a launcher, created on first use.
|
|
665
|
+
* @private
|
|
666
|
+
* @returns {void}
|
|
667
|
+
* @fires Composer#command
|
|
668
|
+
*/
|
|
669
|
+
private _openCommands;
|
|
670
|
+
/**
|
|
671
|
+
* @private
|
|
672
|
+
* @param {File[]} files
|
|
673
|
+
* @param {boolean} fromPicker Whether the files came through the file input, which applied
|
|
674
|
+
* `accept` already.
|
|
675
|
+
* @returns {void}
|
|
676
|
+
* @fires Composer#attach
|
|
677
|
+
*/
|
|
678
|
+
private _addFiles;
|
|
679
|
+
/**
|
|
680
|
+
* @private
|
|
681
|
+
* @param {ClipboardEvent} event
|
|
682
|
+
* @returns {void}
|
|
683
|
+
*/
|
|
684
|
+
private _onPaste;
|
|
685
|
+
/**
|
|
686
|
+
* @private
|
|
687
|
+
* @param {DragEvent} event
|
|
688
|
+
* @returns {void}
|
|
689
|
+
*/
|
|
690
|
+
private _onDrag;
|
|
691
|
+
/**
|
|
692
|
+
* @private
|
|
693
|
+
* @param {DragEvent} event
|
|
694
|
+
* @returns {void}
|
|
695
|
+
*/
|
|
696
|
+
private _onDrop;
|
|
697
|
+
/**
|
|
698
|
+
* @private
|
|
699
|
+
* @param {boolean} dropping
|
|
700
|
+
* @returns {void}
|
|
701
|
+
*/
|
|
702
|
+
private _setDropping;
|
|
703
|
+
/**
|
|
704
|
+
* @private
|
|
705
|
+
* @param {ContextChip} chip
|
|
706
|
+
* @returns {void}
|
|
707
|
+
*/
|
|
708
|
+
private _putContext;
|
|
709
|
+
/** @private @returns {void} */
|
|
710
|
+
private _renderFiles;
|
|
711
|
+
/** @private @returns {void} */
|
|
712
|
+
private _renderContext;
|
|
713
|
+
/**
|
|
714
|
+
* @private
|
|
715
|
+
* @param {{kind: 'file'|'context', id: string, label: string, glyph: string|null, meta: string}} chip
|
|
716
|
+
* @returns {HTMLElement}
|
|
717
|
+
*/
|
|
718
|
+
private _chip;
|
|
719
|
+
/**
|
|
720
|
+
* Removes the chip whose button was pressed, and keeps the focus in the list.
|
|
721
|
+
* @private
|
|
722
|
+
* @param {MouseEvent} event
|
|
723
|
+
* @returns {void}
|
|
724
|
+
* @fires Composer#remove
|
|
725
|
+
*/
|
|
726
|
+
private _onChipClick;
|
|
727
|
+
}
|
|
728
|
+
/** Fired when the message is sent; preventable, which keeps the text and files. @event Composer#send @type {CustomEvent<ComposerSendDetail>} */
|
|
729
|
+
/** Fired when Stop is pressed, or Escape in the text while busy. @event Composer#stop @type {CustomEvent<Record<string, never>>} */
|
|
730
|
+
/** Fired when the reader changes the text. @event Composer#input @type {CustomEvent<{text: string}>} */
|
|
731
|
+
/** Fired before files are attached; preventable. @event Composer#attach @type {CustomEvent<{files: File[]}>} */
|
|
732
|
+
/** Fired after the reader removes an attachment or a context chip. @event Composer#remove @type {CustomEvent<ComposerRemoveDetail>} */
|
|
733
|
+
/** Fired when a suggestion is picked. @event Composer#mention @type {CustomEvent<{item: MentionItem}>} */
|
|
734
|
+
/** Fired when a command is chosen. @event Composer#command @type {CustomEvent<{item: LauncherItem}>} */
|
|
735
|
+
/** Fired when one of the extra tools is pressed; the composer changes nothing itself. @event Composer#tool @type {CustomEvent<ComposerToolDetail>} */
|
|
736
|
+
/** Fired for ArrowUp on an empty text. @event Composer#historyprevious @type {CustomEvent<Record<string, never>>} */
|