@green-on-grey/ui-kit 1.8.0 → 1.10.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.
@@ -1,14 +1,21 @@
1
1
  import { type IconName } from "../components/Icon";
2
- import type { ChatAttachment } from "./types";
3
- export type PreviewKind = "image" | "pdf" | "markdown" | "table" | "html" | "text";
2
+ import type { ChatAttachment, OfficePreview, Sheet } from "./types";
3
+ export type PreviewKind = "image" | "pdf" | "markdown" | "table" | "html" | "text" | "office-doc" | "office-sheet";
4
4
  /** Loads the content of an attachment: the product fetches it with its session. */
5
5
  export type LoadAttachment = (a: ChatAttachment) => Promise<Blob>;
6
+ /** Loads the preview of a document or a spreadsheet (FTR.NAB.CHAT-0003 R13–R16): the product asks its API; a
7
+ * `pending` answer is asked again. */
8
+ export type LoadOfficePreview = (a: ChatAttachment) => Promise<OfficePreview>;
9
+ /** The rows and columns of a sheet in the preview (R14). */
10
+ export declare const SHEET_ROWS = 500;
11
+ export declare const SHEET_COLS = 50;
6
12
  /** Text, tables and Markdown larger than this are downloaded, not drawn. */
7
13
  export declare const TEXT_PREVIEW_MAX: number;
8
14
  /** The rows of a table shown in the preview. */
9
15
  export declare const TABLE_ROWS = 500;
10
- /** How an attachment is previewed, or null when it is only downloaded. */
11
- export declare function previewKind(a: Pick<ChatAttachment, "fileName" | "mimeType">): PreviewKind | null;
16
+ /** How an attachment is previewed, or null when it is only downloaded. `office`: the product previews
17
+ * documents and spreadsheets (FTR.NAB.CHAT-0003). */
18
+ export declare function previewKind(a: Pick<ChatAttachment, "fileName" | "mimeType">, office?: boolean): PreviewKind | null;
12
19
  /** The icon of a kind of preview: the tiles of the chat and the products' own lists of files show it. */
13
20
  export declare const previewIcon: (kind: PreviewKind) => IconName;
14
21
  /** The size of a file in the units of the language. */
@@ -23,18 +30,32 @@ export declare function htmlDocument(text: string): string;
23
30
  export declare function previewType(a: Pick<ChatAttachment, "fileName" | "mimeType">): string | undefined;
24
31
  /** The rows of CSV (quotes by RFC 4180) or TSV. */
25
32
  export declare function parseTable(text: string, tab: boolean): string[][];
26
- /** The files of a message: thumbnails of images and tiles; without `load` every file downloads. */
27
- export declare function AttachmentList({ items, load, onOpen }: {
33
+ /** The files of a message: thumbnails of images and tiles; without `load` every file downloads. `office`:
34
+ * documents and spreadsheets open in the preview (FTR.NAB.CHAT-0003). */
35
+ export declare function AttachmentList({ items, load, onOpen, office }: {
28
36
  items: ChatAttachment[];
29
37
  load?: LoadAttachment;
30
38
  onOpen?: (a: ChatAttachment) => void;
39
+ office?: boolean;
31
40
  }): import("react").JSX.Element;
32
41
  /** The width a previewed page is laid out at: the one of a desktop. A narrower frame shows it scaled down, so a
33
42
  * page made for a screen (a deck of slides) is seen whole instead of cut. */
34
43
  export declare const PAGE_WIDTH = 1280;
35
- /** The preview of an attachment: an image, the browser's PDF viewer, drawn Markdown, a table or text. */
36
- export declare function AttachmentPreview({ a, load, onClose }: {
44
+ /** The preview of an attachment: an image, the browser's PDF viewer, drawn Markdown, a table or text; with
45
+ * `loadPreview` — documents and spreadsheets as well (FTR.NAB.CHAT-0003). */
46
+ export declare function AttachmentPreview({ a, load, loadPreview, onClose }: {
37
47
  a: ChatAttachment;
38
48
  load: LoadAttachment;
49
+ loadPreview?: LoadOfficePreview;
39
50
  onClose: () => void;
40
51
  }): import("react").JSX.Element;
52
+ /** The merged ranges of a sheet: the spans of their first cells and the cells they cover. */
53
+ export declare function mergeSpans(merges: string[]): {
54
+ spans: Map<string, [number, number]>;
55
+ covered: Set<string>;
56
+ };
57
+ /** The letters of a column: 1 → A, 27 → AA. */
58
+ export declare function columnName(n: number): string;
59
+ export declare function SheetView({ sheets }: {
60
+ sheets: Sheet[];
61
+ }): import("react").JSX.Element;
@@ -1,15 +1,19 @@
1
- import { type LoadAttachment } from "./Attachments";
1
+ import { type LoadAttachment, type LoadOfficePreview } from "./Attachments";
2
2
  import type { ChatAttachment, ChatMessage, ChatStep } from "./types";
3
3
  /** The time of a caption: hours and minutes in the language of the interface. */
4
4
  export declare function markTime(iso: string, language: string): string;
5
5
  /** More than three steps are folded to the last two (design §6.4). */
6
6
  export declare function visibleSteps(steps: ChatStep[], open: boolean): ChatStep[];
7
7
  /** One message of the conversation (design §6.4). */
8
- export declare function MessageView({ m, busy, onRetry, loadAttachment, onOpenAttachment }: {
8
+ export declare function MessageView({ m, busy, onRetry, loadAttachment, loadPreview, onOpenAttachment }: {
9
9
  m: ChatMessage;
10
10
  busy: boolean;
11
11
  onRetry?: () => void;
12
12
  /** R34: the preview of the files; without it they are links. */
13
13
  loadAttachment?: LoadAttachment;
14
14
  onOpenAttachment?: (a: ChatAttachment) => void;
15
+ /** FTR.NAB.CHAT-0003: documents and spreadsheets open in the preview too. */
16
+ loadPreview?: LoadOfficePreview;
15
17
  }): import("react").JSX.Element;
18
+ /** A notice longer than this many lines is folded (FTR.NAB.CHAT-0002 design §3.1). */
19
+ export declare const NOTICE_LINES = 12;
@@ -1,10 +1,10 @@
1
1
  export { Chat, VoiceButton } from "./Chat";
2
2
  export { ChatLayout, ConversationList, NewTopicModal } from "./ConversationList";
3
- export { AttachmentList, AttachmentPreview, fileSize, parseTable, previewIcon, previewKind, type LoadAttachment, type PreviewKind } from "./Attachments";
3
+ export { AttachmentList, AttachmentPreview, columnName, fileSize, parseTable, previewIcon, previewKind, type LoadAttachment, type LoadOfficePreview, type PreviewKind } from "./Attachments";
4
4
  export { AgentButton, AgentMenu, type AgentModelOption, type AgentModels, type AgentOption } from "./AgentMenu";
5
5
  export { AgentSettingsMenu, agentModelKey, agentModelOptions, type AgentModel, type AgentModelChoice, type AgentModelState, } from "./AgentSettingsMenu";
6
6
  export { CommandPalette } from "./CommandPalette";
7
7
  export { ContextMeter, tokens } from "./ContextMeter";
8
- export { MessageView } from "./MessageView";
8
+ export { MessageView, NOTICE_LINES } from "./MessageView";
9
9
  export { useRecorder } from "./useRecorder";
10
- export type { ChatAttachment, ChatCommand, ChatConfirmation, ChatContext, ChatConversation, ChatEvent, ChatMark, ChatMessage, ChatProps, ChatStep, ChatUpload, ChatWait, ConversationListProps, } from "./types";
10
+ export type { ChatAttachment, ChatCommand, ChatConfirmation, ChatContext, ChatConversation, ChatEvent, ChatMark, ChatMessage, ChatProps, ChatStep, ChatUpload, ChatWait, ConversationListProps, OfficePreview, Sheet, SheetCell, } from "./types";
@@ -66,6 +66,9 @@ export interface ChatMessage {
66
66
  };
67
67
  /** The content of the product inside the message: a mail card, a digest. */
68
68
  content?: ReactNode;
69
+ /** `notice`: an answer that is a notice of a product, not words of the agent (FTR.NAB.CHAT-0002 R2):
70
+ * a card with a stripe, without the actions of an answer, folded past `NOTICE_LINES` lines. */
71
+ variant?: "notice";
69
72
  /** The tooltip of the bubble: the model of an answer (FTR.NAB.CHAT-0001 R18). */
70
73
  hint?: string;
71
74
  }
@@ -99,6 +102,11 @@ export interface ChatProps {
99
102
  header?: ReactNode;
100
103
  /** The second line of the empty conversation. */
101
104
  emptyHint?: ReactNode;
105
+ /** Replaces the whole empty conversation: the draft of a topic with its suggestions
106
+ * (FTR.HMR.DISC-0001 design §3.2). `emptyHint` is then not used. */
107
+ empty?: ReactNode;
108
+ /** The placeholder of the composer instead of «Message to <agent>»; a picked skill keeps its own. */
109
+ placeholder?: string;
102
110
  loading?: boolean;
103
111
  historyError?: ReactNode;
104
112
  hasOlder?: boolean;
@@ -135,6 +143,9 @@ export interface ChatProps {
135
143
  onUpload?(file: File): Promise<ChatUpload | null>;
136
144
  /** Loads a file of a message for its preview (R34): images, PDF and Markdown open in the chat. Without it files are links. */
137
145
  loadAttachment?(attachment: ChatAttachment): Promise<Blob>;
146
+ /** FTR.NAB.CHAT-0003 R13–R16: the preview of a document (PDF of its first pages) or of a spreadsheet (sheets).
147
+ * Without it documents and spreadsheets download, as before. */
148
+ loadPreview?(attachment: ChatAttachment): Promise<OfficePreview>;
138
149
  /** The files attached to the message being written, after every change. */
139
150
  onPendingChange?(uploads: ChatUpload[]): void;
140
151
  /** The text of a recording; `null`: it failed and the product has told the user. A rejection
@@ -151,3 +162,34 @@ export interface ConversationListProps {
151
162
  /** Rejects with an Error whose message is shown in the dialog. */
152
163
  onCreate?(title: string): Promise<void>;
153
164
  }
165
+ /** A cell of a sheet: the value as shown (`v`), its number (`n`) or a formula without a value (`f`). */
166
+ export interface SheetCell {
167
+ v?: string;
168
+ n?: number;
169
+ f?: string;
170
+ }
171
+ /** A sheet of a spreadsheet in the preview (FTR.NAB.CHAT-0003 R14). */
172
+ export interface Sheet {
173
+ name: string;
174
+ rows: number;
175
+ cols: number;
176
+ cells: SheetCell[][];
177
+ merges: string[];
178
+ }
179
+ /** The answer of a preview of an office file (FTR.NAB.CHAT-0003 tech §8.1). */
180
+ export type OfficePreview = {
181
+ state: "pending";
182
+ } | {
183
+ state: "error";
184
+ reason: "too_large" | "timeout" | "broken" | "busy";
185
+ limitMb?: number;
186
+ } | {
187
+ state: "doc";
188
+ blob: Blob;
189
+ shown: number;
190
+ total: number | null;
191
+ from: string;
192
+ } | {
193
+ state: "sheet";
194
+ sheets: Sheet[];
195
+ };