@orion-ds/react 5.1.13 → 5.3.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.
Files changed (145) hide show
  1. package/AI_COMPONENTS.md +9 -2
  2. package/README.md +1 -5
  3. package/dist/blocks/index.cjs +1 -1
  4. package/dist/blocks/index.mjs +50 -54
  5. package/dist/blocks/sections/index.d.ts +0 -2
  6. package/dist/blocks/sections/index.d.ts.map +1 -1
  7. package/dist/blocks/templates/index.cjs +1 -1
  8. package/dist/blocks/templates/index.d.ts +0 -5
  9. package/dist/blocks/templates/index.d.ts.map +1 -1
  10. package/dist/blocks/templates/index.mjs +12 -14
  11. package/dist/blocks.css +0 -4
  12. package/dist/client.d.ts +1 -2
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/components/ThemeController/ThemeController.cjs +1 -1
  15. package/dist/components/ThemeController/ThemeController.d.ts.map +1 -1
  16. package/dist/components/ThemeController/ThemeController.mjs +7 -7
  17. package/dist/components/index.d.ts +0 -3
  18. package/dist/components/index.d.ts.map +1 -1
  19. package/dist/hooks/useTheme.cjs +1 -1
  20. package/dist/hooks/useTheme.d.ts +1 -1
  21. package/dist/hooks/useTheme.d.ts.map +1 -1
  22. package/dist/hooks/useTheme.mjs +1 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/styles.css +0 -2
  25. package/dist/tokens/types.d.ts +64 -37
  26. package/dist/tokens/types.d.ts.map +1 -1
  27. package/dist/utils/fonts.cjs +1 -1
  28. package/dist/utils/fonts.d.ts.map +1 -1
  29. package/dist/utils/fonts.mjs +1 -0
  30. package/package.json +1 -6
  31. package/dist/blocks/sections/Chat/Chat.cjs +0 -1
  32. package/dist/blocks/sections/Chat/Chat.d.ts +0 -5
  33. package/dist/blocks/sections/Chat/Chat.d.ts.map +0 -1
  34. package/dist/blocks/sections/Chat/Chat.mjs +0 -93
  35. package/dist/blocks/sections/Chat/Chat.module.css +0 -1
  36. package/dist/blocks/sections/Chat/Chat.module.css.cjs +0 -1
  37. package/dist/blocks/sections/Chat/Chat.module.css.mjs +0 -47
  38. package/dist/blocks/sections/Chat/Chat.types.d.ts +0 -33
  39. package/dist/blocks/sections/Chat/Chat.types.d.ts.map +0 -1
  40. package/dist/blocks/sections/Chat/index.d.ts +0 -3
  41. package/dist/blocks/sections/Chat/index.d.ts.map +0 -1
  42. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.cjs +0 -1
  43. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.d.ts +0 -5
  44. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.d.ts.map +0 -1
  45. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.mjs +0 -192
  46. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.module.css +0 -1
  47. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.module.css.cjs +0 -1
  48. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.module.css.mjs +0 -81
  49. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.types.d.ts +0 -42
  50. package/dist/blocks/templates/app/ChatPageTemplate/ChatPageTemplate.types.d.ts.map +0 -1
  51. package/dist/blocks/templates/app/ChatPageTemplate/index.d.ts +0 -3
  52. package/dist/blocks/templates/app/ChatPageTemplate/index.d.ts.map +0 -1
  53. package/dist/components/Chat/Chat.cjs +0 -1
  54. package/dist/components/Chat/Chat.d.ts +0 -22
  55. package/dist/components/Chat/Chat.d.ts.map +0 -1
  56. package/dist/components/Chat/Chat.mjs +0 -56
  57. package/dist/components/Chat/Chat.module.css +0 -1
  58. package/dist/components/Chat/Chat.module.css.cjs +0 -1
  59. package/dist/components/Chat/Chat.module.css.mjs +0 -237
  60. package/dist/components/Chat/Chat.types.d.ts +0 -387
  61. package/dist/components/Chat/Chat.types.d.ts.map +0 -1
  62. package/dist/components/Chat/components/ChatAttachment.cjs +0 -1
  63. package/dist/components/Chat/components/ChatAttachment.d.ts +0 -5
  64. package/dist/components/Chat/components/ChatAttachment.d.ts.map +0 -1
  65. package/dist/components/Chat/components/ChatAttachment.mjs +0 -125
  66. package/dist/components/Chat/components/ChatAudioPlayer.cjs +0 -1
  67. package/dist/components/Chat/components/ChatAudioPlayer.d.ts +0 -5
  68. package/dist/components/Chat/components/ChatAudioPlayer.d.ts.map +0 -1
  69. package/dist/components/Chat/components/ChatAudioPlayer.mjs +0 -127
  70. package/dist/components/Chat/components/ChatCodeBlock.cjs +0 -1
  71. package/dist/components/Chat/components/ChatCodeBlock.d.ts +0 -5
  72. package/dist/components/Chat/components/ChatCodeBlock.d.ts.map +0 -1
  73. package/dist/components/Chat/components/ChatCodeBlock.mjs +0 -93
  74. package/dist/components/Chat/components/ChatFileUpload.cjs +0 -1
  75. package/dist/components/Chat/components/ChatFileUpload.d.ts +0 -5
  76. package/dist/components/Chat/components/ChatFileUpload.d.ts.map +0 -1
  77. package/dist/components/Chat/components/ChatFileUpload.mjs +0 -114
  78. package/dist/components/Chat/components/ChatHeader.cjs +0 -1
  79. package/dist/components/Chat/components/ChatHeader.d.ts +0 -5
  80. package/dist/components/Chat/components/ChatHeader.d.ts.map +0 -1
  81. package/dist/components/Chat/components/ChatHeader.mjs +0 -36
  82. package/dist/components/Chat/components/ChatImagePreview.cjs +0 -1
  83. package/dist/components/Chat/components/ChatImagePreview.d.ts +0 -5
  84. package/dist/components/Chat/components/ChatImagePreview.d.ts.map +0 -1
  85. package/dist/components/Chat/components/ChatImagePreview.mjs +0 -69
  86. package/dist/components/Chat/components/ChatInput.cjs +0 -1
  87. package/dist/components/Chat/components/ChatInput.d.ts +0 -5
  88. package/dist/components/Chat/components/ChatInput.d.ts.map +0 -1
  89. package/dist/components/Chat/components/ChatInput.mjs +0 -188
  90. package/dist/components/Chat/components/ChatLightbox.cjs +0 -1
  91. package/dist/components/Chat/components/ChatLightbox.d.ts +0 -5
  92. package/dist/components/Chat/components/ChatLightbox.d.ts.map +0 -1
  93. package/dist/components/Chat/components/ChatLightbox.mjs +0 -57
  94. package/dist/components/Chat/components/ChatMarkdown.cjs +0 -1
  95. package/dist/components/Chat/components/ChatMarkdown.d.ts +0 -5
  96. package/dist/components/Chat/components/ChatMarkdown.d.ts.map +0 -1
  97. package/dist/components/Chat/components/ChatMarkdown.mjs +0 -70
  98. package/dist/components/Chat/components/ChatMessage.cjs +0 -1
  99. package/dist/components/Chat/components/ChatMessage.d.ts +0 -5
  100. package/dist/components/Chat/components/ChatMessage.d.ts.map +0 -1
  101. package/dist/components/Chat/components/ChatMessage.mjs +0 -173
  102. package/dist/components/Chat/components/ChatMessages.cjs +0 -1
  103. package/dist/components/Chat/components/ChatMessages.d.ts +0 -5
  104. package/dist/components/Chat/components/ChatMessages.d.ts.map +0 -1
  105. package/dist/components/Chat/components/ChatMessages.mjs +0 -46
  106. package/dist/components/Chat/components/ChatSidebar.cjs +0 -1
  107. package/dist/components/Chat/components/ChatSidebar.d.ts +0 -5
  108. package/dist/components/Chat/components/ChatSidebar.d.ts.map +0 -1
  109. package/dist/components/Chat/components/ChatSidebar.mjs +0 -217
  110. package/dist/components/Chat/components/ChatTypingIndicator.cjs +0 -1
  111. package/dist/components/Chat/components/ChatTypingIndicator.d.ts +0 -5
  112. package/dist/components/Chat/components/ChatTypingIndicator.d.ts.map +0 -1
  113. package/dist/components/Chat/components/ChatTypingIndicator.mjs +0 -31
  114. package/dist/components/Chat/components/ChatVoiceRecorder.cjs +0 -1
  115. package/dist/components/Chat/components/ChatVoiceRecorder.d.ts +0 -5
  116. package/dist/components/Chat/components/ChatVoiceRecorder.d.ts.map +0 -1
  117. package/dist/components/Chat/components/ChatVoiceRecorder.mjs +0 -111
  118. package/dist/components/Chat/components/index.d.ts +0 -18
  119. package/dist/components/Chat/components/index.d.ts.map +0 -1
  120. package/dist/components/Chat/hooks/index.d.ts +0 -12
  121. package/dist/components/Chat/hooks/index.d.ts.map +0 -1
  122. package/dist/components/Chat/hooks/useAutoScroll.cjs +0 -1
  123. package/dist/components/Chat/hooks/useAutoScroll.d.ts +0 -24
  124. package/dist/components/Chat/hooks/useAutoScroll.d.ts.map +0 -1
  125. package/dist/components/Chat/hooks/useAutoScroll.mjs +0 -50
  126. package/dist/components/Chat/hooks/useChatInput.cjs +0 -1
  127. package/dist/components/Chat/hooks/useChatInput.d.ts +0 -43
  128. package/dist/components/Chat/hooks/useChatInput.d.ts.map +0 -1
  129. package/dist/components/Chat/hooks/useChatInput.mjs +0 -44
  130. package/dist/components/Chat/hooks/useStreamingText.d.ts +0 -22
  131. package/dist/components/Chat/hooks/useStreamingText.d.ts.map +0 -1
  132. package/dist/components/Chat/hooks/useVoiceRecorder.cjs +0 -1
  133. package/dist/components/Chat/hooks/useVoiceRecorder.d.ts +0 -26
  134. package/dist/components/Chat/hooks/useVoiceRecorder.d.ts.map +0 -1
  135. package/dist/components/Chat/hooks/useVoiceRecorder.mjs +0 -74
  136. package/dist/components/Chat/index.d.ts +0 -28
  137. package/dist/components/Chat/index.d.ts.map +0 -1
  138. package/dist/components/Chat/utils.cjs +0 -1
  139. package/dist/components/Chat/utils.d.ts +0 -16
  140. package/dist/components/Chat/utils.d.ts.map +0 -1
  141. package/dist/components/Chat/utils.mjs +0 -12
  142. package/dist/rich.cjs +0 -1
  143. package/dist/rich.d.ts +0 -16
  144. package/dist/rich.d.ts.map +0 -1
  145. package/dist/rich.mjs +0 -4
@@ -1,217 +0,0 @@
1
- import { jsxs as l, Fragment as C, jsx as r } from "react/jsx-runtime";
2
- import { useState as D, useRef as Y, useEffect as x, useMemo as S, useCallback as y } from "react";
3
- import { Plus as A, X as U, Search as $, MessageSquare as T, Trash2 as q } from "lucide-react";
4
- import e from "../Chat.module.css.mjs";
5
- const G = {
6
- today: "Today",
7
- yesterday: "Yesterday",
8
- previous7: "Previous 7 days",
9
- previous30: "Previous 30 days",
10
- older: "Older"
11
- }, N = [
12
- "today",
13
- "yesterday",
14
- "previous7",
15
- "previous30",
16
- "older"
17
- ], B = (t) => {
18
- const a = /* @__PURE__ */ new Date(), d = (new Date(
19
- a.getFullYear(),
20
- a.getMonth(),
21
- a.getDate()
22
- ).getTime() - new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime()) / (1e3 * 60 * 60 * 24);
23
- return d < 1 ? "today" : d < 2 ? "yesterday" : d < 7 ? "previous7" : d < 30 ? "previous30" : "older";
24
- }, H = (t) => {
25
- const a = B(t);
26
- return a === "today" ? new Intl.DateTimeFormat("en-US", {
27
- hour: "numeric",
28
- minute: "2-digit"
29
- }).format(t) : a === "yesterday" ? "Yesterday" : a === "previous7" ? new Intl.DateTimeFormat("en-US", {
30
- weekday: "short"
31
- }).format(t) : new Intl.DateTimeFormat("en-US", {
32
- month: "short",
33
- day: "numeric"
34
- }).format(t);
35
- }, Q = (t) => {
36
- const a = /* @__PURE__ */ new Map();
37
- return N.forEach((o) => a.set(o, [])), t.forEach((o) => {
38
- const f = B(o.updatedAt);
39
- a.get(f)?.push(o);
40
- }), a;
41
- }, R = ({
42
- conversations: t = [],
43
- activeConversationId: a,
44
- onSelectConversation: o,
45
- onNewConversation: f,
46
- onDeleteConversation: d,
47
- onSearch: g,
48
- header: j,
49
- footer: v,
50
- collapsed: u = !1,
51
- onCollapsedChange: m,
52
- className: k,
53
- ...F
54
- }) => {
55
- const [h, z] = D(""), [p, b] = D(null), c = Y(
56
- void 0
57
- );
58
- x(() => () => {
59
- c.current && clearTimeout(c.current);
60
- }, []);
61
- const w = S(() => {
62
- if (!h.trim()) return t;
63
- const s = h.toLowerCase();
64
- return t.filter(
65
- (n) => n.title.toLowerCase().includes(s) || n.preview?.toLowerCase().includes(s)
66
- );
67
- }, [t, h]), I = S(() => Q(w), [w]), O = y(
68
- (s) => {
69
- const n = s.target.value;
70
- z(n), g?.(n);
71
- },
72
- [g]
73
- ), P = y(
74
- (s) => {
75
- o?.(s), u && m && m(!0);
76
- },
77
- [o, u, m]
78
- ), E = y(
79
- (s, n) => {
80
- s.stopPropagation(), p === n ? (d?.(n), b(null), c.current && clearTimeout(c.current)) : (b(n), c.current && clearTimeout(c.current), c.current = setTimeout(() => {
81
- b(null);
82
- }, 3e3));
83
- },
84
- [p, d]
85
- ), L = N.some(
86
- (s) => (I.get(s)?.length ?? 0) > 0
87
- );
88
- return /* @__PURE__ */ l(C, { children: [
89
- !u && /* @__PURE__ */ r(
90
- "div",
91
- {
92
- className: e.sidebarOverlay,
93
- onClick: () => m?.(!0),
94
- "aria-hidden": "true"
95
- }
96
- ),
97
- /* @__PURE__ */ l(
98
- "aside",
99
- {
100
- className: [
101
- e.sidebar,
102
- u && e.sidebarCollapsed,
103
- !u && e.sidebarOpen,
104
- k
105
- ].filter(Boolean).join(" "),
106
- ...F,
107
- children: [
108
- /* @__PURE__ */ r("div", { className: e.sidebarHeader, children: j || /* @__PURE__ */ l(C, { children: [
109
- /* @__PURE__ */ r(
110
- "button",
111
- {
112
- className: [
113
- e.inputButton,
114
- e.inputButtonPrimary,
115
- e.sidebarNewButton
116
- ].filter(Boolean).join(" "),
117
- onClick: f,
118
- "aria-label": "New conversation",
119
- children: /* @__PURE__ */ l("span", { className: e.sidebarNewButtonInner, children: [
120
- /* @__PURE__ */ r(A, { size: 18 }),
121
- /* @__PURE__ */ r("span", { children: "New Chat" })
122
- ] })
123
- }
124
- ),
125
- /* @__PURE__ */ r(
126
- "button",
127
- {
128
- className: [e.inputButton, e.sidebarCloseButton].join(
129
- " "
130
- ),
131
- onClick: () => m?.(!0),
132
- "aria-label": "Close sidebar",
133
- children: /* @__PURE__ */ r(U, { size: 20 })
134
- }
135
- )
136
- ] }) }),
137
- /* @__PURE__ */ r("div", { className: e.sidebarSearch, children: /* @__PURE__ */ l("div", { className: e.sidebarSearchWrapper, children: [
138
- /* @__PURE__ */ r($, { size: 16, className: e.sidebarSearchIcon }),
139
- /* @__PURE__ */ r(
140
- "input",
141
- {
142
- type: "search",
143
- className: [
144
- e.sidebarSearchInput,
145
- e.sidebarSearchInputWithIcon
146
- ].join(" "),
147
- placeholder: "Search conversations...",
148
- value: h,
149
- onChange: O,
150
- "aria-label": "Search conversations"
151
- }
152
- )
153
- ] }) }),
154
- /* @__PURE__ */ r(
155
- "div",
156
- {
157
- className: e.sidebarList,
158
- role: "list",
159
- "aria-label": "Conversations",
160
- children: L ? N.map((s) => {
161
- const n = I.get(s) ?? [];
162
- return n.length === 0 ? null : /* @__PURE__ */ l("div", { children: [
163
- /* @__PURE__ */ r("div", { className: e.sidebarGroupHeader, children: G[s] }),
164
- n.map((i) => /* @__PURE__ */ l(
165
- "button",
166
- {
167
- className: [
168
- e.sidebarItem,
169
- i.id === a && e.sidebarItemActive
170
- ].filter(Boolean).join(" "),
171
- onClick: () => P(i.id),
172
- role: "listitem",
173
- "aria-selected": i.id === a,
174
- "aria-label": `Conversation: ${i.title}`,
175
- children: [
176
- /* @__PURE__ */ r(
177
- T,
178
- {
179
- size: 18,
180
- className: e.sidebarItemIcon
181
- }
182
- ),
183
- /* @__PURE__ */ l("div", { className: e.sidebarItemContent, children: [
184
- /* @__PURE__ */ r("span", { className: e.sidebarItemTitle, children: i.title }),
185
- i.preview && /* @__PURE__ */ r("span", { className: e.sidebarItemPreview, children: i.preview })
186
- ] }),
187
- /* @__PURE__ */ r("span", { className: e.sidebarItemDate, children: H(i.updatedAt) }),
188
- d && /* @__PURE__ */ r(
189
- "button",
190
- {
191
- className: e.sidebarItemDelete,
192
- onClick: (M) => E(M, i.id),
193
- "aria-label": p === i.id ? `Confirm delete ${i.title}` : `Delete ${i.title}`,
194
- children: p === i.id ? /* @__PURE__ */ r("span", { className: e.sidebarItemDeleteConfirm, children: "Delete?" }) : /* @__PURE__ */ r(q, { size: 16 })
195
- }
196
- )
197
- ]
198
- },
199
- i.id
200
- ))
201
- ] }, s);
202
- }) : /* @__PURE__ */ l("div", { className: e.sidebarEmpty, children: [
203
- /* @__PURE__ */ r(T, { size: 32, className: e.sidebarEmptyIcon }),
204
- /* @__PURE__ */ r("p", { children: h ? "No conversations found" : "No conversations yet" })
205
- ] })
206
- }
207
- ),
208
- v && /* @__PURE__ */ r("div", { className: e.sidebarFooter, children: v })
209
- ]
210
- }
211
- )
212
- ] });
213
- };
214
- R.displayName = "ChatSidebar";
215
- export {
216
- R as ChatSidebar
217
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),e=require("../Chat.module.css.cjs"),s=({label:t="Generating response",className:i,...n})=>a.jsx("div",{className:[e.default.message,e.default.messageAssistant,i].filter(Boolean).join(" "),role:"status","aria-live":"polite","aria-label":t,...n,children:a.jsx("div",{className:e.default.messageContent,children:a.jsx("div",{className:[e.default.messageBubble,e.default.messageBubbleAssistant,e.default.thinkingBubble].join(" "),children:a.jsx("span",{className:e.default.thinkingSpinner})})})});s.displayName="ChatTypingIndicator";exports.ChatTypingIndicator=s;
@@ -1,5 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ChatTypingIndicatorProps } from '../Chat.types';
3
-
4
- export declare const ChatTypingIndicator: React.FC<ChatTypingIndicatorProps>;
5
- //# sourceMappingURL=ChatTypingIndicator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatTypingIndicator.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/components/ChatTypingIndicator.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG9D,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA4BlE,CAAC"}
@@ -1,31 +0,0 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import e from "../Chat.module.css.mjs";
3
- const t = ({
4
- label: a = "Generating response",
5
- className: i,
6
- ...n
7
- }) => /* @__PURE__ */ s(
8
- "div",
9
- {
10
- className: [e.message, e.messageAssistant, i].filter(Boolean).join(" "),
11
- role: "status",
12
- "aria-live": "polite",
13
- "aria-label": a,
14
- ...n,
15
- children: /* @__PURE__ */ s("div", { className: e.messageContent, children: /* @__PURE__ */ s(
16
- "div",
17
- {
18
- className: [
19
- e.messageBubble,
20
- e.messageBubbleAssistant,
21
- e.thinkingBubble
22
- ].join(" "),
23
- children: /* @__PURE__ */ s("span", { className: e.thinkingSpinner })
24
- }
25
- ) })
26
- }
27
- );
28
- t.displayName = "ChatTypingIndicator";
29
- export {
30
- t as ChatTypingIndicator
31
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("lucide-react"),g=require("../hooks/useVoiceRecorder.cjs"),b=require("../utils.cjs"),r=require("../Chat.module.css.cjs"),t=({onRecordingComplete:s,onCancel:u,maxDuration:f=300,className:a,...d})=>{const{isRecording:o,duration:v,audioBlob:c,error:l,startRecording:R,stopRecording:j,cancelRecording:x,reset:n,isSupported:m}=g.useVoiceRecorder({maxDuration:f,onRecordingComplete:s,onError:B=>console.error("Recording error:",B)}),h=()=>{o?j():c?(s?.(c),n()):R()},N=()=>{x(),u?.()};return m?l?e.jsxs("div",{className:[r.default.voiceRecorder,a].filter(Boolean).join(" "),...d,children:[e.jsx("div",{className:r.default.voiceRecorderInfo,children:e.jsx("span",{className:[r.default.voiceRecorderLabel,r.default.voiceRecorderError].join(" "),children:l})}),e.jsx("button",{className:r.default.inputButton,onClick:n,"aria-label":"Try again",children:e.jsx(i.X,{size:20})})]}):e.jsxs("div",{className:[r.default.voiceRecorder,a].filter(Boolean).join(" "),...d,children:[e.jsx("button",{className:[r.default.voiceRecorderButton,!o&&!c&&r.default.voiceRecorderButtonIdle].filter(Boolean).join(" "),onClick:h,"aria-label":o?"Stop recording":c?"Send recording":"Start recording",children:o?e.jsx(i.Square,{size:20}):c?e.jsx(i.Send,{size:20}):e.jsx(i.Mic,{size:20})}),e.jsxs("div",{className:r.default.voiceRecorderInfo,children:[e.jsx("span",{className:r.default.voiceRecorderDuration,children:b.formatTime(v)}),e.jsx("span",{className:r.default.voiceRecorderLabel,children:o?"Recording...":c?"Recording ready":"Click to record"})]}),o&&e.jsxs("div",{className:r.default.voiceRecorderWaveform,children:[e.jsx("div",{className:r.default.voiceRecorderBar}),e.jsx("div",{className:r.default.voiceRecorderBar}),e.jsx("div",{className:r.default.voiceRecorderBar}),e.jsx("div",{className:r.default.voiceRecorderBar}),e.jsx("div",{className:r.default.voiceRecorderBar})]}),(o||c)&&e.jsx("div",{className:r.default.voiceRecorderActions,children:e.jsx("button",{className:r.default.inputButton,onClick:N,"aria-label":"Cancel recording",children:e.jsx(i.X,{size:20})})})]}):e.jsx("div",{className:[r.default.voiceRecorder,a].filter(Boolean).join(" "),...d,children:e.jsx("div",{className:r.default.voiceRecorderInfo,children:e.jsx("span",{className:r.default.voiceRecorderLabel,children:"Voice recording is not supported in this browser"})})})};t.displayName="ChatVoiceRecorder";exports.ChatVoiceRecorder=t;
@@ -1,5 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ChatVoiceRecorderProps } from '../Chat.types';
3
-
4
- export declare const ChatVoiceRecorder: React.FC<ChatVoiceRecorderProps>;
5
- //# sourceMappingURL=ChatVoiceRecorder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatVoiceRecorder.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/components/ChatVoiceRecorder.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAK5D,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAwJ9D,CAAC"}
@@ -1,111 +0,0 @@
1
- import { jsx as r, jsxs as c } from "react/jsx-runtime";
2
- import { X as t, Square as b, Send as C, Mic as j } from "lucide-react";
3
- import { useVoiceRecorder as S } from "../hooks/useVoiceRecorder.mjs";
4
- import { formatTime as k } from "../utils.mjs";
5
- import e from "../Chat.module.css.mjs";
6
- const z = ({
7
- onRecordingComplete: d,
8
- onCancel: v,
9
- maxDuration: m = 300,
10
- className: a,
11
- ...n
12
- }) => {
13
- const {
14
- isRecording: o,
15
- duration: R,
16
- audioBlob: i,
17
- error: s,
18
- startRecording: h,
19
- stopRecording: u,
20
- cancelRecording: N,
21
- reset: l,
22
- isSupported: f
23
- } = S({
24
- maxDuration: m,
25
- onRecordingComplete: d,
26
- onError: (g) => console.error("Recording error:", g)
27
- }), p = () => {
28
- o ? u() : i ? (d?.(i), l()) : h();
29
- }, B = () => {
30
- N(), v?.();
31
- };
32
- return f ? s ? /* @__PURE__ */ c(
33
- "div",
34
- {
35
- className: [e.voiceRecorder, a].filter(Boolean).join(" "),
36
- ...n,
37
- children: [
38
- /* @__PURE__ */ r("div", { className: e.voiceRecorderInfo, children: /* @__PURE__ */ r(
39
- "span",
40
- {
41
- className: [
42
- e.voiceRecorderLabel,
43
- e.voiceRecorderError
44
- ].join(" "),
45
- children: s
46
- }
47
- ) }),
48
- /* @__PURE__ */ r(
49
- "button",
50
- {
51
- className: e.inputButton,
52
- onClick: l,
53
- "aria-label": "Try again",
54
- children: /* @__PURE__ */ r(t, { size: 20 })
55
- }
56
- )
57
- ]
58
- }
59
- ) : /* @__PURE__ */ c(
60
- "div",
61
- {
62
- className: [e.voiceRecorder, a].filter(Boolean).join(" "),
63
- ...n,
64
- children: [
65
- /* @__PURE__ */ r(
66
- "button",
67
- {
68
- className: [
69
- e.voiceRecorderButton,
70
- !o && !i && e.voiceRecorderButtonIdle
71
- ].filter(Boolean).join(" "),
72
- onClick: p,
73
- "aria-label": o ? "Stop recording" : i ? "Send recording" : "Start recording",
74
- children: o ? /* @__PURE__ */ r(b, { size: 20 }) : i ? /* @__PURE__ */ r(C, { size: 20 }) : /* @__PURE__ */ r(j, { size: 20 })
75
- }
76
- ),
77
- /* @__PURE__ */ c("div", { className: e.voiceRecorderInfo, children: [
78
- /* @__PURE__ */ r("span", { className: e.voiceRecorderDuration, children: k(R) }),
79
- /* @__PURE__ */ r("span", { className: e.voiceRecorderLabel, children: o ? "Recording..." : i ? "Recording ready" : "Click to record" })
80
- ] }),
81
- o && /* @__PURE__ */ c("div", { className: e.voiceRecorderWaveform, children: [
82
- /* @__PURE__ */ r("div", { className: e.voiceRecorderBar }),
83
- /* @__PURE__ */ r("div", { className: e.voiceRecorderBar }),
84
- /* @__PURE__ */ r("div", { className: e.voiceRecorderBar }),
85
- /* @__PURE__ */ r("div", { className: e.voiceRecorderBar }),
86
- /* @__PURE__ */ r("div", { className: e.voiceRecorderBar })
87
- ] }),
88
- (o || i) && /* @__PURE__ */ r("div", { className: e.voiceRecorderActions, children: /* @__PURE__ */ r(
89
- "button",
90
- {
91
- className: e.inputButton,
92
- onClick: B,
93
- "aria-label": "Cancel recording",
94
- children: /* @__PURE__ */ r(t, { size: 20 })
95
- }
96
- ) })
97
- ]
98
- }
99
- ) : /* @__PURE__ */ r(
100
- "div",
101
- {
102
- className: [e.voiceRecorder, a].filter(Boolean).join(" "),
103
- ...n,
104
- children: /* @__PURE__ */ r("div", { className: e.voiceRecorderInfo, children: /* @__PURE__ */ r("span", { className: e.voiceRecorderLabel, children: "Voice recording is not supported in this browser" }) })
105
- }
106
- );
107
- };
108
- z.displayName = "ChatVoiceRecorder";
109
- export {
110
- z as ChatVoiceRecorder
111
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * Chat Component - Sub-components
3
- */
4
- export { ChatMessage } from './ChatMessage';
5
- export { ChatMessages } from './ChatMessages';
6
- export { ChatInput } from './ChatInput';
7
- export { ChatHeader } from './ChatHeader';
8
- export { ChatTypingIndicator } from './ChatTypingIndicator';
9
- export { ChatCodeBlock } from './ChatCodeBlock';
10
- export { ChatMarkdown } from './ChatMarkdown';
11
- export { ChatImagePreview } from './ChatImagePreview';
12
- export { ChatAudioPlayer } from './ChatAudioPlayer';
13
- export { ChatVoiceRecorder } from './ChatVoiceRecorder';
14
- export { ChatFileUpload } from './ChatFileUpload';
15
- export { ChatAttachment } from './ChatAttachment';
16
- export { ChatLightbox } from './ChatLightbox';
17
- export { ChatSidebar } from './ChatSidebar';
18
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Chat Component Hooks
3
- */
4
- export { useAutoScroll } from './useAutoScroll';
5
- export type { UseAutoScrollOptions, UseAutoScrollReturn, } from './useAutoScroll';
6
- export { useVoiceRecorder } from './useVoiceRecorder';
7
- export type { UseVoiceRecorderOptions, UseVoiceRecorderReturn, } from './useVoiceRecorder';
8
- export { useChatInput } from './useChatInput';
9
- export type { UseChatInputOptions, UseChatInputReturn } from './useChatInput';
10
- export { useStreamingText } from './useStreamingText';
11
- export type { UseStreamingTextOptions, UseStreamingTextReturn, } from './useStreamingText';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react");function v(h={}){const{enabled:a=!0,threshold:f=100,smooth:c=!0}=h,o=r.useRef(null),[b,m]=r.useState(!0),u=r.useRef(!1),l=r.useRef(!0),n=r.useCallback(()=>{const t=o.current;if(!t)return!0;const{scrollTop:e,scrollHeight:s,clientHeight:d}=t;return s-e-d<f},[f]),i=r.useCallback(()=>{const t=o.current;t&&(u.current=!0,t.scrollTo({top:t.scrollHeight,behavior:c?"smooth":"auto"}),setTimeout(()=>{u.current=!1;const e=n();l.current=e,m(e)},c?300:0))},[c,n]);return r.useEffect(()=>{const t=o.current;if(!t)return;const e=()=>{if(u.current)return;const s=n();l.current=s,m(s)};return t.addEventListener("scroll",e,{passive:!0}),()=>t.removeEventListener("scroll",e)},[n]),r.useEffect(()=>{if(!a)return;const t=o.current;if(!t)return;const e=new MutationObserver(()=>{l.current&&i()});return e.observe(t,{childList:!0,subtree:!0}),()=>e.disconnect()},[a,i]),{scrollRef:o,isAtBottom:b,scrollToBottom:i}}exports.useAutoScroll=v;
@@ -1,24 +0,0 @@
1
- /**
2
- * useAutoScroll Hook
3
- *
4
- * Automatically scrolls to the bottom of a container when new content is added.
5
- * Includes smart detection to pause auto-scroll when user scrolls up.
6
- */
7
- export interface UseAutoScrollOptions {
8
- /** Whether auto-scroll is enabled */
9
- enabled?: boolean;
10
- /** Threshold in pixels from bottom to consider "at bottom" */
11
- threshold?: number;
12
- /** Smooth scroll behavior */
13
- smooth?: boolean;
14
- }
15
- export interface UseAutoScrollReturn {
16
- /** Ref to attach to the scrollable container */
17
- scrollRef: React.RefObject<HTMLDivElement | null>;
18
- /** Whether the user is currently at the bottom */
19
- isAtBottom: boolean;
20
- /** Manually scroll to bottom */
21
- scrollToBottom: () => void;
22
- }
23
- export declare function useAutoScroll(options?: UseAutoScrollOptions): UseAutoScrollReturn;
24
- //# sourceMappingURL=useAutoScroll.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAutoScroll.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/hooks/useAutoScroll.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClD,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,gCAAgC;IAChC,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,wBAAgB,aAAa,CAC3B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAuFrB"}
@@ -1,50 +0,0 @@
1
- import { useRef as i, useState as A, useCallback as h, useEffect as v } from "react";
2
- function g(b = {}) {
3
- const { enabled: a = !0, threshold: f = 100, smooth: s = !0 } = b, r = i(null), [d, m] = A(!0), c = i(!1), u = i(!0), o = h(() => {
4
- const t = r.current;
5
- if (!t) return !0;
6
- const { scrollTop: e, scrollHeight: n, clientHeight: B } = t;
7
- return n - e - B < f;
8
- }, [f]), l = h(() => {
9
- const t = r.current;
10
- t && (c.current = !0, t.scrollTo({
11
- top: t.scrollHeight,
12
- behavior: s ? "smooth" : "auto"
13
- }), setTimeout(
14
- () => {
15
- c.current = !1;
16
- const e = o();
17
- u.current = e, m(e);
18
- },
19
- s ? 300 : 0
20
- ));
21
- }, [s, o]);
22
- return v(() => {
23
- const t = r.current;
24
- if (!t) return;
25
- const e = () => {
26
- if (c.current) return;
27
- const n = o();
28
- u.current = n, m(n);
29
- };
30
- return t.addEventListener("scroll", e, { passive: !0 }), () => t.removeEventListener("scroll", e);
31
- }, [o]), v(() => {
32
- if (!a) return;
33
- const t = r.current;
34
- if (!t) return;
35
- const e = new MutationObserver(() => {
36
- u.current && l();
37
- });
38
- return e.observe(t, {
39
- childList: !0,
40
- subtree: !0
41
- }), () => e.disconnect();
42
- }, [a, l]), {
43
- scrollRef: r,
44
- isAtBottom: d,
45
- scrollToBottom: l
46
- };
47
- }
48
- export {
49
- g as useAutoScroll
50
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function S(g={}){const{maxLength:i,onSend:h,disabled:f=!1}=g,[n,m]=e.useState(""),[s,c]=e.useState([]),a=e.useRef(null),d=n.length,u=i!==void 0&&d>i,l=n.trim().length===0&&s.length===0;e.useEffect(()=>{const t=a.current;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)},[n]);const b=e.useCallback(t=>{c(o=>[...o,...t])},[]),y=e.useCallback(t=>{c(o=>o.filter((x,p)=>p!==t))},[]),C=e.useCallback(()=>{c([])},[]),r=e.useCallback(()=>{if(f||l&&s.length===0||u)return;const t=n.trim();h?.(t,s.length>0?s:void 0),m(""),c([]),a.current&&(a.current.style.height="auto")},[f,l,u,n,s,h]),k=e.useCallback(t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),r())},[r]),v=e.useCallback(()=>{a.current?.focus()},[]);return{value:n,setValue:m,attachments:s,addAttachments:b,removeAttachment:y,clearAttachments:C,handleSubmit:r,handleKeyDown:k,textareaRef:a,isEmpty:l,charCount:d,isOverLimit:u,focus:v}}exports.useChatInput=S;
@@ -1,43 +0,0 @@
1
- /**
2
- * useChatInput Hook
3
- *
4
- * Manages chat input state including text, attachments, and submission.
5
- */
6
- export interface UseChatInputOptions {
7
- /** Maximum character count */
8
- maxLength?: number;
9
- /** Callback when message is sent */
10
- onSend?: (message: string, attachments?: File[]) => void;
11
- /** Whether input is disabled */
12
- disabled?: boolean;
13
- }
14
- export interface UseChatInputReturn {
15
- /** Current input value */
16
- value: string;
17
- /** Set input value */
18
- setValue: (value: string) => void;
19
- /** Pending file attachments */
20
- attachments: File[];
21
- /** Add files to attachments */
22
- addAttachments: (files: File[]) => void;
23
- /** Remove attachment by index */
24
- removeAttachment: (index: number) => void;
25
- /** Clear all attachments */
26
- clearAttachments: () => void;
27
- /** Handle form submission */
28
- handleSubmit: () => void;
29
- /** Handle key down (for Enter to send) */
30
- handleKeyDown: (e: React.KeyboardEvent) => void;
31
- /** Ref for textarea element */
32
- textareaRef: React.RefObject<HTMLTextAreaElement | null>;
33
- /** Whether input is empty */
34
- isEmpty: boolean;
35
- /** Current character count */
36
- charCount: number;
37
- /** Whether character limit is exceeded */
38
- isOverLimit: boolean;
39
- /** Focus the input */
40
- focus: () => void;
41
- }
42
- export declare function useChatInput(options?: UseChatInputOptions): UseChatInputReturn;
43
- //# sourceMappingURL=useChatInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useChatInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/hooks/useChatInput.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACzD,gCAAgC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,+BAA+B;IAC/B,WAAW,EAAE,IAAI,EAAE,CAAC;IACpB,+BAA+B;IAC/B,cAAc,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACxC,iCAAiC;IACjC,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,4BAA4B;IAC5B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,6BAA6B;IAC7B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,0CAA0C;IAC1C,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAChD,+BAA+B;IAC/B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACzD,6BAA6B;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,WAAW,EAAE,OAAO,CAAC;IACrB,sBAAsB;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CAwFpB"}
@@ -1,44 +0,0 @@
1
- import { useState as g, useRef as E, useEffect as S, useCallback as s } from "react";
2
- function K(y = {}) {
3
- const { maxLength: l, onSend: h, disabled: f = !1 } = y, [e, m] = g(""), [n, r] = g([]), c = E(null), d = e.length, o = l !== void 0 && d > l, a = e.trim().length === 0 && n.length === 0;
4
- S(() => {
5
- const t = c.current;
6
- t && (t.style.height = "auto", t.style.height = `${t.scrollHeight}px`);
7
- }, [e]);
8
- const p = s((t) => {
9
- r((i) => [...i, ...t]);
10
- }, []), v = s((t) => {
11
- r((i) => i.filter((k, C) => C !== t));
12
- }, []), x = s(() => {
13
- r([]);
14
- }, []), u = s(() => {
15
- if (f || a && n.length === 0 || o) return;
16
- const t = e.trim();
17
- h?.(t, n.length > 0 ? n : void 0), m(""), r([]), c.current && (c.current.style.height = "auto");
18
- }, [f, a, o, e, n, h]), A = s(
19
- (t) => {
20
- t.key === "Enter" && !t.shiftKey && (t.preventDefault(), u());
21
- },
22
- [u]
23
- ), b = s(() => {
24
- c.current?.focus();
25
- }, []);
26
- return {
27
- value: e,
28
- setValue: m,
29
- attachments: n,
30
- addAttachments: p,
31
- removeAttachment: v,
32
- clearAttachments: x,
33
- handleSubmit: u,
34
- handleKeyDown: A,
35
- textareaRef: c,
36
- isEmpty: a,
37
- charCount: d,
38
- isOverLimit: o,
39
- focus: b
40
- };
41
- }
42
- export {
43
- K as useChatInput
44
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * useStreamingText Hook
3
- *
4
- * Reveals text progressively, word by word, simulating real-time
5
- * content generation. Content is final — text only grows, never rewrites.
6
- */
7
- export interface UseStreamingTextOptions {
8
- /** Words revealed per tick (default: 2) */
9
- wordsPerTick?: number;
10
- /** Milliseconds between ticks (default: 60) */
11
- intervalMs?: number;
12
- /** Whether streaming is active (default: true) */
13
- enabled?: boolean;
14
- }
15
- export interface UseStreamingTextReturn {
16
- /** The portion of text currently visible */
17
- displayText: string;
18
- /** Whether all text has been revealed */
19
- isComplete: boolean;
20
- }
21
- export declare function useStreamingText(fullText: string, options?: UseStreamingTextOptions): UseStreamingTextReturn;
22
- //# sourceMappingURL=useStreamingText.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useStreamingText.d.ts","sourceRoot":"","sources":["../../../../src/components/Chat/hooks/useStreamingText.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,uBAAuB;IACtC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,uBAA4B,GACpC,sBAAsB,CAqCxB"}
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function B(S={}){const{maxDuration:v=300,mimeType:f="audio/webm",onRecordingComplete:y,onError:i}=S,[p,R]=e.useState(!1),[T,m]=e.useState(0),[h,b]=e.useState(),[C,s]=e.useState(),u=e.useRef(null),d=e.useRef(null),l=e.useRef([]),n=e.useRef(null),M=e.useRef(0),g=typeof window<"u"&&"MediaRecorder"in window,o=e.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null),d.current&&(d.current.getTracks().forEach(t=>t.stop()),d.current=null),u.current=null,l.current=[]},[]),D=e.useCallback(async()=>{if(!g){const t="Voice recording is not supported in this browser";s(t),i?.(t);return}try{s(void 0),b(void 0),m(0),l.current=[];const t=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=t;let c=f;MediaRecorder.isTypeSupported(f)||(c=["audio/webm","audio/mp4","audio/ogg"].find(I=>MediaRecorder.isTypeSupported(I))||"");const a=new MediaRecorder(t,{mimeType:c||void 0});u.current=a,a.ondataavailable=r=>{r.data.size>0&&l.current.push(r.data)},a.onstop=()=>{const r=new Blob(l.current,{type:c||"audio/webm"});b(r),y?.(r),o()},a.onerror=()=>{const r="Recording failed";s(r),i?.(r),o()},a.start(100),R(!0),M.current=Date.now(),n.current=window.setInterval(()=>{const r=Math.floor((Date.now()-M.current)/1e3);m(r),r>=v&&k()},100)}catch(t){const c=t instanceof Error?t.message:"Failed to access microphone";s(c),i?.(c),o()}},[g,f,v,y,i,o]),k=e.useCallback(()=>{u.current&&p&&(u.current.stop(),R(!1),n.current&&(clearInterval(n.current),n.current=null))},[p]),w=e.useCallback(()=>{o(),R(!1),m(0),b(void 0)},[o]),E=e.useCallback(()=>{w(),s(void 0)},[w]);return e.useEffect(()=>()=>{o()},[o]),{isRecording:p,duration:T,audioBlob:h,error:C,startRecording:D,stopRecording:k,cancelRecording:w,reset:E,isSupported:g}}exports.useVoiceRecorder=B;