@burdenoff/microfe-healthybowl 2026.902.13 → 2026.902.15
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/components/assistant/AssistantAutoSpeakToggle.js +4 -27
- package/dist/components/assistant/AssistantHeader.js +38 -42
- package/dist/components/assistant/AssistantHeader.js.map +1 -1
- package/dist/components/assistant/AssistantMoreMenu.js +111 -0
- package/dist/components/assistant/AssistantMoreMenu.js.map +1 -0
- package/dist/components/assistant/index.js +2 -2
- package/dist/hooks/useAssistantKeyboardShortcuts.js +1 -1
- package/dist/hooks/useAssistantKeyboardShortcuts.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/assistant/AssistantAutoSpeakToggle.js.map +0 -1
- package/dist/components/assistant/AssistantExportMenu.js +0 -52
- package/dist/components/assistant/AssistantExportMenu.js.map +0 -1
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
//#region src/components/assistant/AssistantAutoSpeakToggle.tsx
|
|
6
|
-
var a = () => {
|
|
7
|
-
let a = e(), { isSupported: o, isBlocked: s, disabledReason: c, autoSpeakEnabled: l, setAutoSpeak: u, stop: d } = t();
|
|
8
|
-
if (!o) return null;
|
|
9
|
-
let f = s && !l, p = l ? a("healthybowl.assistant.header.autoSpeakOff", "Stop reading replies aloud") : a("healthybowl.assistant.header.autoSpeakOn", "Read replies aloud automatically");
|
|
10
|
-
return /* @__PURE__ */ i("button", {
|
|
11
|
-
type: "button",
|
|
12
|
-
onClick: () => {
|
|
13
|
-
l && d(), u(!l);
|
|
14
|
-
},
|
|
15
|
-
disabled: f,
|
|
16
|
-
className: `rounded-lg p-1.5 transition-colors disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent ${l ? "bg-action-primary-bg/15 text-action-primary-bg" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
17
|
-
title: f ? c ?? p : p,
|
|
18
|
-
"aria-label": p,
|
|
19
|
-
"aria-pressed": l,
|
|
20
|
-
"data-testid": "assistant-auto-speak",
|
|
21
|
-
children: i(l ? n : r, { className: "size-4" })
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { a as AssistantAutoSpeakToggle };
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=AssistantAutoSpeakToggle.js.map
|
|
1
|
+
import "../../shared/hooks/useTr.js";
|
|
2
|
+
import "./AssistantSpeechProvider.js";
|
|
3
|
+
import "lucide-react";
|
|
4
|
+
import "react/jsx-runtime";
|
|
@@ -1,81 +1,77 @@
|
|
|
1
1
|
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { History as i, PanelBottom as a, PanelRight as o, Plus as s, Sparkles as c, X as l } from "lucide-react";
|
|
6
|
-
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { AssistantMoreMenu as t } from "./AssistantMoreMenu.js";
|
|
3
|
+
import { History as n, PanelBottom as r, PanelRight as i, Plus as a, Sparkles as o, X as s } from "lucide-react";
|
|
4
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
5
|
//#region src/components/assistant/AssistantHeader.tsx
|
|
8
|
-
var
|
|
9
|
-
let
|
|
10
|
-
return /* @__PURE__ */
|
|
6
|
+
var u = ({ contextLabel: u, onNewConversation: d, onOpenHistory: f, historyOpen: p, onClose: m, docked: h, onToggleDock: g }) => {
|
|
7
|
+
let _ = e();
|
|
8
|
+
return /* @__PURE__ */ l("div", {
|
|
11
9
|
className: "flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5",
|
|
12
|
-
children: [/* @__PURE__ */
|
|
10
|
+
children: [/* @__PURE__ */ l("div", {
|
|
13
11
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
14
|
-
children: [/* @__PURE__ */
|
|
12
|
+
children: [/* @__PURE__ */ c("span", {
|
|
15
13
|
className: "flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg",
|
|
16
|
-
children: /* @__PURE__ */
|
|
17
|
-
}), /* @__PURE__ */
|
|
14
|
+
children: /* @__PURE__ */ c(o, { className: "size-4" })
|
|
15
|
+
}), /* @__PURE__ */ l("span", {
|
|
18
16
|
className: "min-w-0 flex-1",
|
|
19
|
-
children: [/* @__PURE__ */
|
|
17
|
+
children: [/* @__PURE__ */ c("span", {
|
|
20
18
|
className: "block truncate text-[14px] font-semibold leading-tight text-text-primary",
|
|
21
|
-
children:
|
|
22
|
-
}), /* @__PURE__ */
|
|
19
|
+
children: _("healthybowl.assistant.header.title", "HealthyBowl AI")
|
|
20
|
+
}), /* @__PURE__ */ l("span", {
|
|
23
21
|
className: "block truncate text-[11px] leading-tight text-text-muted",
|
|
24
22
|
children: [
|
|
25
|
-
|
|
26
|
-
/* @__PURE__ */
|
|
23
|
+
_("healthybowl.assistant.header.ready", "Ready"),
|
|
24
|
+
/* @__PURE__ */ c("span", {
|
|
27
25
|
"aria-hidden": "true",
|
|
28
26
|
children: " · "
|
|
29
27
|
}),
|
|
30
|
-
|
|
28
|
+
_("healthybowl.assistant.header.context", "Context: {{page}}", { page: u })
|
|
31
29
|
]
|
|
32
30
|
})]
|
|
33
31
|
})]
|
|
34
|
-
}), /* @__PURE__ */
|
|
32
|
+
}), /* @__PURE__ */ l("div", {
|
|
35
33
|
className: "flex flex-shrink-0 items-center gap-0.5",
|
|
36
34
|
children: [
|
|
37
|
-
/* @__PURE__ */
|
|
35
|
+
/* @__PURE__ */ c("button", {
|
|
38
36
|
type: "button",
|
|
39
|
-
onClick:
|
|
37
|
+
onClick: d,
|
|
40
38
|
className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
41
|
-
"aria-label":
|
|
39
|
+
"aria-label": _("healthybowl.assistant.header.newConversation", "New conversation"),
|
|
42
40
|
"data-testid": "assistant-new-conversation",
|
|
43
|
-
children: /* @__PURE__ */
|
|
41
|
+
children: /* @__PURE__ */ c(a, { className: "size-4" })
|
|
44
42
|
}),
|
|
45
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ c("button", {
|
|
46
44
|
type: "button",
|
|
47
|
-
onClick:
|
|
48
|
-
className: `rounded-lg p-1.5 transition-colors ${
|
|
49
|
-
"aria-label":
|
|
50
|
-
"aria-pressed":
|
|
45
|
+
onClick: f,
|
|
46
|
+
className: `rounded-lg p-1.5 transition-colors ${p ? "bg-action-primary-bg/15 text-action-primary-bg" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
47
|
+
"aria-label": _("healthybowl.assistant.header.history", "Conversation history"),
|
|
48
|
+
"aria-pressed": p,
|
|
51
49
|
"data-testid": "assistant-open-history",
|
|
52
|
-
children: /* @__PURE__ */
|
|
50
|
+
children: /* @__PURE__ */ c(n, { className: "size-4" })
|
|
53
51
|
}),
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */ u(t, {}),
|
|
57
|
-
v && /* @__PURE__ */ u("button", {
|
|
52
|
+
/* @__PURE__ */ c(t, {}),
|
|
53
|
+
g && /* @__PURE__ */ c("button", {
|
|
58
54
|
type: "button",
|
|
59
|
-
onClick:
|
|
55
|
+
onClick: g,
|
|
60
56
|
className: "hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex",
|
|
61
|
-
"aria-label":
|
|
62
|
-
"aria-pressed":
|
|
57
|
+
"aria-label": h ? _("healthybowl.assistant.header.float", "Float chat window") : _("healthybowl.assistant.header.dock", "Dock to side panel"),
|
|
58
|
+
"aria-pressed": h,
|
|
63
59
|
"data-testid": "assistant-toggle-dock",
|
|
64
|
-
children:
|
|
60
|
+
children: c(h ? r : i, { className: "size-4" })
|
|
65
61
|
}),
|
|
66
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ c("button", {
|
|
67
63
|
type: "button",
|
|
68
|
-
onClick:
|
|
64
|
+
onClick: m,
|
|
69
65
|
className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
70
|
-
"aria-label":
|
|
66
|
+
"aria-label": _("healthybowl.assistant.header.close", "Close assistant"),
|
|
71
67
|
"data-testid": "assistant-close",
|
|
72
|
-
children: /* @__PURE__ */
|
|
68
|
+
children: /* @__PURE__ */ c(s, { className: "size-4" })
|
|
73
69
|
})
|
|
74
70
|
]
|
|
75
71
|
})]
|
|
76
72
|
});
|
|
77
73
|
};
|
|
78
74
|
//#endregion
|
|
79
|
-
export {
|
|
75
|
+
export { u as AssistantHeader };
|
|
80
76
|
|
|
81
77
|
//# sourceMappingURL=AssistantHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport {
|
|
1
|
+
{"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantMoreMenu } from './AssistantMoreMenu';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('healthybowl.assistant.header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('healthybowl.assistant.header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('healthybowl.assistant.header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('healthybowl.assistant.header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantMoreMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex\"\n aria-label={\n docked\n ? tr('healthybowl.assistant.header.float', 'Float chat window')\n : tr('healthybowl.assistant.header.dock', 'Dock to side panel')\n }\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AA2BA,IAAa,KAA8B,EACzC,iBACA,sBACA,kBACA,gBACA,YACA,WACA,sBACI;CACJ,IAAM,IAAK,EAAM;CAEjB,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CAEE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cACd,kBAAC,GAAD,EAAU,WAAU,SAAU,CAAA;GAC1B,CAAA,GACN,kBAAC,QAAD;IAAM,WAAU;cAAhB,CACE,kBAAC,QAAD;KAAM,WAAU;eACb,EAAG,sCAAsC,gBAAgB;IACtD,CAAA,GACN,kBAAC,QAAD;KAAM,WAAU;eAAhB;MACG,EAAG,sCAAsC,OAAO;MACjD,kBAAC,QAAD;OAAM,eAAY;iBAAO;MAAS,CAAA;MACjC,EAAG,wCAAwC,qBAAqB,EAAE,MAAM,EAAa,CAAC;KACnF;MACF;KACH;MAGL,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cAAY,EAAG,gDAAgD,kBAAkB;KACjF,eAAY;eAEZ,kBAAC,GAAD,EAAM,WAAU,SAAU,CAAA;IACpB,CAAA;IACR,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAW,sCACT,IACI,mDACA;KAEN,cAAY,EAAG,wCAAwC,sBAAsB;KAC7E,gBAAc;KACd,eAAY;eAEZ,kBAAC,GAAD,EAAS,WAAU,SAAU,CAAA;IACvB,CAAA;IAER,kBAAC,GAAD,CAAoB,CAAA;IACnB,KACC,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cACE,IACI,EAAG,sCAAsC,mBAAmB,IAC5D,EAAG,qCAAqC,oBAAoB;KAElE,gBAAc;KACd,eAAY;eAEF,EAAT,IAAU,IAAqC,GAAtC,EAAa,WAAU,SAAU,CAAoC;IACzE,CAAA;IAEV,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cAAY,EAAG,sCAAsC,iBAAiB;KACtE,eAAY;eAEZ,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;IACjB,CAAA;GACL;IACF;;AAET"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useAssistantStore as e } from "../../store/assistantStore.js";
|
|
2
|
+
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
+
import { downloadFile as n, exportConversation as r } from "../../services/assistantExportService.js";
|
|
4
|
+
import { useAssistantSpeech as i } from "./AssistantSpeechProvider.js";
|
|
5
|
+
import { AssistantVoiceSelector as a } from "./composer/AssistantVoiceSelector.js";
|
|
6
|
+
import { useEffect as o, useRef as s, useState as c } from "react";
|
|
7
|
+
import { Check as l, FileJson as u, FileText as d, MoreHorizontal as f, Volume2 as p } from "lucide-react";
|
|
8
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/assistant/AssistantMoreMenu.tsx
|
|
10
|
+
var _ = () => {
|
|
11
|
+
let _ = t(), [v, y] = c(!1), b = s(null), x = s(null), { conversations: S, activeConversationId: C } = e(), w = S.find((e) => e.id === C), T = !!(w && w.messages.length > 0), { isSupported: E, isBlocked: D, disabledReason: O, autoSpeakEnabled: k, setAutoSpeak: A, stop: j } = i(), M = D && !k;
|
|
12
|
+
o(() => {
|
|
13
|
+
if (!v) return;
|
|
14
|
+
let e = (e) => {
|
|
15
|
+
e.key === "Escape" && (y(!1), x.current?.focus());
|
|
16
|
+
}, t = (e) => {
|
|
17
|
+
let t = e.target;
|
|
18
|
+
b.current?.contains(t) || x.current?.contains(t) || y(!1);
|
|
19
|
+
};
|
|
20
|
+
return window.addEventListener("keydown", e), document.addEventListener("mousedown", t), () => {
|
|
21
|
+
window.removeEventListener("keydown", e), document.removeEventListener("mousedown", t);
|
|
22
|
+
};
|
|
23
|
+
}, [v]);
|
|
24
|
+
let N = (e) => {
|
|
25
|
+
if (!w) return;
|
|
26
|
+
let { content: t, filename: i, mimeType: a } = r(w, e);
|
|
27
|
+
n(t, i, a), y(!1);
|
|
28
|
+
}, P = () => {
|
|
29
|
+
k && j(), A(!k);
|
|
30
|
+
}, F = _("healthybowl.assistant.header.more", "More options");
|
|
31
|
+
return /* @__PURE__ */ g("div", {
|
|
32
|
+
className: "relative",
|
|
33
|
+
children: [/* @__PURE__ */ h("button", {
|
|
34
|
+
ref: x,
|
|
35
|
+
type: "button",
|
|
36
|
+
onClick: () => y((e) => !e),
|
|
37
|
+
className: "rounded p-1 transition-colors hover:bg-bg-elevated",
|
|
38
|
+
"aria-label": F,
|
|
39
|
+
"aria-haspopup": "menu",
|
|
40
|
+
"aria-expanded": v,
|
|
41
|
+
"data-testid": "assistant-more",
|
|
42
|
+
children: /* @__PURE__ */ h(f, { className: "size-4 text-text-secondary" })
|
|
43
|
+
}), v ? /* @__PURE__ */ g("div", {
|
|
44
|
+
ref: b,
|
|
45
|
+
role: "menu",
|
|
46
|
+
"aria-label": F,
|
|
47
|
+
className: "absolute right-0 top-full z-50 mt-1 min-w-56 overflow-hidden rounded-xl border border-border-default bg-bg-surface py-1 shadow-lg",
|
|
48
|
+
"data-testid": "assistant-more-menu",
|
|
49
|
+
children: [
|
|
50
|
+
E ? /* @__PURE__ */ g("button", {
|
|
51
|
+
type: "button",
|
|
52
|
+
role: "menuitemcheckbox",
|
|
53
|
+
"aria-checked": k,
|
|
54
|
+
onClick: P,
|
|
55
|
+
disabled: M,
|
|
56
|
+
title: M ? O ?? void 0 : void 0,
|
|
57
|
+
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated disabled:cursor-not-allowed disabled:text-text-muted disabled:hover:bg-transparent",
|
|
58
|
+
"data-testid": "assistant-auto-speak",
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ h(p, {
|
|
61
|
+
className: "size-3.5 flex-shrink-0 text-text-secondary",
|
|
62
|
+
"aria-hidden": "true"
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ h("span", {
|
|
65
|
+
className: "flex-1",
|
|
66
|
+
children: _("healthybowl.assistant.header.autoRead", "Auto-read replies")
|
|
67
|
+
}),
|
|
68
|
+
k ? /* @__PURE__ */ h(l, { className: "size-3.5 flex-shrink-0 text-action-primary-bg" }) : null
|
|
69
|
+
]
|
|
70
|
+
}) : null,
|
|
71
|
+
/* @__PURE__ */ h("div", {
|
|
72
|
+
className: "px-3 py-1.5",
|
|
73
|
+
"data-testid": "assistant-more-voice",
|
|
74
|
+
children: /* @__PURE__ */ h(a, {})
|
|
75
|
+
}),
|
|
76
|
+
T ? /* @__PURE__ */ g(m, { children: [
|
|
77
|
+
/* @__PURE__ */ h("div", {
|
|
78
|
+
className: "my-1 border-t border-border-subtle",
|
|
79
|
+
role: "separator"
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ g("button", {
|
|
82
|
+
type: "button",
|
|
83
|
+
role: "menuitem",
|
|
84
|
+
onClick: () => N("json"),
|
|
85
|
+
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated",
|
|
86
|
+
"data-testid": "export-json",
|
|
87
|
+
children: [/* @__PURE__ */ h(u, {
|
|
88
|
+
className: "size-3.5 flex-shrink-0 text-text-secondary",
|
|
89
|
+
"aria-hidden": "true"
|
|
90
|
+
}), _("healthybowl.assistant.export.json", "Export as JSON")]
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ g("button", {
|
|
93
|
+
type: "button",
|
|
94
|
+
role: "menuitem",
|
|
95
|
+
onClick: () => N("markdown"),
|
|
96
|
+
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated",
|
|
97
|
+
"data-testid": "export-markdown",
|
|
98
|
+
children: [/* @__PURE__ */ h(d, {
|
|
99
|
+
className: "size-3.5 flex-shrink-0 text-text-secondary",
|
|
100
|
+
"aria-hidden": "true"
|
|
101
|
+
}), _("healthybowl.assistant.export.markdown", "Export as Markdown")]
|
|
102
|
+
})
|
|
103
|
+
] }) : null
|
|
104
|
+
]
|
|
105
|
+
}) : null]
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { _ as AssistantMoreMenu };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=AssistantMoreMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssistantMoreMenu.js","names":[],"sources":["../../../src/components/assistant/AssistantMoreMenu.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type FC } from 'react';\nimport { Check, FileJson, FileText, MoreHorizontal, Volume2 } from 'lucide-react';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { exportConversation, downloadFile } from '@/services/assistantExportService';\nimport { useAssistantSpeech } from './AssistantSpeechProvider';\nimport { AssistantVoiceSelector } from './composer/AssistantVoiceSelector';\nimport { useTr } from '../../shared/hooks/useTr';\n\n/**\n * The header's secondary surface — everything that CONFIGURES the assistant.\n *\n * ★ `+` supplies content, `⋯` configures. Keeping those two meanings apart is\n * the point: the header carried seven controls, and three of them\n * (auto-read, the voice picker, export) render null under conditions the user\n * cannot see — no speech support, fewer than two voices, an empty conversation —\n * so the row silently changed width between devices and between the first and\n * second message of the same session.\n *\n * Now four primary controls, always present, and one menu that absorbs the\n * conditional ones. A menu ROW may still hide itself; a menu that keeps its\n * position while its contents vary is a much smaller surprise than a toolbar\n * that reflows.\n *\n * ★ Export is FLATTENED into this menu rather than nested inside it. It was\n * itself a dropdown, and a dropdown inside a dropdown is two Escape presses and\n * two outside-click regions for two menu items.\n *\n * ★ The voice picker keeps its native `<select>`. It is deliberate — see that\n * component — and a custom listbox would look tidier in a screenshot while being\n * worse on the phones this product is used on. Because the select lives inside\n * the menu's own subtree, the outside-click handler ignores clicks on it.\n *\n * Not included, deliberately: Live captions and Assistant settings have nothing\n * behind them yet, and a Transcript entry needs a product decision first (the\n * voice transcript is session-scoped, while the chat thread is always visible —\n * one menu label cannot honestly mean both).\n */\nexport const AssistantMoreMenu: FC = () => {\n const tr = useTr();\n const [open, setOpen] = useState(false);\n const menuRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const { conversations, activeConversationId } = useAssistantStore();\n const activeConversation = conversations.find((conversation) => conversation.id === activeConversationId);\n const canExport = Boolean(activeConversation && activeConversation.messages.length > 0);\n\n const { isSupported, isBlocked, disabledReason, autoSpeakEnabled, setAutoSpeak, stop } = useAssistantSpeech();\n // Blocked and already off means turning it on would do nothing audible.\n const autoReadDisabled = isBlocked && !autoSpeakEnabled;\n\n useEffect(() => {\n if (!open) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n setOpen(false);\n buttonRef.current?.focus();\n }\n };\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (menuRef.current?.contains(target) || buttonRef.current?.contains(target)) return;\n setOpen(false);\n };\n window.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onPointerDown);\n return () => {\n window.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onPointerDown);\n };\n }, [open]);\n\n const handleExport = (format: 'json' | 'markdown') => {\n if (!activeConversation) return;\n const { content, filename, mimeType } = exportConversation(activeConversation, format);\n downloadFile(content, filename, mimeType);\n setOpen(false);\n };\n\n const toggleAutoRead = () => {\n // Turning it OFF stops whatever is speaking now: leaving audio running\n // after the user switched the feature off reads as the control not working.\n if (autoSpeakEnabled) stop();\n setAutoSpeak(!autoSpeakEnabled);\n };\n\n const label = tr('healthybowl.assistant.header.more', 'More options');\n\n return (\n <div className=\"relative\">\n <button\n ref={buttonRef}\n type=\"button\"\n onClick={() => setOpen((wasOpen) => !wasOpen)}\n className=\"rounded p-1 transition-colors hover:bg-bg-elevated\"\n aria-label={label}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n data-testid=\"assistant-more\"\n >\n <MoreHorizontal className=\"size-4 text-text-secondary\" />\n </button>\n\n {open ? (\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n className=\"absolute right-0 top-full z-50 mt-1 min-w-56 overflow-hidden rounded-xl border border-border-default bg-bg-surface py-1 shadow-lg\"\n data-testid=\"assistant-more-menu\"\n >\n {isSupported ? (\n <button\n type=\"button\"\n role=\"menuitemcheckbox\"\n aria-checked={autoSpeakEnabled}\n onClick={toggleAutoRead}\n disabled={autoReadDisabled}\n title={autoReadDisabled ? (disabledReason ?? undefined) : undefined}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated disabled:cursor-not-allowed disabled:text-text-muted disabled:hover:bg-transparent\"\n data-testid=\"assistant-auto-speak\"\n >\n <Volume2 className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"flex-1\">{tr('healthybowl.assistant.header.autoRead', 'Auto-read replies')}</span>\n {/* State as a tick rather than the word \"On\": the row is already a\n checkbox to assistive technology via aria-checked. */}\n {autoSpeakEnabled ? <Check className=\"size-3.5 flex-shrink-0 text-action-primary-bg\" /> : null}\n </button>\n ) : null}\n\n {/* Renders nothing when the device offers fewer than two voices, which\n is most of them until a hosted TTS endpoint is configured. */}\n <div className=\"px-3 py-1.5\" data-testid=\"assistant-more-voice\">\n <AssistantVoiceSelector />\n </div>\n\n {canExport ? (\n <>\n <div className=\"my-1 border-t border-border-subtle\" role=\"separator\" />\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => handleExport('json')}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated\"\n data-testid=\"export-json\"\n >\n <FileJson className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.export.json', 'Export as JSON')}\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => handleExport('markdown')}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-text-primary transition-colors hover:bg-bg-elevated\"\n data-testid=\"export-markdown\"\n >\n <FileText className=\"size-3.5 flex-shrink-0 text-text-secondary\" aria-hidden=\"true\" />\n {tr('healthybowl.assistant.export.markdown', 'Export as Markdown')}\n </button>\n </>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n};\n"],"mappings":"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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "./AssistantExportMenu.js";
|
|
2
1
|
import "./AssistantToolActivity.js";
|
|
3
2
|
import "./AssistantSpeechProvider.js";
|
|
4
|
-
import "./
|
|
3
|
+
import "./AssistantMoreMenu.js";
|
|
5
4
|
import "./AssistantHeader.js";
|
|
6
5
|
import "./AssistantMarkdownRenderer.js";
|
|
7
6
|
import "./AssistantMessageAttachments.js";
|
|
@@ -17,3 +16,4 @@ import "./composer/AssistantComposer.js";
|
|
|
17
16
|
import "./AssistantChatArea.js";
|
|
18
17
|
import "./AssistantConversationList.js";
|
|
19
18
|
import "./AIAssistantPanel.js";
|
|
19
|
+
import "./AssistantAutoSpeakToggle.js";
|
|
@@ -16,7 +16,7 @@ function n({ panelRef: n, inputRef: r, onClose: i }) {
|
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
if (o && t.shiftKey && (t.key === "E" || t.key === "e")) {
|
|
19
|
-
t.preventDefault(), a.querySelector("[data-testid=\"assistant-
|
|
19
|
+
t.preventDefault(), a.querySelector("[data-testid=\"assistant-more\"]")?.click();
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
if (t.key === "/" && !o && !t.shiftKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantKeyboardShortcuts.js","names":[],"sources":["../../src/hooks/useAssistantKeyboardShortcuts.ts"],"sourcesContent":["import { useEffect, type RefObject } from 'react';\nimport { useAssistantStore } from '@/store/assistantStore';\n\ninterface Options {\n panelRef: RefObject<HTMLDivElement | null>;\n inputRef?: RefObject<HTMLTextAreaElement | null>;\n onClose: () => void;\n}\n\n/**\n * Panel-scoped keyboard shortcuts for the AI assistant.\n *\n * All shortcuts only fire when the assistant panel (or one of its children)\n * has focus, so they never override the host page's own shortcuts. We also\n * deliberately avoid the bare `Ctrl+N`/`Cmd+N`/`Ctrl+E`/`Ctrl+W` set the\n * browser owns at the OS level — those couldn't be cancelled reliably\n * anyway and were just adding visible \"shortcut listed, doesn't work\"\n * inconsistencies. The shortcuts here match the in-app shortcuts modal.\n *\n * - Escape: Close panel\n * - Ctrl/Cmd+Shift+N: New conversation\n * - Ctrl/Cmd+Shift+E: Export (triggers click on export button)\n * - /: Focus input (only when no input/textarea is already focused)\n */\nexport function useAssistantKeyboardShortcuts({ panelRef, inputRef, onClose }: Options) {\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n const panel = panelRef.current;\n if (!panel) return;\n\n // Only handle shortcuts when the panel or its children are focused.\n if (!panel.contains(document.activeElement) && document.activeElement !== panel) {\n return;\n }\n\n const isModKey = e.ctrlKey || e.metaKey;\n\n // Escape: close panel\n if (e.key === 'Escape') {\n e.preventDefault();\n onClose();\n return;\n }\n\n // Ctrl/Cmd+Shift+N: new conversation. Shift is required so we don't\n // fight the browser's `Ctrl+N` (new window).\n if (isModKey && e.shiftKey && (e.key === 'N' || e.key === 'n')) {\n e.preventDefault();\n useAssistantStore.getState().createConversation();\n return;\n }\n\n // Ctrl/Cmd+Shift+E: export. Shift required to avoid the browser's\n // `Ctrl+E` (search address bar in Chrome/Edge).\n if (isModKey && e.shiftKey && (e.key === 'E' || e.key === 'e')) {\n e.preventDefault();\n const
|
|
1
|
+
{"version":3,"file":"useAssistantKeyboardShortcuts.js","names":[],"sources":["../../src/hooks/useAssistantKeyboardShortcuts.ts"],"sourcesContent":["import { useEffect, type RefObject } from 'react';\nimport { useAssistantStore } from '@/store/assistantStore';\n\ninterface Options {\n panelRef: RefObject<HTMLDivElement | null>;\n inputRef?: RefObject<HTMLTextAreaElement | null>;\n onClose: () => void;\n}\n\n/**\n * Panel-scoped keyboard shortcuts for the AI assistant.\n *\n * All shortcuts only fire when the assistant panel (or one of its children)\n * has focus, so they never override the host page's own shortcuts. We also\n * deliberately avoid the bare `Ctrl+N`/`Cmd+N`/`Ctrl+E`/`Ctrl+W` set the\n * browser owns at the OS level — those couldn't be cancelled reliably\n * anyway and were just adding visible \"shortcut listed, doesn't work\"\n * inconsistencies. The shortcuts here match the in-app shortcuts modal.\n *\n * - Escape: Close panel\n * - Ctrl/Cmd+Shift+N: New conversation\n * - Ctrl/Cmd+Shift+E: Export (triggers click on export button)\n * - /: Focus input (only when no input/textarea is already focused)\n */\nexport function useAssistantKeyboardShortcuts({ panelRef, inputRef, onClose }: Options) {\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n const panel = panelRef.current;\n if (!panel) return;\n\n // Only handle shortcuts when the panel or its children are focused.\n if (!panel.contains(document.activeElement) && document.activeElement !== panel) {\n return;\n }\n\n const isModKey = e.ctrlKey || e.metaKey;\n\n // Escape: close panel\n if (e.key === 'Escape') {\n e.preventDefault();\n onClose();\n return;\n }\n\n // Ctrl/Cmd+Shift+N: new conversation. Shift is required so we don't\n // fight the browser's `Ctrl+N` (new window).\n if (isModKey && e.shiftKey && (e.key === 'N' || e.key === 'n')) {\n e.preventDefault();\n useAssistantStore.getState().createConversation();\n return;\n }\n\n // Ctrl/Cmd+Shift+E: export. Shift required to avoid the browser's\n // `Ctrl+E` (search address bar in Chrome/Edge).\n //\n // ★ Opens the More menu, which now owns export. This used to click\n // `assistant-export` directly; when export moved into the menu that\n // selector stopped matching anything and the shortcut became a silent\n // no-op — the failure mode of driving UI by test id from a hook.\n if (isModKey && e.shiftKey && (e.key === 'E' || e.key === 'e')) {\n e.preventDefault();\n const moreBtn = panel.querySelector('[data-testid=\"assistant-more\"]') as HTMLButtonElement | null;\n moreBtn?.click();\n return;\n }\n\n // /: focus input (when not in an input/textarea so single-key search\n // typing inside the page doesn't get hijacked).\n if (e.key === '/' && !isModKey && !e.shiftKey) {\n const tag = (document.activeElement as HTMLElement | null)?.tagName;\n if (tag !== 'INPUT' && tag !== 'TEXTAREA') {\n e.preventDefault();\n inputRef?.current?.focus();\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [panelRef, inputRef, onClose]);\n}\n"],"mappings":";;;AAwBA,SAAgB,EAA8B,EAAE,aAAU,aAAU,cAAoB;CACtF,QAAgB;EACd,IAAM,KAAiB,MAAqB;GAC1C,IAAM,IAAQ,EAAS;GAIvB,IAHI,CAAC,KAGD,CAAC,EAAM,SAAS,SAAS,aAAa,KAAK,SAAS,kBAAkB,GACxE;GAGF,IAAM,IAAW,EAAE,WAAW,EAAE;GAGhC,IAAI,EAAE,QAAQ,UAAU;IAEtB,AADA,EAAE,eAAe,GACjB,EAAQ;IACR;GACF;GAIA,IAAI,KAAY,EAAE,aAAa,EAAE,QAAQ,OAAO,EAAE,QAAQ,MAAM;IAE9D,AADA,EAAE,eAAe,GACjB,EAAkB,SAAS,EAAE,mBAAmB;IAChD;GACF;GASA,IAAI,KAAY,EAAE,aAAa,EAAE,QAAQ,OAAO,EAAE,QAAQ,MAAM;IAG9D,AAFA,EAAE,eAAe,GAEjB,EADsB,cAAc,kCACpC,GAAS,MAAM;IACf;GACF;GAIA,IAAI,EAAE,QAAQ,OAAO,CAAC,KAAY,CAAC,EAAE,UAAU;IAC7C,IAAM,IAAO,SAAS,eAAsC;IAC5D,AAAI,MAAQ,WAAW,MAAQ,eAC7B,EAAE,eAAe,GACjB,GAAU,SAAS,MAAM;GAE7B;EACF;EAGA,OADA,SAAS,iBAAiB,WAAW,CAAa,SACrC,SAAS,oBAAoB,WAAW,CAAa;CACpE,GAAG;EAAC;EAAU;EAAU;CAAO,CAAC;AAClC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantAutoSpeakToggle.js","names":[],"sources":["../../../src/components/assistant/AssistantAutoSpeakToggle.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Volume2, VolumeX } from 'lucide-react';\nimport { useAssistantSpeech } from './AssistantSpeechProvider';\nimport { useTr } from '../../shared/hooks/useTr';\n\n/**\n * Header toggle for \"read every reply aloud\" (BOFF-6290).\n *\n * Opt-in, persisted per profile, and **off by default** — the assistant must\n * never start talking on its own until someone has said they want that. Turning\n * it on affects the NEXT reply only; it does not start reading the transcript.\n *\n * Renders nothing when the platform has no speech output, so browsers without\n * `speechSynthesis` see no dead switch.\n *\n * Availability is checked here for the same reason the per-message button\n * checks it: with no installed voice for the app language, switching this on\n * would hand every reply to whatever voice the engine defaults to — a Tamil\n * answer read in English. So it is disabled, with the reason as its tooltip,\n * exactly like the Listen button. It stays operable while it is ON, because a\n * switch you cannot turn off is worse than one you cannot turn on.\n */\nexport const AssistantAutoSpeakToggle: FC = () => {\n const tr = useTr();\n const { isSupported, isBlocked, disabledReason, autoSpeakEnabled, setAutoSpeak, stop } = useAssistantSpeech();\n\n if (!isSupported) return null;\n\n const disabled = isBlocked && !autoSpeakEnabled;\n const label = autoSpeakEnabled\n ? tr('healthybowl.assistant.header.autoSpeakOff', 'Stop reading replies aloud')\n : tr('healthybowl.assistant.header.autoSpeakOn', 'Read replies aloud automatically');\n\n return (\n <button\n type=\"button\"\n onClick={() => {\n // Turning it off also silences whatever is talking right now.\n if (autoSpeakEnabled) stop();\n setAutoSpeak(!autoSpeakEnabled);\n }}\n disabled={disabled}\n className={`rounded-lg p-1.5 transition-colors disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent ${\n autoSpeakEnabled\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n title={disabled ? (disabledReason ?? label) : label}\n aria-label={label}\n aria-pressed={autoSpeakEnabled}\n data-testid=\"assistant-auto-speak\"\n >\n {autoSpeakEnabled ? <Volume2 className=\"size-4\" /> : <VolumeX className=\"size-4\" />}\n </button>\n );\n};\n"],"mappings":";;;;;AAsBA,IAAa,UAAqC;CAChD,IAAM,IAAK,EAAM,GACX,EAAE,gBAAa,cAAW,mBAAgB,qBAAkB,iBAAc,YAAS,EAAmB;CAE5G,IAAI,CAAC,GAAa,OAAO;CAEzB,IAAM,IAAW,KAAa,CAAC,GACzB,IAAQ,IACV,EAAG,6CAA6C,4BAA4B,IAC5E,EAAG,4CAA4C,kCAAkC;CAErF,OACE,kBAAC,UAAD;EACE,MAAK;EACL,eAAe;GAGb,AADI,KAAkB,EAAK,GAC3B,EAAa,CAAC,CAAgB;EAChC;EACU;EACV,WAAW,oHACT,IACI,mDACA;EAEN,OAAO,IAAY,KAAkB,IAAS;EAC9C,cAAY;EACZ,gBAAc;EACd,eAAY;YAEQ,EAAnB,IAAoB,IAAiC,GAAlC,EAAS,WAAU,SAAU,CAAiC;CAC5E,CAAA;AAEZ"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { useAssistantStore as e } from "../../store/assistantStore.js";
|
|
2
|
-
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
-
import { downloadFile as n, exportConversation as r } from "../../services/assistantExportService.js";
|
|
4
|
-
import { useEffect as i, useRef as a, useState as o } from "react";
|
|
5
|
-
import { Download as s, FileJson as c, FileText as l } from "lucide-react";
|
|
6
|
-
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
|
-
//#region src/components/assistant/AssistantExportMenu.tsx
|
|
8
|
-
var f = () => {
|
|
9
|
-
let f = t(), [p, m] = o(!1), h = a(null), { conversations: g, activeConversationId: _ } = e(), v = g.find((e) => e.id === _);
|
|
10
|
-
if (i(() => {
|
|
11
|
-
if (!p) return;
|
|
12
|
-
let e = (e) => {
|
|
13
|
-
h.current && !h.current.contains(e.target) && m(!1);
|
|
14
|
-
};
|
|
15
|
-
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
16
|
-
}, [p]), !v || v.messages.length === 0) return null;
|
|
17
|
-
let y = (e) => {
|
|
18
|
-
let { content: t, filename: i, mimeType: a } = r(v, e);
|
|
19
|
-
n(t, i, a), m(!1);
|
|
20
|
-
};
|
|
21
|
-
return /* @__PURE__ */ d("div", {
|
|
22
|
-
ref: h,
|
|
23
|
-
className: "relative",
|
|
24
|
-
children: [/* @__PURE__ */ u("button", {
|
|
25
|
-
type: "button",
|
|
26
|
-
onClick: () => m(!p),
|
|
27
|
-
className: "p-1 hover:bg-bg-elevated rounded transition-colors",
|
|
28
|
-
"aria-label": f("healthybowl.assistant.export.ariaLabel", "Export conversation"),
|
|
29
|
-
"data-testid": "assistant-export",
|
|
30
|
-
children: /* @__PURE__ */ u(s, { className: "size-3.5 text-text-secondary" })
|
|
31
|
-
}), p && /* @__PURE__ */ d("div", {
|
|
32
|
-
className: "absolute right-0 top-full mt-1 w-40 bg-bg-surface border border-border-default rounded-lg shadow-lg z-50 py-1",
|
|
33
|
-
children: [/* @__PURE__ */ d("button", {
|
|
34
|
-
type: "button",
|
|
35
|
-
onClick: () => y("json"),
|
|
36
|
-
className: "w-full flex items-center gap-2 px-3 py-2 text-xs text-text-primary hover:bg-bg-elevated transition-colors",
|
|
37
|
-
"data-testid": "export-json",
|
|
38
|
-
children: [/* @__PURE__ */ u(c, { className: "size-3.5 text-text-secondary" }), f("healthybowl.assistant.export.json", "Export as JSON")]
|
|
39
|
-
}), /* @__PURE__ */ d("button", {
|
|
40
|
-
type: "button",
|
|
41
|
-
onClick: () => y("markdown"),
|
|
42
|
-
className: "w-full flex items-center gap-2 px-3 py-2 text-xs text-text-primary hover:bg-bg-elevated transition-colors",
|
|
43
|
-
"data-testid": "export-markdown",
|
|
44
|
-
children: [/* @__PURE__ */ u(l, { className: "size-3.5 text-text-secondary" }), f("healthybowl.assistant.export.markdown", "Export as Markdown")]
|
|
45
|
-
})]
|
|
46
|
-
})]
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
//#endregion
|
|
50
|
-
export { f as AssistantExportMenu };
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=AssistantExportMenu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantExportMenu.js","names":[],"sources":["../../../src/components/assistant/AssistantExportMenu.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Download, FileJson, FileText } from 'lucide-react';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { exportConversation, downloadFile } from '@/services/assistantExportService';\nimport { useTr } from '../../shared/hooks/useTr';\n\nexport const AssistantExportMenu: FC = () => {\n const tr = useTr();\n const [open, setOpen] = useState(false);\n const menuRef = useRef<HTMLDivElement>(null);\n\n const { conversations, activeConversationId } = useAssistantStore();\n const activeConversation = conversations.find((c) => c.id === activeConversationId);\n\n useEffect(() => {\n if (!open) return;\n const handleClickOutside = (e: MouseEvent) => {\n if (menuRef.current && !menuRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', handleClickOutside);\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [open]);\n\n if (!activeConversation || activeConversation.messages.length === 0) return null;\n\n const handleExport = (format: 'json' | 'markdown') => {\n const { content, filename, mimeType } = exportConversation(activeConversation, format);\n downloadFile(content, filename, mimeType);\n setOpen(false);\n };\n\n return (\n <div ref={menuRef} className=\"relative\">\n <button\n type=\"button\"\n onClick={() => setOpen(!open)}\n className=\"p-1 hover:bg-bg-elevated rounded transition-colors\"\n aria-label={tr('healthybowl.assistant.export.ariaLabel', 'Export conversation')}\n data-testid=\"assistant-export\"\n >\n <Download className=\"size-3.5 text-text-secondary\" />\n </button>\n\n {open && (\n <div className=\"absolute right-0 top-full mt-1 w-40 bg-bg-surface border border-border-default rounded-lg shadow-lg z-50 py-1\">\n <button\n type=\"button\"\n onClick={() => handleExport('json')}\n className=\"w-full flex items-center gap-2 px-3 py-2 text-xs text-text-primary hover:bg-bg-elevated transition-colors\"\n data-testid=\"export-json\"\n >\n <FileJson className=\"size-3.5 text-text-secondary\" />\n {tr('healthybowl.assistant.export.json', 'Export as JSON')}\n </button>\n <button\n type=\"button\"\n onClick={() => handleExport('markdown')}\n className=\"w-full flex items-center gap-2 px-3 py-2 text-xs text-text-primary hover:bg-bg-elevated transition-colors\"\n data-testid=\"export-markdown\"\n >\n <FileText className=\"size-3.5 text-text-secondary\" />\n {tr('healthybowl.assistant.export.markdown', 'Export as Markdown')}\n </button>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAMA,IAAa,UAAgC;CAC3C,IAAM,IAAK,EAAM,GACX,CAAC,GAAM,KAAW,EAAS,EAAK,GAChC,IAAU,EAAuB,IAAI,GAErC,EAAE,kBAAe,4BAAyB,EAAkB,GAC5D,IAAqB,EAAc,MAAM,MAAM,EAAE,OAAO,CAAoB;CAalF,IAXA,QAAgB;EACd,IAAI,CAAC,GAAM;EACX,IAAM,KAAsB,MAAkB;GAC5C,AAAI,EAAQ,WAAW,CAAC,EAAQ,QAAQ,SAAS,EAAE,MAAc,KAC/D,EAAQ,EAAK;EAEjB;EAEA,OADA,SAAS,iBAAiB,aAAa,CAAkB,SAC5C,SAAS,oBAAoB,aAAa,CAAkB;CAC3E,GAAG,CAAC,CAAI,CAAC,GAEL,CAAC,KAAsB,EAAmB,SAAS,WAAW,GAAG,OAAO;CAE5E,IAAM,KAAgB,MAAgC;EACpD,IAAM,EAAE,YAAS,aAAU,gBAAa,EAAmB,GAAoB,CAAM;EAErF,AADA,EAAa,GAAS,GAAU,CAAQ,GACxC,EAAQ,EAAK;CACf;CAEA,OACE,kBAAC,OAAD;EAAK,KAAK;EAAS,WAAU;YAA7B,CACE,kBAAC,UAAD;GACE,MAAK;GACL,eAAe,EAAQ,CAAC,CAAI;GAC5B,WAAU;GACV,cAAY,EAAG,0CAA0C,qBAAqB;GAC9E,eAAY;aAEZ,kBAAC,GAAD,EAAU,WAAU,+BAAgC,CAAA;EAC9C,CAAA,GAEP,KACC,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,EAAa,MAAM;IAClC,WAAU;IACV,eAAY;cAJd,CAME,kBAAC,GAAD,EAAU,WAAU,+BAAgC,CAAA,GACnD,EAAG,qCAAqC,gBAAgB,CACnD;OACR,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,EAAa,UAAU;IACtC,WAAU;IACV,eAAY;cAJd,CAME,kBAAC,GAAD,EAAU,WAAU,+BAAgC,CAAA,GACnD,EAAG,yCAAyC,oBAAoB,CAC3D;KACL;IAEJ;;AAET"}
|