@automattic/agenttic-ui 0.1.72 → 0.1.74

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 (57) hide show
  1. package/dist/DiffCard-CVeqjQhl.js +242 -0
  2. package/dist/DiffCard.css +1 -0
  3. package/dist/components/AgentUIContainer.d.ts +2 -2
  4. package/dist/components/AgentUIContainer.d.ts.map +1 -1
  5. package/dist/components/DragOverlay.d.ts +2 -0
  6. package/dist/components/DragOverlay.d.ts.map +1 -0
  7. package/dist/components/EmbeddedAgentUI.d.ts.map +1 -1
  8. package/dist/components/ResizeHandles.d.ts +7 -0
  9. package/dist/components/ResizeHandles.d.ts.map +1 -0
  10. package/dist/components/chat/Chat.d.ts +2 -1
  11. package/dist/components/chat/Chat.d.ts.map +1 -1
  12. package/dist/components/chat/Messages.d.ts.map +1 -1
  13. package/dist/components/chat/SuggestionDropdown.d.ts +2 -0
  14. package/dist/components/chat/SuggestionDropdown.d.ts.map +1 -1
  15. package/dist/components/chat/Suggestions.d.ts.map +1 -1
  16. package/dist/components/chat/Suggestions.test.d.ts +2 -0
  17. package/dist/components/chat/Suggestions.test.d.ts.map +1 -0
  18. package/dist/components/diff/DiffCard.d.ts +40 -0
  19. package/dist/components/diff/DiffCard.d.ts.map +1 -0
  20. package/dist/components/diff/DiffCard.test.d.ts +2 -0
  21. package/dist/components/diff/DiffCard.test.d.ts.map +1 -0
  22. package/dist/components/diff/index.d.ts +3 -0
  23. package/dist/components/diff/index.d.ts.map +1 -0
  24. package/dist/components/index.d.ts +4 -0
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/components/sources/SourcesCard.d.ts +7 -0
  27. package/dist/components/sources/SourcesCard.d.ts.map +1 -0
  28. package/dist/components/sources/index.d.ts +3 -0
  29. package/dist/components/sources/index.d.ts.map +1 -0
  30. package/dist/context/AgentUIContext.d.ts +1 -0
  31. package/dist/context/AgentUIContext.d.ts.map +1 -1
  32. package/dist/embedded-agent-ui.d.ts +5 -1
  33. package/dist/embedded-agent-ui.d.ts.map +1 -1
  34. package/dist/embedded-agent-ui.js +124 -117
  35. package/dist/hooks/useFloatingPanel.d.ts +42 -0
  36. package/dist/hooks/useFloatingPanel.d.ts.map +1 -0
  37. package/dist/hooks/useFloatingPanelPosition.d.ts +36 -0
  38. package/dist/hooks/useFloatingPanelPosition.d.ts.map +1 -0
  39. package/dist/hooks/useFloatingPanelPosition.test.d.ts +2 -0
  40. package/dist/hooks/useFloatingPanelPosition.test.d.ts.map +1 -0
  41. package/dist/hooks/useResizablePanel.d.ts +29 -0
  42. package/dist/hooks/useResizablePanel.d.ts.map +1 -0
  43. package/dist/hooks/useResizablePanel.test.d.ts +2 -0
  44. package/dist/hooks/useResizablePanel.test.d.ts.map +1 -0
  45. package/dist/index.css +1 -1
  46. package/dist/index.d.ts +4 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +3073 -2603
  49. package/dist/types/index.d.ts +20 -0
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/dist/utils/chatStorage.d.ts +20 -1
  52. package/dist/utils/chatStorage.d.ts.map +1 -1
  53. package/dist/utils/constants.d.ts +34 -0
  54. package/dist/utils/constants.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/dist/QuestionCard-KolZKB58.js +0 -81
  57. package/dist/QuestionCard.css +0 -1
@@ -1,84 +1,85 @@
1
1
  import { jsx as t, Fragment as I, jsxs as f } from "react/jsx-runtime";
2
2
  import { createContext as P, useState as E, useRef as R, useCallback as F, useContext as T } from "react";
3
3
  import { __ as g } from "@wordpress/i18n";
4
- import { Q as D } from "./QuestionCard-KolZKB58.js";
5
- function L(n) {
4
+ import { S as L } from "./DiffCard-CVeqjQhl.js";
5
+ import { D as ee, Q as te } from "./DiffCard-CVeqjQhl.js";
6
+ function W(n) {
6
7
  const e = n.trim();
7
8
  if (/^(https?:|mailto:)/i.test(e))
8
9
  return e;
9
10
  }
10
11
  function y(n) {
11
- const e = [], r = /(\[[^\]]+\]\([^\)]+\)|`[^`]+`|\*\*[^*]+\*\*|__[^_]+__|\*[^*]+\*|_[^_]+_)/g;
12
- let i = 0, s;
13
- for (; s = r.exec(n); ) {
14
- s.index > i && e.push(n.slice(i, s.index));
15
- const a = s[0], c = `${s.index}-${a}`, l = a.match(/^\[([^\]]+)\]\(([^\)]+)\)$/);
16
- if (l) {
17
- const d = L(l[2]);
12
+ const e = [], i = /(\[[^\]]+\]\([^\)]+\)|`[^`]+`|\*\*[^*]+\*\*|__[^_]+__|\*[^*]+\*|_[^_]+_)/g;
13
+ let s = 0, r;
14
+ for (; r = i.exec(n); ) {
15
+ r.index > s && e.push(n.slice(s, r.index));
16
+ const a = r[0], c = `${r.index}-${a}`, d = a.match(/^\[([^\]]+)\]\(([^\)]+)\)$/);
17
+ if (d) {
18
+ const l = W(d[2]);
18
19
  e.push(
19
- d ? /* @__PURE__ */ t(
20
+ l ? /* @__PURE__ */ t(
20
21
  "a",
21
22
  {
22
- href: d,
23
+ href: l,
23
24
  rel: "noreferrer",
24
25
  target: "_blank",
25
- children: l[1]
26
+ children: d[1]
26
27
  },
27
28
  c
28
29
  ) : a
29
30
  );
30
31
  } else a.startsWith("`") ? e.push(/* @__PURE__ */ t("code", { children: a.slice(1, -1) }, c)) : a.startsWith("**") || a.startsWith("__") ? e.push(/* @__PURE__ */ t("strong", { children: a.slice(2, -2) }, c)) : e.push(/* @__PURE__ */ t("em", { children: a.slice(1, -1) }, c));
31
- i = r.lastIndex;
32
+ s = i.lastIndex;
32
33
  }
33
- return i < n.length && e.push(n.slice(i)), e;
34
+ return s < n.length && e.push(n.slice(s)), e;
34
35
  }
35
- function v(n, e, r, i) {
36
+ function v(n, e, i, s) {
36
37
  if (e.length === 0)
37
38
  return;
38
- const s = e.map((a, c) => /* @__PURE__ */ t("li", { children: y(a) }, c));
39
+ const r = e.map((a, c) => /* @__PURE__ */ t("li", { children: y(a) }, c));
39
40
  n.push(
40
- r ? /* @__PURE__ */ t("ol", { children: s }, i) : /* @__PURE__ */ t("ul", { children: s }, i)
41
+ i ? /* @__PURE__ */ t("ol", { children: r }, s) : /* @__PURE__ */ t("ul", { children: r }, s)
41
42
  ), e.length = 0;
42
43
  }
43
- function W({
44
+ function O({
44
45
  children: n
45
46
  }) {
46
- const e = [], r = [];
47
- let i = !1, s = !1, a = [];
48
- return n.split(/\r?\n/).forEach((c, l) => {
47
+ const e = [], i = [];
48
+ let s = !1, r = !1, a = [];
49
+ return n.split(/\r?\n/).forEach((c, d) => {
49
50
  if (c.startsWith("```")) {
50
- s ? (e.push(
51
+ r ? (e.push(
51
52
  /* @__PURE__ */ t("pre", { children: /* @__PURE__ */ t("code", { children: a.join(`
52
- `) }) }, `code-${l}`)
53
- ), a = [], s = !1) : (v(e, r, i, `list-${l}`), s = !0);
53
+ `) }) }, `code-${d}`)
54
+ ), a = [], r = !1) : (v(e, i, s, `list-${d}`), r = !0);
54
55
  return;
55
56
  }
56
- if (s) {
57
+ if (r) {
57
58
  a.push(c);
58
59
  return;
59
60
  }
60
- const d = c.match(/^\s*[-*]\s+(.+)$/), o = c.match(/^\s*\d+\.\s+(.+)$/);
61
- if (d || o) {
61
+ const l = c.match(/^\s*[-*]\s+(.+)$/), o = c.match(/^\s*\d+\.\s+(.+)$/);
62
+ if (l || o) {
62
63
  const h = !!o;
63
- r.length && i !== h && v(e, r, i, `list-${l}`), i = h, r.push(
64
- ((o == null ? void 0 : o[1]) ?? (d == null ? void 0 : d[1]) ?? "").trim()
64
+ i.length && s !== h && v(e, i, s, `list-${d}`), s = h, i.push(
65
+ ((o == null ? void 0 : o[1]) ?? (l == null ? void 0 : l[1]) ?? "").trim()
65
66
  );
66
67
  return;
67
68
  }
68
- if (v(e, r, i, `list-${l}`), !c.trim())
69
+ if (v(e, i, s, `list-${d}`), !c.trim())
69
70
  return;
70
71
  const u = c.match(/^(#{1,3})\s+(.+)$/);
71
72
  if (u) {
72
73
  const p = `h${u[1].length}`;
73
74
  e.push(
74
- /* @__PURE__ */ t(p, { children: y(u[2]) }, `heading-${l}`)
75
+ /* @__PURE__ */ t(p, { children: y(u[2]) }, `heading-${d}`)
75
76
  );
76
77
  return;
77
78
  }
78
79
  e.push(
79
- /* @__PURE__ */ t("p", { children: y(c) }, `paragraph-${l}`)
80
+ /* @__PURE__ */ t("p", { children: y(c) }, `paragraph-${d}`)
80
81
  );
81
- }), v(e, r, i, "list-final"), s && a.length && e.push(
82
+ }), v(e, i, s, "list-final"), r && a.length && e.push(
82
83
  /* @__PURE__ */ t("pre", { children: /* @__PURE__ */ t("code", { children: a.join(`
83
84
  `) }) }, "code-final")
84
85
  ), /* @__PURE__ */ t(I, { children: e });
@@ -92,26 +93,26 @@ function b() {
92
93
  );
93
94
  return n;
94
95
  }
95
- function O({ content: n }) {
96
+ function Q({ content: n }) {
96
97
  return /* @__PURE__ */ t("div", { className: "agenttic-embedded__thinking", children: n ?? g("Thinking…", "a8c-agenttic") });
97
98
  }
98
99
  function X({
99
100
  heading: n,
100
101
  help: e,
101
- suggestions: r,
102
- onSuggestionClick: i
102
+ suggestions: i,
103
+ onSuggestionClick: s
103
104
  }) {
104
105
  return /* @__PURE__ */ f("div", { className: "agenttic-embedded__empty", children: [
105
106
  n && /* @__PURE__ */ t("h2", { children: n }),
106
107
  e && /* @__PURE__ */ t("p", { children: e }),
107
- r != null && r.length ? /* @__PURE__ */ t("div", { className: "agenttic-embedded__suggestions", children: r.map((s) => /* @__PURE__ */ t(
108
+ i != null && i.length ? /* @__PURE__ */ t("div", { className: "agenttic-embedded__suggestions", children: i.map((r) => /* @__PURE__ */ t(
108
109
  "button",
109
110
  {
110
111
  type: "button",
111
- onClick: () => i == null ? void 0 : i(s),
112
- children: s.label
112
+ onClick: () => s == null ? void 0 : s(r),
113
+ children: r.label
113
114
  },
114
- s.id
115
+ r.id
115
116
  )) }) : null
116
117
  ] });
117
118
  }
@@ -120,36 +121,40 @@ function U(n) {
120
121
  (e) => e.type === "text" || e.type === "component"
121
122
  );
122
123
  }
123
- function Q({ message: n }) {
124
- const { messageRenderer: e } = b(), r = e ?? W;
125
- return /* @__PURE__ */ t(
124
+ function H({ message: n }) {
125
+ var s;
126
+ const { messageRenderer: e } = b(), i = e ?? O;
127
+ return /* @__PURE__ */ f(
126
128
  "div",
127
129
  {
128
130
  "data-slot": "message",
129
131
  "data-role": n.role,
130
132
  className: `agenttic-embedded__message agenttic-embedded__message--${n.role}`,
131
- children: U(n).map((i, s) => {
132
- if (i.type === "text" && i.text)
133
- return /* @__PURE__ */ t(
134
- "div",
135
- {
136
- className: "agenttic-embedded__bubble",
137
- children: /* @__PURE__ */ t(r, { children: i.text })
138
- },
139
- s
140
- );
141
- if (i.type === "component" && i.component) {
142
- const a = i.component;
143
- return /* @__PURE__ */ t(
144
- a,
145
- {
146
- ...i.componentProps || {}
147
- },
148
- s
149
- );
150
- }
151
- return null;
152
- })
133
+ children: [
134
+ U(n).map((r, a) => {
135
+ if (r.type === "text" && r.text)
136
+ return /* @__PURE__ */ t(
137
+ "div",
138
+ {
139
+ className: "agenttic-embedded__bubble",
140
+ children: /* @__PURE__ */ t(i, { children: r.text })
141
+ },
142
+ a
143
+ );
144
+ if (r.type === "component" && r.component) {
145
+ const c = r.component;
146
+ return /* @__PURE__ */ t(
147
+ c,
148
+ {
149
+ ...r.componentProps || {}
150
+ },
151
+ a
152
+ );
153
+ }
154
+ return null;
155
+ }),
156
+ n.role === "agent" && ((s = n.sources) != null && s.length) ? /* @__PURE__ */ t(L, { sources: n.sources }) : null
157
+ ]
153
158
  }
154
159
  );
155
160
  }
@@ -158,15 +163,15 @@ function $({
158
163
  } = {}) {
159
164
  const {
160
165
  messages: e,
161
- isProcessing: r,
162
- error: i,
163
- emptyView: s,
166
+ isProcessing: i,
167
+ error: s,
168
+ emptyView: r,
164
169
  thinkingMessage: a,
165
170
  messagesPosition: c
166
- } = b(), l = e.filter(
167
- (d) => U(d).length > 0
171
+ } = b(), d = e.filter(
172
+ (l) => U(l).length > 0
168
173
  );
169
- return l.length === 0 && !r ? s ? /* @__PURE__ */ t(
174
+ return d.length === 0 && !i ? r ? /* @__PURE__ */ t(
170
175
  "div",
171
176
  {
172
177
  "data-slot": "messages",
@@ -175,7 +180,7 @@ function $({
175
180
  "agenttic-embedded__messages--empty",
176
181
  n
177
182
  ].filter(Boolean).join(" "),
178
- children: s
183
+ children: r
179
184
  }
180
185
  ) : null : /* @__PURE__ */ f(
181
186
  "div",
@@ -187,15 +192,15 @@ function $({
187
192
  n
188
193
  ].filter(Boolean).join(" "),
189
194
  children: [
190
- l.map((d) => /* @__PURE__ */ t(
191
- Q,
195
+ d.map((l) => /* @__PURE__ */ t(
196
+ H,
192
197
  {
193
- message: d
198
+ message: l
194
199
  },
195
- d.reactKey || d.id
200
+ l.reactKey || l.id
196
201
  )),
197
- r && /* @__PURE__ */ t(O, { content: a }),
198
- i && /* @__PURE__ */ t("div", { className: "agenttic-embedded__error", children: i })
202
+ i && /* @__PURE__ */ t(Q, { content: a }),
203
+ s && /* @__PURE__ */ t("div", { className: "agenttic-embedded__error", children: s })
199
204
  ]
200
205
  }
201
206
  );
@@ -203,17 +208,17 @@ function $({
203
208
  function j({
204
209
  className: n,
205
210
  showSuggestions: e,
206
- onSelect: r
211
+ onSelect: i
207
212
  } = {}) {
208
213
  const {
209
- inputValue: i,
210
- setInputValue: s,
214
+ inputValue: s,
215
+ setInputValue: r,
211
216
  suggestions: a,
212
217
  clearSuggestions: c,
213
- onSuggestionClick: l,
214
- submit: d
218
+ onSuggestionClick: d,
219
+ submit: l
215
220
  } = b();
216
- return i && !e || !(a != null && a.length) ? null : /* @__PURE__ */ t(
221
+ return s && !e || !(a != null && a.length) ? null : /* @__PURE__ */ t(
217
222
  "div",
218
223
  {
219
224
  className: ["agenttic-embedded__suggestions", n].filter(Boolean).join(" "),
@@ -224,11 +229,11 @@ function j({
224
229
  {
225
230
  type: "button",
226
231
  onClick: async () => {
227
- if (r == null || r(u), l == null || l(o, a), c == null || c(), o.autoSubmit) {
228
- await d(u);
232
+ if (i == null || i(u), d == null || d(o, a), c == null || c(), o.autoSubmit) {
233
+ await l(u);
229
234
  return;
230
235
  }
231
- s(u);
236
+ r(u);
232
237
  },
233
238
  children: o.label
234
239
  },
@@ -260,36 +265,36 @@ function x({
260
265
  function V({
261
266
  className: n,
262
267
  disabled: e,
263
- onKeyDown: r
268
+ onKeyDown: i
264
269
  } = {}) {
265
270
  const {
266
- acceptedFileTypes: i,
267
- allowAttachments: s,
271
+ acceptedFileTypes: s,
272
+ allowAttachments: r,
268
273
  fileInputRef: a,
269
274
  files: c,
270
- inputValue: l,
271
- isProcessing: d,
275
+ inputValue: d,
276
+ isProcessing: l,
272
277
  maxInputLength: o = 600,
273
278
  onStop: u,
274
279
  placeholder: h,
275
280
  setFiles: p,
276
281
  setInputValue: _,
277
282
  submit: A
278
- } = b(), C = !e && (d || !!l.trim() && l.length <= o), k = Array.isArray(h) ? h[0] : h;
283
+ } = b(), C = !e && (l || !!d.trim() && d.length <= o), k = Array.isArray(h) ? h[0] : h;
279
284
  return /* @__PURE__ */ f(
280
285
  "div",
281
286
  {
282
287
  "data-slot": "chat-input",
283
288
  className: ["agenttic-embedded__input", n].filter(Boolean).join(" "),
284
289
  children: [
285
- s && /* @__PURE__ */ f(I, { children: [
290
+ r && /* @__PURE__ */ f(I, { children: [
286
291
  /* @__PURE__ */ t(
287
292
  "input",
288
293
  {
289
294
  ref: a,
290
295
  type: "file",
291
296
  multiple: !0,
292
- accept: i == null ? void 0 : i.join(","),
297
+ accept: s == null ? void 0 : s.join(","),
293
298
  style: { display: "none" },
294
299
  onChange: (m) => p(
295
300
  Array.from(m.currentTarget.files ?? [])
@@ -314,10 +319,10 @@ function V({
314
319
  {
315
320
  "aria-label": g("Chat input", "a8c-agenttic"),
316
321
  placeholder: k,
317
- value: l,
322
+ value: d,
318
323
  onChange: (m) => _(m.currentTarget.value),
319
324
  onKeyDown: (m) => {
320
- r == null || r(m), !m.defaultPrevented && m.key === "Enter" && !m.shiftKey && C && !d && (m.preventDefault(), A());
325
+ i == null || i(m), !m.defaultPrevented && m.key === "Enter" && !m.shiftKey && C && !l && (m.preventDefault(), A());
321
326
  }
322
327
  }
323
328
  ),
@@ -325,16 +330,16 @@ function V({
325
330
  "button",
326
331
  {
327
332
  type: "button",
328
- "aria-label": d ? g("Stop processing", "a8c-agenttic") : g("Send message", "a8c-agenttic"),
333
+ "aria-label": l ? g("Stop processing", "a8c-agenttic") : g("Send message", "a8c-agenttic"),
329
334
  disabled: !C,
330
335
  onClick: () => {
331
- if (d) {
336
+ if (l) {
332
337
  u == null || u();
333
338
  return;
334
339
  }
335
340
  A();
336
341
  },
337
- children: d ? "■" : "↑"
342
+ children: l ? "■" : "↑"
338
343
  }
339
344
  ),
340
345
  c.length > 0 && /* @__PURE__ */ t("span", { className: "agenttic-embedded__attachment-count", children: c.length })
@@ -378,24 +383,24 @@ function B({
378
383
  function M({
379
384
  children: n,
380
385
  className: e,
381
- ...r
386
+ ...i
382
387
  }) {
383
- const [i, s] = E(""), [a, c] = E([]), l = R(null), d = r.inputValue ?? i, o = r.onInputChange ?? s, u = F(
388
+ const [s, r] = E(""), [a, c] = E([]), d = R(null), l = i.inputValue ?? s, o = i.onInputChange ?? r, u = F(
384
389
  async (p) => {
385
- const _ = (p ?? d).trim();
386
- !_ || r.isProcessing || (o(""), c([]), await r.onSubmit(
390
+ const _ = (p ?? l).trim();
391
+ !_ || i.isProcessing || (o(""), c([]), await i.onSubmit(
387
392
  _,
388
- r.allowAttachments ? a : void 0
393
+ i.allowAttachments ? a : void 0
389
394
  ));
390
395
  },
391
- [a, d, r, o]
396
+ [a, l, i, o]
392
397
  ), h = {
393
- ...r,
394
- inputValue: d,
398
+ ...i,
399
+ inputValue: l,
395
400
  setInputValue: o,
396
401
  files: a,
397
402
  setFiles: c,
398
- fileInputRef: l,
403
+ fileInputRef: d,
399
404
  submit: u
400
405
  };
401
406
  return /* @__PURE__ */ t(N.Provider, { value: h, children: /* @__PURE__ */ t(
@@ -407,7 +412,7 @@ function M({
407
412
  }
408
413
  ) });
409
414
  }
410
- const H = {
415
+ const q = {
411
416
  Container: M,
412
417
  ConversationView: B,
413
418
  Messages: $,
@@ -415,13 +420,14 @@ const H = {
415
420
  Input: V,
416
421
  Suggestions: j,
417
422
  Notice: x
418
- }, q = Object.assign(
423
+ }, z = Object.assign(
419
424
  (n) => /* @__PURE__ */ t(M, { ...n }),
420
- H
421
- ), Y = q;
425
+ q
426
+ ), Y = z;
422
427
  export {
423
428
  Y as AgentUI,
424
- q as EmbeddedAgentUI,
429
+ ee as DiffCard,
430
+ z as EmbeddedAgentUI,
425
431
  M as EmbeddedAgentUIContainer,
426
432
  B as EmbeddedAgentUIConversationView,
427
433
  w as EmbeddedAgentUIFooter,
@@ -430,7 +436,8 @@ export {
430
436
  x as EmbeddedAgentUINotice,
431
437
  j as EmbeddedAgentUISuggestions,
432
438
  X as EmptyView,
433
- W as LightweightMarkdownRenderer,
434
- D as QuestionCard,
435
- O as ThinkingMessage
439
+ O as LightweightMarkdownRenderer,
440
+ te as QuestionCard,
441
+ L as SourcesCard,
442
+ Q as ThinkingMessage
436
443
  };
@@ -0,0 +1,42 @@
1
+ import { type ChatPosition } from '../utils/chatStorage';
2
+ import type { ChatSize, ChatState } from '../types';
3
+ export interface UseFloatingPanelArgs {
4
+ resizable?: boolean | 'horizontal' | 'vertical';
5
+ defaultSize?: ChatSize;
6
+ size?: ChatSize;
7
+ minSize?: Partial<ChatSize>;
8
+ maxSize?: Partial<ChatSize>;
9
+ chatState: ChatState;
10
+ compactHeight: number;
11
+ freeDrag: boolean;
12
+ initialFreeDragPosition: {
13
+ x: number;
14
+ y: number;
15
+ } | undefined;
16
+ initialChatPosition?: ChatPosition;
17
+ onChatPositionChange?: (position: ChatPosition) => void;
18
+ onFreeDragEnd?: (position: {
19
+ x: number;
20
+ y: number;
21
+ }) => void;
22
+ onResize?: (size: ChatSize) => void;
23
+ onResizeEnd?: (size: ChatSize) => void;
24
+ }
25
+ export declare function useFloatingPanel({ resizable, defaultSize, size, minSize, maxSize, chatState, compactHeight, freeDrag, initialFreeDragPosition, initialChatPosition, onChatPositionChange, onFreeDragEnd, onResize, onResizeEnd, }: UseFloatingPanelArgs): {
26
+ x: import("framer-motion").MotionValue<number>;
27
+ y: import("framer-motion").MotionValue<number>;
28
+ currentSide: ChatPosition;
29
+ isDragging: boolean;
30
+ dragControls: import("framer-motion").DragControls;
31
+ chatRef: import("react").RefObject<HTMLDivElement>;
32
+ constraintsRef: import("react").RefObject<HTMLDivElement>;
33
+ handlePointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
34
+ handleDragStart: () => void;
35
+ handleDragEnd: (event: unknown, info: import("framer-motion").PanInfo) => void;
36
+ width: import("framer-motion").MotionValue<number>;
37
+ height: import("framer-motion").MotionValue<number>;
38
+ isResizing: boolean;
39
+ getHeightForState: (state: string) => number;
40
+ handleResizePointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
41
+ };
42
+ //# sourceMappingURL=useFloatingPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFloatingPanel.d.ts","sourceRoot":"","sources":["../../src/hooks/useFloatingPanel.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,YAAY,EAGjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIpD,MAAM,WAAW,oBAAoB;IACpC,SAAS,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;IAChD,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAE,QAAQ,CAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAE,QAAQ,CAAE,CAAC;IAC9B,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,uBAAuB,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC9D,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,oBAAoB,CAAC,EAAE,CAAE,QAAQ,EAAE,YAAY,KAAM,IAAI,CAAC;IAC1D,aAAa,CAAC,EAAE,CAAE,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAM,IAAI,CAAC;IAC/D,QAAQ,CAAC,EAAE,CAAE,IAAI,EAAE,QAAQ,KAAM,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,CAAE,IAAI,EAAE,QAAQ,KAAM,IAAI,CAAC;CACzC;AAOD,wBAAgB,gBAAgB,CAAE,EACjC,SAAiB,EACjB,WAAW,EACX,IAAI,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,aAAa,EACb,QAAQ,EACR,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,WAAW,GACX,EAAE,oBAAoB;;;;;;;;;;;;;;;;EAgFtB"}
@@ -0,0 +1,36 @@
1
+ import { type MotionValue, type PanInfo, useDragControls } from 'framer-motion';
2
+ import { type ChatPosition } from '../utils/chatStorage';
3
+ import type { ChatSize, ChatState } from '../types';
4
+ export interface UseFloatingPanelPositionArgs {
5
+ freeDrag: boolean;
6
+ initialChatPosition?: ChatPosition;
7
+ chatState: ChatState;
8
+ onChatPositionChange?: (position: ChatPosition) => void;
9
+ onFreeDragEnd?: (position: {
10
+ x: number;
11
+ y: number;
12
+ }) => void;
13
+ x: MotionValue<number>;
14
+ y: MotionValue<number>;
15
+ getPanelSize: () => ChatSize;
16
+ clampResizedSize: () => void;
17
+ }
18
+ export interface UseFloatingPanelPositionResult {
19
+ x: MotionValue<number>;
20
+ y: MotionValue<number>;
21
+ currentSide: ChatPosition;
22
+ isDragging: boolean;
23
+ dragControls: ReturnType<typeof useDragControls>;
24
+ chatRef: React.RefObject<HTMLDivElement>;
25
+ constraintsRef: React.RefObject<HTMLDivElement>;
26
+ handlePointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
27
+ handleDragStart: () => void;
28
+ handleDragEnd: (event: unknown, info: PanInfo) => void;
29
+ calculateSnapPosition: (side?: 'left' | 'right') => {
30
+ x: number;
31
+ y: number;
32
+ };
33
+ repositionForResize: (deltaWidth?: number) => void;
34
+ }
35
+ export declare function useFloatingPanelPosition({ freeDrag, initialChatPosition, chatState, onChatPositionChange, onFreeDragEnd, x, y, getPanelSize, clampResizedSize, }: UseFloatingPanelPositionArgs): UseFloatingPanelPositionResult;
36
+ //# sourceMappingURL=useFloatingPanelPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFloatingPanelPosition.d.ts","sourceRoot":"","sources":["../../src/hooks/useFloatingPanelPosition.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,eAAe,EACf,MAAM,eAAe,CAAC;AAGvB,OAAO,EACN,KAAK,YAAY,EAKjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAClB,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB,CAAC,EAAE,CAAE,QAAQ,EAAE,YAAY,KAAM,IAAI,CAAC;IAC1D,aAAa,CAAC,EAAE,CAAE,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAM,IAAI,CAAC;IAG/D,CAAC,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IACzB,CAAC,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IAEzB,YAAY,EAAE,MAAM,QAAQ,CAAC;IAG7B,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,8BAA8B;IAC9C,CAAC,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IACzB,CAAC,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IACzB,WAAW,EAAE,YAAY,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,UAAU,CAAE,OAAO,eAAe,CAAE,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAE,cAAc,CAAE,CAAC;IAC3C,cAAc,EAAE,KAAK,CAAC,SAAS,CAAE,cAAc,CAAE,CAAC;IAClD,iBAAiB,EAAE,CAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAE,cAAc,CAAE,KAAM,IAAI,CAAC;IAC3E,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,EAAE,CAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAM,IAAI,CAAC;IACzD,qBAAqB,EAAE,CAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,KAAM;QACrD,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACV,CAAC;IAKF,mBAAmB,EAAE,CAAE,UAAU,CAAC,EAAE,MAAM,KAAM,IAAI,CAAC;CACrD;AAMD,wBAAgB,wBAAwB,CAAE,EACzC,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,CAAC,EACD,CAAC,EACD,YAAY,EACZ,gBAAgB,GAChB,EAAE,4BAA4B,GAAI,8BAA8B,CAgUhE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useFloatingPanelPosition.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFloatingPanelPosition.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useFloatingPanelPosition.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { type MotionValue } from 'framer-motion';
2
+ import type { ChatSize } from '../types';
3
+ export interface UseResizablePanelArgs {
4
+ resizable?: boolean | 'horizontal' | 'vertical';
5
+ defaultSize?: ChatSize;
6
+ size?: ChatSize;
7
+ minSize?: Partial<ChatSize>;
8
+ maxSize?: Partial<ChatSize>;
9
+ chatState: string;
10
+ compactHeight: number;
11
+ x: MotionValue<number>;
12
+ y: MotionValue<number>;
13
+ repositionForResize: (deltaWidth: number) => void;
14
+ onResize?: (size: ChatSize) => void;
15
+ onResizeEnd?: (size: ChatSize) => void;
16
+ }
17
+ export interface UseResizablePanelResult {
18
+ width: MotionValue<number>;
19
+ height: MotionValue<number>;
20
+ isResizing: boolean;
21
+ expandedSizeRef: React.MutableRefObject<ChatSize>;
22
+ getPanelSize: () => ChatSize;
23
+ clampSize: (size: ChatSize) => ChatSize;
24
+ clampToViewport: () => void;
25
+ getHeightForState: (state: string) => number;
26
+ handleResizePointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
27
+ }
28
+ export declare function useResizablePanel({ resizable, defaultSize, size, minSize, maxSize, chatState, compactHeight, x, y, repositionForResize, onResize, onResizeEnd, }: UseResizablePanelArgs): UseResizablePanelResult;
29
+ //# sourceMappingURL=useResizablePanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResizablePanel.d.ts","sourceRoot":"","sources":["../../src/hooks/useResizablePanel.ts"],"names":[],"mappings":"AAQA,OAAO,EAAW,KAAK,WAAW,EAAkB,MAAM,eAAe,CAAC;AAG1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgEzC,MAAM,WAAW,qBAAqB;IACrC,SAAS,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;IAChD,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAE,QAAQ,CAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAE,QAAQ,CAAE,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IAGtB,CAAC,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IACzB,CAAC,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IAKzB,mBAAmB,EAAE,CAAE,UAAU,EAAE,MAAM,KAAM,IAAI,CAAC;IACpD,QAAQ,CAAC,EAAE,CAAE,IAAI,EAAE,QAAQ,KAAM,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,CAAE,IAAI,EAAE,QAAQ,KAAM,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,uBAAuB;IACvC,KAAK,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAE,QAAQ,CAAE,CAAC;IACpD,YAAY,EAAE,MAAM,QAAQ,CAAC;IAC7B,SAAS,EAAE,CAAE,IAAI,EAAE,QAAQ,KAAM,QAAQ,CAAC;IAI1C,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,iBAAiB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,MAAM,CAAC;IAC/C,uBAAuB,EAAE,CACxB,KAAK,EAAE,KAAK,CAAC,YAAY,CAAE,cAAc,CAAE,KACvC,IAAI,CAAC;CACV;AAKD,wBAAgB,iBAAiB,CAAE,EAClC,SAAiB,EACjB,WAAW,EACX,IAAI,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,aAAa,EACb,CAAC,EACD,CAAC,EACD,mBAAmB,EACnB,QAAQ,EACR,WAAW,GACX,EAAE,qBAAqB,GAAI,uBAAuB,CAoYlD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useResizablePanel.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResizablePanel.test.d.ts","sourceRoot":"","sources":["../../src/hooks/useResizablePanel.test.tsx"],"names":[],"mappings":""}