@joinskips/brand 9.0.0-develop.146 → 9.0.0-develop.148

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.
Files changed (55) hide show
  1. package/chat/{attachments.d.ts → helpers/attachments.d.ts} +2 -1
  2. package/chat/helpers/cable.d.ts +34 -0
  3. package/chat/helpers/cable.js +88 -0
  4. package/chat/helpers/cableFrames.d.ts +40 -0
  5. package/chat/helpers/cableFrames.js +70 -0
  6. package/chat/helpers/index.d.ts +10 -0
  7. package/chat/helpers/index.js +10 -0
  8. package/chat/helpers/skipsMessage.d.ts +52 -0
  9. package/chat/helpers/skipsMessage.js +129 -0
  10. package/chat/hooks/index.d.ts +6 -0
  11. package/chat/hooks/index.js +6 -0
  12. package/chat/hooks/useCodeEntry.d.ts +6 -0
  13. package/chat/hooks/useCodeEntry.js +14 -0
  14. package/chat/hooks/useComposer.d.ts +20 -0
  15. package/chat/hooks/useComposer.js +40 -0
  16. package/chat/hooks/useResendCountdown.d.ts +2 -0
  17. package/chat/hooks/useResendCountdown.js +19 -0
  18. package/chat/hooks/useStepField.d.ts +8 -0
  19. package/chat/hooks/useStepField.js +17 -0
  20. package/chat/hooks/useTypingCue.d.ts +11 -0
  21. package/chat/hooks/useTypingCue.js +41 -0
  22. package/chat/hooks/useWelcomeTyping.d.ts +2 -0
  23. package/chat/hooks/useWelcomeTyping.js +25 -0
  24. package/chat/index.d.ts +3 -11
  25. package/chat/index.js +3 -10
  26. package/chat/ui/CheckIn.d.ts +25 -0
  27. package/chat/ui/CheckIn.js +24 -0
  28. package/chat/{components → ui}/Conversation.d.ts +3 -6
  29. package/chat/{components → ui}/Conversation.js +5 -29
  30. package/chat/{components → ui}/Markdown.js +1 -1
  31. package/chat/{components → ui}/Welcome.d.ts +21 -8
  32. package/chat/{components → ui}/Welcome.js +17 -43
  33. package/chat/ui/index.d.ts +5 -0
  34. package/chat/ui/index.js +4 -0
  35. package/chat/{components → ui}/parts.d.ts +1 -1
  36. package/package.json +13 -1
  37. /package/chat/{attachments.js → helpers/attachments.js} +0 -0
  38. /package/chat/{markdown.d.ts → helpers/markdown.d.ts} +0 -0
  39. /package/chat/{markdown.js → helpers/markdown.js} +0 -0
  40. /package/chat/{message.d.ts → helpers/message.d.ts} +0 -0
  41. /package/chat/{message.js → helpers/message.js} +0 -0
  42. /package/chat/{skipTyping.d.ts → helpers/skipTyping.d.ts} +0 -0
  43. /package/chat/{skipTyping.js → helpers/skipTyping.js} +0 -0
  44. /package/chat/{thread.d.ts → helpers/thread.d.ts} +0 -0
  45. /package/chat/{thread.js → helpers/thread.js} +0 -0
  46. /package/chat/{typing.d.ts → helpers/typing.d.ts} +0 -0
  47. /package/chat/{typing.js → helpers/typing.js} +0 -0
  48. /package/chat/{visibleArea.d.ts → helpers/visibleArea.d.ts} +0 -0
  49. /package/chat/{visibleArea.js → helpers/visibleArea.js} +0 -0
  50. /package/chat/{welcome.d.ts → helpers/welcome.d.ts} +0 -0
  51. /package/chat/{welcome.js → helpers/welcome.js} +0 -0
  52. /package/chat/{components → ui}/Bubble.d.ts +0 -0
  53. /package/chat/{components → ui}/Bubble.js +0 -0
  54. /package/chat/{components → ui}/Markdown.d.ts +0 -0
  55. /package/chat/{components → ui}/parts.js +0 -0
@@ -7,5 +7,6 @@ export interface FileFacts {
7
7
  type: string;
8
8
  size: number;
9
9
  }
10
+ export type AttachmentProblem = 'type' | 'size';
10
11
  /** Why a picked file cannot be sent, or null when it can. */
11
- export declare function attachmentProblem(file: FileFacts): 'type' | 'size' | null;
12
+ export declare function attachmentProblem(file: FileFacts): AttachmentProblem | null;
@@ -0,0 +1,34 @@
1
+ import { type ChatEvent } from './cableFrames.ts';
2
+ export declare const STALE_MS = 10000;
3
+ export declare const FIRST_RETRY_MS = 1000;
4
+ export declare const MAX_RETRY_MS = 30000;
5
+ export type CableState = 'connecting' | 'live' | 'down';
6
+ export interface CableOptions {
7
+ careTeamName: string;
8
+ createSocket: (url: string) => Socket;
9
+ now: () => number;
10
+ }
11
+ export interface CableHandlers {
12
+ onEvent: (event: ChatEvent) => void;
13
+ onState: (state: CableState) => void;
14
+ onKeysRefused: () => void;
15
+ }
16
+ /** The socket address for a Skips App origin, such as https://app.joinskips.com. */
17
+ export declare const cableUrl: (origin: string) => string;
18
+ /** The wait before the nth reconnect, doubling up to MAX_RETRY_MS. */
19
+ export declare const retryDelay: (attempt: number) => number;
20
+ export interface SocketMessage {
21
+ data: unknown;
22
+ }
23
+ export interface Socket extends Pick<WebSocket, 'send' | 'close'> {
24
+ onopen: ((event: unknown) => void) | null;
25
+ onmessage: ((event: SocketMessage) => void) | null;
26
+ onclose: ((event: unknown) => void) | null;
27
+ onerror: ((event: unknown) => void) | null;
28
+ }
29
+ /**
30
+ * Opens the feed for the member's keys, the Skips App's pubsub tokens, on sockets the app makes with createSocket.
31
+ * now is the app's clock, which the stale check reads.
32
+ * Returns a function that closes it for good.
33
+ */
34
+ export declare function openCable(url: string, keys: string[], handlers: CableHandlers, { careTeamName, createSocket, now }: CableOptions): () => void;
@@ -0,0 +1,88 @@
1
+ // A small ActionCable client for the Skips App's RoomChannel. It says when the feed is live or down, so a silent drop
2
+ // never goes unnoticed: no frame for STALE_MS counts as down, and it reconnects with backoff. The Skips App pings
3
+ // every 3 seconds.
4
+ import { readFrame } from "./cableFrames.js";
5
+ export const STALE_MS = 10_000;
6
+ export const FIRST_RETRY_MS = 1_000;
7
+ export const MAX_RETRY_MS = 30_000;
8
+ /** The socket address for a Skips App origin, such as https://app.joinskips.com. */
9
+ export const cableUrl = (origin) => `${origin.replace(/\/$/, '').replace(/^http/, 'ws')}/cable`;
10
+ /** The wait before the nth reconnect, doubling up to MAX_RETRY_MS. */
11
+ export const retryDelay = (attempt) => Math.min(MAX_RETRY_MS, FIRST_RETRY_MS * 2 ** attempt);
12
+ /**
13
+ * Opens the feed for the member's keys, the Skips App's pubsub tokens, on sockets the app makes with createSocket.
14
+ * now is the app's clock, which the stale check reads.
15
+ * Returns a function that closes it for good.
16
+ */
17
+ export function openCable(url, keys, handlers, { careTeamName, createSocket, now }) {
18
+ let socket = null;
19
+ let attempt = 0;
20
+ let lastFrameAt = now();
21
+ let closed = false;
22
+ let retry = null;
23
+ let state = null;
24
+ const setState = (next) => {
25
+ if (next !== state)
26
+ handlers.onState((state = next));
27
+ };
28
+ const drop = (reconnect) => {
29
+ if (socket) {
30
+ const old = socket;
31
+ socket = null;
32
+ old.onclose = old.onmessage = old.onerror = old.onopen = null;
33
+ old.close();
34
+ }
35
+ setState('down');
36
+ if (reconnect && !closed && !retry)
37
+ retry = setTimeout(connect, retryDelay(attempt++));
38
+ };
39
+ function connect() {
40
+ retry = null;
41
+ setState('connecting');
42
+ lastFrameAt = now();
43
+ const next = createSocket(url);
44
+ socket = next;
45
+ next.onmessage = ({ data }) => {
46
+ lastFrameAt = now();
47
+ const frame = readFrame(String(data), careTeamName);
48
+ if (frame.type === 'welcome') {
49
+ attempt = 0;
50
+ for (const key of keys) {
51
+ next.send(JSON.stringify({
52
+ command: 'subscribe',
53
+ identifier: JSON.stringify({ channel: 'RoomChannel', pubsub_token: key }),
54
+ }));
55
+ }
56
+ }
57
+ else if (frame.type === 'confirm_subscription')
58
+ setState('live');
59
+ else if (frame.type === 'event')
60
+ handlers.onEvent(frame.event);
61
+ else if (frame.type === 'reject_subscription' || (frame.type === 'disconnect' && !frame.reconnect)) {
62
+ drop(false);
63
+ handlers.onKeysRefused();
64
+ }
65
+ else if (frame.type === 'disconnect')
66
+ drop(true);
67
+ };
68
+ next.onclose = () => {
69
+ drop(true);
70
+ };
71
+ next.onerror = () => {
72
+ drop(true);
73
+ };
74
+ }
75
+ const watchdog = setInterval(() => {
76
+ if (socket && now() - lastFrameAt > STALE_MS)
77
+ drop(true);
78
+ }, STALE_MS / 2);
79
+ connect();
80
+ return () => {
81
+ closed = true;
82
+ clearInterval(watchdog);
83
+ if (retry)
84
+ clearTimeout(retry);
85
+ retry = null;
86
+ drop(false);
87
+ };
88
+ }
@@ -0,0 +1,40 @@
1
+ import type { ChatMessage } from './message.ts';
2
+ interface ChatMessageEvent {
3
+ kind: 'message';
4
+ conversationId: number;
5
+ message: ChatMessage;
6
+ }
7
+ interface TypingEvent {
8
+ kind: 'typing';
9
+ conversationId: number;
10
+ typing: boolean;
11
+ name: string;
12
+ }
13
+ interface ConversationEvent {
14
+ kind: 'conversation';
15
+ conversationId: number;
16
+ }
17
+ export type ChatEvent = ChatMessageEvent | TypingEvent | ConversationEvent;
18
+ type ControlType = 'welcome' | 'ping' | 'confirm_subscription' | 'reject_subscription';
19
+ interface ControlFrame {
20
+ type: ControlType;
21
+ }
22
+ interface DisconnectFrame {
23
+ type: 'disconnect';
24
+ reconnect: boolean;
25
+ }
26
+ interface EventFrame {
27
+ type: 'event';
28
+ event: ChatEvent;
29
+ }
30
+ interface IgnoredFrame {
31
+ type: 'ignored';
32
+ }
33
+ /** One ActionCable frame: a control frame the client handles, or a Skips App event. */
34
+ export type CableFrame = ControlFrame | DisconnectFrame | EventFrame | IgnoredFrame;
35
+ /**
36
+ * Reads one frame of text from the socket. A frame that is not JSON, or not one the app knows, is ignored.
37
+ * careTeamName is the app's name for a care team line with no named sender (toChatMessage).
38
+ */
39
+ export declare function readFrame(text: string, careTeamName: string): CableFrame;
40
+ export {};
@@ -0,0 +1,70 @@
1
+ // What the Skips App's live socket says, read into the few things an app acts on. Shapes come from the socket itself
2
+ // (message_type and created_at as numbers, the member's own typing never sent back), and anything else is ignored.
3
+ import { firstFilled, isNullableString, isObject, isRawMessage, optional, toChatMessage } from "./skipsMessage.js";
4
+ const CONTROL_TYPES = ['welcome', 'ping', 'confirm_subscription', 'reject_subscription'];
5
+ const IGNORED = { type: 'ignored' };
6
+ function isTypingData(value) {
7
+ if (!isObject(value) || !isObject(value.user) || !isObject(value.conversation))
8
+ return false;
9
+ const { user } = value;
10
+ return (optional(value.is_private, (flag) => typeof flag === 'boolean') &&
11
+ optional(user.type, (type) => typeof type === 'string') &&
12
+ optional(user.available_name, isNullableString) &&
13
+ optional(user.name, isNullableString) &&
14
+ typeof value.conversation.id === 'number');
15
+ }
16
+ const fieldIn = (value, key) => (isObject(value) ? value[key] : undefined);
17
+ function toEvent(message, careTeamName) {
18
+ const event = fieldIn(message, 'event');
19
+ const data = fieldIn(message, 'data');
20
+ switch (event) {
21
+ case 'message.created':
22
+ case 'message.updated': {
23
+ if (!isRawMessage(data))
24
+ return null;
25
+ const chatMessage = toChatMessage(data, careTeamName);
26
+ return chatMessage ? { kind: 'message', conversationId: data.conversation_id ?? 0, message: chatMessage } : null;
27
+ }
28
+ case 'conversation.typing_on':
29
+ case 'conversation.typing_off': {
30
+ // A private note's typing is the care team's own, and a contact's typing is the member's.
31
+ if (!isTypingData(data) || data.is_private || data.user.type === 'contact')
32
+ return null;
33
+ return {
34
+ kind: 'typing',
35
+ conversationId: data.conversation.id,
36
+ typing: event === 'conversation.typing_on',
37
+ name: firstFilled(data.user.available_name, data.user.name) ?? '',
38
+ };
39
+ }
40
+ // Only which conversation changed: its fields on the socket can be partial, so the app asks for them again.
41
+ case 'conversation.updated':
42
+ case 'conversation.status_changed': {
43
+ const id = fieldIn(data, 'id');
44
+ return typeof id === 'number' ? { kind: 'conversation', conversationId: id } : null;
45
+ }
46
+ default:
47
+ return null;
48
+ }
49
+ }
50
+ /**
51
+ * Reads one frame of text from the socket. A frame that is not JSON, or not one the app knows, is ignored.
52
+ * careTeamName is the app's name for a care team line with no named sender (toChatMessage).
53
+ */
54
+ export function readFrame(text, careTeamName) {
55
+ let frame;
56
+ try {
57
+ frame = JSON.parse(text);
58
+ }
59
+ catch {
60
+ return IGNORED;
61
+ }
62
+ const type = fieldIn(frame, 'type');
63
+ if (type === 'disconnect')
64
+ return { type: 'disconnect', reconnect: fieldIn(frame, 'reconnect') !== false };
65
+ const control = CONTROL_TYPES.find((each) => each === type);
66
+ if (control)
67
+ return { type: control };
68
+ const event = toEvent(fieldIn(frame, 'message'), careTeamName);
69
+ return event ? { type: 'event', event } : IGNORED;
70
+ }
@@ -0,0 +1,10 @@
1
+ export { ATTACHMENT_TYPES, MAX_ATTACHMENT_BYTES, attachmentProblem, attachmentType, type AttachmentProblem } from './attachments.ts';
2
+ export { isSkip, type ChatAttachment, type ChatAuthor, type ChatMessage, type ChoiceItem, type MessageChoice, type PickedFile, } from './message.ts';
3
+ export { CLUSTER_GAP_MS, EMPTY_THREAD, groupThread, pendingId, withFailed, withoutMessage, withPending, withReceived, withReceivedAll, withSent, type Delivery, type RunSender, type Thread, type ThreadItem, type ThreadMessage, } from './thread.ts';
4
+ export { TYPING_CLEAR_MS, TYPING_IDLE_MS, createTypingSignal, createTypingWatch } from './typing.ts';
5
+ export { DOT_CYCLE_MS, TYPING_IDLE, TYPING_TIMES, heldFrom, typingReducer, type TypingEvent, type TypingSignal, type TypingStarted, type TypingState, type TypingTimes, } from './skipTyping.ts';
6
+ export { fitVisibleArea, type Fit, type VisualViewportBox } from './visibleArea.ts';
7
+ export { FIRST_RETRY_MS, MAX_RETRY_MS, STALE_MS, cableUrl, openCable, retryDelay, type CableHandlers, type CableOptions, type CableState, type Socket, type SocketMessage, } from './cable.ts';
8
+ export { readFrame, type CableFrame, type ChatEvent } from './cableFrames.ts';
9
+ export { CHOICE_CONTENT_TYPE, choiceFrom, fileNameIn, firstFilled, fromContact, isRawMessage, toChatMessage, toMs, type RawMessage, type RawMessageFile, type RawSender, } from './skipsMessage.ts';
10
+ export { EMAIL_MAX_LENGTH, NAME_MAX_LENGTH, RESEND_AFTER_MS, WELCOME_TYPING_TIMES, givenEmail, givenName, isEmail, isName, typesBefore, typingMs, type WelcomeStep, type WelcomeTypingTimes, } from './welcome.ts';
@@ -0,0 +1,10 @@
1
+ export { ATTACHMENT_TYPES, MAX_ATTACHMENT_BYTES, attachmentProblem, attachmentType } from "./attachments.js";
2
+ export { isSkip, } from "./message.js";
3
+ export { CLUSTER_GAP_MS, EMPTY_THREAD, groupThread, pendingId, withFailed, withoutMessage, withPending, withReceived, withReceivedAll, withSent, } from "./thread.js";
4
+ export { TYPING_CLEAR_MS, TYPING_IDLE_MS, createTypingSignal, createTypingWatch } from "./typing.js";
5
+ export { DOT_CYCLE_MS, TYPING_IDLE, TYPING_TIMES, heldFrom, typingReducer, } from "./skipTyping.js";
6
+ export { fitVisibleArea } from "./visibleArea.js";
7
+ export { FIRST_RETRY_MS, MAX_RETRY_MS, STALE_MS, cableUrl, openCable, retryDelay, } from "./cable.js";
8
+ export { readFrame } from "./cableFrames.js";
9
+ export { CHOICE_CONTENT_TYPE, choiceFrom, fileNameIn, firstFilled, fromContact, isRawMessage, toChatMessage, toMs, } from "./skipsMessage.js";
10
+ export { EMAIL_MAX_LENGTH, NAME_MAX_LENGTH, RESEND_AFTER_MS, WELCOME_TYPING_TIMES, givenEmail, givenName, isEmail, isName, typesBefore, typingMs, } from "./welcome.js";
@@ -0,0 +1,52 @@
1
+ import type { ChatMessage, MessageChoice } from './message.ts';
2
+ export interface RawSender {
3
+ id?: number;
4
+ type?: string;
5
+ name?: string | null;
6
+ available_name?: string | null;
7
+ thumbnail?: string | null;
8
+ }
9
+ export interface RawMessageFile {
10
+ file_type?: string;
11
+ data_url?: string;
12
+ thumb_url?: string | null;
13
+ file_name?: string | null;
14
+ }
15
+ /** A message as the Skips App's API and its socket give it. The socket spells message_type as a word. */
16
+ export interface RawMessage {
17
+ id: number;
18
+ conversation_id?: number;
19
+ content: string | null;
20
+ message_type: number | string;
21
+ created_at: number | string;
22
+ private?: boolean;
23
+ sender?: RawSender | null;
24
+ attachments?: RawMessageFile[];
25
+ content_type?: unknown;
26
+ content_attributes?: unknown;
27
+ }
28
+ export type JsonObject = Record<string, unknown>;
29
+ export declare const isObject: (value: unknown) => value is JsonObject;
30
+ export declare const isNullableString: (value: unknown) => value is string | null;
31
+ export declare const optional: (value: unknown, check: (value: unknown) => boolean) => boolean;
32
+ /** Whether a value from the Skips App has a message's shape, every field it carries checked. */
33
+ export declare function isRawMessage(value: unknown): value is RawMessage;
34
+ /** The first value that holds text, an empty string counting as none, or undefined when none does. */
35
+ export declare const firstFilled: (...values: (string | null | undefined)[]) => string | undefined;
36
+ /** A file's name from its Skips App address, which ends with it. */
37
+ export declare const fileNameIn: (url: string) => string;
38
+ export declare const fromContact: (raw: RawMessage) => boolean;
39
+ /** A Skips App time in milliseconds: the API gives seconds, the socket text. */
40
+ export declare const toMs: (value: number | string) => number;
41
+ export declare const CHOICE_CONTENT_TYPE = "input_select";
42
+ /**
43
+ * A question's buttons, with the answer already given if it is one of them. A message of another type, or one whose
44
+ * buttons cannot all be read, offers none: a button with no words could not be pressed knowingly. Nor does one with
45
+ * two buttons of the same value, since the answer kept could not say which was pressed.
46
+ */
47
+ export declare function choiceFrom(contentType: unknown, attributes: unknown): MessageChoice | null;
48
+ /**
49
+ * The member's view of a message, or null when it is a private note or an activity the member does not see.
50
+ * careTeamName, the app's own words, names a care team line whose sender the Skips App leaves unnamed.
51
+ */
52
+ export declare function toChatMessage(raw: RawMessage, careTeamName: string): ChatMessage | null;
@@ -0,0 +1,129 @@
1
+ // A Skips App message as its API and its live socket give it, and the member's view of it. Neither ever shows the
2
+ // member a private note or an internal activity line.
3
+ export const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ const isNumber = (value) => typeof value === 'number';
5
+ const isString = (value) => typeof value === 'string';
6
+ const isBoolean = (value) => typeof value === 'boolean';
7
+ const isNumberOrString = (value) => isNumber(value) || isString(value);
8
+ export const isNullableString = (value) => value === null || isString(value);
9
+ // A field left out passes, and a field that is there must have its type.
10
+ export const optional = (value, check) => value === undefined || check(value);
11
+ function isRawSender(value) {
12
+ return (isObject(value) &&
13
+ optional(value.id, isNumber) &&
14
+ optional(value.type, isString) &&
15
+ optional(value.name, isNullableString) &&
16
+ optional(value.available_name, isNullableString) &&
17
+ optional(value.thumbnail, isNullableString));
18
+ }
19
+ function isRawMessageFile(value) {
20
+ return (isObject(value) &&
21
+ optional(value.file_type, isString) &&
22
+ optional(value.data_url, isString) &&
23
+ optional(value.thumb_url, isNullableString) &&
24
+ optional(value.file_name, isNullableString));
25
+ }
26
+ /** Whether a value from the Skips App has a message's shape, every field it carries checked. */
27
+ export function isRawMessage(value) {
28
+ return (isObject(value) &&
29
+ isNumber(value.id) &&
30
+ optional(value.conversation_id, isNumber) &&
31
+ isNullableString(value.content) &&
32
+ isNumberOrString(value.message_type) &&
33
+ isNumberOrString(value.created_at) &&
34
+ optional(value.private, isBoolean) &&
35
+ optional(value.sender, (sender) => sender === null || isRawSender(sender)) &&
36
+ optional(value.attachments, (files) => Array.isArray(files) && files.every(isRawMessageFile)));
37
+ }
38
+ /** The first value that holds text, an empty string counting as none, or undefined when none does. */
39
+ export const firstFilled = (...values) => values.find((value) => Boolean(value));
40
+ /** A file's name from its Skips App address, which ends with it. */
41
+ export const fileNameIn = (url) => {
42
+ let path = url;
43
+ try {
44
+ path = new URL(url).pathname;
45
+ }
46
+ catch {
47
+ // Not a full address: its last part is still the best name there is.
48
+ }
49
+ const name = path.slice(path.lastIndexOf('/') + 1);
50
+ try {
51
+ return decodeURIComponent(name);
52
+ }
53
+ catch {
54
+ return name;
55
+ }
56
+ };
57
+ // message_type 0 is the contact's, 2 an activity. The socket sends the names instead of the numbers.
58
+ export const fromContact = (raw) => raw.sender?.type === 'contact' || raw.message_type === 0 || raw.message_type === 'incoming';
59
+ const isActivity = (raw) => raw.message_type === 2 || raw.message_type === 'activity';
60
+ // Of the Skips App's activity lines, only a conversation closing or reopening is the member's business.
61
+ const NOTICE = /conversation was (resolved|reopened)|(resolved|reopened) the conversation/i;
62
+ /** A Skips App time in milliseconds: the API gives seconds, the socket text. */
63
+ export const toMs = (value) => (typeof value === 'number' ? value * 1000 : Date.parse(value));
64
+ // The Skips App's question answered with one of its buttons.
65
+ export const CHOICE_CONTENT_TYPE = 'input_select';
66
+ function isChoiceItem(value) {
67
+ return (isObject(value) &&
68
+ isString(value.title) &&
69
+ value.title.trim().length > 0 &&
70
+ isString(value.value) &&
71
+ value.value.length > 0);
72
+ }
73
+ /**
74
+ * A question's buttons, with the answer already given if it is one of them. A message of another type, or one whose
75
+ * buttons cannot all be read, offers none: a button with no words could not be pressed knowingly. Nor does one with
76
+ * two buttons of the same value, since the answer kept could not say which was pressed.
77
+ */
78
+ export function choiceFrom(contentType, attributes) {
79
+ if (contentType !== CHOICE_CONTENT_TYPE || !isObject(attributes))
80
+ return null;
81
+ const { items, submitted_values: submitted } = attributes;
82
+ if (!Array.isArray(items) || items.length === 0 || !items.every(isChoiceItem))
83
+ return null;
84
+ if (new Set(items.map((item) => item.value)).size !== items.length)
85
+ return null;
86
+ const first = Array.isArray(submitted) ? submitted[0] : null;
87
+ const given = isObject(first) ? first.value : null;
88
+ const chosen = items.find((item) => item.value === given)?.value ?? null;
89
+ return { items, chosen };
90
+ }
91
+ /**
92
+ * The member's view of a message, or null when it is a private note or an activity the member does not see.
93
+ * careTeamName, the app's own words, names a care team line whose sender the Skips App leaves unnamed.
94
+ */
95
+ export function toChatMessage(raw, careTeamName) {
96
+ if (raw.private)
97
+ return null;
98
+ const notice = isActivity(raw);
99
+ if (notice && !NOTICE.test(raw.content ?? ''))
100
+ return null;
101
+ const mine = !notice && fromContact(raw);
102
+ const choice = mine || notice ? null : choiceFrom(raw.content_type, raw.content_attributes);
103
+ return {
104
+ ...(choice === null ? {} : { choice }),
105
+ id: raw.id,
106
+ text: raw.content ?? '',
107
+ sentAt: toMs(raw.created_at),
108
+ mine,
109
+ notice,
110
+ author: mine || notice
111
+ ? null
112
+ : {
113
+ id: raw.sender?.id ?? null,
114
+ name: firstFilled(raw.sender?.available_name, raw.sender?.name) ?? careTeamName,
115
+ avatarUrl: firstFilled(raw.sender?.thumbnail) ?? null,
116
+ bot: raw.sender?.type === 'agent_bot',
117
+ },
118
+ attachments: (raw.attachments ?? []).flatMap((a) => a.data_url
119
+ ? [
120
+ {
121
+ kind: a.file_type === 'image' ? 'image' : 'file',
122
+ url: a.data_url,
123
+ thumbUrl: a.thumb_url ?? null,
124
+ name: firstFilled(a.file_name) ?? fileNameIn(a.data_url),
125
+ },
126
+ ]
127
+ : []),
128
+ };
129
+ }
@@ -0,0 +1,6 @@
1
+ export { useCodeEntry, type CodeEntry } from './useCodeEntry.ts';
2
+ export { useComposer, type Composer, type ComposerOptions } from './useComposer.ts';
3
+ export { useResendCountdown } from './useResendCountdown.ts';
4
+ export { useStepField, type StepField } from './useStepField.ts';
5
+ export { useTypingCue, type SkipsTyping, type TypingCue } from './useTypingCue.ts';
6
+ export { useWelcomeTyping } from './useWelcomeTyping.ts';
@@ -0,0 +1,6 @@
1
+ export { useCodeEntry } from "./useCodeEntry.js";
2
+ export { useComposer } from "./useComposer.js";
3
+ export { useResendCountdown } from "./useResendCountdown.js";
4
+ export { useStepField } from "./useStepField.js";
5
+ export { useTypingCue } from "./useTypingCue.js";
6
+ export { useWelcomeTyping } from "./useWelcomeTyping.js";
@@ -0,0 +1,6 @@
1
+ /** The emailed code as it is typed: digits only, handed on by itself once it is whole. */
2
+ export interface CodeEntry {
3
+ code: string;
4
+ onChangeText: (typed: string) => void;
5
+ }
6
+ export declare function useCodeEntry(length: number, onSubmit: (code: string) => void): CodeEntry;
@@ -0,0 +1,14 @@
1
+ import { useState } from 'react';
2
+ import { codeDigits, completesCode } from "../helpers/welcome.js";
3
+ export function useCodeEntry(length, onSubmit) {
4
+ const [code, setCode] = useState('');
5
+ return {
6
+ code,
7
+ onChangeText: (typed) => {
8
+ const digits = codeDigits(typed, length);
9
+ setCode(digits);
10
+ if (completesCode(digits, code, length))
11
+ onSubmit(digits);
12
+ },
13
+ };
14
+ }
@@ -0,0 +1,20 @@
1
+ import { type AttachmentProblem } from '../helpers/attachments.ts';
2
+ import type { PickedFile } from '../helpers/message.ts';
3
+ export interface ComposerOptions {
4
+ onSend: (text: string, file: PickedFile | null) => void;
5
+ onTyped: (text: string) => void;
6
+ pickFile?: () => Promise<PickedFile | null>;
7
+ initialText?: string;
8
+ }
9
+ /** The message box's state and what each control does, which Conversation draws. */
10
+ export interface Composer {
11
+ text: string;
12
+ picked: PickedFile | null;
13
+ refused: AttachmentProblem | null;
14
+ canSend: boolean;
15
+ onChangeText: (text: string) => void;
16
+ attach: (() => void) | null;
17
+ remove: () => void;
18
+ submit: () => void;
19
+ }
20
+ export declare function useComposer({ onSend, onTyped, pickFile, initialText }: ComposerOptions): Composer;
@@ -0,0 +1,40 @@
1
+ import { useState } from 'react';
2
+ import { attachmentProblem } from "../helpers/attachments.js";
3
+ export function useComposer({ onSend, onTyped, pickFile, initialText = '' }) {
4
+ const [text, setText] = useState(initialText);
5
+ const [picked, setPicked] = useState(null);
6
+ const [refused, setRefused] = useState(null);
7
+ const attach = async (pick) => {
8
+ const file = await pick();
9
+ if (!file)
10
+ return;
11
+ const problem = attachmentProblem(file);
12
+ setRefused(problem);
13
+ if (!problem)
14
+ setPicked(file);
15
+ };
16
+ return {
17
+ text,
18
+ picked,
19
+ refused,
20
+ canSend: Boolean(text.trim() || picked),
21
+ onChangeText: (value) => {
22
+ setText(value);
23
+ onTyped(value);
24
+ },
25
+ attach: pickFile
26
+ ? () => {
27
+ void attach(pickFile);
28
+ }
29
+ : null,
30
+ remove: () => {
31
+ setPicked(null);
32
+ },
33
+ submit: () => {
34
+ onSend(text, picked);
35
+ setText('');
36
+ setPicked(null);
37
+ setRefused(null);
38
+ },
39
+ };
40
+ }
@@ -0,0 +1,2 @@
1
+ /** Whole seconds left before a new code can be sent, counting down to 0 from when the wait starts. */
2
+ export declare function useResendCountdown(waitMs: number): number;
@@ -0,0 +1,19 @@
1
+ import { useEffect, useState } from 'react';
2
+ const TICK_MS = 250;
3
+ /** Whole seconds left before a new code can be sent, counting down to 0 from when the wait starts. */
4
+ export function useResendCountdown(waitMs) {
5
+ const [secondsLeft, setSecondsLeft] = useState(Math.ceil(waitMs / 1000));
6
+ useEffect(() => {
7
+ const end = Date.now() + waitMs;
8
+ const timer = setInterval(() => {
9
+ const left = Math.max(0, Math.ceil((end - Date.now()) / 1000));
10
+ setSecondsLeft(left);
11
+ if (left === 0)
12
+ clearInterval(timer);
13
+ }, TICK_MS);
14
+ return () => {
15
+ clearInterval(timer);
16
+ };
17
+ }, [waitMs]);
18
+ return secondsLeft;
19
+ }
@@ -0,0 +1,8 @@
1
+ /** A welcome step's field: what was typed, whether it was refused, and its change and submit. */
2
+ export interface StepField {
3
+ typed: string;
4
+ refused: boolean;
5
+ onChangeText: (typed: string) => void;
6
+ submit: () => void;
7
+ }
8
+ export declare function useStepField(usable: (typed: string) => string | null, onSubmit: (value: string) => void, initial?: string): StepField;
@@ -0,0 +1,17 @@
1
+ import { useState } from 'react';
2
+ // usable turns what was typed into what is handed on, or null when it cannot be used, as givenEmail and givenName do.
3
+ export function useStepField(usable, onSubmit, initial = '') {
4
+ const [typed, setTyped] = useState(initial);
5
+ const [refused, setRefused] = useState(false);
6
+ return {
7
+ typed,
8
+ refused,
9
+ onChangeText: setTyped,
10
+ submit: () => {
11
+ const value = usable(typed);
12
+ setRefused(value === null);
13
+ if (value !== null)
14
+ onSubmit(value);
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,11 @@
1
+ import { type TypingTimes } from '../helpers/skipTyping.ts';
2
+ /** The Skips App's last word on Skip typing. */
3
+ export interface SkipsTyping {
4
+ typing: boolean;
5
+ count: number;
6
+ }
7
+ export interface TypingCue {
8
+ dots: boolean;
9
+ held: ReadonlySet<number>;
10
+ }
11
+ export declare function useTypingCue(skipsLineIds: readonly number[], skipsTyping: SkipsTyping, times?: TypingTimes): TypingCue;
@@ -0,0 +1,41 @@
1
+ import { useEffect, useReducer, useState } from 'react';
2
+ import { heldFrom, TYPING_IDLE, TYPING_TIMES, typingReducer } from "../helpers/skipTyping.js";
3
+ const NONE = new Set();
4
+ // The Skips App's word on Skip typing and Skip's lines landing drive the cue, and two timers keep the dots up for
5
+ // their minimum and stop them at the limit. skipsLineIds are Skip's lines in the conversation, in order.
6
+ export function useTypingCue(skipsLineIds, skipsTyping, times = TYPING_TIMES) {
7
+ const [state, dispatch] = useReducer(typingReducer, TYPING_IDLE);
8
+ const [wordsSeen, setWordsSeen] = useState(skipsTyping.count);
9
+ const [linesSeen, setLinesSeen] = useState(skipsLineIds.length);
10
+ if (skipsTyping.count !== wordsSeen) {
11
+ setWordsSeen(skipsTyping.count);
12
+ // The lines before this render: a reply that lands with typing_on, as one sent in a keystroke does, waits for the dots.
13
+ dispatch(skipsTyping.typing ? { type: 'typing', skipsLines: linesSeen } : { type: 'stopped' });
14
+ }
15
+ if (skipsLineIds.length !== linesSeen) {
16
+ setLinesSeen(skipsLineIds.length);
17
+ dispatch({ type: 'stopped' });
18
+ }
19
+ useEffect(() => {
20
+ if (!state.dots || state.shown)
21
+ return undefined;
22
+ const shown = setTimeout(() => {
23
+ dispatch({ type: 'shown' });
24
+ }, times.leastMs);
25
+ return () => {
26
+ clearTimeout(shown);
27
+ };
28
+ }, [state.dots, state.shown, state.turn, times.leastMs]);
29
+ useEffect(() => {
30
+ if (!state.dots)
31
+ return undefined;
32
+ const capped = setTimeout(() => {
33
+ dispatch({ type: 'capped' });
34
+ }, times.limitMs);
35
+ return () => {
36
+ clearTimeout(capped);
37
+ };
38
+ }, [state.dots, state.beats, times.limitMs]);
39
+ const from = heldFrom(state);
40
+ return { dots: state.dots, held: from === null ? NONE : new Set(skipsLineIds.slice(from)) };
41
+ }
@@ -0,0 +1,2 @@
1
+ import { type WelcomeStep, type WelcomeTypingTimes } from '../helpers/welcome.ts';
2
+ export declare function useWelcomeTyping(step: WelcomeStep | null, times?: WelcomeTypingTimes): WelcomeStep | null;
@@ -0,0 +1,25 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { typesBefore, typingMs, WELCOME_TYPING_TIMES, } from "../helpers/welcome.js";
3
+ // The welcome step whose new line Skip is still typing, kept out of sight with its field or buttons until the
4
+ // dots go, or null.
5
+ export function useWelcomeTyping(step, times = WELCOME_TYPING_TIMES) {
6
+ const [seen, setSeen] = useState(null);
7
+ const [typing, setTyping] = useState(null);
8
+ const { leastMs, mostMs } = times;
9
+ if (step !== seen) {
10
+ setSeen(step);
11
+ // With no time to type in, the line shows as the step is reached.
12
+ setTyping(step !== null && mostMs > 0 && typesBefore(seen, step) ? step : null);
13
+ }
14
+ useEffect(() => {
15
+ if (typing === null)
16
+ return undefined;
17
+ const typed = setTimeout(() => {
18
+ setTyping(null);
19
+ }, typingMs({ leastMs, mostMs }, Math.random()));
20
+ return () => {
21
+ clearTimeout(typed);
22
+ };
23
+ }, [typing, leastMs, mostMs]);
24
+ return typing;
25
+ }
package/chat/index.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- export { Conversation, type ConversationProps, type LoadState } from './components/Conversation.tsx';
2
- export { Bubble, type BubbleProps } from './components/Bubble.tsx';
3
- export type { ChatIcon, ChatIconName, ChatWords } from './components/parts.ts';
4
- export { ATTACHMENT_TYPES, MAX_ATTACHMENT_BYTES, attachmentProblem, attachmentType } from './attachments.ts';
5
- export { isSkip, type ChatAttachment, type ChatAuthor, type ChatMessage, type ChoiceItem, type MessageChoice, type PickedFile, } from './message.ts';
6
- export { CLUSTER_GAP_MS, EMPTY_THREAD, groupThread, pendingId, withFailed, withoutMessage, withPending, withReceived, withReceivedAll, withSent, type Delivery, type RunSender, type Thread, type ThreadItem, type ThreadMessage, } from './thread.ts';
7
- export { TYPING_CLEAR_MS, TYPING_IDLE_MS, createTypingSignal, createTypingWatch } from './typing.ts';
8
- export { TYPING_IDLE, TYPING_TIMES, heldFrom, typingReducer, type TypingEvent, type TypingSignal, type TypingStarted, type TypingState, type TypingTimes, } from './skipTyping.ts';
9
- export { fitVisibleArea, type Fit, type VisualViewportBox } from './visibleArea.ts';
10
- export { EMAIL_MAX_LENGTH, NAME_MAX_LENGTH, RESEND_AFTER_MS, WELCOME_TYPING_TIMES, givenEmail, givenName, isEmail, isName, typesBefore, typingMs, type WelcomeStep, type WelcomeTypingTimes, } from './welcome.ts';
11
- export { Choices, CodeStep, EmailStep, NameStep, SkipTyping, WelcomeChoice, type WelcomeWords, } from './components/Welcome.tsx';
1
+ export * from './ui/index.ts';
2
+ export * from './hooks/index.ts';
3
+ export * from './helpers/index.ts';
package/chat/index.js CHANGED
@@ -1,10 +1,3 @@
1
- export { Conversation } from "./components/Conversation.js";
2
- export { Bubble } from "./components/Bubble.js";
3
- export { ATTACHMENT_TYPES, MAX_ATTACHMENT_BYTES, attachmentProblem, attachmentType } from "./attachments.js";
4
- export { isSkip, } from "./message.js";
5
- export { CLUSTER_GAP_MS, EMPTY_THREAD, groupThread, pendingId, withFailed, withoutMessage, withPending, withReceived, withReceivedAll, withSent, } from "./thread.js";
6
- export { TYPING_CLEAR_MS, TYPING_IDLE_MS, createTypingSignal, createTypingWatch } from "./typing.js";
7
- export { TYPING_IDLE, TYPING_TIMES, heldFrom, typingReducer, } from "./skipTyping.js";
8
- export { fitVisibleArea } from "./visibleArea.js";
9
- export { EMAIL_MAX_LENGTH, NAME_MAX_LENGTH, RESEND_AFTER_MS, WELCOME_TYPING_TIMES, givenEmail, givenName, isEmail, isName, typesBefore, typingMs, } from "./welcome.js";
10
- export { Choices, CodeStep, EmailStep, NameStep, SkipTyping, WelcomeChoice, } from "./components/Welcome.js";
1
+ export * from "./ui/index.js";
2
+ export * from "./hooks/index.js";
3
+ export * from "./helpers/index.js";
@@ -0,0 +1,25 @@
1
+ import { type ChatIcon } from './parts.ts';
2
+ /** What a person says about one of their current medications. */
3
+ export type MedicationAnswer = 'taking' | 'refill' | 'reorder' | 'stopped';
4
+ /** Every word the medication check-in shows, which the app passes in. */
5
+ export interface CheckInWords {
6
+ taking: string;
7
+ refill: string;
8
+ reorder: string;
9
+ stopped: string;
10
+ whyStopped: string;
11
+ }
12
+ export declare const STOPPED_REASON_MAX_LENGTH = 500;
13
+ export interface MedicationCheckProps {
14
+ name: string;
15
+ directions: string;
16
+ refillable: boolean;
17
+ answer: MedicationAnswer | null;
18
+ reason: string;
19
+ words: CheckInWords;
20
+ Icon: ChatIcon;
21
+ onAnswer: (answer: MedicationAnswer) => void;
22
+ onReason: (reason: string) => void;
23
+ }
24
+ /** One current medication in the check-in: still taking, a refill or re-order, or stopped and why. */
25
+ export declare function MedicationCheck({ name, directions, refillable, answer, reason, words, Icon, onAnswer, onReason, }: MedicationCheckProps): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, Text, TextInput, View } from 'react-native';
3
+ import { useColor } from "./parts.js";
4
+ export const STOPPED_REASON_MAX_LENGTH = 500;
5
+ const ICONS = {
6
+ taking: 'thumbs-up',
7
+ refill: 'repeat',
8
+ reorder: 'copy-plus',
9
+ stopped: 'close',
10
+ };
11
+ const ICON_SIZE = 24;
12
+ /** One current medication in the check-in: still taking, a refill or re-order, or stopped and why. */
13
+ export function MedicationCheck({ name, directions, refillable, answer, reason, words, Icon, onAnswer, onReason, }) {
14
+ const ink = useColor('ink');
15
+ const accentInk = useColor('accent-ink');
16
+ const placeholder = useColor('ink-placeholder');
17
+ const answers = ['taking', refillable ? 'refill' : 'reorder', 'stopped'];
18
+ return (_jsxs(View, { className: "w-80 max-w-full gap-3.5 rounded-[20px] border border-line-subtle bg-surface p-4", children: [_jsxs(View, { className: "gap-0.5", children: [_jsx(Text, { className: "font-ui text-md font-semibold text-ink", children: name }), _jsx(Text, { className: "font-ui text-sm text-ink-secondary", children: directions })] }), _jsx(View, { role: "radiogroup", accessibilityLabel: name, className: "flex-row", children: answers.map((each) => {
19
+ const picked = answer === each;
20
+ return (_jsxs(Pressable, { role: "radio", "aria-checked": picked, accessibilityLabel: words[each], onPress: () => {
21
+ onAnswer(each);
22
+ }, className: "flex-1 items-center gap-1.5", children: [_jsx(View, { className: `h-[52px] w-[52px] items-center justify-center rounded-pill border ${picked ? 'border-accent bg-accent' : 'border-line-control bg-surface'}`, children: _jsx(Icon, { name: ICONS[each], color: picked ? accentInk : ink, size: ICON_SIZE }) }), _jsx(Text, { className: "text-center font-ui text-xs font-semibold text-ink", children: words[each] })] }, each));
23
+ }) }), answer === 'stopped' ? (_jsx(TextInput, { value: reason, onChangeText: onReason, accessibilityLabel: words.whyStopped, placeholder: words.whyStopped, placeholderTextColor: placeholder, multiline: true, maxLength: STOPPED_REASON_MAX_LENGTH, className: "min-h-20 rounded-control border border-line-control bg-surface px-3 py-2 font-ui text-md text-ink" })) : null] }));
24
+ }
@@ -1,6 +1,6 @@
1
1
  import { type ImageSourcePropType } from 'react-native';
2
- import type { PickedFile } from '../message.ts';
3
- import { type Thread } from '../thread.ts';
2
+ import type { Composer } from '../hooks/useComposer.ts';
3
+ import { type Thread } from '../helpers/thread.ts';
4
4
  import { type ChatIcon, type ChatWords } from './parts.ts';
5
5
  export type LoadState = 'loading' | 'ready' | 'failed';
6
6
  export interface ConversationProps {
@@ -9,13 +9,10 @@ export interface ConversationProps {
9
9
  feedDown: boolean;
10
10
  typists: string[];
11
11
  skipUserId: number | null;
12
- onSend: (text: string, file: PickedFile | null) => void;
12
+ composer: Composer;
13
13
  onRetry: (id: number) => void;
14
- onTyped: (text: string) => void;
15
14
  onLoadOlder: () => void;
16
15
  onReload: () => void;
17
- pickFile?: () => Promise<PickedFile | null>;
18
- initialText?: string;
19
16
  keyboardOffset?: number;
20
17
  bottomInset?: number;
21
18
  words: ChatWords;
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { ActivityIndicator, FlatList, Image, KeyboardAvoidingView, Linking, Platform, Pressable, Text, TextInput, View, } from 'react-native';
4
- import { attachmentProblem } from "../attachments.js";
5
- import { groupThread } from "../thread.js";
4
+ import { groupThread } from "../helpers/thread.js";
6
5
  import { Bubble } from "./Bubble.js";
7
6
  import { useColor } from "./parts.js";
8
7
  // An image from require needs its size in style: the web draws it at its own size otherwise.
@@ -20,42 +19,19 @@ export function Conversation(props) {
20
19
  const secondary = useColor('ink-secondary');
21
20
  // The list is inverted so it rests at the newest message and stays put while the member reads older ones.
22
21
  const items = groupThread(thread.messages, props.skipUserId).reverse();
23
- return (_jsxs(KeyboardAvoidingView, { behavior: "padding", keyboardVerticalOffset: props.keyboardOffset ?? 0, className: "flex-1", children: [feedDown ? (_jsx(Line, { role: "status", className: "bg-muted px-gutter-phone py-2 text-center text-sm text-ink-secondary", children: words.feedDown })) : null, load === 'loading' ? (_jsx(ActivityIndicator, { accessibilityLabel: words.loading, className: "flex-1", color: secondary })) : load === 'failed' ? (_jsxs(View, { role: "alert", className: "flex-1 items-center justify-center gap-3 px-gutter-phone", children: [_jsx(Line, { className: "text-center text-base text-ink-secondary", children: words.loadFailed }), _jsx(Pressable, { role: "button", onPress: onReload, className: "h-control items-center justify-center rounded-pill border border-line-control px-6 active:opacity-80", children: _jsx(Line, { className: "text-md font-semibold text-ink", children: words.retry }) })] })) : (_jsx(FlatList, { inverted: true, data: items, keyExtractor: itemKey, onEndReached: onLoadOlder, contentContainerClassName: "gap-4 px-gutter-phone py-4 md:mx-auto md:w-full md:max-w-reading", ListHeaderComponent: typists.length ? _jsx(Line, { className: "text-sm text-ink-secondary", children: words.typingLine(typists) }) : undefined, renderItem: ({ item }) => _jsx(ThreadRow, { item: item, ...props }) })), _jsx(Composer, { ...props })] }));
22
+ return (_jsxs(KeyboardAvoidingView, { behavior: "padding", keyboardVerticalOffset: props.keyboardOffset ?? 0, className: "flex-1", children: [feedDown ? (_jsx(Line, { role: "status", className: "bg-muted px-gutter-phone py-2 text-center text-sm text-ink-secondary", children: words.feedDown })) : null, load === 'loading' ? (_jsx(ActivityIndicator, { accessibilityLabel: words.loading, className: "flex-1", color: secondary })) : load === 'failed' ? (_jsxs(View, { role: "alert", className: "flex-1 items-center justify-center gap-3 px-gutter-phone", children: [_jsx(Line, { className: "text-center text-base text-ink-secondary", children: words.loadFailed }), _jsx(Pressable, { role: "button", onPress: onReload, className: "h-control items-center justify-center rounded-pill border border-line-control px-6 active:opacity-80", children: _jsx(Line, { className: "text-md font-semibold text-ink", children: words.retry }) })] })) : (_jsx(FlatList, { inverted: true, data: items, keyExtractor: itemKey, onEndReached: onLoadOlder, contentContainerClassName: "gap-4 px-gutter-phone py-4 md:mx-auto md:w-full md:max-w-reading", ListHeaderComponent: typists.length ? _jsx(Line, { className: "text-sm text-ink-secondary", children: words.typingLine(typists) }) : undefined, renderItem: ({ item }) => _jsx(ThreadRow, { item: item, ...props }) })), _jsx(ComposerBox, { ...props })] }));
24
23
  }
25
24
  function itemKey(item) {
26
25
  if (item.kind === 'run')
27
26
  return `r${String(item.messages[0]?.id)}`;
28
27
  return `${item.kind === 'notice' ? 'n' : 'u'}${String(item.message.id)}`;
29
28
  }
30
- function Composer({ onSend, onTyped, pickFile, initialText, bottomInset, words, Icon }) {
29
+ function ComposerBox({ composer, bottomInset, words, Icon }) {
31
30
  const secondary = useColor('ink-secondary');
32
31
  const placeholder = useColor('ink-placeholder');
33
32
  const actionInk = useColor('action-ink');
34
- const [text, setText] = useState(initialText ?? '');
35
- const [picked, setPicked] = useState(null);
36
- const [refused, setRefused] = useState(null);
37
- const canSend = Boolean(text.trim() || picked);
38
- const attach = async (pick) => {
39
- const file = await pick();
40
- if (!file)
41
- return;
42
- const problem = attachmentProblem(file);
43
- setRefused(problem ? words.attachmentRefused[problem] : null);
44
- if (!problem)
45
- setPicked(file);
46
- };
47
- const submit = () => {
48
- onSend(text, picked);
49
- setText('');
50
- setPicked(null);
51
- setRefused(null);
52
- };
53
- return (_jsxs(View, { style: { paddingBottom: Math.max(bottomInset ?? 0, MIN_BOTTOM_SPACE) }, className: "gap-2 px-gutter-phone pt-2 md:mx-auto md:w-full md:max-w-reading", children: [refused ? (_jsx(Line, { role: "alert", className: "text-sm text-error-ink", children: refused })) : null, picked ? (_jsxs(View, { className: "flex-row items-center gap-3 self-start rounded-control border border-line-subtle bg-surface p-2 pr-3", children: [isPhoto(picked) ? (_jsx(Image, { source: { uri: picked.uri }, resizeMode: "cover", className: "h-10 w-10 rounded-control bg-muted" })) : (_jsx(View, { className: "h-10 w-10 items-center justify-center", children: _jsx(Icon, { name: "file", color: secondary, size: 20 }) })), _jsxs(View, { className: "max-w-56", children: [_jsx(Line, { className: "text-sm text-ink", numberOfLines: 1, children: picked.name }), _jsx(Line, { className: "text-xs text-ink-secondary", children: `${isPhoto(picked) ? words.photo : words.pdf} · ${words.fileSize(picked.size)}` })] }), _jsx(Pressable, { role: "button", accessibilityLabel: `${words.remove} ${picked.name}`, hitSlop: 8, onPress: () => {
54
- setPicked(null);
55
- }, children: _jsx(Icon, { name: "close", color: secondary, size: 18 }) })] })) : null, _jsxs(View, { className: "flex-row items-end gap-1 rounded-[24px] border border-line-subtle bg-surface p-1.5 shadow-card", children: [pickFile ? (_jsx(Pressable, { role: "button", accessibilityLabel: words.attach, onPress: () => void attach(pickFile), className: "h-[42px] w-[42px] items-center justify-center rounded-pill active:bg-muted", children: _jsx(Icon, { name: "attach", color: secondary, size: 18 }) })) : null, _jsx(TextInput, { value: text, onChangeText: (value) => {
56
- setText(value);
57
- onTyped(value);
58
- }, placeholder: words.composerPlaceholder, placeholderTextColor: placeholder, accessibilityLabel: words.composerPlaceholder, multiline: true, ...Platform.select({ web: { rows: 1 }, default: {} }), className: "max-h-40 flex-1 self-center px-1 py-2 font-ui text-md leading-6 text-ink" }), _jsx(Pressable, { role: "button", accessibilityLabel: words.send, disabled: !canSend, onPress: submit, className: `h-[42px] w-[42px] items-center justify-center rounded-pill bg-action active:bg-action-pressed ${canSend ? '' : 'opacity-40'}`, children: _jsx(View, { style: { transform: [{ rotate: '-90deg' }] }, children: _jsx(Icon, { name: "arrow-right", color: actionInk, size: 18 }) }) })] }), _jsx(Line, { className: "text-center text-xs text-ink-secondary", children: words.emergencyNote })] }));
33
+ const { text, picked, refused, canSend } = composer;
34
+ return (_jsxs(View, { style: { paddingBottom: Math.max(bottomInset ?? 0, MIN_BOTTOM_SPACE) }, className: "gap-2 px-gutter-phone pt-2 md:mx-auto md:w-full md:max-w-reading", children: [refused ? (_jsx(Line, { role: "alert", className: "text-sm text-error-ink", children: words.attachmentRefused[refused] })) : null, picked ? (_jsxs(View, { className: "flex-row items-center gap-3 self-start rounded-control border border-line-subtle bg-surface p-2 pr-3", children: [isPhoto(picked) ? (_jsx(Image, { source: { uri: picked.uri }, resizeMode: "cover", className: "h-10 w-10 rounded-control bg-muted" })) : (_jsx(View, { className: "h-10 w-10 items-center justify-center", children: _jsx(Icon, { name: "file", color: secondary, size: 20 }) })), _jsxs(View, { className: "max-w-56", children: [_jsx(Line, { className: "text-sm text-ink", numberOfLines: 1, children: picked.name }), _jsx(Line, { className: "text-xs text-ink-secondary", children: `${isPhoto(picked) ? words.photo : words.pdf} · ${words.fileSize(picked.size)}` })] }), _jsx(Pressable, { role: "button", accessibilityLabel: `${words.remove} ${picked.name}`, hitSlop: 8, onPress: composer.remove, children: _jsx(Icon, { name: "close", color: secondary, size: 18 }) })] })) : null, _jsxs(View, { className: "flex-row items-end gap-1 rounded-[24px] border border-line-subtle bg-surface p-1.5 shadow-card", children: [composer.attach ? (_jsx(Pressable, { role: "button", accessibilityLabel: words.attach, onPress: composer.attach, className: "h-[42px] w-[42px] items-center justify-center rounded-pill active:bg-muted", children: _jsx(Icon, { name: "attach", color: secondary, size: 18 }) })) : null, _jsx(TextInput, { value: text, onChangeText: composer.onChangeText, placeholder: words.composerPlaceholder, placeholderTextColor: placeholder, accessibilityLabel: words.composerPlaceholder, multiline: true, ...Platform.select({ web: { rows: 1 }, default: {} }), className: "max-h-40 flex-1 self-center px-1 py-2 font-ui text-md leading-6 text-ink" }), _jsx(Pressable, { role: "button", accessibilityLabel: words.send, disabled: !canSend, onPress: composer.submit, className: `h-[42px] w-[42px] items-center justify-center rounded-pill bg-action active:bg-action-pressed ${canSend ? '' : 'opacity-40'}`, children: _jsx(View, { style: { transform: [{ rotate: '-90deg' }] }, children: _jsx(Icon, { name: "arrow-right", color: actionInk, size: 18 }) }) })] }), _jsx(Line, { className: "text-center text-xs text-ink-secondary", children: words.emergencyNote })] }));
59
35
  }
60
36
  function ThreadRow({ item, words, onRetry, ...props }) {
61
37
  if (item.kind === 'notice') {
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Linking, Platform, Text, View } from 'react-native';
3
- import { readMarkdown } from "../markdown.js";
3
+ import { readMarkdown } from "../helpers/markdown.js";
4
4
  // On the web a link opens in a new tab, as the website's own links do, telling the other site nothing.
5
5
  export const NEW_TAB = { target: '_blank', rel: 'noopener noreferrer nofollow' };
6
6
  function Inlines({ nodes }) {
@@ -1,5 +1,7 @@
1
1
  import { type ImageSourcePropType } from 'react-native';
2
- import type { ChoiceItem } from '../message.ts';
2
+ import type { ChoiceItem } from '../helpers/message.ts';
3
+ import type { CodeEntry } from '../hooks/useCodeEntry.ts';
4
+ import type { StepField as StepFieldState } from '../hooks/useStepField.ts';
3
5
  /** Every word the website's welcome shows, which the website passes in. */
4
6
  export interface WelcomeWords {
5
7
  logIn: string;
@@ -20,6 +22,16 @@ export interface WelcomeWords {
20
22
  codeRanOut: string;
21
23
  typing: string;
22
24
  }
25
+ type PillLook = 'solid' | 'stroked' | 'flat';
26
+ export interface PillProps {
27
+ label: string;
28
+ look?: PillLook;
29
+ disabled?: boolean;
30
+ loading?: boolean;
31
+ onPress: () => void;
32
+ }
33
+ /** The chat's button, in the brand's pill. */
34
+ export declare function Pill({ label, look, disabled, loading, onPress, }: PillProps): import("react").JSX.Element;
23
35
  export interface WelcomeChoiceProps {
24
36
  words: WelcomeWords;
25
37
  onLogIn: () => void;
@@ -40,18 +52,17 @@ export interface ChoicesProps {
40
52
  export declare function Choices({ items, question, sending, holding, failed, words, onChoose, }: ChoicesProps): import("react").JSX.Element;
41
53
  export interface EmailStepProps {
42
54
  words: WelcomeWords;
43
- onSubmit: (email: string) => void;
44
- initial?: string;
55
+ field: StepFieldState;
45
56
  }
46
57
  /** The email asked for after Continue here, and again for a visitor changing it. */
47
- export declare function EmailStep({ words, onSubmit, initial, }: EmailStepProps): import("react").JSX.Element;
58
+ export declare function EmailStep({ words, field }: EmailStepProps): import("react").JSX.Element;
48
59
  export interface NameStepProps {
49
60
  words: WelcomeWords;
50
- onSubmit: (name: string) => void;
61
+ field: StepFieldState;
51
62
  onChangeEmail: () => void;
52
63
  }
53
64
  /** The name asked of a visitor the Skips App does not know, with the way back to change a mistyped email. */
54
- export declare function NameStep({ words, onSubmit, onChangeEmail, }: NameStepProps): import("react").JSX.Element;
65
+ export declare function NameStep({ words, field, onChangeEmail }: NameStepProps): import("react").JSX.Element;
55
66
  /**
56
67
  * The code emailed to the visitor, one digit to a box over one real field, so typing, deleting, a paste and the
57
68
  * phone's own code suggestion work as in any field. The chat mounts it afresh for each code that goes out.
@@ -61,12 +72,13 @@ export interface CodeStepProps {
61
72
  length: number;
62
73
  noMatch: boolean;
63
74
  ranOut: boolean;
64
- resendAfterMs?: number;
75
+ entry: CodeEntry;
76
+ secondsLeft: number;
65
77
  onSubmit: (code: string) => void;
66
78
  onResend: () => void;
67
79
  onChangeEmail: () => void;
68
80
  }
69
- export declare function CodeStep({ words, length, noMatch, ranOut, resendAfterMs, onSubmit, onResend, onChangeEmail, }: CodeStepProps): import("react").JSX.Element;
81
+ export declare function CodeStep({ words, length, noMatch, ranOut, entry, secondsLeft, onSubmit, onResend, onChangeEmail, }: CodeStepProps): import("react").JSX.Element;
70
82
  export declare const DOT_REST_OPACITY = 0.35;
71
83
  export declare const DOT_RISE = 3;
72
84
  export declare const DOT_STILL_OPACITY = 0.6;
@@ -76,3 +88,4 @@ export interface SkipTypingProps {
76
88
  skipMark: ImageSourcePropType;
77
89
  }
78
90
  export declare function SkipTyping({ label, skipMark }: SkipTypingProps): import("react").JSX.Element;
91
+ export {};
@@ -1,15 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useState } from 'react';
3
3
  import { AccessibilityInfo, ActivityIndicator, Animated, Image, Pressable, Text, TextInput, View } from 'react-native';
4
- import { DOT_CYCLE_MS } from "../skipTyping.js";
5
- import { codeDigits, completesCode, EMAIL_MAX_LENGTH, givenEmail, givenName, NAME_MAX_LENGTH, RESEND_AFTER_MS, resendClock, } from "../welcome.js";
4
+ import { DOT_CYCLE_MS } from "../helpers/skipTyping.js";
5
+ import { EMAIL_MAX_LENGTH, NAME_MAX_LENGTH, resendClock } from "../helpers/welcome.js";
6
6
  import { useColor } from "./parts.js";
7
7
  const PILL_LOOK = {
8
8
  solid: { box: 'bg-action active:bg-action-pressed', text: 'text-action-ink' },
9
- stroked: { box: 'border border-line-control active:bg-muted', text: 'text-ink' },
9
+ stroked: { box: 'border border-line-control bg-surface active:bg-muted', text: 'text-ink' },
10
10
  flat: { box: 'active:bg-muted', text: 'text-ink' },
11
11
  };
12
- function Pill({ label, look = 'solid', disabled = false, loading = false, onPress, }) {
12
+ /** The chat's button, in the brand's pill. */
13
+ export function Pill({ label, look = 'solid', disabled = false, loading = false, onPress, }) {
13
14
  const ink = useColor(look === 'solid' ? 'action-ink' : 'ink');
14
15
  return (_jsxs(Pressable, { role: "button", accessibilityLabel: label, disabled: disabled || loading, "aria-busy": loading, onPress: onPress, className: `h-control-compact flex-row items-center justify-center gap-2 rounded-pill px-5 ${PILL_LOOK[look].box} ${disabled ? 'opacity-40' : ''}`, children: [loading ? _jsx(ActivityIndicator, { "aria-hidden": true, size: "small", color: ink }) : null, _jsx(Text, { className: `font-ui text-sm font-semibold ${PILL_LOOK[look].text}`, children: label })] }));
15
16
  }
@@ -28,58 +29,31 @@ export function Choices({ items, question, sending, holding = false, failed, wor
28
29
  function describedBy(errorId) {
29
30
  return errorId === undefined ? {} : { 'aria-describedby': errorId };
30
31
  }
31
- // One thing asked of a new visitor: a field in focus and its button. What is typed is checked here and handed on.
32
- function StepField({ label, error, submitLabel, input, usable, onSubmit, initial = '', aside }) {
33
- const [typed, setTyped] = useState(initial);
34
- const [refused, setRefused] = useState(false);
32
+ // One thing asked of a new visitor: a field in focus and its button.
33
+ function StepField({ label, error, submitLabel, input, field, aside }) {
35
34
  const errorId = useId();
36
35
  const placeholder = useColor('ink-placeholder');
37
- const submit = () => {
38
- const value = usable(typed);
39
- setRefused(value === null);
40
- if (value !== null)
41
- onSubmit(value);
42
- };
43
- return (_jsxs(View, { className: "w-full max-w-[360px] gap-2 self-center", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: label }), _jsx(TextInput, { autoFocus: true, value: typed, onChangeText: setTyped, onSubmitEditing: submit, accessibilityLabel: label, "aria-invalid": refused, ...describedBy(refused ? errorId : undefined), placeholderTextColor: placeholder, className: `h-control rounded-control border bg-surface px-3 font-ui text-md text-ink ${refused ? 'border-error-ink' : 'border-line-control'}`, ...input }), refused ? (_jsx(Text, { nativeID: errorId, role: "alert", className: "font-ui text-sm text-error-ink", children: error })) : null, aside ? (_jsx(View, { className: "self-center", children: _jsx(Pill, { label: aside.label, look: "flat", onPress: aside.onPress }) })) : null, _jsx(View, { className: "self-center", children: _jsx(Pill, { label: submitLabel, onPress: submit }) })] }));
36
+ return (_jsxs(View, { className: "w-full max-w-[360px] gap-2 self-center", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: label }), _jsx(TextInput, { autoFocus: true, value: field.typed, onChangeText: field.onChangeText, onSubmitEditing: field.submit, accessibilityLabel: label, "aria-invalid": field.refused, ...describedBy(field.refused ? errorId : undefined), placeholderTextColor: placeholder, className: `h-control rounded-control border bg-surface px-3 font-ui text-md text-ink ${field.refused ? 'border-error-ink' : 'border-line-control'}`, ...input }), field.refused ? (_jsx(Text, { nativeID: errorId, role: "alert", className: "font-ui text-sm text-error-ink", children: error })) : null, aside ? (_jsx(View, { className: "self-center", children: _jsx(Pill, { label: aside.label, look: "flat", onPress: aside.onPress }) })) : null, _jsx(View, { className: "self-center", children: _jsx(Pill, { label: submitLabel, onPress: field.submit }) })] }));
44
37
  }
45
38
  /** The email asked for after Continue here, and again for a visitor changing it. */
46
- export function EmailStep({ words, onSubmit, initial, }) {
47
- return (_jsx(StepField, { label: words.emailLabel, error: words.emailError, submitLabel: words.emailSubmit, input: { autoComplete: 'email', inputMode: 'email', maxLength: EMAIL_MAX_LENGTH, autoCapitalize: 'none' }, usable: givenEmail, onSubmit: onSubmit, ...(initial === undefined ? {} : { initial }) }));
39
+ export function EmailStep({ words, field }) {
40
+ return (_jsx(StepField, { label: words.emailLabel, error: words.emailError, submitLabel: words.emailSubmit, input: { autoComplete: 'email', inputMode: 'email', maxLength: EMAIL_MAX_LENGTH, autoCapitalize: 'none' }, field: field }));
48
41
  }
49
42
  /** The name asked of a visitor the Skips App does not know, with the way back to change a mistyped email. */
50
- export function NameStep({ words, onSubmit, onChangeEmail, }) {
51
- return (_jsx(StepField, { label: words.nameLabel, error: words.nameError, submitLabel: words.nameSubmit, input: { autoComplete: 'name', maxLength: NAME_MAX_LENGTH, autoCapitalize: 'words' }, usable: givenName, onSubmit: onSubmit, aside: { label: words.changeEmail, onPress: onChangeEmail } }));
43
+ export function NameStep({ words, field, onChangeEmail }) {
44
+ return (_jsx(StepField, { label: words.nameLabel, error: words.nameError, submitLabel: words.nameSubmit, input: { autoComplete: 'name', maxLength: NAME_MAX_LENGTH, autoCapitalize: 'words' }, field: field, aside: { label: words.changeEmail, onPress: onChangeEmail } }));
52
45
  }
53
- const TICK_MS = 250;
54
- function NewCode({ waitMs, words, onResend }) {
55
- const [secondsLeft, setSecondsLeft] = useState(Math.ceil(waitMs / 1000));
56
- useEffect(() => {
57
- const end = Date.now() + waitMs;
58
- const timer = setInterval(() => {
59
- const left = Math.max(0, Math.ceil((end - Date.now()) / 1000));
60
- setSecondsLeft(left);
61
- if (left === 0)
62
- clearInterval(timer);
63
- }, TICK_MS);
64
- return () => {
65
- clearInterval(timer);
66
- };
67
- }, [waitMs]);
46
+ function NewCode({ secondsLeft, words, onResend }) {
68
47
  return (_jsxs(_Fragment, { children: [_jsx(Pill, { label: words.resend, look: "flat", disabled: secondsLeft > 0, onPress: onResend }), secondsLeft > 0 ? (_jsx(Text, { role: "timer", accessibilityLabel: words.resendWait, className: "font-ui text-sm text-ink-secondary", children: resendClock(secondsLeft) })) : null] }));
69
48
  }
70
- export function CodeStep({ words, length, noMatch, ranOut, resendAfterMs = RESEND_AFTER_MS, onSubmit, onResend, onChangeEmail, }) {
71
- const [code, setCode] = useState('');
49
+ export function CodeStep({ words, length, noMatch, ranOut, entry, secondsLeft, onSubmit, onResend, onChangeEmail, }) {
50
+ const { code } = entry;
72
51
  const [focused, setFocused] = useState(false);
73
52
  const errorId = useId();
74
53
  const error = ranOut ? words.codeRanOut : noMatch ? words.codeNoMatch : null;
75
54
  // The box the next digit goes in, or the last once the code is whole.
76
55
  const nextBox = Math.min(code.length, length - 1);
77
- return (_jsxs(View, { className: "w-full max-w-[360px] items-center gap-3 self-center", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.codeLabel }), _jsxs(View, { className: "relative", children: [_jsx(View, { "aria-hidden": true, className: "flex-row gap-2", children: Array.from({ length }, (_, box) => (_jsx(View, { className: `h-control w-11 items-center justify-center rounded-control border ${focused && box === nextBox ? 'border-focus' : error ? 'border-error-ink' : 'border-line-control'}`, children: _jsx(Text, { className: "font-ui text-xl font-medium text-ink", children: code[box] ?? '' }) }, box))) }), _jsx(TextInput, { autoFocus: true, value: code, onChangeText: (typed) => {
78
- const digits = codeDigits(typed, length);
79
- setCode(digits);
80
- if (completesCode(digits, code, length))
81
- onSubmit(digits);
82
- }, onFocus: () => {
56
+ return (_jsxs(View, { className: "w-full max-w-[360px] items-center gap-3 self-center", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.codeLabel }), _jsxs(View, { className: "relative", children: [_jsx(View, { "aria-hidden": true, className: "flex-row gap-2", children: Array.from({ length }, (_, box) => (_jsx(View, { className: `h-control w-11 items-center justify-center rounded-control border ${focused && box === nextBox ? 'border-focus' : error ? 'border-error-ink' : 'border-line-control'}`, children: _jsx(Text, { className: "font-ui text-xl font-medium text-ink", children: code[box] ?? '' }) }, box))) }), _jsx(TextInput, { autoFocus: true, value: code, onChangeText: entry.onChangeText, onFocus: () => {
83
57
  setFocused(true);
84
58
  }, onBlur: () => {
85
59
  setFocused(false);
@@ -87,7 +61,7 @@ export function CodeStep({ words, length, noMatch, ranOut, resendAfterMs = RESEN
87
61
  // The boxes draw the digits and the focus. Clear on iOS, which hands no taps to a view under 0.01 alpha.
88
62
  // Unseen elsewhere: Android would draw a long press's selection over the boxes, and a web checker would read
89
63
  // clear text as text with no contrast.
90
- className: "absolute inset-0 ios:text-transparent android:opacity-0 web:opacity-0" })] }), error ? (_jsx(Text, { nativeID: errorId, role: "alert", className: "text-center font-ui text-sm text-error-ink", children: error })) : null, _jsxs(View, { className: "flex-row flex-wrap items-center justify-center gap-2", children: [_jsx(Pill, { label: words.changeEmail, look: "flat", onPress: onChangeEmail }), _jsx(NewCode, { waitMs: resendAfterMs, words: words, onResend: onResend }), _jsx(Pill, { label: words.codeSubmit, disabled: code.length < length, onPress: () => {
64
+ className: "absolute inset-0 ios:text-transparent android:opacity-0 web:opacity-0" })] }), error ? (_jsx(Text, { nativeID: errorId, role: "alert", className: "text-center font-ui text-sm text-error-ink", children: error })) : null, _jsxs(View, { className: "flex-row flex-wrap items-center justify-center gap-2", children: [_jsx(Pill, { label: words.changeEmail, look: "flat", onPress: onChangeEmail }), _jsx(NewCode, { secondsLeft: secondsLeft, words: words, onResend: onResend }), _jsx(Pill, { label: words.codeSubmit, disabled: code.length < length, onPress: () => {
91
65
  onSubmit(code);
92
66
  } })] })] }));
93
67
  }
@@ -0,0 +1,5 @@
1
+ export { Conversation, type ConversationProps, type LoadState } from './Conversation.tsx';
2
+ export { Bubble, type BubbleProps } from './Bubble.tsx';
3
+ export type { ChatIcon, ChatIconName, ChatWords } from './parts.ts';
4
+ export { Choices, CodeStep, EmailStep, NameStep, Pill, SkipTyping, WelcomeChoice, type PillProps, type WelcomeWords, } from './Welcome.tsx';
5
+ export { MedicationCheck, STOPPED_REASON_MAX_LENGTH, type CheckInWords, type MedicationAnswer, type MedicationCheckProps, } from './CheckIn.tsx';
@@ -0,0 +1,4 @@
1
+ export { Conversation } from "./Conversation.js";
2
+ export { Bubble } from "./Bubble.js";
3
+ export { Choices, CodeStep, EmailStep, NameStep, Pill, SkipTyping, WelcomeChoice, } from "./Welcome.js";
4
+ export { MedicationCheck, STOPPED_REASON_MAX_LENGTH, } from "./CheckIn.js";
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType } from 'react';
2
2
  /** The icons the chat draws, from the brand's interface icons, which each app already draws. */
3
- export type ChatIconName = 'attach' | 'arrow-right' | 'file' | 'close';
3
+ export type ChatIconName = 'attach' | 'arrow-right' | 'file' | 'close' | 'thumbs-up' | 'repeat' | 'copy-plus';
4
4
  export interface ChatIconProps {
5
5
  name: ChatIconName;
6
6
  color: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joinskips/brand",
3
- "version": "9.0.0-develop.146",
3
+ "version": "9.0.0-develop.148",
4
4
  "description": "Skips design tokens, Onest, logos, favicons, interface icons, member pictures and app icons.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://brand.joinskips.com",
@@ -13,6 +13,18 @@
13
13
  "types": "./chat/index.d.ts",
14
14
  "default": "./chat/index.js"
15
15
  },
16
+ "./chat/ui": {
17
+ "types": "./chat/ui/index.d.ts",
18
+ "default": "./chat/ui/index.js"
19
+ },
20
+ "./chat/hooks": {
21
+ "types": "./chat/hooks/index.d.ts",
22
+ "default": "./chat/hooks/index.js"
23
+ },
24
+ "./chat/helpers": {
25
+ "types": "./chat/helpers/index.d.ts",
26
+ "default": "./chat/helpers/index.js"
27
+ },
16
28
  "./ui": {
17
29
  "types": "./ui/index.d.ts",
18
30
  "default": "./ui/index.js"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes