@nlxai/touchpoint-ui 1.1.8-alpha.1 → 1.1.8-alpha.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.
package/index.html CHANGED
@@ -90,6 +90,7 @@
90
90
  </main>
91
91
  <script type="module">
92
92
  import { create, html } from "/src/index.tsx";
93
+ import * as z from "zod/v4";
93
94
 
94
95
  const CustomLaunchButton = ({ className, onClick }) => {
95
96
  return html`
@@ -134,19 +135,50 @@
134
135
  };
135
136
 
136
137
  const touchpoint = await create({
138
+ // https://dev.platform.nlx.ai/applications/fe041de0-bc87-4120-a6db-443ab1107ad3 in the dev workspace
137
139
  config: {
138
140
  applicationUrl:
139
- "https://bots.dev.studio.nlx.ai/c/CBuQ3LpsClG5EQoSObVkK/IPzJitiaN8qtJFL3Wz1Jp",
141
+ "https://bots.dev.studio.nlx.ai/c/XeHWunu1RQOVcVzKIQoo5/cKdh8IsqmA0syks0R9oBh",
140
142
  headers: {
141
- "nlx-api-key": "m3kVBd9QeCc5bXInhWIPG3ns",
143
+ "nlx-api-key": "8afGyqKJoObPj4g-UFNUc65s",
142
144
  },
143
- userId: "1234-5678",
145
+ userId: "sdk-test-user",
144
146
  languageCode: "en-US",
145
147
  },
146
- input: "voice",
148
+ input: "voiceMini",
147
149
  launchIcon: CustomLaunchButton,
148
- initializeConversation: () => {},
150
+ bidirectional: {
151
+ custom(action, payload) {
152
+ console.log("Custom bidirectional action:", action, payload);
153
+ },
154
+ customizeAutomaticContext(arg) {
155
+ console.log("Customizing automatic context with arg:", arg);
156
+ arg.context.uri = "foo";
157
+ return arg;
158
+ },
159
+ },
149
160
  });
161
+
162
+ touchpoint.setCustomBidirectionalCommands([
163
+ {
164
+ action: "burger",
165
+ description: "Order a hamburger",
166
+ schema: z.object({
167
+ type: z
168
+ .enum(["cheeseburger", "veggieburger", "hamburger"])
169
+ .describe("Which variety of burger to order"),
170
+ count: z
171
+ .number()
172
+ .min(1)
173
+ .max(200)
174
+ .default(1)
175
+ .describe("How many burgers to order"),
176
+ }),
177
+ handler: (burgerType) => {
178
+ console.log("Custom command executed with args:", burgerType);
179
+ },
180
+ },
181
+ ]);
150
182
  </script>
151
183
  </body>
152
184
  </html>
package/lib/App.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ConversationHandler } from '@nlxai/core';
2
+ import { BidirectionalCustomCommand } from './interface';
2
3
  import { NormalizedTouchpointConfiguration } from './types';
3
4
  /**
4
5
  * Main Touchpoint creation properties object
@@ -13,6 +14,7 @@ export interface AppRef {
13
14
  setExpanded: (val: boolean) => void;
14
15
  getExpanded: () => boolean;
15
16
  getConversationHandler: () => ConversationHandler;
17
+ setCustomBidirectionalCommands: (commands: BidirectionalCustomCommand[]) => void;
16
18
  }
17
19
  declare const App: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<AppRef>>;
18
20
  export default App;
@@ -1,5 +1,12 @@
1
1
  import { ConversationHandler } from '@nlxai/core';
2
- export declare const gatherAutomaticContext: (handler: ConversationHandler, setPageState: (state: {
3
- formElements: any;
4
- links: Record<string, string>;
5
- }) => void) => (() => void);
2
+ import { BidirectionalContext, BidirectionalCustomCommand, PageState } from '../interface';
3
+ export declare const gatherAutomaticContext: (handler: ConversationHandler, customCommands: BidirectionalCustomCommand[], override: (arg: {
4
+ context: BidirectionalContext;
5
+ state: PageState;
6
+ }) => {
7
+ context: BidirectionalContext;
8
+ state: PageState;
9
+ }, setPageState: (state: PageState) => void) => {
10
+ teardown: () => void;
11
+ onCustomCommandsChange: (commands: BidirectionalCustomCommand[]) => void;
12
+ };
@@ -1,8 +1,5 @@
1
1
  import { ConversationHandler } from '@nlxai/core';
2
- import { BidirectionalConfig } from '../types';
2
+ import { PageState, BidirectionalConfig } from '../interface';
3
3
  export declare const commandHandler: (handler: ConversationHandler, bidirectional: BidirectionalConfig, pageState: {
4
- current: {
5
- formElements: Record<string, Element>;
6
- links: Record<string, string>;
7
- };
4
+ current: PageState;
8
5
  }) => () => void;
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { Context, ConversationHandler } from '@nlxai/core';
3
- import { ColorMode, InitializeConversation, CustomModalityComponent } from '../types';
3
+ import { ColorMode, CustomModalityComponent } from '../interface';
4
4
  import { ModalitiesWithContext } from '../voice';
5
5
  interface Props {
6
6
  colorMode: ColorMode;
@@ -9,7 +9,6 @@ interface Props {
9
9
  brandIcon?: string;
10
10
  className?: string;
11
11
  context?: Context;
12
- initializeConversation: InitializeConversation;
13
12
  customModalities?: Record<string, CustomModalityComponent<unknown>>;
14
13
  }
15
14
  export declare const VoiceModalities: FC<{
@@ -1,5 +1,5 @@
1
1
  import { SetStateAction, Dispatch, FC } from 'react';
2
- import { WindowSize, ColorMode } from '../types';
2
+ import { WindowSize, ColorMode } from '../interface';
3
3
  interface HeaderProps {
4
4
  windowSize: WindowSize | "embedded";
5
5
  colorMode: ColorMode;
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { Response, ConversationHandler, ApplicationMessage } from '@nlxai/core';
3
- import { CustomModalityComponent, ColorMode } from '../types';
3
+ import { CustomModalityComponent, ColorMode } from '../interface';
4
4
  export interface MessagesProps {
5
5
  isWaiting: boolean;
6
6
  handler: ConversationHandler;
@@ -1,5 +1,5 @@
1
1
  import { FC, ReactNode } from 'react';
2
- import { ColorMode, Theme } from '../types';
2
+ import { ColorMode, Theme } from '../interface';
3
3
  export declare const CustomPropertiesContainer: FC<{
4
4
  colorMode: ColorMode;
5
5
  className?: string;
@@ -1,6 +1,6 @@
1
1
  import { Context, ConversationHandler } from '@nlxai/core';
2
2
  import { FC } from 'react';
3
- import { CustomModalityComponent } from '../types';
3
+ import { CustomModalityComponent } from '../interface';
4
4
  export declare const VoiceMini: FC<{
5
5
  customModalities: Record<string, CustomModalityComponent<unknown>>;
6
6
  handler: ConversationHandler;
@@ -1,3 +1,3 @@
1
- import { CustomModalityComponent } from '../../types';
1
+ import { CustomModalityComponent } from '../../interface';
2
2
  import { CardData } from './shared';
3
3
  export declare const DefaultCard: CustomModalityComponent<CardData>;
@@ -1,4 +1,4 @@
1
- import { CustomModalityComponent } from '../../types';
1
+ import { CustomModalityComponent } from '../../interface';
2
2
  import { SaveAs, CardData } from './shared';
3
3
  export declare const DefaultCarousel: CustomModalityComponent<{
4
4
  cards: CardData[];
@@ -1,5 +1,5 @@
1
1
  import { SaveAs } from './shared';
2
- import { CustomModalityComponent } from '../../types';
2
+ import { CustomModalityComponent } from '../../interface';
3
3
  export declare const DefaultDateInput: CustomModalityComponent<{
4
4
  $saveAs: SaveAs;
5
5
  }>;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { ConversationHandler } from '@nlxai/core';
2
1
  import { TextButton } from './components/ui/TextButton';
3
2
  import { IconButton } from './components/ui/IconButton';
4
3
  import { Ripple } from './components/Ripple';
@@ -6,7 +5,7 @@ import { BaseText, SmallText } from './components/ui/Typography';
6
5
  import { CustomCard, CustomCardRow, CustomCardImageRow } from './components/ui/CustomCard';
7
6
  import { Carousel } from './components/ui/Carousel';
8
7
  import { DateInput } from './components/ui/DateInput';
9
- import { TouchpointConfiguration } from './types';
8
+ import { TouchpointConfiguration, TouchpointInstance } from './interface';
10
9
  import * as Icons from "./components/ui/Icons";
11
10
  export { analyzePageForms, type InteractiveElementInfo, type PageForms, type AccessibilityInformation, } from './bidirectional/analyzePageForms';
12
11
  /**
@@ -30,24 +29,7 @@ export { type CustomCardProps, type CustomCardRowProps, } from './components/ui/
30
29
  export { type DateInputProps } from './components/ui/DateInput';
31
30
  export { type IconButtonProps, type IconButtonType, } from './components/ui/IconButton';
32
31
  export { type TextButtonProps } from './components/ui/TextButton';
33
- export { type InitializeConversation, type ColorMode, type Input, type Theme, type WindowSize, type CustomModalityComponent, type TouchpointConfiguration, type CustomLaunchButton, type BidirectionalConfig, } from './types';
34
- /**
35
- * Instance of a Touchpoint UI component
36
- */
37
- export interface TouchpointInstance {
38
- /**
39
- * Controls whether the Touchpoint UI is expanded or collapsed
40
- */
41
- expanded: boolean;
42
- /**
43
- * The conversation handler instance for interacting with the application
44
- */
45
- conversationHandler: ConversationHandler;
46
- /**
47
- * Method to remove the Touchpoint UI from the DOM
48
- */
49
- teardown: () => void;
50
- }
32
+ export type { WindowSize, ColorMode, ChoiceMessage, CustomModalityComponent, Theme, InitializeConversation, CustomLaunchButton, Input, InputField, PageState, BidirectionalContext, BidirectionalConfig, TouchpointConfiguration, BidirectionalCustomCommand, TouchpointInstance, } from './interface';
51
33
  /**
52
34
  * Creates a new Touchpoint UI instance and appends it to the document body
53
35
  * @param props - Configuration props for Touchpoint