@nlxai/touchpoint-ui 1.2.3-alpha.2 → 1.2.3

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.
@@ -3,14 +3,17 @@ import { ComponentType } from 'react';
3
3
  import { InteractiveElementInfo } from './bidirectional/analyzePageForms';
4
4
  /**
5
5
  * Window size configuration
6
+ * @inline @hidden
6
7
  */
7
8
  export type WindowSize = "half" | "full";
8
9
  /**
9
10
  * Color mode configuration (light/dark modes)
11
+ * @inline @hidden
10
12
  */
11
- export type ColorMode = "light" | "dark";
13
+ export type ColorMode = "light" | "dark" | "light dark";
12
14
  /**
13
15
  * Choice message with metadata
16
+ * @internal
14
17
  */
15
18
  export interface ChoiceMessage {
16
19
  /**
@@ -27,8 +30,12 @@ export interface ChoiceMessage {
27
30
  messageIndex: number;
28
31
  }
29
32
  /**
30
- * Custom Modalities allow rendering of rich components from nodes.
31
- * See: https://docs.studio.nlx.ai/build/resources/modalities
33
+ * Custom Modalities allow rendering of rich user interfaces directly inside a conversation.
34
+ * A custom modality component is a React component. It will receive the modality data as a
35
+ * `data` prop, along with the conversation handler instance to interact with the conversation as
36
+ * `conversationHandler` prop.
37
+ * @category Modality components
38
+ * @typeParam Data - The type of the modality being rendered by this component.
32
39
  */
33
40
  export type CustomModalityComponent<Data> = ComponentType<{
34
41
  /**
@@ -49,120 +56,22 @@ export type CustomModalityComponent<Data> = ComponentType<{
49
56
  * Class name to propagate to the container
50
57
  */
51
58
  className?: string;
52
- }>;
53
- /**
54
- * The full theme expressed as CSS custom properties
55
- */
56
- export interface Theme {
57
- /**
58
- * Font family
59
- */
60
- fontFamily: string;
61
- /**
62
- * Primary color with 80% opacity
63
- */
64
- primary80: string;
65
- /**
66
- * Primary color with 60% opacity
67
- */
68
- primary60: string;
69
- /**
70
- * Primary color with 40% opacity
71
- */
72
- primary40: string;
73
- /**
74
- * Primary color with 20% opacity
75
- */
76
- primary20: string;
77
59
  /**
78
- * Primary color with 10% opacity
60
+ * Tells the component whether it is rendered as an overlay over other elements. In this case, the class `backdrop-blur-overlay` is required
61
+ * on transparent elements in order to make sure its contents remain visible.
79
62
  */
80
- primary10: string;
81
- /**
82
- * Primary color with 5% opacity
83
- */
84
- primary5: string;
85
- /**
86
- * Primary color with 1% opacity
87
- */
88
- primary1: string;
89
- /**
90
- * Secondary color with 80% opacity
91
- */
92
- secondary80: string;
93
- /**
94
- * Secondary color with 60% opacity
95
- */
96
- secondary60: string;
97
- /**
98
- * Secondary color with 40% opacity
99
- */
100
- secondary40: string;
101
- /**
102
- * Secondary color with 20% opacity
103
- */
104
- secondary20: string;
105
- /**
106
- * Secondary color with 10% opacity
107
- */
108
- secondary10: string;
109
- /**
110
- * Secondary color with 5% opacity
111
- */
112
- secondary5: string;
113
- /**
114
- * Secondary color with 1% opacity
115
- */
116
- secondary1: string;
117
- /**
118
- * Accent color used e.g. for prominent buttons, the loader animation as well as selected card outlines
119
- */
120
- accent: string;
121
- /**
122
- * Accent color with 20% opacity
123
- */
124
- accent20: string;
125
- /**
126
- * The background color of the main Touchpoint interface
127
- */
128
- background: string;
129
- /**
130
- * The color of the overlay covering the visible portion of the website when the Touchpoint interface does not cover the full screen
131
- */
132
- overlay: string;
133
- /**
134
- * Primary warning color
135
- */
136
- warningPrimary: string;
137
- /**
138
- * Secondary warning color
139
- */
140
- warningSecondary: string;
141
- /**
142
- * Primary error color
143
- */
144
- errorPrimary: string;
145
- /**
146
- * Secondary error color
147
- */
148
- errorSecondary: string;
149
- /**
150
- * Inner border radius: used for most buttons
151
- */
152
- innerBorderRadius: string;
153
- /**
154
- * Outer border radius: generally used for elements that contain buttons that have inner border radius. Also used by the launch button.
155
- */
156
- outerBorderRadius: string;
157
- }
63
+ renderedAsOverlay?: boolean;
64
+ }>;
158
65
  /**
159
66
  * Custom conversation init method. Defaults to sending the welcome intent
160
67
  * @param handler - the conversation handler.
161
68
  * @param context - context set via TouchpointConfiguration.initialContext
69
+ * @inline @hidden
162
70
  */
163
71
  export type InitializeConversation = (handler: ConversationHandler, context?: Context) => void;
164
72
  /**
165
73
  * Fully custom launch icon
74
+ * @inline @hidden
166
75
  */
167
76
  export type CustomLaunchButton = ComponentType<{
168
77
  /**
@@ -176,10 +85,12 @@ export type CustomLaunchButton = ComponentType<{
176
85
  }>;
177
86
  /**
178
87
  * Input type for the experience
88
+ * @inline @hidden
179
89
  */
180
90
  export type Input = "text" | "voice" | "voiceMini";
181
91
  /**
182
92
  * Input field value
93
+ * @inline @hidden
183
94
  */
184
95
  export interface InputField {
185
96
  /**
@@ -193,6 +104,7 @@ export interface InputField {
193
104
  }
194
105
  /**
195
106
  * Internal state that the automatic context maintains.
107
+ * @category Bidirectional Voice+
196
108
  */
197
109
  export interface PageState {
198
110
  /** Mapping from form element IDs to their DOM elements */
@@ -204,6 +116,7 @@ export interface PageState {
204
116
  }
205
117
  /**
206
118
  * Bidirectional context information that is sent to the LLM.
119
+ * @category Bidirectional Voice+
207
120
  */
208
121
  export interface BidirectionalContext {
209
122
  /** Identifier for which page you are currently on. This can be used to filter the relevant KB pages. */
@@ -226,6 +139,7 @@ export interface BidirectionalContext {
226
139
  }
227
140
  /**
228
141
  * Configuration for bidirectional mode of voice+.
142
+ * @category Bidirectional Voice+
229
143
  */
230
144
  export type BidirectionalConfig = {
231
145
  /**
@@ -238,18 +152,18 @@ export type BidirectionalConfig = {
238
152
  /**
239
153
  * Navigation handler for bidirectional mode.
240
154
  *
241
- * If automatic context gathering is enabled, the default implementation will navigate to those pages using standard `window.location` APIs.
155
+ * The default implementation will navigate to those pages using standard `window.location` APIs.
242
156
  * @param action - The navigation action to perform.
243
157
  * @param destination - The name of the destination to navigate to if `action` is `"page_custom"`.
244
- * @param destinations - A map of destination names to URLs for custom navigation. Only present if `automaticContext` is enabled.
158
+ * @param destinations - A map of destination names to URLs for custom navigation.
245
159
  */
246
160
  navigation?: (action: "page_next" | "page_previous" | "page_custom" | "page_unknown", destination: string | undefined, destinations: Record<string, string>) => void;
247
161
  /**
248
162
  * A callback for filling out form fields in bidirectional mode.
249
163
  *
250
- * If automatic context gathering is enabled, the default implementation will fill out the form fields using standard DOM APIs.
164
+ * The default implementation will fill out the form fields using standard DOM APIs.
251
165
  * @param fields - An array of field objects with `id` and `value` properties.
252
- * @param pageFields - A map of field IDs to DOM elements for custom form filling. Only present if `automaticContext` is enabled.
166
+ * @param pageFields - A map of field IDs to DOM elements for custom form filling.
253
167
  */
254
168
  input?: (fields: InputField[], pageFields: Record<string, Element>) => void;
255
169
  /**
@@ -264,7 +178,6 @@ export type BidirectionalConfig = {
264
178
  * A callback for customizing the automatic context gathering.
265
179
  *
266
180
  * This allows you to modify the context and state before they are sent to the LLM.
267
- * @param arg - An object containing the current context and state.
268
181
  * @returns The modified context and state. If the state is identical to the previous state, the call to the server will be skipped.
269
182
  */
270
183
  customizeAutomaticContext?: (arg: {
@@ -282,24 +195,17 @@ export type BidirectionalConfig = {
282
195
  };
283
196
  } | {
284
197
  /**
285
- * Attempt to gather and send page context automatically. This will work well on semantically coded pages without too many custom form controls.
286
- * This enables a number of automatic features.
287
- *
288
- * Defaults to `true`.
198
+ * Disable gathering page context automatically.
289
199
  */
290
200
  automaticContext: false;
291
201
  /**
292
- * Navigation handler for bidirectional mode.
293
- *
294
- * If automatic context gathering is enabled, the default implementation will navigate to those pages using standard `window.location` APIs.
202
+ * Navigation handler for bidirectional mode. Without automatic context there is no default implementation.
295
203
  * @param action - The navigation action to perform.
296
204
  * @param destination - The name of the destination to navigate to if `action` is `"page_custom"`.
297
205
  */
298
206
  navigation?: (action: "page_next" | "page_previous" | "page_custom" | "page_unknown", destination?: string) => void;
299
207
  /**
300
- * A callback for filling out form fields in bidirectional mode.
301
- *
302
- * If automatic context gathering is enabled, the default implementation will fill out the form fields using standard DOM APIs.
208
+ * A callback for filling out form fields in bidirectional mode. Without automatic context there is no default implementation.
303
209
  * @param fields - An array of field objects with `id` and `value` properties.
304
210
  */
305
211
  input?: (fields: InputField[]) => void;
@@ -307,12 +213,12 @@ export type BidirectionalConfig = {
307
213
  * A callback for custom actions in bidirectional mode.
308
214
  * @param action - The custom name of your action.
309
215
  * @param payload - The payload defined for the custom action.
310
- * @returns
311
216
  */
312
217
  custom?: (action: string, payload: unknown) => void;
313
218
  };
314
219
  /**
315
220
  * Main Touchpoint creation properties object
221
+ * @category Basics
316
222
  */
317
223
  export interface TouchpointConfiguration {
318
224
  /**
@@ -324,7 +230,7 @@ export interface TouchpointConfiguration {
324
230
  */
325
231
  windowSize?: WindowSize;
326
232
  /**
327
- * Optional color mode for the chat window, defaults to `dark`
233
+ * Optional color mode for the chat window, defaults to `dark`. Setting `light dark` enables automatic switching based on system settings.
328
234
  */
329
235
  colorMode?: ColorMode;
330
236
  /**
@@ -358,16 +264,17 @@ export interface TouchpointConfiguration {
358
264
  */
359
265
  theme?: Partial<Theme>;
360
266
  /**
361
- * Optional custom modality components to render in Touchpoint
267
+ * Optional {@link CustomModalityComponent | custom modality components} to render in Touchpoint
362
268
  */
363
269
  modalityComponents?: Record<string, CustomModalityComponent<unknown>>;
364
270
  /**
365
271
  * Optional custom modality components to render in Touchpoint
366
272
  * @deprecated use {@link TouchpointConfiguration.modalityComponents} instead.
273
+ * @hidden
367
274
  */
368
275
  customModalities?: Record<string, CustomModalityComponent<unknown>>;
369
276
  /**
370
- * Custom conversation init method. Defaults to sending the welcome intent
277
+ * Custom conversation init method. Defaults to sending the welcome flow.
371
278
  * @param handler - the conversation handler.
372
279
  * @param context - the context object
373
280
  */
@@ -386,10 +293,128 @@ export interface TouchpointConfiguration {
386
293
  */
387
294
  bidirectional?: BidirectionalConfig;
388
295
  }
296
+ /**
297
+ * The full theme expressed as CSS custom properties.
298
+ * This means that for instance colors can be made to switch automatically based on the system color mode by using the `light-dark()` CSS function.
299
+ * Note also that not all colors need to be provided manually. For instance if only `primary80` is provided, the rest of the primary colors will be computed automatically based on it.
300
+ * Therefore, for a fully custom but minimal theme, you only need to provide `accent`, `primary80`, `secondary80`, `background`, `overlay`, and potentially the warning and error colors.
301
+ * @example
302
+ * ```typescript
303
+ * const theme : Partial<Theme> = {
304
+ * primary80: "light-dark(rgba(0, 2, 9, 0.8), rgba(255, 255, 255, 0.8))",
305
+ * secondary80: "light-dark(rgba(255, 255, 255, 0.8), rgba(0, 2, 9, 0.8))",
306
+ * accent: "light-dark(rgb(28, 99, 218), rgb(174, 202, 255))",
307
+ * background: "light-dark(rgba(220, 220, 220, 0.9), rgba(0, 2, 9, 0.9))",
308
+ * }
309
+ * ```
310
+ * @category Theming
311
+ */
312
+ export interface Theme {
313
+ /**
314
+ * Font family
315
+ */
316
+ fontFamily: string;
317
+ /**
318
+ * Primary color with 80% opacity
319
+ */
320
+ primary80: string;
321
+ /**
322
+ * Primary color with 60% opacity
323
+ */
324
+ primary60: string;
325
+ /**
326
+ * Primary color with 40% opacity
327
+ */
328
+ primary40: string;
329
+ /**
330
+ * Primary color with 20% opacity
331
+ */
332
+ primary20: string;
333
+ /**
334
+ * Primary color with 10% opacity
335
+ */
336
+ primary10: string;
337
+ /**
338
+ * Primary color with 5% opacity
339
+ */
340
+ primary5: string;
341
+ /**
342
+ * Primary color with 1% opacity
343
+ */
344
+ primary1: string;
345
+ /**
346
+ * Secondary color with 80% opacity
347
+ */
348
+ secondary80: string;
349
+ /**
350
+ * Secondary color with 60% opacity
351
+ */
352
+ secondary60: string;
353
+ /**
354
+ * Secondary color with 40% opacity
355
+ */
356
+ secondary40: string;
357
+ /**
358
+ * Secondary color with 20% opacity
359
+ */
360
+ secondary20: string;
361
+ /**
362
+ * Secondary color with 10% opacity
363
+ */
364
+ secondary10: string;
365
+ /**
366
+ * Secondary color with 5% opacity
367
+ */
368
+ secondary5: string;
369
+ /**
370
+ * Secondary color with 1% opacity
371
+ */
372
+ secondary1: string;
373
+ /**
374
+ * Accent color used e.g. for prominent buttons, the loader animation as well as selected card outlines
375
+ */
376
+ accent: string;
377
+ /**
378
+ * Accent color with 20% opacity
379
+ */
380
+ accent20: string;
381
+ /**
382
+ * The background color of the main Touchpoint interface
383
+ */
384
+ background: string;
385
+ /**
386
+ * The color of the overlay covering the visible portion of the website when the Touchpoint interface does not cover the full screen
387
+ */
388
+ overlay: string;
389
+ /**
390
+ * Primary warning color
391
+ */
392
+ warningPrimary: string;
393
+ /**
394
+ * Secondary warning color
395
+ */
396
+ warningSecondary: string;
397
+ /**
398
+ * Primary error color
399
+ */
400
+ errorPrimary: string;
401
+ /**
402
+ * Secondary error color
403
+ */
404
+ errorSecondary: string;
405
+ /**
406
+ * Inner border radius: used for most buttons
407
+ */
408
+ innerBorderRadius: string;
409
+ /**
410
+ * Outer border radius: generally used for elements that contain buttons that have inner border radius. Also used by the launch button.
411
+ */
412
+ outerBorderRadius: string;
413
+ }
389
414
  /**
390
415
  * During a Voice+ bidirectional conversation, you can indicate to the application the availability of
391
416
  * custom commands that the user can invoke.
392
- * @typeParam T - Commands can take a single parameter which will be generated from this schema.
417
+ * @category Bidirectional Voice+
393
418
  */
394
419
  export interface BidirectionalCustomCommand {
395
420
  /**
@@ -420,6 +445,7 @@ export interface BidirectionalCustomCommand {
420
445
  }
421
446
  /**
422
447
  * Instance of a Touchpoint UI component
448
+ * @category Basics
423
449
  */
424
450
  export interface TouchpointInstance {
425
451
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlxai/touchpoint-ui",
3
- "version": "1.2.3-alpha.2",
3
+ "version": "1.2.3",
4
4
  "description": "Web UI for Touchpoint",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -21,10 +21,13 @@
21
21
  "preview-docs": "npm run docs && comrak --unsafe --gfm -o docs/index.html docs/index.md && open docs/index.html",
22
22
  "publish-docs": "npm run docs && mv docs/index.md ../website/src/content/touchpoint-ui-api-reference.md",
23
23
  "test": "typedoc --emit none",
24
- "tsc": "tsc"
24
+ "tsc": "tsc",
25
+ "update-readme:docs": "rm -rf docs/ && typedoc",
26
+ "update-readme:merge": "../../scripts/transclude-markdown.js",
27
+ "update-readme": "npm run update-readme:docs && npm run update-readme:merge"
25
28
  },
26
29
  "dependencies": {
27
- "@nlxai/core": "^1.2.3-alpha.2",
30
+ "@nlxai/core": "^1.2.3",
28
31
  "@react-hookz/web": "^25.0.1",
29
32
  "@react-input/mask": "^2.0.4",
30
33
  "@rive-app/webgl2": "^2.31.5",
@@ -33,7 +36,7 @@
33
36
  "htm": "^3.1.1",
34
37
  "livekit-client": "^2.15.14",
35
38
  "marked": "^15.0.4",
36
- "ramda": "^0.30.1",
39
+ "ramda": "^0.32.0",
37
40
  "react": "^18.3.1",
38
41
  "react-dom": "^18.3.1",
39
42
  "react-error-boundary": "^6.0.0",
@@ -44,7 +47,7 @@
44
47
  "@rollup/plugin-replace": "^6.0.2",
45
48
  "@tailwindcss/vite": "^4.1.16",
46
49
  "@types/node": "^20.12.8",
47
- "@types/ramda": "^0.30.2",
50
+ "@types/ramda": "^0.31.1",
48
51
  "@types/react": "^18.3.1",
49
52
  "@types/react-dom": "^18.3.0",
50
53
  "@typescript-eslint/eslint-plugin": "^7.8.0",
@@ -53,6 +56,8 @@
53
56
  "dom-accessibility-api": "^0.7.0",
54
57
  "eslint-config-nlx": "*",
55
58
  "tailwindcss": "^4.1.16",
59
+ "typedoc": "^0.28.14",
60
+ "typedoc-plugin-markdown": "^4.9.0",
56
61
  "typescript": "^5.4.5",
57
62
  "vite": "^6.0",
58
63
  "vite-plugin-dts": "^4.5.0",
@@ -61,5 +66,5 @@
61
66
  "publishConfig": {
62
67
  "access": "public"
63
68
  },
64
- "gitHead": "7b3f2bffccf925bf674d8fef42af177dc17c367c"
69
+ "gitHead": "3902161e95745dd4a9cfb68bb469755a62b421f5"
65
70
  }
package/typedoc.cjs CHANGED
@@ -1,14 +1,27 @@
1
1
  /** @type { import('typedoc').TypeDocOptions & { hideInPageTOC?: boolean, hideBreadcrumbs?: boolean} } */
2
2
  module.exports = {
3
- excludeExternals: true,
4
3
  entryPoints: ["./src/index.tsx"],
4
+ hidePageHeader: true,
5
+ hidePageTitle: true,
5
6
  hideBreadcrumbs: true,
6
- hideInPageTOC: true,
7
+ formatWithPrettier: true,
8
+ readme: "none",
7
9
  out: "docs",
10
+ useCodeBlocks: true,
8
11
  plugin: ["typedoc-plugin-markdown"],
9
- readme: "none",
12
+ router: "module",
13
+ excludeInternal: true,
14
+ disableSources: true,
15
+ groupOrder: ["Functions", "Variables", "Interfaces", "*"],
10
16
  sort: ["source-order", "kind", "instance-first", "alphabetical"],
11
- treatValidationWarningsAsErrors: true,
12
- treatWarningsAsErrors: true,
17
+ categoryOrder: [
18
+ "Basics",
19
+ "Theming",
20
+ "Modality components",
21
+ "Bidirectional Voice+",
22
+ "*",
23
+ ],
24
+ treatValidationWarningsAsErrors: false,
25
+ treatWarningsAsErrors: false,
13
26
  validation: { notExported: true, invalidLink: true, notDocumented: true },
14
- };
27
+ };