@chaaskit/client 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/lib/index.js +53 -80
  2. package/dist/lib/index.js.map +1 -1
  3. package/dist/lib/routes/AcceptInviteRoute.js +1 -1
  4. package/dist/lib/routes/AcceptInviteRoute.js.map +1 -1
  5. package/dist/lib/routes/AdminDashboardRoute.js +1 -1
  6. package/dist/lib/routes/AdminDashboardRoute.js.map +1 -1
  7. package/dist/lib/routes/AdminTeamRoute.js +1 -1
  8. package/dist/lib/routes/AdminTeamRoute.js.map +1 -1
  9. package/dist/lib/routes/AdminTeamsRoute.js +1 -1
  10. package/dist/lib/routes/AdminTeamsRoute.js.map +1 -1
  11. package/dist/lib/routes/AdminUsersRoute.js +1 -1
  12. package/dist/lib/routes/AdminUsersRoute.js.map +1 -1
  13. package/dist/lib/routes/ApiKeysRoute.js +1 -1
  14. package/dist/lib/routes/ApiKeysRoute.js.map +1 -1
  15. package/dist/lib/routes/AutomationsRoute.js +1 -1
  16. package/dist/lib/routes/AutomationsRoute.js.map +1 -1
  17. package/dist/lib/routes/ChatRoute.js +1 -1
  18. package/dist/lib/routes/ChatRoute.js.map +1 -1
  19. package/dist/lib/routes/DocumentsRoute.js +1 -1
  20. package/dist/lib/routes/DocumentsRoute.js.map +1 -1
  21. package/dist/lib/routes/OAuthConsentRoute.js +1 -1
  22. package/dist/lib/routes/OAuthConsentRoute.js.map +1 -1
  23. package/dist/lib/routes/PricingRoute.js +1 -1
  24. package/dist/lib/routes/PricingRoute.js.map +1 -1
  25. package/dist/lib/routes/PrivacyRoute.js +1 -1
  26. package/dist/lib/routes/PrivacyRoute.js.map +1 -1
  27. package/dist/lib/routes/TeamSettingsRoute.js +1 -1
  28. package/dist/lib/routes/TeamSettingsRoute.js.map +1 -1
  29. package/dist/lib/routes/TermsRoute.js +1 -1
  30. package/dist/lib/routes/TermsRoute.js.map +1 -1
  31. package/dist/lib/routes/VerifyEmailRoute.js +1 -1
  32. package/dist/lib/routes/VerifyEmailRoute.js.map +1 -1
  33. package/dist/lib/ssr-utils.js +44 -1
  34. package/dist/lib/ssr-utils.js.map +1 -1
  35. package/dist/lib/ssr.js +23 -0
  36. package/dist/lib/ssr.js.map +1 -1
  37. package/dist/lib/styles.css +21 -62
  38. package/package.json +7 -2
  39. package/src/contexts/ConfigContext.tsx +42 -4
  40. package/src/contexts/ThemeContext.tsx +39 -68
  41. package/src/index.tsx +8 -2
  42. package/src/routes/AcceptInviteRoute.tsx +1 -1
  43. package/src/routes/AdminDashboardRoute.tsx +1 -1
  44. package/src/routes/AdminTeamRoute.tsx +1 -1
  45. package/src/routes/AdminTeamsRoute.tsx +1 -1
  46. package/src/routes/AdminUsersRoute.tsx +1 -1
  47. package/src/routes/ApiKeysRoute.tsx +1 -1
  48. package/src/routes/AutomationsRoute.tsx +1 -1
  49. package/src/routes/ChatRoute.tsx +2 -1
  50. package/src/routes/DocumentsRoute.tsx +1 -1
  51. package/src/routes/OAuthConsentRoute.tsx +1 -1
  52. package/src/routes/PricingRoute.tsx +1 -1
  53. package/src/routes/PrivacyRoute.tsx +1 -1
  54. package/src/routes/TeamSettingsRoute.tsx +1 -1
  55. package/src/routes/TermsRoute.tsx +1 -1
  56. package/src/routes/VerifyEmailRoute.tsx +1 -1
  57. package/src/ssr-utils.tsx +80 -1
  58. package/src/ssr.ts +59 -0
  59. package/src/styles/index.css +16 -63
  60. package/src/tailwind-preset.js +360 -0
@@ -0,0 +1,360 @@
1
+ import plugin from 'tailwindcss/plugin.js';
2
+
3
+ /**
4
+ * Converts a hex color to RGB values string (e.g., "#ff0000" -> "255 0 0")
5
+ */
6
+ function hexToRgb(hex) {
7
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
8
+ if (!result) return '0 0 0';
9
+ return `${parseInt(result[1], 16)} ${parseInt(result[2], 16)} ${parseInt(result[3], 16)}`;
10
+ }
11
+
12
+ /**
13
+ * Default ChaasKit themes.
14
+ * Apps can override these by passing their own themes to createChaaskitPreset().
15
+ */
16
+ const defaultThemes = {
17
+ light: {
18
+ primary: '#6366f1',
19
+ primaryHover: '#4f46e5',
20
+ secondary: '#8b5cf6',
21
+ background: '#ffffff',
22
+ backgroundSecondary: '#f9fafb',
23
+ sidebar: '#f3f4f6',
24
+ textPrimary: '#111827',
25
+ textSecondary: '#6b7280',
26
+ textMuted: '#9ca3af',
27
+ border: '#e5e7eb',
28
+ inputBackground: '#ffffff',
29
+ inputBorder: '#d1d5db',
30
+ userMessageBg: '#6366f1',
31
+ userMessageText: '#ffffff',
32
+ assistantMessageBg: '#f3f4f6',
33
+ assistantMessageText: '#111827',
34
+ success: '#10b981',
35
+ warning: '#f59e0b',
36
+ error: '#ef4444',
37
+ },
38
+ dark: {
39
+ primary: '#818cf8',
40
+ primaryHover: '#a5b4fc',
41
+ secondary: '#a78bfa',
42
+ background: '#111827',
43
+ backgroundSecondary: '#1f2937',
44
+ sidebar: '#0f172a',
45
+ textPrimary: '#f9fafb',
46
+ textSecondary: '#d1d5db',
47
+ textMuted: '#6b7280',
48
+ border: '#374151',
49
+ inputBackground: '#1f2937',
50
+ inputBorder: '#4b5563',
51
+ userMessageBg: '#4f46e5',
52
+ userMessageText: '#ffffff',
53
+ assistantMessageBg: '#1f2937',
54
+ assistantMessageText: '#f9fafb',
55
+ success: '#34d399',
56
+ warning: '#fbbf24',
57
+ error: '#f87171',
58
+ },
59
+ };
60
+
61
+ /**
62
+ * Default fonts and border radius.
63
+ */
64
+ const defaultStyles = {
65
+ fonts: {
66
+ sans: "'Inter', system-ui, sans-serif",
67
+ mono: "'JetBrains Mono', Menlo, monospace",
68
+ },
69
+ borderRadius: {
70
+ sm: '0.25rem',
71
+ md: '0.5rem',
72
+ lg: '0.75rem',
73
+ full: '9999px',
74
+ },
75
+ };
76
+
77
+ /**
78
+ * Creates a ChaasKit Tailwind preset with custom themes.
79
+ *
80
+ * @param {Object} options
81
+ * @param {Object} options.themes - Theme definitions (light, dark, etc.)
82
+ * @param {string} options.defaultTheme - Which theme to use for :root (default: 'light')
83
+ * @param {Object} options.fonts - Font family overrides
84
+ * @param {Object} options.borderRadius - Border radius overrides
85
+ *
86
+ * @example
87
+ * // tailwind.config.ts
88
+ * import { createChaaskitPreset } from '@chaaskit/client/tailwind-preset';
89
+ *
90
+ * export default {
91
+ * presets: [
92
+ * createChaaskitPreset({
93
+ * themes: {
94
+ * light: { primary: '#dc2626', ... },
95
+ * dark: { primary: '#ef4444', ... },
96
+ * },
97
+ * defaultTheme: 'dark',
98
+ * }),
99
+ * ],
100
+ * };
101
+ */
102
+ export function createChaaskitPreset(options = {}) {
103
+ const themes = options.themes || defaultThemes;
104
+ const defaultTheme = options.defaultTheme || 'light';
105
+ const fonts = { ...defaultStyles.fonts, ...options.fonts };
106
+ const borderRadius = { ...defaultStyles.borderRadius, ...options.borderRadius };
107
+
108
+ /**
109
+ * Generate CSS-in-JS for all themes
110
+ */
111
+ function generateThemeStyles() {
112
+ const styles = {};
113
+
114
+ for (const [themeName, colors] of Object.entries(themes)) {
115
+ const cssVars = {};
116
+
117
+ // Add color variables
118
+ for (const [key, value] of Object.entries(colors)) {
119
+ const cssKey = `--color-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
120
+ cssVars[cssKey] = hexToRgb(value);
121
+ }
122
+
123
+ // Add font and radius variables
124
+ cssVars['--font-sans'] = fonts.sans;
125
+ cssVars['--font-mono'] = fonts.mono;
126
+ cssVars['--radius-sm'] = borderRadius.sm;
127
+ cssVars['--radius-md'] = borderRadius.md;
128
+ cssVars['--radius-lg'] = borderRadius.lg;
129
+ cssVars['--radius-full'] = borderRadius.full;
130
+
131
+ // Use :root for default theme, data-theme selector for all
132
+ if (themeName === defaultTheme) {
133
+ styles[':root'] = cssVars;
134
+ }
135
+ styles[`html[data-theme="${themeName}"]`] = cssVars;
136
+ }
137
+
138
+ return styles;
139
+ }
140
+
141
+ return {
142
+ content: [
143
+ './node_modules/@chaaskit/client/src/**/*.{js,ts,jsx,tsx}',
144
+ './node_modules/@chaaskit/client/dist/**/*.js',
145
+ ],
146
+ theme: {
147
+ extend: {
148
+ colors: {
149
+ primary: 'rgb(var(--color-primary) / <alpha-value>)',
150
+ 'primary-hover': 'rgb(var(--color-primary-hover) / <alpha-value>)',
151
+ secondary: 'rgb(var(--color-secondary) / <alpha-value>)',
152
+ background: 'rgb(var(--color-background) / <alpha-value>)',
153
+ 'background-secondary': 'rgb(var(--color-background-secondary) / <alpha-value>)',
154
+ sidebar: 'rgb(var(--color-sidebar) / <alpha-value>)',
155
+ 'text-primary': 'rgb(var(--color-text-primary) / <alpha-value>)',
156
+ 'text-secondary': 'rgb(var(--color-text-secondary) / <alpha-value>)',
157
+ 'text-muted': 'rgb(var(--color-text-muted) / <alpha-value>)',
158
+ border: 'rgb(var(--color-border) / <alpha-value>)',
159
+ 'input-background': 'rgb(var(--color-input-background) / <alpha-value>)',
160
+ 'input-border': 'rgb(var(--color-input-border) / <alpha-value>)',
161
+ 'user-message-bg': 'rgb(var(--color-user-message-bg) / <alpha-value>)',
162
+ 'user-message-text': 'rgb(var(--color-user-message-text) / <alpha-value>)',
163
+ 'assistant-message-bg': 'rgb(var(--color-assistant-message-bg) / <alpha-value>)',
164
+ 'assistant-message-text': 'rgb(var(--color-assistant-message-text) / <alpha-value>)',
165
+ success: 'rgb(var(--color-success) / <alpha-value>)',
166
+ warning: 'rgb(var(--color-warning) / <alpha-value>)',
167
+ error: 'rgb(var(--color-error) / <alpha-value>)',
168
+ },
169
+ fontFamily: {
170
+ sans: ['var(--font-sans)', 'system-ui', 'sans-serif'],
171
+ mono: ['var(--font-mono)', 'Menlo', 'monospace'],
172
+ },
173
+ borderRadius: {
174
+ sm: 'var(--radius-sm)',
175
+ md: 'var(--radius-md)',
176
+ lg: 'var(--radius-lg)',
177
+ full: 'var(--radius-full)',
178
+ },
179
+ },
180
+ },
181
+ plugins: [
182
+ // Inject theme CSS variables
183
+ plugin(function ({ addBase }) {
184
+ addBase(generateThemeStyles());
185
+ }),
186
+ // Custom variant for touch devices
187
+ plugin(function ({ addVariant }) {
188
+ addVariant('touch-device', '@media (pointer: coarse)');
189
+ }),
190
+ // Base styles and utilities
191
+ plugin(function ({ addBase, addUtilities }) {
192
+ // Base element styles
193
+ addBase({
194
+ 'html': {
195
+ fontFamily: 'var(--font-sans)',
196
+ },
197
+ 'pre': {
198
+ fontFamily: 'var(--font-mono)',
199
+ fontSize: '0.875rem',
200
+ },
201
+ 'code': {
202
+ fontFamily: 'var(--font-mono)',
203
+ },
204
+ 'kbd': {
205
+ fontFamily: 'var(--font-sans)',
206
+ },
207
+ // Scrollbar styling
208
+ '::-webkit-scrollbar': {
209
+ width: '8px',
210
+ height: '8px',
211
+ },
212
+ '::-webkit-scrollbar-track': {
213
+ backgroundColor: 'transparent',
214
+ },
215
+ '::-webkit-scrollbar-thumb': {
216
+ backgroundColor: 'rgb(var(--color-border))',
217
+ borderRadius: '9999px',
218
+ },
219
+ '::-webkit-scrollbar-thumb:hover': {
220
+ backgroundColor: 'rgb(var(--color-text-muted))',
221
+ },
222
+ // Markdown content styling
223
+ '.markdown-content': {
224
+ lineHeight: '1.625',
225
+ },
226
+ '.markdown-content h1': {
227
+ fontSize: '1.5rem',
228
+ fontWeight: '700',
229
+ marginTop: '1.5rem',
230
+ marginBottom: '1rem',
231
+ },
232
+ '.markdown-content h2': {
233
+ fontSize: '1.25rem',
234
+ fontWeight: '700',
235
+ marginTop: '1.25rem',
236
+ marginBottom: '0.75rem',
237
+ },
238
+ '.markdown-content h3': {
239
+ fontSize: '1.125rem',
240
+ fontWeight: '600',
241
+ marginTop: '1rem',
242
+ marginBottom: '0.5rem',
243
+ },
244
+ '.markdown-content p': {
245
+ marginBottom: '1rem',
246
+ },
247
+ '.markdown-content ul, .markdown-content ol': {
248
+ marginBottom: '1rem',
249
+ paddingLeft: '1.5rem',
250
+ },
251
+ '.markdown-content ul': {
252
+ listStyleType: 'disc',
253
+ },
254
+ '.markdown-content ol': {
255
+ listStyleType: 'decimal',
256
+ },
257
+ '.markdown-content li': {
258
+ marginBottom: '0.25rem',
259
+ },
260
+ '.markdown-content blockquote': {
261
+ borderLeftWidth: '4px',
262
+ borderLeftColor: 'rgb(var(--color-border))',
263
+ paddingLeft: '1rem',
264
+ fontStyle: 'italic',
265
+ marginTop: '1rem',
266
+ marginBottom: '1rem',
267
+ },
268
+ '.markdown-content a': {
269
+ color: 'rgb(var(--color-primary))',
270
+ },
271
+ '.markdown-content a:hover': {
272
+ textDecoration: 'underline',
273
+ },
274
+ '.markdown-content table': {
275
+ width: '100%',
276
+ borderCollapse: 'collapse',
277
+ marginTop: '1rem',
278
+ marginBottom: '1rem',
279
+ },
280
+ '.markdown-content th, .markdown-content td': {
281
+ borderWidth: '1px',
282
+ borderColor: 'rgb(var(--color-border))',
283
+ paddingLeft: '1rem',
284
+ paddingRight: '1rem',
285
+ paddingTop: '0.5rem',
286
+ paddingBottom: '0.5rem',
287
+ textAlign: 'left',
288
+ },
289
+ '.markdown-content th': {
290
+ backgroundColor: 'rgb(var(--color-background-secondary))',
291
+ fontWeight: '600',
292
+ },
293
+ '.markdown-content hr': {
294
+ marginTop: '1.5rem',
295
+ marginBottom: '1.5rem',
296
+ borderColor: 'rgb(var(--color-border))',
297
+ },
298
+ // Search highlight
299
+ 'mark': {
300
+ backgroundColor: 'rgb(var(--color-warning) / 0.3)',
301
+ color: 'rgb(var(--color-text-primary))',
302
+ borderRadius: '0.125rem',
303
+ paddingLeft: '0.125rem',
304
+ paddingRight: '0.125rem',
305
+ },
306
+ // Animations
307
+ '@keyframes fade-in': {
308
+ from: { opacity: '0' },
309
+ to: { opacity: '1' },
310
+ },
311
+ '@keyframes slide-up': {
312
+ from: { transform: 'translateY(10px)', opacity: '0' },
313
+ to: { transform: 'translateY(0)', opacity: '1' },
314
+ },
315
+ '@keyframes typing': {
316
+ '0%, 60%, 100%': { opacity: '1' },
317
+ '30%': { opacity: '0.3' },
318
+ },
319
+ '.animate-fade-in': {
320
+ animation: 'fade-in 0.2s ease-out',
321
+ },
322
+ '.animate-slide-up': {
323
+ animation: 'slide-up 0.2s ease-out',
324
+ },
325
+ '.typing-indicator span': {
326
+ animation: 'typing 1s infinite',
327
+ },
328
+ '.typing-indicator span:nth-child(2)': {
329
+ animationDelay: '0.2s',
330
+ },
331
+ '.typing-indicator span:nth-child(3)': {
332
+ animationDelay: '0.4s',
333
+ },
334
+ });
335
+
336
+ // Custom utilities
337
+ addUtilities({
338
+ // Mobile viewport height fix - dvh with fallback
339
+ '.h-screen-safe': {
340
+ height: '100vh',
341
+ '@supports (height: 100dvh)': {
342
+ height: '100dvh',
343
+ },
344
+ },
345
+ // Line clamp
346
+ '.line-clamp-2': {
347
+ display: '-webkit-box',
348
+ '-webkit-line-clamp': '2',
349
+ '-webkit-box-orient': 'vertical',
350
+ overflow: 'hidden',
351
+ },
352
+ });
353
+ }),
354
+ ],
355
+ };
356
+ }
357
+
358
+ // Default export for simple usage
359
+ const chaaskitPreset = createChaaskitPreset();
360
+ export default chaaskitPreset;