@epam/ai-dial-quotations 1.2.0-dev.2 → 1.2.0-dev.6

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 +1 @@
1
- {"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,8HAA8H;AAC9H,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAuEtD,CAAC"}
1
+ {"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,8HAA8H;AAC9H,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAyEtD,CAAC"}
@@ -3,10 +3,10 @@ import { useCitationCard } from '../utils/useCitationCard';
3
3
  export type CitationCardHook = ReturnType<typeof useCitationCard>;
4
4
  /** Provider that supplies `CitationCardHook` state to a citation subtree. */
5
5
  export declare const CitationCardProvider: import('react').Provider<{
6
- openPopup: (groupKey: string) => void;
7
- closePopup: () => void;
6
+ openPopup: (ownerKey: string) => void;
7
+ closePopup: (ownerKey: string) => void;
8
8
  setActiveIndex: (groupKey: string, index: number) => void;
9
- isOpen: (groupKey: string) => boolean;
9
+ isOpen: (ownerKey: string) => boolean;
10
10
  getActiveIndex: (groupKey: string) => number;
11
11
  } | null>;
12
12
  /** Returns the nearest `CitationCardHook` from context. Throws when used outside a `CitationCardProvider`. */
package/index.js CHANGED
@@ -2,15 +2,15 @@ import { MIMEType as e, MarkdownRenderer as t, buildCssVars as n, isAnnotationSe
2
2
  import { DIAL_KIT_ICON_STROKE as s, ElementSize as c, EllipsisTooltip as l, GhostIconButton as u, NeutralButton as d, PrimaryButton as f, Tooltip as p } from "@epam/ai-dial-ui-kit";
3
3
  import { IconChevronLeft as m, IconChevronRight as h } from "@tabler/icons-react";
4
4
  import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
5
- import { createContext as y, useCallback as b, useContext as x, useMemo as S, useState as C } from "react";
6
- var w = {
5
+ import { createContext as y, useCallback as b, useContext as x, useId as S, useMemo as C, useState as w } from "react";
6
+ var T = {
7
7
  card: "_card_1kph1_1",
8
8
  quote: "_quote_1kph1_5",
9
9
  title: "_title_1kph1_9",
10
10
  switcher: "_switcher_1kph1_13",
11
11
  sourceName: "_sourceName_1kph1_17"
12
- }, T = ({ group: r, activeIndex: a, onIndexChange: o, onPreview: d, onOpenInBrowser: p, headerIcon: g, labels: y, typography: b, colors: x }) => {
13
- let S = r.annotations.length, C = r.annotations[a] ?? r.primaryAnnotation, T = S > 1, E = r.primaryAnnotation.body?.source?.attachment?.type, D = d == null || E === e.HTML || E === e.XHTML, O = b?.sourceNameClassName ?? "dial-tiny-text", k = b?.titleClassName ?? "dial-body-semi-text", A = b?.quoteClassName ?? "dial-small-text", j = b?.quoteStrongClassName ?? "dial-small-semi-text", M = b?.switcherClassName ?? "dial-tiny-text", N = n({
12
+ }, E = ({ group: r, activeIndex: a, onIndexChange: o, onPreview: d, onOpenInBrowser: p, headerIcon: g, labels: y, typography: b, colors: x }) => {
13
+ let S = r.annotations.length, C = r.annotations[a] ?? r.primaryAnnotation, w = S > 1, E = r.primaryAnnotation.body?.source?.attachment?.type, D = d == null || E === e.HTML || E === e.XHTML, O = b?.sourceNameClassName ?? "dial-tiny-text", k = b?.titleClassName ?? "dial-body-semi-text", A = b?.quoteClassName ?? "dial-small-text", j = b?.quoteStrongClassName ?? "dial-small-semi-text", M = b?.switcherClassName ?? "dial-tiny-text", N = n({
14
14
  "--cc-card-bg": x?.cardBackground,
15
15
  "--cc-quote-text": x?.quoteText,
16
16
  "--cc-title-text": x?.titleText,
@@ -22,7 +22,7 @@ var w = {
22
22
  "aria-modal": "true",
23
23
  "aria-label": y.ariaLabel,
24
24
  style: N,
25
- className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", w.card),
25
+ className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", T.card),
26
26
  children: [
27
27
  /* @__PURE__ */ v("div", {
28
28
  className: "flex items-center justify-between gap-2",
@@ -30,9 +30,9 @@ var w = {
30
30
  className: "flex min-w-0 items-center gap-1",
31
31
  children: [g, /* @__PURE__ */ _(l, {
32
32
  text: r.sourceName,
33
- className: i(O, "min-w-0", w.sourceName)
33
+ className: i(O, "min-w-0", T.sourceName)
34
34
  })]
35
- }), T && /* @__PURE__ */ v("div", {
35
+ }), w && /* @__PURE__ */ v("div", {
36
36
  className: "flex shrink-0 items-center gap-1",
37
37
  children: [
38
38
  /* @__PURE__ */ _(u, {
@@ -46,7 +46,7 @@ var w = {
46
46
  onClick: () => o((a - 1 + S) % S)
47
47
  }),
48
48
  /* @__PURE__ */ _("span", {
49
- className: i(M, w.switcher),
49
+ className: i(M, T.switcher),
50
50
  children: y.formatSwitcherText(a + 1, S)
51
51
  }),
52
52
  /* @__PURE__ */ _(u, {
@@ -62,17 +62,17 @@ var w = {
62
62
  ]
63
63
  })]
64
64
  }),
65
- (C.body?.title || C.body?.quote || T) && /* @__PURE__ */ v("div", {
65
+ (C.body?.title || C.body?.quote || w) && /* @__PURE__ */ v("div", {
66
66
  className: "flex flex-col gap-3",
67
67
  children: [C.body?.title && /* @__PURE__ */ _("p", {
68
- className: i(k, w.title, "break-words"),
68
+ className: i(k, T.title, "break-words"),
69
69
  children: C.body.title
70
- }), (C.body?.quote || T) && /* @__PURE__ */ _("div", {
71
- className: i(A, w.quote, "line-clamp-6 break-words", T && "min-h-[3lh]"),
70
+ }), (C.body?.quote || w) && /* @__PURE__ */ _("div", {
71
+ className: i(A, T.quote, "line-clamp-6 break-words", w && "min-h-[3lh]"),
72
72
  children: C.body?.quote && /* @__PURE__ */ _(t, {
73
73
  content: C.body.quote,
74
74
  classNames: {
75
- p: i(A, w.quote),
75
+ p: i(A, T.quote),
76
76
  ul: i(A, "ps-3"),
77
77
  ol: i(A, "ps-3"),
78
78
  strong: j
@@ -94,7 +94,7 @@ var w = {
94
94
  })
95
95
  ]
96
96
  });
97
- }, E = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: i = "dial-caption-text" }) => {
97
+ }, D = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: i = "dial-caption-text" }) => {
98
98
  let a = /* @__PURE__ */ v("span", {
99
99
  className: "flex items-center gap-1",
100
100
  children: [n, /* @__PURE__ */ _("span", {
@@ -108,47 +108,51 @@ var w = {
108
108
  "aria-label": r.ariaLabel,
109
109
  onClick: t
110
110
  });
111
- }, D = y(null), O = D.Provider, k = () => {
112
- let e = x(D);
111
+ }, O = y(null), k = O.Provider, A = () => {
112
+ let e = x(O);
113
113
  if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
114
114
  return e;
115
- }, A = { content: "_content_xzs0h_1" }, j = ({ group: e, onPreview: t, onOpenInBrowser: n, icon: r, headerIcon: a, cardLabels: o, markerLabels: s, cardTypography: c, markerLabelClassName: l }) => {
116
- let u = k(), d = u.isOpen(e.groupKey), f = u.getActiveIndex(e.groupKey), m = b((e) => {
117
- e || u.closePopup();
118
- }, [u]), h = S(() => t ? (e) => {
119
- t(e), u.closePopup();
120
- } : void 0, [t, u]);
115
+ }, j = { content: "_content_xzs0h_1" }, M = ({ group: e, onPreview: t, onOpenInBrowser: n, icon: r, headerIcon: a, cardLabels: o, markerLabels: s, cardTypography: c, markerLabelClassName: l }) => {
116
+ let u = A(), d = S(), f = u.isOpen(d), m = u.getActiveIndex(e.groupKey), h = b((e) => {
117
+ e || u.closePopup(d);
118
+ }, [u, d]), g = C(() => t ? (e) => {
119
+ t(e), u.closePopup(d);
120
+ } : void 0, [
121
+ t,
122
+ u,
123
+ d
124
+ ]);
121
125
  return /* @__PURE__ */ _(p, {
122
- open: d,
123
- onOpenChange: m,
126
+ open: f,
127
+ onOpenChange: h,
124
128
  triggerClassName: "ms-1 inline-flex align-middle",
125
- contentClassName: i("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", A.content),
126
- tooltip: /* @__PURE__ */ _(T, {
129
+ contentClassName: i("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", j.content),
130
+ tooltip: /* @__PURE__ */ _(E, {
127
131
  group: e,
128
- activeIndex: f,
132
+ activeIndex: m,
129
133
  onIndexChange: (t) => u.setActiveIndex(e.groupKey, t),
130
- onPreview: h,
134
+ onPreview: g,
131
135
  onOpenInBrowser: n,
132
136
  headerIcon: a,
133
137
  labels: o,
134
138
  typography: c
135
139
  }),
136
- children: /* @__PURE__ */ _(E, {
140
+ children: /* @__PURE__ */ _(D, {
137
141
  sourceName: e.sourceName,
138
142
  annotationCount: e.annotations.length,
139
- onOpen: () => u.openPopup(e.groupKey),
143
+ onOpen: () => u.openPopup(d),
140
144
  icon: r,
141
145
  labels: s,
142
146
  labelClassName: l
143
147
  })
144
148
  });
145
- }, M = {
149
+ }, N = {
146
150
  backgroundColor: "transparent",
147
151
  borderColor: "var(--stroke-accent, #1D4ED8)",
148
152
  borderWidth: "2px",
149
153
  opacity: .5,
150
154
  hoverOpacity: .5
151
- }, N = (e) => {
155
+ }, ee = (e) => {
152
156
  if (typeof e != "object" || !e) return;
153
157
  let t = e, { lt: n, wh: r } = t;
154
158
  if (Array.isArray(n) && Array.isArray(r) && n.length >= 2 && r.length >= 2) {
@@ -178,7 +182,7 @@ var w = {
178
182
  x2: i,
179
183
  y2: a
180
184
  });
181
- } else t.type === "pdf_region" && (n = N(t.bbox));
185
+ } else t.type === "pdf_region" && (n = ee(t.bbox));
182
186
  if (n == null) return;
183
187
  let i = t.page;
184
188
  if (!(typeof i != "number" || !Number.isInteger(i) || i < 1) && [
@@ -193,7 +197,7 @@ var w = {
193
197
  x2: n.x2,
194
198
  y2: n.y2
195
199
  };
196
- }, ee = (e) => e.flatMap((e, t) => {
200
+ }, F = (e) => e.flatMap((e, t) => {
197
201
  let n = e.body?.selector;
198
202
  if (n == null) return [];
199
203
  let i = (Array.isArray(n) ? n : [n]).flatMap((e) => {
@@ -204,7 +208,7 @@ var w = {
204
208
  return i.length === 0 ? [] : [{
205
209
  id: String(e.index ?? t),
206
210
  bboxes: i,
207
- style: M
211
+ style: N
208
212
  }];
209
213
  }), te = (e, t) => String(e.index ?? t), ne = (e) => {
210
214
  let t = e.body?.selector;
@@ -215,25 +219,25 @@ var w = {
215
219
  let t = P(e);
216
220
  if (t != null) return t.page;
217
221
  }
218
- }, F = (e) => {
222
+ }, I = (e) => {
219
223
  let t = e.custom_content?.annotations;
220
224
  if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(a);
221
225
  let n = e.custom_fields;
222
226
  if (typeof n != "object" || !n) return [];
223
227
  let r = n.annotations;
224
228
  return !Array.isArray(r) || r.length === 0 ? [] : o(r, e.custom_content?.attachments ?? []).map(a);
225
- }, I = (e) => {
229
+ }, L = (e) => {
226
230
  if (e.type !== "docx_text_range") return !1;
227
231
  let t = e;
228
232
  return typeof t.story == "string" && Array.isArray(t.path) && t.path.every((e) => typeof e == "number") && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
229
- }, L = (e) => {
233
+ }, R = (e) => {
230
234
  if (e.type !== "pptx_text_range") return !1;
231
235
  let t = e;
232
236
  return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
233
- }, R = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", z = (e) => {
237
+ }, z = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", B = (e) => {
234
238
  if (e.type !== "excel_rc_range") return !1;
235
239
  let t = e;
236
- return typeof t.sheet == "string" && R(t.start) && (t.end === void 0 || t.end === null || R(t.end));
240
+ return typeof t.sheet == "string" && z(t.start) && (t.end === void 0 || t.end === null || z(t.end));
237
241
  }, re = (e) => {
238
242
  let { story: t, path: n, start: r, end: i, text: a } = e;
239
243
  if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
@@ -273,34 +277,34 @@ var w = {
273
277
  let t = e.body?.selector;
274
278
  return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
275
279
  if (!r(e)) return [];
276
- if (I(e)) {
280
+ if (L(e)) {
277
281
  let t = re(e);
278
282
  return t ? [t] : [];
279
283
  }
280
- if (L(e)) {
284
+ if (R(e)) {
281
285
  let t = ie(e);
282
286
  return t ? [t] : [];
283
287
  }
284
- if (z(e)) {
288
+ if (B(e)) {
285
289
  let t = ae(e);
286
290
  return t ? [t] : [];
287
291
  }
288
292
  return [];
289
293
  });
290
- }, se = (e, t) => S(() => t ? [] : F(e), [t, e]), ce = {
291
- openGroupKey: null,
294
+ }, se = (e, t) => C(() => t ? [] : I(e), [t, e]), ce = {
295
+ openOwnerKey: null,
292
296
  activeIndexByGroup: {}
293
297
  }, le = () => {
294
- let [e, t] = C(ce), n = b((e) => {
298
+ let [e, t] = w(ce), n = b((e) => {
295
299
  t((t) => ({
296
300
  ...t,
297
- openGroupKey: e
298
- }));
299
- }, []), r = b(() => {
300
- t((e) => ({
301
- ...e,
302
- openGroupKey: null
301
+ openOwnerKey: e
303
302
  }));
303
+ }, []), r = b((e) => {
304
+ t((t) => t.openOwnerKey === e ? {
305
+ ...t,
306
+ openOwnerKey: null
307
+ } : t);
304
308
  }, []), i = b((e, n) => {
305
309
  t((t) => ({
306
310
  ...t,
@@ -310,11 +314,11 @@ var w = {
310
314
  }
311
315
  }));
312
316
  }, []);
313
- return S(() => ({
317
+ return C(() => ({
314
318
  openPopup: n,
315
319
  closePopup: r,
316
320
  setActiveIndex: i,
317
- isOpen: (t) => e.openGroupKey === t,
321
+ isOpen: (t) => e.openOwnerKey === t,
318
322
  getActiveIndex: (t) => e.activeIndexByGroup[t] ?? 0
319
323
  }), [
320
324
  n,
@@ -322,7 +326,7 @@ var w = {
322
326
  i,
323
327
  e
324
328
  ]);
325
- }, ue = /⟦C(\d+)⟧/g, B = (e, t) => {
329
+ }, V = /⟦C(\d+)⟧/g, H = (e, t) => {
326
330
  let n = t.map((e, t) => ({
327
331
  g: e,
328
332
  idx: t
@@ -335,9 +339,9 @@ var w = {
335
339
  }).sort((e, t) => t.pos - e.pos), r = e;
336
340
  for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
337
341
  return r;
338
- }, V = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, H = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, de = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, fe = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), U = (e) => e.replace(de, (e) => H.test(e) ? e : fe(e)), W = (e) => U(e).replace(V, ""), G = (e, t) => {
342
+ }, U = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, ue = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, de = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, fe = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), W = (e) => e.replace(de, (e) => ue.test(e) ? e : fe(e)), G = (e) => W(e).replace(U, ""), K = (e, t) => {
339
343
  if (typeof e == "string") {
340
- let n = e.split(ue);
344
+ let n = e.split(V);
341
345
  if (n.length === 1) return e;
342
346
  let r = [];
343
347
  return n.forEach((e, n) => {
@@ -345,7 +349,7 @@ var w = {
345
349
  }), r;
346
350
  }
347
351
  return Array.isArray(e) ? e.flatMap((e) => {
348
- let n = G(e, t);
352
+ let n = K(e, t);
349
353
  return Array.isArray(n) ? n : [n];
350
354
  }) : e;
351
355
  }, pe = (e) => {
@@ -356,14 +360,14 @@ var w = {
356
360
  t,
357
361
  "</cit>"
358
362
  ] }), he = (e, t, n, r = !1, a = !1) => {
359
- let { onPreview: o, onOpenInBrowser: s, buildLabels: c } = n, l = S(() => r ? W(e) : U(t.length > 0 ? B(e, t) : e), [
363
+ let { onPreview: o, onOpenInBrowser: s, buildLabels: c } = n, l = C(() => r ? G(e) : W(t.length > 0 ? H(e, t) : e), [
360
364
  e,
361
365
  t,
362
366
  r
363
367
  ]), u = l.includes("<cit");
364
368
  return {
365
369
  processedContent: l,
366
- markdownComponents: S(() => {
370
+ markdownComponents: C(() => {
367
371
  let e = /* @__PURE__ */ new Map();
368
372
  for (let n of t) {
369
373
  let t = pe(n);
@@ -371,7 +375,7 @@ var w = {
371
375
  }
372
376
  let n = (e) => {
373
377
  let { cardLabels: t, markerLabels: n } = c(e);
374
- return /* @__PURE__ */ _(j, {
378
+ return /* @__PURE__ */ _(M, {
375
379
  group: e,
376
380
  onPreview: (t) => o(t, e),
377
381
  onOpenInBrowser: s,
@@ -390,12 +394,12 @@ var w = {
390
394
  p: ({ children: e, ...t }) => /* @__PURE__ */ _("p", {
391
395
  ...t,
392
396
  className: i(a ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [overflow-wrap:anywhere] [text-wrap:pretty] last:mb-0"),
393
- children: G(e, r)
397
+ children: K(e, r)
394
398
  }),
395
399
  li: ({ children: e, ...t }) => /* @__PURE__ */ _("li", {
396
400
  ...t,
397
401
  className: "mb-1.5 last:mb-0",
398
- children: G(e, r)
402
+ children: K(e, r)
399
403
  })
400
404
  };
401
405
  }, [
@@ -407,7 +411,7 @@ var w = {
407
411
  u
408
412
  ])
409
413
  };
410
- }, K = (e) => {
414
+ }, q = (e) => {
411
415
  try {
412
416
  return decodeURIComponent(e);
413
417
  } catch {
@@ -416,14 +420,14 @@ var w = {
416
420
  }, ge = (e) => {
417
421
  try {
418
422
  let t = new URL(e);
419
- return t.pathname.split("/").map((e) => K(e)).filter(Boolean).at(-1) ?? t.hostname;
423
+ return t.pathname.split("/").map((e) => q(e)).filter(Boolean).at(-1) ?? t.hostname;
420
424
  } catch {
421
- return e.split("/").map((e) => K(e)).filter(Boolean).at(-1) ?? e;
425
+ return e.split("/").map((e) => q(e)).filter(Boolean).at(-1) ?? e;
422
426
  }
423
- }, q = (e, t) => e.body?.source?.attachment?.title ?? ge(t), J = (e) => {
427
+ }, J = (e, t) => e.body?.source?.attachment?.title ?? ge(t), Y = (e) => {
424
428
  let t = e.target?.selector;
425
429
  return t?.type === "html_tag" ? t : void 0;
426
- }, _e = (e) => J(e) != null, Y = (e) => {
430
+ }, _e = (e) => Y(e) != null, X = (e) => {
427
431
  let t = /* @__PURE__ */ new Map();
428
432
  for (let n of e) {
429
433
  if (_e(n)) continue;
@@ -433,16 +437,16 @@ var w = {
433
437
  r ? r.annotations.push(n) : t.set(e, {
434
438
  groupKey: e,
435
439
  sourceUrl: e,
436
- sourceName: q(n, e),
440
+ sourceName: J(n, e),
437
441
  annotations: [n],
438
442
  primaryAnnotation: n
439
443
  });
440
444
  }
441
445
  return Array.from(t.values());
442
- }, X = (e) => {
446
+ }, Z = (e) => {
443
447
  let t = /* @__PURE__ */ new Map();
444
448
  for (let n of e) {
445
- let e = J(n)?.id;
449
+ let e = Y(n)?.id;
446
450
  if (e == null) continue;
447
451
  let r = n.body?.source?.attachment?.url;
448
452
  if (r == null) continue;
@@ -450,22 +454,22 @@ var w = {
450
454
  i ? i.annotations.push(n) : t.set(e, {
451
455
  groupKey: `cit:${e}`,
452
456
  sourceUrl: r,
453
- sourceName: q(n, r),
457
+ sourceName: J(n, r),
454
458
  annotations: [n],
455
459
  primaryAnnotation: n
456
460
  });
457
461
  }
458
462
  return Array.from(t.values());
459
- }, ve = (e) => [...X(e), ...Y(e)], Z = (e, t) => {
463
+ }, ve = (e) => [...Z(e), ...X(e)], ye = (e, t) => {
460
464
  let n = e.body?.source?.attachment?.url;
461
465
  return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
462
- }, Q = (e) => e.url == null && e.reference_url != null, ye = /^(.*\.pdf)(?:#page=(\d+))?$/i, $ = (e) => {
463
- let t = ye.exec(e);
466
+ }, Q = (e) => e.url == null && e.reference_url != null, be = /^(.*\.pdf)(?:#page=(\d+))?$/i, $ = (e) => {
467
+ let t = be.exec(e);
464
468
  return t ? {
465
469
  baseUrl: t[1],
466
470
  page: t[2] == null ? null : Number(t[2])
467
471
  } : null;
468
- }, be = (t) => Y((t ?? []).filter(Q).map((t) => {
472
+ }, xe = (t) => X((t ?? []).filter(Q).map((t) => {
469
473
  let n = t.reference_url, r = $(n) != null;
470
474
  return { body: {
471
475
  quote: t.data,
@@ -480,4 +484,4 @@ var w = {
480
484
  } };
481
485
  }));
482
486
  //#endregion
483
- export { T as CitationCard, O as CitationCardProvider, j as CitationDropdown, E as CitationMarker, te as annotationHighlightId, oe as annotationToOfficeHighlightLocations, ee as annotationsToPdfHighlights, Z as gatherSameSourceAnnotations, ne as getAnnotationPdfPage, be as getReferenceAttachmentGroups, ve as groupAnnotations, X as groupAnnotationsByCitId, Y as groupAnnotationsBySource, B as injectCitationSentinels, I as isDocxRangeSelector, z as isExcelRcRangeSelector, L as isPptxRangeSelector, Q as isReferenceOnlyAttachment, $ as parsePdfPageReference, G as replaceSentinelsInChildren, F as resolveMessageAnnotations, W as stripCitTagsWhileStreaming, se as useAnnotations, le as useCitationCard, k as useCitationCardContext, he as useCitationMarkdownComponents };
487
+ export { E as CitationCard, k as CitationCardProvider, M as CitationDropdown, D as CitationMarker, te as annotationHighlightId, oe as annotationToOfficeHighlightLocations, F as annotationsToPdfHighlights, ye as gatherSameSourceAnnotations, ne as getAnnotationPdfPage, xe as getReferenceAttachmentGroups, ve as groupAnnotations, Z as groupAnnotationsByCitId, X as groupAnnotationsBySource, H as injectCitationSentinels, L as isDocxRangeSelector, B as isExcelRcRangeSelector, R as isPptxRangeSelector, Q as isReferenceOnlyAttachment, $ as parsePdfPageReference, K as replaceSentinelsInChildren, I as resolveMessageAnnotations, G as stripCitTagsWhileStreaming, se as useAnnotations, le as useCitationCard, A as useCitationCardContext, he as useCitationMarkdownComponents };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-quotations",
3
3
  "description": "Citation and annotation components, hooks, and utilities for AI DIAL conversations",
4
- "version": "1.2.0-dev.2",
4
+ "version": "1.2.0-dev.6",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "^19.2.8",
26
- "@epam/ai-dial-chat-shared": "1.2.0-dev.2",
26
+ "@epam/ai-dial-chat-shared": "1.2.0-dev.6",
27
27
  "@epam/ai-dial-ui-kit": "^0.14.2"
28
28
  },
29
29
  "repository": {
@@ -1,15 +1,22 @@
1
1
  /**
2
2
  * Manages open/close state and per-group active annotation index for citation
3
- * cards within a single assistant message. State is keyed by
4
- * `AnnotationGroup.groupKey`, not `sourceUrl` — two groups can share a
5
- * `sourceUrl` (e.g. two `cit`-id groups citing the same document) while
6
- * having independent popup/switcher state.
3
+ * cards within a single assistant message. The hook carries two distinct key
4
+ * spaces:
5
+ *
6
+ * - Openness (`openPopup`/`closePopup`/`isOpen`) is keyed by **occurrence
7
+ * owner key** — a stable per-instance id derived by the rendered
8
+ * `CitationDropdown` (see its `ownerKey`), not by `AnnotationGroup.groupKey`
9
+ * or `sourceUrl`. Two rendered occurrences resolving to the same group are
10
+ * therefore always independent popup owners.
11
+ * - The switcher index (`setActiveIndex`/`getActiveIndex`) is keyed by
12
+ * `groupKey`, because the index indexes into `group.annotations`, which is
13
+ * group data, not occurrence data.
7
14
  */
8
15
  export declare const useCitationCard: () => {
9
- openPopup: (groupKey: string) => void;
10
- closePopup: () => void;
16
+ openPopup: (ownerKey: string) => void;
17
+ closePopup: (ownerKey: string) => void;
11
18
  setActiveIndex: (groupKey: string, index: number) => void;
12
- isOpen: (groupKey: string) => boolean;
19
+ isOpen: (ownerKey: string) => boolean;
13
20
  getActiveIndex: (groupKey: string) => number;
14
21
  };
15
22
  //# sourceMappingURL=useCitationCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCitationCard.d.ts","sourceRoot":"","sources":["../../src/utils/useCitationCard.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;0BAGe,MAAM;;+BAQD,MAAM,SAAS,MAAM;uBAY5C,MAAM;+BACE,MAAM;CAKtC,CAAC"}
1
+ {"version":3,"file":"useCitationCard.d.ts","sourceRoot":"","sources":["../../src/utils/useCitationCard.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe;0BAGe,MAAM;2BAIL,MAAM;+BAMF,MAAM,SAAS,MAAM;uBAY5C,MAAM;+BACE,MAAM;CAKtC,CAAC"}