@shane_donnelly/dsi-internal-react-utils 0.2.1 → 1.0.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/README.md +19 -0
- package/dist/BotMessage-DegH8sM-.js +255 -0
- package/dist/InputBar-CxSc2du6.js +201 -0
- package/dist/MarkdownRenderer-vU2aoyaG.js +12908 -0
- package/dist/SessionContainer-RrzUh_no.js +50 -0
- package/dist/SessionHistory-BUYwbZjE.js +67 -0
- package/dist/UserMessage-CkrDUpkQ.js +76 -0
- package/dist/bs-CmZftXMO.js +35 -0
- package/dist/chatbot/BotMessage/index.d.ts +148 -0
- package/dist/chatbot/BotMessage/index.js +2 -0
- package/dist/chatbot/InputBar/index.d.ts +53 -0
- package/dist/chatbot/InputBar/index.js +2 -0
- package/dist/chatbot/MarkdownRenderer/index.d.ts +19 -0
- package/dist/chatbot/MarkdownRenderer/index.js +2 -0
- package/dist/chatbot/SessionContainer/index.d.ts +26 -0
- package/dist/chatbot/SessionContainer/index.js +2 -0
- package/dist/chatbot/SessionHistory/index.d.ts +48 -0
- package/dist/chatbot/SessionHistory/index.js +2 -0
- package/dist/chatbot/UserMessage/index.d.ts +51 -0
- package/dist/chatbot/UserMessage/index.js +2 -0
- package/dist/chatbot/index.d.ts +14 -0
- package/dist/chatbot/index.js +10 -0
- package/dist/chatbot/theme/index.d.ts +3 -0
- package/dist/chatbot/theme/index.js +3 -0
- package/dist/chatbot/theme/types.d.ts +71 -0
- package/dist/chatbot/theme/types.js +65 -0
- package/dist/chatbot/theme/useTheme.d.ts +6 -0
- package/dist/chatbot/theme/useTheme.js +9 -0
- package/dist/iconBase-CDbPVA4E.js +108 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +13 -4
- package/dist/style.css +2 -0
- package/package.json +16 -7
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useTheme as e } from "./chatbot/theme/useTheme.js";
|
|
2
|
+
import { t } from "./SessionHistory-BUYwbZjE.js";
|
|
3
|
+
import { t as n } from "./InputBar-CxSc2du6.js";
|
|
4
|
+
import { useEffect as r, useMemo as i, useRef as a } from "react";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
//#region lib/chatbot/SessionContainer/styles.module.css
|
|
7
|
+
var c = {
|
|
8
|
+
"dsi-session-container": "_dsi-session-container_1iida_1",
|
|
9
|
+
"dsi-session-container-history": "_dsi-session-container-history_1iida_11",
|
|
10
|
+
"dsi-session-container-inputbar": "_dsi-session-container-inputbar_1iida_18"
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region lib/chatbot/SessionContainer/index.tsx
|
|
14
|
+
function l({ userMessages: l, botMessages: u, orderedIds: d, botMessageRegistry: f, userMessageSlots: p, value: m, onChange: h, placeholder: g, actionButtonType: _, actionButtonEnabled: v, onActionButtonClick: y, plusSlot: b, upperSlot: x }) {
|
|
15
|
+
let S = e(), C = a(null), w = i(() => {
|
|
16
|
+
let e = new Map(l.map((e) => [e.id, e]));
|
|
17
|
+
return d.filter((t) => e.has(t)).map((t) => e.get(t).text);
|
|
18
|
+
}, [l, d]);
|
|
19
|
+
return r(() => {
|
|
20
|
+
C.current?.scrollIntoView({ behavior: "smooth" });
|
|
21
|
+
}, [d.length]), /* @__PURE__ */ s("div", {
|
|
22
|
+
className: c["dsi-session-container"],
|
|
23
|
+
style: { "--dsi-bg": S.background },
|
|
24
|
+
children: [/* @__PURE__ */ s("div", {
|
|
25
|
+
className: c["dsi-session-container-history"],
|
|
26
|
+
children: [/* @__PURE__ */ o(t, {
|
|
27
|
+
userMessages: l,
|
|
28
|
+
botMessages: u,
|
|
29
|
+
orderedIds: d,
|
|
30
|
+
botMessageRegistry: f,
|
|
31
|
+
userMessageSlots: p
|
|
32
|
+
}), /* @__PURE__ */ o("div", { ref: C })]
|
|
33
|
+
}), /* @__PURE__ */ o("div", {
|
|
34
|
+
className: c["dsi-session-container-inputbar"],
|
|
35
|
+
children: /* @__PURE__ */ o(n, {
|
|
36
|
+
value: m,
|
|
37
|
+
onChange: h,
|
|
38
|
+
placeholder: g,
|
|
39
|
+
actionButtonType: _,
|
|
40
|
+
actionButtonEnabled: v,
|
|
41
|
+
onActionButtonClick: y,
|
|
42
|
+
plusSlot: b,
|
|
43
|
+
upperSlot: x,
|
|
44
|
+
messageHistory: w
|
|
45
|
+
})
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { l as t };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { t as e } from "./UserMessage-CkrDUpkQ.js";
|
|
2
|
+
import { n as t, t as n } from "./BotMessage-DegH8sM-.js";
|
|
3
|
+
import { useEffect as r, useRef as i } from "react";
|
|
4
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/chatbot/SessionHistory/styles.module.css
|
|
6
|
+
var o = { "dsi-session-history": "_dsi-session-history_ju41j_1" };
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region lib/chatbot/SessionHistory/index.tsx
|
|
9
|
+
function s({ userMessages: s, botMessages: c, orderedIds: l, botMessageRegistry: u = t, userMessageSlots: d }) {
|
|
10
|
+
let f = new Map(s.map((e) => [e.id, e])), p = new Map(c.map((e) => [e.id, e])), m = i(null), h = i(null), g = i(!0);
|
|
11
|
+
r(() => {
|
|
12
|
+
let e = m.current;
|
|
13
|
+
if (!e) return;
|
|
14
|
+
let t = e.parentElement;
|
|
15
|
+
for (; t;) {
|
|
16
|
+
let { overflowY: e } = window.getComputedStyle(t);
|
|
17
|
+
if (e === "auto" || e === "scroll") break;
|
|
18
|
+
t = t.parentElement;
|
|
19
|
+
}
|
|
20
|
+
h.current = t ?? document.documentElement;
|
|
21
|
+
}, []);
|
|
22
|
+
let _ = c.some((e) => e.isLoading);
|
|
23
|
+
return r(() => {
|
|
24
|
+
let e = h.current;
|
|
25
|
+
if (!e) return;
|
|
26
|
+
let t = (e) => {
|
|
27
|
+
e.deltaY < 0 && _ && (g.current = !1);
|
|
28
|
+
};
|
|
29
|
+
return e.addEventListener("wheel", t, { passive: !0 }), () => e.removeEventListener("wheel", t);
|
|
30
|
+
}, [_]), r(() => {
|
|
31
|
+
_ && (g.current = !0);
|
|
32
|
+
}, [_]), r(() => {
|
|
33
|
+
if (!g.current) return;
|
|
34
|
+
let e = h.current;
|
|
35
|
+
e && (e.scrollTop = e.scrollHeight);
|
|
36
|
+
}, [l.length * 1e5 + c.reduce((e, t) => e + t.elements.reduce((e, t) => {
|
|
37
|
+
let n = t;
|
|
38
|
+
return e + (n.markdownText?.length ?? 0) + (n.content?.length ?? 0);
|
|
39
|
+
}, 0), 0)]), /* @__PURE__ */ a("div", {
|
|
40
|
+
ref: m,
|
|
41
|
+
className: o["dsi-session-history"],
|
|
42
|
+
children: l.map((t) => {
|
|
43
|
+
let r = f.get(t);
|
|
44
|
+
if (r) {
|
|
45
|
+
let n = d?.topSlotPropsMap?.[t], i = d?.bottomSlotPropsMap?.[t], o = d?.leftSlotPropsMap?.[t], s = d?.rightSlotPropsMap?.[t];
|
|
46
|
+
return /* @__PURE__ */ a(e, {
|
|
47
|
+
message: r,
|
|
48
|
+
TopSlot: d?.TopSlot,
|
|
49
|
+
topSlotProps: n,
|
|
50
|
+
BottomSlot: d?.BottomSlot,
|
|
51
|
+
bottomSlotProps: i,
|
|
52
|
+
LeftSlot: d?.LeftSlot,
|
|
53
|
+
leftSlotProps: o,
|
|
54
|
+
RightSlot: d?.RightSlot,
|
|
55
|
+
rightSlotProps: s
|
|
56
|
+
}, t);
|
|
57
|
+
}
|
|
58
|
+
let i = p.get(t);
|
|
59
|
+
return i ? /* @__PURE__ */ a(n, {
|
|
60
|
+
message: i,
|
|
61
|
+
registry: u
|
|
62
|
+
}, t) : null;
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { s as t };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useTheme as e } from "./chatbot/theme/useTheme.js";
|
|
2
|
+
import { n as t, t as n } from "./bs-CmZftXMO.js";
|
|
3
|
+
import r from "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/chatbot/UserMessage/styles.module.css
|
|
6
|
+
var o = {
|
|
7
|
+
"dsi-user-msg-wrapper": "_dsi-user-msg-wrapper_e7uu3_1",
|
|
8
|
+
"dsi-user-msg-top-slot": "_dsi-user-msg-top-slot_e7uu3_12",
|
|
9
|
+
"dsi-user-msg-row": "_dsi-user-msg-row_e7uu3_19",
|
|
10
|
+
"dsi-user-msg-left-slot": "_dsi-user-msg-left-slot_e7uu3_26",
|
|
11
|
+
"dsi-user-msg-right-slot": "_dsi-user-msg-right-slot_e7uu3_27",
|
|
12
|
+
"dsi-user-msg-bubble": "_dsi-user-msg-bubble_e7uu3_34",
|
|
13
|
+
"dsi-user-msg-bottom-slot": "_dsi-user-msg-bottom-slot_e7uu3_46",
|
|
14
|
+
"dsi-user-msg-footer": "_dsi-user-msg-footer_e7uu3_53",
|
|
15
|
+
"dsi-user-msg-copy-btn": "_dsi-user-msg-copy-btn_e7uu3_69",
|
|
16
|
+
"dsi-user-msg-time": "_dsi-user-msg-time_e7uu3_92"
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region lib/chatbot/UserMessage/index.tsx
|
|
20
|
+
function s({ message: s, TopSlot: c, topSlotProps: l, BottomSlot: u, bottomSlotProps: d, LeftSlot: f, leftSlotProps: p, RightSlot: m, rightSlotProps: h }) {
|
|
21
|
+
let g = e(), [_, v] = r.useState(!1), y = {
|
|
22
|
+
"--dsi-user-bubble-bg": g.userBubbleBg,
|
|
23
|
+
"--dsi-user-bubble-text": g.userBubbleText,
|
|
24
|
+
"--dsi-text-secondary": g.textSecondary
|
|
25
|
+
}, b = () => {
|
|
26
|
+
navigator.clipboard.writeText(s.text).then(() => {
|
|
27
|
+
v(!0), setTimeout(() => v(!1), 2e3);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return /* @__PURE__ */ a("div", {
|
|
31
|
+
className: o["dsi-user-msg-wrapper"],
|
|
32
|
+
style: y,
|
|
33
|
+
children: [
|
|
34
|
+
c && l && /* @__PURE__ */ i("div", {
|
|
35
|
+
className: o["dsi-user-msg-top-slot"],
|
|
36
|
+
children: /* @__PURE__ */ i(c, { ...l })
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ a("div", {
|
|
39
|
+
className: o["dsi-user-msg-row"],
|
|
40
|
+
children: [
|
|
41
|
+
f && p && /* @__PURE__ */ i("div", {
|
|
42
|
+
className: o["dsi-user-msg-left-slot"],
|
|
43
|
+
children: /* @__PURE__ */ i(f, { ...p })
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ i("div", {
|
|
46
|
+
className: o["dsi-user-msg-bubble"],
|
|
47
|
+
children: s.text
|
|
48
|
+
}),
|
|
49
|
+
m && h && /* @__PURE__ */ i("div", {
|
|
50
|
+
className: o["dsi-user-msg-right-slot"],
|
|
51
|
+
children: /* @__PURE__ */ i(m, { ...h })
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
u && d && /* @__PURE__ */ i("div", {
|
|
56
|
+
className: o["dsi-user-msg-bottom-slot"],
|
|
57
|
+
children: /* @__PURE__ */ i(u, { ...d })
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ a("div", {
|
|
60
|
+
className: o["dsi-user-msg-footer"],
|
|
61
|
+
children: [/* @__PURE__ */ i("button", {
|
|
62
|
+
className: o["dsi-user-msg-copy-btn"],
|
|
63
|
+
onClick: b,
|
|
64
|
+
"aria-label": "Copier le message",
|
|
65
|
+
type: "button",
|
|
66
|
+
children: i(_ ? n : t, {})
|
|
67
|
+
}), s.timeOrDateToDisplay && /* @__PURE__ */ i("span", {
|
|
68
|
+
className: o["dsi-user-msg-time"],
|
|
69
|
+
children: s.timeOrDateToDisplay
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { s as t };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { t as e } from "./iconBase-CDbPVA4E.js";
|
|
2
|
+
//#region node_modules/react-icons/bs/index.mjs
|
|
3
|
+
function t(t) {
|
|
4
|
+
return e({
|
|
5
|
+
tag: "svg",
|
|
6
|
+
attr: {
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
viewBox: "0 0 16 16"
|
|
9
|
+
},
|
|
10
|
+
child: [{
|
|
11
|
+
tag: "path",
|
|
12
|
+
attr: {
|
|
13
|
+
fillRule: "evenodd",
|
|
14
|
+
d: "M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z"
|
|
15
|
+
},
|
|
16
|
+
child: []
|
|
17
|
+
}]
|
|
18
|
+
})(t);
|
|
19
|
+
}
|
|
20
|
+
function n(t) {
|
|
21
|
+
return e({
|
|
22
|
+
tag: "svg",
|
|
23
|
+
attr: {
|
|
24
|
+
fill: "currentColor",
|
|
25
|
+
viewBox: "0 0 16 16"
|
|
26
|
+
},
|
|
27
|
+
child: [{
|
|
28
|
+
tag: "path",
|
|
29
|
+
attr: { d: "M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0" },
|
|
30
|
+
child: []
|
|
31
|
+
}]
|
|
32
|
+
})(t);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { t as n, n as t };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Données de base pour tout élément d'un message bot.
|
|
4
|
+
*
|
|
5
|
+
* ```python
|
|
6
|
+
* # Pydantic (Python)
|
|
7
|
+
* class ElementData(BaseModel):
|
|
8
|
+
* index: int
|
|
9
|
+
* type: str
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export interface ElementData {
|
|
13
|
+
/** Ordre d'affichage de l'élément dans le message */
|
|
14
|
+
index: number;
|
|
15
|
+
/** Type d'élément — doit correspondre à une clé du registry utilisé */
|
|
16
|
+
type: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Élément de texte en markdown.
|
|
20
|
+
*
|
|
21
|
+
* ```python
|
|
22
|
+
* # Pydantic (Python)
|
|
23
|
+
* class TextElementData(ElementData):
|
|
24
|
+
* type: Literal["text"] = "text"
|
|
25
|
+
* markdownText: Optional[str] = None
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export interface TextElementData extends ElementData {
|
|
29
|
+
type: "text";
|
|
30
|
+
markdownText?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Élément de raisonnement (thinking / chain-of-thought).
|
|
34
|
+
*
|
|
35
|
+
* ```python
|
|
36
|
+
* # Pydantic (Python)
|
|
37
|
+
* class ReasoningElementData(ElementData):
|
|
38
|
+
* type: Literal["reasoning"] = "reasoning"
|
|
39
|
+
* title: Optional[str] = None
|
|
40
|
+
* content: Optional[str] = None
|
|
41
|
+
* isLoading: bool = False
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export interface ReasoningElementData extends ElementData {
|
|
45
|
+
type: "reasoning";
|
|
46
|
+
title?: string;
|
|
47
|
+
content?: string;
|
|
48
|
+
isLoading?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Élément représentant une action / tâche d'outil.
|
|
52
|
+
*
|
|
53
|
+
* ```python
|
|
54
|
+
* # Pydantic (Python)
|
|
55
|
+
* class ToolElementData(ElementData):
|
|
56
|
+
* type: Literal["tool"] = "tool"
|
|
57
|
+
* title: Optional[str] = None
|
|
58
|
+
* content: Optional[str] = None
|
|
59
|
+
* isLoading: bool = False
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export interface ToolElementData extends ElementData {
|
|
63
|
+
type: "tool";
|
|
64
|
+
title?: string;
|
|
65
|
+
content?: string;
|
|
66
|
+
isLoading?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Élément représentant une recherche internet.
|
|
70
|
+
*
|
|
71
|
+
* ```python
|
|
72
|
+
* # Pydantic (Python)
|
|
73
|
+
* class SearchElementData(ElementData):
|
|
74
|
+
* type: Literal["search"] = "search"
|
|
75
|
+
* title: Optional[str] = None
|
|
76
|
+
* content: Optional[str] = None
|
|
77
|
+
* isLoading: bool = False
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export interface SearchElementData extends ElementData {
|
|
81
|
+
type: "search";
|
|
82
|
+
title?: string;
|
|
83
|
+
content?: string;
|
|
84
|
+
isLoading?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Type générique d'un registry de composants BotMessage */
|
|
87
|
+
export type BotMessageRegistry = Record<string, React.ComponentType<any>>;
|
|
88
|
+
/**
|
|
89
|
+
* Registry de base fourni par la librairie.
|
|
90
|
+
* Peut être étendu via spread : `{ ...defaultBotMessageRegistry, myType: MyComponent }`.
|
|
91
|
+
*/
|
|
92
|
+
export declare const defaultBotMessageRegistry: BotMessageRegistry;
|
|
93
|
+
/**
|
|
94
|
+
* Données d'un message bot.
|
|
95
|
+
*
|
|
96
|
+
* ```python
|
|
97
|
+
* # Pydantic (Python)
|
|
98
|
+
* from typing import Union
|
|
99
|
+
* BotElementDataUnion = Union[
|
|
100
|
+
* TextElementData,
|
|
101
|
+
* ReasoningElementData,
|
|
102
|
+
* ToolElementData,
|
|
103
|
+
* SearchElementData,
|
|
104
|
+
* ]
|
|
105
|
+
* class BotMessageData(BaseModel):
|
|
106
|
+
* id: str
|
|
107
|
+
* elements: list[BotElementDataUnion]
|
|
108
|
+
* timeOrDateToDisplay: Optional[str] = None
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export interface BotMessageData {
|
|
112
|
+
/** Identifiant unique du message */
|
|
113
|
+
id: string;
|
|
114
|
+
/** Éléments du message, affichés dans l'ordre croissant de leur `index` */
|
|
115
|
+
elements: ElementData[];
|
|
116
|
+
/** Heure ou date d'envoi (format libre) — affiché au hover */
|
|
117
|
+
timeOrDateToDisplay?: string;
|
|
118
|
+
/** Indique si le message est en cours de génération (affiche l'indicateur de chargement) */
|
|
119
|
+
isLoading?: boolean;
|
|
120
|
+
}
|
|
121
|
+
export interface BotMessageProps {
|
|
122
|
+
/** Données du message bot */
|
|
123
|
+
message: BotMessageData;
|
|
124
|
+
/**
|
|
125
|
+
* Registry des composants d'affichage.
|
|
126
|
+
* Par défaut : `defaultBotMessageRegistry`.
|
|
127
|
+
* Pour étendre : `{ ...defaultBotMessageRegistry, myType: MyComp }`.
|
|
128
|
+
*/
|
|
129
|
+
registry?: BotMessageRegistry;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Affichage d'un message bot en full-width sans bulle.
|
|
133
|
+
*
|
|
134
|
+
* Les éléments sont triés par leur `index` et rendus via le registry.
|
|
135
|
+
* Extensible via le pattern registry : passez un registry personnalisé
|
|
136
|
+
* pour ajouter de nouveaux types d'éléments.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <BotMessage
|
|
141
|
+
* message={{
|
|
142
|
+
* id: "1",
|
|
143
|
+
* elements: [{ index: 0, type: "text", markdownText: "## Bonjour" }],
|
|
144
|
+
* }}
|
|
145
|
+
* />
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function BotMessage({ message, registry, }: BotMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Type du bouton d'action principal */
|
|
3
|
+
export type ActionButtonType = "send" | "stop" | "vocal" | "none";
|
|
4
|
+
export interface InputBarProps {
|
|
5
|
+
/** Valeur courante du champ texte */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Callback de changement du texte */
|
|
8
|
+
onChange: (value: string) => void;
|
|
9
|
+
/** Placeholder du champ texte */
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** Type du bouton d'action à droite */
|
|
12
|
+
actionButtonType?: ActionButtonType;
|
|
13
|
+
/** Active ou désactive le bouton d'action */
|
|
14
|
+
actionButtonEnabled?: boolean;
|
|
15
|
+
/** Callback du bouton d'action — reçoit le type d'action */
|
|
16
|
+
onActionButtonClick?: (type: ActionButtonType) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Slot du bouton "+" — affiché dans un popup au-dessus de l'input.
|
|
19
|
+
* Le popup s'ouvre et se ferme au clic sur le bouton "+".
|
|
20
|
+
*/
|
|
21
|
+
plusSlot?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Slot supérieur — affiché au-dessus de la barre d'input,
|
|
24
|
+
* même largeur, visuellement lié (ex: aperçus de fichiers, suggestions).
|
|
25
|
+
*/
|
|
26
|
+
upperSlot?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Historique des messages précédents pour la navigation clavier.
|
|
29
|
+
* Quand le champ est vide et focusé, ↑ / ↓ parcourent cette liste.
|
|
30
|
+
* SessionContainer alimente automatiquement cette prop.
|
|
31
|
+
*/
|
|
32
|
+
messageHistory?: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Barre d'input pour envoyer des messages dans une interface chatbot.
|
|
36
|
+
*
|
|
37
|
+
* - Bouton "+" à gauche ouvre/ferme un slot popup (ex: menu de pièces jointes)
|
|
38
|
+
* - Zone de texte auto-extensible
|
|
39
|
+
* - Bouton d'action configurable à droite : send / stop / vocal / none
|
|
40
|
+
* - Slot supérieur optionnel (même largeur, visuellement fusionné)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <InputBar
|
|
45
|
+
* value={input}
|
|
46
|
+
* onChange={setInput}
|
|
47
|
+
* actionButtonType="send"
|
|
48
|
+
* actionButtonEnabled={input.trim().length > 0}
|
|
49
|
+
* onActionButtonClick={() => handleSend()}
|
|
50
|
+
* />
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function InputBar({ value, onChange, placeholder, actionButtonType, actionButtonEnabled, onActionButtonClick, plusSlot, upperSlot, messageHistory, }: InputBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface MarkdownRendererProps {
|
|
2
|
+
/** Texte markdown à afficher */
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Composant d'affichage de contenu markdown.
|
|
7
|
+
*
|
|
8
|
+
* Wrapper simplifié autour de `react-markdown` avec :
|
|
9
|
+
* - Plugins `remarkGfm` et `rehypeRaw` préconfigurés
|
|
10
|
+
* - Bouton de copie au hover sur les blocs de code
|
|
11
|
+
* - Style neutre et moderne (inspiré ChatGPT)
|
|
12
|
+
* - Adaptatif : pas de background ni de largeur/hauteur imposés
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <MarkdownRenderer text="## Bonjour\n\nUn **exemple** de markdown." />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function MarkdownRenderer({ text }: MarkdownRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SessionHistoryProps } from '../SessionHistory';
|
|
2
|
+
import { InputBarProps } from '../InputBar';
|
|
3
|
+
export type SessionContainerProps<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>> = SessionHistoryProps<TTop, TBottom, TLeft, TRight> & InputBarProps;
|
|
4
|
+
/**
|
|
5
|
+
* Composant tout-en-un combinant `SessionHistory` et `InputBar`.
|
|
6
|
+
*
|
|
7
|
+
* Fait défiler automatiquement vers le dernier message à chaque
|
|
8
|
+
* mise à jour de la conversation.
|
|
9
|
+
*
|
|
10
|
+
* Ses props sont la somme des props de `SessionHistory` et `InputBar`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <SessionContainer
|
|
15
|
+
* userMessages={userMsgs}
|
|
16
|
+
* botMessages={botMsgs}
|
|
17
|
+
* orderedIds={ids}
|
|
18
|
+
* value={input}
|
|
19
|
+
* onChange={setInput}
|
|
20
|
+
* actionButtonType="send"
|
|
21
|
+
* actionButtonEnabled={input.trim().length > 0}
|
|
22
|
+
* onActionButtonClick={handleSend}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function SessionContainer<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>>({ userMessages, botMessages, orderedIds, botMessageRegistry, userMessageSlots, value, onChange, placeholder, actionButtonType, actionButtonEnabled, onActionButtonClick, plusSlot, upperSlot, }: SessionContainerProps<TTop, TBottom, TLeft, TRight>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { UserMessageData, UserMessageProps } from '../UserMessage';
|
|
2
|
+
import { BotMessageData, BotMessageRegistry } from '../BotMessage';
|
|
3
|
+
/** Props des slots partagés pour tous les UserMessage de la session */
|
|
4
|
+
export interface SessionUserMessageSlots<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>> {
|
|
5
|
+
TopSlot?: UserMessageProps<TTop, TBottom, TLeft, TRight>["TopSlot"];
|
|
6
|
+
BottomSlot?: UserMessageProps<TTop, TBottom, TLeft, TRight>["BottomSlot"];
|
|
7
|
+
LeftSlot?: UserMessageProps<TTop, TBottom, TLeft, TRight>["LeftSlot"];
|
|
8
|
+
RightSlot?: UserMessageProps<TTop, TBottom, TLeft, TRight>["RightSlot"];
|
|
9
|
+
/** Map id → topSlotProps (pour personnaliser par message) */
|
|
10
|
+
topSlotPropsMap?: Record<string, TTop>;
|
|
11
|
+
/** Map id → bottomSlotProps */
|
|
12
|
+
bottomSlotPropsMap?: Record<string, TBottom>;
|
|
13
|
+
/** Map id → leftSlotProps */
|
|
14
|
+
leftSlotPropsMap?: Record<string, TLeft>;
|
|
15
|
+
/** Map id → rightSlotProps */
|
|
16
|
+
rightSlotPropsMap?: Record<string, TRight>;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionHistoryProps<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>> {
|
|
19
|
+
/** Liste des messages utilisateur */
|
|
20
|
+
userMessages: UserMessageData[];
|
|
21
|
+
/** Liste des messages bot */
|
|
22
|
+
botMessages: BotMessageData[];
|
|
23
|
+
/**
|
|
24
|
+
* Liste ordonnée des ids qui définit l'ordre d'affichage.
|
|
25
|
+
* Doit contenir tous les ids de `userMessages` et `botMessages`.
|
|
26
|
+
*/
|
|
27
|
+
orderedIds: string[];
|
|
28
|
+
/** Registry de composants pour BotMessage (défaut : defaultBotMessageRegistry) */
|
|
29
|
+
botMessageRegistry?: BotMessageRegistry;
|
|
30
|
+
/** Slots et données de slots partagés pour les UserMessage */
|
|
31
|
+
userMessageSlots?: SessionUserMessageSlots<TTop, TBottom, TLeft, TRight>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Affiche une conversation complète (sans InputBar).
|
|
35
|
+
*
|
|
36
|
+
* Les messages sont ordonnés selon `orderedIds`. Les slots des messages
|
|
37
|
+
* utilisateur sont partagés et peuvent être personnalisés par message via les maps.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <SessionHistory
|
|
42
|
+
* userMessages={userMsgs}
|
|
43
|
+
* botMessages={botMsgs}
|
|
44
|
+
* orderedIds={["1", "2", "3"]}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function SessionHistory<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>>({ userMessages, botMessages, orderedIds, botMessageRegistry, userMessageSlots, }: SessionHistoryProps<TTop, TBottom, TLeft, TRight>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Données d'un message utilisateur.
|
|
4
|
+
*
|
|
5
|
+
* ```python
|
|
6
|
+
* # Pydantic (Python)
|
|
7
|
+
* class UserMessageData(BaseModel):
|
|
8
|
+
* id: str
|
|
9
|
+
* text: str
|
|
10
|
+
* timeOrDateToDisplay: Optional[str] = None
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export interface UserMessageData {
|
|
14
|
+
/** Identifiant unique du message */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Contenu textuel du message */
|
|
17
|
+
text: string;
|
|
18
|
+
/** Heure ou date d'envoi (format libre) — affiché au hover */
|
|
19
|
+
timeOrDateToDisplay?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Props du composant `UserMessage`.
|
|
23
|
+
*
|
|
24
|
+
* Les slots sont typés génériquement pour passer des données typées
|
|
25
|
+
* aux composants de slot. Voir le pattern session_pattern pour l'usage.
|
|
26
|
+
*/
|
|
27
|
+
export interface UserMessageProps<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>> {
|
|
28
|
+
/** Données du message */
|
|
29
|
+
message: UserMessageData;
|
|
30
|
+
TopSlot?: React.ComponentType<TTop>;
|
|
31
|
+
topSlotProps?: TTop;
|
|
32
|
+
BottomSlot?: React.ComponentType<TBottom>;
|
|
33
|
+
bottomSlotProps?: TBottom;
|
|
34
|
+
LeftSlot?: React.ComponentType<TLeft>;
|
|
35
|
+
leftSlotProps?: TLeft;
|
|
36
|
+
RightSlot?: React.ComponentType<TRight>;
|
|
37
|
+
rightSlotProps?: TRight;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Affichage d'un message utilisateur sous forme de bulle alignée à droite.
|
|
41
|
+
*
|
|
42
|
+
* Inclut un timestamp discret (visible au hover), et 4 slots optionnels
|
|
43
|
+
* typés (top, bottom, left, right) pour injecter des éléments d'UI
|
|
44
|
+
* autour de la bulle.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <UserMessage message={{ id: "1", text: "Bonjour !", timeOrDateToDisplay: "14:32" }} />
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function UserMessage<TTop = Record<string, never>, TBottom = Record<string, never>, TLeft = Record<string, never>, TRight = Record<string, never>>({ message, TopSlot, topSlotProps, BottomSlot, bottomSlotProps, LeftSlot, leftSlotProps, RightSlot, rightSlotProps, }: UserMessageProps<TTop, TBottom, TLeft, TRight>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { setTheme, getTheme, getCurrentTheme, useTheme } from './theme';
|
|
2
|
+
export type { ColorPalette, Theme } from './theme';
|
|
3
|
+
export { MarkdownRenderer } from './MarkdownRenderer';
|
|
4
|
+
export type { MarkdownRendererProps } from './MarkdownRenderer';
|
|
5
|
+
export { UserMessage } from './UserMessage';
|
|
6
|
+
export type { UserMessageData, UserMessageProps } from './UserMessage';
|
|
7
|
+
export { BotMessage, defaultBotMessageRegistry } from './BotMessage';
|
|
8
|
+
export type { ElementData, TextElementData, ReasoningElementData, ToolElementData, SearchElementData, BotMessageData, BotMessageRegistry, BotMessageProps, } from './BotMessage';
|
|
9
|
+
export { SessionHistory } from './SessionHistory';
|
|
10
|
+
export type { SessionHistoryProps, SessionUserMessageSlots } from './SessionHistory';
|
|
11
|
+
export { InputBar } from './InputBar';
|
|
12
|
+
export type { InputBarProps, ActionButtonType } from './InputBar';
|
|
13
|
+
export { SessionContainer } from './SessionContainer';
|
|
14
|
+
export type { SessionContainerProps } from './SessionContainer';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as e } from "../MarkdownRenderer-vU2aoyaG.js";
|
|
2
|
+
import { getCurrentTheme as t, getTheme as n, setTheme as r } from "./theme/types.js";
|
|
3
|
+
import { useTheme as i } from "./theme/useTheme.js";
|
|
4
|
+
import "./theme/index.js";
|
|
5
|
+
import { t as a } from "../UserMessage-CkrDUpkQ.js";
|
|
6
|
+
import { n as o, t as s } from "../BotMessage-DegH8sM-.js";
|
|
7
|
+
import { t as c } from "../SessionHistory-BUYwbZjE.js";
|
|
8
|
+
import { t as l } from "../InputBar-CxSc2du6.js";
|
|
9
|
+
import { t as u } from "../SessionContainer-RrzUh_no.js";
|
|
10
|
+
export { s as BotMessage, l as InputBar, e as MarkdownRenderer, u as SessionContainer, c as SessionHistory, a as UserMessage, o as defaultBotMessageRegistry, t as getCurrentTheme, n as getTheme, r as setTheme, i as useTheme };
|