@evelan/jexity-widget 0.2.0 → 0.3.0-canary.4

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 (90) hide show
  1. package/README.md +162 -16
  2. package/dist/index.mjs +1046 -731
  3. package/dist/index.mjs.map +1 -1
  4. package/dist/react.mjs +20 -11
  5. package/dist/react.mjs.map +1 -1
  6. package/dist/types/entries/esm.d.ts +4 -0
  7. package/dist/types/entries/esm.d.ts.map +1 -0
  8. package/dist/types/{react.d.ts → entries/react.d.ts} +1 -1
  9. package/dist/types/entries/react.d.ts.map +1 -0
  10. package/dist/types/features/chat/components/BotMessage.d.ts +6 -0
  11. package/dist/types/features/chat/components/BotMessage.d.ts.map +1 -0
  12. package/dist/types/features/chat/components/ChatInput.d.ts +3 -0
  13. package/dist/types/features/chat/components/ChatInput.d.ts.map +1 -0
  14. package/dist/types/features/chat/components/ChatScreen.d.ts +8 -0
  15. package/dist/types/features/chat/components/ChatScreen.d.ts.map +1 -0
  16. package/dist/types/features/chat/components/MessageList.d.ts +3 -0
  17. package/dist/types/features/chat/components/MessageList.d.ts.map +1 -0
  18. package/dist/types/features/chat/components/TypingIndicator.d.ts +2 -0
  19. package/dist/types/features/chat/components/TypingIndicator.d.ts.map +1 -0
  20. package/dist/types/features/chat/components/UserMessage.d.ts +6 -0
  21. package/dist/types/features/chat/components/UserMessage.d.ts.map +1 -0
  22. package/dist/types/features/chat/lib/chat.d.ts +13 -0
  23. package/dist/types/features/chat/lib/chat.d.ts.map +1 -0
  24. package/dist/types/features/home/components/HomeScreen.d.ts +14 -0
  25. package/dist/types/features/home/components/HomeScreen.d.ts.map +1 -0
  26. package/dist/types/features/selection/components/SelectionScreen.d.ts +7 -0
  27. package/dist/types/features/selection/components/SelectionScreen.d.ts.map +1 -0
  28. package/dist/types/features/ticket/components/ConfirmationScreen.d.ts +7 -0
  29. package/dist/types/features/ticket/components/ConfirmationScreen.d.ts.map +1 -0
  30. package/dist/types/features/ticket/components/FormScreen.d.ts +3 -0
  31. package/dist/types/features/ticket/components/FormScreen.d.ts.map +1 -0
  32. package/dist/types/i18n/config.d.ts +10 -0
  33. package/dist/types/i18n/config.d.ts.map +1 -0
  34. package/dist/types/i18n/index.d.ts +6 -1
  35. package/dist/types/i18n/index.d.ts.map +1 -1
  36. package/dist/types/i18n/locales/de.d.ts.map +1 -1
  37. package/dist/types/i18n/locales/en.d.ts +19 -0
  38. package/dist/types/i18n/locales/en.d.ts.map +1 -1
  39. package/dist/types/i18n/resolve-widget-locale.d.ts +10 -7
  40. package/dist/types/i18n/resolve-widget-locale.d.ts.map +1 -1
  41. package/dist/types/module/screens/ScreenRouter.d.ts +8 -0
  42. package/dist/types/module/screens/ScreenRouter.d.ts.map +1 -0
  43. package/dist/types/module/screens/screens.state.d.ts +26 -0
  44. package/dist/types/module/screens/screens.state.d.ts.map +1 -0
  45. package/dist/types/module/shell/AppShell.d.ts +8 -0
  46. package/dist/types/module/shell/AppShell.d.ts.map +1 -0
  47. package/dist/types/module/shell/mount.d.ts +13 -0
  48. package/dist/types/module/shell/mount.d.ts.map +1 -0
  49. package/dist/types/module/shell/shell.state.d.ts +2 -0
  50. package/dist/types/module/shell/shell.state.d.ts.map +1 -0
  51. package/dist/types/module/visitor/visitor.state.d.ts +21 -0
  52. package/dist/types/module/visitor/visitor.state.d.ts.map +1 -0
  53. package/dist/types/shared/icons/BotIcon.d.ts +4 -0
  54. package/dist/types/shared/icons/BotIcon.d.ts.map +1 -0
  55. package/dist/types/shared/icons/CloseIcon.d.ts +4 -0
  56. package/dist/types/shared/icons/CloseIcon.d.ts.map +1 -0
  57. package/dist/types/shared/icons/MessageIcon.d.ts +4 -0
  58. package/dist/types/shared/icons/MessageIcon.d.ts.map +1 -0
  59. package/dist/types/shared/icons/SendIcon.d.ts +4 -0
  60. package/dist/types/shared/icons/SendIcon.d.ts.map +1 -0
  61. package/dist/types/shared/icons/SparklesIcon.d.ts +5 -0
  62. package/dist/types/shared/icons/SparklesIcon.d.ts.map +1 -0
  63. package/dist/types/shared/icons/ZapIcon.d.ts +4 -0
  64. package/dist/types/shared/icons/ZapIcon.d.ts.map +1 -0
  65. package/dist/types/shared/theme/build-theme.d.ts +5 -0
  66. package/dist/types/shared/theme/build-theme.d.ts.map +1 -0
  67. package/dist/types/shared/theme/inject-styles.d.ts +10 -0
  68. package/dist/types/shared/theme/inject-styles.d.ts.map +1 -0
  69. package/dist/types/shared/ui/ErrorScreen.d.ts +9 -0
  70. package/dist/types/shared/ui/ErrorScreen.d.ts.map +1 -0
  71. package/dist/types/shared/ui/FAB.d.ts +9 -0
  72. package/dist/types/shared/ui/FAB.d.ts.map +1 -0
  73. package/dist/types/shared/ui/Footer.d.ts +3 -0
  74. package/dist/types/shared/ui/Footer.d.ts.map +1 -0
  75. package/dist/types/shared/ui/Header.d.ts +7 -0
  76. package/dist/types/shared/ui/Header.d.ts.map +1 -0
  77. package/dist/types/shared/ui/LoadingScreen.d.ts +7 -0
  78. package/dist/types/shared/ui/LoadingScreen.d.ts.map +1 -0
  79. package/dist/types/types.d.ts +11 -1
  80. package/dist/types/types.d.ts.map +1 -1
  81. package/dist/widget.js +1 -2
  82. package/dist/widget.js.map +1 -1
  83. package/package.json +6 -4
  84. package/dist/types/app.d.ts +0 -6
  85. package/dist/types/app.d.ts.map +0 -1
  86. package/dist/types/index.d.ts +0 -4
  87. package/dist/types/index.d.ts.map +0 -1
  88. package/dist/types/react.d.ts.map +0 -1
  89. package/dist/types/widget-state.d.ts +0 -7
  90. package/dist/types/widget-state.d.ts.map +0 -1
package/README.md CHANGED
@@ -8,8 +8,9 @@ Embeddable AI chat widget for any website. Add customer support chat with a sing
8
8
 
9
9
  ```html
10
10
  <script
11
- src="https://unpkg.com/@evelan/jexity-widget/dist/widget.js"
12
- data-org-id="YOUR_ORG_ID"
11
+ src="https://cdn.evelan.de/widget/latest/widget.js"
12
+ data-org-slug="YOUR_ORG_SLUG"
13
+ async
13
14
  ></script>
14
15
  ```
15
16
 
@@ -23,10 +24,11 @@ npm install @evelan/jexity-widget
23
24
  import { JexityChat } from '@evelan/jexity-widget'
24
25
 
25
26
  const chat = JexityChat({
26
- orgId: 'YOUR_ORG_ID',
27
+ orgSlug: 'YOUR_ORG_SLUG',
27
28
  })
28
29
 
29
- // Later: chat.shutdown()
30
+ // Later:
31
+ chat.shutdown()
30
32
  ```
31
33
 
32
34
  ### React Provider
@@ -36,7 +38,7 @@ import { JexityChatProvider, useJexityChat } from '@evelan/jexity-widget/react'
36
38
 
37
39
  function App() {
38
40
  return (
39
- <JexityChatProvider orgId="YOUR_ORG_ID">
41
+ <JexityChatProvider orgSlug="YOUR_ORG_SLUG">
40
42
  <HomePage />
41
43
  </JexityChatProvider>
42
44
  )
@@ -48,40 +50,184 @@ function HomePage() {
48
50
  }
49
51
  ```
50
52
 
53
+ ---
54
+
51
55
  ## Configuration
52
56
 
53
57
  | Option | Type | Default | Description |
54
58
  |--------|------|---------|-------------|
55
- | `orgId` | `string` | *required* | Your organization ID |
59
+ | `orgSlug` | `string` | **required** | Your organization slug (e.g. `acme-corp`) |
56
60
  | `container` | `string \| HTMLElement` | auto-created `div` | CSS selector or element to mount into |
57
61
  | `position` | `'bottom-right' \| 'bottom-left'` | `'bottom-right'` | Widget position on screen |
58
- | `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Color theme |
59
- | `greeting` | `string` | `'Hi there! How can I help?'` | Initial bot message |
62
+ | `colorScheme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Force color scheme; `'auto'` follows system preference |
60
63
  | `title` | `string` | `'Jexity Assistant'` | Chat window header title |
61
- | `primaryColor` | `string` | `'#0070f3'` | Brand color (hex) |
64
+ | `greeting` | `string` | `'Hi! How can I help?'` | Initial bot message shown on open |
65
+ | `primaryColor` | `string` | `'#0070f3'` | Shorthand brand color — tints FAB, header, user bubbles, send button |
66
+ | `accentColor` | `string` | — | Secondary accent color |
67
+ | `fontFamily` | `string` | — | Override widget font family |
68
+ | `fontSize` | `number` | — | Base font size in px |
69
+ | `borderRadius` | `string` | — | Override widget corner radius (e.g. `'8px'`) |
70
+ | `windowWidth` | `number` | — | Chat window width in px |
71
+ | `windowHeight` | `number` | — | Chat window height in px |
72
+ | `triggerIcon` | `'chat' \| 'bot' \| 'sparkles'` | `'chat'` | Floating action button icon |
73
+ | `triggerRadius` | `'none' \| 'sm' \| 'md' \| 'lg' \| 'full'` | `'full'` | FAB border radius shape |
74
+ | `triggerLabel` | `string` | — | Text label shown next to the FAB |
75
+ | `hideBranding` | `boolean` | `false` | Hide the "Powered by Jexity" footer |
76
+ | `locale` | `string` | browser / `'de'` | Force locale (`'de'` \| `'en'`). Overrides browser detection |
77
+ | `parentOrigin` | `string` | `window.location.origin` | Trusted origin for postMessage dashboard preview updates |
78
+ | `theme` | `JexityTheme` | — | Granular per-element color overrides (see below) |
79
+
80
+ ### Granular Theme Overrides
81
+
82
+ `theme` lets you override individual element colors. Unset keys fall back to `primaryColor` or brand defaults.
83
+
84
+ ```ts
85
+ JexityChat({
86
+ orgSlug: 'acme',
87
+ theme: {
88
+ bg: {
89
+ trigger: '#1a1a2e', // FAB background
90
+ header: '#16213e', // Chat header
91
+ msgUser: '#0f3460', // User bubble background
92
+ msgBot: '#f5f5f5', // Bot bubble background
93
+ window: '#ffffff', // Chat window background
94
+ sendBtn: '#e94560', // Send button background
95
+ },
96
+ text: {
97
+ header: '#ffffff', // Header text/icon color
98
+ msgUser: '#ffffff', // User bubble text
99
+ msgBot: '#333333', // Bot bubble text
100
+ main: '#212121', // Primary body text
101
+ muted: '#888888', // Secondary/muted text
102
+ },
103
+ border: {
104
+ window: '#e0e0e0', // Window border
105
+ input: '#cccccc', // Input field border
106
+ },
107
+ },
108
+ })
109
+ ```
110
+
111
+ ---
62
112
 
63
113
  ## Programmatic API
64
114
 
65
115
  ```ts
66
116
  const chat = JexityChat(options)
67
117
 
68
- chat.open() // Open the chat window
69
- chat.close() // Close the chat window
70
- chat.toggle() // Toggle open/closed
71
- chat.shutdown() // Remove widget from DOM
72
- chat.isOpen // readonly boolean
118
+ chat.open() // Open the chat window
119
+ chat.close() // Close the chat window
120
+ chat.toggle() // Toggle open/closed
121
+ chat.shutdown() // Remove widget from DOM
122
+ chat.isOpen // readonly boolean — current open state
123
+ chat.subscribe(cb) // Subscribe to open/close changes
124
+ // Returns unsubscribe function
125
+
126
+ // IIFE global (script tag):
127
+ window.JexityChat.open()
128
+ window.JexityChat.close()
129
+ window.JexityChat.toggle()
130
+ window.JexityChat.shutdown()
131
+ ```
132
+
133
+ ---
134
+
135
+ ## IIFE (Script Tag) Attributes
136
+
137
+ All options can be set as `data-*` attributes on the `<script>` tag:
138
+
139
+ ```html
140
+ <script
141
+ src="https://cdn.evelan.de/widget/latest/widget.js"
142
+ data-org-slug="acme-corp"
143
+ data-locale="de"
144
+ data-primary-color="#ff6600"
145
+ data-trigger-icon="sparkles"
146
+ data-trigger-radius="lg"
147
+ data-trigger-label="Chat with us"
148
+ data-hide-branding="true"
149
+ async
150
+ ></script>
73
151
  ```
74
152
 
75
- ## Script Tag Global
153
+ Then control programmatically after load:
76
154
 
77
155
  ```html
78
- <script src="https://cdn.evelan.de/widget/latest/widget.js" data-org-id="YOUR_ORG_ID"></script>
79
156
  <script>
80
157
  window.JexityChat.open()
81
158
  window.JexityChat.shutdown()
82
159
  </script>
83
160
  ```
84
161
 
162
+ ---
163
+
164
+ ## Build Outputs
165
+
166
+ ```
167
+ dist/
168
+ widget.js ← IIFE for <script> embed (CDN)
169
+ index.mjs ← ESM for bundlers (npm)
170
+ react.mjs ← React bindings (externalizes react + core)
171
+ types/index.d.ts ← TypeScript declarations (core)
172
+ types/react.d.ts ← TypeScript declarations (React)
173
+ ```
174
+
175
+ Target sizes: IIFE ≤ 32 KB · ESM ≤ 42 KB (gzipped)
176
+
177
+ ---
178
+
179
+ ## Development
180
+
181
+ ```bash
182
+ # From repo root:
183
+ pnpm dev --filter @evelan/jexity-widget
184
+
185
+ # Or directly:
186
+ cd apps/widget
187
+ pnpm dev
188
+ ```
189
+
190
+ Open **`http://localhost:3002`** — the dev playground with live config controls.
191
+
192
+ ### Environment variables
193
+
194
+ Create `apps/widget/.env.local`:
195
+
196
+ ```bash
197
+ # Convex HTTP site URL — used to fetch widget config on mount.
198
+ # Copy from packages/backend/.env.local (CONVEX_SITE_URL).
199
+ # Dev deployment: sensible-anaconda-990.eu-west-1.convex.site
200
+ # Prod deployment: festive-<...>.convex.site (set in GitHub Actions Variable)
201
+ VITE_CONVEX_SITE_URL=https://<your-dev-deployment>.convex.site
202
+
203
+ # Reserved — not consumed yet. Future escape hatch if we ever swap Convex for
204
+ # a traditional REST backend (Express, Fastify, etc.). Once wired, widget code
205
+ # will read this instead of VITE_CONVEX_SITE_URL so the backend is hot-swappable
206
+ # via env alone. Set in GitHub Actions Secret: VITE_API_BASE_URL.
207
+ # VITE_API_BASE_URL=https://api.example.com
208
+ ```
209
+
210
+ ### URL Parameters
211
+
212
+ | Parameter | Example | Purpose |
213
+ |-----------|---------|---------|
214
+ | `?orgSlug=` | `?orgSlug=demo` | Set org slug (default: `dev_local`) |
215
+ | `?primaryColor=` | `?primaryColor=%230070f3` | Set primary color |
216
+ | `?locale=` | `?locale=en` | Lock locale |
217
+ | `?position=` | `?position=bottom-left` | Widget position |
218
+ | `?title=` | `?title=My+Assistant` | Widget title |
219
+ | `?hideBranding=true` | — | Hide footer branding |
220
+ | `?skipHomeScreen=true` | — | Open directly to chat (skip landing) |
221
+
222
+ ### Build
223
+
224
+ ```bash
225
+ pnpm build # Full build (all 5 outputs)
226
+ pnpm check-types # Type-check only (fast)
227
+ ```
228
+
229
+ ---
230
+
85
231
  ## License
86
232
 
87
233
  MIT