fi-glass 1.1.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/LICENSE +77 -0
- package/README.md +162 -0
- package/dist/agent/index.d.ts +399 -0
- package/dist/agent/index.js +1979 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/composer/index.d.ts +57 -0
- package/dist/composer/index.js +112 -0
- package/dist/composer/index.js.map +1 -0
- package/dist/conversation/index.d.ts +80 -0
- package/dist/conversation/index.js +207 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/glass-theme-D-leVuKb.d.ts +19 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4316 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/index.d.ts +213 -0
- package/dist/messages/index.js +337 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/persona-selector/index.d.ts +54 -0
- package/dist/persona-selector/index.js +215 -0
- package/dist/persona-selector/index.js.map +1 -0
- package/dist/shell/index.d.ts +429 -0
- package/dist/shell/index.js +1566 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/theme/index.d.ts +58 -0
- package/dist/theme/index.js +38 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/voice/index.d.ts +790 -0
- package/dist/voice/index.js +2591 -0
- package/dist/voice/index.js.map +1 -0
- package/package.json +85 -0
- package/src/theme/glass-chat-preset.ts +74 -0
- package/src/theme/glass-chat.css +217 -0
- package/src/theme/glass-theme.ts +26 -0
- package/src/theme/glass.css +27 -0
- package/src/theme/index.css +3 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/tokens.css +13 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/persona-selector/PersonaSelector.tsx
|
|
4
|
+
import {
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useId,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import { createPortal } from "react-dom";
|
|
12
|
+
import { ChevronDown, Check } from "lucide-react";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var TRIGGER_DEFAULT = "flex w-full items-center justify-between rounded-md border border-slate-700 bg-slate-800 px-3 py-2 text-sm transition-colors";
|
|
15
|
+
var CONTENT_BASE = "rounded-md border border-slate-700 bg-slate-800 p-1 shadow-lg";
|
|
16
|
+
var ITEM_BASE = "cursor-pointer rounded-lg px-3 py-2 text-left transition-all";
|
|
17
|
+
function PersonaSelector({
|
|
18
|
+
personas,
|
|
19
|
+
selected,
|
|
20
|
+
onSelect,
|
|
21
|
+
getPersonaId,
|
|
22
|
+
loading = false,
|
|
23
|
+
getPersonaLabel,
|
|
24
|
+
getPersonaDescription,
|
|
25
|
+
renderPersonaIcon,
|
|
26
|
+
renderPersonaBadge,
|
|
27
|
+
renderPersonaMeta,
|
|
28
|
+
renderTriggerValue,
|
|
29
|
+
renderHeader,
|
|
30
|
+
renderFooter,
|
|
31
|
+
renderLoading,
|
|
32
|
+
placeholder = "Seleccionar...",
|
|
33
|
+
className = "relative",
|
|
34
|
+
triggerClassName,
|
|
35
|
+
contentClassName = "",
|
|
36
|
+
ariaLabel
|
|
37
|
+
}) {
|
|
38
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
39
|
+
const [position, setPosition] = useState({ top: 0, left: 0, width: 0 });
|
|
40
|
+
const triggerRef = useRef(null);
|
|
41
|
+
const contentRef = useRef(null);
|
|
42
|
+
const reactId = useId();
|
|
43
|
+
const triggerId = `persona-trigger-${reactId}`;
|
|
44
|
+
const contentId = `persona-content-${reactId}`;
|
|
45
|
+
const close = useCallback(() => setIsOpen(false), []);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!isOpen) return;
|
|
48
|
+
const handle = (event) => {
|
|
49
|
+
const target = event.target;
|
|
50
|
+
if (triggerRef.current?.contains(target) || contentRef.current?.contains(target)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setIsOpen(false);
|
|
54
|
+
};
|
|
55
|
+
document.addEventListener("mousedown", handle);
|
|
56
|
+
return () => document.removeEventListener("mousedown", handle);
|
|
57
|
+
}, [isOpen]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!isOpen) return;
|
|
60
|
+
const trigger = triggerRef.current;
|
|
61
|
+
if (!trigger) return;
|
|
62
|
+
const rect = trigger.getBoundingClientRect();
|
|
63
|
+
const baseTop = rect.bottom + window.scrollY + 4;
|
|
64
|
+
const left = rect.left + window.scrollX;
|
|
65
|
+
const width = rect.width;
|
|
66
|
+
setPosition({ top: baseTop, left, width });
|
|
67
|
+
const raf = requestAnimationFrame(() => {
|
|
68
|
+
const el = contentRef.current;
|
|
69
|
+
if (!el) return;
|
|
70
|
+
const height = el.offsetHeight;
|
|
71
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
72
|
+
if (spaceBelow < height && rect.top > height) {
|
|
73
|
+
setPosition({ top: rect.top + window.scrollY - height - 4, left, width });
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return () => cancelAnimationFrame(raf);
|
|
77
|
+
}, [isOpen]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!isOpen) return;
|
|
80
|
+
const raf = requestAnimationFrame(() => {
|
|
81
|
+
const content2 = contentRef.current;
|
|
82
|
+
if (!content2) return;
|
|
83
|
+
const sel = content2.querySelector(
|
|
84
|
+
'[role="option"][aria-selected="true"]'
|
|
85
|
+
);
|
|
86
|
+
const first = content2.querySelector('[role="option"]');
|
|
87
|
+
(sel || first)?.focus();
|
|
88
|
+
});
|
|
89
|
+
return () => cancelAnimationFrame(raf);
|
|
90
|
+
}, [isOpen]);
|
|
91
|
+
const handleOptionKeyDown = (event) => {
|
|
92
|
+
const key = event.key;
|
|
93
|
+
if (key === "Enter" || key === " ") {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
event.currentTarget.click();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (key === "Escape") {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
setIsOpen(false);
|
|
101
|
+
triggerRef.current?.focus();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
const root = event.currentTarget.closest(
|
|
107
|
+
"[data-persona-content]"
|
|
108
|
+
);
|
|
109
|
+
const options = root ? Array.from(root.querySelectorAll('[role="option"]')) : [];
|
|
110
|
+
if (!options.length) return;
|
|
111
|
+
const idx = options.indexOf(event.currentTarget);
|
|
112
|
+
const nextIdx = key === "ArrowDown" ? (idx + 1) % options.length : (idx - 1 + options.length) % options.length;
|
|
113
|
+
options[nextIdx]?.focus();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
if (loading) {
|
|
117
|
+
return renderLoading ? /* @__PURE__ */ jsx(Fragment, { children: renderLoading() }) : /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", children: "Cargando..." });
|
|
118
|
+
}
|
|
119
|
+
const selectedPersona = personas.find((p) => getPersonaId(p) === selected);
|
|
120
|
+
const triggerInner = renderTriggerValue ? renderTriggerValue(selectedPersona, isOpen) : selectedPersona && getPersonaLabel ? getPersonaLabel(selectedPersona) : placeholder;
|
|
121
|
+
const content = isOpen ? /* @__PURE__ */ jsxs(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
ref: contentRef,
|
|
125
|
+
id: contentId,
|
|
126
|
+
role: "listbox",
|
|
127
|
+
"aria-labelledby": triggerId,
|
|
128
|
+
tabIndex: -1,
|
|
129
|
+
"data-persona-content": true,
|
|
130
|
+
style: {
|
|
131
|
+
position: "fixed",
|
|
132
|
+
top: `${position.top}px`,
|
|
133
|
+
left: `${position.left}px`,
|
|
134
|
+
minWidth: `${position.width}px`,
|
|
135
|
+
zIndex: 9999
|
|
136
|
+
},
|
|
137
|
+
className: `${CONTENT_BASE} ${contentClassName}`.trim(),
|
|
138
|
+
children: [
|
|
139
|
+
renderHeader?.({ count: personas.length }),
|
|
140
|
+
personas.map((persona) => {
|
|
141
|
+
const id = getPersonaId(persona);
|
|
142
|
+
const isSelected = id === selected;
|
|
143
|
+
const ctx = { selected: isSelected };
|
|
144
|
+
const badge = renderPersonaBadge?.(persona, ctx);
|
|
145
|
+
const meta = renderPersonaMeta?.(persona);
|
|
146
|
+
const description = getPersonaDescription?.(persona);
|
|
147
|
+
return /* @__PURE__ */ jsxs(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
role: "option",
|
|
151
|
+
"aria-selected": isSelected,
|
|
152
|
+
tabIndex: 0,
|
|
153
|
+
onClick: () => {
|
|
154
|
+
onSelect(id);
|
|
155
|
+
setIsOpen(false);
|
|
156
|
+
},
|
|
157
|
+
onKeyDown: handleOptionKeyDown,
|
|
158
|
+
className: `${ITEM_BASE} hover:bg-slate-700/60 ${isSelected ? "bg-purple-500/20 border-purple-500/50 border" : "bg-slate-700/30 border border-transparent"}`,
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
161
|
+
renderPersonaIcon?.(persona, ctx),
|
|
162
|
+
/* @__PURE__ */ jsx(
|
|
163
|
+
"span",
|
|
164
|
+
{
|
|
165
|
+
className: `font-medium text-sm ${isSelected ? "text-purple-200" : "text-slate-200"}`,
|
|
166
|
+
children: getPersonaLabel?.(persona) ?? id
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
isSelected && /* @__PURE__ */ jsx(Check, { className: "w-4 h-4 fi-text-purple ml-auto" })
|
|
170
|
+
] }),
|
|
171
|
+
description && /* @__PURE__ */ jsx("p", { className: "fi-text-xs mb-2 line-clamp-2", children: description }),
|
|
172
|
+
(badge || meta) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
173
|
+
badge,
|
|
174
|
+
meta
|
|
175
|
+
] })
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
id
|
|
179
|
+
);
|
|
180
|
+
}),
|
|
181
|
+
renderFooter?.({ close })
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
) : null;
|
|
185
|
+
return /* @__PURE__ */ jsxs("div", { className, "data-persona-root": true, children: [
|
|
186
|
+
/* @__PURE__ */ jsxs(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
ref: triggerRef,
|
|
190
|
+
id: triggerId,
|
|
191
|
+
type: "button",
|
|
192
|
+
onClick: () => setIsOpen((v) => !v),
|
|
193
|
+
"aria-haspopup": "listbox",
|
|
194
|
+
"aria-expanded": isOpen,
|
|
195
|
+
"aria-controls": isOpen ? contentId : void 0,
|
|
196
|
+
"aria-label": ariaLabel,
|
|
197
|
+
className: triggerClassName ?? TRIGGER_DEFAULT,
|
|
198
|
+
children: [
|
|
199
|
+
triggerInner,
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
ChevronDown,
|
|
202
|
+
{
|
|
203
|
+
className: `h-4 w-4 transition-transform ${isOpen ? "rotate-180" : ""}`
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
content && createPortal(content, document.body)
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
PersonaSelector
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/persona-selector/PersonaSelector.tsx"],"sourcesContent":["'use client';\n\n/**\n * fi-glass · PersonaSelector — Californio (element 98), configurable optional.\n *\n * A generic, accessible single-select dropdown for choosing a \"persona\" (or any\n * keyed entity). fi-glass OWNS the dropdown behavior — open/close, click-outside,\n * portal positioning with flip-up, keyboard navigation (Arrow/Enter/Space),\n * focus-on-open, and full ARIA (listbox/option/aria-selected/aria-expanded). That\n * behavior is generic, not domain — it belongs to the framework, the same way the\n * clipboard logic belongs to <CopyButton>.\n *\n * The mechanics here are LIFTED from aurity's proven `components/ui/select.tsx`\n * (the same code, battle-tested in production), decoupled from its two domain\n * deps: the `Button` component (→ plain <button>) and `select-configs` badge\n * palette (→ injected via the renderPersonaBadge slot). No new accessibility\n * dependency is added — the monorepo ships none, and a downloadable framework\n * should not force Radix/React-Aria onto every consumer (og118 charter).\n *\n * DOMAIN stays in the app, injected by slot:\n * - icons, badges, model metadata → render* slots (each gets `{ selected }`)\n * - the persona's label/description → getPersonaLabel / getPersonaDescription\n * - the header copy + the \"edit personas\" link → renderHeader / renderFooter\n *\n * CONFIGURABILITY (fire test): an app restyles via *ClassName props, relabels via\n * the render slots, or drops a section (omit the slot) — all without touching\n * fi-glass. `<T>` is opaque; the only thing fi-glass reads is the id via\n * getPersonaId.\n */\n\nimport {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown, Check } from 'lucide-react';\n\nexport interface PersonaSlotContext {\n /** Whether the persona this slot renders is the selected one. */\n selected: boolean;\n}\n\nexport interface PersonaSelectorProps<T> {\n /** Available personas (opaque to fi-glass). */\n personas: T[];\n /** Currently selected persona id. */\n selected: string;\n /** Called with the chosen persona id. */\n onSelect: (personaId: string) => void;\n /** How to read the stable id off a persona. */\n getPersonaId: (persona: T) => string;\n /** Loading state — renders renderLoading() (or a minimal default). */\n loading?: boolean;\n\n // ── Item slots (domain) ──────────────────────────────────────────────────\n /** The persona label shown in the option row. */\n getPersonaLabel?: (persona: T) => ReactNode;\n /** Optional description line under the label. */\n getPersonaDescription?: (persona: T) => ReactNode;\n /** Leading icon for the option row. Receives `{ selected }` for state color. */\n renderPersonaIcon?: (persona: T, ctx: PersonaSlotContext) => ReactNode;\n /** Badge (e.g. model · voice) for the option row. */\n renderPersonaBadge?: (persona: T, ctx: PersonaSlotContext) => ReactNode;\n /** Metadata chips row (e.g. temp / tokens). */\n renderPersonaMeta?: (persona: T) => ReactNode;\n\n // ── Container slots (domain) ─────────────────────────────────────────────\n /** The trigger's inner content (before the chevron). Defaults to placeholder. */\n renderTriggerValue?: (selected: T | undefined, isOpen: boolean) => ReactNode;\n /** Dropdown header (e.g. title + count). */\n renderHeader?: (ctx: { count: number }) => ReactNode;\n /** Dropdown footer (e.g. an \"edit personas\" link). `close()` shuts the menu. */\n renderFooter?: (ctx: { close: () => void }) => ReactNode;\n /** Loading-state renderer (default: minimal text). */\n renderLoading?: () => ReactNode;\n\n /** Trigger content when nothing is selected and no renderTriggerValue given. */\n placeholder?: ReactNode;\n\n // ── Styling hooks (app keeps its CSS) ────────────────────────────────────\n /** Root wrapper class. */\n className?: string;\n /** Trigger button class — pass the exact legacy string for byte-identical look. */\n triggerClassName?: string;\n /** Extra class appended to the portalled content panel. */\n contentClassName?: string;\n /** Accessible label for the trigger. */\n ariaLabel?: string;\n}\n\nconst TRIGGER_DEFAULT =\n 'flex w-full items-center justify-between rounded-md border border-slate-700 bg-slate-800 px-3 py-2 text-sm transition-colors';\nconst CONTENT_BASE =\n 'rounded-md border border-slate-700 bg-slate-800 p-1 shadow-lg';\nconst ITEM_BASE = 'cursor-pointer rounded-lg px-3 py-2 text-left transition-all';\n\nexport function PersonaSelector<T>({\n personas,\n selected,\n onSelect,\n getPersonaId,\n loading = false,\n getPersonaLabel,\n getPersonaDescription,\n renderPersonaIcon,\n renderPersonaBadge,\n renderPersonaMeta,\n renderTriggerValue,\n renderHeader,\n renderFooter,\n renderLoading,\n placeholder = 'Seleccionar...',\n className = 'relative',\n triggerClassName,\n contentClassName = '',\n ariaLabel,\n}: PersonaSelectorProps<T>) {\n const [isOpen, setIsOpen] = useState(false);\n const [position, setPosition] = useState({ top: 0, left: 0, width: 0 });\n const triggerRef = useRef<HTMLButtonElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const reactId = useId();\n const triggerId = `persona-trigger-${reactId}`;\n const contentId = `persona-content-${reactId}`;\n\n const close = useCallback(() => setIsOpen(false), []);\n\n // Close on outside click (mousedown, matches aurity's Select).\n useEffect(() => {\n if (!isOpen) return;\n const handle = (event: MouseEvent) => {\n const target = event.target as Node;\n if (\n triggerRef.current?.contains(target) ||\n contentRef.current?.contains(target)\n ) {\n return;\n }\n setIsOpen(false);\n };\n document.addEventListener('mousedown', handle);\n return () => document.removeEventListener('mousedown', handle);\n }, [isOpen]);\n\n // Portal positioning with flip-up when there's no room below.\n useEffect(() => {\n if (!isOpen) return;\n const trigger = triggerRef.current;\n if (!trigger) return;\n\n const rect = trigger.getBoundingClientRect();\n const baseTop = rect.bottom + window.scrollY + 4;\n const left = rect.left + window.scrollX;\n const width = rect.width;\n setPosition({ top: baseTop, left, width });\n\n const raf = requestAnimationFrame(() => {\n const el = contentRef.current;\n if (!el) return;\n const height = el.offsetHeight;\n const spaceBelow = window.innerHeight - rect.bottom;\n if (spaceBelow < height && rect.top > height) {\n setPosition({ top: rect.top + window.scrollY - height - 4, left, width });\n }\n });\n return () => cancelAnimationFrame(raf);\n }, [isOpen]);\n\n // Focus the selected (or first) option when the menu opens.\n useEffect(() => {\n if (!isOpen) return;\n const raf = requestAnimationFrame(() => {\n const content = contentRef.current;\n if (!content) return;\n const sel = content.querySelector(\n '[role=\"option\"][aria-selected=\"true\"]',\n ) as HTMLElement | null;\n const first = content.querySelector('[role=\"option\"]') as HTMLElement | null;\n (sel || first)?.focus();\n });\n return () => cancelAnimationFrame(raf);\n }, [isOpen]);\n\n const handleOptionKeyDown = (event: React.KeyboardEvent) => {\n const key = event.key;\n if (key === 'Enter' || key === ' ') {\n event.preventDefault();\n (event.currentTarget as HTMLElement).click();\n return;\n }\n if (key === 'Escape') {\n event.preventDefault();\n setIsOpen(false);\n triggerRef.current?.focus();\n return;\n }\n if (key === 'ArrowDown' || key === 'ArrowUp') {\n event.preventDefault();\n const root = (event.currentTarget as HTMLElement).closest(\n '[data-persona-content]',\n ) as HTMLElement | null;\n const options = root\n ? (Array.from(root.querySelectorAll('[role=\"option\"]')) as HTMLElement[])\n : [];\n if (!options.length) return;\n const idx = options.indexOf(event.currentTarget as HTMLElement);\n const nextIdx =\n key === 'ArrowDown'\n ? (idx + 1) % options.length\n : (idx - 1 + options.length) % options.length;\n options[nextIdx]?.focus();\n }\n };\n\n if (loading) {\n return renderLoading ? (\n <>{renderLoading()}</>\n ) : (\n <div role=\"status\" aria-live=\"polite\">\n Cargando...\n </div>\n );\n }\n\n const selectedPersona = personas.find((p) => getPersonaId(p) === selected);\n\n const triggerInner = renderTriggerValue\n ? renderTriggerValue(selectedPersona, isOpen)\n : selectedPersona && getPersonaLabel\n ? getPersonaLabel(selectedPersona)\n : placeholder;\n\n const content = isOpen ? (\n <div\n ref={contentRef}\n id={contentId}\n role=\"listbox\"\n aria-labelledby={triggerId}\n tabIndex={-1}\n data-persona-content\n style={{\n position: 'fixed',\n top: `${position.top}px`,\n left: `${position.left}px`,\n minWidth: `${position.width}px`,\n zIndex: 9999,\n }}\n className={`${CONTENT_BASE} ${contentClassName}`.trim()}\n >\n {renderHeader?.({ count: personas.length })}\n\n {personas.map((persona) => {\n const id = getPersonaId(persona);\n const isSelected = id === selected;\n const ctx: PersonaSlotContext = { selected: isSelected };\n const badge = renderPersonaBadge?.(persona, ctx);\n const meta = renderPersonaMeta?.(persona);\n const description = getPersonaDescription?.(persona);\n\n return (\n <div\n key={id}\n role=\"option\"\n aria-selected={isSelected}\n tabIndex={0}\n onClick={() => {\n onSelect(id);\n setIsOpen(false);\n }}\n onKeyDown={handleOptionKeyDown}\n className={`${ITEM_BASE} hover:bg-slate-700/60 ${\n isSelected\n ? 'bg-purple-500/20 border-purple-500/50 border'\n : 'bg-slate-700/30 border border-transparent'\n }`}\n >\n <div className=\"flex items-center gap-2 mb-1\">\n {renderPersonaIcon?.(persona, ctx)}\n <span\n className={`font-medium text-sm ${\n isSelected ? 'text-purple-200' : 'text-slate-200'\n }`}\n >\n {getPersonaLabel?.(persona) ?? id}\n </span>\n {isSelected && <Check className=\"w-4 h-4 fi-text-purple ml-auto\" />}\n </div>\n\n {description && (\n <p className=\"fi-text-xs mb-2 line-clamp-2\">{description}</p>\n )}\n\n {(badge || meta) && (\n <div className=\"flex items-center gap-2 flex-wrap\">\n {badge}\n {meta}\n </div>\n )}\n </div>\n );\n })}\n\n {renderFooter?.({ close })}\n </div>\n ) : null;\n\n return (\n <div className={className} data-persona-root>\n <button\n ref={triggerRef}\n id={triggerId}\n type=\"button\"\n onClick={() => setIsOpen((v) => !v)}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? contentId : undefined}\n aria-label={ariaLabel}\n className={triggerClassName ?? TRIGGER_DEFAULT}\n >\n {triggerInner}\n <ChevronDown\n className={`h-4 w-4 transition-transform ${isOpen ? 'rotate-180' : ''}`}\n />\n </button>\n {content && createPortal(content, document.body)}\n </div>\n );\n}\n"],"mappings":";AA8BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAC7B,SAAS,aAAa,aAAa;AAqL7B,wBA4DM,YA5DN;AA9HN,IAAM,kBACJ;AACF,IAAM,eACJ;AACF,IAAM,YAAY;AAEX,SAAS,gBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,YAAY;AAAA,EACZ;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,GAA4B;AAC1B,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAC1C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;AACtE,QAAM,aAAa,OAA0B,IAAI;AACjD,QAAM,aAAa,OAAuB,IAAI;AAC9C,QAAM,UAAU,MAAM;AACtB,QAAM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YAnCG;AAAA,UAqCP;AAAA,QAEJ,CAAC;AAAA,QAEA,eAAe,EAAE,MAAM,CAAC;AAAA;AAAA;AAAA,EAC3B,IACE;AAEJ,SACE,qBAAC,SAAI,WAAsB,qBAAiB,MAC1C;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,IAAI;AAAA,QACJ,MAAK;AAAA,QACL,SAAS,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAAA,QAClC,iBAAc;AAAA,QACd,iBAAe;AAAA,QACf,iBAAe,SAAS,YAAY;AAAA,QACpC,cAAY;AAAA,QACZ,WAAW,oBAAoB;AAAA,QAE9B;AAAA;AAAA,UACD;AAAA,YAAC;AAAA;AAAA,cACC,WAAW,gCAAgC,SAAS,eAAe,EAAE;AAAA;AAAA,UACvE;AAAA;AAAA;AAAA,IACF;AAAA,IACC,WAAW,aAAa,SAAS,SAAS,IAAI;AAAA,KACjD;AAEJ;","names":["content"]}
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ChatMessage, ChatHook } from '@free-intelligence/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* fi-glass · shell config — the ChatConfig contract the shell renders against.
|
|
7
|
+
*
|
|
8
|
+
* Copied (shape-for-shape) from aurity's `config/chat.config.ts` so the app can
|
|
9
|
+
* pass its own ChatConfig into <ChatWidget config={…}> with zero friction
|
|
10
|
+
* (TypeScript checks structurally). The shell only ever reads `title`,
|
|
11
|
+
* `subtitle`, `theme.background.header` and `behavior.showThinking`; the rest of
|
|
12
|
+
* the shape is kept identical so the default is complete and the app's superset
|
|
13
|
+
* stays assignable. Persona styles are NOT here — they belong to the message
|
|
14
|
+
* render layer (aurity domain), not the shell skeleton.
|
|
15
|
+
*/
|
|
16
|
+
interface ChatTheme {
|
|
17
|
+
background: {
|
|
18
|
+
header: string;
|
|
19
|
+
body: string;
|
|
20
|
+
input: string;
|
|
21
|
+
};
|
|
22
|
+
border: {
|
|
23
|
+
main: string;
|
|
24
|
+
input: string;
|
|
25
|
+
bubble: string;
|
|
26
|
+
};
|
|
27
|
+
text: {
|
|
28
|
+
primary: string;
|
|
29
|
+
secondary: string;
|
|
30
|
+
muted: string;
|
|
31
|
+
accent: string;
|
|
32
|
+
};
|
|
33
|
+
accent: {
|
|
34
|
+
from: string;
|
|
35
|
+
to: string;
|
|
36
|
+
};
|
|
37
|
+
shadow: string;
|
|
38
|
+
timestamp: {
|
|
39
|
+
text: string;
|
|
40
|
+
tooltip: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface ChatBehavior {
|
|
44
|
+
autoScroll: boolean;
|
|
45
|
+
showTyping: boolean;
|
|
46
|
+
groupMessages: boolean;
|
|
47
|
+
groupThresholdMinutes: number;
|
|
48
|
+
showDayDividers: boolean;
|
|
49
|
+
animateEntrance: boolean;
|
|
50
|
+
maxMessages: number;
|
|
51
|
+
inputPlaceholder: string;
|
|
52
|
+
sendButtonLabel?: string;
|
|
53
|
+
enableReactions: boolean;
|
|
54
|
+
enableReadReceipts: boolean;
|
|
55
|
+
enableThinking: boolean;
|
|
56
|
+
showThinking: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface TimestampConfig {
|
|
59
|
+
show: boolean;
|
|
60
|
+
format: 'relative' | 'absolute' | 'smart';
|
|
61
|
+
showTooltip: boolean;
|
|
62
|
+
relativeThreshold: number;
|
|
63
|
+
showSeconds: boolean;
|
|
64
|
+
position: 'top' | 'bottom' | 'inline';
|
|
65
|
+
updateInterval?: number;
|
|
66
|
+
}
|
|
67
|
+
interface AnimationConfig {
|
|
68
|
+
entrance: {
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
duration: string;
|
|
71
|
+
easing: string;
|
|
72
|
+
};
|
|
73
|
+
typing: {
|
|
74
|
+
dotDuration: string;
|
|
75
|
+
dotDelay: string;
|
|
76
|
+
};
|
|
77
|
+
scroll: {
|
|
78
|
+
behavior: 'smooth' | 'auto';
|
|
79
|
+
duration: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
interface ChatConfig {
|
|
83
|
+
title: string;
|
|
84
|
+
subtitle?: string;
|
|
85
|
+
theme: ChatTheme;
|
|
86
|
+
behavior: ChatBehavior;
|
|
87
|
+
timestamp: TimestampConfig;
|
|
88
|
+
animation: AnimationConfig;
|
|
89
|
+
footer?: string;
|
|
90
|
+
dimensions?: {
|
|
91
|
+
width: string;
|
|
92
|
+
height: string;
|
|
93
|
+
minHeight?: string;
|
|
94
|
+
maxHeight?: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
declare const defaultTheme: ChatTheme;
|
|
98
|
+
declare const defaultBehavior: ChatBehavior;
|
|
99
|
+
declare const defaultTimestampConfig: TimestampConfig;
|
|
100
|
+
declare const defaultAnimationConfig: AnimationConfig;
|
|
101
|
+
/** Neutral default — apps inject their own ChatConfig and only fall back here. */
|
|
102
|
+
declare const defaultChatConfig: ChatConfig;
|
|
103
|
+
/** Merge a partial app config over the fi-glass default (one level deep on the nested groups). */
|
|
104
|
+
declare function mergeChatConfig(custom?: Partial<ChatConfig>): ChatConfig;
|
|
105
|
+
interface ChatBreakpoints {
|
|
106
|
+
mobile: string;
|
|
107
|
+
tablet: string;
|
|
108
|
+
desktop: string;
|
|
109
|
+
}
|
|
110
|
+
declare const CHAT_BREAKPOINTS: ChatBreakpoints;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* fi-glass · shell types — the dependency-inverted ChatWidget contract.
|
|
114
|
+
*
|
|
115
|
+
* The shell consumes core's `ChatHook` (the conversation spine) and receives
|
|
116
|
+
* everything domain-shaped as props or slots: auth (`user`/`isAuthenticated`/
|
|
117
|
+
* `onLogin`), navigation (`onNavigate`, a TYPED union — not next/link), the
|
|
118
|
+
* persona selector / history / messages (React-node SLOTS the app fills), and
|
|
119
|
+
* the voice + file-upload state (their hooks live in the app). fi-glass NEVER
|
|
120
|
+
* imports useAuth / useFIConversation / usePersonas / next/* / @/components/ui/*.
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
/** View modes handled by ChatWidgetContainer. */
|
|
124
|
+
type ChatViewMode = 'normal' | 'fullscreen' | 'dense' | 'minimized' | 'expanded';
|
|
125
|
+
/** Response verbosity preference (app-owned, surfaced in the toolbar). */
|
|
126
|
+
type ResponseMode = 'explanatory' | 'concise';
|
|
127
|
+
/** Persona id — opaque string, resolved by the app's persona registry. */
|
|
128
|
+
type PersonaType = string;
|
|
129
|
+
/** Typed navigation destinations — replaces the 3 hardcoded next/link hrefs. */
|
|
130
|
+
type ChatNavDest = 'chat' | 'downloads' | 'personas';
|
|
131
|
+
/** Upload lifecycle the file-preview renders against (state owned by the app). */
|
|
132
|
+
type UploadStatus = 'selecting' | 'uploading' | 'pending_instructions' | 'processing' | 'indexed' | 'error';
|
|
133
|
+
/** Voice recorder snapshot the toolbar's mic button renders against. */
|
|
134
|
+
interface VoiceRecordingState {
|
|
135
|
+
isRecording: boolean;
|
|
136
|
+
isTranscribing: boolean;
|
|
137
|
+
audioLevel: number;
|
|
138
|
+
isSilent: boolean;
|
|
139
|
+
recordingTime: number;
|
|
140
|
+
}
|
|
141
|
+
/** Streaming snapshot passed through to the messages slot. */
|
|
142
|
+
interface ShellStreamingState {
|
|
143
|
+
status: 'idle' | 'streaming' | 'complete' | 'error';
|
|
144
|
+
content: string;
|
|
145
|
+
thinking: string;
|
|
146
|
+
isStreaming: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* ChatWidget props — generic over the message type (`TMessage`, the app's
|
|
150
|
+
* FIMessage) and the custom-slot node type (`TNode`) the ChatHook is keyed on.
|
|
151
|
+
*/
|
|
152
|
+
interface ChatWidgetProps<TMessage = ChatMessage, TNode = unknown> {
|
|
153
|
+
/** REQUIRED — the conversation hook. No internal default. */
|
|
154
|
+
chatHook: ChatHook<TMessage, TNode>;
|
|
155
|
+
/** App ChatConfig (merged over the fi-glass neutral default). */
|
|
156
|
+
config?: Partial<ChatConfig>;
|
|
157
|
+
user?: {
|
|
158
|
+
sub?: string;
|
|
159
|
+
name?: string;
|
|
160
|
+
} | null;
|
|
161
|
+
isAuthenticated?: boolean;
|
|
162
|
+
onLogin?: () => void;
|
|
163
|
+
onNavigate?: (dest: ChatNavDest) => void;
|
|
164
|
+
isMobile?: boolean;
|
|
165
|
+
initialOpen?: boolean;
|
|
166
|
+
initialMode?: ChatViewMode;
|
|
167
|
+
embedded?: boolean;
|
|
168
|
+
message: string;
|
|
169
|
+
onMessageChange: (value: string) => void;
|
|
170
|
+
onSend: () => void;
|
|
171
|
+
responseMode?: ResponseMode;
|
|
172
|
+
selectedPersona?: PersonaType;
|
|
173
|
+
personaName?: string;
|
|
174
|
+
showThinking?: boolean;
|
|
175
|
+
onResponseModeToggle?: () => void;
|
|
176
|
+
onShowThinkingToggle?: () => void;
|
|
177
|
+
onPersonaChange?: (persona: PersonaType) => void;
|
|
178
|
+
onClearConversation?: () => void;
|
|
179
|
+
voiceState?: VoiceRecordingState;
|
|
180
|
+
onVoiceStart?: () => void;
|
|
181
|
+
onVoiceStop?: () => void;
|
|
182
|
+
uploadFile?: File | null;
|
|
183
|
+
uploadStatus?: UploadStatus;
|
|
184
|
+
isUploadActive?: boolean;
|
|
185
|
+
onAttach?: () => void;
|
|
186
|
+
onCancelUpload?: () => void;
|
|
187
|
+
isStartingConversation?: boolean;
|
|
188
|
+
onStartConversation?: () => void;
|
|
189
|
+
/** PersonaSelectorPanel (uses @/components/ui/select) — lives in the app. */
|
|
190
|
+
personaSelector?: ReactNode;
|
|
191
|
+
/** HistorySearch (useAuth + backend fetch) — lives in the app. fi-glass owns the close. */
|
|
192
|
+
renderHistory?: (ctx: {
|
|
193
|
+
onClose: () => void;
|
|
194
|
+
}) => ReactNode;
|
|
195
|
+
/** ChatWidgetMessages + ./messages subtree (domain) — lives in the app. fi-glass owns the view mode. */
|
|
196
|
+
renderMessages?: (ctx: {
|
|
197
|
+
viewMode: ChatViewMode;
|
|
198
|
+
}) => ReactNode;
|
|
199
|
+
/** Copy-curl dev tool (uses app routes/env). */
|
|
200
|
+
onCopyCurl?: () => void;
|
|
201
|
+
}
|
|
202
|
+
/** Props for the presentational shell skeleton (ChatContent). */
|
|
203
|
+
interface ChatContentProps {
|
|
204
|
+
config: ChatConfig;
|
|
205
|
+
embedded: boolean;
|
|
206
|
+
isAuthenticated: boolean;
|
|
207
|
+
userName?: string;
|
|
208
|
+
viewMode: ChatViewMode;
|
|
209
|
+
isHistoryOpen: boolean;
|
|
210
|
+
isStartingConversation: boolean;
|
|
211
|
+
messageCount: number;
|
|
212
|
+
loading: boolean;
|
|
213
|
+
isTyping: boolean;
|
|
214
|
+
loadingInitial: boolean;
|
|
215
|
+
customEmptyState?: ReactNode;
|
|
216
|
+
customQuickReplies?: ReactNode;
|
|
217
|
+
message: string;
|
|
218
|
+
responseMode?: ResponseMode;
|
|
219
|
+
selectedPersona?: PersonaType;
|
|
220
|
+
personaName?: string;
|
|
221
|
+
showThinking?: boolean;
|
|
222
|
+
voiceState?: VoiceRecordingState;
|
|
223
|
+
uploadFile?: File | null;
|
|
224
|
+
uploadStatus?: UploadStatus;
|
|
225
|
+
isUploadActive?: boolean;
|
|
226
|
+
onNavigate?: (dest: ChatNavDest) => void;
|
|
227
|
+
onModeChange: (mode: ChatViewMode) => void;
|
|
228
|
+
onMinimize: () => void;
|
|
229
|
+
onMaximize: () => void;
|
|
230
|
+
onToggleDenseMode: () => void;
|
|
231
|
+
onClose: () => void;
|
|
232
|
+
onHistoryOpen: () => void;
|
|
233
|
+
onHistoryClose: () => void;
|
|
234
|
+
onStartConversation: () => void;
|
|
235
|
+
onLogin: () => void;
|
|
236
|
+
onMessageChange: (message: string) => void;
|
|
237
|
+
onSend: () => void;
|
|
238
|
+
onResponseModeToggle?: () => void;
|
|
239
|
+
onShowThinkingToggle?: () => void;
|
|
240
|
+
onPersonaChange?: (persona: PersonaType) => void;
|
|
241
|
+
onClearConversation?: () => void;
|
|
242
|
+
onVoiceStart?: () => void;
|
|
243
|
+
onVoiceStop?: () => void;
|
|
244
|
+
onAttach?: () => void;
|
|
245
|
+
onCancelUpload?: () => void;
|
|
246
|
+
onCopyCurl?: () => void;
|
|
247
|
+
personaSelector?: ReactNode;
|
|
248
|
+
renderHistory?: (ctx: {
|
|
249
|
+
onClose: () => void;
|
|
250
|
+
}) => ReactNode;
|
|
251
|
+
renderMessages?: (ctx: {
|
|
252
|
+
viewMode: ChatViewMode;
|
|
253
|
+
}) => ReactNode;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare function ChatWidget<TMessage = ChatMessage, TNode = unknown>({ chatHook, config: customConfig, user, isAuthenticated, onLogin, onNavigate, isMobile: isMobileProp, initialOpen, initialMode, embedded, message, onMessageChange, onSend, responseMode, selectedPersona, personaName, showThinking, onResponseModeToggle, onShowThinkingToggle, onPersonaChange, onClearConversation, voiceState, onVoiceStart, onVoiceStop, uploadFile, uploadStatus, isUploadActive, onAttach, onCancelUpload, isStartingConversation, onStartConversation, personaSelector, renderHistory, renderMessages, onCopyCurl, }: ChatWidgetProps<TMessage, TNode>): react.JSX.Element | null;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Same surface as ChatWidget minus the launcher/view-mode knobs, which
|
|
260
|
+
* ChatSurface fixes to the always-open full-page configuration.
|
|
261
|
+
*/
|
|
262
|
+
type ChatSurfaceProps<TMessage = ChatMessage, TNode = unknown> = Omit<ChatWidgetProps<TMessage, TNode>, 'initialOpen' | 'embedded' | 'initialMode'>;
|
|
263
|
+
declare function ChatSurface<TMessage = ChatMessage, TNode = unknown>(props: ChatSurfaceProps<TMessage, TNode>): react.JSX.Element;
|
|
264
|
+
|
|
265
|
+
declare function ChatContent({ config, embedded, isAuthenticated, userName, viewMode, isHistoryOpen, isStartingConversation, messageCount, loading, isTyping, loadingInitial, customEmptyState, customQuickReplies, message, responseMode, selectedPersona, personaName, showThinking, voiceState, uploadFile, uploadStatus, isUploadActive, onNavigate, onModeChange, onMinimize, onMaximize, onToggleDenseMode, onClose, onHistoryOpen, onHistoryClose, onStartConversation, onLogin, onMessageChange, onSend, onResponseModeToggle, onShowThinkingToggle, onPersonaChange: _onPersonaChange, onClearConversation, onVoiceStart, onVoiceStop, onAttach, onCancelUpload, onCopyCurl, personaSelector, renderHistory, renderMessages, }: ChatContentProps): react.JSX.Element;
|
|
266
|
+
|
|
267
|
+
interface ChatWidgetContainerProps {
|
|
268
|
+
/** Current view mode */
|
|
269
|
+
mode: ChatViewMode;
|
|
270
|
+
/** Widget title (for minimized view) */
|
|
271
|
+
title: string;
|
|
272
|
+
/** Children (header, messages, input) */
|
|
273
|
+
children: ReactNode;
|
|
274
|
+
/** Whether the widget is embedded in a page (uses relative positioning) */
|
|
275
|
+
embedded?: boolean;
|
|
276
|
+
/** Callbacks */
|
|
277
|
+
onModeChange: (mode: ChatViewMode) => void;
|
|
278
|
+
}
|
|
279
|
+
declare function ChatWidgetContainer(props: ChatWidgetContainerProps): react.JSX.Element;
|
|
280
|
+
|
|
281
|
+
interface ChatWidgetHeaderProps {
|
|
282
|
+
title: string;
|
|
283
|
+
subtitle?: string;
|
|
284
|
+
backgroundClass?: string;
|
|
285
|
+
mode: ChatViewMode;
|
|
286
|
+
showControls?: boolean;
|
|
287
|
+
showHistorySearch?: boolean;
|
|
288
|
+
onNavigate?: (dest: ChatNavDest) => void;
|
|
289
|
+
onMinimize?: () => void;
|
|
290
|
+
onMaximize?: () => void;
|
|
291
|
+
onToggleDenseMode?: () => void;
|
|
292
|
+
onClose?: () => void;
|
|
293
|
+
onHistorySearch?: () => void;
|
|
294
|
+
}
|
|
295
|
+
declare function ChatWidgetHeader({ title, subtitle, backgroundClass, mode, showControls, showHistorySearch, onNavigate, onMinimize, onMaximize, onToggleDenseMode, onClose, onHistorySearch, }: ChatWidgetHeaderProps): react.JSX.Element;
|
|
296
|
+
|
|
297
|
+
interface ChatToolbarProps {
|
|
298
|
+
showAttach?: boolean;
|
|
299
|
+
showLanguage?: boolean;
|
|
300
|
+
showFormatting?: boolean;
|
|
301
|
+
showResponseMode?: boolean;
|
|
302
|
+
showVoice?: boolean;
|
|
303
|
+
showPersonaSelector?: boolean;
|
|
304
|
+
showThinkingToggle?: boolean;
|
|
305
|
+
responseMode?: ResponseMode;
|
|
306
|
+
selectedPersona?: PersonaType;
|
|
307
|
+
showThinking?: boolean;
|
|
308
|
+
voiceRecording?: VoiceRecordingState;
|
|
309
|
+
/** Persona selector SLOT (app's PersonaSelectorPanel). */
|
|
310
|
+
personaSelector?: ReactNode;
|
|
311
|
+
onAttach?: () => void;
|
|
312
|
+
onLanguage?: () => void;
|
|
313
|
+
onFormatting?: () => void;
|
|
314
|
+
onResponseModeToggle?: () => void;
|
|
315
|
+
onVoiceStart?: () => void;
|
|
316
|
+
onVoiceStop?: () => void;
|
|
317
|
+
onShowThinkingToggle?: () => void;
|
|
318
|
+
/** Show the clear-conversation control (off when no handler is wired). */
|
|
319
|
+
showClear?: boolean;
|
|
320
|
+
/** Clear conversation — the app wraps this with its confirm dialog. */
|
|
321
|
+
onClearConversation?: () => void;
|
|
322
|
+
/** Show copy-curl dev tool button. */
|
|
323
|
+
showCopyCurl?: boolean;
|
|
324
|
+
/** Copy-curl handler — the app builds the template + toasts. */
|
|
325
|
+
onCopyCurl?: () => void;
|
|
326
|
+
onSend?: () => void;
|
|
327
|
+
canSend?: boolean;
|
|
328
|
+
sendLoading?: boolean;
|
|
329
|
+
}
|
|
330
|
+
declare function ChatToolbar({ showAttach, showLanguage, showFormatting, showResponseMode, showVoice, showPersonaSelector, showThinkingToggle, responseMode, selectedPersona: _selectedPersona, showThinking, voiceRecording, personaSelector, onAttach, onLanguage, onFormatting, onResponseModeToggle, onVoiceStart, onVoiceStop, onShowThinkingToggle, showClear, onClearConversation, showCopyCurl, onCopyCurl, onSend, canSend, sendLoading, }: ChatToolbarProps): react.JSX.Element;
|
|
331
|
+
|
|
332
|
+
interface ChatFilePreviewProps {
|
|
333
|
+
file: File;
|
|
334
|
+
status: UploadStatus;
|
|
335
|
+
progress?: number;
|
|
336
|
+
error?: string;
|
|
337
|
+
onCancel: () => void;
|
|
338
|
+
}
|
|
339
|
+
declare function ChatFilePreview({ file, status, progress, error, onCancel, }: ChatFilePreviewProps): react.JSX.Element;
|
|
340
|
+
|
|
341
|
+
interface ChatStartScreenProps {
|
|
342
|
+
/** Whether the user is authenticated */
|
|
343
|
+
isAuthenticated: boolean;
|
|
344
|
+
/** User's display name */
|
|
345
|
+
userName?: string;
|
|
346
|
+
/** Callback when user clicks "Comenzar" */
|
|
347
|
+
onStart: () => void;
|
|
348
|
+
/** Callback when user clicks "Iniciar sesión" */
|
|
349
|
+
onLogin: () => void;
|
|
350
|
+
/** Typed navigation (downloads link) */
|
|
351
|
+
onNavigate?: (dest: ChatNavDest) => void;
|
|
352
|
+
/** Whether the start action is loading */
|
|
353
|
+
isLoading?: boolean;
|
|
354
|
+
}
|
|
355
|
+
declare function ChatStartScreen({ isAuthenticated, userName, onStart, onLogin: _onLogin, onNavigate, isLoading, }: ChatStartScreenProps): react.JSX.Element;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* fi-glass · FloatingButton — the closed-state launcher (bottom-right).
|
|
359
|
+
* Pure: lucide icon + app CSS classes (fi-fab-emerald, fi-dot-pulse-red,
|
|
360
|
+
* fi-tooltip-right live in the app's stylesheet). Copied verbatim from aurity.
|
|
361
|
+
*/
|
|
362
|
+
interface FloatingButtonProps {
|
|
363
|
+
onClick: () => void;
|
|
364
|
+
isMobile: boolean;
|
|
365
|
+
}
|
|
366
|
+
declare function FloatingButton({ onClick, isMobile }: FloatingButtonProps): react.JSX.Element;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* fi-glass · useChatWidgetState — widget UI state (open/close, view mode,
|
|
370
|
+
* history panel, conversation-started). Pure React, no domain. Copied verbatim
|
|
371
|
+
* from aurity (it had zero coupling).
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
interface UseChatWidgetStateOptions {
|
|
375
|
+
initialOpen: boolean;
|
|
376
|
+
initialMode: ChatViewMode;
|
|
377
|
+
}
|
|
378
|
+
interface UseChatWidgetStateReturn {
|
|
379
|
+
isOpen: boolean;
|
|
380
|
+
viewMode: ChatViewMode;
|
|
381
|
+
isHistoryOpen: boolean;
|
|
382
|
+
conversationStarted: boolean;
|
|
383
|
+
isStartingConversation: boolean;
|
|
384
|
+
open: () => void;
|
|
385
|
+
close: () => void;
|
|
386
|
+
setViewMode: (mode: ChatViewMode) => void;
|
|
387
|
+
minimize: () => void;
|
|
388
|
+
maximize: () => void;
|
|
389
|
+
toggleDenseMode: () => void;
|
|
390
|
+
openHistory: () => void;
|
|
391
|
+
closeHistory: () => void;
|
|
392
|
+
startConversation: () => void;
|
|
393
|
+
onMessagesLoaded: (hasMessages: boolean) => void;
|
|
394
|
+
}
|
|
395
|
+
declare function useChatWidgetState({ initialOpen, initialMode, }: UseChatWidgetStateOptions): UseChatWidgetStateReturn;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* fi-glass · useMediaQuery — pure, tearing-free media-query subscription.
|
|
399
|
+
*
|
|
400
|
+
* Copied verbatim from aurity's `hooks/useMediaQuery.ts` (it had zero domain
|
|
401
|
+
* coupling — only React). The shell's responsive container consumes it so
|
|
402
|
+
* fi-glass never reaches back into the app for breakpoint state.
|
|
403
|
+
*
|
|
404
|
+
* - useSyncExternalStore for concurrent-safe reads
|
|
405
|
+
* - SSR-safe (configurable server snapshot)
|
|
406
|
+
* - global MediaQueryList cache shared across components
|
|
407
|
+
* - RAF-debounced notifications
|
|
408
|
+
* - legacy addListener/removeListener fallback
|
|
409
|
+
*/
|
|
410
|
+
interface UseMediaQueryOptions {
|
|
411
|
+
ssrMatch?: boolean;
|
|
412
|
+
useRaf?: boolean;
|
|
413
|
+
cache?: boolean;
|
|
414
|
+
}
|
|
415
|
+
declare function useMediaQuery(query: string, options?: UseMediaQueryOptions): boolean;
|
|
416
|
+
interface Breakpoints {
|
|
417
|
+
mobile: string;
|
|
418
|
+
tablet: string;
|
|
419
|
+
desktop: string;
|
|
420
|
+
}
|
|
421
|
+
interface BreakpointMatches {
|
|
422
|
+
isMobile: boolean;
|
|
423
|
+
isTablet: boolean;
|
|
424
|
+
isDesktop: boolean;
|
|
425
|
+
}
|
|
426
|
+
declare function useBreakpoints(breakpoints: Breakpoints, options?: Pick<UseMediaQueryOptions, 'ssrMatch'>): BreakpointMatches;
|
|
427
|
+
declare function clearMediaQueryCache(): void;
|
|
428
|
+
|
|
429
|
+
export { type AnimationConfig, type BreakpointMatches, type Breakpoints, CHAT_BREAKPOINTS, type ChatBehavior, type ChatBreakpoints, type ChatConfig, ChatContent, type ChatContentProps, ChatFilePreview, type ChatFilePreviewProps, type ChatNavDest, ChatStartScreen, type ChatStartScreenProps, ChatSurface, type ChatSurfaceProps, type ChatTheme, ChatToolbar, type ChatToolbarProps, type ChatViewMode, ChatWidget, ChatWidgetContainer, type ChatWidgetContainerProps, ChatWidgetHeader, type ChatWidgetHeaderProps, type ChatWidgetProps, FloatingButton, type FloatingButtonProps, type PersonaType, type ResponseMode, type ShellStreamingState, type TimestampConfig, type UploadStatus, type UseChatWidgetStateOptions, type UseChatWidgetStateReturn, type UseMediaQueryOptions, type VoiceRecordingState, clearMediaQueryCache, defaultAnimationConfig, defaultBehavior, defaultChatConfig, defaultTheme, defaultTimestampConfig, mergeChatConfig, useBreakpoints, useChatWidgetState, useMediaQuery };
|