@epam/ai-dial-attachment-canvas 1.3.0-dev.98 → 1.3.0-rc.1

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.
Files changed (46) hide show
  1. package/LazyContentBoundary-ES0u-Jn7.js +137 -0
  2. package/LazyContentBoundary.css +1 -0
  3. package/PdfContent-BEWJ_9tn.js +274 -0
  4. package/PdfContent.css +1 -1
  5. package/components/AttachmentCanvas/AttachmentCanvas.d.ts.map +1 -1
  6. package/components/AttachmentCanvasBody/AttachmentCanvasBody.d.ts.map +1 -1
  7. package/components/AttachmentCanvasContainer/AttachmentCanvasContainer.d.ts +4 -0
  8. package/components/AttachmentCanvasContainer/AttachmentCanvasContainer.d.ts.map +1 -1
  9. package/components/CodeContent/CodeContent.d.ts +4 -0
  10. package/components/CodeContent/CodeContent.d.ts.map +1 -1
  11. package/components/HtmlContent/HtmlContent.d.ts +3 -1
  12. package/components/HtmlContent/HtmlContent.d.ts.map +1 -1
  13. package/components/LazyContentBoundary/LazyContentBoundary.d.ts +13 -14
  14. package/components/LazyContentBoundary/LazyContentBoundary.d.ts.map +1 -1
  15. package/components/McpAppCanvasRenderer/McpAppCanvasRenderer.d.ts +2 -0
  16. package/components/McpAppCanvasRenderer/McpAppCanvasRenderer.d.ts.map +1 -1
  17. package/components/OoxmlContent/OoxmlContent.d.ts +4 -0
  18. package/components/OoxmlContent/OoxmlContent.d.ts.map +1 -1
  19. package/components/PdfContent/PdfContent.d.ts +2 -0
  20. package/components/PdfContent/PdfContent.d.ts.map +1 -1
  21. package/components/VisualizerCanvasRenderer/VisualizerCanvasRenderer.d.ts +1 -1
  22. package/components/VisualizerCanvasRenderer/VisualizerCanvasRenderer.d.ts.map +1 -1
  23. package/constants/canvas-body.d.ts +4 -0
  24. package/constants/canvas-body.d.ts.map +1 -0
  25. package/constants/file.d.ts +4 -3
  26. package/constants/file.d.ts.map +1 -1
  27. package/constants/open-routing.d.ts +6 -0
  28. package/constants/open-routing.d.ts.map +1 -0
  29. package/context/AttachmentCanvasContext.d.ts +8 -2
  30. package/context/AttachmentCanvasContext.d.ts.map +1 -1
  31. package/hooks/useOpenAttachmentCanvas/useOpenAttachmentCanvas.d.ts.map +1 -1
  32. package/index.css +2 -2
  33. package/index.d.ts +1 -0
  34. package/index.d.ts.map +1 -1
  35. package/index.js +833 -756
  36. package/models/attachment-canvas.d.ts +35 -5
  37. package/models/attachment-canvas.d.ts.map +1 -1
  38. package/{ooxml-highlight-surfaces-BzgOKpBV.js → ooxml-highlight-surfaces-C18JJb0P.js} +6 -14
  39. package/package.json +13 -12
  40. package/types/open-resolver.d.ts +7 -0
  41. package/types/open-resolver.d.ts.map +1 -0
  42. package/utils/download.d.ts.map +1 -1
  43. package/utils/vite-external-matcher.d.ts +1 -1
  44. package/utils/vite-external-matcher.d.ts.map +1 -1
  45. package/LazyContentBoundary-tNE1ExbI.js +0 -167
  46. package/PdfContent-CoDPA4FK.js +0 -267
@@ -1,267 +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 d, useRef as f, useState as p } from "react";
7
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
- import { DocumentPreview as re, PageThumbnail as ie } from "@epam/ai-dial-react-pdf-highlighter";
9
- var g = { viewer: "_viewer_1gfxm_1" }, _ = null, ae = (e) => (_ ||= new Promise((t, n) => {
10
- try {
11
- t(e());
12
- } catch (e) {
13
- n(e);
14
- }
15
- }).catch((e) => {
16
- throw _ = null, e;
17
- }), _), oe = 15, v = 3, se = 172, ce = 400, y = 150, le = 60, b = ({ url: _, highlights: b, selectedHighlightId: x, selectedPageNumber: S, loadPdf: C, configurePdfWorker: w, hideHeader: ue = !1, onLoadError: T, labels: { thumbnailsLabel: de = "Thumbnails", showThumbnailsLabel: fe = "Show thumbnails", hideThumbnailsLabel: pe = "Hide thumbnails", pageNumberLabel: me = "Page number", loadingLabel: he = "Loading…", errorLabel: ge = "Failed to load content", retryLabel: _e = "Retry" } = {} }) => {
18
- let [E, D] = p(() => w ? "preparing" : "ready"), [ve, ye] = p(0), be = l(async (t) => {
19
- try {
20
- return await (C ?? e)(t);
21
- } catch (e) {
22
- throw T?.(t), e;
23
- }
24
- }, [C, T]);
25
- u(() => {
26
- if (!w) return;
27
- D("preparing");
28
- let e = !1;
29
- return ae(w).then(() => {
30
- e || D("ready");
31
- }).catch(() => {
32
- e || D("error");
33
- }), () => {
34
- e = !0;
35
- };
36
- }, [w, ve]);
37
- let xe = l(() => {
38
- ye((e) => e + 1);
39
- }, []), O = d(), [k, Se] = p(0), [A, j] = p(/* @__PURE__ */ new Map()), [M, Ce] = p(!1), [N, P] = p(() => S ?? (x ? b.find((e) => e.id === x)?.bboxes[0]?.page ?? 1 : 1)), F = f(null), I = f(null), [we, L] = p([]), [R, Te] = p(se), [z, Ee] = p(ce), [De, B] = p(0), V = f(!1), H = f(0), U = f(null);
40
- u(() => {
41
- if (S != null) {
42
- P(S);
43
- return;
44
- }
45
- if (!x) return;
46
- let e = b.find((e) => e.id === x)?.bboxes[0]?.page;
47
- e != null && P(e);
48
- }, [
49
- S,
50
- x,
51
- b
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 && Ee(t);
58
- });
59
- return t.observe(e), () => t.disconnect();
60
- }, [M]);
61
- let Oe = l((e) => {
62
- if (!e || V.current) return;
63
- let t = e.getBoundingClientRect().height;
64
- t > 0 && (V.current = !0, Te(t));
65
- }, []), ke = 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
- ]), Ae = 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(De / R) - v), je = Math.ceil(z / R) + v * 2, K = Math.min(k - 1, G + je);
89
- u(() => {
90
- if (k === 0) return;
91
- let e = Math.min(k, oe);
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
- }, y);
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) + v, 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
- }, y);
118
- return () => clearTimeout(e);
119
- }, [
120
- N,
121
- k,
122
- z,
123
- R
124
- ]);
125
- let Me = l((e) => {
126
- j((t) => new Map([...t, ...e]));
127
- }, []), [q, Ne] = p(!1), Pe = l((e) => {
128
- F.current = e, Ne(!0);
129
- }, []), J = f(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 = le), 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 || x || S != null) return;
150
- let e = requestAnimationFrame(() => {
151
- F.current?.navigateToPage(1);
152
- });
153
- return () => cancelAnimationFrame(e);
154
- }, [
155
- q,
156
- x,
157
- S
158
- ]);
159
- let Y = l((e) => {
160
- P(e), F.current?.navigateToPage(e);
161
- }, []), Fe = l((e) => {
162
- P(e);
163
- }, []), [X, Z] = p(() => 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 (!_) return null;
176
- if (E === "preparing") return /* @__PURE__ */ m(n, { loadingLabel: he });
177
- if (E === "error") return /* @__PURE__ */ m(t, {
178
- errorLabel: ge,
179
- retryLabel: _e,
180
- onRetry: xe
181
- });
182
- let $ = [];
183
- for (let e = G + 1; e <= K + 1 && e <= k; e++) $.push(/* @__PURE__ */ m("div", {
184
- ref: e === G + 1 ? Oe : void 0,
185
- children: /* @__PURE__ */ m(ie, {
186
- pageNum: e,
187
- onSelectPage: Y,
188
- isSelected: N === e,
189
- isLoading: !A.has(e),
190
- thumbnailUrl: A.get(e) ?? null
191
- })
192
- }, e));
193
- let Ie = G * R, Le = Math.max(0, k - K - 1) * R;
194
- return /* @__PURE__ */ h("div", {
195
- className: "relative flex h-full overflow-hidden",
196
- children: [k > 0 && /* @__PURE__ */ m("div", {
197
- className: "absolute start-3 top-3 z-10",
198
- children: /* @__PURE__ */ m(o, {
199
- open: M,
200
- onOpenChange: Ce,
201
- placement: "bottom-start",
202
- matchReferenceWidth: !1,
203
- initialFocus: -1,
204
- renderOverlay: () => /* @__PURE__ */ h("div", {
205
- className: "flex w-36 flex-col",
206
- children: [/* @__PURE__ */ m("div", {
207
- className: "shrink-0 p-1",
208
- children: /* @__PURE__ */ m(ee, {
209
- size: s.Small,
210
- "aria-label": me,
211
- value: X,
212
- postfix: `/ ${k}`,
213
- inputMode: "numeric",
214
- onChange: (e) => Z(e ?? ""),
215
- onBlur: () => Q(X),
216
- onKeyDown: (e) => {
217
- e.key === "Enter" && Q(X);
218
- }
219
- })
220
- }), /* @__PURE__ */ h("div", {
221
- ref: Ae,
222
- id: O,
223
- role: "region",
224
- "aria-label": de,
225
- onScroll: ke,
226
- className: "max-h-[70vh] min-h-0 [scrollbar-gutter:stable] overflow-x-hidden overflow-y-auto p-1",
227
- children: [
228
- /* @__PURE__ */ m("div", { style: { height: Ie } }),
229
- $,
230
- /* @__PURE__ */ m("div", { style: { height: Le } })
231
- ]
232
- })]
233
- }),
234
- children: /* @__PURE__ */ m(c, {
235
- icon: m(M ? ne : te, {
236
- size: i.LG,
237
- stroke: a,
238
- "aria-hidden": !0
239
- }),
240
- "aria-label": M ? pe : fe,
241
- "aria-expanded": M,
242
- "aria-controls": M ? O : void 0
243
- })
244
- })
245
- }), /* @__PURE__ */ m("div", {
246
- ref: J,
247
- className: r("min-w-0 flex-1 overflow-hidden", g.viewer),
248
- children: /* @__PURE__ */ m(re, {
249
- fileUrl: _,
250
- loadFileCb: be,
251
- highlights: b,
252
- selectedHighlightId: x,
253
- selectedPageNumber: S,
254
- showOccurrences: !1,
255
- onTotalPagesChange: Se,
256
- thumbnailPageNumbers: we,
257
- onThumbnailsLoaded: Me,
258
- onViewerReady: Pe,
259
- onCurrentPageChange: Fe,
260
- viewerOptions: { enableVirtualScrolling: !0 },
261
- containerClassName: ue ? "[&>div:first-child]:hidden" : void 0
262
- })
263
- })]
264
- });
265
- };
266
- //#endregion
267
- export { b as PdfContent };