@chatlychat/react-native 0.0.0-stage → 0.1.0
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 +50 -4
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ActivityIndicator, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native';
|
|
4
|
+
import { useChatly } from '../useChatly';
|
|
5
|
+
export function Composer({ conversationId, onSent, placeholder = 'Type a message…', }) {
|
|
6
|
+
const { rest, theme } = useChatly();
|
|
7
|
+
const [value, setValue] = useState('');
|
|
8
|
+
const [sending, setSending] = useState(false);
|
|
9
|
+
const [uploading, setUploading] = useState(false);
|
|
10
|
+
const [staged, setStaged] = useState([]);
|
|
11
|
+
const send = async () => {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if ((trimmed.length === 0 && staged.length === 0) || sending) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
setSending(true);
|
|
17
|
+
try {
|
|
18
|
+
const attachments = staged.length > 0 ? staged : undefined;
|
|
19
|
+
if (conversationId === null) {
|
|
20
|
+
const res = await rest.start(trimmed, attachments);
|
|
21
|
+
onSent?.(res.conversation.id);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
await rest.reply(conversationId, trimmed, attachments);
|
|
25
|
+
onSent?.(conversationId);
|
|
26
|
+
}
|
|
27
|
+
setValue('');
|
|
28
|
+
setStaged([]);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Non-fatal: leave the input populated so the user can retry.
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setSending(false);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const attach = async () => {
|
|
38
|
+
const picker = globalThis.__chatlyPicker;
|
|
39
|
+
if (picker === undefined) {
|
|
40
|
+
// No picker installed — silently no-op so the host doesn't crash. Hosts
|
|
41
|
+
// can detect this by checking `globalThis.__chatlyPicker` themselves.
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (uploading) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setUploading(true);
|
|
48
|
+
try {
|
|
49
|
+
const picked = await picker();
|
|
50
|
+
if (picked === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const attachment = await rest.uploadAttachment({
|
|
54
|
+
bytes: picked.bytes,
|
|
55
|
+
filename: picked.filename,
|
|
56
|
+
mimeType: picked.mimeType,
|
|
57
|
+
});
|
|
58
|
+
setStaged((prev) => [...prev, attachment]);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// No-op; the user can retry.
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
setUploading(false);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const removeStaged = (id) => {
|
|
68
|
+
setStaged((prev) => prev.filter((a) => a.id !== id));
|
|
69
|
+
};
|
|
70
|
+
const sendDisabled = sending || (value.trim().length === 0 && staged.length === 0);
|
|
71
|
+
return (_jsxs(View, { style: [
|
|
72
|
+
styles.column,
|
|
73
|
+
{
|
|
74
|
+
borderTopColor: theme.colors.border,
|
|
75
|
+
backgroundColor: theme.colors.background,
|
|
76
|
+
padding: theme.spacing.sm,
|
|
77
|
+
},
|
|
78
|
+
], children: [(staged.length > 0 || uploading) && (_jsxs(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, style: styles.chipScroll, contentContainerStyle: styles.chipRow, children: [uploading && (_jsxs(View, { style: [
|
|
79
|
+
styles.chip,
|
|
80
|
+
{
|
|
81
|
+
backgroundColor: theme.colors.surface,
|
|
82
|
+
borderColor: theme.colors.border,
|
|
83
|
+
borderRadius: theme.radius.md,
|
|
84
|
+
},
|
|
85
|
+
], children: [_jsx(ActivityIndicator, { color: theme.colors.primary, size: "small" }), _jsx(Text, { style: {
|
|
86
|
+
color: theme.colors.foreground,
|
|
87
|
+
fontSize: theme.typography.sizeSmall,
|
|
88
|
+
marginLeft: 6,
|
|
89
|
+
}, children: "Uploading\u2026" })] })), staged.map((a) => (_jsxs(View, { style: [
|
|
90
|
+
styles.chip,
|
|
91
|
+
{
|
|
92
|
+
backgroundColor: theme.colors.surface,
|
|
93
|
+
borderColor: theme.colors.border,
|
|
94
|
+
borderRadius: theme.radius.md,
|
|
95
|
+
},
|
|
96
|
+
], children: [_jsx(Text, { style: {
|
|
97
|
+
color: theme.colors.foreground,
|
|
98
|
+
fontSize: theme.typography.sizeSmall,
|
|
99
|
+
maxWidth: 140,
|
|
100
|
+
}, numberOfLines: 1, ellipsizeMode: "middle", children: a.filename }), _jsx(Pressable, { onPress: () => removeStaged(a.id), accessibilityRole: "button", accessibilityLabel: "Remove attachment", style: styles.removeBtn, children: _jsx(Text, { style: { color: theme.colors.mutedForeground }, children: "\u00D7" }) })] }, a.id)))] })), _jsxs(View, { style: styles.row, children: [_jsx(Pressable, { onPress: attach, disabled: uploading || sending, accessibilityRole: "button", accessibilityLabel: "Attach a file", style: ({ pressed }) => [
|
|
101
|
+
styles.attach,
|
|
102
|
+
{
|
|
103
|
+
opacity: pressed || uploading ? 0.6 : 1,
|
|
104
|
+
marginRight: theme.spacing.sm,
|
|
105
|
+
},
|
|
106
|
+
], children: uploading ? (_jsx(ActivityIndicator, { color: theme.colors.primary })) : (_jsx(Text, { style: {
|
|
107
|
+
color: theme.colors.primary,
|
|
108
|
+
fontSize: theme.typography.sizeBody + 6,
|
|
109
|
+
fontWeight: theme.typography.weightMedium,
|
|
110
|
+
}, children: "+" })) }), _jsx(TextInput, { value: value, onChangeText: setValue, placeholder: placeholder, placeholderTextColor: theme.colors.mutedForeground, multiline: true, editable: !sending, style: [
|
|
111
|
+
styles.input,
|
|
112
|
+
{
|
|
113
|
+
color: theme.colors.foreground,
|
|
114
|
+
backgroundColor: theme.colors.surface,
|
|
115
|
+
borderColor: theme.colors.border,
|
|
116
|
+
borderRadius: theme.radius.md,
|
|
117
|
+
paddingHorizontal: theme.spacing.md,
|
|
118
|
+
paddingVertical: theme.spacing.sm,
|
|
119
|
+
fontSize: theme.typography.sizeBody,
|
|
120
|
+
},
|
|
121
|
+
] }), _jsx(Pressable, { onPress: send, disabled: sendDisabled, accessibilityRole: "button", accessibilityLabel: "Send message", style: ({ pressed }) => [
|
|
122
|
+
styles.send,
|
|
123
|
+
{
|
|
124
|
+
backgroundColor: theme.colors.primary,
|
|
125
|
+
borderRadius: theme.radius.md,
|
|
126
|
+
paddingHorizontal: theme.spacing.md,
|
|
127
|
+
paddingVertical: theme.spacing.sm,
|
|
128
|
+
opacity: pressed || sendDisabled ? 0.6 : 1,
|
|
129
|
+
marginLeft: theme.spacing.sm,
|
|
130
|
+
},
|
|
131
|
+
], children: sending ? (_jsx(ActivityIndicator, { color: theme.colors.onPrimary })) : (_jsx(Text, { style: {
|
|
132
|
+
color: theme.colors.onPrimary,
|
|
133
|
+
fontWeight: theme.typography.weightMedium,
|
|
134
|
+
fontSize: theme.typography.sizeBody,
|
|
135
|
+
}, children: "Send" })) })] })] }));
|
|
136
|
+
}
|
|
137
|
+
const styles = StyleSheet.create({
|
|
138
|
+
column: {
|
|
139
|
+
flexDirection: 'column',
|
|
140
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
141
|
+
},
|
|
142
|
+
row: {
|
|
143
|
+
flexDirection: 'row',
|
|
144
|
+
alignItems: 'flex-end',
|
|
145
|
+
},
|
|
146
|
+
chipScroll: { marginBottom: 6 },
|
|
147
|
+
chipRow: { alignItems: 'center', paddingVertical: 2 },
|
|
148
|
+
chip: {
|
|
149
|
+
flexDirection: 'row',
|
|
150
|
+
alignItems: 'center',
|
|
151
|
+
paddingHorizontal: 10,
|
|
152
|
+
paddingVertical: 4,
|
|
153
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
154
|
+
marginRight: 6,
|
|
155
|
+
},
|
|
156
|
+
removeBtn: {
|
|
157
|
+
marginLeft: 6,
|
|
158
|
+
paddingHorizontal: 4,
|
|
159
|
+
minWidth: 16,
|
|
160
|
+
alignItems: 'center',
|
|
161
|
+
},
|
|
162
|
+
attach: {
|
|
163
|
+
height: 40,
|
|
164
|
+
width: 40,
|
|
165
|
+
alignItems: 'center',
|
|
166
|
+
justifyContent: 'center',
|
|
167
|
+
},
|
|
168
|
+
input: {
|
|
169
|
+
flex: 1,
|
|
170
|
+
minHeight: 40,
|
|
171
|
+
maxHeight: 120,
|
|
172
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
173
|
+
},
|
|
174
|
+
send: {
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
justifyContent: 'center',
|
|
177
|
+
minHeight: 40,
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=Composer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Composer.js","sourceRoot":"","sources":["../../src/components/Composer.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,UAAU,EACV,IAAI,EACJ,SAAS,EACT,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAqCzC,MAAM,UAAU,QAAQ,CAAC,EACvB,cAAc,EACd,MAAM,EACN,WAAW,GAAG,iBAAiB,GACjB;IACd,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;IACpC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAe,EAAE,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;QACrC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;YAC7D,OAAO;QACT,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,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AAK;QACpB,UAAU,EAAE,UAAU;KACvB;IACD,UAAU,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE;IAC/B,OAAO,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE;IACrD,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE,CAAC;QAClB,WAAW,EAAE,UAAU,CAAC,aAAa;QACrC,WAAW,EAAE,CAAC;KACf;IACD,SAAS,EAAE;QACT,UAAU,EAAE,CAAC;QACb,iBAAiB,EAAE,CAAC;QACpB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,QAAQ;KACrB;IACD,MAAM,EAAE;QACN,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,UAAU,CAAC,aAAa;KACtC;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,SAAS,EAAE,EAAE;KACd;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface HelpCenterProps {
|
|
3
|
+
/** Initial query to seed the search box. */
|
|
4
|
+
initialQuery?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Renders a KB search box, a result list, and an article reader. We do not
|
|
8
|
+
* pull in a markdown renderer (would add a non-RN-primitive dep); instead we
|
|
9
|
+
* display the plaintext `body` field. Consumers who want rich rendering can
|
|
10
|
+
* embed their own renderer by re-using `useChatly().rest.getKbArticle`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function HelpCenter({ initialQuery }: HelpCenterProps): React.JSX.Element;
|
|
13
|
+
//# sourceMappingURL=HelpCenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelpCenter.d.ts","sourceRoot":"","sources":["../../src/components/HelpCenter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAiBhE,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,YAAiB,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAkKpF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { ActivityIndicator, FlatList, Pressable, ScrollView, StyleSheet, Text, TextInput, View, } from 'react-native';
|
|
4
|
+
import { useChatly } from '../useChatly';
|
|
5
|
+
/**
|
|
6
|
+
* Renders a KB search box, a result list, and an article reader. We do not
|
|
7
|
+
* pull in a markdown renderer (would add a non-RN-primitive dep); instead we
|
|
8
|
+
* display the plaintext `body` field. Consumers who want rich rendering can
|
|
9
|
+
* embed their own renderer by re-using `useChatly().rest.getKbArticle`.
|
|
10
|
+
*/
|
|
11
|
+
export function HelpCenter({ initialQuery = '' }) {
|
|
12
|
+
const { rest, theme } = useChatly();
|
|
13
|
+
const [query, setQuery] = useState(initialQuery);
|
|
14
|
+
const [results, setResults] = useState([]);
|
|
15
|
+
const [article, setArticle] = useState(null);
|
|
16
|
+
const [loading, setLoading] = useState(false);
|
|
17
|
+
const runSearch = useCallback(async (q) => {
|
|
18
|
+
if (q.trim().length === 0) {
|
|
19
|
+
setResults([]);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setLoading(true);
|
|
23
|
+
try {
|
|
24
|
+
const res = await rest.searchKb(q.trim());
|
|
25
|
+
setResults(res.results);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
setResults([]);
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
setLoading(false);
|
|
32
|
+
}
|
|
33
|
+
}, [rest]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const handle = setTimeout(() => {
|
|
36
|
+
void runSearch(query);
|
|
37
|
+
}, 200);
|
|
38
|
+
return () => clearTimeout(handle);
|
|
39
|
+
}, [query, runSearch]);
|
|
40
|
+
const openArticle = useCallback(async (slug) => {
|
|
41
|
+
setLoading(true);
|
|
42
|
+
try {
|
|
43
|
+
const res = await rest.getKbArticle(slug);
|
|
44
|
+
setArticle(res.article);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
}, [rest]);
|
|
50
|
+
if (article !== null) {
|
|
51
|
+
return (_jsxs(View, { style: [styles.container, { backgroundColor: theme.colors.background }], children: [_jsx(Pressable, { onPress: () => setArticle(null), accessibilityRole: "button", accessibilityLabel: "Back to results", style: { padding: theme.spacing.md }, children: _jsx(Text, { style: { color: theme.colors.primary, fontSize: theme.typography.sizeBody }, children: "\u2190 Back" }) }), _jsxs(ScrollView, { contentContainerStyle: { padding: theme.spacing.lg }, children: [_jsx(Text, { style: {
|
|
52
|
+
color: theme.colors.foreground,
|
|
53
|
+
fontSize: theme.typography.sizeTitle,
|
|
54
|
+
fontWeight: theme.typography.weightBold,
|
|
55
|
+
marginBottom: theme.spacing.md,
|
|
56
|
+
}, children: article.title }), _jsx(Text, { style: {
|
|
57
|
+
color: theme.colors.foreground,
|
|
58
|
+
fontSize: theme.typography.sizeBody,
|
|
59
|
+
lineHeight: theme.typography.sizeBody * 1.5,
|
|
60
|
+
}, children: article.body })] })] }));
|
|
61
|
+
}
|
|
62
|
+
const renderItem = ({ item }) => (_jsxs(Pressable, { onPress: () => void openArticle(item.slug), accessibilityRole: "button", accessibilityLabel: `Open article ${item.title}`, style: ({ pressed }) => [
|
|
63
|
+
{
|
|
64
|
+
padding: theme.spacing.md,
|
|
65
|
+
backgroundColor: pressed ? theme.colors.surface : theme.colors.background,
|
|
66
|
+
borderBottomColor: theme.colors.border,
|
|
67
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
68
|
+
},
|
|
69
|
+
], children: [_jsx(Text, { style: {
|
|
70
|
+
color: theme.colors.foreground,
|
|
71
|
+
fontWeight: theme.typography.weightMedium,
|
|
72
|
+
fontSize: theme.typography.sizeBody,
|
|
73
|
+
}, children: item.title }), _jsx(Text, { style: {
|
|
74
|
+
color: theme.colors.mutedForeground,
|
|
75
|
+
fontSize: theme.typography.sizeSmall,
|
|
76
|
+
marginTop: 2,
|
|
77
|
+
}, numberOfLines: 2, children: item.excerpt })] }));
|
|
78
|
+
return (_jsxs(View, { style: [styles.container, { backgroundColor: theme.colors.background }], children: [_jsx(View, { style: { padding: theme.spacing.md }, children: _jsx(TextInput, { value: query, onChangeText: setQuery, placeholder: "Search help articles\u2026", placeholderTextColor: theme.colors.mutedForeground, style: {
|
|
79
|
+
color: theme.colors.foreground,
|
|
80
|
+
backgroundColor: theme.colors.surface,
|
|
81
|
+
borderColor: theme.colors.border,
|
|
82
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
83
|
+
borderRadius: theme.radius.md,
|
|
84
|
+
paddingHorizontal: theme.spacing.md,
|
|
85
|
+
paddingVertical: theme.spacing.sm,
|
|
86
|
+
fontSize: theme.typography.sizeBody,
|
|
87
|
+
} }) }), loading ? (_jsx(ActivityIndicator, { color: theme.colors.primary, style: { marginTop: theme.spacing.lg } })) : (_jsx(FlatList, { data: results, keyExtractor: (r) => r.id, renderItem: renderItem, ListEmptyComponent: _jsx(Text, { style: {
|
|
88
|
+
color: theme.colors.mutedForeground,
|
|
89
|
+
textAlign: 'center',
|
|
90
|
+
padding: theme.spacing.lg,
|
|
91
|
+
}, children: query.trim().length === 0 ? 'Type to search.' : 'No results.' }) }))] }));
|
|
92
|
+
}
|
|
93
|
+
const styles = StyleSheet.create({
|
|
94
|
+
container: { flex: 1 },
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=HelpCenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HelpCenter.js","sourceRoot":"","sources":["../../src/components/HelpCenter.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,QAAQ,EAER,SAAS,EACT,UAAU,EACV,UAAU,EACV,IAAI,EACJ,SAAS,EACT,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,YAAY,GAAG,EAAE,EAAmB;IAC/D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;IACpC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAa,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAC;IAC/D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,WAAW,CAC3B,KAAK,EAAE,CAAS,EAAiB,EAAE;QACjC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,UAAU,CAAC,EAAE,CAAC,CAAC;YACf,OAAO;QACT,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAA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,aAAa;wBACrC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE;wBAC7B,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;wBACnC,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;wBACjC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ;qBACpC,GACD,GACG,EACN,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,iBAAiB,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,GAAI,CAC3F,CAAC,CAAC,CAAC,CACF,KAAC,QAAQ,IACP,IAAI,EAAE,OAAO,EACb,YAAY,EAAE,CAAC,CAAC,EAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EACjC,UAAU,EAAE,UAAU,EACtB,kBAAkB,EAChB,KAAC,IAAI,IACH,KAAK,EAAE;wBACL,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe;wBACnC,SAAS,EAAE,QAAQ;wBACnB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;qBAC1B,YAEA,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,GACzD,GAET,CACH,IACI,CACR,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich blocks on a native screen — INTERACTIVE, unlike the agent app's.
|
|
3
|
+
*
|
|
4
|
+
* ── What makes this one different ──────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* `apps/mobile-agent`'s renderer draws every action as plain text, because an
|
|
7
|
+
* agent on their phone has no visitor session to act as. This one is the
|
|
8
|
+
* visitor's own app, so a button is a button: a `postback` sends a reply, a
|
|
9
|
+
* `url` opens a link, a `step` asks for a canvas, and a `host_event` is handed
|
|
10
|
+
* to the APP.
|
|
11
|
+
*
|
|
12
|
+
* `host_event` is the whole reason the spec asked for this package. A card
|
|
13
|
+
* saying "Pay $48.20" has to run Stripe with the buyer's real session, and on
|
|
14
|
+
* a phone that means a native payment sheet — not a WebView, not a browser
|
|
15
|
+
* hop. So the action does nothing here and calls `onAction` from the
|
|
16
|
+
* provider, which is the integrator's own code.
|
|
17
|
+
*
|
|
18
|
+
* ── A carousel is a horizontal ScrollView, a grid is a stack ───────────
|
|
19
|
+
*
|
|
20
|
+
* Never two columns. Two cards at 160px on a phone are narrower than the
|
|
21
|
+
* images they carry, which is the same call `apps/mobile-agent` made. A
|
|
22
|
+
* `carousel` layout is honoured because it is horizontal rather than narrow:
|
|
23
|
+
* each card gets most of the width and the row scrolls.
|
|
24
|
+
*
|
|
25
|
+
* ── `status` is rendered here, and skipped in the agent app ────────────
|
|
26
|
+
*
|
|
27
|
+
* There it is "progress, not content" for somebody reading history. Here the
|
|
28
|
+
* shopper is watching it happen — "Looking through the shop…" patched to
|
|
29
|
+
* "Found 6" is the feedback that stops them tapping again.
|
|
30
|
+
*/
|
|
31
|
+
import React from 'react';
|
|
32
|
+
export interface MessageBlocksProps {
|
|
33
|
+
/** The stored envelope, straight off the message row. Unvalidated. */
|
|
34
|
+
readonly blocks: unknown;
|
|
35
|
+
/** The conversation the blocks belong to, for `reportAction` and postbacks. */
|
|
36
|
+
readonly conversationId: string | null;
|
|
37
|
+
/** The message they are on, for the same reason. */
|
|
38
|
+
readonly messageId: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function MessageBlocks(props: MessageBlocksProps): React.JSX.Element | null;
|
|
41
|
+
//# sourceMappingURL=MessageBlocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBlocks.d.ts","sourceRoot":"","sources":["../../src/components/MessageBlocks.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AA8OD,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAuEjF"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Image, Linking, Pressable, ScrollView, Text, View } from 'react-native';
|
|
3
|
+
import { formatMoney } from '../blocks/money';
|
|
4
|
+
import { readBlocksEnvelope } from '../blocks/read-envelope';
|
|
5
|
+
import { useChatly } from '../useChatly';
|
|
6
|
+
/**
|
|
7
|
+
* The price.
|
|
8
|
+
*
|
|
9
|
+
* ONE line of text rather than a struck-through was-price beside it: React
|
|
10
|
+
* Native has no `<s>`, and `textDecorationLine: 'line-through'` on a nested
|
|
11
|
+
* `Text` is unreliable across the two platforms. "Was X" reads correctly in
|
|
12
|
+
* both and in a screen reader, which the visual version does not — the same
|
|
13
|
+
* call `apps/mobile-agent` made.
|
|
14
|
+
*/
|
|
15
|
+
function Price({ value }) {
|
|
16
|
+
const { theme } = useChatly();
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const was = value.compareAt !== undefined && value.compareAt > value.amount
|
|
21
|
+
? formatMoney({ amount: value.compareAt, currency: value.currency })
|
|
22
|
+
: null;
|
|
23
|
+
const now = formatMoney(value);
|
|
24
|
+
return (_jsx(Text, { style: { color: theme.colors.foreground, fontSize: theme.typography.sizeBody }, children: was === null ? now : `${now} (was ${was})` }));
|
|
25
|
+
}
|
|
26
|
+
function ActionButton(props) {
|
|
27
|
+
const { theme } = useChatly();
|
|
28
|
+
const { action, onRun } = props;
|
|
29
|
+
return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: () => onRun(action), style: {
|
|
30
|
+
borderRadius: theme.radius.md,
|
|
31
|
+
paddingHorizontal: theme.spacing.md,
|
|
32
|
+
paddingVertical: theme.spacing.sm,
|
|
33
|
+
backgroundColor: action.style === 'primary' ? theme.colors.primary : theme.colors.surface,
|
|
34
|
+
borderColor: theme.colors.border,
|
|
35
|
+
borderWidth: action.style === 'primary' ? 0 : 1,
|
|
36
|
+
}, children: _jsx(Text, { style: {
|
|
37
|
+
color: action.style === 'primary' ? theme.colors.onPrimary : theme.colors.foreground,
|
|
38
|
+
fontSize: theme.typography.sizeBody,
|
|
39
|
+
}, children: action.label }) }));
|
|
40
|
+
}
|
|
41
|
+
function Card(props) {
|
|
42
|
+
const { theme } = useChatly();
|
|
43
|
+
const { card, width } = props;
|
|
44
|
+
return (_jsxs(View, { style: {
|
|
45
|
+
borderWidth: 1,
|
|
46
|
+
borderColor: theme.colors.border,
|
|
47
|
+
borderRadius: theme.radius.bubble,
|
|
48
|
+
backgroundColor: theme.colors.surface,
|
|
49
|
+
padding: theme.spacing.sm,
|
|
50
|
+
gap: 4,
|
|
51
|
+
...(width === undefined ? {} : { width }),
|
|
52
|
+
}, children: [card.image !== undefined && (_jsx(Image, { source: { uri: card.image }, accessibilityLabel: card.title, accessibilityIgnoresInvertColors: true, style: { width: '100%', height: 140, borderRadius: theme.radius.md } })), card.badge !== undefined && (_jsx(Text, { style: { color: theme.colors.mutedForeground, fontSize: theme.typography.sizeSmall }, children: card.badge })), _jsx(Text, { style: { color: theme.colors.foreground, fontSize: theme.typography.sizeBody }, children: card.title }), card.subtitle !== undefined && (_jsx(Text, { style: { color: theme.colors.mutedForeground, fontSize: theme.typography.sizeSmall }, children: card.subtitle })), _jsx(Price, { value: card.price }), (card.fields ?? []).map((f, i) => (_jsx(Text, { style: { color: theme.colors.mutedForeground, fontSize: theme.typography.sizeSmall }, children: `${f.label}: ${f.value}` }, `${f.label}-${String(i)}`))), (card.actions ?? []).length > 0 && (_jsx(View, { style: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginTop: 4 }, children: (card.actions ?? []).map((a, i) => (_jsx(ActionButton, { action: a, onRun: props.onRun }, `${a.label}-${String(i)}`))) }))] }));
|
|
53
|
+
}
|
|
54
|
+
function Block(props) {
|
|
55
|
+
const { theme } = useChatly();
|
|
56
|
+
const { block, onRun, onReply } = props;
|
|
57
|
+
const muted = { color: theme.colors.mutedForeground, fontSize: theme.typography.sizeSmall };
|
|
58
|
+
const body = { color: theme.colors.foreground, fontSize: theme.typography.sizeBody };
|
|
59
|
+
switch (block.type) {
|
|
60
|
+
case 'text':
|
|
61
|
+
/*
|
|
62
|
+
* The markdown is rendered as PLAIN TEXT, deliberately.
|
|
63
|
+
*
|
|
64
|
+
* A markdown renderer on React Native is a dependency, and this package
|
|
65
|
+
* has exactly one (`socket.io-client`). The characters a bot actually
|
|
66
|
+
* emits — `**bold**`, a bullet, a link — read acceptably raw, and the
|
|
67
|
+
* alternative a consumer has is to render the block themselves from the
|
|
68
|
+
* envelope, which `readBlocksEnvelope` is exported for.
|
|
69
|
+
*/
|
|
70
|
+
return _jsx(Text, { style: body, children: block.markdown });
|
|
71
|
+
case 'media':
|
|
72
|
+
return block.kind === 'image' ? (_jsx(Image, { source: { uri: block.url }, accessibilityLabel: block.alt, accessibilityIgnoresInvertColors: true, style: { width: '100%', height: 180, borderRadius: theme.radius.md } })) : (
|
|
73
|
+
// No video element without a dependency. The alt text plus a tappable
|
|
74
|
+
// link is strictly better than a blank space.
|
|
75
|
+
_jsx(Pressable, { accessibilityRole: "link", onPress: () => void Linking.openURL(block.url), children: _jsx(Text, { style: body, children: block.alt }) }));
|
|
76
|
+
case 'fields':
|
|
77
|
+
return (_jsx(View, { style: { gap: 2 }, children: block.items.map((f, i) => (_jsx(Text, { style: muted, children: `${f.label}: ${f.value}` }, `${f.label}-${String(i)}`))) }));
|
|
78
|
+
case 'card':
|
|
79
|
+
return _jsx(Card, { card: block, onRun: onRun });
|
|
80
|
+
case 'card_grid':
|
|
81
|
+
return block.layout === 'carousel' ? (_jsx(ScrollView, { horizontal: true, accessibilityLabel: "Scrollable options", children: _jsx(View, { style: { flexDirection: 'row', gap: 8 }, children: block.cards.map((c, i) => (_jsx(Card, { card: c, onRun: onRun, width: 240 }, c.id ?? String(i)))) }) })) : (_jsx(View, { style: { gap: 8 }, children: block.cards.map((c, i) => (_jsx(Card, { card: c, onRun: onRun }, c.id ?? String(i)))) }));
|
|
82
|
+
case 'actions':
|
|
83
|
+
return (_jsx(View, { style: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 }, children: block.actions.map((a, i) => (_jsx(ActionButton, { action: a, onRun: onRun }, `${a.label}-${String(i)}`))) }));
|
|
84
|
+
case 'quick_replies':
|
|
85
|
+
return (_jsx(View, { accessibilityLabel: "Quick replies", style: { flexDirection: 'row', flexWrap: 'wrap', gap: 6 }, children: block.options.map((o, i) => (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: o.label, onPress: () => onReply(o.value), style: {
|
|
86
|
+
borderRadius: 999,
|
|
87
|
+
borderWidth: 1,
|
|
88
|
+
borderColor: theme.colors.border,
|
|
89
|
+
paddingHorizontal: theme.spacing.md,
|
|
90
|
+
paddingVertical: 6,
|
|
91
|
+
}, children: _jsx(Text, { style: body, children: o.label }) }, `${o.value}-${String(i)}`))) }));
|
|
92
|
+
case 'status':
|
|
93
|
+
return (_jsx(Text, { accessibilityRole: "text", style: muted, children: block.state === 'failed' ? `${block.text} — failed` : block.text }));
|
|
94
|
+
case 'divider':
|
|
95
|
+
return (_jsx(View, { style: { height: 1, backgroundColor: theme.colors.border, marginVertical: 4 }, accessibilityLabel: "divider" }));
|
|
96
|
+
default:
|
|
97
|
+
// Unreachable: `readBlocksEnvelope` drops an unknown type. Present so
|
|
98
|
+
// adding one to the schema is a compile error here rather than a blank
|
|
99
|
+
// space on a shopper's screen — which is what
|
|
100
|
+
// `check-block-renderer-parity.mjs` is also watching for.
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function MessageBlocks(props) {
|
|
105
|
+
const { rest, onAction } = useChatly();
|
|
106
|
+
const envelope = readBlocksEnvelope(props.blocks);
|
|
107
|
+
if (envelope === null) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Run one action.
|
|
112
|
+
*
|
|
113
|
+
* `host_event` is handed to the app and nothing else happens here — the app
|
|
114
|
+
* reports the outcome back with `rest.reportAction`, which is what appends
|
|
115
|
+
* "Added to your cart" under the card and tells the owning bot. Everything
|
|
116
|
+
* else is a call this package can make itself.
|
|
117
|
+
*/
|
|
118
|
+
const onRun = (action) => {
|
|
119
|
+
const conversationId = props.conversationId;
|
|
120
|
+
switch (action.kind) {
|
|
121
|
+
case 'host_event':
|
|
122
|
+
onAction?.({
|
|
123
|
+
event: action.event,
|
|
124
|
+
data: action.data ?? {},
|
|
125
|
+
conversationId,
|
|
126
|
+
messageId: props.messageId,
|
|
127
|
+
actionId: action.id ?? action.event,
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
case 'url':
|
|
131
|
+
void Linking.openURL(action.href);
|
|
132
|
+
return;
|
|
133
|
+
case 'postback':
|
|
134
|
+
if (conversationId !== null) {
|
|
135
|
+
void rest.postback(conversationId, {
|
|
136
|
+
value: action.value,
|
|
137
|
+
...(action.payload === undefined ? {} : { payload: action.payload }),
|
|
138
|
+
silent: action.silent === true,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
case 'step':
|
|
143
|
+
if (conversationId !== null) {
|
|
144
|
+
void rest.requestCanvasStep(conversationId, action.canvasId, action.params);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
case 'copy':
|
|
148
|
+
/*
|
|
149
|
+
* No clipboard. `@react-native-clipboard/clipboard` is a native
|
|
150
|
+
* module and this package has no native dependencies by design — a
|
|
151
|
+
* consumer adding one would have to rebuild. The text is shown
|
|
152
|
+
* instead, which is selectable, and an integrator who wants a real
|
|
153
|
+
* copy button renders the envelope themselves.
|
|
154
|
+
*/
|
|
155
|
+
return;
|
|
156
|
+
default:
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const onReply = (value) => {
|
|
161
|
+
if (props.conversationId !== null) {
|
|
162
|
+
void rest.reply(props.conversationId, value);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
return (_jsx(View, { style: { gap: 6, marginTop: 6 }, children: envelope.blocks.map((b, i) => (_jsx(Block, { block: b, onRun: onRun, onReply: onReply }, b.id ?? `${b.type}-${String(i)}`))) }));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=MessageBlocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBlocks.js","sourceRoot":"","sources":["../../src/components/MessageBlocks.tsx"],"names":[],"mappings":";AA+BA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAczC;;;;;;;;GAQG;AACH,SAAS,KAAK,CAAC,EAAE,KAAK,EAA8B;IAClD,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC;IAC9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,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,CAAC;YAClC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,IAAC,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,YAClC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC7B,KAAC,KAAK,IAAwC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,IAA1E,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAA8C,CAC3F,CAAC,GACG,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MessageRow } from '../client/types';
|
|
3
|
+
export interface MessageBubbleProps {
|
|
4
|
+
message: MessageRow;
|
|
5
|
+
/**
|
|
6
|
+
* The conversation the message is in, so a card action knows where to
|
|
7
|
+
* report. Optional, because a consumer rendering a bubble outside a thread
|
|
8
|
+
* (a preview, a notification) has no conversation — and then an action
|
|
9
|
+
* renders and does nothing rather than posting to the wrong place.
|
|
10
|
+
*/
|
|
11
|
+
conversationId?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function MessageBubble({ message, conversationId }: MessageBubbleProps): React.JSX.Element;
|
|
14
|
+
//# sourceMappingURL=MessageBubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBubble.d.ts","sourceRoot":"","sources":["../../src/components/MessageBubble.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,UAAU,CAAC;IACpB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,kBAAkB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAgFhG"}
|