@epam/ai-dial-attachment-canvas 1.3.0-dev.310 → 1.3.0-dev.317

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-attachment-canvas",
3
3
  "description": "Canvas viewer for rendering attachment content — images, PDFs, Office documents, CSV, JSON, markdown, and plain text",
4
- "version": "1.3.0-dev.310",
4
+ "version": "1.3.0-dev.317",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -22,18 +22,18 @@
22
22
  "react-json-view-lite": "^2.5.0",
23
23
  "react-syntax-highlighter": "^16.1.2",
24
24
  "@epam/ai-dial-react-pdf-highlighter": "0.3.0-dev.6",
25
- "@epam/ai-dial-visualizer-connector": "1.3.0-dev.310",
25
+ "@epam/ai-dial-visualizer-connector": "1.3.0-dev.317",
26
26
  "@epam/pdf-highlighter-kit": "^0.0.19",
27
27
  "@mcp-ui/client": "^7.1.1",
28
28
  "@modelcontextprotocol/sdk": "^1.32.2",
29
29
  "@modelcontextprotocol/ext-apps": "1.7.5",
30
30
  "zod": "^4.6.6",
31
- "pdfjs-dist": "^5.6.205",
32
- "@epam/ai-dial-sidebar": "1.3.0-dev.310"
31
+ "pdfjs-dist": "^6.5.438",
32
+ "@epam/ai-dial-sidebar": "1.3.0-dev.317"
33
33
  },
34
34
  "peerDependencies": {
35
- "@epam/ai-dial-chat-shared": "1.3.0-dev.310",
36
- "@epam/ai-dial-ui-kit": "^0.16.0-dev.71",
35
+ "@epam/ai-dial-chat-shared": "1.3.0-dev.317",
36
+ "@epam/ai-dial-ui-kit": "^0.16.0-dev.72",
37
37
  "react": "^19.2.8"
38
38
  },
39
39
  "repository": {
@@ -1,268 +0,0 @@
1
- import "./PdfContent.css";
2
- import { a as e, n as t, r as n } from "./LazyContentBoundary-rT6s5wBc.js";
3
- import { mergeClasses as r } from "@epam/ai-dial-chat-shared";
4
- import { DIAL_ICON_SIZE as i, DIAL_KIT_ICON_STROKE as a, Dropdown as o, ElementSize as s, FabButton as c, Input as ee } from "@epam/ai-dial-ui-kit";
5
- import { IconMenu2 as te, IconX as ne } from "@tabler/icons-react";
6
- import { useCallback as l, useEffect as u, useId as re, useRef as d, useState as f } from "react";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
- import { DocumentPreview as ie, PageThumbnail as ae } from "@epam/ai-dial-react-pdf-highlighter";
9
- var oe = { viewer: "_viewer_1gfxm_1" }, h = null, se = (e) => (h ||= new Promise((t, n) => {
10
- try {
11
- t(e());
12
- } catch (e) {
13
- n(e);
14
- }
15
- }).catch((e) => {
16
- throw h = null, e;
17
- }), h), g = 15, _ = 3, ce = 172, le = 400, v = 150, ue = 60, y = ({ url: h, highlights: y, selectedHighlightId: b, selectedPageNumber: x, loadPdf: S, configurePdfWorker: C, hideHeader: de = !1, onLoadError: w, errorLabelClassName: fe, labels: { thumbnailsLabel: pe = "Thumbnails", showThumbnailsLabel: me = "Show thumbnails", hideThumbnailsLabel: he = "Hide thumbnails", pageNumberLabel: ge = "Page number", loadingLabel: _e = "Loading…", errorLabel: ve = "Failed to load content", retryLabel: T = "Retry" } = {} }) => {
18
- let [E, D] = f(() => C ? "preparing" : "ready"), [ye, be] = f(0), xe = l(async (t) => {
19
- try {
20
- return await (S ?? e)(t);
21
- } catch (e) {
22
- throw w?.(t), e;
23
- }
24
- }, [S, w]);
25
- u(() => {
26
- if (!C) return;
27
- D("preparing");
28
- let e = !1;
29
- return se(C).then(() => {
30
- e || D("ready");
31
- }).catch(() => {
32
- e || D("error");
33
- }), () => {
34
- e = !0;
35
- };
36
- }, [C, ye]);
37
- let Se = l(() => {
38
- be((e) => e + 1);
39
- }, []), O = re(), [k, A] = f(0), [j, Ce] = f(/* @__PURE__ */ new Map()), [M, we] = f(!1), [N, P] = f(() => x ?? (b ? y.find((e) => e.id === b)?.bboxes[0]?.page ?? 1 : 1)), F = d(null), I = d(null), [Te, L] = f([]), [R, Ee] = f(ce), [z, De] = f(le), [Oe, B] = f(0), V = d(!1), H = d(0), U = d(null);
40
- u(() => {
41
- if (x != null) {
42
- P(x);
43
- return;
44
- }
45
- if (!b) return;
46
- let e = y.find((e) => e.id === b)?.bboxes[0]?.page;
47
- e != null && P(e);
48
- }, [
49
- x,
50
- b,
51
- y
52
- ]), u(() => {
53
- let e = I.current;
54
- if (!M || !e) return;
55
- let t = new ResizeObserver((e) => {
56
- let t = e[0]?.contentRect.height;
57
- t && De(t);
58
- });
59
- return t.observe(e), () => t.disconnect();
60
- }, [M]);
61
- let ke = l((e) => {
62
- if (!e || V.current) return;
63
- let t = e.getBoundingClientRect().height;
64
- t > 0 && (V.current = !0, Ee(t));
65
- }, []), Ae = l((e) => {
66
- H.current = e.currentTarget.scrollTop, U.current ??= requestAnimationFrame(() => {
67
- U.current = null, B(H.current);
68
- });
69
- }, []);
70
- u(() => () => {
71
- U.current != null && cancelAnimationFrame(U.current);
72
- }, []);
73
- let W = l((e) => {
74
- if (k === 0) return;
75
- let t = Math.max(0, (N - 1) * R - e.clientHeight / 2 + R / 2);
76
- H.current = t, B(t), e.scrollTop = t;
77
- }, [
78
- N,
79
- k,
80
- R
81
- ]), je = l((e) => {
82
- I.current = e, e && W(e);
83
- }, [W]);
84
- u(() => {
85
- let e = I.current;
86
- e && W(e);
87
- }, [W]);
88
- let G = Math.max(0, Math.floor(Oe / R) - _), Me = Math.ceil(z / R) + 6, K = Math.min(k - 1, G + Me);
89
- u(() => {
90
- if (k === 0) return;
91
- let e = Math.min(k, g);
92
- L(Array.from({ length: e }, (e, t) => t + 1));
93
- }, [k]), u(() => {
94
- if (!M || k === 0) return;
95
- let e = setTimeout(() => {
96
- L((e) => {
97
- let t = new Set(e), n = !1;
98
- for (let e = G + 1; e <= K + 1; e++) t.has(e) || (t.add(e), n = !0);
99
- return n ? Array.from(t).sort((e, t) => e - t) : e;
100
- });
101
- }, v);
102
- return () => clearTimeout(e);
103
- }, [
104
- M,
105
- G,
106
- K,
107
- k
108
- ]), u(() => {
109
- if (k === 0) return;
110
- let e = setTimeout(() => {
111
- let e = Math.ceil(z / R / 2) + _, t = Math.max(0, N - 1 - e), n = Math.min(k - 1, N - 1 + e);
112
- L((e) => {
113
- let r = new Set(e), i = !1;
114
- for (let e = t + 1; e <= n + 1; e++) r.has(e) || (r.add(e), i = !0);
115
- return i ? Array.from(r).sort((e, t) => e - t) : e;
116
- });
117
- }, v);
118
- return () => clearTimeout(e);
119
- }, [
120
- N,
121
- k,
122
- z,
123
- R
124
- ]);
125
- let Ne = l((e) => {
126
- Ce((t) => new Map([...t, ...e]));
127
- }, []), [q, Pe] = f(!1), Fe = l((e) => {
128
- F.current = e, Pe(!0);
129
- }, []), J = d(null);
130
- u(() => {
131
- if (!q) return;
132
- let e = J.current, t = e?.querySelector(".pdf-container"), n = e?.querySelector(".pdf-highlight-viewer");
133
- if (!t || !n) return;
134
- let r = () => {
135
- let e = n.scrollWidth - n.clientWidth;
136
- e > 0 && (n.scrollLeft = e / 2);
137
- };
138
- r();
139
- let i = new ResizeObserver(r);
140
- i.observe(t), i.observe(n);
141
- let a = F.current?.getZoom(), o = 0, s, c = () => {
142
- let e = F.current?.getZoom();
143
- e !== a && (a = e, o = ue), o > 0 && (r(), --o), s = requestAnimationFrame(c);
144
- };
145
- return s = requestAnimationFrame(c), () => {
146
- cancelAnimationFrame(s), i.disconnect();
147
- };
148
- }, [q]), u(() => {
149
- if (!q || b || x != null) return;
150
- let e = requestAnimationFrame(() => {
151
- F.current?.navigateToPage(1);
152
- });
153
- return () => cancelAnimationFrame(e);
154
- }, [
155
- q,
156
- b,
157
- x
158
- ]);
159
- let Y = l((e) => {
160
- P(e), F.current?.navigateToPage(e);
161
- }, []), Ie = l((e) => {
162
- P(e);
163
- }, []), [X, Z] = f(() => String(N));
164
- u(() => {
165
- Z(String(N));
166
- }, [N]);
167
- let Q = l((e) => {
168
- let t = Number(e);
169
- Number.isInteger(t) && t >= 1 && t <= k ? Y(t) : Z(String(N));
170
- }, [
171
- k,
172
- N,
173
- Y
174
- ]);
175
- if (!h) return null;
176
- if (E === "preparing") return /* @__PURE__ */ p(n, { loadingLabel: _e });
177
- if (E === "error") return /* @__PURE__ */ p(t, {
178
- errorLabel: ve,
179
- retryLabel: T,
180
- onRetry: Se,
181
- errorLabelClassName: fe
182
- });
183
- let $ = [];
184
- for (let e = G + 1; e <= K + 1 && e <= k; e++) $.push(/* @__PURE__ */ p("div", {
185
- ref: e === G + 1 ? ke : void 0,
186
- children: /* @__PURE__ */ p(ae, {
187
- pageNum: e,
188
- onSelectPage: Y,
189
- isSelected: N === e,
190
- isLoading: !j.has(e),
191
- thumbnailUrl: j.get(e) ?? null
192
- })
193
- }, e));
194
- let Le = G * R, Re = Math.max(0, k - K - 1) * R;
195
- return /* @__PURE__ */ m("div", {
196
- className: "relative flex h-full overflow-hidden",
197
- children: [k > 0 && /* @__PURE__ */ p("div", {
198
- className: "absolute inset-s-3 top-3 z-10",
199
- children: /* @__PURE__ */ p(o, {
200
- open: M,
201
- onOpenChange: we,
202
- allowedPlacements: ["bottom-start"],
203
- matchReferenceWidth: !1,
204
- initialFocus: -1,
205
- renderOverlay: () => /* @__PURE__ */ m("div", {
206
- className: "flex w-36 flex-col",
207
- children: [/* @__PURE__ */ p("div", {
208
- className: "w-[88px] shrink-0 p-1",
209
- children: /* @__PURE__ */ p(ee, {
210
- size: s.Small,
211
- "aria-label": ge,
212
- value: X,
213
- postfix: `/ ${k}`,
214
- inputMode: "numeric",
215
- onChange: (e) => Z(e ?? ""),
216
- onBlur: () => Q(X),
217
- onKeyDown: (e) => {
218
- e.key === "Enter" && Q(X);
219
- }
220
- })
221
- }), /* @__PURE__ */ m("div", {
222
- ref: je,
223
- id: O,
224
- role: "region",
225
- "aria-label": pe,
226
- onScroll: Ae,
227
- className: "max-h-[min(70vh,calc(var(--fui-available-height,70vh)-2.5rem))] min-h-0 scrollbar-gutter-both overflow-x-hidden overflow-y-auto p-1",
228
- children: [
229
- /* @__PURE__ */ p("div", { style: { height: Le } }),
230
- $,
231
- /* @__PURE__ */ p("div", { style: { height: Re } })
232
- ]
233
- })]
234
- }),
235
- children: /* @__PURE__ */ p(c, {
236
- icon: p(M ? ne : te, {
237
- size: i.LG,
238
- stroke: a,
239
- "aria-hidden": !0
240
- }),
241
- "aria-label": M ? he : me,
242
- "aria-expanded": M,
243
- "aria-controls": M ? O : void 0
244
- })
245
- })
246
- }), /* @__PURE__ */ p("div", {
247
- ref: J,
248
- className: r("min-w-0 flex-1 overflow-hidden", oe.viewer),
249
- children: /* @__PURE__ */ p(ie, {
250
- fileUrl: h,
251
- loadFileCb: xe,
252
- highlights: y,
253
- selectedHighlightId: b,
254
- selectedPageNumber: x,
255
- showOccurrences: !1,
256
- onTotalPagesChange: A,
257
- thumbnailPageNumbers: Te,
258
- onThumbnailsLoaded: Ne,
259
- onViewerReady: Fe,
260
- onCurrentPageChange: Ie,
261
- viewerOptions: { enableVirtualScrolling: !0 },
262
- containerClassName: de ? "[&>div:first-child]:hidden" : void 0
263
- })
264
- })]
265
- });
266
- };
267
- //#endregion
268
- export { y as PdfContent };