@nlxai/touchpoint-ui 1.1.2 → 1.1.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/index.html +116 -6
- package/lib/App.d.ts +2 -3
- package/lib/bidirectional/automaticContext.d.ts +5 -0
- package/lib/bidirectional/commandHandler.d.ts +8 -0
- package/lib/components/FullscreenVoice.d.ts +1 -0
- package/lib/components/VoiceMini.d.ts +3 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +5235 -5077
- package/lib/index.umd.js +47 -40
- package/lib/types.d.ts +82 -1
- package/package.json +3 -3
- /package/lib/{analyzePageForms.d.ts → bidirectional/analyzePageForms.d.ts} +0 -0
package/index.html
CHANGED
|
@@ -17,7 +17,23 @@
|
|
|
17
17
|
</head>
|
|
18
18
|
|
|
19
19
|
<body>
|
|
20
|
-
<
|
|
20
|
+
<nav>
|
|
21
|
+
<ul
|
|
22
|
+
onclick="event.preventDefault(); window.history.pushState({}, '', event.target.href); render(event.target.href.split('/').pop());"
|
|
23
|
+
>
|
|
24
|
+
<li>
|
|
25
|
+
<a href="/index.html">Home</a>
|
|
26
|
+
</li>
|
|
27
|
+
<li>
|
|
28
|
+
<a href="/form.html">Form</a>
|
|
29
|
+
</li>
|
|
30
|
+
</ul>
|
|
31
|
+
</nav>
|
|
32
|
+
<div id="app"></div>
|
|
33
|
+
<script type="module">
|
|
34
|
+
window.render = (url) => {
|
|
35
|
+
if (url == "index.html") {
|
|
36
|
+
app.innerHTML = `<main>
|
|
21
37
|
<h1>Loreum ipsum dolor sit amet</h1>
|
|
22
38
|
|
|
23
39
|
<p>
|
|
@@ -70,6 +86,38 @@
|
|
|
70
86
|
porttitor nec.
|
|
71
87
|
</p>
|
|
72
88
|
|
|
89
|
+
<h2>Embedded touchpoint</h2>
|
|
90
|
+
|
|
91
|
+
<h3>Text touchpoint defined in HTML</h3>
|
|
92
|
+
<nlx-touchpoint
|
|
93
|
+
configuration='{
|
|
94
|
+
"config": {
|
|
95
|
+
"applicationUrl":
|
|
96
|
+
"https://bots.dev.studio.nlx.ai/c/kQwAgKCx86vJ4r0PUSxYR/ON4zgwWnVofsz2NaiD38Z",
|
|
97
|
+
"headers": {
|
|
98
|
+
"nlx-api-key": "XDE2Th70VhBSlhz2YA"
|
|
99
|
+
},
|
|
100
|
+
"userId": "1234-5678",
|
|
101
|
+
"languageCode": "en-US"
|
|
102
|
+
},
|
|
103
|
+
"input": "text"
|
|
104
|
+
}'
|
|
105
|
+
></nlx-touchpoint>
|
|
106
|
+
|
|
107
|
+
<h3>Voice touchpoint defined in code</h3>
|
|
108
|
+
<button id="voiceTouchpointTrigger">Open Voice Touchpoint</button>
|
|
109
|
+
|
|
110
|
+
<div id="voiceTouchpoint" style="height: 300px"></div>
|
|
111
|
+
|
|
112
|
+
<h3>Voice mini defined in HTML (inline) late initialization</h3>
|
|
113
|
+
|
|
114
|
+
<p>
|
|
115
|
+
<nlx-touchpoint id="voiceMini"></nlx-touchpoint>
|
|
116
|
+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint, cum
|
|
117
|
+
repellendus distinctio eveniet id odit sit velit? Vel, autem, quaerat
|
|
118
|
+
quidem natus molestias ea vero cumque et, numquam ab aut!
|
|
119
|
+
</p>
|
|
120
|
+
|
|
73
121
|
<p>
|
|
74
122
|
Orci varius natoque penatibus et magnis dis parturient montes, nascetur
|
|
75
123
|
ridiculus mus. Nunc elementum non urna vel vulputate. Vestibulum vitae
|
|
@@ -87,7 +135,33 @@
|
|
|
87
135
|
volutpat tellus lectus sit amet enim. Duis laoreet lorem vitae lorem
|
|
88
136
|
aliquam bibendum.
|
|
89
137
|
</p>
|
|
90
|
-
</main
|
|
138
|
+
</main>`;
|
|
139
|
+
} else if (url == "form.html") {
|
|
140
|
+
app.innerHTML = `<form style="display: grid; grid-template-columns: 100px 300px; gap: 10px;">
|
|
141
|
+
<label for="input">Name:</label>
|
|
142
|
+
<input type="text" id="input" name="input" value="" />
|
|
143
|
+
<label for="input2">Email:</label>
|
|
144
|
+
<input type="email" id="input2" name="input2" value="" />
|
|
145
|
+
<label for="input3">Message:</label>
|
|
146
|
+
<textarea id="input3" name="input3"></textarea>
|
|
147
|
+
<label for="input4">Favourite fruit:</label>
|
|
148
|
+
<select id="input4" name="input4">
|
|
149
|
+
<option value="apple">Apple</option>
|
|
150
|
+
<option value="banana">Banana</option>
|
|
151
|
+
<option value="cherry">Cherry</option>
|
|
152
|
+
<option value="date">Date</option>
|
|
153
|
+
</select>
|
|
154
|
+
<button type="submit">Submit</button>
|
|
155
|
+
</form>`;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
render(window.location.pathname.split("/").pop());
|
|
159
|
+
window.addEventListener("popstate", (event) => {
|
|
160
|
+
render(window.location.pathname.split("/").pop());
|
|
161
|
+
history.pushState(null, null, document.URL);
|
|
162
|
+
});
|
|
163
|
+
</script>
|
|
164
|
+
|
|
91
165
|
<script type="module">
|
|
92
166
|
import { create, html } from "/src/index.tsx";
|
|
93
167
|
|
|
@@ -136,17 +210,53 @@
|
|
|
136
210
|
const touchpoint = await create({
|
|
137
211
|
config: {
|
|
138
212
|
applicationUrl:
|
|
139
|
-
"https://bots.dev.studio.nlx.ai/c/
|
|
213
|
+
"https://bots.dev.studio.nlx.ai/c/CBuQ3LpsClG5EQoSObVkK/IPzJitiaN8qtJFL3Wz1Jp",
|
|
140
214
|
headers: {
|
|
141
|
-
"nlx-api-key": "
|
|
215
|
+
"nlx-api-key": "m3kVBd9QeCc5bXInhWIPG3ns",
|
|
142
216
|
},
|
|
143
217
|
userId: "1234-5678",
|
|
144
218
|
languageCode: "en-US",
|
|
145
219
|
},
|
|
146
|
-
input: "
|
|
147
|
-
|
|
220
|
+
input: "voiceMini",
|
|
221
|
+
bidirectional: {},
|
|
148
222
|
initializeConversation: () => {},
|
|
149
223
|
});
|
|
224
|
+
|
|
225
|
+
voiceTouchpointTrigger.addEventListener("click", () => {
|
|
226
|
+
voiceTouchpointTrigger.parentElement.removeChild(
|
|
227
|
+
voiceTouchpointTrigger,
|
|
228
|
+
);
|
|
229
|
+
const embeddedVoiceTouchpoint =
|
|
230
|
+
document.createElement("nlx-touchpoint");
|
|
231
|
+
embeddedVoiceTouchpoint.touchpointConfiguration = {
|
|
232
|
+
config: {
|
|
233
|
+
applicationUrl:
|
|
234
|
+
"https://bots.dev.studio.nlx.ai/c/CBuQ3LpsClG5EQoSObVkK/IPzJitiaN8qtJFL3Wz1Jp",
|
|
235
|
+
headers: {
|
|
236
|
+
"nlx-api-key": "m3kVBd9QeCc5bXInhWIPG3ns",
|
|
237
|
+
},
|
|
238
|
+
userId: "1234-5678",
|
|
239
|
+
languageCode: "en-US",
|
|
240
|
+
},
|
|
241
|
+
input: "voice",
|
|
242
|
+
initializeConversation: () => {},
|
|
243
|
+
};
|
|
244
|
+
voiceTouchpoint.appendChild(embeddedVoiceTouchpoint);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
voiceMini.touchpointConfiguration = {
|
|
248
|
+
config: {
|
|
249
|
+
applicationUrl:
|
|
250
|
+
"https://bots.dev.studio.nlx.ai/c/CBuQ3LpsClG5EQoSObVkK/IPzJitiaN8qtJFL3Wz1Jp",
|
|
251
|
+
headers: {
|
|
252
|
+
"nlx-api-key": "m3kVBd9QeCc5bXInhWIPG3ns",
|
|
253
|
+
},
|
|
254
|
+
userId: "1234-5678",
|
|
255
|
+
languageCode: "en-US",
|
|
256
|
+
},
|
|
257
|
+
input: "voiceMini",
|
|
258
|
+
initializeConversation: () => {},
|
|
259
|
+
};
|
|
150
260
|
</script>
|
|
151
261
|
</body>
|
|
152
262
|
</html>
|
package/lib/App.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { ConversationHandler } from '@nlxai/chat-core';
|
|
2
|
-
import {
|
|
2
|
+
import { NormalizedTouchpointConfiguration } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Main Touchpoint creation properties object
|
|
5
5
|
*/
|
|
6
|
-
interface Props extends
|
|
6
|
+
interface Props extends NormalizedTouchpointConfiguration {
|
|
7
7
|
embedded: boolean;
|
|
8
8
|
onClose: ((event: Event) => void) | null;
|
|
9
9
|
enableSettings: boolean;
|
|
10
10
|
enabled: boolean;
|
|
11
|
-
initializeConversation: InitializeConversation;
|
|
12
11
|
}
|
|
13
12
|
export interface AppRef {
|
|
14
13
|
setExpanded: (val: boolean) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConversationHandler } from '@nlxai/chat-core';
|
|
2
|
+
import { BidirectionalConfig } from '../types';
|
|
3
|
+
export declare const commandHandler: (handler: ConversationHandler, bidirectional: BidirectionalConfig, pageState: {
|
|
4
|
+
current: {
|
|
5
|
+
formElements: Record<string, Element>;
|
|
6
|
+
links: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
}) => () => void;
|
|
@@ -4,6 +4,8 @@ import { CustomModalityComponent } from '../types';
|
|
|
4
4
|
export declare const VoiceMini: FC<{
|
|
5
5
|
customModalities: Record<string, CustomModalityComponent<unknown>>;
|
|
6
6
|
handler: ConversationHandler;
|
|
7
|
-
|
|
7
|
+
renderCollapse: boolean;
|
|
8
|
+
onClose: (event: Event) => void;
|
|
8
9
|
context?: Context;
|
|
10
|
+
restore: boolean;
|
|
9
11
|
}>;
|
package/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Carousel } from './components/ui/Carousel';
|
|
|
8
8
|
import { DateInput } from './components/ui/DateInput';
|
|
9
9
|
import { TouchpointConfiguration } from './types';
|
|
10
10
|
import * as Icons from "./components/ui/Icons";
|
|
11
|
-
export { analyzePageForms, type InteractiveElementInfo, type PageForms, type AccessibilityInformation, } from './analyzePageForms';
|
|
11
|
+
export { analyzePageForms, type InteractiveElementInfo, type PageForms, type AccessibilityInformation, } from './bidirectional/analyzePageForms';
|
|
12
12
|
/**
|
|
13
13
|
* If you wish to build custom modalities using JSX, you will want to
|
|
14
14
|
*
|
|
@@ -30,7 +30,7 @@ export { type CustomCardProps, type CustomCardRowProps, } from './components/ui/
|
|
|
30
30
|
export { type DateInputProps } from './components/ui/DateInput';
|
|
31
31
|
export { type IconButtonProps, type IconButtonType, } from './components/ui/IconButton';
|
|
32
32
|
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, } from './types';
|
|
33
|
+
export { type InitializeConversation, type ColorMode, type Input, type Theme, type WindowSize, type CustomModalityComponent, type TouchpointConfiguration, type CustomLaunchButton, type BidirectionalConfig, } from './types';
|
|
34
34
|
/**
|
|
35
35
|
* Instance of a Touchpoint UI component
|
|
36
36
|
*/
|