@joinskips/common 0.0.0-stage → 0.1.0-develop.138
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 +102 -2
- package/dist/chat/SkipsChat.d.ts +37 -0
- package/dist/chat/SkipsChat.js +103 -0
- package/dist/chat/client.d.ts +53 -0
- package/dist/chat/client.js +178 -0
- package/dist/chat/connection.d.ts +4 -0
- package/dist/chat/connection.js +6 -0
- package/dist/chat/generated/skips-app/index.d.ts +1 -0
- package/dist/chat/generated/skips-app/index.js +2 -0
- package/dist/chat/generated/skips-app/types.gen.d.ts +733 -0
- package/dist/chat/generated/skips-app/types.gen.js +2 -0
- package/dist/chat/index.d.ts +3 -0
- package/dist/chat/index.js +2 -0
- package/dist/chat/platform.d.ts +4 -0
- package/dist/chat/platform.js +46 -0
- package/dist/chat/session.d.ts +19 -0
- package/dist/chat/session.js +95 -0
- package/dist/chat/useSkipsChat.d.ts +79 -0
- package/dist/chat/useSkipsChat.js +507 -0
- package/dist/chat/verify.d.ts +35 -0
- package/dist/chat/verify.js +84 -0
- package/dist/elements/skips-elements.js +18521 -0
- package/dist/helpers/attachments.d.ts +12 -0
- package/dist/helpers/attachments.js +34 -0
- package/dist/helpers/cable.d.ts +34 -0
- package/dist/helpers/cable.js +88 -0
- package/dist/helpers/cableFrames.d.ts +40 -0
- package/dist/helpers/cableFrames.js +70 -0
- package/dist/helpers/cardNote.d.ts +79 -0
- package/dist/helpers/cardNote.js +152 -0
- package/dist/helpers/commandNote.d.ts +4 -0
- package/dist/helpers/commandNote.js +23 -0
- package/dist/helpers/index.d.ts +19 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/markdown.d.ts +47 -0
- package/dist/helpers/markdown.js +129 -0
- package/dist/helpers/medicationOrder.d.ts +333 -0
- package/dist/helpers/medicationOrder.js +383 -0
- package/dist/helpers/message.d.ts +46 -0
- package/dist/helpers/message.js +12 -0
- package/dist/helpers/noteView.d.ts +35 -0
- package/dist/helpers/noteView.js +65 -0
- package/dist/helpers/orderForm.d.ts +126 -0
- package/dist/helpers/orderForm.js +271 -0
- package/dist/helpers/ordersMenu.d.ts +56 -0
- package/dist/helpers/ordersMenu.js +129 -0
- package/dist/helpers/regimenChoice.d.ts +42 -0
- package/dist/helpers/regimenChoice.js +73 -0
- package/dist/helpers/scrollBox.d.ts +5 -0
- package/dist/helpers/scrollBox.js +15 -0
- package/dist/helpers/skipTyping.d.ts +26 -0
- package/dist/helpers/skipTyping.js +29 -0
- package/dist/helpers/skipsMessage.d.ts +55 -0
- package/dist/helpers/skipsMessage.js +130 -0
- package/dist/helpers/stageRefill.d.ts +33 -0
- package/dist/helpers/stageRefill.js +41 -0
- package/dist/helpers/thread.d.ts +54 -0
- package/dist/helpers/thread.js +122 -0
- package/dist/helpers/typing.d.ts +13 -0
- package/dist/helpers/typing.js +68 -0
- package/dist/helpers/usrxNote.d.ts +22 -0
- package/dist/helpers/usrxNote.js +26 -0
- package/dist/helpers/visibleArea.d.ts +15 -0
- package/dist/helpers/visibleArea.js +11 -0
- package/dist/helpers/welcome.d.ts +25 -0
- package/dist/helpers/welcome.js +51 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useCardNoteActions.d.ts +82 -0
- package/dist/hooks/useCardNoteActions.js +210 -0
- package/dist/hooks/useCodeEntry.d.ts +6 -0
- package/dist/hooks/useCodeEntry.js +14 -0
- package/dist/hooks/useComposer.d.ts +20 -0
- package/dist/hooks/useComposer.js +40 -0
- package/dist/hooks/useOrderForm.d.ts +80 -0
- package/dist/hooks/useOrderForm.js +403 -0
- package/dist/hooks/useOrdersMenu.d.ts +114 -0
- package/dist/hooks/useOrdersMenu.js +337 -0
- package/dist/hooks/useRegimenChoice.d.ts +23 -0
- package/dist/hooks/useRegimenChoice.js +50 -0
- package/dist/hooks/useResendCountdown.d.ts +2 -0
- package/dist/hooks/useResendCountdown.js +19 -0
- package/dist/hooks/useStepField.d.ts +8 -0
- package/dist/hooks/useStepField.js +17 -0
- package/dist/hooks/useTypingCue.d.ts +11 -0
- package/dist/hooks/useTypingCue.js +41 -0
- package/dist/hooks/useWelcomeTyping.d.ts +2 -0
- package/dist/hooks/useWelcomeTyping.js +25 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/staff/CardNoteActions.d.ts +10 -0
- package/dist/staff/CardNoteActions.js +16 -0
- package/dist/staff/OrderFormNote.d.ts +8 -0
- package/dist/staff/OrderFormNote.js +8 -0
- package/dist/staff/OrdersMenuNote.d.ts +8 -0
- package/dist/staff/OrdersMenuNote.js +8 -0
- package/dist/staff/RegimenChoiceNote.d.ts +7 -0
- package/dist/staff/RegimenChoiceNote.js +8 -0
- package/dist/staff/features.d.ts +9 -0
- package/dist/staff/features.js +8 -0
- package/dist/staff/index.d.ts +11 -0
- package/dist/staff/index.js +7 -0
- package/dist/ui/Bubble.d.ts +5 -0
- package/dist/ui/Bubble.js +9 -0
- package/dist/ui/CardActions.d.ts +34 -0
- package/dist/ui/CardActions.js +28 -0
- package/dist/ui/Conversation.d.ts +69 -0
- package/dist/ui/Conversation.js +192 -0
- package/dist/ui/Markdown.d.ts +11 -0
- package/dist/ui/Markdown.js +51 -0
- package/dist/ui/NoteFold.d.ts +19 -0
- package/dist/ui/NoteFold.js +12 -0
- package/dist/ui/NoteViewControl.d.ts +19 -0
- package/dist/ui/NoteViewControl.js +20 -0
- package/dist/ui/OrderForm.d.ts +71 -0
- package/dist/ui/OrderForm.js +118 -0
- package/dist/ui/OrdersMenu.d.ts +71 -0
- package/dist/ui/OrdersMenu.js +128 -0
- package/dist/ui/RegimenChoice.d.ts +23 -0
- package/dist/ui/RegimenChoice.js +16 -0
- package/dist/ui/SkipAvatar.d.ts +7 -0
- package/dist/ui/SkipAvatar.js +8 -0
- package/dist/ui/StaffButton.d.ts +18 -0
- package/dist/ui/StaffButton.js +17 -0
- package/dist/ui/Welcome.d.ts +91 -0
- package/dist/ui/Welcome.js +128 -0
- package/dist/ui/index.d.ts +8 -0
- package/dist/ui/index.js +7 -0
- package/dist/ui/parts.d.ts +38 -0
- package/dist/ui/parts.js +6 -0
- package/package.json +115 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const SKIPS_FEATURES = [
|
|
2
|
+
{ name: 'regimen-choice', element: 'skips-regimen-choice', component: 'RegimenChoiceNote' },
|
|
3
|
+
{ name: 'card-note-actions', element: 'skips-card-note-actions', component: 'CardNoteActions' },
|
|
4
|
+
{ name: 'note-fold', element: 'skips-note-fold', component: 'NoteFold' },
|
|
5
|
+
{ name: 'note-view', element: 'skips-note-view', component: 'NoteViewControl' },
|
|
6
|
+
{ name: 'orders-menu', element: 'skips-orders-menu', component: 'OrdersMenuNote' },
|
|
7
|
+
{ name: 'order-form', element: 'skips-order-form', component: 'OrderFormNote' },
|
|
8
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { CardNoteActions, type CardNoteActionsProps } from './CardNoteActions.tsx';
|
|
2
|
+
export { RegimenChoiceNote, type RegimenChoiceNoteProps } from './RegimenChoiceNote.tsx';
|
|
3
|
+
export { OrdersMenuNote, type OrdersMenuNoteProps } from './OrdersMenuNote.tsx';
|
|
4
|
+
export type { OrdersMenuWords } from '../ui/OrdersMenu.tsx';
|
|
5
|
+
export type { OrderFormRequest, OrderFormOptions } from '../hooks/useOrdersMenu.ts';
|
|
6
|
+
export { OrderFormNote, type OrderFormNoteProps } from './OrderFormNote.tsx';
|
|
7
|
+
export type { OrderFormWords } from '../ui/OrderForm.tsx';
|
|
8
|
+
export type { PharmacyPlace } from '../hooks/useOrderForm.ts';
|
|
9
|
+
export { NoteFold, type NoteFoldProps, type NoteFoldWords } from '../ui/NoteFold.tsx';
|
|
10
|
+
export { NoteViewControl, type NoteViewControlProps, type NoteViewWords } from '../ui/NoteViewControl.tsx';
|
|
11
|
+
export { SKIPS_FEATURES, type SkipsFeature, type SkipsFeatureName } from './features.ts';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { CardNoteActions } from "./CardNoteActions.js";
|
|
2
|
+
export { RegimenChoiceNote } from "./RegimenChoiceNote.js";
|
|
3
|
+
export { OrdersMenuNote } from "./OrdersMenuNote.js";
|
|
4
|
+
export { OrderFormNote } from "./OrderFormNote.js";
|
|
5
|
+
export { NoteFold } from "../ui/NoteFold.js";
|
|
6
|
+
export { NoteViewControl } from "../ui/NoteViewControl.js";
|
|
7
|
+
export { SKIPS_FEATURES } from "./features.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { Markdown } from "./Markdown.js";
|
|
4
|
+
export function Bubble({ mine = false, text }) {
|
|
5
|
+
if (mine) {
|
|
6
|
+
return (_jsx(View, { className: "shrink rounded-[20px] rounded-br-[7px] bg-accent px-4 py-2.5 web:w-fit", children: _jsx(Text, { className: "font-ui text-md text-accent-ink", children: text }) }));
|
|
7
|
+
}
|
|
8
|
+
return (_jsx(View, { className: "shrink rounded-[20px] rounded-bl-[7px] border border-line-subtle bg-surface px-4 py-2.5", children: _jsx(Markdown, { text: text }) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CardNoteActionsView } from '../hooks/useCardNoteActions.ts';
|
|
2
|
+
/** Every word a card note's actions show, which each app passes in. */
|
|
3
|
+
export interface CardActionsWords {
|
|
4
|
+
/** The name of the group of actions. */
|
|
5
|
+
group: string;
|
|
6
|
+
submitted: string;
|
|
7
|
+
replaced: string;
|
|
8
|
+
deleted: string;
|
|
9
|
+
createdBy: (name: string) => string;
|
|
10
|
+
editedBy: (name: string) => string;
|
|
11
|
+
submittedBy: (name: string) => string;
|
|
12
|
+
send: string;
|
|
13
|
+
edit: string;
|
|
14
|
+
delete: string;
|
|
15
|
+
cancel: string;
|
|
16
|
+
/** Asks before a card is deleted. */
|
|
17
|
+
confirmDelete: (name: string) => string;
|
|
18
|
+
/** A Send waits on usrx's answer. */
|
|
19
|
+
asked: string;
|
|
20
|
+
cardsNotRead: string;
|
|
21
|
+
noCards: string;
|
|
22
|
+
deleteFailed: string;
|
|
23
|
+
/** The label of the field for the ID.me app's code. */
|
|
24
|
+
idMeCode: string;
|
|
25
|
+
signAndSend: string;
|
|
26
|
+
/** The code waits on usrx's answer. */
|
|
27
|
+
codeSent: string;
|
|
28
|
+
codeFailed: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CardActionsProps extends CardNoteActionsView {
|
|
31
|
+
words: CardActionsWords;
|
|
32
|
+
}
|
|
33
|
+
/** The cards on usrx's card note, and its Send, Edit and Delete. */
|
|
34
|
+
export declare function CardActions(props: CardActionsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text, TextInput, View } from 'react-native';
|
|
3
|
+
import { cardWords } from "../helpers/medicationOrder.js";
|
|
4
|
+
import { StaffButton } from "./StaffButton.js";
|
|
5
|
+
function Status({ text, error = false }) {
|
|
6
|
+
return (_jsx(Text, { role: "status", className: `font-ui text-xs font-medium ${error ? 'text-error-ink' : 'text-ink-secondary'}`, children: text }));
|
|
7
|
+
}
|
|
8
|
+
/** The cards on usrx's card note, and its Send, Edit and Delete. */
|
|
9
|
+
export function CardActions(props) {
|
|
10
|
+
const { cards, people, words, busy, toDelete, edit, signing } = props;
|
|
11
|
+
const outcome = props.submitted ? words.submitted : props.replaced ? words.replaced : props.allDeleted ? words.deleted : null;
|
|
12
|
+
const named = people
|
|
13
|
+
? [
|
|
14
|
+
people.createdBy ? words.createdBy(people.createdBy) : null,
|
|
15
|
+
people.editedBy ? words.editedBy(people.editedBy) : null,
|
|
16
|
+
people.submittedBy ? words.submittedBy(people.submittedBy) : null,
|
|
17
|
+
].flatMap((line) => (line ? [line] : []))
|
|
18
|
+
: [];
|
|
19
|
+
return (_jsxs(View, { role: "group", accessibilityLabel: words.group, className: "gap-2", children: [outcome ? _jsx(Status, { text: outcome }) : null, named.length > 0 ? (_jsx(View, { className: "flex-row flex-wrap gap-x-2", children: named.map((line) => (_jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: line }, line))) })) : null, !props.replaced && cards.length > 0 ? (_jsx(View, { role: "list", className: "gap-0.5", children: cards.map((card) => (_jsx(Text, { role: "listitem", className: "font-ui text-sm text-ink", children: card.name }, card.uid))) })) : null, props.closed ? null : (_jsxs(_Fragment, { children: [_jsxs(View, { className: "flex-row flex-wrap justify-end gap-2", children: [cards.length === 1 ? (cards.map((card) => (_jsx(StaffButton, { label: words.delete, look: "danger", loading: props.deleting !== null, disabled: busy, onPress: () => {
|
|
20
|
+
props.askDelete(card);
|
|
21
|
+
} }, card.uid)))) : (_jsx(StaffButton, { label: words.delete, look: "danger", loading: props.deleting !== null, disabled: busy, onPress: props.togglePicking })), edit ? _jsx(StaffButton, { label: words.edit, loading: props.reading, disabled: busy, onPress: edit.start }) : null, props.canSend ? _jsx(StaffButton, { label: words.send, look: "primary", loading: props.sending, disabled: busy, onPress: props.send }) : null] }), props.picking && cards.length > 1 ? (_jsx(View, { className: "gap-1", children: cards.map((card) => (_jsx(StaffButton, { label: card.name, disabled: busy, onPress: () => {
|
|
22
|
+
props.askDelete(card);
|
|
23
|
+
} }, card.uid))) })) : null, toDelete ? (_jsxs(View, { role: "alert", className: "gap-2 rounded-control border border-line-control bg-surface p-3", children: [_jsx(Text, { className: "font-ui text-sm text-ink", children: words.confirmDelete(toDelete.name) }), props.deleteRefused === null ? null : _jsx(Status, { text: props.deleteRefused || words.deleteFailed, error: true }), props.deleteFailed ? _jsx(Status, { text: words.deleteFailed, error: true }) : null, _jsxs(View, { className: "flex-row justify-end gap-2", children: [_jsx(StaffButton, { label: words.cancel, disabled: props.deleting !== null, onPress: props.cancelDelete }), _jsx(StaffButton, { label: words.delete, look: "danger", loading: props.deleting !== null, disabled: props.deleting !== null, onPress: () => {
|
|
24
|
+
props.confirmDelete(toDelete);
|
|
25
|
+
} })] })] })) : null, props.sending ? _jsx(Status, { text: words.asked }) : null, props.readFailed ? _jsx(Status, { text: words.cardsNotRead, error: true }) : null, props.noCards ? _jsx(Status, { text: words.noCards }) : null, edit && props.editing.length > 0 ? (_jsx(View, { className: "gap-1", children: props.editing.map((card) => (_jsx(StaffButton, { label: cardWords(card), onPress: () => {
|
|
26
|
+
edit.open(card);
|
|
27
|
+
} }, card.uid))) })) : null] })), signing ? (_jsxs(View, { className: "gap-1", children: [_jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: words.idMeCode }), _jsxs(View, { className: "flex-row flex-wrap items-center justify-end gap-2", children: [_jsx(TextInput, { accessibilityLabel: words.idMeCode, value: signing.code, onChangeText: signing.setCode, onSubmitEditing: signing.sign, inputMode: "numeric", autoComplete: "one-time-code", textContentType: "oneTimeCode", maxLength: 6, editable: !signing.sending, className: "min-h-control-compact w-28 flex-1 rounded-control border border-line-control bg-surface px-3 py-1.5 font-ui text-sm text-ink" }), _jsx(StaffButton, { label: words.signAndSend, look: "primary", loading: signing.sending, disabled: !signing.ready, onPress: signing.sign })] }), signing.sending ? _jsx(Status, { text: words.codeSent }) : null, signing.failed ? _jsx(Status, { text: words.codeFailed, error: true }) : null] })) : null] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type ImageSourcePropType } from 'react-native';
|
|
3
|
+
import type { Composer } from '../hooks/useComposer.ts';
|
|
4
|
+
import type { ChoiceItem } from '../helpers/message.ts';
|
|
5
|
+
import { type OpenQuestion, type Thread, type ThreadItem, type ThreadMessage } from '../helpers/thread.ts';
|
|
6
|
+
import { type ChatIcon, type ChatWords } from './parts.ts';
|
|
7
|
+
import { type WelcomeWords } from './Welcome.tsx';
|
|
8
|
+
export type LoadState = 'loading' | 'ready' | 'failed';
|
|
9
|
+
export interface ConversationProps {
|
|
10
|
+
thread: Thread;
|
|
11
|
+
load: LoadState;
|
|
12
|
+
feedDown: boolean;
|
|
13
|
+
typists: string[];
|
|
14
|
+
skipUserId: number | null;
|
|
15
|
+
composer: Composer;
|
|
16
|
+
onRetry: (id: number) => void;
|
|
17
|
+
onLoadOlder: () => void;
|
|
18
|
+
onReload: () => void;
|
|
19
|
+
keyboardOffset?: number | undefined;
|
|
20
|
+
bottomInset?: number | undefined;
|
|
21
|
+
words: ChatWords;
|
|
22
|
+
Icon: ChatIcon;
|
|
23
|
+
skipMark: ImageSourcePropType;
|
|
24
|
+
label?: string;
|
|
25
|
+
lead?: ReactNode;
|
|
26
|
+
trail?: ReactNode;
|
|
27
|
+
hidden?: ReadonlySet<number>;
|
|
28
|
+
choices?: ConversationChoices;
|
|
29
|
+
composerClosed?: boolean;
|
|
30
|
+
holding?: boolean;
|
|
31
|
+
focusBox?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ConversationChoices {
|
|
34
|
+
sending: string | null;
|
|
35
|
+
failed: number | null;
|
|
36
|
+
holding?: boolean;
|
|
37
|
+
words: WelcomeWords;
|
|
38
|
+
onChoose: (question: ThreadMessage, answer: ChoiceItem) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare const PHOTO_RETRIES = 5;
|
|
41
|
+
export declare const PHOTO_RETRY_MS = 1500;
|
|
42
|
+
/** One conversation: its messages oldest at the top, the care team's typing, and the box to write in. */
|
|
43
|
+
export declare function Conversation(props: ConversationProps): import("react").JSX.Element;
|
|
44
|
+
/** Scrolls a conversation's list to its newest line. */
|
|
45
|
+
type ShowNewest = () => void;
|
|
46
|
+
/** What both of a conversation's lists draw: its items newest first, the open question, and how to show the newest. */
|
|
47
|
+
export interface ThreadLogProps extends ConversationProps {
|
|
48
|
+
items: ThreadItem[];
|
|
49
|
+
question: OpenQuestion | undefined;
|
|
50
|
+
newest: Ref<ShowNewest>;
|
|
51
|
+
typing: ReactNode;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The web's list. A page reads in its own order, so the lines go oldest first, as the eye reads them, in a box that is
|
|
55
|
+
* column-reverse, so it starts at its bottom, the newest line, and stays put while older lines load above.
|
|
56
|
+
*/
|
|
57
|
+
export declare function WebThread({ items, question, newest, typing, ...props }: ThreadLogProps): import("react").JSX.Element;
|
|
58
|
+
/** The phone's list, inverted so it rests at the newest message and stays put while the member reads older ones. */
|
|
59
|
+
export declare function NativeThread({ items, question, newest, typing, ...props }: ThreadLogProps): import("react").JSX.Element;
|
|
60
|
+
export interface UnsentProps {
|
|
61
|
+
message: ThreadMessage;
|
|
62
|
+
words: ChatWords;
|
|
63
|
+
onRetry: (id: number) => void;
|
|
64
|
+
Icon: ChatIcon;
|
|
65
|
+
holding: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** The member's line while it is on its way, or after it failed, with its retry. */
|
|
68
|
+
export declare function Unsent({ message, words, onRetry, Icon, holding, }: UnsentProps): import("react").JSX.Element;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useImperativeHandle, useRef, useState, } from 'react';
|
|
3
|
+
import { ActivityIndicator, FlatList, Image, KeyboardAvoidingView, Linking, Platform, Pressable, ScrollView, Text, TextInput, View, } from 'react-native';
|
|
4
|
+
import { contentFits } from "../helpers/scrollBox.js";
|
|
5
|
+
import { groupThread, openQuestion, } from "../helpers/thread.js";
|
|
6
|
+
import { Bubble } from "./Bubble.js";
|
|
7
|
+
import { useColor } from "./parts.js";
|
|
8
|
+
import { AVATAR_SIZE, SkipAvatar } from "./SkipAvatar.js";
|
|
9
|
+
import { Choices, Pill } from "./Welcome.js";
|
|
10
|
+
export const PHOTO_RETRIES = 5;
|
|
11
|
+
export const PHOTO_RETRY_MS = 1_500;
|
|
12
|
+
const MIN_BOTTOM_SPACE = 12;
|
|
13
|
+
function Line({ className, ...props }) {
|
|
14
|
+
return _jsx(Text, { className: `font-ui ${className}`, ...props });
|
|
15
|
+
}
|
|
16
|
+
const isPhoto = (file) => file.type.startsWith('image/');
|
|
17
|
+
/** One conversation: its messages oldest at the top, the care team's typing, and the box to write in. */
|
|
18
|
+
export function Conversation(props) {
|
|
19
|
+
const { thread, load, feedDown, words, onReload } = props;
|
|
20
|
+
const secondary = useColor('ink-secondary');
|
|
21
|
+
const shown = props.hidden ? thread.messages.filter((message) => !props.hidden?.has(message.id)) : thread.messages;
|
|
22
|
+
const items = groupThread(shown, props.skipUserId).reverse();
|
|
23
|
+
const question = props.choices ? openQuestion(shown) : undefined;
|
|
24
|
+
const newest = useRef(null);
|
|
25
|
+
// A member who wrote from further up the thread is taken to the newest line, where their message lands.
|
|
26
|
+
const submit = () => {
|
|
27
|
+
props.composer.submit();
|
|
28
|
+
newest.current?.();
|
|
29
|
+
};
|
|
30
|
+
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(View, { className: "w-full max-w-[360px]", children: _jsx(Pill, { label: words.retry, look: "stroked", onPress: onReload }) })] })) : (_jsx(ThreadLog, { ...props, items: items, question: question, newest: newest, typing: props.typists.length ? (_jsx(Line, { className: "text-sm text-ink-secondary", children: words.typingLine(props.typists) })) : null })), _jsx(ComposerBox, { ...props, submit: submit })] }));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The web's list. A page reads in its own order, so the lines go oldest first, as the eye reads them, in a box that is
|
|
34
|
+
* column-reverse, so it starts at its bottom, the newest line, and stays put while older lines load above.
|
|
35
|
+
*/
|
|
36
|
+
export function WebThread({ items, question, newest, typing, ...props }) {
|
|
37
|
+
const { onLoadOlder } = props;
|
|
38
|
+
const log = useRef(null);
|
|
39
|
+
// The content height older lines were last asked at, so the top asks once until they land.
|
|
40
|
+
const askedAt = useRef(-1);
|
|
41
|
+
const askOnce = (contentHeight) => {
|
|
42
|
+
if (askedAt.current === contentHeight)
|
|
43
|
+
return;
|
|
44
|
+
askedAt.current = contentHeight;
|
|
45
|
+
onLoadOlder();
|
|
46
|
+
};
|
|
47
|
+
// Content that does not fill the box has nothing to scroll, so it asks for older lines on its own, once per number of
|
|
48
|
+
// messages: its content is as tall as the box however many lines it has, so a page that lands and leaves it short
|
|
49
|
+
// still asks for the next. A page that brings nothing changes no count and asks no more.
|
|
50
|
+
const messages = props.thread.messages.length;
|
|
51
|
+
const shortAskedAt = useRef(-1);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
askWhenShort();
|
|
54
|
+
});
|
|
55
|
+
// Measured from the page as it is drawn: a page that has just landed is on screen before onContentSizeChange says so.
|
|
56
|
+
function askWhenShort() {
|
|
57
|
+
if (!contentFits(log.current?.getScrollableNode()) || shortAskedAt.current === messages)
|
|
58
|
+
return;
|
|
59
|
+
shortAskedAt.current = messages;
|
|
60
|
+
onLoadOlder();
|
|
61
|
+
}
|
|
62
|
+
// Not animated: a smooth scroll stops short of a line that lands while it runs.
|
|
63
|
+
useImperativeHandle(newest, () => () => log.current?.scrollTo({ y: 0, animated: false }), []);
|
|
64
|
+
return (_jsxs(ScrollView, { ref: log, style: WEB_LOG, contentContainerClassName: "grow gap-4 px-gutter-phone py-4 md:mx-auto md:w-full md:max-w-reading", role: "log", "aria-label": props.label,
|
|
65
|
+
// The conversation scrolls, so the keyboard has to be able to reach it.
|
|
66
|
+
tabIndex: 0, scrollEventThrottle: 100, onLayout: askWhenShort, onContentSizeChange: askWhenShort, onScroll: ({ nativeEvent: { contentOffset, contentSize, layoutMeasurement } }) => {
|
|
67
|
+
// column-reverse counts scrollTop up from the bottom as negative, so the top is where this reaches 0.
|
|
68
|
+
const fromTop = contentSize.height - layoutMeasurement.height + contentOffset.y;
|
|
69
|
+
if (fromTop > layoutMeasurement.height / 2) {
|
|
70
|
+
askedAt.current = -1;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
askOnce(contentSize.height);
|
|
74
|
+
}, children: [props.lead, [...items].reverse().map((item) => (_jsx(ThreadRow, { item: item, question: question, ...props }, itemKey(item)))), props.trail, typing] }));
|
|
75
|
+
}
|
|
76
|
+
/** The phone's list, inverted so it rests at the newest message and stays put while the member reads older ones. */
|
|
77
|
+
export function NativeThread({ items, question, newest, typing, ...props }) {
|
|
78
|
+
const { onLoadOlder } = props;
|
|
79
|
+
const list = useRef(null);
|
|
80
|
+
useImperativeHandle(newest, () => () => list.current?.scrollToOffset({ offset: 0, animated: true }), []);
|
|
81
|
+
return (_jsx(FlatList, { ref: list, inverted: true, data: items, keyExtractor: itemKey, onEndReached: onLoadOlder,
|
|
82
|
+
// The list is upside down, so its content's end is the top: a short conversation starts there and grows down.
|
|
83
|
+
contentContainerClassName: "grow justify-end gap-4 px-gutter-phone py-4 md:mx-auto md:w-full md:max-w-reading", role: "log", "aria-label": props.label,
|
|
84
|
+
// The conversation scrolls, so the keyboard has to be able to reach it.
|
|
85
|
+
tabIndex: 0, ListHeaderComponent: _jsxs(_Fragment, { children: [props.trail, typing] }), ListFooterComponent: _jsx(_Fragment, { children: props.lead }), renderItem: ({ item }) => _jsx(ThreadRow, { item: item, question: question, ...props }) }));
|
|
86
|
+
}
|
|
87
|
+
const ThreadLog = Platform.select({ web: WebThread, default: NativeThread });
|
|
88
|
+
const WEB_LOG = { flexDirection: 'column-reverse' };
|
|
89
|
+
function itemKey(item) {
|
|
90
|
+
if (item.kind === 'run')
|
|
91
|
+
return `r${String(item.messages[0]?.id)}`;
|
|
92
|
+
return `${item.kind === 'notice' ? 'n' : 'u'}${String(item.message.id)}`;
|
|
93
|
+
}
|
|
94
|
+
// The web sends on Enter, as joinskips.com's chat does, and Shift+Enter starts a new line. A phone's return key
|
|
95
|
+
// starts a new line.
|
|
96
|
+
function sendOnEnter(canSend, submit) {
|
|
97
|
+
return (event) => {
|
|
98
|
+
const { nativeEvent } = event;
|
|
99
|
+
if (nativeEvent.key !== 'Enter' || ('shiftKey' in nativeEvent && nativeEvent.shiftKey === true))
|
|
100
|
+
return;
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
if (canSend)
|
|
103
|
+
submit();
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function ComposerBox({ composer, submit, bottomInset, words, Icon, composerClosed = false, holding = false, focusBox = false, }) {
|
|
107
|
+
const box = useRef(null);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (focusBox)
|
|
110
|
+
box.current?.focus();
|
|
111
|
+
}, [focusBox]);
|
|
112
|
+
const secondary = useColor('ink-secondary');
|
|
113
|
+
const placeholder = useColor('ink-placeholder');
|
|
114
|
+
const actionInk = useColor('action-ink');
|
|
115
|
+
const { text, picked, refused } = composer;
|
|
116
|
+
const canSend = composer.canSend && !composerClosed && !holding;
|
|
117
|
+
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 web:focus-within:shadow-lift", children: [composer.attach && !composerClosed ? (_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, { ref: box, value: text, editable: !composerClosed,
|
|
118
|
+
// A closed box is out of the Tab order and dimmed, so the keyboard and the eye both skip it.
|
|
119
|
+
focusable: !composerClosed, onChangeText: composer.onChangeText, placeholder: words.composerPlaceholder, placeholderTextColor: placeholder, accessibilityLabel: words.composerPlaceholder, multiline: true, ...Platform.select({ web: { rows: 1, onKeyPress: sendOnEnter(canSend, submit) }, default: {} }),
|
|
120
|
+
// The web's textarea sizes to what is typed, up to max-h-40, and the pill shows its focus.
|
|
121
|
+
className: `max-h-40 flex-1 resize-none self-center px-1 py-2 font-ui text-md leading-6 text-ink web:field-sizing-content web:outline-none ${composerClosed ? 'opacity-50' : ''}` }), _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 }) }) })] }), words.emergencyNote ? (_jsx(Line, { className: "text-center text-xs text-ink-secondary", children: words.emergencyNote })) : null] }));
|
|
122
|
+
}
|
|
123
|
+
function ThreadRow({ item, words, onRetry, ...props }) {
|
|
124
|
+
if (item.kind === 'notice') {
|
|
125
|
+
return (_jsx(Line, { className: "self-center rounded-control border border-line-subtle px-3 py-2 text-sm text-ink-secondary", children: item.message.text }));
|
|
126
|
+
}
|
|
127
|
+
if (item.kind === 'unsent') {
|
|
128
|
+
return (_jsx(Unsent, { message: item.message, words: words, onRetry: onRetry, Icon: props.Icon, holding: props.holding ?? false }));
|
|
129
|
+
}
|
|
130
|
+
const { sender, messages } = item;
|
|
131
|
+
const mine = sender === 'mine';
|
|
132
|
+
const name = mine ? words.you : sender === 'skip' ? words.skip : sender.name;
|
|
133
|
+
// The run is in time order, so its time is its last line's.
|
|
134
|
+
const sentAt = Math.max(...messages.map((m) => m.sentAt));
|
|
135
|
+
const asks = (message) => props.choices !== undefined && props.question?.message.id === message.id;
|
|
136
|
+
// A run takes the width of its lines, so one with answers to press takes its whole share for them.
|
|
137
|
+
const answering = messages.some(asks);
|
|
138
|
+
return (_jsxs(View, { className: `${answering ? 'w-[82%]' : 'max-w-[82%]'} gap-1 ${mine ? 'items-end self-end' : 'items-start self-start'}`, children: [messages.map((message, index) => (_jsxs(View, { className: `flex-row items-end gap-2 ${asks(message) ? 'self-stretch' : ''}`, children: [mine ? null : index === messages.length - 1 ? (_jsx(SenderAvatar, { sender: sender, name: name, skipMark: props.skipMark })) : (_jsx(View, { className: "w-8" })), _jsxs(View, { className: `${asks(message) ? 'flex-1' : 'shrink'} gap-2 ${mine ? 'items-end' : 'items-start'}`, children: [message.attachments.map((attachment) => (_jsx(Attachment, { attachment: attachment, words: words, Icon: props.Icon }, attachment.url))), message.text ? _jsx(Bubble, { mine: mine, text: message.text }) : null, props.choices && props.question && asks(message) ? (_jsx(ChoiceRow, { question: props.question, choices: props.choices })) : null] })] }, message.id))), _jsx(Line, { className: `px-1 text-xs text-ink-secondary ${mine ? '' : 'ml-10'}`, children: `${name} · ${words.messageTime(sentAt)}` })] }));
|
|
139
|
+
}
|
|
140
|
+
function ChoiceRow({ question, choices }) {
|
|
141
|
+
return (_jsx(Choices, { items: question.items, question: question.message.text, sending: choices.sending, holding: choices.holding ?? false, failed: choices.failed === question.message.id, words: choices.words, onChoose: (answer) => {
|
|
142
|
+
choices.onChoose(question.message, answer);
|
|
143
|
+
} }));
|
|
144
|
+
}
|
|
145
|
+
// A failed line is a button to send it again, and its note is announced.
|
|
146
|
+
const BUTTON_ROLE = 'button';
|
|
147
|
+
const ALERT_ROLE = 'alert';
|
|
148
|
+
/** The member's line while it is on its way, or after it failed, with its retry. */
|
|
149
|
+
export function Unsent({ message, words, onRetry, Icon, holding, }) {
|
|
150
|
+
const failed = message.delivery === 'failed';
|
|
151
|
+
const status = `${words.you} · ${failed ? words.notSent : words.sending}`;
|
|
152
|
+
// A label takes the place of the button's content in its name, so it names the file and the line as shown.
|
|
153
|
+
const file = message.file ? (isPhoto(message.file) ? `${words.photo} ${message.file.name}` : message.file.name) : '';
|
|
154
|
+
return (_jsxs(Pressable, { ...(failed ? { role: BUTTON_ROLE, accessibilityLabel: [file, message.text, status].filter(Boolean).join(' ') } : {}), disabled: !failed || holding, onPress: () => {
|
|
155
|
+
onRetry(message.id);
|
|
156
|
+
}, className: `max-w-[82%] items-end gap-1 self-end ${failed ? '' : 'opacity-70'}`, children: [message.file ? _jsx(PickedPreview, { picked: message.file, words: words, Icon: Icon }) : null, message.text ? _jsx(Bubble, { mine: true, text: message.text }) : null, _jsx(Line, { ...(failed ? { role: ALERT_ROLE } : {}), className: `px-1 text-xs ${failed ? 'text-error-ink' : 'text-ink-secondary'}`, children: status })] }));
|
|
157
|
+
}
|
|
158
|
+
// Skip's mark, or a care team member's photo, or their initial when they have none or it does not load.
|
|
159
|
+
function SenderAvatar({ sender, name, skipMark, }) {
|
|
160
|
+
const [failed, setFailed] = useState(false);
|
|
161
|
+
if (sender === 'skip')
|
|
162
|
+
return _jsx(SkipAvatar, { skipMark: skipMark });
|
|
163
|
+
return (_jsx(View, { accessibilityElementsHidden: true, className: "h-8 w-8 items-center justify-center overflow-hidden rounded-pill bg-muted", children: sender.avatarUrl && !failed ? (_jsx(Image, { source: { uri: sender.avatarUrl }, onError: () => {
|
|
164
|
+
setFailed(true);
|
|
165
|
+
}, style: { width: AVATAR_SIZE, height: AVATAR_SIZE } })) : (_jsx(Line, { className: "text-sm font-semibold text-ink", children: name.trim().charAt(0).toUpperCase() })) }));
|
|
166
|
+
}
|
|
167
|
+
function FileCard({ name, detail, Icon }) {
|
|
168
|
+
const secondary = useColor('ink-secondary');
|
|
169
|
+
return (_jsxs(View, { className: "w-80 max-w-full flex-row items-center gap-3 rounded-control border border-line-subtle bg-surface p-3", children: [_jsx(Icon, { name: "file", color: secondary, size: 20 }), _jsxs(View, { className: "flex-1", children: [_jsx(Line, { className: "text-sm text-ink", numberOfLines: 1, children: name }), _jsx(Line, { className: "text-xs text-ink-secondary", children: detail })] })] }));
|
|
170
|
+
}
|
|
171
|
+
function PickedPreview({ picked, words, Icon }) {
|
|
172
|
+
if (isPhoto(picked)) {
|
|
173
|
+
return (_jsx(Image, { source: { uri: picked.uri }, accessibilityLabel: `${words.photo} ${picked.name}`, resizeMode: "cover", className: "h-48 w-48 rounded-control bg-muted" }));
|
|
174
|
+
}
|
|
175
|
+
return _jsx(FileCard, { name: picked.name, detail: `${words.pdf} · ${words.fileSize(picked.size)}`, Icon: Icon });
|
|
176
|
+
}
|
|
177
|
+
// A photo shows in the conversation and a PDF as its card. Either opens in full.
|
|
178
|
+
function Attachment({ attachment, words, Icon, }) {
|
|
179
|
+
// The Skips App stores a photo a moment after its upload answers, so a fresh one loads again until it is there.
|
|
180
|
+
const [attempt, setAttempt] = useState(0);
|
|
181
|
+
const open = () => void Linking.openURL(attachment.url);
|
|
182
|
+
if (attachment.kind === 'file') {
|
|
183
|
+
return (_jsx(Pressable, { role: "link", onPress: open, className: "active:opacity-80", children: _jsx(FileCard, { name: attachment.name, detail: words.fileKind(attachment.name), Icon: Icon }) }));
|
|
184
|
+
}
|
|
185
|
+
return (_jsx(Pressable, { role: "link", accessibilityLabel: `${words.photo} ${attachment.name}`, onPress: open, className: "active:opacity-80", children: _jsx(Image, { source: { uri: attachment.thumbUrl ?? attachment.url },
|
|
186
|
+
// Past the last attempt the key stays the same, so the photo is not asked for again.
|
|
187
|
+
onError: () => {
|
|
188
|
+
setTimeout(() => {
|
|
189
|
+
setAttempt((last) => Math.min(last + 1, PHOTO_RETRIES));
|
|
190
|
+
}, PHOTO_RETRY_MS);
|
|
191
|
+
}, resizeMode: "cover", className: "h-48 w-48 rounded-control bg-muted" }, attempt) }));
|
|
192
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface NewTab {
|
|
2
|
+
target: string;
|
|
3
|
+
rel: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const NEW_TAB: NewTab;
|
|
6
|
+
export interface MarkdownProps {
|
|
7
|
+
text: string;
|
|
8
|
+
note?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function Markdown({ text, note }: MarkdownProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Linking, Platform, Text, View } from 'react-native';
|
|
3
|
+
import { readMarkdown } from "../helpers/markdown.js";
|
|
4
|
+
// On the web a link opens in a new tab, as the website's own links do, telling the other site nothing.
|
|
5
|
+
export const NEW_TAB = { target: '_blank', rel: 'noopener noreferrer nofollow' };
|
|
6
|
+
const LINE_TEXT = 'font-ui text-md text-ink';
|
|
7
|
+
const NOTE_TEXT = 'text-center font-ui text-xs text-ink-secondary';
|
|
8
|
+
function Inlines({ nodes }) {
|
|
9
|
+
return nodes.map((node, i) => _jsx(InlineNode, { node: node }, `${String(i)}-${node.type}`));
|
|
10
|
+
}
|
|
11
|
+
function InlineNode({ node }) {
|
|
12
|
+
switch (node.type) {
|
|
13
|
+
case 'text':
|
|
14
|
+
return node.text;
|
|
15
|
+
case 'break':
|
|
16
|
+
return '\n';
|
|
17
|
+
case 'code':
|
|
18
|
+
return _jsx(Text, { className: "bg-muted font-mono text-sm", children: node.text });
|
|
19
|
+
case 'strong':
|
|
20
|
+
return (_jsx(Text, { className: "font-semibold", children: _jsx(Inlines, { nodes: node.children }) }));
|
|
21
|
+
case 'em':
|
|
22
|
+
return (_jsx(Text, { className: "italic", children: _jsx(Inlines, { nodes: node.children }) }));
|
|
23
|
+
case 'del':
|
|
24
|
+
return (_jsx(Text, { className: "line-through", children: _jsx(Inlines, { nodes: node.children }) }));
|
|
25
|
+
case 'link':
|
|
26
|
+
return (_jsx(Text, { role: "link", className: "underline", ...Platform.select({
|
|
27
|
+
web: { href: node.href, hrefAttrs: NEW_TAB },
|
|
28
|
+
default: { onPress: Linking.openURL.bind(Linking, node.href) },
|
|
29
|
+
}), children: _jsx(Inlines, { nodes: node.children }) }));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function Blocks({ blocks, textClass }) {
|
|
33
|
+
return blocks.map((block, i) => (_jsx(BlockNode, { block: block, textClass: textClass }, `${String(i)}-${block.type}`)));
|
|
34
|
+
}
|
|
35
|
+
function BlockNode({ block, textClass }) {
|
|
36
|
+
switch (block.type) {
|
|
37
|
+
case 'paragraph':
|
|
38
|
+
return (_jsx(Text, { className: textClass, children: _jsx(Inlines, { nodes: block.children }) }));
|
|
39
|
+
case 'list':
|
|
40
|
+
return (_jsx(View, { role: "list", className: "gap-1", children: block.items.map((item, i) => (_jsxs(View, { role: "listitem", className: "flex-row gap-2", children: [_jsx(Text, { className: textClass, children: block.ordered ? `${String(block.start + i)}.` : '•' }), _jsx(View, { className: "shrink gap-1", children: _jsx(Blocks, { blocks: item, textClass: textClass }) })] }, String(i)))) }));
|
|
41
|
+
case 'quote':
|
|
42
|
+
return (_jsx(View, { className: "gap-1 border-l-2 border-line-control pl-3", children: _jsx(Blocks, { blocks: block.children, textClass: textClass }) }));
|
|
43
|
+
case 'code':
|
|
44
|
+
return _jsx(Text, { className: "bg-muted p-2 font-mono text-sm text-ink", children: block.text });
|
|
45
|
+
case 'rule':
|
|
46
|
+
return _jsx(View, { className: "h-px bg-line-control" });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function Markdown({ text, note = false }) {
|
|
50
|
+
return (_jsx(View, { className: "gap-2", children: _jsx(Blocks, { blocks: readMarkdown(text), textClass: note ? NOTE_TEXT : LINE_TEXT }) }));
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Every word the fold shows, which each app passes in. */
|
|
2
|
+
export interface NoteFoldWords {
|
|
3
|
+
/** The opened note's control that folds it again. */
|
|
4
|
+
showLess: string;
|
|
5
|
+
}
|
|
6
|
+
export interface NoteFoldProps {
|
|
7
|
+
/** The note's text, whose first line shows while it is folded. */
|
|
8
|
+
content: string | null;
|
|
9
|
+
/** The note's time, for a folded note the thread draws no time under, or null. */
|
|
10
|
+
time: string | null;
|
|
11
|
+
open: boolean;
|
|
12
|
+
onToggle: (open: boolean) => void;
|
|
13
|
+
words: NoteFoldWords;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A command note's fold (joinskips/skips-app#88): folded, its first line and time open it, and opened, Show less folds
|
|
17
|
+
* it. The app shows or hides the note's text beside it, and keeps whether it is open.
|
|
18
|
+
*/
|
|
19
|
+
export declare function NoteFold({ content, time, open, onToggle, words }: NoteFoldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, Text } from 'react-native';
|
|
3
|
+
import { summaryLine } from "../helpers/commandNote.js";
|
|
4
|
+
/**
|
|
5
|
+
* A command note's fold (joinskips/skips-app#88): folded, its first line and time open it, and opened, Show less folds
|
|
6
|
+
* it. The app shows or hides the note's text beside it, and keeps whether it is open.
|
|
7
|
+
*/
|
|
8
|
+
export function NoteFold({ content, time, open, onToggle, words }) {
|
|
9
|
+
return (_jsx(Pressable, { role: "button", "aria-expanded": open, onPress: () => {
|
|
10
|
+
onToggle(!open);
|
|
11
|
+
}, className: "min-w-0 flex-row items-baseline gap-2", children: open ? (_jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: words.showLess })) : (_jsxs(_Fragment, { children: [_jsx(Text, { numberOfLines: 1, className: "shrink font-ui text-sm text-ink-secondary", children: summaryLine(content) }), time === null ? null : _jsx(Text, { className: "shrink-0 font-ui text-xs text-ink-secondary", children: time })] })) }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type NoteView } from '../helpers/noteView.ts';
|
|
2
|
+
/** Every word the note view control shows, which each app passes in. */
|
|
3
|
+
export interface NoteViewWords {
|
|
4
|
+
/** The name of the group of choices. */
|
|
5
|
+
group: string;
|
|
6
|
+
all: string;
|
|
7
|
+
messages: string;
|
|
8
|
+
notes: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NoteViewControlProps {
|
|
11
|
+
view: NoteView;
|
|
12
|
+
onChange: (view: NoteView) => void;
|
|
13
|
+
words: NoteViewWords;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The thread's choice of all, the messages only or the notes only (joinskips/skips-app#311). The app filters its thread
|
|
17
|
+
* with notesInView and keeps the choice on the device.
|
|
18
|
+
*/
|
|
19
|
+
export declare function NoteViewControl({ view, onChange, words }: NoteViewControlProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, Text, View } from 'react-native';
|
|
3
|
+
import { NOTE_VIEWS } from "../helpers/noteView.js";
|
|
4
|
+
/**
|
|
5
|
+
* The thread's choice of all, the messages only or the notes only (joinskips/skips-app#311). The app filters its thread
|
|
6
|
+
* with notesInView and keeps the choice on the device.
|
|
7
|
+
*/
|
|
8
|
+
export function NoteViewControl({ view, onChange, words }) {
|
|
9
|
+
const choices = [
|
|
10
|
+
[NOTE_VIEWS.ALL, words.all],
|
|
11
|
+
[NOTE_VIEWS.MESSAGES, words.messages],
|
|
12
|
+
[NOTE_VIEWS.NOTES, words.notes],
|
|
13
|
+
];
|
|
14
|
+
return (_jsx(View, { role: "group", accessibilityLabel: words.group, className: "flex-row gap-1 self-start rounded-control bg-muted p-0.5", children: choices.map(([choice, label]) => {
|
|
15
|
+
const shown = view === choice;
|
|
16
|
+
return (_jsx(Pressable, { role: "button", "aria-pressed": shown, onPress: () => {
|
|
17
|
+
onChange(choice);
|
|
18
|
+
}, className: `rounded-control px-2 py-0.5 ${shown ? 'bg-surface' : ''}`, children: _jsx(Text, { className: `font-ui text-xs ${shown ? 'text-ink' : 'text-ink-secondary'}`, children: label }) }, choice));
|
|
19
|
+
}) }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type LookupFailure } from '../helpers/medicationOrder.ts';
|
|
2
|
+
import type { OrderFormView } from '../hooks/useOrderForm.ts';
|
|
3
|
+
/** Every word the Order form shows, which each app passes in. */
|
|
4
|
+
export interface OrderFormWords {
|
|
5
|
+
title: string;
|
|
6
|
+
editTitle: (name: string) => string;
|
|
7
|
+
sendTitle: (name: string) => string;
|
|
8
|
+
chartTitle: string;
|
|
9
|
+
medicationN: (number: number) => string;
|
|
10
|
+
roundOf: (round: number, rounds: number) => string;
|
|
11
|
+
medication: string;
|
|
12
|
+
medicationPlaceholder: (count: number) => string;
|
|
13
|
+
controlled: (name: string) => string;
|
|
14
|
+
clear: string;
|
|
15
|
+
searching: string;
|
|
16
|
+
details: string;
|
|
17
|
+
quantity: string;
|
|
18
|
+
dose: string;
|
|
19
|
+
frequency: string;
|
|
20
|
+
duration: string;
|
|
21
|
+
durationPlaceholder: string;
|
|
22
|
+
maxPerDay: string;
|
|
23
|
+
sig: string;
|
|
24
|
+
dispenseAmount: string;
|
|
25
|
+
dispenseUnit: string;
|
|
26
|
+
refills: string;
|
|
27
|
+
earliestFillDate: string;
|
|
28
|
+
pharmacyNotes: string;
|
|
29
|
+
substitute: string;
|
|
30
|
+
indication: string;
|
|
31
|
+
discontinueDuplicate: string;
|
|
32
|
+
choose: string;
|
|
33
|
+
pharmacy: string;
|
|
34
|
+
pharmacyKind: string;
|
|
35
|
+
retail: string;
|
|
36
|
+
mailOrder: string;
|
|
37
|
+
zip: string;
|
|
38
|
+
searchWords: string;
|
|
39
|
+
noResults: string;
|
|
40
|
+
ncpdpId: (id: string) => string;
|
|
41
|
+
addMedication: string;
|
|
42
|
+
addRound: string;
|
|
43
|
+
remove: string;
|
|
44
|
+
removeRound: (round: number) => string;
|
|
45
|
+
create: string;
|
|
46
|
+
update: string;
|
|
47
|
+
edit: string;
|
|
48
|
+
send: string;
|
|
49
|
+
openInTreat: string;
|
|
50
|
+
reference: (ref: string) => string;
|
|
51
|
+
/** The banner for a failed lookup, from its message key and values. */
|
|
52
|
+
lookup: (failure: LookupFailure, shortestTerm: number) => string;
|
|
53
|
+
postFailed: string;
|
|
54
|
+
chartIntro: (count: number, name: string, dob: string) => string;
|
|
55
|
+
treatCharts: string;
|
|
56
|
+
chartNamed: (name: string, uid: string) => string;
|
|
57
|
+
phoneEnding: (digits: string) => string;
|
|
58
|
+
lastVisit: (date: string) => string;
|
|
59
|
+
noVisits: string;
|
|
60
|
+
noChartFits: string;
|
|
61
|
+
orderInTreat: string;
|
|
62
|
+
backToOrder: string;
|
|
63
|
+
stageOnChart: string;
|
|
64
|
+
}
|
|
65
|
+
export interface OrderFormProps extends OrderFormView {
|
|
66
|
+
words: OrderFormWords;
|
|
67
|
+
/** Opens a link, such as a refusal's way into Treat. */
|
|
68
|
+
openLink: (url: string) => void;
|
|
69
|
+
}
|
|
70
|
+
/** The Order form, as the web dashboard and the mobile app both show it in their own dialog. */
|
|
71
|
+
export declare function OrderForm(props: OrderFormProps): import("react").JSX.Element;
|