@epam/ai-dial-conversation-stages 1.0.4 → 1.0.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":"CollapsedGroup.d.ts","sourceRoot":"","sources":["../../../src/components/CollapsedGroup/CollapsedGroup.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAUxE,gJAAgJ;AAChJ,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA+OlD,CAAC"}
1
+ {"version":3,"file":"CollapsedGroup.d.ts","sourceRoot":"","sources":["../../../src/components/CollapsedGroup/CollapsedGroup.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAUxE,gJAAgJ;AAChJ,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA8OlD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"StagesPanel.d.ts","sourceRoot":"","sources":["../../../src/components/StagesPanel/StagesPanel.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAEV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AA8InC,+FAA+F;AAC/F,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA+D5C,CAAC"}
1
+ {"version":3,"file":"StagesPanel.d.ts","sourceRoot":"","sources":["../../../src/components/StagesPanel/StagesPanel.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAEV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AA4InC,+FAA+F;AAC/F,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA+D5C,CAAC"}
package/index.js CHANGED
@@ -4,30 +4,58 @@ import { IconAlertCircle as f, IconCheck as p, IconChevronDown as m, IconChevron
4
4
  import { memo as _, useCallback as v, useEffect as y, useRef as b, useState as x } from "react";
5
5
  import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
6
6
  //#region src/utils/stage-name.ts
7
- var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e) => {
8
- let t = e ?? "";
7
+ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /\bStart:\s*(\d{1,2}):([0-5]\d):([0-5]\d(?:\.\d+)?)\b/i, O = /:\s*$/, k = 1440 * 60, A = k / 2, j = (e) => {
8
+ let t = D.exec(e);
9
+ if (!t) return;
10
+ let n = Number(t[1]);
11
+ if (!(n > 23)) return n * 60 * 60 + Number(t[2]) * 60 + Number(t[3]);
12
+ }, M = (e) => {
9
13
  T.lastIndex = 0;
10
- let n, r = null, i = -1, a = 0;
11
- for (; n = T.exec(t);) {
12
- let e = n[0].slice(1, -1), t = E.exec(e);
13
- if (t) {
14
- r = t, i = n.index, a = n[0].length;
15
- break;
16
- }
14
+ let t;
15
+ for (; t = T.exec(e);) {
16
+ let e = t[0].slice(1, -1), n = E.exec(e);
17
+ if (n) return {
18
+ durationLabel: `${n[1]}s`,
19
+ groupIndex: t.index,
20
+ groupLength: t[0].length,
21
+ startTimeSeconds: j(e)
22
+ };
17
23
  }
24
+ }, N = (e) => {
25
+ let t = e ?? "", n = M(t);
18
26
  return {
19
- name: (r && i >= 0 ? t.slice(0, i) + t.slice(i + a) : t).replace(D, "").trim().replace(/ {2,}/g, " "),
20
- durationLabel: r ? `${r[1]}s` : void 0
27
+ name: (n ? t.slice(0, n.groupIndex) + t.slice(n.groupIndex + n.groupLength) : t).replace(O, "").trim().replace(/ {2,}/g, " "),
28
+ durationLabel: n?.durationLabel
21
29
  };
22
- }, k = (e) => e.length > 0 && !/\s/.test(e) && e.includes("_"), A = (e) => e >= 60 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${e.toFixed(1)}s`, j = (e) => {
30
+ }, P = (e) => e.length > 0 && !/\s/.test(e) && e.includes("_"), F = (e) => e >= 60 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${e.toFixed(1)}s`, I = (e) => {
23
31
  if (!e) return;
24
32
  let t = /^(\d+(?:\.\d+)?)s$/.exec(e);
25
33
  return t ? parseFloat(t[1]) : void 0;
26
- }, M = (e) => [...e].reverse().find((e) => e.status == null), N = (e, t) => e.findIndex((e) => e.index === t.index) + 1, P = (e) => {
34
+ }, L = (e) => {
35
+ let t = e.flatMap((e) => {
36
+ let t = M(e ?? ""), n = I(t?.durationLabel);
37
+ return n == null ? [] : [{
38
+ durationSeconds: n,
39
+ startTimeSeconds: t?.startTimeSeconds
40
+ }];
41
+ });
42
+ if (t.length === 0) return 0;
43
+ if (t.some(({ startTimeSeconds: e }) => e == null)) return t.reduce((e, { durationSeconds: t }) => e + t, 0);
44
+ let n = 0, r, i = t.flatMap(({ durationSeconds: e, startTimeSeconds: t }) => {
45
+ if (t == null) return [];
46
+ let i = t + n;
47
+ return r != null && r - i > A && (n += k, i += k), r = i, {
48
+ start: i,
49
+ end: i + e
50
+ };
51
+ }).sort((e, t) => e.start - t.start), a = 0, o = i[0].start, s = i[0].end;
52
+ for (let e of i.slice(1)) e.start <= s ? s = Math.max(s, e.end) : (a += s - o, o = e.start, s = e.end);
53
+ return a + s - o;
54
+ }, R = (e) => [...e].reverse().find((e) => e.status == null), z = (e, t) => e.findIndex((e) => e.index === t.index) + 1, B = (e) => {
27
55
  let t = [], n = 0;
28
56
  for (; n < e.length;) {
29
- let r = e[n], i = O(r.name).name, a = n + 1;
30
- for (; a < e.length && O(e[a].name).name === i;) a += 1;
57
+ let r = e[n], i = N(r.name).name, a = n + 1;
58
+ for (; a < e.length && N(e[a].name).name === i;) a += 1;
31
59
  let o = e.slice(n, a);
32
60
  o.length > 1 ? t.push({
33
61
  key: r.index,
@@ -39,7 +67,7 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
39
67
  }), n = a;
40
68
  }
41
69
  return t;
42
- }, F = {
70
+ }, V = {
43
71
  panel: "_panel_vd48n_1",
44
72
  row: "_row_vd48n_5",
45
73
  collapseButton: "_collapseButton_vd48n_9",
@@ -57,12 +85,12 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
57
85
  codeInline: "_codeInline_vd48n_62",
58
86
  blockquote: "_blockquote_vd48n_68",
59
87
  tableCell: "_tableCell_vd48n_73"
60
- }, I = ({ status: e, isLive: n, runningLabel: r = "Running", failedLabel: i = "Failed" }) => n ? /* @__PURE__ */ C(d, {
88
+ }, H = ({ status: e, isLive: n, runningLabel: r = "Running", failedLabel: i = "Failed" }) => n ? /* @__PURE__ */ C(d, {
61
89
  size: 16,
62
90
  ariaLabel: r
63
91
  }) : e === t.Failed ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(f, {
64
92
  size: a.MD,
65
- className: F.iconError,
93
+ className: V.iconError,
66
94
  "aria-hidden": !0,
67
95
  stroke: o
68
96
  }), /* @__PURE__ */ C("span", {
@@ -70,10 +98,10 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
70
98
  children: i
71
99
  })] }) : /* @__PURE__ */ C(p, {
72
100
  size: a.SM,
73
- className: F.iconCompleted,
101
+ className: V.iconCompleted,
74
102
  "aria-hidden": !0,
75
103
  stroke: o
76
- }), L = ({ children: e, codeClassName: t, blockClassName: n = "dial-code-text", copyAriaLabel: c }) => {
104
+ }), U = ({ children: e, codeClassName: t, blockClassName: n = "dial-code-text", copyAriaLabel: c }) => {
77
105
  let [u, d] = x(!1), f = b(null);
78
106
  y(() => () => {
79
107
  f.current != null && clearTimeout(f.current);
@@ -82,12 +110,12 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
82
110
  r(typeof e == "string" ? e : String(e ?? "")), f.current && clearTimeout(f.current), d(!0), f.current = setTimeout(() => d(!1), 2e3);
83
111
  }, [e]);
84
112
  return /* @__PURE__ */ w("pre", {
85
- className: i("relative max-h-[300px] overflow-auto rounded border p-3", n, F.codeBlock),
113
+ className: i("relative max-h-[300px] overflow-auto rounded border p-3", n, V.codeBlock),
86
114
  children: [/* @__PURE__ */ C(l, {
87
115
  size: s.Small,
88
116
  icon: C(u ? p : g, {
89
117
  size: a.SM,
90
- className: F.iconSecondary,
118
+ className: V.iconSecondary,
91
119
  stroke: o
92
120
  }),
93
121
  "aria-label": c,
@@ -98,8 +126,8 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
98
126
  children: e
99
127
  })]
100
128
  });
101
- }, R = _(({ content: t, typography: n, copyAriaLabel: r = "Copy" }) => {
102
- let a = "mb-1.5 last:mb-0", o = i(n?.headingClassName ?? "dial-small-semi-text", F.stageContent, a);
129
+ }, W = _(({ content: t, typography: n, copyAriaLabel: r = "Copy" }) => {
130
+ let a = "mb-1.5 last:mb-0", o = i(n?.headingClassName ?? "dial-small-semi-text", V.stageContent, a);
103
131
  return /* @__PURE__ */ C(e, {
104
132
  content: t,
105
133
  classNames: {
@@ -109,30 +137,30 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
109
137
  h4: o,
110
138
  h5: o,
111
139
  h6: o,
112
- p: i(n?.contentClassName ?? "dial-tiny-text", F.stageContent, "mb-1.5"),
113
- ul: i(n?.contentClassName ?? "dial-tiny-text", F.stageContent, a),
114
- ol: i(n?.contentClassName ?? "dial-tiny-text", F.stageContent, a),
115
- strong: i(n?.strongClassName ?? n?.contentClassName ?? "dial-tiny-text", F.stageContent),
116
- codeInline: F.codeInline,
117
- blockquote: i(n?.contentClassName ?? "dial-tiny-text", F.blockquote, a),
118
- link: i(n?.contentClassName ?? "dial-tiny-text", F.stageContent),
119
- tableCell: i(n?.contentClassName ?? "dial-tiny-text", F.tableCell)
140
+ p: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent, "mb-1.5"),
141
+ ul: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent, a),
142
+ ol: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent, a),
143
+ strong: i(n?.strongClassName ?? n?.contentClassName ?? "dial-tiny-text", V.stageContent),
144
+ codeInline: V.codeInline,
145
+ blockquote: i(n?.contentClassName ?? "dial-tiny-text", V.blockquote, a),
146
+ link: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent),
147
+ tableCell: i(n?.contentClassName ?? "dial-tiny-text", V.tableCell)
120
148
  },
121
- components: { code: ({ children: e, className: t }) => t?.includes("language-") ? /* @__PURE__ */ C(L, {
149
+ components: { code: ({ children: e, className: t }) => t?.includes("language-") ? /* @__PURE__ */ C(U, {
122
150
  codeClassName: t,
123
151
  blockClassName: n?.codeBlockClassName,
124
152
  copyAriaLabel: r,
125
153
  children: e
126
154
  }) : /* @__PURE__ */ C("code", {
127
- className: i("inline-block px-1.5 py-1", n?.codeClassName ?? "dial-code-text rounded-md", F.codeInline),
155
+ className: i("inline-block px-1.5 py-1", n?.codeClassName ?? "dial-code-text rounded-md", V.codeInline),
128
156
  children: e
129
157
  }) }
130
158
  });
131
- }), z = ({ stage: e, isLive: n, typography: r, labels: s, nameOverride: l }) => {
132
- let [u, d] = x(!1), { copyAriaLabel: f = "Copy stage content", runningAriaLabel: p, failedAriaLabel: g } = s ?? {}, { name: _, durationLabel: v } = O(e.name), y = l ?? _, b = !l && k(_), T = e.status === t.Failed, E = !!e.content, D = /* @__PURE__ */ w(S, { children: [
159
+ }), G = ({ stage: e, isLive: n, typography: r, labels: s, nameOverride: l }) => {
160
+ let [u, d] = x(!1), { copyAriaLabel: f = "Copy stage content", runningAriaLabel: p, failedAriaLabel: g } = s ?? {}, { name: _, durationLabel: v } = N(e.name), y = l ?? _, b = !l && P(_), T = e.status === t.Failed, E = !!e.content, D = /* @__PURE__ */ w(S, { children: [
133
161
  /* @__PURE__ */ C("span", {
134
162
  className: "flex flex-none items-center",
135
- children: /* @__PURE__ */ C(I, {
163
+ children: /* @__PURE__ */ C(H, {
136
164
  status: e.status,
137
165
  isLive: n,
138
166
  runningLabel: p,
@@ -140,19 +168,19 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
140
168
  })
141
169
  }),
142
170
  /* @__PURE__ */ C("span", {
143
- className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", F.stageName, T && F.stageNameFailed, b && F.monoName),
171
+ className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", V.stageName, T && V.stageNameFailed, b && V.monoName),
144
172
  children: /* @__PURE__ */ C(c, { text: y || e.status || "" })
145
173
  }),
146
174
  e.tag && /* @__PURE__ */ C("span", {
147
- className: i("flex-none", r?.tagClassName ?? "dial-tiny-lead-text", F.tag),
175
+ className: i("flex-none", r?.tagClassName ?? "dial-tiny-lead-text", V.tag),
148
176
  children: e.tag
149
177
  }),
150
178
  v && /* @__PURE__ */ C("span", {
151
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", F.duration),
179
+ className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", V.duration),
152
180
  children: v
153
181
  }),
154
182
  E && /* @__PURE__ */ C("span", {
155
- className: i("flex-none", F.iconSecondary),
183
+ className: i("flex-none", V.iconSecondary),
156
184
  children: u ? /* @__PURE__ */ C(m, {
157
185
  size: a.SM,
158
186
  "aria-hidden": !0,
@@ -164,9 +192,9 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
164
192
  stroke: o
165
193
  })
166
194
  })
167
- ] }), A = i("flex w-full items-center gap-2 px-2 py-1.5", F.row);
195
+ ] }), O = i("flex w-full items-center gap-2 px-2 py-1.5", V.row);
168
196
  return E ? /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("div", {
169
- className: A,
197
+ className: O,
170
198
  children: /* @__PURE__ */ C("button", {
171
199
  type: "button",
172
200
  onClick: () => d((e) => !e),
@@ -182,7 +210,7 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
182
210
  className: "mt-2 flex flex-col gap-3 py-1 ps-8",
183
211
  children: e.content && /* @__PURE__ */ C("div", {
184
212
  className: "max-h-[300px] overflow-y-auto",
185
- children: /* @__PURE__ */ C(R, {
213
+ children: /* @__PURE__ */ C(W, {
186
214
  content: e.content,
187
215
  typography: r,
188
216
  copyAriaLabel: f
@@ -191,23 +219,20 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
191
219
  })
192
220
  })
193
221
  })] }) : /* @__PURE__ */ C("div", {
194
- className: A,
222
+ className: O,
195
223
  children: D
196
224
  });
197
- }, B = ({ row: e, isLive: n, typography: r, labels: s }) => {
198
- let { runningAriaLabel: l, failedAriaLabel: u, attemptLabel: d = (e) => `Attempt ${e}` } = s ?? {}, [f, p] = x(!1), g = e.attempts?.some((e) => e.status === t.Failed), _ = (e.attempts || []).reduce((e, t) => {
199
- let { durationLabel: n } = O(t.name);
200
- return e + (j(n) ?? 0);
201
- }, 0), v = _ > 0 ? A(_) : void 0;
225
+ }, K = ({ row: e, isLive: n, typography: r, labels: s }) => {
226
+ let { runningAriaLabel: l, failedAriaLabel: u, attemptLabel: d = (e) => `Attempt ${e}` } = s ?? {}, [f, p] = x(!1), g = e.attempts?.some((e) => e.status === t.Failed), _ = L((e.attempts || []).map((e) => e.name)), v = _ > 0 ? F(_) : void 0;
202
227
  return /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ w("button", {
203
228
  type: "button",
204
229
  onClick: () => p((e) => !e),
205
230
  "aria-expanded": f,
206
- className: i("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start", F.collapseButton, F.row),
231
+ className: i("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start", V.collapseButton, V.row),
207
232
  children: [
208
233
  /* @__PURE__ */ C("span", {
209
234
  className: "flex flex-none items-center",
210
- children: /* @__PURE__ */ C(I, {
235
+ children: /* @__PURE__ */ C(H, {
211
236
  status: g ? t.Failed : t.Completed,
212
237
  isLive: n,
213
238
  runningLabel: l,
@@ -215,19 +240,19 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
215
240
  })
216
241
  }),
217
242
  /* @__PURE__ */ C("span", {
218
- className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", F.stageName, g && F.stageNameFailed),
243
+ className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", V.stageName, g && V.stageNameFailed),
219
244
  children: /* @__PURE__ */ C(c, { text: e.name })
220
245
  }),
221
246
  /* @__PURE__ */ w("span", {
222
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", F.count),
247
+ className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", V.count),
223
248
  children: ["×", e.attempts?.length ?? 0]
224
249
  }),
225
250
  v && /* @__PURE__ */ C("span", {
226
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", F.duration),
251
+ className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", V.duration),
227
252
  children: v
228
253
  }),
229
254
  /* @__PURE__ */ C("span", {
230
- className: i("flex-none", F.iconSecondary),
255
+ className: i("flex-none", V.iconSecondary),
231
256
  children: f ? /* @__PURE__ */ C(m, {
232
257
  size: a.SM,
233
258
  "aria-hidden": !0,
@@ -249,7 +274,7 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
249
274
  className: "mt-1 flex flex-col gap-0.5 ps-6",
250
275
  children: e.attempts?.map((t, i) => /* @__PURE__ */ C("li", {
251
276
  role: "listitem",
252
- children: /* @__PURE__ */ C(z, {
277
+ children: /* @__PURE__ */ C(G, {
253
278
  stage: t,
254
279
  nameOverride: d(i + 1),
255
280
  isLive: n && t.index === e.attempts?.[e.attempts.length - 1]?.index,
@@ -260,7 +285,7 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
260
285
  })
261
286
  })
262
287
  })] });
263
- }, V = ({ stages: e, isStreaming: t, className: r, styles: a, labels: o }) => {
288
+ }, q = ({ stages: e, isStreaming: t, className: r, styles: a, labels: o }) => {
264
289
  let { colors: s, typography: c } = a ?? {}, l = n({
265
290
  "--cs-text": s?.text,
266
291
  "--cs-row-hover": s?.rowHoverColor,
@@ -277,16 +302,16 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
277
302
  "--cs-code-border": s?.codeBorderColor,
278
303
  "--cs-code-text": s?.codeTextColor,
279
304
  "--cs-border": s?.borderColor
280
- }), u = t ? M(e) : void 0, d = P(e);
305
+ }), u = t ? R(e) : void 0, d = B(e);
281
306
  return /* @__PURE__ */ C("div", {
282
307
  style: l,
283
- className: i("w-full", F.panel, r),
308
+ className: i("w-full", V.panel, r),
284
309
  children: /* @__PURE__ */ C("ul", {
285
310
  role: "list",
286
311
  className: "flex w-full flex-col gap-0.5 ps-5",
287
312
  children: d.map((e) => e.stage ? /* @__PURE__ */ C("li", {
288
313
  role: "listitem",
289
- children: /* @__PURE__ */ C(z, {
314
+ children: /* @__PURE__ */ C(G, {
290
315
  stage: e.stage,
291
316
  isLive: u?.index === e.stage.index,
292
317
  typography: c,
@@ -294,7 +319,7 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
294
319
  })
295
320
  }, e.key) : /* @__PURE__ */ C("li", {
296
321
  role: "listitem",
297
- children: /* @__PURE__ */ C(B, {
322
+ children: /* @__PURE__ */ C(K, {
298
323
  row: e,
299
324
  isLive: u?.index === e.attempts?.[e.attempts.length - 1].index,
300
325
  typography: c,
@@ -303,64 +328,61 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
303
328
  }, e.key))
304
329
  })
305
330
  });
306
- }, H = {
331
+ }, J = {
307
332
  toggleButton: "_toggleButton_1sa5v_1",
308
333
  executedLabel: "_executedLabel_1sa5v_13",
309
334
  stepsCount: "_stepsCount_1sa5v_17",
310
335
  doneIcon: "_doneIcon_1sa5v_22",
311
336
  failedText: "_failedText_1sa5v_26",
312
337
  liveName: "_liveName_1sa5v_30"
313
- }, U = ({ stages: e, isStreaming: r, labels: s, className: l, styles: f }) => {
314
- let { executedLabel: g = "Executed", stepsLabel: _ = () => "steps", failedCountLabel: v = (e) => `${e} failed`, runningStepLabel: S = (e, t) => `Step ${e} of ${t}`, runningAriaLabel: T = "Running", copyAriaLabel: E, failedAriaLabel: D, attemptLabel: k } = s ?? {}, [P, F] = x(r), I = b(r);
338
+ }, Y = ({ stages: e, isStreaming: r, labels: s, className: l, styles: f }) => {
339
+ let { executedLabel: g = "Executed", stepsLabel: _ = () => "steps", failedCountLabel: v = (e) => `${e} failed`, runningStepLabel: S = (e, t) => `Step ${e} of ${t}`, runningAriaLabel: T = "Running", copyAriaLabel: E, failedAriaLabel: D, attemptLabel: O } = s ?? {}, [k, A] = x(r), j = b(r);
315
340
  y(() => {
316
- I.current && !r && F(!1), I.current = r;
341
+ j.current && !r && A(!1), j.current = r;
317
342
  }, [r]);
318
- let { colors: L, panel: R } = f ?? {}, z = f?.typography ?? { fontClassName: "dial-small-text" }, B = n({
319
- "--cs-cg-label": L?.labelColor,
320
- "--cs-cg-label-hover": L?.labelHoverColor,
321
- "--cs-cg-steps-count": L?.stepsCountColor,
322
- "--cs-cg-done": L?.doneColor,
323
- "--cs-cg-failed": L?.failedColor,
324
- "--cs-text": R?.text,
325
- "--cs-row-hover": R?.rowHoverColor,
326
- "--cs-button-bg": R?.collapsedButtonBg,
327
- "--cs-stage-text": R?.stageTextColor,
328
- "--cs-failed-text": R?.failedColor,
329
- "--cs-tag-text": R?.tagTextColor,
330
- "--cs-count-text": R?.countTextColor,
331
- "--cs-duration-text": R?.durationTextColor,
332
- "--cs-icon-secondary": R?.iconSecondaryColor,
333
- "--cs-icon-completed": R?.iconCompletedColor,
334
- "--cs-icon-error": R?.iconErrorColor,
335
- "--cs-code-bg": R?.codeBg,
336
- "--cs-code-border": R?.codeBorderColor,
337
- "--cs-code-text": R?.codeTextColor,
338
- "--cs-border": R?.borderColor
343
+ let { colors: M, panel: P } = f ?? {}, I = f?.typography ?? { fontClassName: "dial-small-text" }, B = n({
344
+ "--cs-cg-label": M?.labelColor,
345
+ "--cs-cg-label-hover": M?.labelHoverColor,
346
+ "--cs-cg-steps-count": M?.stepsCountColor,
347
+ "--cs-cg-done": M?.doneColor,
348
+ "--cs-cg-failed": M?.failedColor,
349
+ "--cs-text": P?.text,
350
+ "--cs-row-hover": P?.rowHoverColor,
351
+ "--cs-button-bg": P?.collapsedButtonBg,
352
+ "--cs-stage-text": P?.stageTextColor,
353
+ "--cs-failed-text": P?.failedColor,
354
+ "--cs-tag-text": P?.tagTextColor,
355
+ "--cs-count-text": P?.countTextColor,
356
+ "--cs-duration-text": P?.durationTextColor,
357
+ "--cs-icon-secondary": P?.iconSecondaryColor,
358
+ "--cs-icon-completed": P?.iconCompletedColor,
359
+ "--cs-icon-error": P?.iconErrorColor,
360
+ "--cs-code-bg": P?.codeBg,
361
+ "--cs-code-border": P?.codeBorderColor,
362
+ "--cs-code-text": P?.codeTextColor,
363
+ "--cs-border": P?.borderColor
339
364
  });
340
365
  if (e.length === 0) return null;
341
- let U = {
366
+ let V = {
342
367
  copyAriaLabel: E,
343
368
  runningAriaLabel: T,
344
369
  failedAriaLabel: D,
345
- attemptLabel: k
370
+ attemptLabel: O
346
371
  };
347
- if (e.length === 1) return /* @__PURE__ */ C(V, {
372
+ if (e.length === 1) return /* @__PURE__ */ C(q, {
348
373
  stages: e,
349
374
  isStreaming: r,
350
375
  className: l,
351
376
  styles: {
352
- colors: R,
377
+ colors: P,
353
378
  typography: f?.typography
354
379
  },
355
- labels: U
380
+ labels: V
356
381
  });
357
- let W = e.some((e) => e.status === t.Failed), G = e.reduce((e, t) => {
358
- let { durationLabel: n } = O(t.name);
359
- return e + (j(n) ?? 0);
360
- }, 0), K = G > 0 ? A(G) : void 0, q = r ? M(e) : void 0, J;
382
+ let H = e.some((e) => e.status === t.Failed), U = L(e.map((e) => e.name)), W = U > 0 ? F(U) : void 0, G = r ? R(e) : void 0, K;
361
383
  if (r) {
362
- let t = q ? N(e, q) : e.length, n = q ? O(q.name).name : "";
363
- J = /* @__PURE__ */ w("span", {
384
+ let t = G ? z(e, G) : e.length, n = G ? N(G.name).name : "";
385
+ K = /* @__PURE__ */ w("span", {
364
386
  role: "status",
365
387
  "aria-live": "polite",
366
388
  className: "flex min-w-0 items-center gap-2",
@@ -373,22 +395,22 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
373
395
  })
374
396
  }),
375
397
  /* @__PURE__ */ C("span", {
376
- className: i("flex-none whitespace-nowrap", z.fontClassName, H.liveName),
398
+ className: i("flex-none whitespace-nowrap", I.fontClassName, J.liveName),
377
399
  children: S(t, e.length)
378
400
  }),
379
401
  n && /* @__PURE__ */ C("span", {
380
- className: i("min-w-0 max-w-[22rem] truncate", z.fontClassName, H.executedLabel),
402
+ className: i("min-w-0 max-w-[22rem] truncate", I.fontClassName, J.executedLabel),
381
403
  children: /* @__PURE__ */ C(c, { text: n })
382
404
  })
383
405
  ]
384
406
  });
385
- } else if (W) {
407
+ } else if (H) {
386
408
  let n = e.filter((e) => e.status === t.Failed).length;
387
- J = /* @__PURE__ */ w("span", {
409
+ K = /* @__PURE__ */ w("span", {
388
410
  className: "inline-flex items-center gap-1",
389
411
  children: [
390
412
  /* @__PURE__ */ w("span", {
391
- className: i(z.fontClassName, H.executedLabel),
413
+ className: i(I.fontClassName, J.executedLabel),
392
414
  children: [
393
415
  g,
394
416
  " ",
@@ -398,26 +420,26 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
398
420
  ]
399
421
  }),
400
422
  /* @__PURE__ */ C("span", {
401
- className: i(z.fontClassName, H.failedText),
423
+ className: i(I.fontClassName, J.failedText),
402
424
  children: v(n)
403
425
  }),
404
- K && /* @__PURE__ */ C("span", {
405
- className: i(z.fontClassName, H.stepsCount),
406
- children: K
426
+ W && /* @__PURE__ */ C("span", {
427
+ className: i(I.fontClassName, J.stepsCount),
428
+ children: W
407
429
  })
408
430
  ]
409
431
  });
410
- } else J = /* @__PURE__ */ w("span", {
432
+ } else K = /* @__PURE__ */ w("span", {
411
433
  className: "inline-flex items-center gap-1",
412
434
  children: [
413
435
  /* @__PURE__ */ C(p, {
414
436
  size: a.SM,
415
- className: H.doneIcon,
437
+ className: J.doneIcon,
416
438
  "aria-hidden": !0,
417
439
  stroke: o
418
440
  }),
419
441
  /* @__PURE__ */ w("span", {
420
- className: i(z.fontClassName, H.executedLabel),
442
+ className: i(I.fontClassName, J.executedLabel),
421
443
  children: [
422
444
  g,
423
445
  " ",
@@ -426,9 +448,9 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
426
448
  _(e.length)
427
449
  ]
428
450
  }),
429
- K && /* @__PURE__ */ C("span", {
430
- className: i(z.fontClassName, H.stepsCount),
431
- children: K
451
+ W && /* @__PURE__ */ C("span", {
452
+ className: i(I.fontClassName, J.stepsCount),
453
+ children: W
432
454
  })
433
455
  ]
434
456
  });
@@ -436,11 +458,11 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
436
458
  style: B,
437
459
  className: i("flex w-full flex-col gap-1", l),
438
460
  children: [/* @__PURE__ */ C(u, {
439
- className: H.toggleButton,
461
+ className: J.toggleButton,
440
462
  textClassName: "min-w-0",
441
- onClick: () => F((e) => !e),
442
- "aria-expanded": P,
443
- iconAfter: P ? /* @__PURE__ */ C(m, {
463
+ onClick: () => A((e) => !e),
464
+ "aria-expanded": k,
465
+ iconAfter: k ? /* @__PURE__ */ C(m, {
444
466
  size: 12,
445
467
  "aria-hidden": !0,
446
468
  stroke: o
@@ -450,19 +472,19 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
450
472
  "aria-hidden": !0,
451
473
  stroke: o
452
474
  }),
453
- label: J
475
+ label: K
454
476
  }), /* @__PURE__ */ C("div", {
455
- className: i("grid transition-[grid-template-rows] duration-300 ease-in-out", P ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
477
+ className: i("grid transition-[grid-template-rows] duration-300 ease-in-out", k ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
456
478
  children: /* @__PURE__ */ C("div", {
457
479
  className: "overflow-hidden",
458
- children: /* @__PURE__ */ C(V, {
480
+ children: /* @__PURE__ */ C(q, {
459
481
  stages: e,
460
482
  isStreaming: r,
461
483
  styles: {
462
- colors: R,
484
+ colors: P,
463
485
  typography: f?.typography
464
486
  },
465
- labels: U,
487
+ labels: V,
466
488
  className: "pt-1"
467
489
  })
468
490
  })
@@ -470,4 +492,4 @@ var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /:\s*$/, O = (e)
470
492
  });
471
493
  };
472
494
  //#endregion
473
- export { U as CollapsedGroup, V as StagesPanel };
495
+ export { Y as CollapsedGroup, q as StagesPanel };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-conversation-stages",
3
3
  "description": "Panel for displaying agent processing stages during LLM response streaming",
4
- "version": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -19,7 +19,7 @@
19
19
  "peerDependencies": {
20
20
  "react": "^19.0.0",
21
21
  "@tabler/icons-react": "^3.0.0",
22
- "@epam/ai-dial-chat-shared": "1.0.4",
22
+ "@epam/ai-dial-chat-shared": "1.0.6",
23
23
  "@epam/ai-dial-ui-kit": "^0.14.0-dev.15"
24
24
  },
25
25
  "repository": {
@@ -13,5 +13,7 @@ export declare const isIdentifierLike: (name: string) => boolean;
13
13
  export declare const formatTotalDuration: (totalSeconds: number) => string;
14
14
  /** Parses a duration label produced by {@link cleanStageName} (e.g. `'3.99s'`) back into seconds. */
15
15
  export declare const parseDurationSeconds: (durationLabel: string | undefined) => number | undefined;
16
+ /** Returns the elapsed duration represented by stage names, without double-counting overlapping timed stages. */
17
+ export declare const calculateStagesDurationSeconds: (stageNames: string[]) => number;
16
18
  export {};
17
19
  //# sourceMappingURL=stage-name.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stage-name.d.ts","sourceRoot":"","sources":["../../src/utils/stage-name.ts"],"names":[],"mappings":"AAeA,+DAA+D;AAC/D,UAAU,gBAAgB;IACxB,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,0HAA0H;AAC1H,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,gBAkChD,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OACW,CAAC;AAE5D,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM,KAAG,MAO1D,CAAC;AAEF,qGAAqG;AACrG,eAAO,MAAM,oBAAoB,GAC/B,eAAe,MAAM,GAAG,SAAS,KAChC,MAAM,GAAG,SAIX,CAAC"}
1
+ {"version":3,"file":"stage-name.d.ts","sourceRoot":"","sources":["../../src/utils/stage-name.ts"],"names":[],"mappings":"AA6BA,+DAA+D;AAC/D,UAAU,gBAAgB;IACxB,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAkCD,0HAA0H;AAC1H,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,gBAkBhD,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OACW,CAAC;AAE5D,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM,KAAG,MAO1D,CAAC;AAEF,qGAAqG;AACrG,eAAO,MAAM,oBAAoB,GAC/B,eAAe,MAAM,GAAG,SAAS,KAChC,MAAM,GAAG,SAIX,CAAC;AAEF,iHAAiH;AACjH,eAAO,MAAM,8BAA8B,GACzC,YAAY,MAAM,EAAE,KACnB,MA2DF,CAAC"}