@shane_donnelly/dsi-internal-react-utils 1.2.1 → 1.3.1
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/BotMessage-9XyyKf52.js +242 -0
- package/dist/{MarkdownRenderer-vU2aoyaG.js → MarkdownRenderer-DsCX-ARI.js} +1 -1
- package/dist/SessionContainer-C4YWEApz.js +48 -0
- package/dist/{SessionHistory-BUYwbZjE.js → SessionHistory-uFMdR01J.js} +11 -23
- package/dist/{UserMessage-CkrDUpkQ.js → UserMessage-iwSKfrPo.js} +1 -1
- package/dist/{bs-CmZftXMO.js → bs-BGOTKj78.js} +20 -2
- package/dist/chatbot/BotMessage/ImageElement.d.ts +21 -0
- package/dist/chatbot/BotMessage/ImageElement.js +68 -0
- package/dist/chatbot/BotMessage/IsolatedHtmlElement.d.ts +26 -0
- package/dist/chatbot/BotMessage/IsolatedHtmlElement.js +35 -0
- package/dist/chatbot/BotMessage/PlotlyChartElement.d.ts +23 -0
- package/dist/chatbot/BotMessage/PlotlyChartElement.js +30 -0
- package/dist/chatbot/BotMessage/VegaChartElement.d.ts +21 -0
- package/dist/chatbot/BotMessage/VegaChartElement.js +17 -0
- package/dist/chatbot/BotMessage/index.d.ts +6 -16
- package/dist/chatbot/BotMessage/index.js +1 -1
- package/dist/chatbot/BotMessage/types.d.ts +16 -0
- package/dist/chatbot/BotMessage/types.js +0 -0
- package/dist/chatbot/InputBar/index.js +1 -1
- package/dist/chatbot/MarkdownRenderer/index.js +1 -1
- package/dist/chatbot/SessionContainer/index.js +1 -1
- package/dist/chatbot/SessionHistory/index.js +1 -1
- package/dist/chatbot/UserMessage/index.js +1 -1
- package/dist/chatbot/index.d.ts +1 -1
- package/dist/chatbot/index.js +6 -6
- package/dist/keycloak/core/client.d.ts +1 -1
- package/dist/keycloak/core/client.js +6 -3
- package/dist/keycloak/react/KeycloakProvider/index.js +16 -6
- package/dist/main.d.ts +1 -1
- package/dist/main.js +6 -6
- package/dist/style.css +1 -1
- package/dist/styles.module-DTfCO5TA.js +34 -0
- package/package.json +9 -5
- package/dist/BotMessage-DegH8sM-.js +0 -255
- package/dist/SessionContainer-DfTD7hX3.js +0 -50
- /package/dist/{InputBar-CVy2_QtC.js → InputBar-DOkn2T-l.js} +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { t as e } from "./MarkdownRenderer-DsCX-ARI.js";
|
|
2
|
+
import { useTheme as t } from "./chatbot/theme/useTheme.js";
|
|
3
|
+
import { t as n } from "./iconBase-CDbPVA4E.js";
|
|
4
|
+
import { n as r, t as i } from "./bs-BGOTKj78.js";
|
|
5
|
+
import { t as a } from "./styles.module-DTfCO5TA.js";
|
|
6
|
+
import { ImageElement as o } from "./chatbot/BotMessage/ImageElement.js";
|
|
7
|
+
import { IsolatedHtmlElement as s } from "./chatbot/BotMessage/IsolatedHtmlElement.js";
|
|
8
|
+
import { VegaChartElement as c } from "./chatbot/BotMessage/VegaChartElement.js";
|
|
9
|
+
import { PlotlyChartElement as l } from "./chatbot/BotMessage/PlotlyChartElement.js";
|
|
10
|
+
import { useEffect as u, useState as d } from "react";
|
|
11
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
12
|
+
//#region node_modules/react-icons/tb/index.mjs
|
|
13
|
+
function h(e) {
|
|
14
|
+
return n({
|
|
15
|
+
tag: "svg",
|
|
16
|
+
attr: {
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
fill: "none",
|
|
19
|
+
stroke: "currentColor",
|
|
20
|
+
strokeWidth: "2",
|
|
21
|
+
strokeLinecap: "round",
|
|
22
|
+
strokeLinejoin: "round"
|
|
23
|
+
},
|
|
24
|
+
child: [
|
|
25
|
+
{
|
|
26
|
+
tag: "path",
|
|
27
|
+
attr: { d: "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" },
|
|
28
|
+
child: []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
tag: "path",
|
|
32
|
+
attr: { d: "M3.6 9h16.8" },
|
|
33
|
+
child: []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
tag: "path",
|
|
37
|
+
attr: { d: "M3.6 15h16.8" },
|
|
38
|
+
child: []
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
tag: "path",
|
|
42
|
+
attr: { d: "M11.5 3a17 17 0 0 0 0 18" },
|
|
43
|
+
child: []
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
tag: "path",
|
|
47
|
+
attr: { d: "M12.5 3a17 17 0 0 1 0 18" },
|
|
48
|
+
child: []
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
})(e);
|
|
52
|
+
}
|
|
53
|
+
function g(e) {
|
|
54
|
+
return n({
|
|
55
|
+
tag: "svg",
|
|
56
|
+
attr: {
|
|
57
|
+
viewBox: "0 0 24 24",
|
|
58
|
+
fill: "none",
|
|
59
|
+
stroke: "currentColor",
|
|
60
|
+
strokeWidth: "2",
|
|
61
|
+
strokeLinecap: "round",
|
|
62
|
+
strokeLinejoin: "round"
|
|
63
|
+
},
|
|
64
|
+
child: [{
|
|
65
|
+
tag: "path",
|
|
66
|
+
attr: { d: "M6 9l6 6l6 -6" },
|
|
67
|
+
child: []
|
|
68
|
+
}]
|
|
69
|
+
})(e);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region lib/chatbot/BotMessage/index.tsx
|
|
73
|
+
function _({ markdownText: t }) {
|
|
74
|
+
return t ? /* @__PURE__ */ p(e, { text: t }) : null;
|
|
75
|
+
}
|
|
76
|
+
function v() {
|
|
77
|
+
return /* @__PURE__ */ p("svg", {
|
|
78
|
+
className: a["dsi-bot-loading-dot"],
|
|
79
|
+
width: "10",
|
|
80
|
+
height: "10",
|
|
81
|
+
viewBox: "0 0 10 10",
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
children: /* @__PURE__ */ p("circle", {
|
|
84
|
+
cx: "5",
|
|
85
|
+
cy: "5",
|
|
86
|
+
r: "4",
|
|
87
|
+
fill: "currentColor"
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function y({ text: e }) {
|
|
92
|
+
let [t, n] = d(!1);
|
|
93
|
+
return /* @__PURE__ */ p("button", {
|
|
94
|
+
className: a["dsi-bot-copy-btn"],
|
|
95
|
+
onClick: () => {
|
|
96
|
+
navigator.clipboard.writeText(e).then(() => {
|
|
97
|
+
n(!0), setTimeout(() => n(!1), 2e3);
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
"aria-label": "Copier le message",
|
|
101
|
+
type: "button",
|
|
102
|
+
children: p(t ? i : r, {})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function b({ defaultOpen: e, closeWhen: t = !1, header: n, content: r, className: i, style: o }) {
|
|
106
|
+
let [s, c] = d(e);
|
|
107
|
+
return u(() => {
|
|
108
|
+
t && c(!1);
|
|
109
|
+
}, [t]), /* @__PURE__ */ m("div", {
|
|
110
|
+
className: i,
|
|
111
|
+
style: o,
|
|
112
|
+
children: [/* @__PURE__ */ m("div", {
|
|
113
|
+
className: a["dsi-bot-collapsible-header"],
|
|
114
|
+
onClick: () => c((e) => !e),
|
|
115
|
+
role: "button",
|
|
116
|
+
tabIndex: 0,
|
|
117
|
+
onKeyDown: (e) => {
|
|
118
|
+
(e.key === "Enter" || e.key === " ") && c((e) => !e);
|
|
119
|
+
},
|
|
120
|
+
"aria-expanded": s,
|
|
121
|
+
children: [/* @__PURE__ */ p("div", {
|
|
122
|
+
className: a["dsi-bot-collapsible-header-inner"],
|
|
123
|
+
children: n
|
|
124
|
+
}), /* @__PURE__ */ p(g, {
|
|
125
|
+
className: a["dsi-bot-collapse-chevron"],
|
|
126
|
+
style: { transform: s ? "rotate(0deg)" : "rotate(-90deg)" },
|
|
127
|
+
"aria-hidden": "true"
|
|
128
|
+
})]
|
|
129
|
+
}), s && r && /* @__PURE__ */ p("div", {
|
|
130
|
+
className: a["dsi-bot-collapsible-body"],
|
|
131
|
+
children: r
|
|
132
|
+
})]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function x({ title: e, content: n, isLoading: r = !1, _isLastElement: i = !1 }) {
|
|
136
|
+
let o = t();
|
|
137
|
+
return /* @__PURE__ */ p(b, {
|
|
138
|
+
defaultOpen: r || i,
|
|
139
|
+
closeWhen: !r && !i,
|
|
140
|
+
className: a["dsi-bot-reasoning"],
|
|
141
|
+
style: {
|
|
142
|
+
"--dsi-reasoning-border": o.reasoningBorder,
|
|
143
|
+
"--dsi-reasoning-text": o.reasoningText
|
|
144
|
+
},
|
|
145
|
+
header: /* @__PURE__ */ p("span", {
|
|
146
|
+
className: a["dsi-bot-element-title"],
|
|
147
|
+
children: e || "Raisonnement"
|
|
148
|
+
}),
|
|
149
|
+
content: n ? /* @__PURE__ */ p("p", {
|
|
150
|
+
className: a["dsi-bot-collapsible-content"],
|
|
151
|
+
children: n
|
|
152
|
+
}) : null
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function S({ title: e, content: n, isLoading: r = !1, _isLastElement: i = !1 }) {
|
|
156
|
+
let o = t();
|
|
157
|
+
return /* @__PURE__ */ p(b, {
|
|
158
|
+
defaultOpen: r || i,
|
|
159
|
+
closeWhen: !r && !i,
|
|
160
|
+
className: a["dsi-bot-tool"],
|
|
161
|
+
style: {
|
|
162
|
+
"--dsi-tool-border": o.toolBorder,
|
|
163
|
+
"--dsi-text-secondary": o.textSecondary,
|
|
164
|
+
"--dsi-text-primary": o.textPrimary
|
|
165
|
+
},
|
|
166
|
+
header: /* @__PURE__ */ m(f, { children: [r && /* @__PURE__ */ p("span", { className: a["dsi-bot-spinner"] }), /* @__PURE__ */ p("span", {
|
|
167
|
+
className: a["dsi-bot-element-title"],
|
|
168
|
+
children: e || "Outil"
|
|
169
|
+
})] }),
|
|
170
|
+
content: n ? /* @__PURE__ */ p("p", {
|
|
171
|
+
className: a["dsi-bot-collapsible-content"],
|
|
172
|
+
children: n
|
|
173
|
+
}) : null
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function C({ title: e, content: n, isLoading: r = !1, _isLastElement: i = !1 }) {
|
|
177
|
+
let o = t();
|
|
178
|
+
return /* @__PURE__ */ p(b, {
|
|
179
|
+
defaultOpen: r || i,
|
|
180
|
+
closeWhen: !r && !i,
|
|
181
|
+
className: a["dsi-bot-search"],
|
|
182
|
+
style: {
|
|
183
|
+
"--dsi-tool-border": o.toolBorder,
|
|
184
|
+
"--dsi-text-secondary": o.textSecondary,
|
|
185
|
+
"--dsi-text-primary": o.textPrimary
|
|
186
|
+
},
|
|
187
|
+
header: /* @__PURE__ */ m(f, { children: [
|
|
188
|
+
/* @__PURE__ */ p(h, { className: a["dsi-bot-search-icon"] }),
|
|
189
|
+
r && /* @__PURE__ */ p("span", { className: a["dsi-bot-spinner"] }),
|
|
190
|
+
/* @__PURE__ */ p("span", {
|
|
191
|
+
className: a["dsi-bot-element-title"],
|
|
192
|
+
children: e || "Recherche"
|
|
193
|
+
})
|
|
194
|
+
] }),
|
|
195
|
+
content: n ? /* @__PURE__ */ p("p", {
|
|
196
|
+
className: a["dsi-bot-collapsible-content"],
|
|
197
|
+
children: n
|
|
198
|
+
}) : null
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
var w = {
|
|
202
|
+
text: _,
|
|
203
|
+
reasoning: x,
|
|
204
|
+
tool: S,
|
|
205
|
+
search: C,
|
|
206
|
+
image: o,
|
|
207
|
+
isolatedHtml: s,
|
|
208
|
+
vegaChart: c,
|
|
209
|
+
plotlyChart: l
|
|
210
|
+
};
|
|
211
|
+
function T({ message: e, registry: n = w }) {
|
|
212
|
+
let r = t(), i = [...e.elements].sort((e, t) => e.index - t.index), o = [...i].reverse().find((e) => e.type === "text")?.markdownText ?? "";
|
|
213
|
+
return /* @__PURE__ */ m("div", {
|
|
214
|
+
className: a["dsi-bot-msg"],
|
|
215
|
+
style: {
|
|
216
|
+
"--dsi-text-primary": r.textPrimary,
|
|
217
|
+
"--dsi-text-secondary": r.textSecondary,
|
|
218
|
+
"--dsi-border": r.border
|
|
219
|
+
},
|
|
220
|
+
children: [
|
|
221
|
+
e.isLoading && /* @__PURE__ */ p(v, {}),
|
|
222
|
+
i.map((e, t) => {
|
|
223
|
+
let r = n[e.type];
|
|
224
|
+
if (!r) return null;
|
|
225
|
+
let a = t === i.length - 1;
|
|
226
|
+
return /* @__PURE__ */ p(r, {
|
|
227
|
+
...e,
|
|
228
|
+
_isLastElement: a
|
|
229
|
+
}, `${e.type}-${e.index}-${t}`);
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ m("div", {
|
|
232
|
+
className: a["dsi-bot-msg-footer"],
|
|
233
|
+
children: [!e.isLoading && /* @__PURE__ */ p(y, { text: o }), !e.isLoading && e.timeOrDateToDisplay && /* @__PURE__ */ p("span", {
|
|
234
|
+
className: a["dsi-bot-msg-time"],
|
|
235
|
+
children: e.timeOrDateToDisplay
|
|
236
|
+
})]
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
export { w as n, T as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTheme as e } from "./chatbot/theme/useTheme.js";
|
|
2
|
-
import { n as t, t as n } from "./bs-
|
|
2
|
+
import { n as t, t as n } from "./bs-BGOTKj78.js";
|
|
3
3
|
import { useRef as r, useState as i } from "react";
|
|
4
4
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
5
|
//#region \0rolldown/runtime.js
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useTheme as e } from "./chatbot/theme/useTheme.js";
|
|
2
|
+
import { t } from "./SessionHistory-uFMdR01J.js";
|
|
3
|
+
import { t as n } from "./InputBar-DOkn2T-l.js";
|
|
4
|
+
import { useMemo as r } from "react";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
//#region lib/chatbot/SessionContainer/styles.module.css
|
|
7
|
+
var o = {
|
|
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 s({ userMessages: s, botMessages: c, orderedIds: l, botMessageRegistry: u, userMessageSlots: d, alternativeScreenComponent: f, isAlternativeScreenActive: p = !1, value: m, onChange: h, placeholder: g, actionButtonType: _, actionButtonEnabled: v, onActionButtonClick: y, plusSlot: b, upperSlot: x }) {
|
|
15
|
+
let S = e(), C = r(() => {
|
|
16
|
+
let e = new Map(s.map((e) => [e.id, e]));
|
|
17
|
+
return l.filter((t) => e.has(t)).map((t) => e.get(t).text);
|
|
18
|
+
}, [s, l]);
|
|
19
|
+
return /* @__PURE__ */ a("div", {
|
|
20
|
+
className: o["dsi-session-container"],
|
|
21
|
+
style: { "--dsi-bg": S.background },
|
|
22
|
+
children: [/* @__PURE__ */ i("div", {
|
|
23
|
+
className: o["dsi-session-container-history"],
|
|
24
|
+
children: p ? f ?? null : /* @__PURE__ */ i(t, {
|
|
25
|
+
userMessages: s,
|
|
26
|
+
botMessages: c,
|
|
27
|
+
orderedIds: l,
|
|
28
|
+
botMessageRegistry: u,
|
|
29
|
+
userMessageSlots: d
|
|
30
|
+
})
|
|
31
|
+
}), /* @__PURE__ */ i("div", {
|
|
32
|
+
className: o["dsi-session-container-inputbar"],
|
|
33
|
+
children: /* @__PURE__ */ i(n, {
|
|
34
|
+
value: m,
|
|
35
|
+
onChange: h,
|
|
36
|
+
placeholder: g,
|
|
37
|
+
actionButtonType: _,
|
|
38
|
+
actionButtonEnabled: v,
|
|
39
|
+
onActionButtonClick: y,
|
|
40
|
+
plusSlot: b,
|
|
41
|
+
upperSlot: x,
|
|
42
|
+
messageHistory: C
|
|
43
|
+
})
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { s as t };
|
|
@@ -1,37 +1,25 @@
|
|
|
1
|
-
import { t as e } from "./UserMessage-
|
|
2
|
-
import { n as t, t as n } from "./BotMessage-
|
|
1
|
+
import { t as e } from "./UserMessage-iwSKfrPo.js";
|
|
2
|
+
import { n as t, t as n } from "./BotMessage-9XyyKf52.js";
|
|
3
3
|
import { useEffect as r, useRef as i } from "react";
|
|
4
4
|
import { jsx as a } from "react/jsx-runtime";
|
|
5
5
|
//#region lib/chatbot/SessionHistory/styles.module.css
|
|
6
|
-
var o = { "dsi-session-history": "_dsi-session-
|
|
6
|
+
var o = { "dsi-session-history": "_dsi-session-history_13fgm_1" };
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region lib/chatbot/SessionHistory/index.tsx
|
|
9
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(
|
|
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);
|
|
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(!0);
|
|
23
11
|
return r(() => {
|
|
24
|
-
let e =
|
|
12
|
+
let e = m.current;
|
|
25
13
|
if (!e) return;
|
|
26
14
|
let t = (e) => {
|
|
27
|
-
e.deltaY < 0 &&
|
|
15
|
+
e.deltaY < 0 && (h.current = !1);
|
|
28
16
|
};
|
|
29
17
|
return e.addEventListener("wheel", t, { passive: !0 }), () => e.removeEventListener("wheel", t);
|
|
30
|
-
}, [
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
if (!
|
|
34
|
-
let e =
|
|
18
|
+
}, []), r(() => {
|
|
19
|
+
h.current = !0;
|
|
20
|
+
}, [l.length]), r(() => {
|
|
21
|
+
if (!h.current) return;
|
|
22
|
+
let e = m.current;
|
|
35
23
|
e && (e.scrollTop = e.scrollHeight);
|
|
36
24
|
}, [l.length * 1e5 + c.reduce((e, t) => e + t.elements.reduce((e, t) => {
|
|
37
25
|
let n = t;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTheme as e } from "./chatbot/theme/useTheme.js";
|
|
2
|
-
import { n as t, t as n } from "./bs-
|
|
2
|
+
import { n as t, t as n } from "./bs-BGOTKj78.js";
|
|
3
3
|
import r from "react";
|
|
4
4
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
5
|
//#region lib/chatbot/UserMessage/styles.module.css
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { t as e } from "./iconBase-CDbPVA4E.js";
|
|
2
2
|
//#region node_modules/react-icons/bs/index.mjs
|
|
3
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: { d: "M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5" },
|
|
13
|
+
child: []
|
|
14
|
+
}, {
|
|
15
|
+
tag: "path",
|
|
16
|
+
attr: { d: "M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z" },
|
|
17
|
+
child: []
|
|
18
|
+
}]
|
|
19
|
+
})(t);
|
|
20
|
+
}
|
|
21
|
+
function n(t) {
|
|
4
22
|
return e({
|
|
5
23
|
tag: "svg",
|
|
6
24
|
attr: {
|
|
@@ -17,7 +35,7 @@ function t(t) {
|
|
|
17
35
|
}]
|
|
18
36
|
})(t);
|
|
19
37
|
}
|
|
20
|
-
function
|
|
38
|
+
function r(t) {
|
|
21
39
|
return e({
|
|
22
40
|
tag: "svg",
|
|
23
41
|
attr: {
|
|
@@ -32,4 +50,4 @@ function n(t) {
|
|
|
32
50
|
})(t);
|
|
33
51
|
}
|
|
34
52
|
//#endregion
|
|
35
|
-
export { t as
|
|
53
|
+
export { n, t as r, r as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ElementData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Élément image — affichage d'une image avec spinner pendant le chargement
|
|
4
|
+
* et état d'erreur si le chargement échoue.
|
|
5
|
+
*
|
|
6
|
+
* ```python
|
|
7
|
+
* # Pydantic (Python)
|
|
8
|
+
* class ImageElementData(ElementData):
|
|
9
|
+
* type: Literal["image"] = "image"
|
|
10
|
+
* src: str
|
|
11
|
+
* alt: Optional[str] = "Image Not Found"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export interface ImageElementData extends ElementData {
|
|
15
|
+
type: "image";
|
|
16
|
+
/** URL ou base64 de l'image */
|
|
17
|
+
src: string;
|
|
18
|
+
/** Texte alternatif (défaut : "Image Not Found") */
|
|
19
|
+
alt?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function ImageElement({ src, alt }: ImageElementData): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "../../bs-BGOTKj78.js";
|
|
2
|
+
import { t as r } from "../../styles.module-DTfCO5TA.js";
|
|
3
|
+
import { useState as i } from "react";
|
|
4
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/chatbot/BotMessage/ImageElement.tsx
|
|
6
|
+
function s({ src: s, alt: c = "Image Not Found" }) {
|
|
7
|
+
let [l, u] = i("loading"), [d, f] = i(!1);
|
|
8
|
+
return /* @__PURE__ */ o("div", {
|
|
9
|
+
className: r["dsi-bot-image-wrap"],
|
|
10
|
+
children: [
|
|
11
|
+
l === "loading" && /* @__PURE__ */ a("div", {
|
|
12
|
+
className: r["dsi-bot-image-placeholder"],
|
|
13
|
+
children: /* @__PURE__ */ a("span", {
|
|
14
|
+
className: r["dsi-bot-image-spinner"],
|
|
15
|
+
"aria-hidden": "true"
|
|
16
|
+
})
|
|
17
|
+
}),
|
|
18
|
+
l === "error" && /* @__PURE__ */ a("div", {
|
|
19
|
+
className: r["dsi-bot-image-placeholder"],
|
|
20
|
+
children: /* @__PURE__ */ a("span", {
|
|
21
|
+
className: r["dsi-bot-image-error"],
|
|
22
|
+
children: c
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ a("img", {
|
|
26
|
+
src: s,
|
|
27
|
+
alt: c,
|
|
28
|
+
className: r["dsi-bot-image"],
|
|
29
|
+
style: { display: l === "loaded" ? "block" : "none" },
|
|
30
|
+
onLoad: () => u("loaded"),
|
|
31
|
+
onError: () => u("error")
|
|
32
|
+
}),
|
|
33
|
+
l === "loaded" && /* @__PURE__ */ o("div", {
|
|
34
|
+
className: r["dsi-bot-image-actions"],
|
|
35
|
+
children: [/* @__PURE__ */ a("button", {
|
|
36
|
+
className: r["dsi-bot-image-btn"],
|
|
37
|
+
onClick: async () => {
|
|
38
|
+
try {
|
|
39
|
+
let e = await (await fetch(s)).blob();
|
|
40
|
+
await navigator.clipboard.write([new ClipboardItem({ [e.type]: e })]);
|
|
41
|
+
} catch {
|
|
42
|
+
await navigator.clipboard.writeText(s);
|
|
43
|
+
}
|
|
44
|
+
f(!0), setTimeout(() => f(!1), 2e3);
|
|
45
|
+
},
|
|
46
|
+
"aria-label": "Copier l'image",
|
|
47
|
+
type: "button",
|
|
48
|
+
children: a(d ? n : e, {})
|
|
49
|
+
}), /* @__PURE__ */ a("button", {
|
|
50
|
+
className: r["dsi-bot-image-btn"],
|
|
51
|
+
onClick: async () => {
|
|
52
|
+
try {
|
|
53
|
+
let e = await (await fetch(s)).blob(), t = URL.createObjectURL(e), n = s.startsWith("data:") ? `image.${e.type.split("/")[1] || "png"}` : s.split("/").pop()?.split("?")[0] || "image", r = document.createElement("a");
|
|
54
|
+
r.href = t, r.download = n, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(t);
|
|
55
|
+
} catch {
|
|
56
|
+
window.open(s, "_blank", "noopener,noreferrer");
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"aria-label": "Télécharger l'image",
|
|
60
|
+
type: "button",
|
|
61
|
+
children: /* @__PURE__ */ a(t, {})
|
|
62
|
+
})]
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { s as ImageElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ElementData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Élément affichant du contenu HTML de façon isolée et sécurisée
|
|
4
|
+
* (iframe sandboxée).
|
|
5
|
+
*
|
|
6
|
+
* La hauteur de l'iframe est ajustée automatiquement au contenu via
|
|
7
|
+
* `onLoad` + lecture de `scrollHeight` (accessible grâce à `allow-same-origin`).
|
|
8
|
+
* Le CSS du document parent ne fuit pas dans l'iframe — l'isolation visuelle
|
|
9
|
+
* est garantie par le document séparé de l'iframe.
|
|
10
|
+
*
|
|
11
|
+
* ```python
|
|
12
|
+
* # Pydantic (Python)
|
|
13
|
+
* class IsolatedHtmlElementData(ElementData):
|
|
14
|
+
* type: Literal["isolatedHtml"] = "isolatedHtml"
|
|
15
|
+
* htmlContent: str
|
|
16
|
+
* sandbox: Optional[str] = "allow-scripts allow-same-origin allow-forms"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface IsolatedHtmlElementData extends ElementData {
|
|
20
|
+
type: "isolatedHtml";
|
|
21
|
+
/** Contenu HTML à afficher dans l'iframe */
|
|
22
|
+
htmlContent: string;
|
|
23
|
+
/** Options de sandbox (défaut : "allow-scripts allow-same-origin allow-forms") */
|
|
24
|
+
sandbox?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function IsolatedHtmlElement({ htmlContent, sandbox, }: IsolatedHtmlElementData): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { n as e, t } from "../../bs-BGOTKj78.js";
|
|
2
|
+
import { t as n } from "../../styles.module-DTfCO5TA.js";
|
|
3
|
+
import { useRef as r, useState as i } from "react";
|
|
4
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/chatbot/BotMessage/IsolatedHtmlElement.tsx
|
|
6
|
+
function s({ htmlContent: s, sandbox: c = "allow-scripts allow-same-origin allow-forms" }) {
|
|
7
|
+
let [l, u] = i(!1), [d, f] = i(void 0), p = r(null);
|
|
8
|
+
return /* @__PURE__ */ o("div", {
|
|
9
|
+
className: n["dsi-bot-iframe-wrap"],
|
|
10
|
+
children: [/* @__PURE__ */ a("iframe", {
|
|
11
|
+
ref: p,
|
|
12
|
+
srcDoc: s,
|
|
13
|
+
sandbox: c,
|
|
14
|
+
className: n["dsi-bot-iframe"],
|
|
15
|
+
style: d === void 0 ? void 0 : { height: `${d}px` },
|
|
16
|
+
onLoad: () => {
|
|
17
|
+
let e = p.current?.contentWindow?.document;
|
|
18
|
+
e && f(e.documentElement.scrollHeight);
|
|
19
|
+
},
|
|
20
|
+
title: "isolated-html"
|
|
21
|
+
}), /* @__PURE__ */ a("button", {
|
|
22
|
+
className: n["dsi-bot-iframe-copy"],
|
|
23
|
+
onClick: () => {
|
|
24
|
+
navigator.clipboard.writeText(s).then(() => {
|
|
25
|
+
u(!0), setTimeout(() => u(!1), 2e3);
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
"aria-label": "Copier le HTML",
|
|
29
|
+
type: "button",
|
|
30
|
+
children: a(l ? t : e, {})
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { s as IsolatedHtmlElement };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ElementData } from './types';
|
|
2
|
+
type AnyData = any[];
|
|
3
|
+
type AnyLayout = any;
|
|
4
|
+
/**
|
|
5
|
+
* Élément affichant un graphique Plotly.
|
|
6
|
+
*
|
|
7
|
+
* ```python
|
|
8
|
+
* # Pydantic (Python)
|
|
9
|
+
* class PlotlyChartElementData(ElementData):
|
|
10
|
+
* type: Literal["plotlyChart"] = "plotlyChart"
|
|
11
|
+
* data: list[dict]
|
|
12
|
+
* layout: Optional[dict] = None
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface PlotlyChartElementData extends ElementData {
|
|
16
|
+
type: "plotlyChart";
|
|
17
|
+
/** Liste des traces Plotly (voir https://plot.ly/javascript/reference/) */
|
|
18
|
+
data: AnyData;
|
|
19
|
+
/** Layout Plotly (voir https://plot.ly/javascript/reference/#layout) */
|
|
20
|
+
layout?: AnyLayout;
|
|
21
|
+
}
|
|
22
|
+
export declare function PlotlyChartElement({ data, layout }: PlotlyChartElementData): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as e } from "../../styles.module-DTfCO5TA.js";
|
|
2
|
+
import { Suspense as t, lazy as n, useEffect as r, useState as i } from "react";
|
|
3
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
4
|
+
//#region lib/chatbot/BotMessage/PlotlyChartElement.tsx
|
|
5
|
+
var o = n(async () => {
|
|
6
|
+
let e = await import("react-plotly.js"), t = typeof e == "function" ? e : typeof e?.default == "function" ? e.default : typeof e?.default?.default == "function" ? e.default.default : null;
|
|
7
|
+
if (!t) throw Error("[dsi-react-utils] react-plotly.js loaded but no component export found");
|
|
8
|
+
return { default: t };
|
|
9
|
+
});
|
|
10
|
+
function s({ data: n, layout: s }) {
|
|
11
|
+
let [c, l] = i(!1);
|
|
12
|
+
return r(() => l(!0), []), c ? /* @__PURE__ */ a("div", {
|
|
13
|
+
className: e["dsi-bot-chart-wrap"],
|
|
14
|
+
children: /* @__PURE__ */ a(t, {
|
|
15
|
+
fallback: /* @__PURE__ */ a("div", {}),
|
|
16
|
+
children: /* @__PURE__ */ a(o, {
|
|
17
|
+
data: n,
|
|
18
|
+
layout: s,
|
|
19
|
+
config: {
|
|
20
|
+
displaylogo: !1,
|
|
21
|
+
responsive: !0
|
|
22
|
+
},
|
|
23
|
+
useResizeHandler: !0,
|
|
24
|
+
style: { maxWidth: "100%" }
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
}) : /* @__PURE__ */ a("div", { className: e["dsi-bot-chart-wrap"] });
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { s as PlotlyChartElement };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ElementData } from './types';
|
|
2
|
+
type AnySpec = any;
|
|
3
|
+
/**
|
|
4
|
+
* Élément affichant un graphique Vega / Vega-Lite.
|
|
5
|
+
* Wrapper léger autour de `react-vega` (importé dynamiquement pour rester
|
|
6
|
+
* compatible SSR).
|
|
7
|
+
*
|
|
8
|
+
* ```python
|
|
9
|
+
* # Pydantic (Python)
|
|
10
|
+
* class VegaChartElementData(ElementData):
|
|
11
|
+
* type: Literal["vegaChart"] = "vegaChart"
|
|
12
|
+
* chartSpec: dict # spec Vega ou Vega-Lite, data incluse
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface VegaChartElementData extends ElementData {
|
|
16
|
+
type: "vegaChart";
|
|
17
|
+
/** Spécification Vega ou Vega-Lite (data incluse) */
|
|
18
|
+
chartSpec: AnySpec;
|
|
19
|
+
}
|
|
20
|
+
export declare function VegaChartElement({ chartSpec }: VegaChartElementData): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { t as e } from "../../styles.module-DTfCO5TA.js";
|
|
2
|
+
import { Suspense as t, lazy as n, useEffect as r, useState as i } from "react";
|
|
3
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
4
|
+
//#region lib/chatbot/BotMessage/VegaChartElement.tsx
|
|
5
|
+
var o = n(async () => ({ default: (await import("react-vega")).VegaEmbed }));
|
|
6
|
+
function s({ chartSpec: n }) {
|
|
7
|
+
let [s, c] = i(!1);
|
|
8
|
+
return r(() => c(!0), []), s ? /* @__PURE__ */ a("div", {
|
|
9
|
+
className: e["dsi-bot-chart-wrap"],
|
|
10
|
+
children: /* @__PURE__ */ a(t, {
|
|
11
|
+
fallback: /* @__PURE__ */ a("div", {}),
|
|
12
|
+
children: /* @__PURE__ */ a(o, { spec: n })
|
|
13
|
+
})
|
|
14
|
+
}) : /* @__PURE__ */ a("div", { className: e["dsi-bot-chart-wrap"] });
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { s as VegaChartElement };
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
}
|
|
2
|
+
import { ElementData } from './types';
|
|
3
|
+
export type { ElementData } from './types';
|
|
4
|
+
export type { ImageElementData } from './ImageElement';
|
|
5
|
+
export type { IsolatedHtmlElementData } from './IsolatedHtmlElement';
|
|
6
|
+
export type { VegaChartElementData } from './VegaChartElement';
|
|
7
|
+
export type { PlotlyChartElementData } from './PlotlyChartElement';
|
|
18
8
|
/**
|
|
19
9
|
* Élément de texte en markdown.
|
|
20
10
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "../../BotMessage-
|
|
1
|
+
import { n as e, t } from "../../BotMessage-9XyyKf52.js";
|
|
2
2
|
export { t as BotMessage, e as defaultBotMessageRegistry };
|