@shane_donnelly/dsi-internal-react-utils 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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 { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
//#region lib/chatbot/SessionContainer/styles.module.css
|
|
7
|
+
var l = {
|
|
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 u({ userMessages: u, botMessages: d, orderedIds: f, botMessageRegistry: p, userMessageSlots: m, alternativeScreenComponent: h, isAlternativeScreenActive: g = !1, value: _, onChange: v, placeholder: y, actionButtonType: b, actionButtonEnabled: x, onActionButtonClick: S, plusSlot: C, upperSlot: w }) {
|
|
15
|
+
let T = e(), E = a(null), D = i(() => {
|
|
16
|
+
let e = new Map(u.map((e) => [e.id, e]));
|
|
17
|
+
return f.filter((t) => e.has(t)).map((t) => e.get(t).text);
|
|
18
|
+
}, [u, f]);
|
|
19
|
+
return r(() => {
|
|
20
|
+
E.current?.scrollIntoView({ behavior: "smooth" });
|
|
21
|
+
}, [f.length]), /* @__PURE__ */ c("div", {
|
|
22
|
+
className: l["dsi-session-container"],
|
|
23
|
+
style: { "--dsi-bg": T.background },
|
|
24
|
+
children: [/* @__PURE__ */ s("div", {
|
|
25
|
+
className: l["dsi-session-container-history"],
|
|
26
|
+
children: g ? h ?? null : /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(t, {
|
|
27
|
+
userMessages: u,
|
|
28
|
+
botMessages: d,
|
|
29
|
+
orderedIds: f,
|
|
30
|
+
botMessageRegistry: p,
|
|
31
|
+
userMessageSlots: m
|
|
32
|
+
}), /* @__PURE__ */ s("div", { ref: E })] })
|
|
33
|
+
}), /* @__PURE__ */ s("div", {
|
|
34
|
+
className: l["dsi-session-container-inputbar"],
|
|
35
|
+
children: /* @__PURE__ */ s(n, {
|
|
36
|
+
value: _,
|
|
37
|
+
onChange: v,
|
|
38
|
+
placeholder: y,
|
|
39
|
+
actionButtonType: b,
|
|
40
|
+
actionButtonEnabled: x,
|
|
41
|
+
onActionButtonClick: S,
|
|
42
|
+
plusSlot: C,
|
|
43
|
+
upperSlot: w,
|
|
44
|
+
messageHistory: D
|
|
45
|
+
})
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { u as t };
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { SessionHistoryProps } from '../SessionHistory';
|
|
2
3
|
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
|
+
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 & {
|
|
5
|
+
/**
|
|
6
|
+
* Composant alternatif affiché à la place de `SessionHistory`
|
|
7
|
+
* quand `isAlternativeScreenActive` est `true`.
|
|
8
|
+
*/
|
|
9
|
+
alternativeScreenComponent?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Quand `true`, affiche `alternativeScreenComponent` à la place de
|
|
12
|
+
* `SessionHistory`. Par défaut `false`.
|
|
13
|
+
*/
|
|
14
|
+
isAlternativeScreenActive?: boolean;
|
|
15
|
+
};
|
|
4
16
|
/**
|
|
5
17
|
* Composant tout-en-un combinant `SessionHistory` et `InputBar`.
|
|
6
18
|
*
|
|
7
19
|
* Fait défiler automatiquement vers le dernier message à chaque
|
|
8
20
|
* mise à jour de la conversation.
|
|
9
21
|
*
|
|
10
|
-
* Ses props sont la somme des props de `SessionHistory` et `InputBar
|
|
22
|
+
* Ses props sont la somme des props de `SessionHistory` et `InputBar`,
|
|
23
|
+
* plus deux props optionnelles pour un écran alternatif :
|
|
24
|
+
* - `alternativeScreenComponent` : contenu affiché à la place de `SessionHistory`
|
|
25
|
+
* - `isAlternativeScreenActive` : active l'affichage de l'écran alternatif (défaut `false`)
|
|
11
26
|
*
|
|
12
27
|
* @example
|
|
13
28
|
* ```tsx
|
|
@@ -23,4 +38,4 @@ export type SessionContainerProps<TTop = Record<string, never>, TBottom = Record
|
|
|
23
38
|
* />
|
|
24
39
|
* ```
|
|
25
40
|
*/
|
|
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;
|
|
41
|
+
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, alternativeScreenComponent, isAlternativeScreenActive, value, onChange, placeholder, actionButtonType, actionButtonEnabled, onActionButtonClick, plusSlot, upperSlot, }: SessionContainerProps<TTop, TBottom, TLeft, TRight>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../SessionContainer-
|
|
1
|
+
import { t as e } from "../../SessionContainer-DGTMKCFX.js";
|
|
2
2
|
export { e as SessionContainer };
|
package/dist/chatbot/index.js
CHANGED
|
@@ -6,5 +6,5 @@ import { t as a } from "../UserMessage-CkrDUpkQ.js";
|
|
|
6
6
|
import { n as o, t as s } from "../BotMessage-DegH8sM-.js";
|
|
7
7
|
import { t as c } from "../SessionHistory-BUYwbZjE.js";
|
|
8
8
|
import { t as l } from "../InputBar-CxSc2du6.js";
|
|
9
|
-
import { t as u } from "../SessionContainer-
|
|
9
|
+
import { t as u } from "../SessionContainer-DGTMKCFX.js";
|
|
10
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 };
|
package/dist/main.js
CHANGED
|
@@ -9,6 +9,6 @@ import { t as l } from "./UserMessage-CkrDUpkQ.js";
|
|
|
9
9
|
import { n as u, t as d } from "./BotMessage-DegH8sM-.js";
|
|
10
10
|
import { t as f } from "./SessionHistory-BUYwbZjE.js";
|
|
11
11
|
import { t as p } from "./InputBar-CxSc2du6.js";
|
|
12
|
-
import { t as m } from "./SessionContainer-
|
|
12
|
+
import { t as m } from "./SessionContainer-DGTMKCFX.js";
|
|
13
13
|
import "./chatbot/index.js";
|
|
14
14
|
export { d as BotMessage, p as InputBar, r as KeycloakProvider, e as MarkdownRenderer, m as SessionContainer, f as SessionHistory, l as UserMessage, u as defaultBotMessageRegistry, a as getCurrentTheme, o as getTheme, t as logoutKeycloak, n as refreshTokenKeycloak, s as setTheme, i as useKeycloakAuth, c as useTheme };
|
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
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 };
|