@green-on-grey/ui-kit 1.3.0 → 1.5.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,5 +1,6 @@
1
+ import { type IconName } from "../components/Icon";
1
2
  import type { ChatAttachment } from "./types";
2
- export type PreviewKind = "image" | "pdf" | "markdown" | "table" | "text";
3
+ export type PreviewKind = "image" | "pdf" | "markdown" | "table" | "html" | "text";
3
4
  /** Loads the content of an attachment: the product fetches it with its session. */
4
5
  export type LoadAttachment = (a: ChatAttachment) => Promise<Blob>;
5
6
  /** Text, tables and Markdown larger than this are downloaded, not drawn. */
@@ -8,8 +9,18 @@ export declare const TEXT_PREVIEW_MAX: number;
8
9
  export declare const TABLE_ROWS = 500;
9
10
  /** How an attachment is previewed, or null when it is only downloaded. */
10
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;
11
14
  /** The size of a file in the units of the language. */
12
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;
13
24
  /** The rows of CSV (quotes by RFC 4180) or TSV. */
14
25
  export declare function parseTable(text: string, tab: boolean): string[][];
15
26
  /** The files of a message: thumbnails of images and tiles; without `load` every file downloads. */
@@ -18,6 +29,9 @@ export declare function AttachmentList({ items, load, onOpen }: {
18
29
  load?: LoadAttachment;
19
30
  onOpen?: (a: ChatAttachment) => void;
20
31
  }): import("react").JSX.Element;
32
+ /** The width a previewed page is laid out at: the one of a desktop. A narrower frame shows it scaled down, so a
33
+ * page made for a screen (a deck of slides) is seen whole instead of cut. */
34
+ export declare const PAGE_WIDTH = 1280;
21
35
  /** The preview of an attachment: an image, the browser's PDF viewer, drawn Markdown, a table or text. */
22
36
  export declare function AttachmentPreview({ a, load, onClose }: {
23
37
  a: ChatAttachment;
@@ -1,6 +1,6 @@
1
1
  export { Chat, VoiceButton } from "./Chat";
2
2
  export { ChatLayout, ConversationList, NewTopicModal } from "./ConversationList";
3
- export { AttachmentList, AttachmentPreview, fileSize, parseTable, previewKind, type LoadAttachment, type PreviewKind } from "./Attachments";
3
+ export { AttachmentList, AttachmentPreview, fileSize, parseTable, previewIcon, previewKind, type LoadAttachment, type PreviewKind } from "./Attachments";
4
4
  export { AgentButton, AgentMenu, type AgentModelOption, type AgentModels, type AgentOption } from "./AgentMenu";
5
5
  export { CommandPalette } from "./CommandPalette";
6
6
  export { ContextMeter, tokens } from "./ContextMeter";