@chatlychat/react-native 0.0.0-stage → 0.1.1
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 +208 -2
- package/dist/ChatlyProvider.d.ts +69 -0
- package/dist/ChatlyProvider.d.ts.map +1 -0
- package/dist/ChatlyProvider.js +146 -0
- package/dist/ChatlyProvider.js.map +1 -0
- package/dist/ChatlyWidget.d.ts +15 -0
- package/dist/ChatlyWidget.d.ts.map +1 -0
- package/dist/ChatlyWidget.js +122 -0
- package/dist/ChatlyWidget.js.map +1 -0
- package/dist/blocks/money.d.ts +56 -0
- package/dist/blocks/money.d.ts.map +1 -0
- package/dist/blocks/money.js +82 -0
- package/dist/blocks/money.js.map +1 -0
- package/dist/blocks/money.parity.spec.d.ts +2 -0
- package/dist/blocks/money.parity.spec.d.ts.map +1 -0
- package/dist/blocks/money.parity.spec.js +87 -0
- package/dist/blocks/money.parity.spec.js.map +1 -0
- package/dist/blocks/read-envelope.d.ts +15 -0
- package/dist/blocks/read-envelope.d.ts.map +1 -0
- package/dist/blocks/read-envelope.js +196 -0
- package/dist/blocks/read-envelope.js.map +1 -0
- package/dist/blocks/read-envelope.parity.spec.d.ts +2 -0
- package/dist/blocks/read-envelope.parity.spec.d.ts.map +1 -0
- package/dist/blocks/read-envelope.parity.spec.js +146 -0
- package/dist/blocks/read-envelope.parity.spec.js.map +1 -0
- package/dist/blocks/types.d.ts +171 -0
- package/dist/blocks/types.d.ts.map +1 -0
- package/dist/blocks/types.js +3 -0
- package/dist/blocks/types.js.map +1 -0
- package/dist/client/RealtimeClient.d.ts +29 -0
- package/dist/client/RealtimeClient.d.ts.map +1 -0
- package/dist/client/RealtimeClient.js +113 -0
- package/dist/client/RealtimeClient.js.map +1 -0
- package/dist/client/RealtimeClient.spec.d.ts +2 -0
- package/dist/client/RealtimeClient.spec.d.ts.map +1 -0
- package/dist/client/RealtimeClient.spec.js +123 -0
- package/dist/client/RealtimeClient.spec.js.map +1 -0
- package/dist/client/RestClient.d.ts +160 -0
- package/dist/client/RestClient.d.ts.map +1 -0
- package/dist/client/RestClient.js +395 -0
- package/dist/client/RestClient.js.map +1 -0
- package/dist/client/RestClient.spec.d.ts +2 -0
- package/dist/client/RestClient.spec.d.ts.map +1 -0
- package/dist/client/RestClient.spec.js +267 -0
- package/dist/client/RestClient.spec.js.map +1 -0
- package/dist/client/types.d.ts +148 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +14 -0
- package/dist/client/types.js.map +1 -0
- package/dist/components/Composer.d.ts +35 -0
- package/dist/components/Composer.d.ts.map +1 -0
- package/dist/components/Composer.js +180 -0
- package/dist/components/Composer.js.map +1 -0
- package/dist/components/HelpCenter.d.ts +13 -0
- package/dist/components/HelpCenter.d.ts.map +1 -0
- package/dist/components/HelpCenter.js +96 -0
- package/dist/components/HelpCenter.js.map +1 -0
- package/dist/components/MessageBlocks.d.ts +41 -0
- package/dist/components/MessageBlocks.d.ts.map +1 -0
- package/dist/components/MessageBlocks.js +167 -0
- package/dist/components/MessageBlocks.js.map +1 -0
- package/dist/components/MessageBubble.d.ts +14 -0
- package/dist/components/MessageBubble.d.ts.map +1 -0
- package/dist/components/MessageBubble.js +87 -0
- package/dist/components/MessageBubble.js.map +1 -0
- package/dist/components/MessageBubble.spec.d.ts +2 -0
- package/dist/components/MessageBubble.spec.d.ts.map +1 -0
- package/dist/components/MessageBubble.spec.js +207 -0
- package/dist/components/MessageBubble.spec.js.map +1 -0
- package/dist/components/MessageCanvas.d.ts +39 -0
- package/dist/components/MessageCanvas.d.ts.map +1 -0
- package/dist/components/MessageCanvas.js +144 -0
- package/dist/components/MessageCanvas.js.map +1 -0
- package/dist/components/MessageCanvas.spec.d.ts +2 -0
- package/dist/components/MessageCanvas.spec.d.ts.map +1 -0
- package/dist/components/MessageCanvas.spec.js +142 -0
- package/dist/components/MessageCanvas.spec.js.map +1 -0
- package/dist/components/MessagesList.d.ts +8 -0
- package/dist/components/MessagesList.d.ts.map +1 -0
- package/dist/components/MessagesList.js +58 -0
- package/dist/components/MessagesList.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/push/registerPushToken.d.ts +12 -0
- package/dist/push/registerPushToken.d.ts.map +1 -0
- package/dist/push/registerPushToken.js +32 -0
- package/dist/push/registerPushToken.js.map +1 -0
- package/dist/storage/TokenStore.d.ts +53 -0
- package/dist/storage/TokenStore.d.ts.map +1 -0
- package/dist/storage/TokenStore.js +89 -0
- package/dist/storage/TokenStore.js.map +1 -0
- package/dist/test/react-native-dom.d.ts +97 -0
- package/dist/test/react-native-dom.d.ts.map +1 -0
- package/dist/test/react-native-dom.js +155 -0
- package/dist/test/react-native-dom.js.map +1 -0
- package/dist/test/react-native-dom.spec.d.ts +2 -0
- package/dist/test/react-native-dom.spec.d.ts.map +1 -0
- package/dist/test/react-native-dom.spec.js +83 -0
- package/dist/test/react-native-dom.spec.js.map +1 -0
- package/dist/theme/ChatlyTheme.d.ts +37 -0
- package/dist/theme/ChatlyTheme.d.ts.map +1 -0
- package/dist/theme/ChatlyTheme.js +2 -0
- package/dist/theme/ChatlyTheme.js.map +1 -0
- package/dist/theme/defaultTheme.d.ts +7 -0
- package/dist/theme/defaultTheme.d.ts.map +1 -0
- package/dist/theme/defaultTheme.js +37 -0
- package/dist/theme/defaultTheme.js.map +1 -0
- package/dist/useChatly.d.ts +3 -0
- package/dist/useChatly.d.ts.map +1 -0
- package/dist/useChatly.js +10 -0
- package/dist/useChatly.js.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Image, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { useChatly } from '../useChatly';
|
|
4
|
+
import { MessageBlocks } from './MessageBlocks';
|
|
5
|
+
import { MessageCanvas } from './MessageCanvas';
|
|
6
|
+
export function MessageBubble({ message, conversationId }) {
|
|
7
|
+
const { theme } = useChatly();
|
|
8
|
+
const isContact = message.authorType === 'contact';
|
|
9
|
+
const isSystem = message.authorType === 'system' || message.kind === 'event';
|
|
10
|
+
const attachments = message.attachments ?? [];
|
|
11
|
+
if (isSystem) {
|
|
12
|
+
return (_jsx(View, { style: styles.systemRow, children: _jsx(Text, { style: [
|
|
13
|
+
styles.systemText,
|
|
14
|
+
{ color: theme.colors.mutedForeground, fontSize: theme.typography.sizeSmall },
|
|
15
|
+
], children: message.body }) }));
|
|
16
|
+
}
|
|
17
|
+
return (_jsx(View, { style: [styles.row, isContact ? styles.rowRight : styles.rowLeft], children: _jsxs(View, { style: [
|
|
18
|
+
styles.bubble,
|
|
19
|
+
{
|
|
20
|
+
borderRadius: theme.radius.bubble,
|
|
21
|
+
paddingHorizontal: theme.spacing.md,
|
|
22
|
+
paddingVertical: theme.spacing.sm,
|
|
23
|
+
backgroundColor: isContact ? theme.colors.primary : theme.colors.surface,
|
|
24
|
+
borderColor: theme.colors.border,
|
|
25
|
+
borderWidth: isContact ? 0 : StyleSheet.hairlineWidth,
|
|
26
|
+
maxWidth: '80%',
|
|
27
|
+
},
|
|
28
|
+
], children: [message.body.length > 0 && (_jsx(Text, { style: {
|
|
29
|
+
color: isContact ? theme.colors.onPrimary : theme.colors.foreground,
|
|
30
|
+
fontSize: theme.typography.sizeBody,
|
|
31
|
+
}, children: message.body })), attachments.map((a) => (_jsx(AttachmentView, { attachment: a, isContact: isContact, withCaption: message.body.length > 0 }, a.id))), _jsx(MessageBlocks, { blocks: message.blocks, conversationId: conversationId ?? null, messageId: message.id }), _jsx(MessageCanvas, { canvas: message.canvas, conversationId: conversationId ?? null, messageId: message.id })] }) }));
|
|
32
|
+
}
|
|
33
|
+
function AttachmentView(props) {
|
|
34
|
+
const { theme } = useChatly();
|
|
35
|
+
const { attachment, isContact, withCaption } = props;
|
|
36
|
+
const isImage = attachment.mimeType.toLowerCase().startsWith('image/');
|
|
37
|
+
const topMargin = withCaption ? 6 : 0;
|
|
38
|
+
if (isImage) {
|
|
39
|
+
return (_jsx(Image, { source: { uri: attachment.url }, resizeMode: "cover", accessibilityLabel: attachment.filename, style: {
|
|
40
|
+
width: 220,
|
|
41
|
+
height: 180,
|
|
42
|
+
borderRadius: 10,
|
|
43
|
+
marginTop: topMargin,
|
|
44
|
+
} }));
|
|
45
|
+
}
|
|
46
|
+
return (_jsxs(View, { style: [
|
|
47
|
+
styles.fileRow,
|
|
48
|
+
{
|
|
49
|
+
backgroundColor: isContact ? 'rgba(255,255,255,0.15)' : 'rgba(0,0,0,0.04)',
|
|
50
|
+
marginTop: topMargin,
|
|
51
|
+
},
|
|
52
|
+
], children: [_jsx(Text, { style: {
|
|
53
|
+
color: isContact ? theme.colors.onPrimary : theme.colors.foreground,
|
|
54
|
+
fontSize: 13,
|
|
55
|
+
fontWeight: theme.typography.weightMedium,
|
|
56
|
+
flexShrink: 1,
|
|
57
|
+
}, numberOfLines: 1, ellipsizeMode: "middle", children: attachment.filename }), _jsx(Text, { style: {
|
|
58
|
+
color: isContact ? 'rgba(255,255,255,0.75)' : theme.colors.mutedForeground,
|
|
59
|
+
fontSize: 11,
|
|
60
|
+
marginLeft: 8,
|
|
61
|
+
}, children: formatSize(attachment.sizeBytes) })] }));
|
|
62
|
+
}
|
|
63
|
+
function formatSize(bytes) {
|
|
64
|
+
if (bytes < 1024) {
|
|
65
|
+
return `${bytes} B`;
|
|
66
|
+
}
|
|
67
|
+
if (bytes < 1024 * 1024) {
|
|
68
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
69
|
+
}
|
|
70
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
71
|
+
}
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
row: { width: '100%', flexDirection: 'row', marginVertical: 4 },
|
|
74
|
+
rowLeft: { justifyContent: 'flex-start' },
|
|
75
|
+
rowRight: { justifyContent: 'flex-end' },
|
|
76
|
+
bubble: {},
|
|
77
|
+
fileRow: {
|
|
78
|
+
flexDirection: 'row',
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
paddingHorizontal: 8,
|
|
81
|
+
paddingVertical: 6,
|
|
82
|
+
borderRadius: 8,
|
|
83
|
+
},
|
|
84
|
+
systemRow: { width: '100%', alignItems: 'center', marginVertical: 6 },
|
|
85
|
+
systemText: { fontStyle: 'italic' },
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=MessageBubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBubble.js","sourceRoot":"","sources":["../../src/components/MessageBubble.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAehD,MAAM,UAAU,aAAa,CAAC,EAAE,OAAO,EAAE,cAAc,EAAsB;IAC3E,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC;IAC7E,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IAE9C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CACL,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,SAAS,YAC3B,KAAC,IAAI,IACH,KAAK,EAAE;oBACL,MAAM,CAAC,UAAU;oBACjB,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,QAAQ,EAAE,KAAK,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MAAM,EAAE,EAAE;IACV,OAAO,EAAE;QACP,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,iBAAiB,EAAE,CAAC;QACpB,eAAe,EAAE,CAAC;QAClB,YAAY,EAAE,CAAC;KAChB;IACD,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,EAAE;IACrE,UAAU,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBubble.spec.d.ts","sourceRoot":"","sources":["../../src/components/MessageBubble.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The bubble, with rich blocks and a canvas MOUNTED.
|
|
4
|
+
*
|
|
5
|
+
* ── Why the mount is the thing under test ──────────────────────────────
|
|
6
|
+
*
|
|
7
|
+
* A renderer that handles every block type and that nothing mounts passes
|
|
8
|
+
* its own unit test and renders nowhere. That exact pair of defects shipped
|
|
9
|
+
* in this product once already: the agent inbox mounted blocks inside an
|
|
10
|
+
* `if (isNote)` early return so the AI answer the feature exists for never
|
|
11
|
+
* reached it, and the mobile renderer was exported, spec'd, and imported by
|
|
12
|
+
* nothing but its own spec. `check-block-renderer-parity.mjs` asserts the
|
|
13
|
+
* mount literal is in this file and that THIS spec carries a block envelope;
|
|
14
|
+
* it cannot tell which branches a component has, so the assertions below are
|
|
15
|
+
* the half that reads the output.
|
|
16
|
+
*
|
|
17
|
+
* The interactive half matters as much. On the agent app every action is
|
|
18
|
+
* plain text, because an agent has no visitor session; here a tap must reach
|
|
19
|
+
* either the API or the integrator's own code, and `host_event` reaching the
|
|
20
|
+
* app is the single feature this package exists for.
|
|
21
|
+
*/
|
|
22
|
+
import { cleanup, render, screen } from '@testing-library/react';
|
|
23
|
+
import userEvent from '@testing-library/user-event';
|
|
24
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
25
|
+
import { ChatlyContext } from '../ChatlyProvider';
|
|
26
|
+
import { MessageBubble } from './MessageBubble';
|
|
27
|
+
import { defaultTheme } from '../theme/defaultTheme';
|
|
28
|
+
const CONV = 'conv-1';
|
|
29
|
+
/*
|
|
30
|
+
* Explicit, not inherited.
|
|
31
|
+
*
|
|
32
|
+
* `@testing-library/react` auto-cleans only when vitest runs with
|
|
33
|
+
* `globals: true`, which this package does not. Without it each render
|
|
34
|
+
* accumulates in the same document and `getByText` starts failing with
|
|
35
|
+
* "found multiple elements" — which reads as a duplicate-render bug in the
|
|
36
|
+
* component rather than as a missing afterEach. Three tests failed that way
|
|
37
|
+
* before this line existed.
|
|
38
|
+
*/
|
|
39
|
+
afterEach(cleanup);
|
|
40
|
+
function harness(over = {}) {
|
|
41
|
+
const rest = {
|
|
42
|
+
reply: vi.fn().mockResolvedValue({}),
|
|
43
|
+
postback: vi.fn().mockResolvedValue({}),
|
|
44
|
+
reportAction: vi.fn().mockResolvedValue({}),
|
|
45
|
+
requestCanvasStep: vi.fn().mockResolvedValue({}),
|
|
46
|
+
submitCanvas: vi.fn().mockResolvedValue({ canvas: null, errors: {} }),
|
|
47
|
+
};
|
|
48
|
+
const value = {
|
|
49
|
+
theme: defaultTheme,
|
|
50
|
+
rest,
|
|
51
|
+
...over,
|
|
52
|
+
};
|
|
53
|
+
const wrap = (message) => render(_jsx(ChatlyContext.Provider, { value: value, children: _jsx(MessageBubble, { message: message, conversationId: CONV }) }));
|
|
54
|
+
return { rest, wrap };
|
|
55
|
+
}
|
|
56
|
+
const row = (over) => ({
|
|
57
|
+
id: 'm1',
|
|
58
|
+
authorType: 'bot',
|
|
59
|
+
kind: 'text',
|
|
60
|
+
body: 'Here are six hats',
|
|
61
|
+
createdAt: '2026-10-12T00:00:00.000Z',
|
|
62
|
+
...over,
|
|
63
|
+
});
|
|
64
|
+
describe('MessageBubble + blocks', () => {
|
|
65
|
+
it('renders the body and the card beside it', () => {
|
|
66
|
+
const h = harness();
|
|
67
|
+
h.wrap(row({
|
|
68
|
+
blocks: {
|
|
69
|
+
v: 1,
|
|
70
|
+
blocks: [{ type: 'card', title: 'Wool hat', price: { amount: 4820, currency: 'USD' } }],
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
expect(screen.getByText('Here are six hats')).toBeDefined();
|
|
74
|
+
expect(screen.getByText('Wool hat')).toBeDefined();
|
|
75
|
+
// Through the shared formatter: minor units, and the divisor read off the
|
|
76
|
+
// currency rather than assumed to be 100.
|
|
77
|
+
expect(screen.getByText('$48.20')).toBeDefined();
|
|
78
|
+
});
|
|
79
|
+
it('shows a was-price as words, not as a strike-through', () => {
|
|
80
|
+
// RN has no `<s>` and `textDecorationLine` on a nested `Text` is
|
|
81
|
+
// unreliable across the two platforms; "was" reads in a screen reader too.
|
|
82
|
+
const h = harness();
|
|
83
|
+
h.wrap(row({
|
|
84
|
+
blocks: {
|
|
85
|
+
v: 1,
|
|
86
|
+
blocks: [
|
|
87
|
+
{
|
|
88
|
+
type: 'card',
|
|
89
|
+
title: 'Wool hat',
|
|
90
|
+
price: { amount: 4820, currency: 'USD', compareAt: 6000 },
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
}));
|
|
95
|
+
expect(screen.getByText('$48.20 (was $60.00)')).toBeDefined();
|
|
96
|
+
});
|
|
97
|
+
it('hands a host_event to the APP and calls no API', async () => {
|
|
98
|
+
// The feature this package exists for: a native payment sheet cannot be
|
|
99
|
+
// opened from inside a chat library.
|
|
100
|
+
const onAction = vi.fn();
|
|
101
|
+
const h = harness({ onAction });
|
|
102
|
+
h.wrap(row({
|
|
103
|
+
blocks: {
|
|
104
|
+
v: 1,
|
|
105
|
+
blocks: [
|
|
106
|
+
{
|
|
107
|
+
type: 'actions',
|
|
108
|
+
actions: [
|
|
109
|
+
{ kind: 'host_event', label: 'Pay', event: 'pay', id: 'a1', data: { x: 1 } },
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
}));
|
|
115
|
+
await userEvent.click(screen.getByRole('button', { name: 'Pay' }));
|
|
116
|
+
expect(onAction).toHaveBeenCalledWith({
|
|
117
|
+
event: 'pay',
|
|
118
|
+
data: { x: 1 },
|
|
119
|
+
conversationId: CONV,
|
|
120
|
+
messageId: 'm1',
|
|
121
|
+
actionId: 'a1',
|
|
122
|
+
});
|
|
123
|
+
expect(h.rest.reply).not.toHaveBeenCalled();
|
|
124
|
+
expect(h.rest.postback).not.toHaveBeenCalled();
|
|
125
|
+
});
|
|
126
|
+
it('sends a postback through the API, silently when asked', async () => {
|
|
127
|
+
const h = harness();
|
|
128
|
+
h.wrap(row({
|
|
129
|
+
blocks: {
|
|
130
|
+
v: 1,
|
|
131
|
+
blocks: [
|
|
132
|
+
{
|
|
133
|
+
type: 'actions',
|
|
134
|
+
actions: [{ kind: 'postback', label: 'Under $50', value: 'under_50', silent: true }],
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
}));
|
|
139
|
+
await userEvent.click(screen.getByRole('button', { name: 'Under $50' }));
|
|
140
|
+
expect(h.rest.postback).toHaveBeenCalledWith(CONV, { value: 'under_50', silent: true });
|
|
141
|
+
});
|
|
142
|
+
it('sends a quick reply as an ordinary message', async () => {
|
|
143
|
+
const h = harness();
|
|
144
|
+
h.wrap(row({
|
|
145
|
+
blocks: {
|
|
146
|
+
v: 1,
|
|
147
|
+
blocks: [{ type: 'quick_replies', options: [{ label: 'Under $50', value: 'under_50' }] }],
|
|
148
|
+
},
|
|
149
|
+
}));
|
|
150
|
+
await userEvent.click(screen.getByRole('button', { name: 'Under $50' }));
|
|
151
|
+
expect(h.rest.reply).toHaveBeenCalledWith(CONV, 'under_50');
|
|
152
|
+
});
|
|
153
|
+
it('renders a carousel as a scrollable row of every card', () => {
|
|
154
|
+
const h = harness();
|
|
155
|
+
h.wrap(row({
|
|
156
|
+
blocks: {
|
|
157
|
+
v: 1,
|
|
158
|
+
blocks: [
|
|
159
|
+
{
|
|
160
|
+
type: 'card_grid',
|
|
161
|
+
layout: 'carousel',
|
|
162
|
+
cards: [{ title: 'One' }, { title: 'Two' }, { title: 'Three' }],
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
}));
|
|
167
|
+
expect(screen.getByLabelText('Scrollable options')).toBeDefined();
|
|
168
|
+
for (const title of ['One', 'Two', 'Three']) {
|
|
169
|
+
expect(screen.getByText(title)).toBeDefined();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
it('renders a status line — unlike the agent app, which skips it', () => {
|
|
173
|
+
// There it is "progress, not content" for somebody reading history. Here
|
|
174
|
+
// the shopper is watching it happen.
|
|
175
|
+
const h = harness();
|
|
176
|
+
h.wrap(row({ blocks: { v: 1, blocks: [{ type: 'status', id: 's1', text: 'Looking…' }] } }));
|
|
177
|
+
expect(screen.getByText('Looking…')).toBeDefined();
|
|
178
|
+
});
|
|
179
|
+
it('drops an unsafe card image and keeps the card', () => {
|
|
180
|
+
const h = harness();
|
|
181
|
+
h.wrap(row({
|
|
182
|
+
blocks: {
|
|
183
|
+
v: 1,
|
|
184
|
+
blocks: [{ type: 'card', title: 'Wool hat', image: 'javascript:alert(1)' }],
|
|
185
|
+
},
|
|
186
|
+
}));
|
|
187
|
+
expect(screen.getByText('Wool hat')).toBeDefined();
|
|
188
|
+
expect(screen.queryByRole('img')).toBeNull();
|
|
189
|
+
});
|
|
190
|
+
it('renders nothing extra for a message with no blocks', () => {
|
|
191
|
+
const h = harness();
|
|
192
|
+
h.wrap(row({}));
|
|
193
|
+
expect(screen.getByText('Here are six hats')).toBeDefined();
|
|
194
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
195
|
+
});
|
|
196
|
+
it('renders a system line WITHOUT blocks — a system message is never a card', () => {
|
|
197
|
+
const h = harness();
|
|
198
|
+
h.wrap(row({
|
|
199
|
+
authorType: 'system',
|
|
200
|
+
body: 'Buyer support is taking over from here.',
|
|
201
|
+
blocks: { v: 1, blocks: [{ type: 'card', title: 'Should not render' }] },
|
|
202
|
+
}));
|
|
203
|
+
expect(screen.getByText('Buyer support is taking over from here.')).toBeDefined();
|
|
204
|
+
expect(screen.queryByText('Should not render')).toBeNull();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
//# sourceMappingURL=MessageBubble.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBubble.spec.js","sourceRoot":"","sources":["../../src/components/MessageBubble.spec.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAKrD,MAAM,IAAI,GAAG,QAAQ,CAAC;AAEtB;;;;;;;;;GASG;AACH,SAAS,CAAC,OAAO,CAAC,CAAC;AAEnB,SAAS,OAAO,CAAC,OAAsD,EAAE;IACvE,MAAM,IAAI,GAAG;QACX,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACpC,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACvC,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3C,iBAAiB,EAAE,EAAE,CAAC,E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AI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAChB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5D,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC,IAAI,CACJ,GAAG,CAAC;YACF,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,yCAAyC;YAC/C,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,EAAE;SACzE,CAAC,CACH,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAClF,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Tier 2 canvas on a native screen — a form inside a message bubble.
|
|
3
|
+
*
|
|
4
|
+
* ── What it is for ────────────────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* A confirm step: the total is quoted, the shopper confirms, the server
|
|
7
|
+
* re-quotes and refuses if it moved. The price guard is the server-held
|
|
8
|
+
* `state`, which is why submission goes back through the API rather than
|
|
9
|
+
* being resolved here.
|
|
10
|
+
*
|
|
11
|
+
* ── Two properties worth stating ──────────────────────────────────────
|
|
12
|
+
*
|
|
13
|
+
* The canvas on screen is REPLACED by whatever the submission returns, not
|
|
14
|
+
* merged. A refused submission comes back as the same canvas with messages on
|
|
15
|
+
* it, and a changed total comes back as a FRESH step rather than a charge —
|
|
16
|
+
* so a renderer that kept its own copy would show the shopper the old price
|
|
17
|
+
* next to the new errors.
|
|
18
|
+
*
|
|
19
|
+
* A `hostEvent` on the answer is handed to the app. That is how 3-D Secure
|
|
20
|
+
* works on a phone: the step's answer says "now run this", the app runs it
|
|
21
|
+
* natively, and nothing in this library has to know what Stripe is.
|
|
22
|
+
*
|
|
23
|
+
* ── Tier 3 is deliberately not rendered ───────────────────────────────
|
|
24
|
+
*
|
|
25
|
+
* An `app` canvas is an integrator's own page in a sandboxed iframe, and
|
|
26
|
+
* there is no React Native equivalent of a sandbox attribute — an app frame
|
|
27
|
+
* here would be a WebView, which is the thing a native SDK exists to avoid.
|
|
28
|
+
* The title and a one-line explanation are shown instead, and the integrator
|
|
29
|
+
* can present it natively if they want to.
|
|
30
|
+
*/
|
|
31
|
+
import React from 'react';
|
|
32
|
+
export interface MessageCanvasProps {
|
|
33
|
+
/** The stored canvas, straight off the message row. Unvalidated. */
|
|
34
|
+
readonly canvas: unknown;
|
|
35
|
+
readonly conversationId: string | null;
|
|
36
|
+
readonly messageId: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function MessageCanvas(props: MessageCanvasProps): React.JSX.Element | null;
|
|
39
|
+
//# sourceMappingURL=MessageCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageCanvas.d.ts","sourceRoot":"","sources":["../../src/components/MessageCanvas.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAA4B,MAAM,OAAO,CAAC;AASjD,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAUD,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAkMjF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A Tier 2 canvas on a native screen — a form inside a message bubble.
|
|
4
|
+
*
|
|
5
|
+
* ── What it is for ────────────────────────────────────────────────────
|
|
6
|
+
*
|
|
7
|
+
* A confirm step: the total is quoted, the shopper confirms, the server
|
|
8
|
+
* re-quotes and refuses if it moved. The price guard is the server-held
|
|
9
|
+
* `state`, which is why submission goes back through the API rather than
|
|
10
|
+
* being resolved here.
|
|
11
|
+
*
|
|
12
|
+
* ── Two properties worth stating ──────────────────────────────────────
|
|
13
|
+
*
|
|
14
|
+
* The canvas on screen is REPLACED by whatever the submission returns, not
|
|
15
|
+
* merged. A refused submission comes back as the same canvas with messages on
|
|
16
|
+
* it, and a changed total comes back as a FRESH step rather than a charge —
|
|
17
|
+
* so a renderer that kept its own copy would show the shopper the old price
|
|
18
|
+
* next to the new errors.
|
|
19
|
+
*
|
|
20
|
+
* A `hostEvent` on the answer is handed to the app. That is how 3-D Secure
|
|
21
|
+
* works on a phone: the step's answer says "now run this", the app runs it
|
|
22
|
+
* natively, and nothing in this library has to know what Stripe is.
|
|
23
|
+
*
|
|
24
|
+
* ── Tier 3 is deliberately not rendered ───────────────────────────────
|
|
25
|
+
*
|
|
26
|
+
* An `app` canvas is an integrator's own page in a sandboxed iframe, and
|
|
27
|
+
* there is no React Native equivalent of a sandbox attribute — an app frame
|
|
28
|
+
* here would be a WebView, which is the thing a native SDK exists to avoid.
|
|
29
|
+
* The title and a one-line explanation are shown instead, and the integrator
|
|
30
|
+
* can present it natively if they want to.
|
|
31
|
+
*/
|
|
32
|
+
import { useMemo, useState } from 'react';
|
|
33
|
+
import { Pressable, Text, TextInput, View } from 'react-native';
|
|
34
|
+
import { readCanvas } from '../blocks/read-envelope';
|
|
35
|
+
import { useChatly } from '../useChatly';
|
|
36
|
+
import { MessageBlocks } from './MessageBlocks';
|
|
37
|
+
/** The value a field starts with, as a string the input can hold. */
|
|
38
|
+
function initialValue(field) {
|
|
39
|
+
if (field.type === 'checkbox') {
|
|
40
|
+
return field.value === true ? 'true' : '';
|
|
41
|
+
}
|
|
42
|
+
return field.value ?? '';
|
|
43
|
+
}
|
|
44
|
+
export function MessageCanvas(props) {
|
|
45
|
+
const { theme, rest, onAction } = useChatly();
|
|
46
|
+
const initial = useMemo(() => readCanvas(props.canvas), [props.canvas]);
|
|
47
|
+
/**
|
|
48
|
+
* The canvas is STATE, seeded from the prop.
|
|
49
|
+
*
|
|
50
|
+
* A submission returns the next canvas — or the same one with errors — and
|
|
51
|
+
* that answer has to win over the message row this component was handed,
|
|
52
|
+
* because the row only catches up when the realtime `message.updated`
|
|
53
|
+
* arrives. Rendering the prop would flash the pre-submission step back onto
|
|
54
|
+
* the screen in between.
|
|
55
|
+
*/
|
|
56
|
+
const [canvas, setCanvas] = useState(initial);
|
|
57
|
+
const [values, setValues] = useState(() => Object.fromEntries((initial?.fields ?? []).map((f) => [f.name, initialValue(f)])));
|
|
58
|
+
const [errors, setErrors] = useState({});
|
|
59
|
+
const [busy, setBusy] = useState(false);
|
|
60
|
+
if (canvas === null) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const submit = (actionId, kind) => {
|
|
64
|
+
const conversationId = props.conversationId;
|
|
65
|
+
if (conversationId === null || busy) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setBusy(true);
|
|
69
|
+
void rest
|
|
70
|
+
.submitCanvas(conversationId, {
|
|
71
|
+
messageId: props.messageId,
|
|
72
|
+
actionId,
|
|
73
|
+
// Checkboxes go as booleans; everything else as the string typed.
|
|
74
|
+
values: Object.fromEntries((canvas.fields ?? []).map((f) => [
|
|
75
|
+
f.name,
|
|
76
|
+
f.type === 'checkbox' ? values[f.name] === 'true' : (values[f.name] ?? ''),
|
|
77
|
+
])),
|
|
78
|
+
})
|
|
79
|
+
.then((answer) => {
|
|
80
|
+
const next = readCanvas(answer.canvas);
|
|
81
|
+
if (next !== null) {
|
|
82
|
+
setCanvas(next);
|
|
83
|
+
setValues(Object.fromEntries((next.fields ?? []).map((f) => [f.name, initialValue(f)])));
|
|
84
|
+
}
|
|
85
|
+
setErrors(answer.errors);
|
|
86
|
+
const hostEvent = answer.hostEvent;
|
|
87
|
+
if (hostEvent?.event !== undefined) {
|
|
88
|
+
// 3-D Secure, a native screen, whatever the integrator needs. The
|
|
89
|
+
// step asked; the app does it.
|
|
90
|
+
onAction?.({
|
|
91
|
+
event: hostEvent.event,
|
|
92
|
+
data: hostEvent.data ?? {},
|
|
93
|
+
conversationId,
|
|
94
|
+
messageId: props.messageId,
|
|
95
|
+
actionId,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
.catch(() => {
|
|
100
|
+
// A failed submit must leave the form usable. The shopper can retry,
|
|
101
|
+
// and the server is the only thing that can settle the price.
|
|
102
|
+
setErrors({ _: 'That did not go through. Try again.' });
|
|
103
|
+
})
|
|
104
|
+
.finally(() => setBusy(false));
|
|
105
|
+
if (kind === 'cancel') {
|
|
106
|
+
setErrors({});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const label = { color: theme.colors.foreground, fontSize: theme.typography.sizeSmall };
|
|
110
|
+
return (_jsxs(View, { accessibilityLabel: canvas.title ?? 'Step', style: {
|
|
111
|
+
borderWidth: 1,
|
|
112
|
+
borderColor: theme.colors.border,
|
|
113
|
+
borderRadius: theme.radius.bubble,
|
|
114
|
+
backgroundColor: theme.colors.surface,
|
|
115
|
+
padding: theme.spacing.sm,
|
|
116
|
+
marginTop: 6,
|
|
117
|
+
gap: 6,
|
|
118
|
+
}, children: [canvas.title !== undefined && (_jsx(Text, { style: { color: theme.colors.foreground, fontSize: theme.typography.sizeTitle }, children: canvas.title })), canvas.blocks !== undefined && canvas.blocks.length > 0 && (_jsx(MessageBlocks, { blocks: { v: 1, blocks: canvas.blocks }, conversationId: props.conversationId, messageId: props.messageId })), canvas.app !== undefined && (_jsx(Text, { style: { color: theme.colors.mutedForeground, fontSize: theme.typography.sizeSmall }, children: `${canvas.app.title ?? 'This step'} opens outside the chat.` })), (canvas.fields ?? []).map((f) => (_jsxs(View, { style: { gap: 2 }, children: [_jsx(Text, { style: label, children: f.required === true ? `${f.label} *` : f.label }), f.type === 'checkbox' ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: f.label, onPress: () => setValues((v) => ({ ...v, [f.name]: v[f.name] === 'true' ? '' : 'true' })), children: _jsx(Text, { style: label, children: values[f.name] === 'true' ? 'Yes' : 'No' }) })) : (_jsx(TextInput, { accessibilityLabel: f.label, value: values[f.name] ?? '', placeholder: 'placeholder' in f ? f.placeholder : undefined, editable: !busy, onChangeText: (text) => setValues((v) => ({ ...v, [f.name]: text })), style: {
|
|
119
|
+
borderWidth: 1,
|
|
120
|
+
borderColor: theme.colors.border,
|
|
121
|
+
borderRadius: theme.radius.md,
|
|
122
|
+
paddingHorizontal: theme.spacing.sm,
|
|
123
|
+
paddingVertical: 6,
|
|
124
|
+
color: theme.colors.foreground,
|
|
125
|
+
} })), errors[f.name] !== undefined && (_jsx(Text, { style: { color: theme.colors.danger, fontSize: theme.typography.sizeSmall }, children: errors[f.name] }))] }, f.name))), errors['_'] !== undefined && (_jsx(Text, { style: { color: theme.colors.danger, fontSize: theme.typography.sizeSmall }, children: errors['_'] })), (canvas.actions ?? []).length > 0 && (_jsx(View, { style: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 }, children: (canvas.actions ?? []).map((a) => (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: a.label, disabled: busy, onPress: () => submit(a.id, a.kind), style: {
|
|
126
|
+
borderRadius: theme.radius.md,
|
|
127
|
+
paddingHorizontal: theme.spacing.md,
|
|
128
|
+
paddingVertical: theme.spacing.sm,
|
|
129
|
+
backgroundColor: a.style === 'primary'
|
|
130
|
+
? theme.colors.primary
|
|
131
|
+
: a.style === 'danger'
|
|
132
|
+
? theme.colors.danger
|
|
133
|
+
: theme.colors.surface,
|
|
134
|
+
borderColor: theme.colors.border,
|
|
135
|
+
borderWidth: a.style === undefined || a.style === 'secondary' ? 1 : 0,
|
|
136
|
+
opacity: busy ? 0.6 : 1,
|
|
137
|
+
}, children: _jsx(Text, { style: {
|
|
138
|
+
color: a.style === 'primary' || a.style === 'danger'
|
|
139
|
+
? theme.colors.onPrimary
|
|
140
|
+
: theme.colors.foreground,
|
|
141
|
+
fontSize: theme.typography.sizeBody,
|
|
142
|
+
}, children: a.label }) }, a.id))) }))] }));
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=MessageCanvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageCanvas.js","sourceRoot":"","sources":["../../src/components/MessageCanvas.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAWhD,qEAAqE;AACrE,SAAS,YAAY,CAAC,KAAkB;IACtC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;AAC3B,CA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