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