@vinaverse/react-native 0.1.0-alpha.2 → 0.1.0-alpha.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/README.md +57 -2
- package/dist/index.cjs +457 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -47
- package/dist/index.d.ts +143 -47
- package/dist/index.js +448 -100
- package/dist/index.js.map +1 -1
- package/package.json +37 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,95 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ComponentType, ReactElement, ReactNode, RefObject } from 'react';
|
|
3
|
+
import { CardItem, MessageItem, Welcome as Welcome$1, TimelineItem, HeldCard, Question, SystemItem, ProposalOutcome, ConversationStore } from '@vinaverse/client/conversation';
|
|
4
4
|
import { CopyOverrides } from '@vinaverse/react';
|
|
5
5
|
import { ImageProps, StyleProp, ViewStyle } from 'react-native';
|
|
6
6
|
import { ColorScheme, Colors, font, space, radius, motion, size } from '@vinaverse/tokens';
|
|
7
7
|
|
|
8
|
+
interface HeaderProps {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly avatarUrl: string | null;
|
|
11
|
+
/** While a person from the business replies: their role. */
|
|
12
|
+
readonly takeoverBy: string | null;
|
|
13
|
+
readonly Default: ComponentType<Omit<HeaderProps, 'Default'>>;
|
|
14
|
+
}
|
|
15
|
+
interface MessageBubbleProps {
|
|
16
|
+
readonly item: MessageItem;
|
|
17
|
+
/** The text to draw: the message's, or the streamed text so far. */
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly Default: ComponentType<Omit<MessageBubbleProps, 'Default'>>;
|
|
20
|
+
}
|
|
21
|
+
interface ComposerProps {
|
|
22
|
+
readonly placeholder: string;
|
|
23
|
+
readonly responding: boolean;
|
|
24
|
+
readonly onSend: (text: string) => void;
|
|
25
|
+
readonly onStop: () => void;
|
|
26
|
+
readonly Default: ComponentType<Omit<ComposerProps, 'Default'>>;
|
|
27
|
+
}
|
|
28
|
+
interface EmptyStateProps {
|
|
29
|
+
readonly agentName: string;
|
|
30
|
+
/** The tenant's greeting and chips for the session's mode (`Session.welcome`), or null. */
|
|
31
|
+
readonly welcome: Welcome$1 | null;
|
|
32
|
+
/** Sends a chip's `message` as the person's own text. */
|
|
33
|
+
readonly onChip: (message: string) => void;
|
|
34
|
+
}
|
|
35
|
+
/** `components.CardGroup`: the cards one turn drew together with `group.layout: carousel`, in order. */
|
|
36
|
+
interface CardGroupProps {
|
|
37
|
+
readonly items: readonly CardItem[];
|
|
38
|
+
}
|
|
39
|
+
/** The props the kit gives its list: FlashList's, so FlashList or LegendList take them as they are. */
|
|
40
|
+
interface ListProps {
|
|
41
|
+
readonly data: readonly TimelineItem[];
|
|
42
|
+
readonly renderItem: (info: {
|
|
43
|
+
item: TimelineItem;
|
|
44
|
+
index: number;
|
|
45
|
+
}) => ReactElement | null;
|
|
46
|
+
readonly keyExtractor: (item: TimelineItem) => string;
|
|
47
|
+
readonly getItemType: (item: TimelineItem) => string;
|
|
48
|
+
readonly maintainVisibleContentPosition: {
|
|
49
|
+
readonly startRenderingFromBottom: boolean;
|
|
50
|
+
readonly autoscrollToBottomThreshold: number;
|
|
51
|
+
readonly animateAutoScrollToBottom: boolean;
|
|
52
|
+
};
|
|
53
|
+
readonly ListFooterComponent: ReactElement | null;
|
|
54
|
+
readonly ListEmptyComponent: ReactElement | null;
|
|
55
|
+
readonly keyboardShouldPersistTaps: 'handled';
|
|
56
|
+
readonly contentContainerStyle: object;
|
|
57
|
+
}
|
|
58
|
+
/** A failure the person needs a way out of: a turn that failed before any reply, or no session to talk to. */
|
|
59
|
+
interface FailureState {
|
|
60
|
+
/** `turn_failed`: a turn failed before any of its reply; `unavailable`: the backend gave no session, or none it could use. */
|
|
61
|
+
readonly kind: 'turn_failed' | 'unavailable';
|
|
62
|
+
/** Why: the turn's error `code` (`internal`, `timeout`, …), or the conversation's status (`unavailable`, `unauthorized`). */
|
|
63
|
+
readonly reason: string | null;
|
|
64
|
+
/** Try again, when it can be: the person's text again for a turn the server allows to retry, a new session otherwise. */
|
|
65
|
+
readonly retry: (() => void) | undefined;
|
|
66
|
+
/** The conversation, once a session named it: for your support records. */
|
|
67
|
+
readonly conversationId: string | null;
|
|
68
|
+
}
|
|
69
|
+
/** A slot for a failure (`components.Error`, `components.Unavailable`): the state, and the kit's own part to wrap. */
|
|
70
|
+
interface FailureProps {
|
|
71
|
+
readonly state: FailureState;
|
|
72
|
+
readonly Default: ComponentType<{
|
|
73
|
+
readonly state: FailureState;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
/** One action on every failure, drawn as a button by the kit's own parts: a person is always the way out. */
|
|
77
|
+
interface FailureAction {
|
|
78
|
+
/** Default: the copy's `talkToPerson` ("Talk to a person"), in the person's language. */
|
|
79
|
+
readonly label?: string;
|
|
80
|
+
readonly onPress: (state: FailureState) => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare function CardCarousel(props: CardGroupProps): react.JSX.Element;
|
|
84
|
+
|
|
8
85
|
declare function CardFrame(props: {
|
|
9
86
|
readonly label: string;
|
|
10
87
|
readonly restored?: boolean;
|
|
11
88
|
readonly children?: ReactNode;
|
|
12
89
|
readonly testID?: string;
|
|
13
90
|
}): react.JSX.Element;
|
|
91
|
+
/** A rating in millionths as the locale writes it, one decimal: 4.8, or 4,8 in Spanish and Portuguese. */
|
|
92
|
+
declare function ratingText(valuePpm: number, locale: string | undefined): string;
|
|
14
93
|
|
|
15
94
|
interface CardProps {
|
|
16
95
|
readonly card: HeldCard;
|
|
@@ -29,6 +108,14 @@ declare const CardView: react.NamedExoticComponent<{
|
|
|
29
108
|
}>;
|
|
30
109
|
|
|
31
110
|
declare function InfoCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
111
|
+
/** A card's actions: a link that passes the deep-link rule opens the tenant's page, any other goes to the session. */
|
|
112
|
+
declare function CardActions(props: Omit<CardProps, 'Default'>): react.JSX.Element | null;
|
|
113
|
+
|
|
114
|
+
declare function LinksCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
115
|
+
|
|
116
|
+
declare function ListingCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
117
|
+
/** The first letters of the first two words: "Bell's Barber Lounge" is "BB". */
|
|
118
|
+
declare function monogram(title: string): string;
|
|
32
119
|
|
|
33
120
|
declare function NextStepCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
34
121
|
|
|
@@ -65,49 +152,6 @@ interface ButtonProps {
|
|
|
65
152
|
}
|
|
66
153
|
declare const Button: react.NamedExoticComponent<ButtonProps>;
|
|
67
154
|
|
|
68
|
-
interface HeaderProps {
|
|
69
|
-
readonly name: string;
|
|
70
|
-
readonly avatarUrl: string | null;
|
|
71
|
-
/** While a person from the business replies: their role. */
|
|
72
|
-
readonly takeoverBy: string | null;
|
|
73
|
-
readonly Default: ComponentType<Omit<HeaderProps, 'Default'>>;
|
|
74
|
-
}
|
|
75
|
-
interface MessageBubbleProps {
|
|
76
|
-
readonly item: MessageItem;
|
|
77
|
-
/** The text to draw: the message's, or the streamed text so far. */
|
|
78
|
-
readonly text: string;
|
|
79
|
-
readonly Default: ComponentType<Omit<MessageBubbleProps, 'Default'>>;
|
|
80
|
-
}
|
|
81
|
-
interface ComposerProps {
|
|
82
|
-
readonly placeholder: string;
|
|
83
|
-
readonly responding: boolean;
|
|
84
|
-
readonly onSend: (text: string) => void;
|
|
85
|
-
readonly onStop: () => void;
|
|
86
|
-
readonly Default: ComponentType<Omit<ComposerProps, 'Default'>>;
|
|
87
|
-
}
|
|
88
|
-
interface EmptyStateProps {
|
|
89
|
-
readonly agentName: string;
|
|
90
|
-
}
|
|
91
|
-
/** The props the kit gives its list: FlashList's, so FlashList or LegendList take them as they are. */
|
|
92
|
-
interface ListProps {
|
|
93
|
-
readonly data: readonly TimelineItem[];
|
|
94
|
-
readonly renderItem: (info: {
|
|
95
|
-
item: TimelineItem;
|
|
96
|
-
index: number;
|
|
97
|
-
}) => ReactElement | null;
|
|
98
|
-
readonly keyExtractor: (item: TimelineItem) => string;
|
|
99
|
-
readonly getItemType: (item: TimelineItem) => string;
|
|
100
|
-
readonly maintainVisibleContentPosition: {
|
|
101
|
-
readonly startRenderingFromBottom: boolean;
|
|
102
|
-
readonly autoscrollToBottomThreshold: number;
|
|
103
|
-
readonly animateAutoScrollToBottom: boolean;
|
|
104
|
-
};
|
|
105
|
-
readonly ListFooterComponent: ReactElement | null;
|
|
106
|
-
readonly ListEmptyComponent: ReactElement | null;
|
|
107
|
-
readonly keyboardShouldPersistTaps: 'handled';
|
|
108
|
-
readonly contentContainerStyle: object;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
155
|
declare function DefaultHeader(props: Omit<HeaderProps, 'Default'>): react.JSX.Element;
|
|
112
156
|
declare const ChatHeader: react.NamedExoticComponent<object>;
|
|
113
157
|
|
|
@@ -120,6 +164,11 @@ declare const Composer: react.NamedExoticComponent<{
|
|
|
120
164
|
|
|
121
165
|
declare const DisclosureBar: react.NamedExoticComponent<object>;
|
|
122
166
|
|
|
167
|
+
/** The tenant's failure action as a button, or nothing when there is none. */
|
|
168
|
+
declare function FailureActionButton(props: {
|
|
169
|
+
readonly state: FailureState;
|
|
170
|
+
}): ReactNode;
|
|
171
|
+
|
|
123
172
|
declare function DefaultBubble(props: Omit<MessageBubbleProps, 'Default'>): react.JSX.Element;
|
|
124
173
|
declare const MessageBubble: react.NamedExoticComponent<{
|
|
125
174
|
readonly item: MessageItem;
|
|
@@ -134,17 +183,38 @@ declare const StreamingBubble: react.NamedExoticComponent<{
|
|
|
134
183
|
|
|
135
184
|
/** Rows of one kind recycle together. */
|
|
136
185
|
declare function itemType(item: TimelineItem): string;
|
|
186
|
+
/**
|
|
187
|
+
* Runs of two or more consecutive cards with one carousel group (`group.layout: carousel`, the same `group.id`): by
|
|
188
|
+
* the first card's key, and the keys of the cards the run draws after it. A run equal to the previous one is the
|
|
189
|
+
* same array, so its row does not render again.
|
|
190
|
+
*/
|
|
191
|
+
declare function carousels(items: readonly TimelineItem[], previous: ReadonlyMap<string, readonly CardItem[]>): {
|
|
192
|
+
runs: Map<string, readonly CardItem[]>;
|
|
193
|
+
inside: Set<string>;
|
|
194
|
+
};
|
|
137
195
|
declare const Row: react.NamedExoticComponent<{
|
|
138
196
|
readonly item: TimelineItem;
|
|
139
197
|
readonly showAuthor: boolean;
|
|
198
|
+
/** The carousel this card starts (`components.CardGroup`). */
|
|
199
|
+
readonly run?: readonly CardItem[] | undefined;
|
|
200
|
+
/** A card a carousel earlier in the list draws. */
|
|
201
|
+
readonly inside?: boolean;
|
|
140
202
|
}>;
|
|
141
203
|
declare const MessageList: react.NamedExoticComponent<object>;
|
|
142
204
|
|
|
143
205
|
declare const StatusBanner: react.NamedExoticComponent<object>;
|
|
206
|
+
/** The kit's own "Couldn't connect." banner: try again, and the tenant's failure action when there is one. */
|
|
207
|
+
declare function DefaultUnavailable(props: {
|
|
208
|
+
readonly state: FailureState;
|
|
209
|
+
}): ReactNode;
|
|
144
210
|
|
|
145
211
|
declare const SystemRow: react.NamedExoticComponent<{
|
|
146
212
|
readonly item: SystemItem;
|
|
147
213
|
}>;
|
|
214
|
+
/** The kit's own failed-turn row: "Something went wrong.", and the tenant's failure action when there is one. */
|
|
215
|
+
declare function DefaultTurnFailed(props: {
|
|
216
|
+
readonly state: FailureState;
|
|
217
|
+
}): ReactNode;
|
|
148
218
|
|
|
149
219
|
type ProposalDecision = 'confirm' | 'decline';
|
|
150
220
|
/** What the kit asks of the tenant's app. Only `onProposal` and `onOpenLink` are needed for the cards that use them. */
|
|
@@ -154,7 +224,10 @@ interface ChatHandlers {
|
|
|
154
224
|
* happened (`confirmed`, `declined`, `failed`, or `expired` when it had expired). The kit reports it to the session.
|
|
155
225
|
*/
|
|
156
226
|
readonly onProposal?: (card: HeldCard, decision: ProposalDecision) => Promise<ProposalOutcome>;
|
|
157
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Open a card's link in your app: a deep link that already passed the deep-link rule (route by the page it names),
|
|
229
|
+
* or a `links` card's https page (your in-app browser; without this handler the system opens it).
|
|
230
|
+
*/
|
|
158
231
|
readonly onOpenLink?: (link: string, card: HeldCard) => void;
|
|
159
232
|
/** A card action without a link (`show_times`, …): sent to the session; this tells your app too. */
|
|
160
233
|
readonly onCardAction?: (card: HeldCard, action: string) => void;
|
|
@@ -162,6 +235,11 @@ interface ChatHandlers {
|
|
|
162
235
|
readonly onPickPhoto?: (question: Question, card: HeldCard) => Promise<{
|
|
163
236
|
readonly upload_ref: string;
|
|
164
237
|
} | null>;
|
|
238
|
+
/**
|
|
239
|
+
* A way out on a failed turn and on "couldn't connect": a button with your label (default "Talk to a person"),
|
|
240
|
+
* drawn by the kit's own parts when no `components.Error` or `components.Unavailable` replaces them.
|
|
241
|
+
*/
|
|
242
|
+
readonly failureAction?: FailureAction;
|
|
165
243
|
/** Development warnings: a theme that is hard to read, copy that says "assistant". */
|
|
166
244
|
readonly onWarning?: (message: string) => void;
|
|
167
245
|
}
|
|
@@ -174,6 +252,15 @@ interface ChatSlots {
|
|
|
174
252
|
readonly Image?: ComponentType<ImageProps>;
|
|
175
253
|
/** A list with FlashList's props (LegendList works). Default: FlashList. */
|
|
176
254
|
readonly ListComponent?: ComponentType<ListProps>;
|
|
255
|
+
/** A turn that failed before any reply: replaces the "Something went wrong." row. */
|
|
256
|
+
readonly Error?: ComponentType<FailureProps>;
|
|
257
|
+
/** No session to talk to: replaces the "Couldn't connect." banner. */
|
|
258
|
+
readonly Unavailable?: ComponentType<FailureProps>;
|
|
259
|
+
/**
|
|
260
|
+
* Draws a turn's cards that ask for a carousel (`group.layout: carousel`) in one row: the kit's `CardCarousel`, or
|
|
261
|
+
* yours. Without it they draw one under another. Opt-in, so an app that never draws a carousel does not ship one.
|
|
262
|
+
*/
|
|
263
|
+
readonly CardGroup?: ComponentType<CardGroupProps>;
|
|
177
264
|
/** Card renderers by kind (`professional`, `proposal`, …). */
|
|
178
265
|
readonly cards?: Readonly<Partial<Record<string, ComponentType<CardProps>>>>;
|
|
179
266
|
}
|
|
@@ -183,6 +270,10 @@ interface ChatContextValue {
|
|
|
183
270
|
readonly slots: ChatSlots;
|
|
184
271
|
readonly agentAvatar: string | undefined;
|
|
185
272
|
readonly timeZone: string | undefined;
|
|
273
|
+
/** The failure action's label when there is one (`label` undefined: the copy's); `onPress` is read from `handlers`. */
|
|
274
|
+
readonly failureAction: {
|
|
275
|
+
readonly label: string | undefined;
|
|
276
|
+
} | null;
|
|
186
277
|
}
|
|
187
278
|
/** The conversation, handlers and slots; only inside `VinaverseChat` (or `VinaverseChatProvider`). */
|
|
188
279
|
declare function useChat(): ChatContextValue;
|
|
@@ -250,6 +341,11 @@ declare function VinaverseChatProvider(props: Omit<VinaverseChatProps, 'hideHead
|
|
|
250
341
|
}): ReactNode;
|
|
251
342
|
declare function VinaverseChat(props: VinaverseChatProps): ReactNode;
|
|
252
343
|
|
|
344
|
+
declare const Welcome: react.NamedExoticComponent<{
|
|
345
|
+
readonly welcome: Welcome$1;
|
|
346
|
+
readonly onChip: (message: string) => void;
|
|
347
|
+
}>;
|
|
348
|
+
|
|
253
349
|
/** The part of the conversation store the adapter drives. */
|
|
254
350
|
interface LifecycleTarget {
|
|
255
351
|
setForeground(foreground: boolean): void;
|
|
@@ -261,4 +357,4 @@ declare function useReducedMotion(): boolean;
|
|
|
261
357
|
/** Reads a line to a screen reader, without moving focus. */
|
|
262
358
|
declare function announce(text: string): void;
|
|
263
359
|
|
|
264
|
-
export { ActivityLine, Avatar, Button, type ButtonProps, CardFrame, type CardProps, CardView, type ChatHandlers, ChatHeader, ChatSkeleton, type ChatSlots, type ColorSchemeSetting, Composer, type ComposerProps, DefaultBubble, DefaultComposer, DefaultHeader, DisclosureBar, type EmptyStateProps, type HeaderProps, InfoCard, type LifecycleTarget, type ListProps, MessageBubble, type MessageBubbleProps, MessageList, NextStepCard, ProposalCard, type ProposalDecision, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, type Theme, type ThemeOverrides, ThemeProvider, TimeSlotsCard, VinaverseChat, type VinaverseChatProps, VinaverseChatProvider, announce, answerText, createTheme, defaultCard, fieldText, itemType, themeProblems, useChat, useNativeLifecycle, useReducedMotion, useTheme };
|
|
360
|
+
export { ActivityLine, Avatar, Button, type ButtonProps, CardActions, CardCarousel, CardFrame, type CardGroupProps, type CardProps, CardView, type ChatHandlers, ChatHeader, ChatSkeleton, type ChatSlots, type ColorSchemeSetting, Composer, type ComposerProps, DefaultBubble, DefaultComposer, DefaultHeader, DefaultTurnFailed, DefaultUnavailable, DisclosureBar, type EmptyStateProps, type FailureAction, FailureActionButton, type FailureProps, type FailureState, type HeaderProps, InfoCard, type LifecycleTarget, LinksCard, type ListProps, ListingCard, MessageBubble, type MessageBubbleProps, MessageList, NextStepCard, ProposalCard, type ProposalDecision, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, type Theme, type ThemeOverrides, ThemeProvider, TimeSlotsCard, VinaverseChat, type VinaverseChatProps, VinaverseChatProvider, Welcome, announce, answerText, carousels, createTheme, defaultCard, fieldText, itemType, monogram, ratingText, themeProblems, useChat, useNativeLifecycle, useReducedMotion, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,95 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ComponentType, ReactElement, ReactNode, RefObject } from 'react';
|
|
3
|
+
import { CardItem, MessageItem, Welcome as Welcome$1, TimelineItem, HeldCard, Question, SystemItem, ProposalOutcome, ConversationStore } from '@vinaverse/client/conversation';
|
|
4
4
|
import { CopyOverrides } from '@vinaverse/react';
|
|
5
5
|
import { ImageProps, StyleProp, ViewStyle } from 'react-native';
|
|
6
6
|
import { ColorScheme, Colors, font, space, radius, motion, size } from '@vinaverse/tokens';
|
|
7
7
|
|
|
8
|
+
interface HeaderProps {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly avatarUrl: string | null;
|
|
11
|
+
/** While a person from the business replies: their role. */
|
|
12
|
+
readonly takeoverBy: string | null;
|
|
13
|
+
readonly Default: ComponentType<Omit<HeaderProps, 'Default'>>;
|
|
14
|
+
}
|
|
15
|
+
interface MessageBubbleProps {
|
|
16
|
+
readonly item: MessageItem;
|
|
17
|
+
/** The text to draw: the message's, or the streamed text so far. */
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly Default: ComponentType<Omit<MessageBubbleProps, 'Default'>>;
|
|
20
|
+
}
|
|
21
|
+
interface ComposerProps {
|
|
22
|
+
readonly placeholder: string;
|
|
23
|
+
readonly responding: boolean;
|
|
24
|
+
readonly onSend: (text: string) => void;
|
|
25
|
+
readonly onStop: () => void;
|
|
26
|
+
readonly Default: ComponentType<Omit<ComposerProps, 'Default'>>;
|
|
27
|
+
}
|
|
28
|
+
interface EmptyStateProps {
|
|
29
|
+
readonly agentName: string;
|
|
30
|
+
/** The tenant's greeting and chips for the session's mode (`Session.welcome`), or null. */
|
|
31
|
+
readonly welcome: Welcome$1 | null;
|
|
32
|
+
/** Sends a chip's `message` as the person's own text. */
|
|
33
|
+
readonly onChip: (message: string) => void;
|
|
34
|
+
}
|
|
35
|
+
/** `components.CardGroup`: the cards one turn drew together with `group.layout: carousel`, in order. */
|
|
36
|
+
interface CardGroupProps {
|
|
37
|
+
readonly items: readonly CardItem[];
|
|
38
|
+
}
|
|
39
|
+
/** The props the kit gives its list: FlashList's, so FlashList or LegendList take them as they are. */
|
|
40
|
+
interface ListProps {
|
|
41
|
+
readonly data: readonly TimelineItem[];
|
|
42
|
+
readonly renderItem: (info: {
|
|
43
|
+
item: TimelineItem;
|
|
44
|
+
index: number;
|
|
45
|
+
}) => ReactElement | null;
|
|
46
|
+
readonly keyExtractor: (item: TimelineItem) => string;
|
|
47
|
+
readonly getItemType: (item: TimelineItem) => string;
|
|
48
|
+
readonly maintainVisibleContentPosition: {
|
|
49
|
+
readonly startRenderingFromBottom: boolean;
|
|
50
|
+
readonly autoscrollToBottomThreshold: number;
|
|
51
|
+
readonly animateAutoScrollToBottom: boolean;
|
|
52
|
+
};
|
|
53
|
+
readonly ListFooterComponent: ReactElement | null;
|
|
54
|
+
readonly ListEmptyComponent: ReactElement | null;
|
|
55
|
+
readonly keyboardShouldPersistTaps: 'handled';
|
|
56
|
+
readonly contentContainerStyle: object;
|
|
57
|
+
}
|
|
58
|
+
/** A failure the person needs a way out of: a turn that failed before any reply, or no session to talk to. */
|
|
59
|
+
interface FailureState {
|
|
60
|
+
/** `turn_failed`: a turn failed before any of its reply; `unavailable`: the backend gave no session, or none it could use. */
|
|
61
|
+
readonly kind: 'turn_failed' | 'unavailable';
|
|
62
|
+
/** Why: the turn's error `code` (`internal`, `timeout`, …), or the conversation's status (`unavailable`, `unauthorized`). */
|
|
63
|
+
readonly reason: string | null;
|
|
64
|
+
/** Try again, when it can be: the person's text again for a turn the server allows to retry, a new session otherwise. */
|
|
65
|
+
readonly retry: (() => void) | undefined;
|
|
66
|
+
/** The conversation, once a session named it: for your support records. */
|
|
67
|
+
readonly conversationId: string | null;
|
|
68
|
+
}
|
|
69
|
+
/** A slot for a failure (`components.Error`, `components.Unavailable`): the state, and the kit's own part to wrap. */
|
|
70
|
+
interface FailureProps {
|
|
71
|
+
readonly state: FailureState;
|
|
72
|
+
readonly Default: ComponentType<{
|
|
73
|
+
readonly state: FailureState;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
/** One action on every failure, drawn as a button by the kit's own parts: a person is always the way out. */
|
|
77
|
+
interface FailureAction {
|
|
78
|
+
/** Default: the copy's `talkToPerson` ("Talk to a person"), in the person's language. */
|
|
79
|
+
readonly label?: string;
|
|
80
|
+
readonly onPress: (state: FailureState) => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare function CardCarousel(props: CardGroupProps): react.JSX.Element;
|
|
84
|
+
|
|
8
85
|
declare function CardFrame(props: {
|
|
9
86
|
readonly label: string;
|
|
10
87
|
readonly restored?: boolean;
|
|
11
88
|
readonly children?: ReactNode;
|
|
12
89
|
readonly testID?: string;
|
|
13
90
|
}): react.JSX.Element;
|
|
91
|
+
/** A rating in millionths as the locale writes it, one decimal: 4.8, or 4,8 in Spanish and Portuguese. */
|
|
92
|
+
declare function ratingText(valuePpm: number, locale: string | undefined): string;
|
|
14
93
|
|
|
15
94
|
interface CardProps {
|
|
16
95
|
readonly card: HeldCard;
|
|
@@ -29,6 +108,14 @@ declare const CardView: react.NamedExoticComponent<{
|
|
|
29
108
|
}>;
|
|
30
109
|
|
|
31
110
|
declare function InfoCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
111
|
+
/** A card's actions: a link that passes the deep-link rule opens the tenant's page, any other goes to the session. */
|
|
112
|
+
declare function CardActions(props: Omit<CardProps, 'Default'>): react.JSX.Element | null;
|
|
113
|
+
|
|
114
|
+
declare function LinksCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
115
|
+
|
|
116
|
+
declare function ListingCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
117
|
+
/** The first letters of the first two words: "Bell's Barber Lounge" is "BB". */
|
|
118
|
+
declare function monogram(title: string): string;
|
|
32
119
|
|
|
33
120
|
declare function NextStepCard(props: Omit<CardProps, 'Default'>): react.JSX.Element;
|
|
34
121
|
|
|
@@ -65,49 +152,6 @@ interface ButtonProps {
|
|
|
65
152
|
}
|
|
66
153
|
declare const Button: react.NamedExoticComponent<ButtonProps>;
|
|
67
154
|
|
|
68
|
-
interface HeaderProps {
|
|
69
|
-
readonly name: string;
|
|
70
|
-
readonly avatarUrl: string | null;
|
|
71
|
-
/** While a person from the business replies: their role. */
|
|
72
|
-
readonly takeoverBy: string | null;
|
|
73
|
-
readonly Default: ComponentType<Omit<HeaderProps, 'Default'>>;
|
|
74
|
-
}
|
|
75
|
-
interface MessageBubbleProps {
|
|
76
|
-
readonly item: MessageItem;
|
|
77
|
-
/** The text to draw: the message's, or the streamed text so far. */
|
|
78
|
-
readonly text: string;
|
|
79
|
-
readonly Default: ComponentType<Omit<MessageBubbleProps, 'Default'>>;
|
|
80
|
-
}
|
|
81
|
-
interface ComposerProps {
|
|
82
|
-
readonly placeholder: string;
|
|
83
|
-
readonly responding: boolean;
|
|
84
|
-
readonly onSend: (text: string) => void;
|
|
85
|
-
readonly onStop: () => void;
|
|
86
|
-
readonly Default: ComponentType<Omit<ComposerProps, 'Default'>>;
|
|
87
|
-
}
|
|
88
|
-
interface EmptyStateProps {
|
|
89
|
-
readonly agentName: string;
|
|
90
|
-
}
|
|
91
|
-
/** The props the kit gives its list: FlashList's, so FlashList or LegendList take them as they are. */
|
|
92
|
-
interface ListProps {
|
|
93
|
-
readonly data: readonly TimelineItem[];
|
|
94
|
-
readonly renderItem: (info: {
|
|
95
|
-
item: TimelineItem;
|
|
96
|
-
index: number;
|
|
97
|
-
}) => ReactElement | null;
|
|
98
|
-
readonly keyExtractor: (item: TimelineItem) => string;
|
|
99
|
-
readonly getItemType: (item: TimelineItem) => string;
|
|
100
|
-
readonly maintainVisibleContentPosition: {
|
|
101
|
-
readonly startRenderingFromBottom: boolean;
|
|
102
|
-
readonly autoscrollToBottomThreshold: number;
|
|
103
|
-
readonly animateAutoScrollToBottom: boolean;
|
|
104
|
-
};
|
|
105
|
-
readonly ListFooterComponent: ReactElement | null;
|
|
106
|
-
readonly ListEmptyComponent: ReactElement | null;
|
|
107
|
-
readonly keyboardShouldPersistTaps: 'handled';
|
|
108
|
-
readonly contentContainerStyle: object;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
155
|
declare function DefaultHeader(props: Omit<HeaderProps, 'Default'>): react.JSX.Element;
|
|
112
156
|
declare const ChatHeader: react.NamedExoticComponent<object>;
|
|
113
157
|
|
|
@@ -120,6 +164,11 @@ declare const Composer: react.NamedExoticComponent<{
|
|
|
120
164
|
|
|
121
165
|
declare const DisclosureBar: react.NamedExoticComponent<object>;
|
|
122
166
|
|
|
167
|
+
/** The tenant's failure action as a button, or nothing when there is none. */
|
|
168
|
+
declare function FailureActionButton(props: {
|
|
169
|
+
readonly state: FailureState;
|
|
170
|
+
}): ReactNode;
|
|
171
|
+
|
|
123
172
|
declare function DefaultBubble(props: Omit<MessageBubbleProps, 'Default'>): react.JSX.Element;
|
|
124
173
|
declare const MessageBubble: react.NamedExoticComponent<{
|
|
125
174
|
readonly item: MessageItem;
|
|
@@ -134,17 +183,38 @@ declare const StreamingBubble: react.NamedExoticComponent<{
|
|
|
134
183
|
|
|
135
184
|
/** Rows of one kind recycle together. */
|
|
136
185
|
declare function itemType(item: TimelineItem): string;
|
|
186
|
+
/**
|
|
187
|
+
* Runs of two or more consecutive cards with one carousel group (`group.layout: carousel`, the same `group.id`): by
|
|
188
|
+
* the first card's key, and the keys of the cards the run draws after it. A run equal to the previous one is the
|
|
189
|
+
* same array, so its row does not render again.
|
|
190
|
+
*/
|
|
191
|
+
declare function carousels(items: readonly TimelineItem[], previous: ReadonlyMap<string, readonly CardItem[]>): {
|
|
192
|
+
runs: Map<string, readonly CardItem[]>;
|
|
193
|
+
inside: Set<string>;
|
|
194
|
+
};
|
|
137
195
|
declare const Row: react.NamedExoticComponent<{
|
|
138
196
|
readonly item: TimelineItem;
|
|
139
197
|
readonly showAuthor: boolean;
|
|
198
|
+
/** The carousel this card starts (`components.CardGroup`). */
|
|
199
|
+
readonly run?: readonly CardItem[] | undefined;
|
|
200
|
+
/** A card a carousel earlier in the list draws. */
|
|
201
|
+
readonly inside?: boolean;
|
|
140
202
|
}>;
|
|
141
203
|
declare const MessageList: react.NamedExoticComponent<object>;
|
|
142
204
|
|
|
143
205
|
declare const StatusBanner: react.NamedExoticComponent<object>;
|
|
206
|
+
/** The kit's own "Couldn't connect." banner: try again, and the tenant's failure action when there is one. */
|
|
207
|
+
declare function DefaultUnavailable(props: {
|
|
208
|
+
readonly state: FailureState;
|
|
209
|
+
}): ReactNode;
|
|
144
210
|
|
|
145
211
|
declare const SystemRow: react.NamedExoticComponent<{
|
|
146
212
|
readonly item: SystemItem;
|
|
147
213
|
}>;
|
|
214
|
+
/** The kit's own failed-turn row: "Something went wrong.", and the tenant's failure action when there is one. */
|
|
215
|
+
declare function DefaultTurnFailed(props: {
|
|
216
|
+
readonly state: FailureState;
|
|
217
|
+
}): ReactNode;
|
|
148
218
|
|
|
149
219
|
type ProposalDecision = 'confirm' | 'decline';
|
|
150
220
|
/** What the kit asks of the tenant's app. Only `onProposal` and `onOpenLink` are needed for the cards that use them. */
|
|
@@ -154,7 +224,10 @@ interface ChatHandlers {
|
|
|
154
224
|
* happened (`confirmed`, `declined`, `failed`, or `expired` when it had expired). The kit reports it to the session.
|
|
155
225
|
*/
|
|
156
226
|
readonly onProposal?: (card: HeldCard, decision: ProposalDecision) => Promise<ProposalOutcome>;
|
|
157
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Open a card's link in your app: a deep link that already passed the deep-link rule (route by the page it names),
|
|
229
|
+
* or a `links` card's https page (your in-app browser; without this handler the system opens it).
|
|
230
|
+
*/
|
|
158
231
|
readonly onOpenLink?: (link: string, card: HeldCard) => void;
|
|
159
232
|
/** A card action without a link (`show_times`, …): sent to the session; this tells your app too. */
|
|
160
233
|
readonly onCardAction?: (card: HeldCard, action: string) => void;
|
|
@@ -162,6 +235,11 @@ interface ChatHandlers {
|
|
|
162
235
|
readonly onPickPhoto?: (question: Question, card: HeldCard) => Promise<{
|
|
163
236
|
readonly upload_ref: string;
|
|
164
237
|
} | null>;
|
|
238
|
+
/**
|
|
239
|
+
* A way out on a failed turn and on "couldn't connect": a button with your label (default "Talk to a person"),
|
|
240
|
+
* drawn by the kit's own parts when no `components.Error` or `components.Unavailable` replaces them.
|
|
241
|
+
*/
|
|
242
|
+
readonly failureAction?: FailureAction;
|
|
165
243
|
/** Development warnings: a theme that is hard to read, copy that says "assistant". */
|
|
166
244
|
readonly onWarning?: (message: string) => void;
|
|
167
245
|
}
|
|
@@ -174,6 +252,15 @@ interface ChatSlots {
|
|
|
174
252
|
readonly Image?: ComponentType<ImageProps>;
|
|
175
253
|
/** A list with FlashList's props (LegendList works). Default: FlashList. */
|
|
176
254
|
readonly ListComponent?: ComponentType<ListProps>;
|
|
255
|
+
/** A turn that failed before any reply: replaces the "Something went wrong." row. */
|
|
256
|
+
readonly Error?: ComponentType<FailureProps>;
|
|
257
|
+
/** No session to talk to: replaces the "Couldn't connect." banner. */
|
|
258
|
+
readonly Unavailable?: ComponentType<FailureProps>;
|
|
259
|
+
/**
|
|
260
|
+
* Draws a turn's cards that ask for a carousel (`group.layout: carousel`) in one row: the kit's `CardCarousel`, or
|
|
261
|
+
* yours. Without it they draw one under another. Opt-in, so an app that never draws a carousel does not ship one.
|
|
262
|
+
*/
|
|
263
|
+
readonly CardGroup?: ComponentType<CardGroupProps>;
|
|
177
264
|
/** Card renderers by kind (`professional`, `proposal`, …). */
|
|
178
265
|
readonly cards?: Readonly<Partial<Record<string, ComponentType<CardProps>>>>;
|
|
179
266
|
}
|
|
@@ -183,6 +270,10 @@ interface ChatContextValue {
|
|
|
183
270
|
readonly slots: ChatSlots;
|
|
184
271
|
readonly agentAvatar: string | undefined;
|
|
185
272
|
readonly timeZone: string | undefined;
|
|
273
|
+
/** The failure action's label when there is one (`label` undefined: the copy's); `onPress` is read from `handlers`. */
|
|
274
|
+
readonly failureAction: {
|
|
275
|
+
readonly label: string | undefined;
|
|
276
|
+
} | null;
|
|
186
277
|
}
|
|
187
278
|
/** The conversation, handlers and slots; only inside `VinaverseChat` (or `VinaverseChatProvider`). */
|
|
188
279
|
declare function useChat(): ChatContextValue;
|
|
@@ -250,6 +341,11 @@ declare function VinaverseChatProvider(props: Omit<VinaverseChatProps, 'hideHead
|
|
|
250
341
|
}): ReactNode;
|
|
251
342
|
declare function VinaverseChat(props: VinaverseChatProps): ReactNode;
|
|
252
343
|
|
|
344
|
+
declare const Welcome: react.NamedExoticComponent<{
|
|
345
|
+
readonly welcome: Welcome$1;
|
|
346
|
+
readonly onChip: (message: string) => void;
|
|
347
|
+
}>;
|
|
348
|
+
|
|
253
349
|
/** The part of the conversation store the adapter drives. */
|
|
254
350
|
interface LifecycleTarget {
|
|
255
351
|
setForeground(foreground: boolean): void;
|
|
@@ -261,4 +357,4 @@ declare function useReducedMotion(): boolean;
|
|
|
261
357
|
/** Reads a line to a screen reader, without moving focus. */
|
|
262
358
|
declare function announce(text: string): void;
|
|
263
359
|
|
|
264
|
-
export { ActivityLine, Avatar, Button, type ButtonProps, CardFrame, type CardProps, CardView, type ChatHandlers, ChatHeader, ChatSkeleton, type ChatSlots, type ColorSchemeSetting, Composer, type ComposerProps, DefaultBubble, DefaultComposer, DefaultHeader, DisclosureBar, type EmptyStateProps, type HeaderProps, InfoCard, type LifecycleTarget, type ListProps, MessageBubble, type MessageBubbleProps, MessageList, NextStepCard, ProposalCard, type ProposalDecision, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, type Theme, type ThemeOverrides, ThemeProvider, TimeSlotsCard, VinaverseChat, type VinaverseChatProps, VinaverseChatProvider, announce, answerText, createTheme, defaultCard, fieldText, itemType, themeProblems, useChat, useNativeLifecycle, useReducedMotion, useTheme };
|
|
360
|
+
export { ActivityLine, Avatar, Button, type ButtonProps, CardActions, CardCarousel, CardFrame, type CardGroupProps, type CardProps, CardView, type ChatHandlers, ChatHeader, ChatSkeleton, type ChatSlots, type ColorSchemeSetting, Composer, type ComposerProps, DefaultBubble, DefaultComposer, DefaultHeader, DefaultTurnFailed, DefaultUnavailable, DisclosureBar, type EmptyStateProps, type FailureAction, FailureActionButton, type FailureProps, type FailureState, type HeaderProps, InfoCard, type LifecycleTarget, LinksCard, type ListProps, ListingCard, MessageBubble, type MessageBubbleProps, MessageList, NextStepCard, ProposalCard, type ProposalDecision, QuestionCard, Row, StatusBanner, StreamingBubble, SystemRow, type Theme, type ThemeOverrides, ThemeProvider, TimeSlotsCard, VinaverseChat, type VinaverseChatProps, VinaverseChatProvider, Welcome, announce, answerText, carousels, createTheme, defaultCard, fieldText, itemType, monogram, ratingText, themeProblems, useChat, useNativeLifecycle, useReducedMotion, useTheme };
|