@green-on-grey/ui-kit 1.2.0 → 1.4.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/dist/chat/Attachments.d.ts +37 -0
- package/dist/chat/Chat.d.ts +5 -0
- package/dist/chat/MessageView.d.ts +6 -2
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/intl.d.ts +2 -0
- package/dist/chat/types.d.ts +6 -0
- package/dist/chat.js +564 -178
- package/dist/chat.js.map +1 -1
- package/dist/components/Icon.d.ts +3 -0
- package/dist/components/TopBar.d.ts +10 -2
- package/dist/index.js +25 -21
- package/dist/index.js.map +1 -1
- package/dist/locales/index.d.ts +55 -0
- package/dist/locales.js +60 -5
- package/dist/locales.js.map +1 -1
- package/dist/manifest.json +45 -1
- package/dist/styles.css +77 -2
- package/dist/{ui-joAvYmUH.js → ui-ChXUXoIB.js} +4 -1
- package/dist/ui-ChXUXoIB.js.map +1 -0
- package/package.json +1 -1
- package/dist/ui-joAvYmUH.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type IconName } from "../components/Icon";
|
|
2
|
+
import type { ChatAttachment } from "./types";
|
|
3
|
+
export type PreviewKind = "image" | "pdf" | "markdown" | "table" | "html" | "text";
|
|
4
|
+
/** Loads the content of an attachment: the product fetches it with its session. */
|
|
5
|
+
export type LoadAttachment = (a: ChatAttachment) => Promise<Blob>;
|
|
6
|
+
/** Text, tables and Markdown larger than this are downloaded, not drawn. */
|
|
7
|
+
export declare const TEXT_PREVIEW_MAX: number;
|
|
8
|
+
/** The rows of a table shown in the preview. */
|
|
9
|
+
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;
|
|
12
|
+
/** The icon of a kind of preview: the tiles of the chat and the products' own lists of files show it. */
|
|
13
|
+
export declare const previewIcon: (kind: PreviewKind) => IconName;
|
|
14
|
+
/** The size of a file in the units of the language. */
|
|
15
|
+
export declare function fileSize(bytes: number, language: string): string;
|
|
16
|
+
/** The document of a previewed HTML page. In a browser the page is parsed inert (a DOMParser loads nothing) and
|
|
17
|
+
* cleaned of everything that would load or lead anywhere: scripts, frames, plug-ins, links of the head, its own
|
|
18
|
+
* `http-equiv` (a refresh), and every address that is not `data:`, `blob:` or an anchor — a relative one would go to
|
|
19
|
+
* the site with the session. The policy is put first into the head, after the doctype of the file, so the page keeps
|
|
20
|
+
* its mode. The policy alone is not enough: a browser may fetch a picture before it applies a policy of a meta. */
|
|
21
|
+
export declare function htmlDocument(text: string): string;
|
|
22
|
+
/** The type a preview draws a file with: its own, else the one of its extension. */
|
|
23
|
+
export declare function previewType(a: Pick<ChatAttachment, "fileName" | "mimeType">): string | undefined;
|
|
24
|
+
/** The rows of CSV (quotes by RFC 4180) or TSV. */
|
|
25
|
+
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 }: {
|
|
28
|
+
items: ChatAttachment[];
|
|
29
|
+
load?: LoadAttachment;
|
|
30
|
+
onOpen?: (a: ChatAttachment) => void;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
/** The preview of an attachment: an image, the browser's PDF viewer, drawn Markdown, a table or text. */
|
|
33
|
+
export declare function AttachmentPreview({ a, load, onClose }: {
|
|
34
|
+
a: ChatAttachment;
|
|
35
|
+
load: LoadAttachment;
|
|
36
|
+
onClose: () => void;
|
|
37
|
+
}): import("react").JSX.Element;
|
package/dist/chat/Chat.d.ts
CHANGED
|
@@ -4,3 +4,8 @@ import type { ChatProps } from "./types";
|
|
|
4
4
|
* chat of Nabu. A control exists only when the product gave its handler: no
|
|
5
5
|
* `onCancel` — no cancel button, no `commands` — no palette. */
|
|
6
6
|
export declare function Chat(props: ChatProps): import("react").JSX.Element;
|
|
7
|
+
export declare function VoiceButton({ supported, recognizing, onStart }: {
|
|
8
|
+
supported: boolean;
|
|
9
|
+
recognizing: boolean;
|
|
10
|
+
onStart: () => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type LoadAttachment } from "./Attachments";
|
|
2
|
+
import type { ChatAttachment, ChatMessage, ChatStep } from "./types";
|
|
2
3
|
/** The time of a caption: hours and minutes in the language of the interface. */
|
|
3
4
|
export declare function markTime(iso: string, language: string): string;
|
|
4
5
|
/** More than three steps are folded to the last two (design §6.4). */
|
|
5
6
|
export declare function visibleSteps(steps: ChatStep[], open: boolean): ChatStep[];
|
|
6
7
|
/** One message of the conversation (design §6.4). */
|
|
7
|
-
export declare function MessageView({ m, busy, onRetry }: {
|
|
8
|
+
export declare function MessageView({ m, busy, onRetry, loadAttachment, onOpenAttachment }: {
|
|
8
9
|
m: ChatMessage;
|
|
9
10
|
busy: boolean;
|
|
10
11
|
onRetry?: () => void;
|
|
12
|
+
/** R34: the preview of the files; without it they are links. */
|
|
13
|
+
loadAttachment?: LoadAttachment;
|
|
14
|
+
onOpenAttachment?: (a: ChatAttachment) => void;
|
|
11
15
|
}): import("react").JSX.Element;
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { Chat } from "./Chat";
|
|
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
4
|
export { AgentButton, AgentMenu, type AgentModelOption, type AgentModels, type AgentOption } from "./AgentMenu";
|
|
4
5
|
export { CommandPalette } from "./CommandPalette";
|
|
5
6
|
export { ContextMeter, tokens } from "./ContextMeter";
|
package/dist/chat/types.d.ts
CHANGED
|
@@ -14,8 +14,12 @@ export interface ChatUpload {
|
|
|
14
14
|
id: string;
|
|
15
15
|
fileName: string;
|
|
16
16
|
}
|
|
17
|
+
/** A file of a message: `href` downloads it; the type and the size choose and caption its preview
|
|
18
|
+
* (FTR.NAB.CHAT-0001 R34). */
|
|
17
19
|
export interface ChatAttachment extends ChatUpload {
|
|
18
20
|
href: string;
|
|
21
|
+
mimeType?: string;
|
|
22
|
+
size?: number;
|
|
19
23
|
}
|
|
20
24
|
export interface ChatStep {
|
|
21
25
|
id: string;
|
|
@@ -129,6 +133,8 @@ export interface ChatProps {
|
|
|
129
133
|
onConfirm?(id: string, approve: boolean): void;
|
|
130
134
|
/** `null`: the upload failed and the product has told the user. */
|
|
131
135
|
onUpload?(file: File): Promise<ChatUpload | null>;
|
|
136
|
+
/** Loads a file of a message for its preview (R34): images, PDF and Markdown open in the chat. Without it files are links. */
|
|
137
|
+
loadAttachment?(attachment: ChatAttachment): Promise<Blob>;
|
|
132
138
|
/** The files attached to the message being written, after every change. */
|
|
133
139
|
onPendingChange?(uploads: ChatUpload[]): void;
|
|
134
140
|
/** The text of a recording; `null`: it failed and the product has told the user. A rejection
|