@aslaluroba/help-center-react 3.2.16 → 3.2.18

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 (102) hide show
  1. package/dist/components/shared/Button/button.d.ts +1 -1
  2. package/dist/components/shared/Card/card.d.ts +1 -4
  3. package/dist/components/ui/agent-response/agent-response.d.ts +2 -1
  4. package/dist/index.css +1424 -1
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.esm.js +19248 -38614
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.js +19269 -38635
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/LanguageContext.d.ts +1 -1
  11. package/dist/lib/custom-hooks/useAblyConnection.d.ts +25 -0
  12. package/dist/lib/custom-hooks/useActionHandler.d.ts +1 -7
  13. package/dist/lib/custom-hooks/useChatSession.d.ts +37 -0
  14. package/dist/lib/custom-hooks/useMessageQueue.d.ts +16 -0
  15. package/dist/lib/custom-hooks/useReview.d.ts +14 -0
  16. package/dist/lib/index.d.ts +1 -2
  17. package/dist/services.d.ts +9 -6
  18. package/dist/services.esm.js +1 -14195
  19. package/dist/services.esm.js.map +1 -1
  20. package/dist/services.js +19 -14191
  21. package/dist/services.js.map +1 -1
  22. package/dist/ui/chatbot-popup/chat-window-screen/footer.d.ts +1 -1
  23. package/dist/ui/chatbot-popup/chat-window-screen/in-chat-review.d.ts +1 -1
  24. package/dist/ui/chatbot-popup/chat-window-screen/index.d.ts +2 -2
  25. package/dist/ui/chatbot-popup/options-list-screen/helpscreen-list.d.ts +1 -1
  26. package/dist/ui/chatbot-popup/options-list-screen/helpscreen-option.d.ts +1 -1
  27. package/dist/ui/chatbot-popup/options-list-screen/index.d.ts +1 -1
  28. package/dist/ui/help-center.d.ts +1 -1
  29. package/dist/ui/help-popup.d.ts +4 -27
  30. package/dist/ui/review-dialog/index.d.ts +1 -1
  31. package/package.json +31 -45
  32. package/postcss.config.js +5 -0
  33. package/rollup.config.mjs +34 -0
  34. package/tsconfig.json +5 -6
  35. package/dist/core/AblyService.d.ts +0 -16
  36. package/dist/core/ApiService.d.ts +0 -16
  37. package/dist/core/api.d.ts +0 -10
  38. package/dist/core/token-service.d.ts +0 -10
  39. package/dist/i18n.d.ts +0 -3
  40. package/dist/lib/config.d.ts +0 -18
  41. package/dist/lib/theme-utils.d.ts +0 -10
  42. package/dist/lib/types.d.ts +0 -145
  43. package/dist/lib/utils.d.ts +0 -2
  44. package/src/assets/animatedLogo.gif +0 -0
  45. package/src/assets/logo.svg +0 -5
  46. package/src/assets/seperator.svg +0 -5
  47. package/src/components/index.ts +0 -1
  48. package/src/components/shared/Button/button.tsx +0 -38
  49. package/src/components/shared/Button/index.ts +0 -1
  50. package/src/components/shared/Card/card.tsx +0 -44
  51. package/src/components/shared/Card/index.ts +0 -1
  52. package/src/components/shared/index.ts +0 -2
  53. package/src/components/ui/agent-response/agent-response.tsx +0 -57
  54. package/src/components/ui/agent-response/doc.md +0 -88
  55. package/src/components/ui/image-attachment.tsx +0 -119
  56. package/src/components/ui/image-preview-dialog.tsx +0 -400
  57. package/src/components/ui/index.ts +0 -3
  58. package/src/core/AblyService.ts +0 -243
  59. package/src/core/ApiService.ts +0 -116
  60. package/src/core/api.ts +0 -278
  61. package/src/core/token-service.ts +0 -35
  62. package/src/globals.css +0 -268
  63. package/src/i18n.ts +0 -21
  64. package/src/index.ts +0 -19
  65. package/src/lib/LanguageContext.tsx +0 -28
  66. package/src/lib/config.ts +0 -52
  67. package/src/lib/custom-hooks/useActionHandler.ts +0 -102
  68. package/src/lib/custom-hooks/useTypewriter.ts +0 -26
  69. package/src/lib/index.ts +0 -4
  70. package/src/lib/theme-utils.ts +0 -56
  71. package/src/lib/types.ts +0 -158
  72. package/src/lib/utils.ts +0 -6
  73. package/src/locales/ar.json +0 -45
  74. package/src/locales/en.json +0 -45
  75. package/src/services.ts +0 -14
  76. package/src/types/icons.d.ts +0 -6
  77. package/src/types/svg.d.ts +0 -5
  78. package/src/types.d.ts +0 -9
  79. package/src/ui/chatbot-popup/active-chat-actions.tsx +0 -39
  80. package/src/ui/chatbot-popup/chat-window-screen/action-button.tsx +0 -37
  81. package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +0 -313
  82. package/src/ui/chatbot-popup/chat-window-screen/header.tsx +0 -53
  83. package/src/ui/chatbot-popup/chat-window-screen/in-chat-review.tsx +0 -116
  84. package/src/ui/chatbot-popup/chat-window-screen/index.tsx +0 -366
  85. package/src/ui/chatbot-popup/chat-window-screen/typing-indicator.tsx +0 -31
  86. package/src/ui/chatbot-popup/error-screen/index.tsx +0 -22
  87. package/src/ui/chatbot-popup/loading-screen/index.tsx +0 -21
  88. package/src/ui/chatbot-popup/options-list-screen/company-card.tsx +0 -39
  89. package/src/ui/chatbot-popup/options-list-screen/header.tsx +0 -23
  90. package/src/ui/chatbot-popup/options-list-screen/helpscreen-intro.tsx +0 -32
  91. package/src/ui/chatbot-popup/options-list-screen/helpscreen-list.tsx +0 -57
  92. package/src/ui/chatbot-popup/options-list-screen/helpscreen-option.tsx +0 -56
  93. package/src/ui/chatbot-popup/options-list-screen/index.tsx +0 -70
  94. package/src/ui/confirmation-modal/index.tsx +0 -62
  95. package/src/ui/floating-message.tsx +0 -28
  96. package/src/ui/help-button.tsx +0 -24
  97. package/src/ui/help-center.tsx +0 -448
  98. package/src/ui/help-popup.tsx +0 -367
  99. package/src/ui/powered-by.tsx +0 -62
  100. package/src/ui/review-dialog/index.tsx +0 -149
  101. package/src/ui/review-dialog/rating.tsx +0 -79
  102. package/src/useLocalTranslation.ts +0 -15
package/src/globals.css DELETED
@@ -1,268 +0,0 @@
1
- @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap');
2
-
3
- /* Tailwind v4: theme + utilities only (base/preflight disabled) */
4
- @layer theme, base, components, utilities;
5
- @import "tailwindcss/theme.css" layer(theme) prefix(babylai);
6
- @import "tailwindcss/utilities.css" layer(utilities) prefix(babylai);
7
-
8
- /* CSS Custom Properties - Light Theme (Default) */
9
- :root {
10
- --babylai-font-sans: "Cairo", sans-serif;
11
- /* Light theme colors */
12
- --babylai-black-white-50: #ffffff;
13
- --babylai-black-white-100: #f3f3f3;
14
- --babylai-black-white-200: #e2e2e2;
15
- --babylai-black-white-300: #919191;
16
- --babylai-black-white-400: #606060;
17
- --babylai-black-white-500: #333333;
18
- --babylai-black-white-600: #1f1f1f;
19
- --babylai-black-white-700: #171717;
20
- --babylai-black-white-800: #0a0a0a;
21
- --babylai-black-white-900: #050505;
22
- --babylai-black-white-950: #000000;
23
- --babylai-black-white-default: #333333;
24
- --babylai-primary-color: #ad49e1;
25
- --babylai-primary-color-100: #f6ecfc;
26
- --babylai-primary-color-200: #deb6f3;
27
- --babylai-primary-color-300: #d49cee;
28
- --babylai-primary-color-400: #c57fea;
29
- --babylai-primary-color-500: #ad49e1;
30
- --babylai-primary-color-600: #672b87;
31
- --babylai-primary-color-700: #451d5a;
32
- --babylai-primary-color-800: #220e2d;
33
- --babylai-primary-color-900: #110716;
34
- --babylai-primary-color-950: #0a0310;
35
-
36
- /* Theme-aware colors - Light mode defaults */
37
- --babylai-background: var(--babylai-black-white-50);
38
- --babylai-card: var(--babylai-black-white-50);
39
- --babylai-card-foreground: var(--babylai-black-white-500);
40
- --babylai-secondary: var(--babylai-black-white-100);
41
- --babylai-secondary-foreground: var(--babylai-black-white-500);
42
- --babylai-muted: var(--babylai-black-white-100);
43
- --babylai-muted-foreground: var(--babylai-black-white-400);
44
- --babylai-destructive: #ef4444;
45
- --babylai-destructive-foreground: var(--babylai-black-white-50);
46
- --babylai-border: var(--babylai-black-white-200);
47
- --babylai-ring: var(--babylai-primary-color);
48
- --babylai-radius: 0.5rem;
49
- }
50
-
51
- /* Tailwind v4 Theme Configuration - must come after @import */
52
- /* Using actual color values for build-time, CSS variables will override at runtime */
53
- /* postcss-disable-next-line */
54
- @theme {
55
- /* Font Family - override Tailwind's default sans font */
56
- --font-sans: "Cairo", sans-serif;
57
-
58
- /* Primary Colors - default light theme values */
59
- --color-primary: var(--babylai-primary-color);
60
- --color-primary-100: var(--babylai-primary-color-100);
61
- --color-primary-200: var(--babylai-primary-color-200);
62
- --color-primary-300: var(--babylai-primary-color-300);
63
- --color-primary-400: var(--babylai-primary-color-400);
64
- --color-primary-500: var(--babylai-primary-color-500);
65
- --color-primary-600: var(--babylai-primary-color-600);
66
- --color-primary-700: var(--babylai-primary-color-700);
67
- --color-primary-800: var(--babylai-primary-color-800);
68
- --color-primary-900: var(--babylai-primary-color-900);
69
- --color-primary-950: var(--babylai-primary-color-950);
70
-
71
- /* Theme Colors - default light theme values */
72
- --color-background: var(--babylai-background);
73
- --color-card: var(--babylai-card);
74
- --color-card-foreground: var(--babylai-card-foreground);
75
- --color-secondary: var(--babylai-secondary);
76
- --color-secondary-foreground: var(--babylai-secondary-foreground);
77
- --color-muted: var(--babylai-muted);
78
- --color-muted-foreground: var(--babylai-muted-foreground);
79
- --color-destructive: var(--babylai-destructive);
80
- --color-destructive-foreground: var(--babylai-destructive-foreground);
81
- --color-border: var(--babylai-border);
82
- --color-ring: var(--babylai-ring);
83
-
84
- /* Black-White Scale */
85
- --color-black-white-50: var(--babylai-black-white-50);
86
- --color-black-white-100: var(--babylai-black-white-100);
87
- --color-black-white-200: var(--babylai-black-white-200);
88
- --color-black-white-300: var(--babylai-black-white-300);
89
- --color-black-white-400: var(--babylai-black-white-400);
90
- --color-black-white-500: var(--babylai-black-white-500);
91
- --color-black-white-600: var(--babylai-black-white-600);
92
- --color-black-white-700: var(--babylai-black-white-700);
93
- --color-black-white-800: var(--babylai-black-white-800);
94
- --color-black-white-900: var(--babylai-black-white-900);
95
- --color-black-white-950: var(--babylai-black-white-950);
96
-
97
- --animate-wave: wave 1.3s ease-in-out infinite;
98
- --animate-circular-progress: circular-progress 2s ease-in-out infinite;
99
- --animate-float: float 3s infinite ease-in-out;
100
-
101
- @keyframes wave {
102
-
103
- 0%,
104
- 60%,
105
- 100% {
106
- transform: initial;
107
- }
108
-
109
- 30% {
110
- transform: translateY(-10px);
111
- }
112
- }
113
-
114
- @keyframes circular-progress {
115
- 0% {
116
- stroke-dashoffset: 100.48;
117
- }
118
-
119
- 50% {
120
- stroke-dashoffset: 25.12;
121
- }
122
-
123
- 100% {
124
- stroke-dashoffset: 100.48;
125
- }
126
- }
127
-
128
- @keyframes float {
129
-
130
- 0%,
131
- 100% {
132
- transform: translateY(0);
133
- }
134
-
135
- 50% {
136
- transform: translateY(-10px);
137
- }
138
- }
139
-
140
- @keyframes typing-dot {
141
-
142
- 0%,
143
- 60%,
144
- 100% {
145
- opacity: 0.35;
146
- transform: scale(0.85);
147
- }
148
-
149
- 30% {
150
- opacity: 1;
151
- transform: scale(1);
152
- }
153
- }
154
- }
155
-
156
- /* Typing indicator dots - staggered pulse animation */
157
- .babylai-typing-dot {
158
- animation: typing-dot 1.4s ease-in-out infinite;
159
- }
160
-
161
- .babylai-typing-dot:nth-child(1) {
162
- animation-delay: 0ms;
163
- }
164
-
165
- .babylai-typing-dot:nth-child(2) {
166
- animation-delay: 0.2s;
167
- }
168
-
169
- .babylai-typing-dot:nth-child(3) {
170
- animation-delay: 0.4s;
171
- }
172
-
173
- /* Re-scope primary theme vars on widget root so primaryColor prop (inline style) wins over :root.
174
- Tailwind v4 with prefix(babylai) emits --babylai-color-primary-* in utilities, so we set
175
- prefixed names here so they resolve from this element. */
176
- .babylai-theme-root {
177
- --babylai-color-primary: var(--babylai-primary-color);
178
- --babylai-color-primary-100: var(--babylai-primary-color-100);
179
- --babylai-color-primary-200: var(--babylai-primary-color-200);
180
- --babylai-color-primary-300: var(--babylai-primary-color-300);
181
- --babylai-color-primary-400: var(--babylai-primary-color-400);
182
- --babylai-color-primary-500: var(--babylai-primary-color-500);
183
- --babylai-color-primary-600: var(--babylai-primary-color-600);
184
- --babylai-color-primary-700: var(--babylai-primary-color-700);
185
- --babylai-color-primary-800: var(--babylai-primary-color-800);
186
- --babylai-color-primary-900: var(--babylai-primary-color-900);
187
- --babylai-color-primary-950: var(--babylai-primary-color-950);
188
- --ring: var(--babylai-primary-color);
189
- --color-ring: var(--babylai-primary-color);
190
- font-family: var(--babylai-font-sans);
191
-
192
- * {
193
- box-sizing: border-box;
194
- }
195
-
196
- button {
197
- font: inherit;
198
- }
199
-
200
- input,
201
- textarea {
202
- font-family: inherit;
203
- }
204
-
205
- h1,
206
- h2,
207
- h3,
208
- h4,
209
- h5,
210
- h6 {
211
- font-size: inherit;
212
- font-weight: inherit;
213
- }
214
-
215
- h1,
216
- h2,
217
- h3,
218
- h4,
219
- h5,
220
- h6,
221
- p {
222
- margin: 0;
223
- }
224
-
225
- ul,
226
- ol {
227
- list-style: auto;
228
- padding-inline-start: 40px;
229
- margin-block-start: 1rem;
230
- margin-block-end: 1rem;
231
- }
232
- }
233
-
234
- /* Dark theme colors */
235
- /* @media (prefers-color-scheme: dark) {
236
- :root {
237
- --babylai-black-white-50: #000000;
238
- --babylai-black-white-100: #050505;
239
- --babylai-black-white-200: #0a0a0a;
240
- --babylai-black-white-300: #171717;
241
- --babylai-black-white-400: #1f1f1f;
242
- --babylai-black-white-500: #333333;
243
- --babylai-black-white-600: #606060;
244
- --babylai-black-white-700: #919191;
245
- --babylai-black-white-800: #e2e2e2;
246
- --babylai-black-white-900: #f3f3f3;
247
- --babylai-black-white-950: #ffffff;
248
- --babylai-black-white-default: #e2e2e2;
249
-
250
- --babylai-background: #121212;
251
- --babylai-card: #262626;
252
- --babylai-card-foreground: var(--babylai-black-white-950);
253
- --babylai-secondary: #3d3d3d;
254
- --babylai-secondary-foreground: var(--babylai-black-white-950);
255
- --babylai-muted: #2a2a2a;
256
- --babylai-muted-foreground: #b3b3b3;
257
- --babylai-destructive: #ff6b6b;
258
- --babylai-destructive-foreground: var(--babylai-black-white-950);
259
- --babylai-border: var(--babylai-black-white-200);
260
- --babylai-ring: var(--babylai-primary-color);
261
- }
262
- } */
263
-
264
- .bg-header {
265
- background: linear-gradient(171deg,
266
- color-mix(in srgb, var(--babylai-primary-color) 25%, transparent) -131.06%,
267
- color-mix(in srgb, var(--babylai-black-white-50) 25%, transparent) 89.82%);
268
- }
package/src/i18n.ts DELETED
@@ -1,21 +0,0 @@
1
- import i18next, { i18n as I18nType } from "i18next";
2
- import en from "./locales/en.json";
3
- import ar from "./locales/ar.json";
4
-
5
- export const defaultLanguage = "ar";
6
-
7
- export const createHelpCenterI18n = (
8
- lng: string = defaultLanguage
9
- ): I18nType => {
10
- const instance = i18next.createInstance();
11
- instance.init({
12
- resources: {
13
- en: { translation: en },
14
- ar: { translation: ar },
15
- },
16
- lng,
17
- fallbackLng: defaultLanguage,
18
- interpolation: { escapeValue: false },
19
- });
20
- return instance;
21
- };
package/src/index.ts DELETED
@@ -1,19 +0,0 @@
1
- import { configService } from './lib/config';
2
- import { TokenResponse } from './lib/types';
3
-
4
- // Main component export
5
- export { default as HelpCenter } from './ui/help-center';
6
-
7
- // Essential types and functions for HMR compatibility
8
- export type HelpCenterConfig = {
9
- baseUrl?: string;
10
- getToken?: () => Promise<TokenResponse>;
11
- };
12
-
13
- // Initialize function - defined here to avoid HMR issues with re-exports
14
- export function initializeHelpCenter(config: HelpCenterConfig) {
15
- configService.initialize(config);
16
- }
17
-
18
- // Note: Additional services and utilities are available from './services'
19
- // For services, import them directly: import { ApiService } from 'babylai-fe-react-sdk/services'
@@ -1,28 +0,0 @@
1
- import React, { createContext, ReactNode, useContext } from "react";
2
-
3
- interface LanguageContextType {
4
- language: string;
5
- }
6
-
7
- const LanguageContext = createContext<LanguageContextType | null>(null);
8
-
9
- interface LanguageProviderProps {
10
- children: ReactNode;
11
- language: string;
12
- }
13
-
14
- export const LanguageProvider: React.FC<LanguageProviderProps> = ({
15
- children,
16
- language,
17
- }) => {
18
- return (
19
- <LanguageContext.Provider value={{ language }}>
20
- {children}
21
- </LanguageContext.Provider>
22
- );
23
- };
24
-
25
- export const useLanguage = () => {
26
- const context = useContext(LanguageContext);
27
- return context;
28
- };
package/src/lib/config.ts DELETED
@@ -1,52 +0,0 @@
1
- import { initializeAPI, getValidToken } from '../core/api';
2
- import { TokenResponse } from './types';
3
-
4
- type Config = {
5
- baseUrl?: string;
6
- tenantId?: string;
7
- apiKey?: string;
8
- getToken?: () => Promise<TokenResponse>;
9
- };
10
-
11
- class ConfigService {
12
- private static instance: ConfigService;
13
- private config: Config | null = null;
14
-
15
- private constructor() {}
16
-
17
- static getInstance(): ConfigService {
18
- if (!ConfigService.instance) {
19
- ConfigService.instance = new ConfigService();
20
- }
21
- return ConfigService.instance;
22
- }
23
-
24
- initialize(config: Config) {
25
- this.config = {
26
- baseUrl: config.baseUrl || 'https://babylai.net/api',
27
- tenantId: config.tenantId,
28
- apiKey: config.apiKey,
29
- getToken: config.getToken,
30
- };
31
-
32
- // Initialize API with the getToken function directly
33
- if (!this.config.getToken) {
34
- throw new Error('getToken function is required in configuration');
35
- }
36
-
37
- initializeAPI(this.config.baseUrl || 'https://babylai.net/api', this.config.getToken);
38
- }
39
-
40
- getConfig(): Config {
41
- if (!this.config) {
42
- throw new Error('Help Center not initialized. Call initialize() first with configuration.');
43
- }
44
- return this.config;
45
- }
46
-
47
- async getToken(): Promise<string> {
48
- return await getValidToken();
49
- }
50
- }
51
-
52
- export const configService = ConfigService.getInstance();
@@ -1,102 +0,0 @@
1
- import { useCallback, useRef } from 'react';
2
-
3
- export type ActionHandler = (messageData: unknown) => void | Promise<void>;
4
-
5
- export interface ActionHandlerService {
6
- registerHandler(actionType: string, handler: ActionHandler): void;
7
- unregisterHandler(actionType: string): void;
8
- handleAction(actionType: string | undefined | null, messageData: unknown): Promise<void>;
9
- getRegisteredActions(): string[];
10
- }
11
-
12
- export const useActionHandler = (): ActionHandlerService => {
13
- const handlersRef = useRef<Map<string, ActionHandler>>(new Map());
14
-
15
- const defaultHandlerRef = useRef<ActionHandler>((messageData) => {
16
- const message = (messageData as { actionType?: string } | undefined) ?? {};
17
- const actionType = message.actionType || '';
18
-
19
- if (actionType) {
20
- // Log unknown actions for debugging but do not crash
21
- // eslint-disable-next-line no-console
22
- console.warn(
23
- `[ActionHandler] Unknown action type received: "${actionType}". Message data:`,
24
- messageData
25
- );
26
- }
27
- });
28
-
29
- const registerHandler = useCallback((actionType: string, handler: ActionHandler) => {
30
- if (!actionType) {
31
- // eslint-disable-next-line no-console
32
- console.warn('[ActionHandler] Attempted to register handler with empty action type. Ignored.');
33
- return;
34
- }
35
-
36
- if (handlersRef.current.has(actionType)) {
37
- // eslint-disable-next-line no-console
38
- console.warn(
39
- `[ActionHandler] Handler for action type "${actionType}" already exists. Overwriting with new handler.`
40
- );
41
- }
42
-
43
- handlersRef.current.set(actionType, handler);
44
- }, []);
45
-
46
- const unregisterHandler = useCallback((actionType: string) => {
47
- if (!actionType) {
48
- return;
49
- }
50
- handlersRef.current.delete(actionType);
51
- }, []);
52
-
53
- const handleAction = useCallback(
54
- async (actionType: string | undefined | null, messageData: unknown) => {
55
- // Ignore empty, null, or undefined action types (no-op)
56
- if (!actionType || actionType === '') {
57
- return;
58
- }
59
-
60
- const handler = handlersRef.current.get(actionType);
61
-
62
- if (handler) {
63
- try {
64
- await handler(messageData);
65
- } catch (error) {
66
- // eslint-disable-next-line no-console
67
- console.error(
68
- `[ActionHandler] Error executing handler for action type "${actionType}":`,
69
- error
70
- );
71
- }
72
- return;
73
- }
74
-
75
- const defaultHandler = defaultHandlerRef.current;
76
- if (defaultHandler) {
77
- try {
78
- await Promise.resolve(defaultHandler(messageData));
79
- } catch (error) {
80
- // eslint-disable-next-line no-console
81
- console.error(
82
- `[ActionHandler] Error executing default handler for unknown action type "${actionType}":`,
83
- error
84
- );
85
- }
86
- }
87
- },
88
- []
89
- );
90
-
91
- const getRegisteredActions = useCallback(() => {
92
- return Array.from(handlersRef.current.keys());
93
- }, []);
94
-
95
- return {
96
- registerHandler,
97
- unregisterHandler,
98
- handleAction,
99
- getRegisteredActions,
100
- };
101
- };
102
-
@@ -1,26 +0,0 @@
1
- import { useState, useEffect } from 'react'
2
-
3
- export function useTypewriter(text: string, speed: number = 20, onType?: () => void) {
4
- const [displayedText, setDisplayedText] = useState('')
5
-
6
- useEffect(() => {
7
- // Ensure text is always a string to prevent errors
8
- const safeText = text ?? ''
9
- let index = 0
10
- setDisplayedText('')
11
-
12
- const interval = setInterval(() => {
13
- setDisplayedText(() => {
14
- const next = safeText.slice(0, index + 1)
15
- index++
16
- if (onType) onType()
17
- if (index >= safeText.length) clearInterval(interval)
18
- return next
19
- })
20
- }, speed)
21
-
22
- return () => clearInterval(interval)
23
- }, [text, onType])
24
-
25
- return displayedText
26
- }
package/src/lib/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./LanguageContext";
2
- export * from "./utils";
3
- export * from "./theme-utils";
4
- export * from "./custom-hooks/useActionHandler";
@@ -1,56 +0,0 @@
1
- /**
2
- * Utility functions for dynamic theming
3
- */
4
-
5
- export interface ThemeColors {
6
- primaryColor?: string;
7
- }
8
-
9
- /**
10
- * Generate dynamic styles for primary color
11
- */
12
- export const getPrimaryColorStyles = (primaryColor?: string) => {
13
- if (!primaryColor) return {};
14
-
15
- return {
16
- '--babylai-primary-color': primaryColor,
17
- '--babylai-primary-color-100': lightenColor(primaryColor, 0.9),
18
- '--babylai-primary-color-200': lightenColor(primaryColor, 0.8),
19
- '--babylai-primary-color-300': lightenColor(primaryColor, 0.7),
20
- '--babylai-primary-color-400': lightenColor(primaryColor, 0.6),
21
- '--babylai-primary-color-500': primaryColor,
22
- '--babylai-primary-color-600': darkenColor(primaryColor, 0.1),
23
- '--babylai-primary-color-700': darkenColor(primaryColor, 0.2),
24
- '--babylai-primary-color-800': darkenColor(primaryColor, 0.3),
25
- '--babylai-primary-color-900': darkenColor(primaryColor, 0.4),
26
- '--babylai-primary-color-950': darkenColor(primaryColor, 0.5),
27
- } as React.CSSProperties;
28
- };
29
-
30
- /**
31
- * Lighten a color by a percentage
32
- */
33
- function lightenColor(color: string, amount: number): string {
34
- const num = parseInt(color.replace('#', ''), 16);
35
- const amt = Math.round(2.55 * amount * 100);
36
- const R = (num >> 16) + amt;
37
- const G = (num >> 8 & 0x00FF) + amt;
38
- const B = (num & 0x0000FF) + amt;
39
- return '#' + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
40
- (G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
41
- (B < 255 ? B < 1 ? 0 : B : 255)).toString(16).slice(1);
42
- }
43
-
44
- /**
45
- * Darken a color by a percentage
46
- */
47
- function darkenColor(color: string, amount: number): string {
48
- const num = parseInt(color.replace('#', ''), 16);
49
- const amt = Math.round(2.55 * amount * 100);
50
- const R = (num >> 16) - amt;
51
- const G = (num >> 8 & 0x00FF) - amt;
52
- const B = (num & 0x0000FF) - amt;
53
- return '#' + (0x1000000 + (R > 255 ? 255 : R < 0 ? 0 : R) * 0x10000 +
54
- (G > 255 ? 255 : G < 0 ? 0 : G) * 0x100 +
55
- (B > 255 ? 255 : B < 0 ? 0 : B)).toString(16).slice(1);
56
- }