@nlxai/touchpoint-ui 1.2.4-alpha.8 → 1.2.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.
package/README.md CHANGED
@@ -11,7 +11,9 @@ import { create } from "@nlxai/touchpoint-ui";
11
11
 
12
12
  const touchpoint = await create({
13
13
  config: {
14
- applicationUrl: "REPLACE_WITH_APPLICATION_URL",
14
+ host: "REPLACE_WITH_HOST",
15
+ deploymentKey: "REPLACE_WITH_DEPLOYMENT_KEY",
16
+ channelKey: "REPLACE_WITH_CHANNEL_KEY",
15
17
  headers: {
16
18
  "nlx-api-key": "REPLACE_WITH_API_KEY",
17
19
  },
@@ -192,6 +194,14 @@ optional input: "text" | "external" | "voice" | "voiceMini";
192
194
 
193
195
  Controls the ways in which the user can communicate with the application. Defaults to `"text"`
194
196
 
197
+ ##### showVoiceTranscript?
198
+
199
+ ```ts
200
+ optional showVoiceTranscript: boolean;
201
+ ```
202
+
203
+ Sets whether the transcript is shown in `voice` and `voiceMini` inputs.
204
+
195
205
  ##### initialContext?
196
206
 
197
207
  ```ts
@@ -208,6 +218,14 @@ optional bidirectional: BidirectionalConfig;
208
218
 
209
219
  Enables bidirectional mode of voice+. Will automatically set the bidirectional flag in the config.
210
220
 
221
+ ##### copy?
222
+
223
+ ```ts
224
+ optional copy: Partial<Copy>;
225
+ ```
226
+
227
+ Copy
228
+
211
229
  ---
212
230
 
213
231
  ### TouchpointInstance
@@ -319,15 +337,15 @@ A list containing the custom commands to set.
319
337
 
320
338
  The full theme expressed as CSS custom properties.
321
339
  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.
322
- 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.
323
- 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.
340
+ Note also that not all colors need to be provided manually. For instance if only `primary` is provided, the rest of the primary colors will be computed automatically based on it.
341
+ Therefore, for a fully custom but minimal theme, you only need to provide `accent`, `primary`, `secondary`, `background`, `overlay`, and potentially the warning and error colors.
324
342
 
325
343
  #### Example
326
344
 
327
345
  ```typescript
328
346
  const theme: Partial<Theme> = {
329
- primary80: "light-dark(rgba(0, 2, 9, 0.8), rgba(255, 255, 255, 0.8))",
330
- secondary80: "light-dark(rgba(255, 255, 255, 0.8), rgba(0, 2, 9, 0.8))",
347
+ primary: "light-dark(rgb(0, 2, 9), rgb(255, 255, 255))",
348
+ secondary: "light-dark(rgb(255, 255, 255), rgb(0, 2, 9))",
331
349
  accent: "light-dark(rgb(28, 99, 218), rgb(174, 202, 255))",
332
350
  background: "light-dark(rgba(220, 220, 220, 0.9), rgba(0, 2, 9, 0.9))",
333
351
  };
@@ -343,6 +361,22 @@ fontFamily: string;
343
361
 
344
362
  Font family
345
363
 
364
+ ##### primary
365
+
366
+ ```ts
367
+ primary: string;
368
+ ```
369
+
370
+ Primary color
371
+
372
+ ##### primary90
373
+
374
+ ```ts
375
+ primary90: string;
376
+ ```
377
+
378
+ Primary color with 90% opacity
379
+
346
380
  ##### primary80
347
381
 
348
382
  ```ts
@@ -399,6 +433,22 @@ primary1: string;
399
433
 
400
434
  Primary color with 1% opacity
401
435
 
436
+ ##### secondary
437
+
438
+ ```ts
439
+ secondary: string;
440
+ ```
441
+
442
+ Secondary color
443
+
444
+ ##### secondary90
445
+
446
+ ```ts
447
+ secondary90: string;
448
+ ```
449
+
450
+ Secondary color with 90% opacity
451
+
402
452
  ##### secondary80
403
453
 
404
454
  ```ts
@@ -1366,10 +1416,6 @@ A handler that will be called with an argument matching the schema when the comm
1366
1416
 
1367
1417
  `void`
1368
1418
 
1369
- ## Other
1370
-
1371
- - [Icons](@nlxai/namespaces/Icons.md)
1372
-
1373
1419
  ## Utilities
1374
1420
 
1375
1421
  ### version
package/docs/README.md CHANGED
@@ -160,7 +160,7 @@ the context object
160
160
  ##### input?
161
161
 
162
162
  ```ts
163
- optional input: "text" | "voice" | "voiceMini";
163
+ optional input: "text" | "external" | "voice" | "voiceMini";
164
164
  ```
165
165
 
166
166
  Controls the ways in which the user can communicate with the application. Defaults to `"text"`
@@ -181,6 +181,14 @@ optional bidirectional: BidirectionalConfig;
181
181
 
182
182
  Enables bidirectional mode of voice+. Will automatically set the bidirectional flag in the config.
183
183
 
184
+ ##### copy?
185
+
186
+ ```ts
187
+ optional copy: Partial<Copy>;
188
+ ```
189
+
190
+ Copy
191
+
184
192
  ---
185
193
 
186
194
  ### TouchpointInstance
@@ -292,15 +300,15 @@ A list containing the custom commands to set.
292
300
 
293
301
  The full theme expressed as CSS custom properties.
294
302
  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.
295
- 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.
296
- 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.
303
+ Note also that not all colors need to be provided manually. For instance if only `primary` is provided, the rest of the primary colors will be computed automatically based on it.
304
+ Therefore, for a fully custom but minimal theme, you only need to provide `accent`, `primary`, `secondary`, `background`, `overlay`, and potentially the warning and error colors.
297
305
 
298
306
  #### Example
299
307
 
300
308
  ```typescript
301
309
  const theme: Partial<Theme> = {
302
- primary80: "light-dark(rgba(0, 2, 9, 0.8), rgba(255, 255, 255, 0.8))",
303
- secondary80: "light-dark(rgba(255, 255, 255, 0.8), rgba(0, 2, 9, 0.8))",
310
+ primary: "light-dark(rgb(0, 2, 9), rgb(255, 255, 255))",
311
+ secondary: "light-dark(rgb(255, 255, 255), rgb(0, 2, 9))",
304
312
  accent: "light-dark(rgb(28, 99, 218), rgb(174, 202, 255))",
305
313
  background: "light-dark(rgba(220, 220, 220, 0.9), rgba(0, 2, 9, 0.9))",
306
314
  };
@@ -316,6 +324,22 @@ fontFamily: string;
316
324
 
317
325
  Font family
318
326
 
327
+ ##### primary
328
+
329
+ ```ts
330
+ primary: string;
331
+ ```
332
+
333
+ Primary color
334
+
335
+ ##### primary90
336
+
337
+ ```ts
338
+ primary90: string;
339
+ ```
340
+
341
+ Primary color with 90% opacity
342
+
319
343
  ##### primary80
320
344
 
321
345
  ```ts
@@ -372,6 +396,22 @@ primary1: string;
372
396
 
373
397
  Primary color with 1% opacity
374
398
 
399
+ ##### secondary
400
+
401
+ ```ts
402
+ secondary: string;
403
+ ```
404
+
405
+ Secondary color
406
+
407
+ ##### secondary90
408
+
409
+ ```ts
410
+ secondary90: string;
411
+ ```
412
+
413
+ Secondary color with 90% opacity
414
+
375
415
  ##### secondary80
376
416
 
377
417
  ```ts
package/index.html CHANGED
@@ -1,63 +1,55 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <title>Touchpoint</title>
6
- <link
7
- href="https://db.onlinewebfonts.com/c/0970e3fd1aa7e6ff6937c76a583f3a30?family=BW+Haas+Text+Mono+C+55+Rom+Regular"
8
- rel="stylesheet"
9
- />
10
- </head>
11
3
 
12
- <body
13
- style="
14
- background-image: url(https://platform.nlx.ai/onboarding-bg/voiceplus.webp);
15
- background-size: cover;
16
- color: white;
17
- "
18
- >
19
- <div
20
- style="width: 40vw; height: 80vh; margin: auto; padding-top: 10vh"
21
- ></div>
22
- <script type="module">
23
- import { create, html } from "./src/index.tsx";
4
+ <head>
5
+ <style>
6
+ html,
7
+ body,
8
+ nlx-touchpoint {
9
+ width: 100%;
10
+ height: 100%;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+ </style>
15
+ <meta charset="UTF-8" />
16
+ <title>Touchpoint</title>
17
+ </head>
24
18
 
25
- const touchpoint = await create({
26
- config: {
27
- applicationUrl:
28
- "https://bots.dev.studio.nlx.ai/c/Nji0Tkk8UOqaFc3Z3mDW9/5p7ZdO_XgcnCKnuxbhNAS",
19
+ <body>
20
+ <nlx-touchpoint></nlx-touchpoint>
21
+ <script type="module">
22
+ import {create, html} from "./src/index.tsx";
29
23
 
30
- headers: {
31
- "nlx-api-key": "crLjtXvXIOPtc1AgnPHoEE1y",
32
- },
33
- languageCode: "en-US",
34
- conversationId: "12345",
24
+ const touchpointConfig = {
25
+ config: {
26
+ applicationUrl:
27
+ "https://bots.dev.studio.nlx.ai/c/Nji0Tkk8UOqaFc3Z3mDW9/5p7ZdO_XgcnCKnuxbhNAS",
28
+
29
+ headers: {
30
+ "nlx-api-key": "crLjtXvXIOPtc1AgnPHoEE1y",
35
31
  },
36
- windowSize: "full",
37
- input: "external",
38
- bidirectional: {},
39
- // colorMode: "light dark",
40
- // userMessageBubble: true,
41
- // agentMessageBubble: true,
42
- // chatMode: true,
43
- // theme: {
44
- // accent: "rgba(255, 253, 114, 1)",
45
- // primary80:
46
- // "light-dark(rgba(12, 12, 200, 0.8), rgba(255, 255, 255, 0.85))",
32
+ languageCode: "en-US",
33
+ conversationId: "12345",
34
+ },
35
+ windowSize: "full",
36
+ input: "text",
37
+ bidirectional: {},
38
+ // colorMode: "light dark",
39
+ // userMessageBubble: true,
40
+ // agentMessageBubble: true,
41
+ // chatMode: true,
42
+ // theme: {
43
+ // accent: "rgba(255, 253, 114, 1)",
44
+ // primary80:
45
+ // "light-dark(rgba(12, 12, 200, 0.8), rgba(255, 255, 255, 0.85))",
47
46
 
48
- // fontFamily: "'BW Haas Text Mono C 55 Rom Regular', monospace",
49
- // },
50
- });
47
+ // fontFamily: "'BW Haas Text Mono C 55 Rom Regular', monospace",
48
+ // },
49
+ };
50
+
51
+ document.querySelector("nlx-touchpoint").touchpointConfiguration = touchpointConfig;
52
+ </script>
53
+ </body>
51
54
 
52
- touchpoint.setCustomBidirectionalCommands([
53
- {
54
- action: "externalInput",
55
- // description: "Handle external input",
56
- handler: (args) => {
57
- alert(`External input received: ${args}`);
58
- },
59
- },
60
- ]);
61
- </script>
62
- </body>
63
55
  </html>
@@ -0,0 +1,31 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { Copy, ColorMode, Theme } from './interface';
3
+ /**
4
+ *
5
+ */
6
+ export declare const ProviderStack: FC<{
7
+ /**
8
+ *
9
+ */
10
+ colorMode: ColorMode;
11
+ /**
12
+ *
13
+ */
14
+ className?: string;
15
+ /**
16
+ *
17
+ */
18
+ theme?: Partial<Theme>;
19
+ /**
20
+ *
21
+ */
22
+ children?: ReactNode;
23
+ /**
24
+ *
25
+ */
26
+ languageCode: string;
27
+ /**
28
+ *
29
+ */
30
+ copy?: Partial<Copy>;
31
+ }>;
@@ -1,21 +1,36 @@
1
- import { FC } from 'react';
2
- import { Context, ConversationHandler } from '@nlxai/core';
1
+ import { FC, Dispatch, SetStateAction } from 'react';
2
+ import { Context, ConversationHandler, Response } from '@nlxai/core';
3
3
  import { ColorMode, CustomModalityComponent } from '../interface';
4
- import { ModalitiesWithContext } from '../voice';
4
+ import { VoiceHandler, VoiceState } from '../voice';
5
5
  interface Props {
6
6
  colorMode: ColorMode;
7
7
  handler: ConversationHandler;
8
+ responses: Response[];
8
9
  speakersEnabled: boolean;
10
+ showTranscript: boolean;
9
11
  brandIcon?: string;
10
12
  className?: string;
11
13
  context?: Context;
12
14
  modalityComponents: Record<string, CustomModalityComponent<unknown>>;
13
15
  }
16
+ export type WidgetVoiceState = null | "loading" | {
17
+ type: "error";
18
+ error: string;
19
+ } | {
20
+ type: "success";
21
+ handler: VoiceHandler;
22
+ state?: VoiceState;
23
+ };
24
+ export declare const useWidgetVoiceState: () => [
25
+ WidgetVoiceState,
26
+ Dispatch<SetStateAction<WidgetVoiceState>>
27
+ ];
14
28
  export declare const VoiceModalities: FC<{
15
29
  className?: string;
16
- modalities: ModalitiesWithContext[];
30
+ responses: Response[];
17
31
  modalityComponents: Record<string, CustomModalityComponent<unknown>>;
18
32
  renderedAsOverlay: boolean;
33
+ showTranscript: boolean;
19
34
  handler: ConversationHandler;
20
35
  }>;
21
36
  export declare const FullscreenVoice: FC<Props>;
@@ -25,4 +25,9 @@ export declare const MessageChoices: FC<{
25
25
  responseIndex: number;
26
26
  messageIndex: number;
27
27
  }>;
28
+ export declare const UserMessage: FC<{
29
+ text: string;
30
+ files?: File[];
31
+ bubble: boolean;
32
+ }>;
28
33
  export declare const Messages: FC<MessagesProps>;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ export declare const Notice: FC<{
3
+ text: string;
4
+ }>;
@@ -1,8 +1,4 @@
1
- import { FC, ReactNode } from 'react';
2
- import { ColorMode, Theme } from '../interface';
3
- export declare const CustomPropertiesContainer: FC<{
4
- colorMode: ColorMode;
5
- className?: string;
6
- theme?: Partial<Theme>;
7
- children?: ReactNode;
8
- }>;
1
+ import { CSSProperties } from 'react';
2
+ import { Theme } from '../interface';
3
+ export declare const toCustomProperties: (theme: Theme) => CSSProperties;
4
+ export declare const intelligentMerge: (theme: Partial<Theme>) => Theme;
@@ -1,8 +1,10 @@
1
- import { Context, ConversationHandler } from '@nlxai/core';
1
+ import { Context, ConversationHandler, Response } from '@nlxai/core';
2
2
  import { FC } from 'react';
3
3
  import { CustomModalityComponent } from '../interface';
4
4
  export declare const VoiceMini: FC<{
5
5
  modalityComponents: Record<string, CustomModalityComponent<unknown>>;
6
+ showTranscript: boolean;
7
+ responses: Response[];
6
8
  handler: ConversationHandler;
7
9
  brandIcon?: string;
8
10
  renderCollapse: boolean;
@@ -42,6 +42,12 @@ export declare const UnsemanticIconButton: FC<{
42
42
  type: IconButtonType;
43
43
  Icon: FC<IconProps>;
44
44
  }>;
45
+ export declare const HeadlessIconButton: FC<{
46
+ onClick?: MouseEventHandler<HTMLButtonElement>;
47
+ label: string;
48
+ className?: string;
49
+ children: React.ReactNode;
50
+ }>;
45
51
  /**
46
52
  * A button showing only an icon (textual label is provided for accessibility)
47
53
  * @example
package/lib/feedback.d.ts CHANGED
@@ -11,27 +11,24 @@ export interface State {
11
11
  }
12
12
  type CommentState = {
13
13
  state: "idle";
14
- } | {
14
+ } | ({
15
15
  state: "editing";
16
- activeFeedbackUrl: string;
17
- text: string;
18
- } | {
16
+ } & ActiveCommentState) | ({
19
17
  state: "submitting";
20
- activeFeedbackUrl: string;
21
- text: string;
22
- } | {
18
+ } & ActiveCommentState) | ({
23
19
  state: "submitted";
24
- activeFeedbackUrl: string;
25
- text: string;
26
- } | {
20
+ } & ActiveCommentState) | ({
27
21
  state: "error";
22
+ } & ActiveCommentState);
23
+ interface ActiveCommentState {
28
24
  activeFeedbackUrl: string;
29
25
  text: string;
30
- };
26
+ prompt: string;
27
+ }
31
28
  export declare const getFeedbackInfo: (state: State, feedbackUrl: string) => FeedbackInfo;
32
29
  export interface Actions {
33
30
  clickRating: (feedbackUrl: string, value: number) => void;
34
- clickCommentButton: (feedbackUrl: string) => void;
31
+ clickCommentButton: (feedbackUrl: string, prompt: string) => void;
35
32
  clickCommentEdit: () => void;
36
33
  editCommentText: (text: string) => void;
37
34
  submitComment: () => Promise<void>;