@shane_donnelly/dsi-internal-react-utils 1.0.0 → 1.2.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.
@@ -1,9 +1,10 @@
1
1
  import { useTheme as e } from "./chatbot/theme/useTheme.js";
2
2
  import { t } from "./iconBase-CDbPVA4E.js";
3
- import { useEffect as n, useRef as r, useState as i } from "react";
4
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
+ import { getPlusOpen as n, setPlusOpen as r, subscribePlusOpen as i } from "./chatbot/InputBar/plusSlotStore.js";
4
+ import { useEffect as a, useRef as o, useState as s } from "react";
5
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
5
6
  //#region node_modules/react-icons/fi/index.mjs
6
- function s(e) {
7
+ function u(e) {
7
8
  return t({
8
9
  tag: "svg",
9
10
  attr: {
@@ -30,7 +31,7 @@ function s(e) {
30
31
  }]
31
32
  })(e);
32
33
  }
33
- function c(e) {
34
+ function d(e) {
34
35
  return t({
35
36
  tag: "svg",
36
37
  attr: {
@@ -64,7 +65,7 @@ function c(e) {
64
65
  }
65
66
  //#endregion
66
67
  //#region node_modules/react-icons/fa/index.mjs
67
- function l(e) {
68
+ function f(e) {
68
69
  return t({
69
70
  tag: "svg",
70
71
  attr: { viewBox: "0 0 448 512" },
@@ -77,7 +78,7 @@ function l(e) {
77
78
  }
78
79
  //#endregion
79
80
  //#region node_modules/react-icons/ri/index.mjs
80
- function u(e) {
81
+ function p(e) {
81
82
  return t({
82
83
  tag: "svg",
83
84
  attr: {
@@ -93,7 +94,7 @@ function u(e) {
93
94
  }
94
95
  //#endregion
95
96
  //#region lib/chatbot/InputBar/styles.module.css
96
- var d = {
97
+ var m = {
97
98
  "dsi-inputbar": "_dsi-inputbar_1ngbl_2",
98
99
  "dsi-inputbar-upper-slot": "_dsi-inputbar-upper-slot_1ngbl_12",
99
100
  "dsi-inputbar-plus-slot": "_dsi-inputbar-plus-slot_1ngbl_23",
@@ -106,91 +107,91 @@ var d = {
106
107
  };
107
108
  //#endregion
108
109
  //#region lib/chatbot/InputBar/index.tsx
109
- function f({ type: e }) {
110
+ function h({ type: e }) {
110
111
  switch (e) {
111
- case "send": return /* @__PURE__ */ a(s, {});
112
- case "stop": return /* @__PURE__ */ a(l, {});
113
- case "vocal": return /* @__PURE__ */ a(u, {});
112
+ case "send": return /* @__PURE__ */ c(u, {});
113
+ case "stop": return /* @__PURE__ */ c(f, {});
114
+ case "vocal": return /* @__PURE__ */ c(p, {});
114
115
  default: return null;
115
116
  }
116
117
  }
117
- function p({ value: t, onChange: s, placeholder: l = "Envoyer un message…", actionButtonType: u = "send", actionButtonEnabled: p = !0, onActionButtonClick: m, plusSlot: h, upperSlot: g, messageHistory: _ }) {
118
- let v = e(), [y, b] = i(!1), x = r(null), S = r(null), C = r(null), w = r(-1);
119
- n(() => {
120
- let e = x.current;
118
+ function g({ value: t, onChange: u, placeholder: f = "Placeholder", actionButtonType: p = "send", actionButtonEnabled: g = !0, onActionButtonClick: _, plusSlot: v, upperSlot: y, messageHistory: b }) {
119
+ let x = e(), [S, C] = s(n), w = o(null), T = o(null), E = o(null), D = o(-1);
120
+ a(() => i((e) => C(e)), []), a(() => {
121
+ let e = w.current;
121
122
  e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
122
- }, [t]), n(() => {
123
- if (!y) return;
123
+ }, [t]), a(() => {
124
+ if (!S) return;
124
125
  let e = (e) => {
125
- !S.current?.contains(e.target) && !C.current?.contains(e.target) && b(!1);
126
+ !T.current?.contains(e.target) && !E.current?.contains(e.target) && r(!1);
126
127
  };
127
128
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
128
- }, [y]);
129
- let T = {
130
- "--dsi-border": v.border,
131
- "--dsi-input-bg": v.inputBg,
132
- "--dsi-accent": v.accent,
133
- "--dsi-text-primary": v.textPrimary,
134
- "--dsi-text-secondary": v.textSecondary,
135
- "--dsi-button-bg": v.buttonBg,
136
- "--dsi-button-hover-bg": v.buttonHoverBg,
137
- "--dsi-action-btn-bg": v.actionButtonBg,
138
- "--dsi-action-btn-hover-bg": v.actionButtonHoverBg,
139
- "--dsi-action-btn-icon": v.actionButtonIcon
129
+ }, [S]);
130
+ let O = {
131
+ "--dsi-border": x.border,
132
+ "--dsi-input-bg": x.inputBg,
133
+ "--dsi-accent": x.accent,
134
+ "--dsi-text-primary": x.textPrimary,
135
+ "--dsi-text-secondary": x.textSecondary,
136
+ "--dsi-button-bg": x.buttonBg,
137
+ "--dsi-button-hover-bg": x.buttonHoverBg,
138
+ "--dsi-action-btn-bg": x.actionButtonBg,
139
+ "--dsi-action-btn-hover-bg": x.actionButtonHoverBg,
140
+ "--dsi-action-btn-icon": x.actionButtonIcon
140
141
  };
141
- return /* @__PURE__ */ o("div", {
142
- className: d["dsi-inputbar"],
143
- style: T,
142
+ return /* @__PURE__ */ l("div", {
143
+ className: m["dsi-inputbar"],
144
+ style: O,
144
145
  children: [
145
- y && h && /* @__PURE__ */ a("div", {
146
- className: d["dsi-inputbar-plus-slot"],
147
- ref: S,
148
- children: h
146
+ S && v && /* @__PURE__ */ c("div", {
147
+ className: m["dsi-inputbar-plus-slot"],
148
+ ref: T,
149
+ children: v
149
150
  }),
150
- g && /* @__PURE__ */ a("div", {
151
- className: d["dsi-inputbar-upper-slot"],
152
- children: g
151
+ y && /* @__PURE__ */ c("div", {
152
+ className: m["dsi-inputbar-upper-slot"],
153
+ children: y
153
154
  }),
154
- /* @__PURE__ */ o("div", {
155
- className: `${d["dsi-inputbar-row"]} ${g ? d["dsi-inputbar-row--with-upper"] : ""}`,
155
+ /* @__PURE__ */ l("div", {
156
+ className: `${m["dsi-inputbar-row"]} ${y ? m["dsi-inputbar-row--with-upper"] : ""}`,
156
157
  children: [
157
- /* @__PURE__ */ a("button", {
158
- ref: C,
159
- className: `${d["dsi-inputbar-plus-btn"]} ${y ? d["dsi-inputbar-plus-btn--open"] : ""}`,
160
- onClick: () => b((e) => !e),
158
+ /* @__PURE__ */ c("button", {
159
+ ref: E,
160
+ className: `${m["dsi-inputbar-plus-btn"]} ${S ? m["dsi-inputbar-plus-btn--open"] : ""}`,
161
+ onClick: () => r(!S),
161
162
  "aria-label": "Options",
162
163
  type: "button",
163
- children: /* @__PURE__ */ a(c, {})
164
+ children: /* @__PURE__ */ c(d, {})
164
165
  }),
165
- /* @__PURE__ */ a("textarea", {
166
- ref: x,
167
- className: d["dsi-inputbar-textarea"],
166
+ /* @__PURE__ */ c("textarea", {
167
+ ref: w,
168
+ className: m["dsi-inputbar-textarea"],
168
169
  value: t,
169
170
  onChange: (e) => {
170
- w.current = -1, s(e.target.value);
171
+ D.current = -1, u(e.target.value);
171
172
  },
172
- placeholder: l,
173
+ placeholder: f,
173
174
  rows: 1,
174
175
  onKeyDown: (e) => {
175
- let n = _ ?? [];
176
+ let n = b ?? [];
176
177
  if (e.key === "ArrowUp" && !e.shiftKey) {
177
- t === "" && w.current === -1 && n.length > 0 ? (w.current = n.length - 1, s(n[w.current]), e.preventDefault()) : w.current > 0 ? (w.current--, s(n[w.current]), e.preventDefault()) : w.current === 0 && e.preventDefault();
178
+ t === "" && D.current === -1 && n.length > 0 ? (D.current = n.length - 1, u(n[D.current]), e.preventDefault()) : D.current > 0 ? (D.current--, u(n[D.current]), e.preventDefault()) : D.current === 0 && e.preventDefault();
178
179
  return;
179
180
  }
180
- if (e.key === "ArrowDown" && w.current !== -1) {
181
- w.current < n.length - 1 ? (w.current++, s(n[w.current])) : (w.current = -1, s("")), e.preventDefault();
181
+ if (e.key === "ArrowDown" && D.current !== -1) {
182
+ D.current < n.length - 1 ? (D.current++, u(n[D.current])) : (D.current = -1, u("")), e.preventDefault();
182
183
  return;
183
184
  }
184
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), w.current = -1, p && u !== "none" && m?.(u));
185
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), D.current = -1, g && p !== "none" && _?.(p));
185
186
  }
186
187
  }),
187
- u !== "none" && /* @__PURE__ */ a("button", {
188
- className: d["dsi-inputbar-action-btn"],
189
- disabled: !p,
190
- onClick: () => m?.(u),
191
- "aria-label": u,
188
+ p !== "none" && /* @__PURE__ */ c("button", {
189
+ className: m["dsi-inputbar-action-btn"],
190
+ disabled: !g,
191
+ onClick: () => _?.(p),
192
+ "aria-label": p,
192
193
  type: "button",
193
- children: /* @__PURE__ */ a(f, { type: u })
194
+ children: /* @__PURE__ */ c(h, { type: p })
194
195
  })
195
196
  ]
196
197
  })
@@ -198,4 +199,4 @@ function p({ value: t, onChange: s, placeholder: l = "Envoyer un message…", ac
198
199
  });
199
200
  }
200
201
  //#endregion
201
- export { p as t };
202
+ export { g as t };
@@ -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-CVy2_QtC.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,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ export { usePlusSlot } from './usePlusSlot';
2
3
  /** Type du bouton d'action principal */
3
4
  export type ActionButtonType = "send" | "stop" | "vocal" | "none";
4
5
  export interface InputBarProps {
@@ -1,2 +1,3 @@
1
- import { t as e } from "../../InputBar-CxSc2du6.js";
2
- export { e as InputBar };
1
+ import { t as e } from "../../InputBar-CVy2_QtC.js";
2
+ import { usePlusSlot as t } from "./usePlusSlot.js";
3
+ export { e as InputBar, t as usePlusSlot };
@@ -0,0 +1,5 @@
1
+ type Listener = (open: boolean) => void;
2
+ export declare function getPlusOpen(): boolean;
3
+ export declare function setPlusOpen(open: boolean): void;
4
+ export declare function subscribePlusOpen(l: Listener): () => void;
5
+ export {};
@@ -0,0 +1,13 @@
1
+ //#region lib/chatbot/InputBar/plusSlotStore.ts
2
+ var e = !1, t = /* @__PURE__ */ new Set();
3
+ function n() {
4
+ return e;
5
+ }
6
+ function r(n) {
7
+ e = n, t.forEach((e) => e(n));
8
+ }
9
+ function i(e) {
10
+ return t.add(e), () => t.delete(e);
11
+ }
12
+ //#endregion
13
+ export { n as getPlusOpen, r as setPlusOpen, i as subscribePlusOpen };
@@ -0,0 +1,19 @@
1
+ import { setPlusOpen } from './plusSlotStore';
2
+ /**
3
+ * Hook permettant de contrôler programmatiquement l'ouverture/fermeture
4
+ * du plus slot de l'InputBar.
5
+ *
6
+ * Le comportement natif (clic sur le bouton "+" pour basculer) est conservé :
7
+ * ce hook ajoute uniquement la capacité d'agir depuis l'extérieur.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const { setOpen } = usePlusSlot();
12
+ *
13
+ * // Ouvrir le plus slot lors d'un drop de fichier
14
+ * const handleDrop = () => setOpen(true);
15
+ * ```
16
+ */
17
+ export declare function usePlusSlot(): {
18
+ setOpen: typeof setPlusOpen;
19
+ };
@@ -0,0 +1,7 @@
1
+ import { setPlusOpen as e } from "./plusSlotStore.js";
2
+ //#region lib/chatbot/InputBar/usePlusSlot.ts
3
+ function t() {
4
+ return { setOpen: e };
5
+ }
6
+ //#endregion
7
+ export { t as usePlusSlot };
@@ -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-RrzUh_no.js";
1
+ import { t as e } from "../../SessionContainer-DfTD7hX3.js";
2
2
  export { e as SessionContainer };
@@ -8,7 +8,7 @@ export { BotMessage, defaultBotMessageRegistry } from './BotMessage';
8
8
  export type { ElementData, TextElementData, ReasoningElementData, ToolElementData, SearchElementData, BotMessageData, BotMessageRegistry, BotMessageProps, } from './BotMessage';
9
9
  export { SessionHistory } from './SessionHistory';
10
10
  export type { SessionHistoryProps, SessionUserMessageSlots } from './SessionHistory';
11
- export { InputBar } from './InputBar';
11
+ export { InputBar, usePlusSlot } from './InputBar';
12
12
  export type { InputBarProps, ActionButtonType } from './InputBar';
13
13
  export { SessionContainer } from './SessionContainer';
14
14
  export type { SessionContainerProps } from './SessionContainer';
@@ -5,6 +5,7 @@ import "./theme/index.js";
5
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
- 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 };
8
+ import { t as l } from "../InputBar-CVy2_QtC.js";
9
+ import { usePlusSlot as u } from "./InputBar/usePlusSlot.js";
10
+ import { t as d } from "../SessionContainer-DfTD7hX3.js";
11
+ export { s as BotMessage, l as InputBar, e as MarkdownRenderer, d as SessionContainer, c as SessionHistory, a as UserMessage, o as defaultBotMessageRegistry, t as getCurrentTheme, n as getTheme, r as setTheme, u as usePlusSlot, i as useTheme };
package/dist/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { KeycloakProvider, useKeycloakAuth, logoutKeycloak, refreshTokenKeycloak, } from './keycloak';
2
2
  export type { KeycloakProviderProps, KeycloakConfig, KeycloakAuthOptions, AuthStatus, AuthUser, AuthContextValue, LoginOptions, LogoutOptions, } from './keycloak';
3
- export { setTheme, getTheme, getCurrentTheme, useTheme, MarkdownRenderer, UserMessage, BotMessage, defaultBotMessageRegistry, SessionHistory, InputBar, SessionContainer, } from './chatbot';
3
+ export { setTheme, getTheme, getCurrentTheme, useTheme, MarkdownRenderer, UserMessage, BotMessage, defaultBotMessageRegistry, SessionHistory, InputBar, SessionContainer, usePlusSlot, } from './chatbot';
4
4
  export type { ColorPalette, Theme, MarkdownRendererProps, UserMessageData, UserMessageProps, ElementData, TextElementData, ReasoningElementData, ToolElementData, SearchElementData, BotMessageData, BotMessageRegistry, BotMessageProps, SessionHistoryProps, SessionUserMessageSlots, InputBarProps, ActionButtonType, SessionContainerProps, } from './chatbot';
package/dist/main.js CHANGED
@@ -8,7 +8,8 @@ import { useTheme as c } from "./chatbot/theme/useTheme.js";
8
8
  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
- import { t as p } from "./InputBar-CxSc2du6.js";
12
- import { t as m } from "./SessionContainer-RrzUh_no.js";
11
+ import { t as p } from "./InputBar-CVy2_QtC.js";
12
+ import { usePlusSlot as m } from "./chatbot/InputBar/usePlusSlot.js";
13
+ import { t as h } from "./SessionContainer-DfTD7hX3.js";
13
14
  import "./chatbot/index.js";
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 };
15
+ export { d as BotMessage, p as InputBar, r as KeycloakProvider, e as MarkdownRenderer, h 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, m as usePlusSlot, c as useTheme };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shane_donnelly/dsi-internal-react-utils",
3
3
  "private": false,
4
- "version": "1.0.0",
4
+ "version": "1.2.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -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 };