@nlxai/touchpoint-ui 1.2.3 → 1.2.4-alpha.10
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/.tool-versions +1 -0
- package/README.md +7 -3
- package/__tests__/feedback.test.tsx +123 -0
- package/docs/@nlxai/namespaces/Icons.md +377 -0
- package/docs/@nlxai/namespaces/React/README.md +221390 -0
- package/docs/@nlxai/namespaces/React/namespaces/JSX.md +3050 -0
- package/docs/README.md +1143 -268
- package/index.html +23 -9
- package/lib/ProviderStack.d.ts +31 -0
- package/lib/components/FeedbackComment.d.ts +6 -0
- package/lib/components/Messages.d.ts +4 -0
- package/lib/components/Theme.d.ts +4 -8
- package/lib/components/ui/IconButton.d.ts +8 -2
- package/lib/components/ui/Icons.d.ts +2 -0
- package/lib/components/ui/MessageButton.d.ts +58 -0
- package/lib/feedback.d.ts +38 -0
- package/lib/index.js +23083 -17972
- package/lib/index.umd.js +122 -106
- package/lib/interface.d.ts +46 -5
- package/lib/utils/useAppRoot.d.ts +3 -0
- package/lib/utils/useCopy.d.ts +4 -0
- package/package.json +9 -4
- package/vitest.config.ts +17 -0
- package/docs/.nojekyll +0 -1
- package/docs/interfaces/BidirectionalContext.md +0 -51
- package/docs/interfaces/BidirectionalCustomCommand.md +0 -79
- package/docs/interfaces/ChoiceMessage.md +0 -39
- package/docs/interfaces/CustomCardProps.md +0 -83
- package/docs/interfaces/CustomCardRowProps.md +0 -39
- package/docs/interfaces/DateInputProps.md +0 -41
- package/docs/interfaces/IconButtonProps.md +0 -71
- package/docs/interfaces/Icons.IconProps.md +0 -29
- package/docs/interfaces/InputField.md +0 -27
- package/docs/interfaces/InteractiveElementInfo.md +0 -21
- package/docs/interfaces/PageForms.md +0 -27
- package/docs/interfaces/PageState.md +0 -39
- package/docs/interfaces/TextButtonProps.md +0 -72
- package/docs/interfaces/Theme.md +0 -303
- package/docs/interfaces/TouchpointConfiguration.md +0 -209
- package/docs/interfaces/TouchpointInstance.md +0 -121
- package/docs/modules/Icons.md +0 -878
- /package/lib/{hooks.d.ts → utils/useTailwindMediaQuery.d.ts} +0 -0
package/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodejs 20.19.6
|
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
|
-
|
|
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
|
},
|
|
@@ -187,7 +189,7 @@ the context object
|
|
|
187
189
|
##### input?
|
|
188
190
|
|
|
189
191
|
```ts
|
|
190
|
-
optional input: "text" | "voice" | "voiceMini";
|
|
192
|
+
optional input: "text" | "external" | "voice" | "voiceMini";
|
|
191
193
|
```
|
|
192
194
|
|
|
193
195
|
Controls the ways in which the user can communicate with the application. Defaults to `"text"`
|
|
@@ -646,6 +648,7 @@ const CustomCardRow: FC<{
|
|
|
646
648
|
left: ReactNode;
|
|
647
649
|
right: ReactNode;
|
|
648
650
|
icon?: Icon;
|
|
651
|
+
className?: string;
|
|
649
652
|
}>;
|
|
650
653
|
```
|
|
651
654
|
|
|
@@ -718,7 +721,7 @@ Represents the different types of icon buttons available in the application.
|
|
|
718
721
|
|
|
719
722
|
```ts
|
|
720
723
|
const IconButton: FC<{
|
|
721
|
-
onClick?:
|
|
724
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
722
725
|
label: string;
|
|
723
726
|
className?: string;
|
|
724
727
|
type: IconButtonType;
|
|
@@ -861,6 +864,7 @@ type CustomModalityComponent<Data> = ComponentType<{
|
|
|
861
864
|
data: Data;
|
|
862
865
|
conversationHandler: ConversationHandler;
|
|
863
866
|
className?: string;
|
|
867
|
+
renderedAsOverlay?: boolean;
|
|
864
868
|
}>;
|
|
865
869
|
```
|
|
866
870
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { renderHook, act, waitFor } from "@testing-library/react";
|
|
2
|
+
import { useFeedback, getFeedbackInfo } from "../src/feedback";
|
|
3
|
+
import { vi, describe, it, expect, beforeEach } from "vitest";
|
|
4
|
+
|
|
5
|
+
// Mock ConversationHandler
|
|
6
|
+
const mockHandlerObj = {
|
|
7
|
+
submitFeedback: vi.fn(async () => Promise.resolve()),
|
|
8
|
+
};
|
|
9
|
+
const mockHandler =
|
|
10
|
+
mockHandlerObj as unknown as import("@nlxai/core").ConversationHandler;
|
|
11
|
+
|
|
12
|
+
describe("useFeedback", () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should initialize with default state", () => {
|
|
18
|
+
const { result } = renderHook(() => useFeedback(mockHandler));
|
|
19
|
+
const [state] = result.current;
|
|
20
|
+
expect(state.comment.state).toBe("idle");
|
|
21
|
+
expect(state.items).toEqual({});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should handle clickRating and update state", async () => {
|
|
25
|
+
const { result } = renderHook(() => useFeedback(mockHandler as any));
|
|
26
|
+
const [, actions] = result.current;
|
|
27
|
+
await act(async () => {
|
|
28
|
+
actions.clickRating("url1", 4);
|
|
29
|
+
});
|
|
30
|
+
const [state] = result.current;
|
|
31
|
+
expect(getFeedbackInfo(state as any, "url1").rating).toBe(4);
|
|
32
|
+
expect(mockHandler.submitFeedback).toHaveBeenCalledWith("url1", {
|
|
33
|
+
rating: 4,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should handle clickCommentButton and enter editing state", () => {
|
|
38
|
+
const { result } = renderHook(() => useFeedback(mockHandler));
|
|
39
|
+
const [, actions] = result.current;
|
|
40
|
+
act(() => {
|
|
41
|
+
actions.clickCommentButton("url2");
|
|
42
|
+
});
|
|
43
|
+
const [state] = result.current;
|
|
44
|
+
expect(state.comment.state).toBe("editing");
|
|
45
|
+
if (state.comment.state === "editing") {
|
|
46
|
+
expect(state.comment.activeFeedbackUrl).toBe("url2");
|
|
47
|
+
} else {
|
|
48
|
+
throw new Error("Expected comment state to be 'editing'");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should handle editCommentText and update text", () => {
|
|
53
|
+
const { result } = renderHook(() => useFeedback(mockHandler));
|
|
54
|
+
act(() => {
|
|
55
|
+
result.current[1].clickCommentButton("url3");
|
|
56
|
+
});
|
|
57
|
+
act(() => {
|
|
58
|
+
result.current[1].editCommentText("Test comment");
|
|
59
|
+
});
|
|
60
|
+
const [state] = result.current;
|
|
61
|
+
if (state.comment.state !== "editing") throw new Error();
|
|
62
|
+
expect(state.comment.text).toBe("Test comment");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should handle submitComment and update state on success", async () => {
|
|
66
|
+
const { result } = renderHook(() => useFeedback(mockHandler));
|
|
67
|
+
act(() => {
|
|
68
|
+
result.current[1].clickCommentButton("url4");
|
|
69
|
+
});
|
|
70
|
+
act(() => {
|
|
71
|
+
result.current[1].editCommentText("My feedback");
|
|
72
|
+
});
|
|
73
|
+
await act(async () => {
|
|
74
|
+
await result.current[1].submitComment();
|
|
75
|
+
});
|
|
76
|
+
// Wait for the state to update to 'submitted'
|
|
77
|
+
await waitFor(() => {
|
|
78
|
+
const [state] = result.current;
|
|
79
|
+
expect(state.comment.state).toBe("idle");
|
|
80
|
+
});
|
|
81
|
+
const [state] = result.current;
|
|
82
|
+
expect(getFeedbackInfo(state as any, "url4").commentSubmitted).toBe(true);
|
|
83
|
+
expect(getFeedbackInfo(state as any, "url4").commentText).toBe(
|
|
84
|
+
"My feedback",
|
|
85
|
+
);
|
|
86
|
+
expect(mockHandler.submitFeedback).toHaveBeenCalledWith("url4", {
|
|
87
|
+
comment: "My feedback",
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should handle cancelComment and return to idle", () => {
|
|
92
|
+
const { result } = renderHook(() => useFeedback(mockHandler));
|
|
93
|
+
const [, actions] = result.current;
|
|
94
|
+
act(() => {
|
|
95
|
+
actions.clickCommentButton("url5");
|
|
96
|
+
actions.cancelComment();
|
|
97
|
+
});
|
|
98
|
+
const [state] = result.current;
|
|
99
|
+
expect(state.comment.state).toBe("idle");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("should handle submission error", async () => {
|
|
103
|
+
const errorHandlerObj = {
|
|
104
|
+
submitFeedback: vi.fn(async () => Promise.reject(new Error("fail"))),
|
|
105
|
+
};
|
|
106
|
+
const errorHandler =
|
|
107
|
+
errorHandlerObj as unknown as import("@nlxai/core").ConversationHandler;
|
|
108
|
+
const { result } = renderHook(() => useFeedback(errorHandler));
|
|
109
|
+
|
|
110
|
+
act(() => {
|
|
111
|
+
result.current[1].clickCommentButton("url6");
|
|
112
|
+
result.current[1].editCommentText("fail");
|
|
113
|
+
});
|
|
114
|
+
await act(async () => {
|
|
115
|
+
await result.current[1].submitComment();
|
|
116
|
+
});
|
|
117
|
+
// Wait for the state to update to 'error'
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
const [state] = result.current;
|
|
120
|
+
expect(state.comment.state).toBe("error");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
## Variables
|
|
2
|
+
|
|
3
|
+
### Action
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const Action: Icon;
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
### Touchpoint
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const Touchpoint: Icon;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### AssistantOld
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const AssistantOld: Icon;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### Add
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const Add: Icon;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### ArrowDown
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const ArrowDown: Icon;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### ArrowLeft
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const ArrowLeft: Icon;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### ArrowRight
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const ArrowRight: Icon;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### ArrowUp
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const ArrowUp: Icon;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### ArrowForward
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const ArrowForward: Icon;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### Attachment
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const Attachment: Icon;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### BotMessage
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const BotMessage: Icon;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### Camera
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const Camera: Icon;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### Check
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const Check: Icon;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### Close
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const Close: Icon;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### Copy
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
const Copy: Icon;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### Date
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
const Date: Icon;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Delete
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const Delete: Icon;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### Edit
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const Edit: Icon;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### Escalate
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
const Escalate: Icon;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### Error
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const Error: Icon;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### FullScreen
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
const FullScreen: Icon;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### Mic
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
const Mic: Icon;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### MicOff
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const MicOff: Icon;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### Location
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const Location: Icon;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### Volume
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const Volume: Icon;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### VolumeOff
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
const VolumeOff: Icon;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### Translate
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
const Translate: Icon;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
### OpenInNew
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
const OpenInNew: Icon;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### Play
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
const Play: Icon;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Preview
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
const Preview: Icon;
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### Reorder
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
const Reorder: Icon;
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### Restart
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
const Restart: Icon;
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### Settings
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
const Settings: Icon;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### Search
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
const Search: Icon;
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### Share
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
const Share: Icon;
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### Warning
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
const Warning: Icon;
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### ThumbDown
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
const ThumbDown: Icon;
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### ThumbUp
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
const ThumbUp: Icon;
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
### Time
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
const Time: Icon;
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
### Undo
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
const Undo: Icon;
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### Refresh
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
const Refresh: Icon;
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
### Help
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
const Help: Icon;
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
### OpenLink
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
const OpenLink: Icon;
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Interfaces
|
|
346
|
+
|
|
347
|
+
### IconProps
|
|
348
|
+
|
|
349
|
+
Props for icon components
|
|
350
|
+
|
|
351
|
+
#### Properties
|
|
352
|
+
|
|
353
|
+
##### className?
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
optional className: string;
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Additional CSS classes to apply to the icon
|
|
360
|
+
|
|
361
|
+
##### size?
|
|
362
|
+
|
|
363
|
+
```ts
|
|
364
|
+
optional size: number;
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Custom size in pixels for the icon
|
|
368
|
+
|
|
369
|
+
## Type Aliases
|
|
370
|
+
|
|
371
|
+
### Icon
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
type Icon = FC<IconProps>;
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Type definition for an icon component
|