@epam/ai-dial-attachment-canvas 0.0.0-dev.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.
@@ -0,0 +1,155 @@
1
+ import { CodeBlockTheme } from '@epam/ai-dial-chat-shared';
2
+ import { SidebarPanelStyles } from '@epam/ai-dial-sidebar';
3
+ import { InputHighlightData } from '@epam/pdf-highlighter-kit';
4
+ import { CSSProperties } from 'react';
5
+ import { AttachmentContentType } from '../types/attachment-canvas';
6
+ /** Content payload for plain-text attachments. */
7
+ export interface PlainTextCanvasContent {
8
+ /** Discriminates the content type to select the correct renderer. */
9
+ type: AttachmentContentType.PlainText;
10
+ /** The raw text to display. */
11
+ text: string;
12
+ }
13
+ /** Content payload for image attachments. */
14
+ export interface ImageCanvasContent {
15
+ /** Discriminates the content type to select the correct renderer. */
16
+ type: AttachmentContentType.Image;
17
+ /** URL of the image to display (object URL or resolved download URL). */
18
+ url: string;
19
+ }
20
+ /** Content payload for Markdown file attachments. */
21
+ export interface MarkdownCanvasContent {
22
+ /** Discriminates the content type to select the correct renderer. */
23
+ type: AttachmentContentType.Markdown;
24
+ /** Raw Markdown string to render. */
25
+ text: string;
26
+ }
27
+ /** Content payload for JSON file attachments. */
28
+ export interface JsonCanvasContent {
29
+ /** Discriminates the content type to select the correct renderer. */
30
+ type: AttachmentContentType.Json;
31
+ /** Already-parsed JSON value. The lib never calls JSON.parse. */
32
+ value: unknown;
33
+ }
34
+ /** Content payload for PDF file attachments. */
35
+ export interface PdfCanvasContent {
36
+ /** Discriminates the content type to select the correct renderer. */
37
+ type: AttachmentContentType.Pdf;
38
+ /** Resolved download URL or object URL for the PDF file. */
39
+ url: string;
40
+ /** Highlight regions to render over the PDF pages. */
41
+ highlights?: InputHighlightData[];
42
+ /** ID of the highlight to scroll to and select on initial load. */
43
+ selectedHighlightId?: string;
44
+ }
45
+ /** Content payload for attachments whose format cannot be previewed. */
46
+ export interface UnsupportedCanvasContent {
47
+ /** Discriminates the content type to select the correct renderer. */
48
+ type: AttachmentContentType.Unsupported;
49
+ /** Remote URL used to download the file even though it cannot be previewed. */
50
+ url?: string;
51
+ }
52
+ /** The content payload passed to AttachmentCanvas. */
53
+ export type AttachmentCanvasContent = PlainTextCanvasContent | ImageCanvasContent | MarkdownCanvasContent | JsonCanvasContent | PdfCanvasContent | UnsupportedCanvasContent;
54
+ /** Themeable color overrides for the AttachmentCanvas content body. */
55
+ export interface AttachmentCanvasColors {
56
+ /** Primary text color for the content body. */
57
+ text?: string;
58
+ }
59
+ /** Themeable typography overrides for the AttachmentCanvas content body. */
60
+ export interface AttachmentCanvasTypography {
61
+ /** CSS font-family value. */
62
+ fontFamily?: string;
63
+ /** CSS font-size value. */
64
+ fontSize?: string;
65
+ /** CSS font-weight value. */
66
+ fontWeight?: string | number;
67
+ /** CSS line-height value. */
68
+ lineHeight?: string | number;
69
+ /** CSS letter-spacing value. */
70
+ letterSpacing?: string;
71
+ /**
72
+ * A single CSS utility class applied to the content body instead of
73
+ * individual typography vars. When set, individual typography fields
74
+ * are ignored.
75
+ */
76
+ fontClassName?: string;
77
+ }
78
+ /** Combined style override prop for AttachmentCanvas. */
79
+ export interface AttachmentCanvasStyles {
80
+ /** Color overrides for the content body, applied as CSS custom properties. */
81
+ colors?: AttachmentCanvasColors;
82
+ /** Typography overrides for the content body. */
83
+ typography?: AttachmentCanvasTypography;
84
+ /** Extra class name(s) merged onto the scrollable content body element. */
85
+ bodyClassName?: string;
86
+ /**
87
+ * Arbitrary CSS custom properties applied inline to the content body.
88
+ * Merged after the typed color/typography vars, so they can override them.
89
+ */
90
+ cssVars?: CSSProperties;
91
+ /** Style overrides forwarded to the underlying SidebarPanel (panel chrome). */
92
+ panelStyles?: SidebarPanelStyles;
93
+ }
94
+ /** Props for the AttachmentCanvas component. */
95
+ export interface AttachmentCanvasProps {
96
+ /** Controls visibility of the side panel. */
97
+ isOpen: boolean;
98
+ /** Called when the user activates the built-in close button. */
99
+ onClose: () => void;
100
+ /** The attachment content to render inside the canvas. */
101
+ content: AttachmentCanvasContent;
102
+ /** File name displayed as the panel title. */
103
+ fileName?: string;
104
+ /** Accessible label for the panel region. */
105
+ ariaLabel: string;
106
+ /** Accessible label for the close button. Defaults to `'Close'`. */
107
+ closeLabel?: string;
108
+ /** Called when the user activates the download button. When omitted the download button is hidden. Hidden automatically when content type is `Unsupported`. */
109
+ onDownload?: () => void;
110
+ /** Called when the user activates the copy-text button. When omitted the button is hidden. Only relevant when content type is `PlainText`. */
111
+ onCopyText?: () => void;
112
+ /** Called when the user activates the copy-as-markdown button. When omitted the button is hidden. Only relevant when content type is `Markdown`. */
113
+ onCopyMarkdown?: () => void;
114
+ /** Called when the user activates the copy-JSON button. When omitted the button is hidden. Only relevant when content type is `Json`. */
115
+ onCopyJson?: () => void;
116
+ /** Message shown in the canvas body when the content type is `Unsupported`. Defaults to `'Preview is not supported for this file'`. */
117
+ unsupportedLabel?: string;
118
+ /** Accessible label for the download button. Defaults to `'Download'`. */
119
+ downloadLabel?: string;
120
+ /** Tooltip and accessible label for the copy-text button in its default state. Defaults to `'Copy text'`. */
121
+ copyTextLabel?: string;
122
+ /** Tooltip and accessible label for the copy-text button after a successful copy. Defaults to `'Copied!'`. */
123
+ copiedTextLabel?: string;
124
+ /** Tooltip and accessible label for the copy-as-markdown button in its default state. Defaults to `'Copy as Markdown'`. */
125
+ copyMarkdownLabel?: string;
126
+ /** Tooltip and accessible label for the copy-as-markdown button after a successful copy. Defaults to `'Copied!'`. */
127
+ copiedMarkdownLabel?: string;
128
+ /** Tooltip and accessible label for the copy-JSON button in its default state. Defaults to `'Copy as JSON'`. */
129
+ copyJsonLabel?: string;
130
+ /** Tooltip and accessible label for the copy-JSON button after a successful copy. Defaults to `'Copied!'`. */
131
+ copiedJsonLabel?: string;
132
+ /** Whether the viewport is in mobile breakpoint — disables drag-to-resize. */
133
+ isMobile?: boolean;
134
+ /** Initial panel width in pixels (when resizable). Defaults to `min(maxWidth, 2/3 of viewport width)`. */
135
+ defaultWidth?: number;
136
+ /** Minimum panel width in pixels (when resizable). Defaults to `320`. */
137
+ minWidth?: number;
138
+ /** Maximum panel width in pixels (when resizable). Defaults to `1500`. */
139
+ maxWidth?: number;
140
+ /** Called with the new width in pixels after the user finishes a resize drag. */
141
+ onResizeStop?: (width: number) => void;
142
+ /** Style overrides for the content body and the underlying SidebarPanel chrome. */
143
+ styles?: AttachmentCanvasStyles;
144
+ /** Extra class name(s) merged onto the panel width wrapper. */
145
+ className?: string;
146
+ /** Syntax highlight color theme forwarded to MarkdownRenderer code blocks. */
147
+ codeBlockTheme?: CodeBlockTheme;
148
+ /**
149
+ * Fetches a PDF file by URL and returns its bytes as a `Blob`. Used when
150
+ * content type is `Pdf` to load the file before rendering. Defaults to a
151
+ * plain `fetch` if not provided.
152
+ */
153
+ loadPdf?: (url: string) => Promise<Blob>;
154
+ }
155
+ //# sourceMappingURL=attachment-canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment-canvas.d.ts","sourceRoot":"","sources":["../../src/models/attachment-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,kDAAkD;AAClD,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC;IACtC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC;IAClC,yEAAyE;I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IAC3H,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qHAAqH;IACrH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gHAAgH;IAChH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8GAA8G;IAC9G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,mFAAmF;IACnF,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@epam/ai-dial-attachment-canvas",
3
+ "version": "0.0.0-dev.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "module": "./index.js",
8
+ "types": "./index.d.ts",
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ "./styles.css": "./style.css",
12
+ ".": {
13
+ "types": "./index.d.ts",
14
+ "import": "./index.js",
15
+ "default": "./index.js"
16
+ }
17
+ },
18
+ "peerDependencies": {
19
+ "@epam/ai-dial-chat-shared": "0.0.0-dev.0",
20
+ "@epam/ai-dial-sidebar": "0.0.0-dev.0",
21
+ "@epam/ai-dial-ui-kit": "0.12.0-dev.21",
22
+ "@epam/pdf-highlighter-kit": ">=0.0.14",
23
+ "@tabler/icons-react": "^3.44.0",
24
+ "react": "^19.0.0",
25
+ "react-json-view-lite": "^2.5.0",
26
+ "@epam/ai-dial-react-pdf-highlighter": "0.2.0-dev.17"
27
+ },
28
+ "dependencies": {}
29
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /** The type of content the canvas can display. */
2
+ export declare enum AttachmentContentType {
3
+ PlainText = "plain_text",
4
+ Image = "image",
5
+ Markdown = "markdown",
6
+ Json = "json",
7
+ Pdf = "pdf",
8
+ Unsupported = "unsupported"
9
+ }
10
+ //# sourceMappingURL=attachment-canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment-canvas.d.ts","sourceRoot":"","sources":["../../src/types/attachment-canvas.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,oBAAY,qBAAqB;IAC/B,SAAS,eAAe;IACxB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,WAAW,gBAAgB;CAC5B"}
@@ -0,0 +1,6 @@
1
+ import { UnsupportedCanvasContent } from '../models/attachment-canvas';
2
+ /** Returns true if the file name has an extension known to be text-previewable. */
3
+ export declare const isTextPreviewable: (name: string) => boolean;
4
+ /** Creates an unsupported-format content payload. */
5
+ export declare const createUnsupportedCanvasContent: (url?: string) => UnsupportedCanvasContent;
6
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/utils/content.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAG5E,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,OAIhD,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,8BAA8B,GACzC,MAAM,MAAM,KACX,wBAGD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { AttachmentCanvasContent } from '../models/attachment-canvas';
2
+ /** Returns true if the given canvas content can be downloaded. */
3
+ export declare const isDownloadable: (content: AttachmentCanvasContent) => boolean;
4
+ /** Fetches a URL and returns its response body as a `Blob`. */
5
+ export declare const fetchBlobFromUrl: (url: string) => Promise<Blob>;
6
+ /** Triggers a browser download for the given canvas content. */
7
+ export declare const downloadAttachmentContent: (content: AttachmentCanvasContent, fileName?: string) => void;
8
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/utils/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAG3E,kEAAkE;AAClE,eAAO,MAAM,cAAc,GAAI,SAAS,uBAAuB,KAAG,OAWjE,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,IAAI,CAIhE,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,GACpC,SAAS,uBAAuB,EAChC,WAAW,MAAM,KAChB,IAwCF,CAAC"}