@epam/ai-dial-conversation-input 1.3.0-dev.225 → 1.3.0-dev.234

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":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAalE,wIAAwI;AACxI,eAAO,MAAM,KAAK,oGA8xCjB,CAAC"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAalE,wIAAwI;AACxI,eAAO,MAAM,KAAK,oGAkzCjB,CAAC"}
@@ -28,6 +28,12 @@ export interface UseTextInsertionResult {
28
28
  altKey: boolean;
29
29
  preventDefault: () => void;
30
30
  }) => boolean;
31
+ /**
32
+ * Call after placing the caret programmatically (e.g. applying a host's
33
+ * `caretPositionOverride`), so the next insertion goes at that caret even
34
+ * when the textarea was never focused and the caret is at the start.
35
+ */
36
+ markCaretPlaced: () => void;
31
37
  }
32
38
  /**
33
39
  * Inserts host-supplied text at the caret whenever `insertion.revision` changes,
@@ -1 +1 @@
1
- {"version":3,"file":"useTextInsertion.d.ts","sourceRoot":"","sources":["../../src/hooks/useTextInsertion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,wDAAwD;AACxD,UAAU,sBAAsB;IAC9B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,2DAA2D;IAC3D,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CACpD;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,mBAAmB,EAC7B,OAAO,MAAM,EACb,gBAAgB,MAAM,EACtB,eAAc,MAAuB,KACpC,IAiBF,CAAC;AA6BF,yDAAyD;AACzD,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE;QACzB,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,cAAc,EAAE,MAAM,IAAI,CAAC;KAC5B,KAAK,OAAO,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,6BAG9B,sBAAsB,KAAG,sBAmG3B,CAAC"}
1
+ {"version":3,"file":"useTextInsertion.d.ts","sourceRoot":"","sources":["../../src/hooks/useTextInsertion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,wDAAwD;AACxD,UAAU,sBAAsB;IAC9B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,2DAA2D;IAC3D,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CACpD;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,mBAAmB,EAC7B,OAAO,MAAM,EACb,gBAAgB,MAAM,EACtB,eAAc,MAAuB,KACpC,IAiBF,CAAC;AA6BF,yDAAyD;AACzD,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE;QACzB,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,cAAc,EAAE,MAAM,IAAI,CAAC;KAC5B,KAAK,OAAO,CAAC;IACd;;;;OAIG;IACH,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,6BAG9B,sBAAsB,KAAG,sBAoI3B,CAAC"}
package/index.js CHANGED
@@ -420,28 +420,39 @@ var U = {
420
420
  }, qe = (e) => e.key.toLowerCase() === "z" && (e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey, Je = ({ insertion: e, textareaRef: t }) => {
421
421
  let n = e?.revision, r = V(e?.text);
422
422
  r.current = e?.text;
423
- let i = V(n), a = V(null);
423
+ let i = V(n), a = V(null), o = V(!1);
424
424
  return z(() => {
425
+ document.activeElement === t.current && (o.current = !0);
426
+ let e = (e) => {
427
+ e.target === t.current && (o.current = !0);
428
+ };
429
+ return document.addEventListener("focusin", e), () => document.removeEventListener("focusin", e);
430
+ }, [t]), z(() => {
425
431
  if (n === i.current) return;
426
432
  i.current = n;
427
433
  let e = r.current;
428
434
  t.current && e && queueMicrotask(() => {
429
435
  let n = t.current;
430
436
  if (!n) return;
431
- let { value: r, selectionStart: i, selectionEnd: o } = n, s = i ?? r.length, c = o ?? s;
432
- if (n.focus(), a.current = null, typeof document.execCommand == "function" && document.execCommand("insertText", !1, e)) return;
433
- let l = `${r.slice(0, s)}${e}${r.slice(c)}`;
434
- Ke(n, l, s + e.length), a.current = {
435
- insertedValue: l,
437
+ let { value: r, selectionStart: i, selectionEnd: s } = n, c = !o.current && r.length > 0 && i === 0 && s === 0, l = c ? r.length : i ?? r.length, u = c ? l : s ?? l;
438
+ if (n.focus(), c && n.setSelectionRange(l, u), a.current = null, typeof document.execCommand == "function" && document.execCommand("insertText", !1, e)) return;
439
+ let d = `${r.slice(0, l)}${e}${r.slice(u)}`;
440
+ Ke(n, d, l + e.length), a.current = {
441
+ insertedValue: d,
436
442
  previousValue: r,
437
- previousSelectionStart: s,
438
- previousSelectionEnd: c
443
+ previousSelectionStart: l,
444
+ previousSelectionEnd: u
439
445
  };
440
446
  });
441
- }, [n, t]), { handleUndoKeyDown: (e) => {
442
- let n = a.current, r = t.current;
443
- return n == null || r == null || !qe(e) || (a.current = null, r.value !== n.insertedValue) ? !1 : (e.preventDefault(), Ke(r, n.previousValue, n.previousSelectionStart, n.previousSelectionEnd), !0);
444
- } };
447
+ }, [n, t]), {
448
+ handleUndoKeyDown: (e) => {
449
+ let n = a.current, r = t.current;
450
+ return n == null || r == null || !qe(e) || (a.current = null, r.value !== n.insertedValue) ? !1 : (e.preventDefault(), Ke(r, n.previousValue, n.previousSelectionStart, n.previousSelectionEnd), !0);
451
+ },
452
+ markCaretPlaced: () => {
453
+ o.current = !0;
454
+ }
455
+ };
445
456
  }, Ye = /* @__PURE__ */ function(e) {
446
457
  return e.Idle = "idle", e.Recording = "recording", e.Processing = "processing", e.Error = "error", e;
447
458
  }({}), Xe = /* @__PURE__ */ function(e) {
@@ -1519,7 +1530,7 @@ function Bt({ cachedBounds: e, containerScrollOffset: t, containerSize: n, itemC
1519
1530
  stopIndexOverscan: l
1520
1531
  };
1521
1532
  }
1522
- function Q({ itemCount: e, itemProps: t, itemSize: n }) {
1533
+ function Vt({ itemCount: e, itemProps: t, itemSize: n }) {
1523
1534
  let r = /* @__PURE__ */ new Map();
1524
1535
  return {
1525
1536
  get(i) {
@@ -1554,8 +1565,8 @@ function Q({ itemCount: e, itemProps: t, itemSize: n }) {
1554
1565
  }
1555
1566
  };
1556
1567
  }
1557
- function Vt({ itemCount: e, itemProps: t, itemSize: n }) {
1558
- return B(() => Q({
1568
+ function Q({ itemCount: e, itemProps: t, itemSize: n }) {
1569
+ return B(() => Vt({
1559
1570
  itemCount: e,
1560
1571
  itemProps: t,
1561
1572
  itemSize: n
@@ -1602,7 +1613,7 @@ function Ut({ containerElement: e, containerStyle: t, defaultContainerSize: n =
1602
1613
  c,
1603
1614
  d
1604
1615
  ]);
1605
- let h = Vt({
1616
+ let h = Q({
1606
1617
  itemCount: a,
1607
1618
  itemProps: o,
1608
1619
  itemSize: m
@@ -2082,71 +2093,74 @@ var Yt = {
2082
2093
  messageRevision: t
2083
2094
  });
2084
2095
  z(() => {
2096
+ let e = Z.current;
2097
+ e != null && e.value.length !== 0 && document.activeElement === e && e.setSelectionRange(e.value.length, e.value.length);
2098
+ }, [Z]), z(() => {
2085
2099
  n !== void 0 && Z.current?.focus();
2086
2100
  }, [n, Z]), Oe(kt, () => ({ getCaretPosition: () => Z.current?.selectionStart ?? Y.length }), [Y, Z]);
2087
- let { handleUndoKeyDown: Rt } = Je({
2101
+ let { handleUndoKeyDown: Rt, markCaretPlaced: zt } = Je({
2088
2102
  insertion: r,
2089
2103
  textareaRef: Z
2090
- }), { isMenuOpen: zt, query: Bt, activeWordStart: Q, dismiss: Vt, closeOnOutsidePress: Ht, handleCaretMove: Ut, handleValueChange: Wt, listboxId: Gt, overlayRef: Kt, activeOptionId: qt, moveActiveOption: Jt, getActiveOption: Yt } = Le({
2104
+ }), { isMenuOpen: Bt, query: Vt, activeWordStart: Q, dismiss: Ht, closeOnOutsidePress: Ut, handleCaretMove: Wt, handleValueChange: Gt, listboxId: Kt, overlayRef: qt, activeOptionId: Jt, moveActiveOption: Yt, getActiveOption: Xt } = Le({
2091
2105
  config: K,
2092
2106
  message: Y
2093
- }), Xt = V(Ut);
2094
- Xt.current = Ut;
2095
- let Zt = () => {
2096
- Ut(Z.current?.selectionStart ?? Y.length);
2097
- }, Qt = V(!1), $t = () => {
2098
- Qt.current ? Qt.current = !1 : requestAnimationFrame(() => {
2107
+ }), Zt = V(Wt);
2108
+ Zt.current = Wt;
2109
+ let Qt = () => {
2110
+ Wt(Z.current?.selectionStart ?? Y.length);
2111
+ }, $t = V(!1), tn = () => {
2112
+ $t.current ? $t.current = !1 : requestAnimationFrame(() => {
2099
2113
  let e = Z.current;
2100
- Xt.current(e?.selectionStart ?? e?.value.length ?? 0);
2114
+ Zt.current(e?.selectionStart ?? e?.value.length ?? 0);
2101
2115
  });
2102
- }, tn = (e) => {
2103
- (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End" || e.key === "PageUp" || e.key === "PageDown") && Ut(e.currentTarget.selectionStart ?? Y.length);
2104
- }, nn = K?.emptyQueryHint != null, rn = K != null && Q != null ? Q + K.triggerPrefix.length : null, an = rn != null && Y.slice(rn).split("\n", 1)[0] !== "", on = nn && zt && Bt === "" && rn != null && !an, sn = K != null && zt ? Q ?? 0 : null, cn = V(null), ln = V(null), [un, dn] = H(null), fn = R(() => {
2105
- let e = cn.current, t = ln.current;
2116
+ }, nn = (e) => {
2117
+ (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End" || e.key === "PageUp" || e.key === "PageDown") && Wt(e.currentTarget.selectionStart ?? Y.length);
2118
+ }, rn = K?.emptyQueryHint != null, an = K != null && Q != null ? Q + K.triggerPrefix.length : null, on = an != null && Y.slice(an).split("\n", 1)[0] !== "", sn = rn && Bt && Vt === "" && an != null && !on, cn = K != null && Bt ? Q ?? 0 : null, ln = V(null), un = V(null), [dn, fn] = H(null), pn = R(() => {
2119
+ let e = ln.current, t = un.current;
2106
2120
  if (e == null || t == null) {
2107
- dn(null);
2121
+ fn(null);
2108
2122
  return;
2109
2123
  }
2110
2124
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
2111
- dn({
2125
+ fn({
2112
2126
  left: n.left - r.left,
2113
2127
  top: n.top - r.top
2114
2128
  });
2115
2129
  }, []);
2116
2130
  z(() => {
2117
- if (sn == null) return;
2131
+ if (cn == null) return;
2118
2132
  let e = Z.current;
2119
2133
  if (e == null || typeof ResizeObserver > "u") return;
2120
- let t = new ResizeObserver(fn);
2134
+ let t = new ResizeObserver(pn);
2121
2135
  return t.observe(e), () => t.disconnect();
2122
2136
  }, [
2123
- sn,
2137
+ cn,
2124
2138
  Z,
2125
- fn
2139
+ pn
2126
2140
  ]);
2127
- let pn = R((e) => {
2128
- if (K == null || (Vt(), !e?.consumeQuery) || (e.returnFocus !== !1 && Z.current?.focus(), Q == null)) return;
2129
- let t = `${K.triggerPrefix}${Bt}`, n = Q + t.length;
2141
+ let mn = R((e) => {
2142
+ if (K == null || (Ht(), !e?.consumeQuery) || (e.returnFocus !== !1 && Z.current?.focus(), Q == null)) return;
2143
+ let t = `${K.triggerPrefix}${Vt}`, n = Q + t.length;
2130
2144
  if (Y.slice(Q, n) !== t) return;
2131
2145
  let r = Y.slice(0, Q) + Y.slice(n);
2132
2146
  X(r), Nt.notifyChange(), u?.(r);
2133
2147
  }, [
2134
2148
  K,
2149
+ Ht,
2135
2150
  Vt,
2136
- Bt,
2137
2151
  Y,
2138
2152
  Q,
2139
2153
  X,
2140
2154
  Nt,
2141
2155
  u,
2142
2156
  Z
2143
- ]), mn = V(void 0);
2157
+ ]), hn = V(void 0);
2144
2158
  z(() => {
2145
- dt != null && mn.current !== t && (mn.current = t, Z.current?.setSelectionRange(dt, dt), Ut(dt));
2159
+ dt != null && hn.current !== t && (hn.current = t, Z.current?.setSelectionRange(dt, dt), zt(), Wt(dt));
2146
2160
  }, [Y]);
2147
- let hn = V(Y);
2148
- hn.current = Y;
2149
- let { attachments: gn, buildAttachments: _n, addAttachments: vn, resetAttachments: yn, handleRemove: bn, handleRetry: xn, handleExpand: Sn, hasBlockedAttachments: Cn } = je({
2161
+ let gn = V(Y);
2162
+ gn.current = Y;
2163
+ let { attachments: _n, buildAttachments: vn, addAttachments: yn, resetAttachments: bn, handleRemove: xn, handleRetry: Sn, handleExpand: Cn, hasBlockedAttachments: wn } = je({
2150
2164
  initialAttachments: Ce,
2151
2165
  onUploadAttachment: a,
2152
2166
  onAttachmentsChange: p,
@@ -2157,99 +2171,99 @@ var Yt = {
2157
2171
  pendingAttachments: me,
2158
2172
  onPendingAttachmentsConsumed: he,
2159
2173
  onExpandPastedText: R((e) => {
2160
- let t = hn.current, n = t ? `${t}\n${e}` : e;
2161
- hn.current = n, X(n), u?.(n);
2174
+ let t = gn.current, n = t ? `${t}\n${e}` : e;
2175
+ gn.current = n, X(n), u?.(n);
2162
2176
  }, [X, u]),
2163
2177
  maximumAttachmentsAmount: bt,
2164
2178
  baseAttachmentsAmount: qe.length,
2165
2179
  onAttachmentsLimitExceeded: wt
2166
- }), wn = R((e) => {
2167
- vn(_n([e]));
2168
- }, [vn, _n]), Tn = V(!1), [En, Dn] = H({
2180
+ }), Tn = R((e) => {
2181
+ yn(vn([e]));
2182
+ }, [yn, vn]), En = V(!1), [Dn, On] = H({
2169
2183
  text: "",
2170
2184
  revision: 0
2171
- }), { state: On, analyserNodeRef: kn, errorMessage: An, startRecording: jn, stopRecording: Mn, discardRecording: Nn } = tt({
2172
- onAttachAudio: wn,
2185
+ }), { state: kn, analyserNodeRef: An, errorMessage: jn, startRecording: Mn, stopRecording: Nn, discardRecording: Pn } = tt({
2186
+ onAttachAudio: Tn,
2173
2187
  onTranscribeAudio: Re,
2174
2188
  onTranscript: R((e) => {
2175
2189
  let t = e.trim();
2176
2190
  if (t) {
2177
- let e = hn.current, n = `${e}${e && !/\s$/.test(e) ? " " : ""}${t}`;
2178
- hn.current = n, X(n), Dn((e) => ({
2191
+ let e = gn.current, n = `${e}${e && !/\s$/.test(e) ? " " : ""}${t}`;
2192
+ gn.current = n, X(n), On((e) => ({
2179
2193
  text: t,
2180
2194
  revision: e.revision + 1
2181
2195
  })), Nt.notifyChange(), u?.(n);
2182
2196
  }
2183
- Tn.current = !0;
2197
+ En.current = !0;
2184
2198
  }, [
2185
2199
  X,
2186
2200
  Nt,
2187
2201
  u
2188
2202
  ]),
2189
2203
  errorLabel: He
2190
- }), $ = On === Ye.Recording || On === Ye.Processing;
2204
+ }), $ = kn === Ye.Recording || kn === Ye.Processing;
2191
2205
  z(() => {
2192
- if (On === Ye.Error || On === Ye.Idle && Tn.current) {
2193
- Tn.current = !1;
2206
+ if (kn === Ye.Error || kn === Ye.Idle && En.current) {
2207
+ En.current = !1;
2194
2208
  let e = Z.current;
2195
2209
  if (e != null) {
2196
- Qt.current = document.activeElement !== e, e.focus();
2210
+ $t.current = document.activeElement !== e, e.focus();
2197
2211
  let t = e.value.length;
2198
2212
  e.setSelectionRange(t, t);
2199
2213
  }
2200
2214
  }
2201
- }, [On, Z]);
2202
- let Pn = V(null), Fn = V(null), In = Tt && Et, { handlePaste: Ln } = ue(vn, In ? ge : Infinity), Rn = R((e) => {
2203
- if (!In) {
2215
+ }, [kn, Z]);
2216
+ let Fn = V(null), In = V(null), Ln = Tt && Et, { handlePaste: Rn } = ue(yn, Ln ? ge : Infinity), zn = R((e) => {
2217
+ if (!Ln) {
2204
2218
  let t = e.clipboardData.getData("text/plain");
2205
2219
  t.length >= L && Ot?.(t.length, L);
2206
2220
  }
2207
- if (Ln(e), e.defaultPrevented) return;
2221
+ if (Rn(e), e.defaultPrevented) return;
2208
2222
  let t = e.clipboardData.getData("text/plain").replace(/\r\n?/g, "\n");
2209
2223
  t !== "" && K?.onTextPaste?.(t);
2210
2224
  }, [
2211
- In,
2225
+ Ln,
2212
2226
  L,
2213
2227
  Ot,
2214
- Ln,
2228
+ Rn,
2215
2229
  K
2216
- ]), zn = Y.trim().length > 0 || gn.length > 0, Bn = zn && !Cn && !Ne && !$, [Vn, Hn] = H([]), Un = ($e ?? []).map((e) => e.id).join("|");
2230
+ ]), Bn = Y.trim().length > 0 || _n.length > 0, Vn = Bn && !wn && !Ne && !$, [Hn, Un] = H([]), Wn = ($e ?? []).map((e) => e.id).join("|");
2217
2231
  z(() => {
2218
- Hn([]);
2219
- }, [Un]);
2220
- let Wn = B(() => {
2232
+ Un([]);
2233
+ }, [Wn]);
2234
+ let Gn = B(() => {
2221
2235
  let e = $e ?? [];
2222
- return it ? e.filter((e) => e.isSelected || !Vn.includes(e.id)) : e;
2236
+ return it ? e.filter((e) => e.isSelected || !Hn.includes(e.id)) : e;
2223
2237
  }, [
2224
2238
  $e,
2225
- Vn,
2239
+ Hn,
2226
2240
  it
2227
- ]), Gn = R((e) => {
2228
- Hn((t) => t.includes(e) ? t : [...t, e]), $e?.find((t) => t.id === e)?.isSelected && et?.(e);
2229
- }, [$e, et]), Kn = ye === void 0 || be != null, qn = Pe && !s, Jn = async () => {
2241
+ ]), Kn = R((e) => {
2242
+ Un((t) => t.includes(e) ? t : [...t, e]), $e?.find((t) => t.id === e)?.isSelected && et?.(e);
2243
+ }, [$e, et]), qn = ye === void 0 || be != null, Jn = Pe && !s, Yn = async () => {
2230
2244
  if (Ne || $) return;
2231
2245
  if (Y.length >= L) {
2232
2246
  Ot?.(Y.length, L);
2233
2247
  return;
2234
2248
  }
2235
- let e = Y, t = gn;
2249
+ let e = Y, t = _n;
2236
2250
  X(""), Nt.reset();
2237
2251
  try {
2238
2252
  await i?.(e, t), t.forEach((e) => {
2239
2253
  e.previewUrl && URL.revokeObjectURL(e.previewUrl), e.playUrl && URL.revokeObjectURL(e.playUrl);
2240
- }), yn([]);
2254
+ }), bn([]);
2241
2255
  } catch {
2242
- X(e), yn(t);
2256
+ X(e), bn(t);
2243
2257
  }
2244
- }, Yn = (e) => Ue === nt.MetaEnter ? (e.metaKey || e.ctrlKey) && !e.shiftKey : !e.shiftKey && !e.metaKey && !e.ctrlKey, Xn = (e) => {
2245
- if (!zt || e.nativeEvent.isComposing) return !1;
2246
- if (e.key === "Escape") return e.preventDefault(), e.stopPropagation(), Vt(), !0;
2247
- if (e.key === "ArrowDown" || e.key === "ArrowUp") return e.preventDefault(), Jt(e.key === "ArrowDown" ? Ie.Next : Ie.Previous), !0;
2258
+ }, Xn = (e) => Ue === nt.MetaEnter ? (e.metaKey || e.ctrlKey) && !e.shiftKey : !e.shiftKey && !e.metaKey && !e.ctrlKey, Zn = (e) => {
2259
+ if (!Bt || e.nativeEvent.isComposing) return !1;
2260
+ if (e.key === "Escape") return e.preventDefault(), e.stopPropagation(), Ht(), !0;
2261
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") return e.preventDefault(), Yt(e.key === "ArrowDown" ? Ie.Next : Ie.Previous), !0;
2248
2262
  if (e.key !== "Enter" || e.shiftKey) return !1;
2249
- let t = Yt();
2250
- return t == null ? Yn(e) ? (e.preventDefault(), !0) : !1 : (e.preventDefault(), t.click(), !0);
2251
- }, Zn = (e) => {
2252
- if (!$ && !Rt(e) && !Xn(e)) {
2263
+ let t = Xt();
2264
+ return t == null ? Xn(e) ? (e.preventDefault(), !0) : !1 : (e.preventDefault(), t.click(), !0);
2265
+ }, Qn = (e) => {
2266
+ if (!$ && !Rt(e) && !Zn(e)) {
2253
2267
  if (!e.nativeEvent.isComposing && !G && !s) {
2254
2268
  if (e.key === "ArrowUp" || e.key === "ArrowDown") {
2255
2269
  let t = e.currentTarget.selectionStart ?? 0, n = Nt.navigate(e.key === "ArrowUp" ? "up" : "down", Y, t);
@@ -2268,24 +2282,24 @@ var Yt = {
2268
2282
  }
2269
2283
  }
2270
2284
  }
2271
- e.key === "Enter" && Yn(e) && (e.preventDefault(), !s && Bn && Kn && !G && Jn());
2285
+ e.key === "Enter" && Xn(e) && (e.preventDefault(), !s && Vn && qn && !G && Yn());
2272
2286
  }
2273
- }, Qn = (e) => {
2287
+ }, $n = (e) => {
2274
2288
  let t = Array.from(e.target.files ?? []);
2275
2289
  if (t.length === 0) return;
2276
- let n = _n(t);
2277
- e.target.value = "", vn(n);
2278
- }, $n = B(() => {
2290
+ let n = vn(t);
2291
+ e.target.value = "", yn(n);
2292
+ }, er = B(() => {
2279
2293
  let e = [];
2280
- return sn != null && e.push({
2281
- offset: sn,
2294
+ return cn != null && e.push({
2295
+ offset: cn,
2282
2296
  node: /* @__PURE__ */ P("span", {
2283
- ref: cn,
2297
+ ref: ln,
2284
2298
  "aria-hidden": !0,
2285
2299
  className: "inline-block h-lh w-0 align-text-top"
2286
2300
  }, "caret-marker")
2287
- }), on && K != null && rn != null && e.push({
2288
- offset: rn,
2301
+ }), sn && K != null && an != null && e.push({
2302
+ offset: an,
2289
2303
  node: /* @__PURE__ */ P("span", {
2290
2304
  className: J.commandHint,
2291
2305
  "aria-hidden": !0,
@@ -2294,61 +2308,61 @@ var Yt = {
2294
2308
  }, "command-hint")
2295
2309
  }), e;
2296
2310
  }, [
2311
+ cn,
2297
2312
  sn,
2298
- on,
2299
2313
  K,
2300
- rn
2301
- ]), er = Ft || $n.length > 0, { mirrorRef: tr, selectionRects: nr, updateSelectionRects: rr, syncMirrorToTextarea: ir } = We({
2314
+ an
2315
+ ]), tr = Ft || er.length > 0, { mirrorRef: nr, selectionRects: rr, updateSelectionRects: ir, syncMirrorToTextarea: ar } = We({
2302
2316
  textareaRef: Z,
2303
2317
  message: Y,
2304
- isMirrorActive: er
2318
+ isMirrorActive: tr
2305
2319
  });
2306
2320
  ke(() => {
2307
- fn();
2321
+ pn();
2308
2322
  }, [
2309
- fn,
2310
- sn,
2323
+ pn,
2324
+ cn,
2311
2325
  Y
2312
2326
  ]);
2313
- let ar = /* @__PURE__ */ P("textarea", {
2314
- className: l(J.textarea, er && J.textareaMentionMode, se?.fontClassName || "dial-body-paragraph-text", "relative z-0 [field-sizing:content] max-h-[272px] w-full resize-none overflow-y-auto border-0 bg-transparent ps-1 pe-1 outline-hidden", "disabled:cursor-not-allowed"),
2327
+ let or = /* @__PURE__ */ P("textarea", {
2328
+ className: l(J.textarea, tr && J.textareaMentionMode, se?.fontClassName || "dial-body-paragraph-text", "relative z-0 [field-sizing:content] max-h-[272px] w-full resize-none overflow-y-auto border-0 bg-transparent ps-1 pe-1 outline-hidden", "disabled:cursor-not-allowed"),
2315
2329
  ref: Z,
2316
2330
  autoFocus: ft,
2317
2331
  value: Y,
2318
2332
  onChange: (e) => {
2319
2333
  X(e.target.value), Nt.notifyChange();
2320
2334
  let t = e.nativeEvent instanceof InputEvent ? e.nativeEvent : void 0;
2321
- Wt(e.target.value, e.target.selectionStart ?? e.target.value.length, t?.isComposing ?? !1), u?.(e.target.value);
2335
+ Gt(e.target.value, e.target.selectionStart ?? e.target.value.length, t?.isComposing ?? !1), u?.(e.target.value);
2322
2336
  },
2323
- onSelect: rr,
2337
+ onSelect: ir,
2324
2338
  onScroll: () => {
2325
- ir(), sn != null && fn();
2339
+ ar(), cn != null && pn();
2326
2340
  },
2327
- onFocus: $t,
2328
- onClick: Zt,
2329
- onKeyDown: Zn,
2330
- onKeyUp: tn,
2331
- onPaste: Rn,
2341
+ onFocus: tn,
2342
+ onClick: Qt,
2343
+ onKeyDown: Qn,
2344
+ onKeyUp: nn,
2345
+ onPaste: zn,
2332
2346
  placeholder: m,
2333
2347
  "aria-label": h,
2334
2348
  "aria-autocomplete": K == null ? void 0 : "list",
2335
- "aria-controls": zt ? Gt : void 0,
2336
- "aria-activedescendant": qt ?? void 0,
2349
+ "aria-controls": Bt ? Kt : void 0,
2350
+ "aria-activedescendant": Jt ?? void 0,
2337
2351
  "aria-hidden": Ft ? !0 : void 0,
2338
2352
  disabled: G,
2339
2353
  readOnly: $,
2340
2354
  rows: 1
2341
- }), or = /* @__PURE__ */ F(N, { children: [ar, K != null && /* @__PURE__ */ P("div", {
2355
+ }), sr = /* @__PURE__ */ F(N, { children: [or, K != null && /* @__PURE__ */ P("div", {
2342
2356
  "aria-hidden": !0,
2343
2357
  className: l("pointer-events-none absolute", se?.fontClassName || "dial-body-paragraph-text"),
2344
2358
  style: {
2345
- left: un?.left ?? 0,
2346
- top: un?.top ?? 0
2359
+ left: dn?.left ?? 0,
2360
+ top: dn?.top ?? 0
2347
2361
  },
2348
2362
  children: /* @__PURE__ */ P(y, {
2349
- open: zt,
2363
+ open: Bt,
2350
2364
  onOpenChange: (e) => {
2351
- e || Ht();
2365
+ e || Ut();
2352
2366
  },
2353
2367
  placement: "top-start",
2354
2368
  trigger: [],
@@ -2358,15 +2372,15 @@ var Yt = {
2358
2372
  renderOverlay: () => {
2359
2373
  let e = K.menuLabel != null;
2360
2374
  return /* @__PURE__ */ P("div", {
2361
- ref: Kt,
2375
+ ref: qt,
2362
2376
  role: e ? "group" : void 0,
2363
2377
  "aria-label": K.menuLabel,
2364
2378
  children: K.renderMenu({
2365
- query: Bt,
2379
+ query: Vt,
2366
2380
  caretPosition: Q ?? 0,
2367
- close: pn,
2368
- listboxId: Gt,
2369
- activeOptionId: qt
2381
+ close: mn,
2382
+ listboxId: Kt,
2383
+ activeOptionId: Jt
2370
2384
  })
2371
2385
  });
2372
2386
  },
@@ -2375,13 +2389,13 @@ var Yt = {
2375
2389
  className: "inline-block h-lh w-0"
2376
2390
  })
2377
2391
  })
2378
- })] }), sr = /* @__PURE__ */ F("div", {
2379
- ref: ln,
2392
+ })] }), cr = /* @__PURE__ */ F("div", {
2393
+ ref: un,
2380
2394
  className: "relative -ms-1 -me-1 w-[calc(100%+8px)]",
2381
- children: [er && /* @__PURE__ */ F("div", {
2382
- ref: tr,
2395
+ children: [tr && /* @__PURE__ */ F("div", {
2396
+ ref: nr,
2383
2397
  className: l(J.textarea, se?.fontClassName || "dial-body-paragraph-text", "pointer-events-none absolute inset-0 z-10 max-h-[272px] w-full overflow-hidden ps-1 pe-1 [overflow-wrap:anywhere] whitespace-pre-wrap"),
2384
- children: [Ve(Y, Pt, $n, J.mentionHighlight, J.mentionHighlightUnsupported), nr.map((e, t) => /* @__PURE__ */ P("div", {
2398
+ children: [Ve(Y, Pt, er, J.mentionHighlight, J.mentionHighlightUnsupported), rr.map((e, t) => /* @__PURE__ */ P("div", {
2385
2399
  "aria-hidden": !0,
2386
2400
  className: "pointer-events-none absolute rounded-sm bg-control-accent-alpha-active",
2387
2401
  style: {
@@ -2391,9 +2405,9 @@ var Yt = {
2391
2405
  height: e.height
2392
2406
  }
2393
2407
  }, `selection-${t}`))]
2394
- }), or]
2395
- }), cr = we ? void 0 : /* @__PURE__ */ P(mt, {
2396
- onAttachClick: Te ? void 0 : () => Pn.current?.click(),
2408
+ }), sr]
2409
+ }), lr = we ? void 0 : /* @__PURE__ */ P(mt, {
2410
+ onAttachClick: Te ? void 0 : () => Fn.current?.click(),
2397
2411
  attachLabel: g,
2398
2412
  addMenuTitle: C,
2399
2413
  menuTitle: w,
@@ -2402,7 +2416,7 @@ var Yt = {
2402
2416
  isDisabled: G || $,
2403
2417
  chatSettings: Qe,
2404
2418
  extraMenuItems: Lt,
2405
- onRecordVoice: Fe && Tt && !s && !$ ? () => jn(Xe.Attachment) : void 0,
2419
+ onRecordVoice: Fe && Tt && !s && !$ ? () => Mn(Xe.Attachment) : void 0,
2406
2420
  recordVoiceLabel: ie,
2407
2421
  toolsMenuItems: it ? $e : void 0,
2408
2422
  onToolToggle: et,
@@ -2410,15 +2424,15 @@ var Yt = {
2410
2424
  toolsBackLabel: ot,
2411
2425
  menuOverlays: ct,
2412
2426
  getCaretPosition: () => Z.current?.selectionStart ?? Y.length
2413
- }), lr = De === rt.Inline && (!At || Ae), ur = cr && /* @__PURE__ */ P("div", {
2427
+ }), ur = De === rt.Inline && (!At || Ae), dr = lr && /* @__PURE__ */ P("div", {
2414
2428
  className: l("flex", U.addCluster),
2415
- children: cr
2416
- }), dr = Wn.length > 0 && et != null && /* @__PURE__ */ P("div", {
2429
+ children: lr
2430
+ }), fr = Gn.length > 0 && et != null && /* @__PURE__ */ P("div", {
2417
2431
  className: l("min-w-0 flex-1", U.toolsChips),
2418
2432
  children: /* @__PURE__ */ P(gt, {
2419
- items: Wn,
2433
+ items: Gn,
2420
2434
  onToolToggle: et,
2421
- onToolDismiss: Gn,
2435
+ onToolDismiss: Kn,
2422
2436
  canRemove: it,
2423
2437
  removeLabel: st?.removeLabel,
2424
2438
  stateOnLabel: st?.stateOnLabel,
@@ -2426,17 +2440,17 @@ var Yt = {
2426
2440
  })
2427
2441
  });
2428
2442
  return /* @__PURE__ */ F("div", {
2429
- ref: Fn,
2443
+ ref: In,
2430
2444
  style: It,
2431
2445
  className: l(J.wrapper, G && J.wrapperDisabled, G && "cursor-not-allowed", "flex w-full max-w-[748px] flex-col justify-center gap-3 rounded-xl border", "p-4 focus-within:outline focus-within:-outline-offset-1 active:outline active:-outline-offset-1", de, U.wrapper),
2432
2446
  children: [
2433
- (qe.length > 0 || gn.length > 0) && /* @__PURE__ */ P(I, {
2434
- attachments: [...qe, ...gn],
2447
+ (qe.length > 0 || _n.length > 0) && /* @__PURE__ */ P(I, {
2448
+ attachments: [...qe, ..._n],
2435
2449
  onRemove: (e) => {
2436
- qe.some((t) => t.id === e) ? Ze?.(e) : bn(e);
2450
+ qe.some((t) => t.id === e) ? Ze?.(e) : xn(e);
2437
2451
  },
2438
- onRetry: xn,
2439
- onExpand: Sn,
2452
+ onRetry: Sn,
2453
+ onExpand: Cn,
2440
2454
  labels: {
2441
2455
  removeLabel: E,
2442
2456
  retryLabel: D,
@@ -2446,59 +2460,59 @@ var Yt = {
2446
2460
  },
2447
2461
  styles: {
2448
2462
  ...ce,
2449
- className: l(gn.length > 6 && "-me-4", ce?.className)
2463
+ className: l(_n.length > 6 && "-me-4", ce?.className)
2450
2464
  },
2451
2465
  onAttachmentClick: vt == null ? void 0 : (e) => {
2452
- let t = [...qe, ...gn].find((t) => t.id === e);
2466
+ let t = [...qe, ..._n].find((t) => t.id === e);
2453
2467
  t != null && vt(t);
2454
2468
  }
2455
2469
  }),
2456
2470
  !we && /* @__PURE__ */ P("input", {
2457
- ref: Pn,
2471
+ ref: Fn,
2458
2472
  type: "file",
2459
2473
  multiple: !0,
2460
2474
  accept: b,
2461
2475
  className: "sr-only",
2462
2476
  "aria-hidden": !0,
2463
2477
  tabIndex: -1,
2464
- onChange: Qn
2478
+ onChange: $n
2465
2479
  }),
2466
- An && /* @__PURE__ */ P("div", {
2480
+ jn && /* @__PURE__ */ P("div", {
2467
2481
  role: "alert",
2468
2482
  className: "min-w-0 px-1 wrap-break-word",
2469
- children: /* @__PURE__ */ P(x, { text: An })
2483
+ children: /* @__PURE__ */ P(x, { text: jn })
2470
2484
  }),
2471
2485
  $ && /* @__PURE__ */ P(xt, {
2472
2486
  embedded: !0,
2473
- state: On,
2474
- analyserNodeRef: kn,
2475
- onStop: Mn,
2476
- onDiscard: Nn,
2477
- attachButton: cr,
2487
+ state: kn,
2488
+ analyserNodeRef: An,
2489
+ onStop: Nn,
2490
+ onDiscard: Pn,
2491
+ attachButton: lr,
2478
2492
  stopLabel: ae,
2479
2493
  discardLabel: oe,
2480
2494
  processingLabel: ze
2481
2495
  }),
2482
- !$ && Ee && sr,
2483
- !$ && !Ee && lr && dr && /* @__PURE__ */ P("div", {
2496
+ !$ && Ee && cr,
2497
+ !$ && !Ee && ur && fr && /* @__PURE__ */ P("div", {
2484
2498
  className: "flex",
2485
- children: dr
2499
+ children: fr
2486
2500
  }),
2487
2501
  !$ && !Ee && /* @__PURE__ */ F("div", {
2488
- className: l("flex items-center gap-2", lr ? "flex-nowrap" : "flex-wrap", U.actionRow),
2502
+ className: l("flex items-center gap-2", ur ? "flex-nowrap" : "flex-wrap", U.actionRow),
2489
2503
  children: [
2490
- lr && ur,
2504
+ ur && dr,
2491
2505
  /* @__PURE__ */ P("div", {
2492
- className: l("flex min-w-0 items-center self-stretch", lr ? "flex-1" : "w-full", U.textareaWrap),
2493
- children: sr
2506
+ className: l("flex min-w-0 items-center self-stretch", ur ? "flex-1" : "w-full", U.textareaWrap),
2507
+ children: cr
2494
2508
  }),
2495
- !lr && ur,
2496
- !lr && dr,
2509
+ !ur && dr,
2510
+ !ur && fr,
2497
2511
  /* @__PURE__ */ P("div", {
2498
2512
  className: l("ms-auto flex flex-shrink-0 items-center gap-2", U.footerActions),
2499
2513
  children: W ? W({
2500
- canSend: Bn,
2501
- onSend: Jn
2514
+ canSend: Vn,
2515
+ onSend: Yn
2502
2516
  }) : /* @__PURE__ */ F(N, { children: [
2503
2517
  Dt,
2504
2518
  /* @__PURE__ */ P(en, {
@@ -2516,7 +2530,7 @@ var Yt = {
2516
2530
  onPickerToggle: () => Mt((e) => !e),
2517
2531
  onPickerOpenChange: Mt
2518
2532
  }),
2519
- qn && /* @__PURE__ */ P(S, {
2533
+ Jn && /* @__PURE__ */ P(S, {
2520
2534
  icon: /* @__PURE__ */ P(ve, {
2521
2535
  size: _.LG,
2522
2536
  stroke: v,
@@ -2525,17 +2539,17 @@ var Yt = {
2525
2539
  "aria-label": re,
2526
2540
  tooltipProps: { tooltip: re },
2527
2541
  className: "size-[40px] shrink-0 mobile:min-h-11 mobile:min-w-11",
2528
- onClick: () => jn(Xe.Dictation),
2542
+ onClick: () => Mn(Xe.Dictation),
2529
2543
  disabled: G || s
2530
2544
  }),
2531
2545
  s && o ? /* @__PURE__ */ P(Ct, {
2532
2546
  onStop: o,
2533
2547
  ariaLabel: ne
2534
2548
  }) : !s && /* @__PURE__ */ P(St, {
2535
- onSend: Jn,
2536
- isDisabled: !Kn || !Bn,
2549
+ onSend: Yn,
2550
+ isDisabled: !qn || !Vn,
2537
2551
  ariaLabel: te,
2538
- sendTooltip: zn ? A : j ?? A
2552
+ sendTooltip: Bn ? A : j ?? A
2539
2553
  })
2540
2554
  ] })
2541
2555
  })
@@ -2546,7 +2560,7 @@ var Yt = {
2546
2560
  role: "status",
2547
2561
  "aria-live": "polite",
2548
2562
  "aria-atomic": "true",
2549
- children: /* @__PURE__ */ P("span", { children: En.text }, En.revision)
2563
+ children: /* @__PURE__ */ P("span", { children: Dn.text }, Dn.revision)
2550
2564
  })
2551
2565
  ]
2552
2566
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-conversation-input",
3
3
  "description": "Conversation message input with model selection, attachments, voice input, and edit mode",
4
- "version": "1.3.0-dev.225",
4
+ "version": "1.3.0-dev.234",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -19,10 +19,10 @@
19
19
  "dependencies": {
20
20
  "react-window": "^2.2.7",
21
21
  "@tabler/icons-react": "^3.44.0",
22
- "@epam/ai-dial-attachment-input": "1.3.0-dev.225"
22
+ "@epam/ai-dial-attachment-input": "1.3.0-dev.234"
23
23
  },
24
24
  "peerDependencies": {
25
- "@epam/ai-dial-chat-shared": "1.3.0-dev.225",
25
+ "@epam/ai-dial-chat-shared": "1.3.0-dev.234",
26
26
  "react": "^19.2.8",
27
27
  "@epam/ai-dial-ui-kit": "^0.16.0-dev.45"
28
28
  },