@photon-ai/pho-ui 4.3.1 → 4.5.0
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.
- package/dist/chunks/{basic-page-OrUVXKrx.js → basic-page-D3MY3uY6.js} +751 -707
- package/dist/chunks/basic-page-D3MY3uY6.js.map +1 -0
- package/dist/chunks/bubble-eaoLJP4N.js +88 -0
- package/dist/chunks/bubble-eaoLJP4N.js.map +1 -0
- package/dist/chunks/{button-CdqS_t5a.js → button-CgUS0j3D.js} +4 -4
- package/dist/chunks/button-CgUS0j3D.js.map +1 -0
- package/dist/chunks/chat-DUqWlXqt.js +619 -0
- package/dist/chunks/chat-DUqWlXqt.js.map +1 -0
- package/dist/chunks/{code-block-BuDIo8Q0.js → code-block-BGgbp-6Q.js} +12 -12
- package/dist/chunks/{code-block-BuDIo8Q0.js.map → code-block-BGgbp-6Q.js.map} +1 -1
- package/dist/chunks/command-BfCCRaoc.js +225 -0
- package/dist/chunks/command-BfCCRaoc.js.map +1 -0
- package/dist/chunks/{copy-button-B_B15mEi.js → copy-button-D8XyP0oR.js} +10 -10
- package/dist/chunks/copy-button-D8XyP0oR.js.map +1 -0
- package/dist/chunks/{description-list-C-mwe4ki.js → description-list-8qm83WZB.js} +17 -17
- package/dist/chunks/description-list-8qm83WZB.js.map +1 -0
- package/dist/chunks/{dialog-BOz_xOrn.js → dialog-DeM4axJ6.js} +3 -3
- package/dist/chunks/{dialog-BOz_xOrn.js.map → dialog-DeM4axJ6.js.map} +1 -1
- package/dist/chunks/{error-BAQgnde7.js → error-VvHnteyf.js} +2 -2
- package/dist/chunks/{error-BAQgnde7.js.map → error-VvHnteyf.js.map} +1 -1
- package/dist/chunks/{filter-bar-Cr_1zBFq.js → filter-bar-BcpeTKCC.js} +38 -36
- package/dist/chunks/filter-bar-BcpeTKCC.js.map +1 -0
- package/dist/chunks/{log-list-BERiO4UJ.js → log-list-Didt-MV4.js} +2 -2
- package/dist/chunks/{log-list-BERiO4UJ.js.map → log-list-Didt-MV4.js.map} +1 -1
- package/dist/chunks/message-CTml-TrB.js +89 -0
- package/dist/chunks/message-CTml-TrB.js.map +1 -0
- package/dist/chunks/{scroll-area-Zik8t1Mk.js → scroll-area-DSwD9th7.js} +2 -2
- package/dist/chunks/{scroll-area-Zik8t1Mk.js.map → scroll-area-DSwD9th7.js.map} +1 -1
- package/dist/chunks/{sidebar-bLsjo_yb.js → sidebar-BmloUwJQ.js} +56 -56
- package/dist/chunks/sidebar-BmloUwJQ.js.map +1 -0
- package/dist/chunks/{toast-72Wwlzg9.js → toast-DUvjSZF7.js} +3 -3
- package/dist/chunks/{toast-72Wwlzg9.js.map → toast-DUvjSZF7.js.map} +1 -1
- package/dist/components/bubble.js +6 -0
- package/dist/components/button.js +1 -1
- package/dist/components/chat.js +5 -0
- package/dist/components/code-block.js +1 -1
- package/dist/components/command.js +1 -1
- package/dist/components/copy-button.js +1 -1
- package/dist/components/description-list.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/error.js +1 -1
- package/dist/components/filter-bar.js +1 -1
- package/dist/components/log-list.js +1 -1
- package/dist/components/message.js +7 -0
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/index.js +145 -136
- package/dist/sections/basic-page.js +1 -1
- package/dist/sections/sidebar.js +1 -1
- package/dist/src/components/bubble/bubble.d.ts +112 -0
- package/dist/src/components/bubble/index.d.ts +1 -0
- package/dist/src/components/chat/chat.d.ts +301 -0
- package/dist/src/components/chat/index.d.ts +1 -0
- package/dist/src/components/command/command.d.ts +14 -4
- package/dist/src/components/command/index.d.ts +1 -1
- package/dist/src/components/filter-bar/filter-bar.d.ts +5 -0
- package/dist/src/components/message/index.d.ts +2 -0
- package/dist/src/components/message/message-status.d.ts +22 -0
- package/dist/src/components/message/message.d.ts +78 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/sections/basic-page/basic-page.d.ts +15 -2
- package/dist/src/sections/sidebar/sidebar.d.ts +10 -1
- package/package.json +13 -1
- package/dist/chunks/basic-page-OrUVXKrx.js.map +0 -1
- package/dist/chunks/button-CdqS_t5a.js.map +0 -1
- package/dist/chunks/command-Cn000hMK.js +0 -192
- package/dist/chunks/command-Cn000hMK.js.map +0 -1
- package/dist/chunks/copy-button-B_B15mEi.js.map +0 -1
- package/dist/chunks/description-list-C-mwe4ki.js.map +0 -1
- package/dist/chunks/filter-bar-Cr_1zBFq.js.map +0 -1
- package/dist/chunks/sidebar-bLsjo_yb.js.map +0 -1
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as v } from "./cn-ChIgwEl3.js";
|
|
3
|
+
import { n as se } from "./link-provider-DXzDQ08N.js";
|
|
4
|
+
import { FADE_SWAP as B, PRESS_SCALE_ROW as le, SPRING_PRESS as ce, TRAVEL_LINEAR as de } from "../motion.js";
|
|
5
|
+
import { a as D } from "./button-CgUS0j3D.js";
|
|
6
|
+
import { t as L } from "./createReactComponent-BqCmnqfX.js";
|
|
7
|
+
import { t as ue } from "./input-DjvZoF8v.js";
|
|
8
|
+
import { n as G } from "./avatar-BkmGDIqf.js";
|
|
9
|
+
import { t as pe } from "./IconSearch-BKAHkLyX.js";
|
|
10
|
+
import { t as C } from "./scroll-area-DSwD9th7.js";
|
|
11
|
+
import { i as he } from "./status-view-C8tabjDu.js";
|
|
12
|
+
import { t as k } from "./skeleton-DwjSl4vC.js";
|
|
13
|
+
import { createContext as fe, useCallback as q, useContext as me, useEffect as ve, useId as xe, useLayoutEffect as be, useMemo as Y, useRef as _, useState as R } from "react";
|
|
14
|
+
import { Fragment as Z, jsx as e, jsxs as y } from "react/jsx-runtime";
|
|
15
|
+
import { AnimatePresence as we, motion as M, useReducedMotion as ee } from "motion/react";
|
|
16
|
+
var ge = [
|
|
17
|
+
["path", {
|
|
18
|
+
d: "M5 12l14 0",
|
|
19
|
+
key: "svg-0"
|
|
20
|
+
}],
|
|
21
|
+
["path", {
|
|
22
|
+
d: "M5 12l6 6",
|
|
23
|
+
key: "svg-1"
|
|
24
|
+
}],
|
|
25
|
+
["path", {
|
|
26
|
+
d: "M5 12l6 -6",
|
|
27
|
+
key: "svg-2"
|
|
28
|
+
}]
|
|
29
|
+
], ye = L("outline", "arrow-left", "ArrowLeft", ge), Ne = [
|
|
30
|
+
["path", {
|
|
31
|
+
d: "M12 5l0 14",
|
|
32
|
+
key: "svg-0"
|
|
33
|
+
}],
|
|
34
|
+
["path", {
|
|
35
|
+
d: "M18 11l-6 -6",
|
|
36
|
+
key: "svg-1"
|
|
37
|
+
}],
|
|
38
|
+
["path", {
|
|
39
|
+
d: "M6 11l6 -6",
|
|
40
|
+
key: "svg-2"
|
|
41
|
+
}]
|
|
42
|
+
], Ce = L("outline", "arrow-up", "ArrowUp", Ne), _e = [["path", {
|
|
43
|
+
d: "M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0",
|
|
44
|
+
key: "svg-0"
|
|
45
|
+
}], ["path", {
|
|
46
|
+
d: "M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",
|
|
47
|
+
key: "svg-1"
|
|
48
|
+
}]], ke = L("outline", "user", "User", _e), Se = [
|
|
49
|
+
["path", {
|
|
50
|
+
d: "M5 7a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",
|
|
51
|
+
key: "svg-0"
|
|
52
|
+
}],
|
|
53
|
+
["path", {
|
|
54
|
+
d: "M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",
|
|
55
|
+
key: "svg-1"
|
|
56
|
+
}],
|
|
57
|
+
["path", {
|
|
58
|
+
d: "M16 3.13a4 4 0 0 1 0 7.75",
|
|
59
|
+
key: "svg-2"
|
|
60
|
+
}],
|
|
61
|
+
["path", {
|
|
62
|
+
d: "M21 21v-2a4 4 0 0 0 -3 -3.85",
|
|
63
|
+
key: "svg-3"
|
|
64
|
+
}]
|
|
65
|
+
], Pe = L("outline", "users", "Users", Se), Re = "rounded-base border border-pho-secondary bg-pho-primary", A = "@2xl", Ae = 672, Ee = 24, Ie = 8, te = "min-h-[61px]", Me = 273, S = 256, z = 320, Le = 16;
|
|
66
|
+
function J(t, r) {
|
|
67
|
+
const a = Math.max(S, t);
|
|
68
|
+
return r <= 0 ? Number.isFinite(a) ? a : S : Math.min(a, Math.max(S, r - z));
|
|
69
|
+
}
|
|
70
|
+
var re = fe(null);
|
|
71
|
+
function E(t) {
|
|
72
|
+
const r = me(re);
|
|
73
|
+
if (r == null) throw new Error(`Chat.${t} must be used inside Chat.Root`);
|
|
74
|
+
return r;
|
|
75
|
+
}
|
|
76
|
+
var W = typeof window > "u" ? ve : be;
|
|
77
|
+
function O(t) {
|
|
78
|
+
return t === "thread" ? 1 : -1;
|
|
79
|
+
}
|
|
80
|
+
function Te(t, r) {
|
|
81
|
+
return t === "compact" || t === "auto" && r > 0 && r < Ae;
|
|
82
|
+
}
|
|
83
|
+
function I(t, r) {
|
|
84
|
+
return r ? {
|
|
85
|
+
initial: { opacity: 0 },
|
|
86
|
+
animate: { opacity: 1 },
|
|
87
|
+
exit: { opacity: 0 },
|
|
88
|
+
transition: { duration: 0 }
|
|
89
|
+
} : {
|
|
90
|
+
initial: {
|
|
91
|
+
x: t * Ee,
|
|
92
|
+
opacity: 0,
|
|
93
|
+
filter: "blur(1px)"
|
|
94
|
+
},
|
|
95
|
+
animate: {
|
|
96
|
+
x: 0,
|
|
97
|
+
opacity: 1,
|
|
98
|
+
filter: "blur(0px)"
|
|
99
|
+
},
|
|
100
|
+
exit: {
|
|
101
|
+
x: -t * Ie,
|
|
102
|
+
opacity: 0,
|
|
103
|
+
filter: "blur(1px)"
|
|
104
|
+
},
|
|
105
|
+
transition: {
|
|
106
|
+
x: de,
|
|
107
|
+
opacity: B,
|
|
108
|
+
filter: B
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function Oe(t) {
|
|
113
|
+
return {
|
|
114
|
+
enter: (r) => I(r, t).initial,
|
|
115
|
+
rest: (r) => I(r, t).animate,
|
|
116
|
+
leave: (r) => I(r, t).exit
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function ae({ as: t, show: r, swapped: a, direction: l, reduceMotion: o, children: c, ...s }) {
|
|
120
|
+
const u = I(l, o), f = {
|
|
121
|
+
custom: l,
|
|
122
|
+
variants: Oe(o),
|
|
123
|
+
initial: "enter",
|
|
124
|
+
animate: "rest",
|
|
125
|
+
exit: "leave",
|
|
126
|
+
transition: u.transition
|
|
127
|
+
};
|
|
128
|
+
return /* @__PURE__ */ e(we, {
|
|
129
|
+
initial: !a && r ? !1 : void 0,
|
|
130
|
+
mode: "popLayout",
|
|
131
|
+
custom: l,
|
|
132
|
+
children: r ? t === "aside" ? /* @__PURE__ */ e(M.aside, {
|
|
133
|
+
...s,
|
|
134
|
+
...f,
|
|
135
|
+
children: c
|
|
136
|
+
}, "list") : /* @__PURE__ */ e(M.section, {
|
|
137
|
+
...s,
|
|
138
|
+
...f,
|
|
139
|
+
children: c
|
|
140
|
+
}, "thread") : null
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function ze({ layout: t = "default", pane: r, defaultPane: a = "list", onPaneChange: l, className: o, style: c, ref: s, ...u }) {
|
|
144
|
+
const [f, m] = R(a), [g, w] = R(Me), [i, n] = R(0), p = _(null), x = r !== void 0, h = x ? r : f, [b, d] = R(() => O(h)), [$, ne] = R(!1), H = _(h);
|
|
145
|
+
let P = b, T = $;
|
|
146
|
+
H.current !== h && (P = O(h), T = !0, H.current = h, P !== b && d(P), $ || ne(!0));
|
|
147
|
+
const V = q((N) => {
|
|
148
|
+
d(O(N)), x || m(N), l?.(N);
|
|
149
|
+
}, [x, l]), X = q((N) => {
|
|
150
|
+
w(J(N, p.current?.clientWidth ?? 0));
|
|
151
|
+
}, []), U = Te(t, i);
|
|
152
|
+
W(() => {
|
|
153
|
+
const N = p.current;
|
|
154
|
+
if (!N || typeof ResizeObserver > "u") return;
|
|
155
|
+
const F = () => {
|
|
156
|
+
const K = N.clientWidth;
|
|
157
|
+
n(K), w((oe) => J(oe, K));
|
|
158
|
+
};
|
|
159
|
+
F();
|
|
160
|
+
const j = new ResizeObserver(F);
|
|
161
|
+
return j.observe(N), () => j.disconnect();
|
|
162
|
+
}, []);
|
|
163
|
+
const ie = Y(() => ({
|
|
164
|
+
layout: t,
|
|
165
|
+
pane: h,
|
|
166
|
+
setPane: V,
|
|
167
|
+
direction: P,
|
|
168
|
+
swap: U,
|
|
169
|
+
swapped: T,
|
|
170
|
+
listWidth: g,
|
|
171
|
+
frameWidth: i,
|
|
172
|
+
resizeList: X,
|
|
173
|
+
rootRef: p
|
|
174
|
+
}), [
|
|
175
|
+
t,
|
|
176
|
+
h,
|
|
177
|
+
V,
|
|
178
|
+
P,
|
|
179
|
+
U,
|
|
180
|
+
T,
|
|
181
|
+
g,
|
|
182
|
+
i,
|
|
183
|
+
X
|
|
184
|
+
]);
|
|
185
|
+
return /* @__PURE__ */ e(re.Provider, {
|
|
186
|
+
value: ie,
|
|
187
|
+
children: /* @__PURE__ */ e("div", {
|
|
188
|
+
ref: (N) => {
|
|
189
|
+
p.current = N, typeof s == "function" ? s(N) : s && (s.current = N);
|
|
190
|
+
},
|
|
191
|
+
"data-chat": "",
|
|
192
|
+
"data-basic-page-card": "",
|
|
193
|
+
"data-layout": t,
|
|
194
|
+
"data-pane": h,
|
|
195
|
+
style: {
|
|
196
|
+
...c,
|
|
197
|
+
"--chat-list-width": `${g}px`
|
|
198
|
+
},
|
|
199
|
+
className: v(Re, "@container relative flex min-h-0 min-w-0 overflow-hidden", o),
|
|
200
|
+
...u
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function De({ className: t, children: r, id: a, ...l }) {
|
|
205
|
+
const { layout: o, pane: c, direction: s, swap: u, swapped: f } = E("List"), m = ee(), g = xe(), w = a ?? g, i = v("border-pho-secondary bg-pho-page relative z-10 flex min-h-0 shrink-0 flex-col", o === "default" && "min-w-64 w-[var(--chat-list-width)] border-r", o === "compact" && "w-full", o === "auto" && v(`w-full ${A}:min-w-64 ${A}:w-[var(--chat-list-width)] ${A}:border-r`, !u && c === "thread" && "@max-2xl:hidden"), t), n = /* @__PURE__ */ y(Z, { children: [r, o !== "compact" && /* @__PURE__ */ e(We, { controlsId: w })] }), p = {
|
|
206
|
+
id: w,
|
|
207
|
+
"aria-label": "Conversations",
|
|
208
|
+
"data-chat-list": "",
|
|
209
|
+
className: i,
|
|
210
|
+
...l
|
|
211
|
+
};
|
|
212
|
+
return u ? /* @__PURE__ */ e(ae, {
|
|
213
|
+
as: "aside",
|
|
214
|
+
show: c === "list",
|
|
215
|
+
swapped: f,
|
|
216
|
+
direction: s,
|
|
217
|
+
reduceMotion: m,
|
|
218
|
+
...p,
|
|
219
|
+
children: n
|
|
220
|
+
}) : /* @__PURE__ */ e("aside", {
|
|
221
|
+
...p,
|
|
222
|
+
children: n
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function We({ controlsId: t }) {
|
|
226
|
+
const { layout: r, listWidth: a, frameWidth: l, resizeList: o, rootRef: c } = E("Splitter"), s = _(null), u = (i) => {
|
|
227
|
+
i.button === 0 && (i.currentTarget.setPointerCapture?.(i.pointerId), s.current = {
|
|
228
|
+
x: i.clientX,
|
|
229
|
+
width: a
|
|
230
|
+
});
|
|
231
|
+
}, f = (i) => {
|
|
232
|
+
const n = s.current;
|
|
233
|
+
if (n == null) return;
|
|
234
|
+
const p = c.current, x = p != null && getComputedStyle(p).direction === "rtl", h = (i.clientX - n.x) * (x ? -1 : 1);
|
|
235
|
+
o(n.width + h);
|
|
236
|
+
}, m = () => {
|
|
237
|
+
s.current = null;
|
|
238
|
+
}, g = (i) => {
|
|
239
|
+
const n = c.current, p = n != null && getComputedStyle(n).direction === "rtl", x = p ? "ArrowRight" : "ArrowLeft", h = p ? "ArrowLeft" : "ArrowRight", b = i.shiftKey ? 32 : Le;
|
|
240
|
+
if (i.key === x)
|
|
241
|
+
i.preventDefault(), o(a - b);
|
|
242
|
+
else if (i.key === h)
|
|
243
|
+
i.preventDefault(), o(a + b);
|
|
244
|
+
else if (i.key === "Home")
|
|
245
|
+
i.preventDefault(), o(S);
|
|
246
|
+
else if (i.key === "End") {
|
|
247
|
+
i.preventDefault();
|
|
248
|
+
const d = n?.clientWidth ?? 0;
|
|
249
|
+
d > 0 && o(d - z);
|
|
250
|
+
}
|
|
251
|
+
}, w = l > 0 ? Math.max(S, l - z) : a;
|
|
252
|
+
return /* @__PURE__ */ e("div", {
|
|
253
|
+
role: "separator",
|
|
254
|
+
"aria-orientation": "vertical",
|
|
255
|
+
"aria-label": "Resize conversation list",
|
|
256
|
+
"aria-controls": t,
|
|
257
|
+
"aria-valuenow": a,
|
|
258
|
+
"aria-valuemin": S,
|
|
259
|
+
"aria-valuemax": w,
|
|
260
|
+
"aria-valuetext": `${a} pixels`,
|
|
261
|
+
tabIndex: 0,
|
|
262
|
+
"data-chat-splitter": "",
|
|
263
|
+
onPointerDown: u,
|
|
264
|
+
onPointerMove: f,
|
|
265
|
+
onPointerUp: m,
|
|
266
|
+
onPointerCancel: m,
|
|
267
|
+
onKeyDown: g,
|
|
268
|
+
className: v("absolute inset-y-0 -right-3 z-10 w-6 cursor-col-resize touch-none select-none", "outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-2", "after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent", "[@media(hover:hover)]:hover:after:bg-pho-brand focus-visible:after:bg-pho-brand", r === "auto" && "@max-2xl:hidden")
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function $e({ className: t, placeholder: r = "Search", ...a }) {
|
|
272
|
+
return /* @__PURE__ */ e("div", {
|
|
273
|
+
"data-chat-search": "",
|
|
274
|
+
className: v("p-3", te, t),
|
|
275
|
+
children: /* @__PURE__ */ e(ue, {
|
|
276
|
+
size: "sm",
|
|
277
|
+
icon: pe,
|
|
278
|
+
placeholder: r,
|
|
279
|
+
"aria-label": "Search conversations",
|
|
280
|
+
autoComplete: "off",
|
|
281
|
+
spellCheck: !1,
|
|
282
|
+
...a
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
function He({ className: t, children: r, ...a }) {
|
|
287
|
+
return /* @__PURE__ */ e("div", {
|
|
288
|
+
"data-chat-conversations": "",
|
|
289
|
+
className: v("flex min-h-0 flex-1 flex-col", t),
|
|
290
|
+
...a,
|
|
291
|
+
children: /* @__PURE__ */ y(C.Root, {
|
|
292
|
+
className: "min-h-0 flex-1",
|
|
293
|
+
children: [/* @__PURE__ */ e(C.Viewport, { children: /* @__PURE__ */ e(C.Content, {
|
|
294
|
+
style: { minWidth: 0 },
|
|
295
|
+
className: "flex min-h-full flex-col px-3 py-1",
|
|
296
|
+
children: r
|
|
297
|
+
}) }), /* @__PURE__ */ e(C.Scrollbar, { children: /* @__PURE__ */ e(C.Thumb, {}) })]
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function Ve({ className: t, ...r }) {
|
|
302
|
+
return /* @__PURE__ */ e("ul", {
|
|
303
|
+
"data-chat-conversation-list": "",
|
|
304
|
+
className: v("m-0 flex list-none flex-col gap-0.5 *:m-0", t),
|
|
305
|
+
...r
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
var Xe = "outline-pho-brand rounded-base flex w-full cursor-pointer items-center gap-3 px-2 py-2.5 text-left transition-colors focus-visible:outline-2 focus-visible:-outline-offset-1", Ue = "bg-pho-primary text-pho-primary ring-pho-secondary ring-1 ring-inset *:data-icon:text-pho-primary", Fe = "hover:bg-pho-ghost-hover", Q = {
|
|
309
|
+
initial: !1,
|
|
310
|
+
whileTap: { scale: le },
|
|
311
|
+
transition: ce
|
|
312
|
+
};
|
|
313
|
+
function je({ title: t, time: r, preview: a, avatar: l, group: o, active: c, className: s, href: u, onClick: f, ...m }) {
|
|
314
|
+
const { layout: g, setPane: w } = E("Conversation"), i = se(), n = Y(() => M.create(i), [i]), p = v(Xe, c ? Ue : Fe, s), x = () => {
|
|
315
|
+
g !== "default" && w("thread");
|
|
316
|
+
}, h = /* @__PURE__ */ y(Z, { children: [l ?? /* @__PURE__ */ e(G.Root, {
|
|
317
|
+
size: "sm",
|
|
318
|
+
children: /* @__PURE__ */ e(G.Fallback, { children: o ? /* @__PURE__ */ e(Pe, {
|
|
319
|
+
className: "size-4",
|
|
320
|
+
"aria-hidden": !0
|
|
321
|
+
}) : /* @__PURE__ */ e(ke, {
|
|
322
|
+
className: "size-4",
|
|
323
|
+
"aria-hidden": !0
|
|
324
|
+
}) })
|
|
325
|
+
}), /* @__PURE__ */ y("span", {
|
|
326
|
+
className: "min-w-0 flex-1",
|
|
327
|
+
children: [/* @__PURE__ */ y("span", {
|
|
328
|
+
className: "flex items-baseline justify-between gap-2",
|
|
329
|
+
children: [/* @__PURE__ */ e("span", {
|
|
330
|
+
className: "text-pho-primary min-w-0 truncate text-base font-medium",
|
|
331
|
+
children: t
|
|
332
|
+
}), r != null && /* @__PURE__ */ e("span", {
|
|
333
|
+
className: "text-pho-description shrink-0 text-xs font-normal whitespace-nowrap tabular-nums",
|
|
334
|
+
children: r
|
|
335
|
+
})]
|
|
336
|
+
}), a != null && /* @__PURE__ */ e("span", {
|
|
337
|
+
className: "text-pho-description mt-0.5 block min-w-0 truncate text-xs font-normal",
|
|
338
|
+
children: a
|
|
339
|
+
})]
|
|
340
|
+
})] });
|
|
341
|
+
return u !== void 0 ? /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(n, {
|
|
342
|
+
href: u,
|
|
343
|
+
"aria-current": c ? "page" : void 0,
|
|
344
|
+
...m,
|
|
345
|
+
onClick: (b) => {
|
|
346
|
+
f?.(b), b.defaultPrevented || x();
|
|
347
|
+
},
|
|
348
|
+
className: p,
|
|
349
|
+
...Q,
|
|
350
|
+
children: h
|
|
351
|
+
}) }) : /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(M.button, {
|
|
352
|
+
type: "button",
|
|
353
|
+
"aria-current": c ? "true" : void 0,
|
|
354
|
+
...m,
|
|
355
|
+
onClick: (b) => {
|
|
356
|
+
f?.(b), b.defaultPrevented || x();
|
|
357
|
+
},
|
|
358
|
+
className: p,
|
|
359
|
+
...Q,
|
|
360
|
+
children: h
|
|
361
|
+
}) });
|
|
362
|
+
}
|
|
363
|
+
function Ke({ className: t, children: r, ...a }) {
|
|
364
|
+
const { layout: l, pane: o, direction: c, swap: s, swapped: u } = E("Thread"), f = ee(), m = v("bg-pho-primary flex min-h-0 flex-1 flex-col", l === "default" && "min-w-80", l === "compact" && "min-w-0", l === "auto" && `min-w-0 ${A}:min-w-80`, !s && l === "auto" && o === "list" && "@max-2xl:hidden", t);
|
|
365
|
+
return s ? /* @__PURE__ */ e(ae, {
|
|
366
|
+
as: "section",
|
|
367
|
+
show: o === "thread",
|
|
368
|
+
swapped: u,
|
|
369
|
+
direction: c,
|
|
370
|
+
reduceMotion: f,
|
|
371
|
+
"aria-label": "Conversation",
|
|
372
|
+
"data-chat-thread": "",
|
|
373
|
+
className: m,
|
|
374
|
+
...a,
|
|
375
|
+
children: r
|
|
376
|
+
}) : /* @__PURE__ */ e("section", {
|
|
377
|
+
"aria-label": "Conversation",
|
|
378
|
+
"data-chat-thread": "",
|
|
379
|
+
className: m,
|
|
380
|
+
...a,
|
|
381
|
+
children: r
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function Be({ avatar: t, actions: r, backLabel: a = "Back to conversations", className: l, children: o, ...c }) {
|
|
385
|
+
const { layout: s, setPane: u } = E("Header");
|
|
386
|
+
return /* @__PURE__ */ y("header", {
|
|
387
|
+
"data-chat-header": "",
|
|
388
|
+
className: v("flex shrink-0 items-center gap-3 px-4 py-1.5", te, l),
|
|
389
|
+
...c,
|
|
390
|
+
children: [
|
|
391
|
+
s !== "default" && /* @__PURE__ */ e(D, {
|
|
392
|
+
variant: "ghost",
|
|
393
|
+
size: "sm",
|
|
394
|
+
shape: "circle",
|
|
395
|
+
svgOnly: !0,
|
|
396
|
+
"aria-label": a,
|
|
397
|
+
"data-chat-back": "",
|
|
398
|
+
className: v("-ml-1 shrink-0", s === "auto" && `${A}:hidden`),
|
|
399
|
+
onClick: () => u("list"),
|
|
400
|
+
children: /* @__PURE__ */ e(ye, {})
|
|
401
|
+
}),
|
|
402
|
+
t,
|
|
403
|
+
/* @__PURE__ */ e("div", {
|
|
404
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
405
|
+
children: o
|
|
406
|
+
}),
|
|
407
|
+
r != null && /* @__PURE__ */ e("div", {
|
|
408
|
+
className: "flex shrink-0 items-center gap-1",
|
|
409
|
+
children: r
|
|
410
|
+
})
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function Ge({ className: t, children: r, ...a }) {
|
|
415
|
+
return /* @__PURE__ */ e("h2", {
|
|
416
|
+
"data-chat-title": "",
|
|
417
|
+
className: v("text-pho-primary m-0 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 overflow-visible text-base font-medium", t),
|
|
418
|
+
...a,
|
|
419
|
+
children: r
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function qe({ className: t, ...r }) {
|
|
423
|
+
return /* @__PURE__ */ e("p", {
|
|
424
|
+
"data-chat-description": "",
|
|
425
|
+
className: v("text-pho-description m-0 min-w-0 truncate text-xs", t),
|
|
426
|
+
...r
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
var Je = 40;
|
|
430
|
+
function Qe({ hasEarlier: t = !1, loadingEarlier: r = !1, onLoadEarlier: a, earlierLabel: l = "Load earlier messages", className: o, children: c, ...s }) {
|
|
431
|
+
const u = _(null), f = _(null), m = _(!0), g = _(null);
|
|
432
|
+
W(() => {
|
|
433
|
+
const n = u.current, p = f.current;
|
|
434
|
+
if (!n || !p) return;
|
|
435
|
+
const x = () => {
|
|
436
|
+
const b = g.current;
|
|
437
|
+
if (b) {
|
|
438
|
+
g.current = null, n.scrollTop = n.scrollHeight - b.height + b.top;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
m.current && (n.scrollTop = n.scrollHeight);
|
|
442
|
+
};
|
|
443
|
+
if (x(), typeof ResizeObserver > "u") return;
|
|
444
|
+
const h = new ResizeObserver(x);
|
|
445
|
+
return h.observe(p), h.observe(n), () => h.disconnect();
|
|
446
|
+
}, []);
|
|
447
|
+
const w = () => {
|
|
448
|
+
const n = u.current;
|
|
449
|
+
n && (m.current = n.scrollHeight - n.scrollTop - n.clientHeight < Je);
|
|
450
|
+
}, i = () => {
|
|
451
|
+
const n = u.current;
|
|
452
|
+
n && (g.current = {
|
|
453
|
+
height: n.scrollHeight,
|
|
454
|
+
top: n.scrollTop
|
|
455
|
+
}), m.current = !1, a?.();
|
|
456
|
+
};
|
|
457
|
+
return /* @__PURE__ */ e("div", {
|
|
458
|
+
"data-chat-messages": "",
|
|
459
|
+
className: v("flex min-h-0 flex-1 flex-col [--pho-bubble-backdrop:var(--background-color-pho-primary)]", o),
|
|
460
|
+
...s,
|
|
461
|
+
children: /* @__PURE__ */ y(C.Root, {
|
|
462
|
+
className: "min-h-0 flex-1",
|
|
463
|
+
children: [/* @__PURE__ */ e(C.Viewport, {
|
|
464
|
+
ref: u,
|
|
465
|
+
onScroll: w,
|
|
466
|
+
children: /* @__PURE__ */ y(C.Content, {
|
|
467
|
+
ref: f,
|
|
468
|
+
style: { minWidth: 0 },
|
|
469
|
+
className: "flex min-h-full flex-col gap-1 p-4",
|
|
470
|
+
children: [t && /* @__PURE__ */ e("div", {
|
|
471
|
+
className: "flex justify-center",
|
|
472
|
+
children: /* @__PURE__ */ e(D, {
|
|
473
|
+
variant: "outlined",
|
|
474
|
+
size: "sm",
|
|
475
|
+
loading: r,
|
|
476
|
+
onClick: i,
|
|
477
|
+
children: l
|
|
478
|
+
})
|
|
479
|
+
}), c]
|
|
480
|
+
})
|
|
481
|
+
}), /* @__PURE__ */ e(C.Scrollbar, { children: /* @__PURE__ */ e(C.Thumb, {}) })]
|
|
482
|
+
})
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
function Ye({ className: t, children: r, ...a }) {
|
|
486
|
+
return /* @__PURE__ */ e("div", {
|
|
487
|
+
"data-chat-divider": "",
|
|
488
|
+
className: v("text-pho-description py-1 text-center text-xs", t),
|
|
489
|
+
...a,
|
|
490
|
+
children: r
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
function Ze({ className: t, ...r }) {
|
|
494
|
+
return /* @__PURE__ */ e("footer", {
|
|
495
|
+
"data-chat-footer": "",
|
|
496
|
+
className: v("shrink-0 px-4 py-3", t),
|
|
497
|
+
...r
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
var et = 200;
|
|
501
|
+
function tt({ value: t, onValueChange: r, onSend: a, placeholder: l = "Message", sending: o = !1, disabled: c = !1, canSend: s, prefix: u, meta: f, sendLabel: m = "Send", children: g, textareaRef: w, className: i, ...n }) {
|
|
502
|
+
const p = _(null), x = !o && !c && (s ?? t.trim().length > 0);
|
|
503
|
+
W(() => {
|
|
504
|
+
const d = p.current;
|
|
505
|
+
d && (d.style.height = "0px", d.style.height = `${Math.min(d.scrollHeight, et)}px`);
|
|
506
|
+
}, [t]);
|
|
507
|
+
const h = (d) => {
|
|
508
|
+
d.preventDefault(), x && a();
|
|
509
|
+
}, b = (d) => {
|
|
510
|
+
d.key === "Enter" && !d.shiftKey && !d.nativeEvent.isComposing && (d.preventDefault(), x && a());
|
|
511
|
+
};
|
|
512
|
+
return /* @__PURE__ */ y("form", {
|
|
513
|
+
"aria-label": "Message composer",
|
|
514
|
+
"data-chat-composer": "",
|
|
515
|
+
onSubmit: h,
|
|
516
|
+
className: v("rounded-base bg-pho-primary ring-pho-primary focus-within:ring-pho-brand ring-1 transition-shadow duration-100 ease-linear ring-inset focus-within:ring-2", c && "opacity-50", i),
|
|
517
|
+
...n,
|
|
518
|
+
children: [
|
|
519
|
+
g,
|
|
520
|
+
/* @__PURE__ */ e("textarea", {
|
|
521
|
+
ref: (d) => {
|
|
522
|
+
p.current = d, typeof w == "function" ? w(d) : w && (w.current = d);
|
|
523
|
+
},
|
|
524
|
+
value: t,
|
|
525
|
+
onChange: (d) => r(d.target.value),
|
|
526
|
+
onKeyDown: b,
|
|
527
|
+
rows: 1,
|
|
528
|
+
placeholder: l,
|
|
529
|
+
"aria-label": "Message",
|
|
530
|
+
disabled: c,
|
|
531
|
+
readOnly: o,
|
|
532
|
+
className: "text-pho-primary placeholder:text-pho-placeholder m-0 block w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none disabled:cursor-not-allowed"
|
|
533
|
+
}),
|
|
534
|
+
/* @__PURE__ */ y("div", {
|
|
535
|
+
className: "flex items-center gap-2 px-2 pb-2",
|
|
536
|
+
children: [
|
|
537
|
+
u,
|
|
538
|
+
/* @__PURE__ */ e("p", {
|
|
539
|
+
className: "text-pho-description m-0 min-w-0 flex-1 truncate text-xs",
|
|
540
|
+
children: f
|
|
541
|
+
}),
|
|
542
|
+
/* @__PURE__ */ e(D, {
|
|
543
|
+
type: "submit",
|
|
544
|
+
size: "sm",
|
|
545
|
+
shape: "circle",
|
|
546
|
+
svgOnly: !0,
|
|
547
|
+
"aria-label": m,
|
|
548
|
+
disabled: !x,
|
|
549
|
+
loading: o,
|
|
550
|
+
children: /* @__PURE__ */ e(Ce, {})
|
|
551
|
+
})
|
|
552
|
+
]
|
|
553
|
+
})
|
|
554
|
+
]
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
function rt({ className: t, size: r = "sm", ...a }) {
|
|
558
|
+
return /* @__PURE__ */ e("div", {
|
|
559
|
+
"data-chat-empty": "",
|
|
560
|
+
className: v("flex flex-1 flex-col items-center justify-center px-6 py-8", t),
|
|
561
|
+
children: /* @__PURE__ */ e(he, {
|
|
562
|
+
size: r,
|
|
563
|
+
...a
|
|
564
|
+
})
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function at({ rows: t = 5 }) {
|
|
568
|
+
return /* @__PURE__ */ e("div", {
|
|
569
|
+
"aria-hidden": !0,
|
|
570
|
+
"data-chat-conversations-loading": "",
|
|
571
|
+
className: "flex flex-col gap-0.5",
|
|
572
|
+
children: Array.from({ length: t }, (r, a) => /* @__PURE__ */ y("div", {
|
|
573
|
+
className: "flex items-center gap-3 px-2 py-2.5",
|
|
574
|
+
children: [/* @__PURE__ */ e(k, { className: "size-8 shrink-0 rounded-full" }), /* @__PURE__ */ y("div", {
|
|
575
|
+
className: "min-w-0 flex-1",
|
|
576
|
+
children: [/* @__PURE__ */ y("div", {
|
|
577
|
+
className: "flex items-center justify-between gap-2",
|
|
578
|
+
children: [/* @__PURE__ */ e(k, { className: "h-3.5 w-32" }), /* @__PURE__ */ e(k, { className: "h-2.5 w-8" })]
|
|
579
|
+
}), /* @__PURE__ */ e(k, { className: "mt-2 h-2.5 w-44" })]
|
|
580
|
+
})]
|
|
581
|
+
}, a))
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
function nt() {
|
|
585
|
+
return /* @__PURE__ */ y("div", {
|
|
586
|
+
"aria-hidden": !0,
|
|
587
|
+
"data-chat-messages-loading": "",
|
|
588
|
+
className: "flex flex-col gap-3",
|
|
589
|
+
children: [
|
|
590
|
+
/* @__PURE__ */ e(k, { className: "rounded-base h-10 w-1/2 self-start" }),
|
|
591
|
+
/* @__PURE__ */ e(k, { className: "rounded-base h-10 w-2/5 self-end" }),
|
|
592
|
+
/* @__PURE__ */ e(k, { className: "rounded-base h-16 w-3/5 self-start" })
|
|
593
|
+
]
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
var gt = {
|
|
597
|
+
Root: ze,
|
|
598
|
+
List: De,
|
|
599
|
+
Search: $e,
|
|
600
|
+
Conversations: He,
|
|
601
|
+
ConversationList: Ve,
|
|
602
|
+
Conversation: je,
|
|
603
|
+
Thread: Ke,
|
|
604
|
+
Header: Be,
|
|
605
|
+
Title: Ge,
|
|
606
|
+
Description: qe,
|
|
607
|
+
Messages: Qe,
|
|
608
|
+
Divider: Ye,
|
|
609
|
+
Footer: Ze,
|
|
610
|
+
Composer: tt,
|
|
611
|
+
Empty: rt,
|
|
612
|
+
ConversationsLoading: at,
|
|
613
|
+
MessagesLoading: nt
|
|
614
|
+
};
|
|
615
|
+
export {
|
|
616
|
+
gt as t
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
//# sourceMappingURL=chat-DUqWlXqt.js.map
|