@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,118 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { ActivityIndicator, Pressable, ScrollView, Text, TextInput, View } from 'react-native';
|
|
4
|
+
import { dayWords, refusalParts, } from "../helpers/medicationOrder.js";
|
|
5
|
+
import { canSearchPharmacies, isAsNeeded, pharmacyOf, resolved, shownPharmacies, SHORTEST_TERM, } from "../helpers/orderForm.js";
|
|
6
|
+
import { useColor } from "./parts.js";
|
|
7
|
+
import { StaffButton } from "./StaffButton.js";
|
|
8
|
+
const INPUT = 'min-h-control-compact rounded-control border border-line-control bg-surface px-3 py-1.5 font-ui text-sm text-ink';
|
|
9
|
+
const NUMBER = /^\d+(\.\d+)?$/;
|
|
10
|
+
// A number field gives a number, as the Vue form's number inputs did, so usrx gets `{ refills: 3 }` for a card change.
|
|
11
|
+
// Text a number would rewrite, as 1.0 to 1, stays text while it is typed, so 1.05 can be typed.
|
|
12
|
+
const typed = (text) => (NUMBER.test(text) && String(Number(text)) === text ? Number(text) : text);
|
|
13
|
+
const shown = (value) => (value == null ? '' : String(value));
|
|
14
|
+
function Label({ text, hidden = false }) {
|
|
15
|
+
return (_jsx(Text, { "aria-hidden": hidden, className: "font-ui text-xs font-medium text-ink-secondary", children: text }));
|
|
16
|
+
}
|
|
17
|
+
function Line({ text, error = false }) {
|
|
18
|
+
return (_jsx(Text, { role: error ? 'alert' : 'status', className: `font-ui text-xs ${error ? 'text-error-ink' : 'text-ink-secondary'}`, children: text }));
|
|
19
|
+
}
|
|
20
|
+
function FieldInput({ label, value, onChange, editable, numeric = false, placeholder, multiline = false, focused = false }) {
|
|
21
|
+
const input = useRef(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (focused)
|
|
24
|
+
input.current?.focus();
|
|
25
|
+
}, [focused]);
|
|
26
|
+
return (_jsxs(View, { className: "min-w-24 flex-1 gap-1", children: [_jsx(Label, { text: label }), _jsx(TextInput, { ref: input, accessibilityLabel: label, value: value, onChangeText: onChange, editable: editable, inputMode: numeric ? 'decimal' : 'text', placeholder: placeholder, multiline: multiline, className: `${INPUT} ${multiline ? 'min-h-16' : ''}` })] }));
|
|
27
|
+
}
|
|
28
|
+
/** One of Treat's options, picked from a list the field opens, since React Native has no select. */
|
|
29
|
+
function ChoiceField({ label, options, value, onChange, editable, chooseWord, open: openAt = false }) {
|
|
30
|
+
const [toggled, setToggled] = useState(false);
|
|
31
|
+
// A refusal that names the field opens it, and a press after that closes it.
|
|
32
|
+
const open = openAt !== toggled;
|
|
33
|
+
const setOpen = (next) => {
|
|
34
|
+
setToggled(next !== openAt);
|
|
35
|
+
};
|
|
36
|
+
const chosen = options?.find((option) => option.id === shown(value));
|
|
37
|
+
return (_jsxs(View, { className: "min-w-24 flex-1 gap-1", children: [_jsx(Label, { text: label, hidden: true }), _jsx(StaffButton, { label: chosen?.name ?? chooseWord, name: `${label}: ${chosen?.name ?? chooseWord}`, disabled: !editable || !options, onPress: () => {
|
|
38
|
+
setOpen(!open);
|
|
39
|
+
} }), open && options ? (_jsx(View, { role: "radiogroup", accessibilityLabel: label, className: "gap-1", children: options.map((option) => (_jsx(Pressable, { role: "radio", "aria-checked": option.id === chosen?.id, accessibilityLabel: option.name, onPress: () => {
|
|
40
|
+
onChange(option.id);
|
|
41
|
+
setOpen(false);
|
|
42
|
+
}, className: `rounded-control border px-3 py-1.5 ${option.id === chosen?.id ? 'border-action bg-muted' : 'border-line-control bg-surface'}`, children: _jsx(Text, { className: "font-ui text-sm text-ink", children: option.name }) }, option.id))) })) : null] }));
|
|
43
|
+
}
|
|
44
|
+
function Round({ props, medicine, item, round }) {
|
|
45
|
+
const { words, viewing, editing, focus } = props;
|
|
46
|
+
const editable = !viewing;
|
|
47
|
+
const at = (field) => focus?.itemKey === item.key && focus.field === field;
|
|
48
|
+
const set = (field) => (text) => {
|
|
49
|
+
props.setField(item.key, field, field === 'pharmacyNotes' || field === 'earliestFillDate' || field === 'indication' ? text : typed(text));
|
|
50
|
+
};
|
|
51
|
+
const choose = (field) => (id) => {
|
|
52
|
+
props.setField(item.key, field, id);
|
|
53
|
+
};
|
|
54
|
+
const rounds = medicine.rounds.length;
|
|
55
|
+
const { sig } = resolved(item);
|
|
56
|
+
const ink = useColor('ink');
|
|
57
|
+
return (_jsxs(View, { className: "gap-2", children: [rounds > 1 ? (_jsxs(View, { className: "flex-row items-center justify-between", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.roundOf(round, rounds) }), round > 1 && !editing ? (_jsx(StaffButton, { label: words.removeRound(round), look: "danger", onPress: () => {
|
|
58
|
+
props.removeRound(medicine.key, item.key);
|
|
59
|
+
} })) : null] })) : null, _jsxs(View, { className: "gap-1", children: [_jsx(Label, { text: words.medication }), _jsxs(View, { className: "flex-row items-center gap-2", children: [_jsx(TextInput, { accessibilityLabel: words.medication, value: item.term, onChangeText: (text) => {
|
|
60
|
+
props.typeTerm(item.key, text);
|
|
61
|
+
}, editable: editable, placeholder: words.medicationPlaceholder(SHORTEST_TERM), autoComplete: "off", className: `${INPUT} flex-1` }), item.loadingChoices ? _jsx(ActivityIndicator, { size: "small", color: ink, accessibilityLabel: words.searching }) : null, item.term && editable ? (_jsx(StaffButton, { label: words.clear, onPress: () => {
|
|
62
|
+
props.typeTerm(item.key, '');
|
|
63
|
+
} })) : null] }), item.searching ? _jsx(Line, { text: words.searching }) : null, !item.searching && item.found.length > 0 ? (_jsx(View, { className: "gap-1", children: item.found.map((drug) => (_jsx(StaffButton, { label: drug.controlled ? words.controlled(drug.name) : drug.name, onPress: () => {
|
|
64
|
+
props.pickDrug(item.key, drug);
|
|
65
|
+
} }, drug.ddid))) })) : null] }), item.drug ? (_jsxs(_Fragment, { children: [item.drug.details ? (_jsxs(View, { className: "gap-1", children: [_jsx(Label, { text: words.details }), _jsx(Text, { className: "font-ui text-sm text-ink", children: item.drug.details })] })) : null, _jsxs(View, { className: "flex-row flex-wrap gap-2", children: [_jsx(FieldInput, { label: words.quantity, value: shown(item.quantity), onChange: set('quantity'), editable: editable, numeric: true, focused: at('quantity') }), _jsx(ChoiceField, { label: words.dose, options: item.choices?.doseUnits, value: item.doseUnitId, onChange: choose('doseUnitId'), editable: editable, chooseWord: words.choose, open: at('doseUnit') })] }), _jsxs(View, { className: "flex-row flex-wrap gap-2", children: [_jsx(ChoiceField, { label: words.frequency, options: item.choices?.frequencies, value: item.frequencyId, onChange: choose('frequencyId'), editable: editable, chooseWord: words.choose, open: at('frequency') }), _jsx(FieldInput, { label: words.duration, value: shown(item.days), onChange: set('days'), editable: editable, numeric: true, placeholder: words.durationPlaceholder })] }), isAsNeeded(item) ? (_jsx(FieldInput, { label: words.maxPerDay, value: shown(item.maxPerDay), onChange: set('maxPerDay'), editable: editable, numeric: true })) : null, _jsxs(View, { className: "gap-1", children: [_jsx(Label, { text: words.sig }), _jsx(Text, { className: "font-ui text-sm text-ink", children: sig })] }), _jsxs(View, { className: "flex-row flex-wrap gap-2", children: [_jsx(FieldInput, { label: words.dispenseAmount, value: shown(item.dispenseAmount), onChange: set('dispenseAmount'), editable: editable, numeric: true, focused: at('dispenseAmount') }), _jsx(ChoiceField, { label: words.dispenseUnit, options: item.choices?.dispenseUnits, value: item.dispenseUnitId, onChange: choose('dispenseUnitId'), editable: editable, chooseWord: words.choose, open: at('dispenseUnit') }), _jsx(FieldInput, { label: words.refills, value: shown(item.refills), onChange: set('refills'), editable: editable, numeric: true })] }), item.indication === undefined || round > 1 ? null : (_jsx(FieldInput, { label: words.indication, value: item.indication, onChange: set('indication'), editable: editable })), _jsx(FieldInput, { label: words.earliestFillDate, value: item.earliestFillDate ?? '', onChange: set('earliestFillDate'), editable: editable, placeholder: "YYYY-MM-DD" }), _jsx(FieldInput, { label: words.pharmacyNotes, value: item.pharmacyNotes ?? '', onChange: set('pharmacyNotes'), editable: editable, multiline: true }), _jsxs(Pressable, { role: "checkbox", "aria-checked": item.substituteOk !== false, accessibilityLabel: words.substitute, disabled: !editable, onPress: () => {
|
|
66
|
+
props.setSubstituteOk(item.key, item.substituteOk === false);
|
|
67
|
+
}, className: "flex-row items-center gap-2", children: [_jsx(View, { className: `h-4 w-4 rounded-sm border border-line-control ${item.substituteOk === false ? 'bg-surface' : 'bg-action'}` }), _jsx(Text, { className: "font-ui text-sm text-ink", children: words.substitute })] }), editing || round > 1 ? null : (_jsxs(Pressable, { role: "checkbox", "aria-checked": item.discontinueDuplicate === true, accessibilityLabel: words.discontinueDuplicate, disabled: !editable, onPress: () => {
|
|
68
|
+
props.setDiscontinueDuplicate(item.key, item.discontinueDuplicate !== true);
|
|
69
|
+
}, className: "flex-row items-center gap-2", children: [_jsx(View, { className: `h-4 w-4 rounded-sm border border-line-control ${item.discontinueDuplicate === true ? 'bg-action' : 'bg-surface'}` }), _jsx(Text, { className: "font-ui text-sm text-ink", children: words.discontinueDuplicate })] }))] })) : null] }));
|
|
70
|
+
}
|
|
71
|
+
function PharmacySearch({ props, medicine }) {
|
|
72
|
+
const { words, viewing, editing, focus } = props;
|
|
73
|
+
const { picker } = medicine;
|
|
74
|
+
const going = pharmacyOf(props.medicines, medicine);
|
|
75
|
+
const ink = useColor('ink');
|
|
76
|
+
const listed = shownPharmacies(picker);
|
|
77
|
+
const pickedName = going?.name ?? editing?.pharmacyName ?? '';
|
|
78
|
+
const details = going ? [going.phone, words.ncpdpId(going.ncpdpid)].filter(Boolean).join(' · ') : '';
|
|
79
|
+
return (_jsxs(View, { className: "gap-2", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.pharmacy }), pickedName ? (_jsxs(View, { role: "status", className: "gap-0.5 rounded-control bg-muted p-2", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: pickedName }), going?.address ? _jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: going.address }) : null, details ? _jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: details }) : null] })) : null, viewing ? null : (_jsxs(_Fragment, { children: [_jsx(View, { role: "radiogroup", accessibilityLabel: words.pharmacyKind, className: "flex-row gap-2", children: [false, true].map((mailOrder) => (_jsx(Pressable, { role: "radio", "aria-checked": picker.mailOrder === mailOrder, onPress: () => {
|
|
80
|
+
props.setPlace(medicine.key, picker, { mailOrder });
|
|
81
|
+
}, className: `rounded-control border px-3 py-1.5 ${picker.mailOrder === mailOrder ? 'border-action bg-muted' : 'border-line-control bg-surface'}`, children: _jsx(Text, { className: "font-ui text-sm text-ink", children: mailOrder ? words.mailOrder : words.retail }) }, String(mailOrder)))) }), _jsxs(View, { className: "flex-row flex-wrap gap-2", children: [picker.mailOrder ? null : (_jsx(FieldInput, { label: words.zip, value: picker.zip, onChange: (zip) => {
|
|
82
|
+
props.setPlace(medicine.key, picker, { zip });
|
|
83
|
+
}, editable: true, numeric: true, focused: focus?.medicineKey === medicine.key && focus.field === 'pharmacy' })), _jsx(FieldInput, { label: words.searchWords, value: picker.words, onChange: (text) => {
|
|
84
|
+
props.setWords(medicine.key, text);
|
|
85
|
+
}, editable: true })] }), props.searchingPharmacies.has(medicine.key) ? (_jsx(ActivityIndicator, { size: "small", color: ink, accessibilityLabel: words.searching })) : picker.pharmacies && canSearchPharmacies(picker) ? (listed.length === 0 ? (_jsx(Line, { text: words.noResults })) : (_jsx(ScrollView, { className: "max-h-64", children: _jsx(View, { className: "gap-1", children: listed.map((pharmacy) => (_jsxs(Pressable, { role: "button", "aria-pressed": picker.pharmacy?.ncpdpid === pharmacy.ncpdpid, onPress: () => {
|
|
86
|
+
props.pickPharmacy(medicine.key, pharmacy);
|
|
87
|
+
}, className: `rounded-control border px-3 py-1.5 ${picker.pharmacy?.ncpdpid === pharmacy.ncpdpid ? 'border-action bg-muted' : 'border-line-control bg-surface'}`, children: [_jsx(Text, { className: "font-ui text-sm text-ink", children: pharmacy.name }), _jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: pharmacy.address })] }, pharmacy.ncpdpid))) }) }))) : null] }))] }));
|
|
88
|
+
}
|
|
89
|
+
function ChartPick({ props, charts, searchLink }) {
|
|
90
|
+
const { words } = props;
|
|
91
|
+
const [first] = charts;
|
|
92
|
+
const name = first ? `${first.firstName} ${first.lastName}` : '';
|
|
93
|
+
return (_jsxs(View, { className: "gap-3", children: [_jsx(Text, { className: "font-ui text-sm text-ink", children: words.chartIntro(charts.length, name, first ? dayWords(first.dob) : '') }), _jsx(View, { role: "radiogroup", accessibilityLabel: words.treatCharts, className: "gap-2", children: charts.map((chart) => {
|
|
94
|
+
const reach = [chart.phoneEnding ? words.phoneEnding(chart.phoneEnding) : '', [chart.city, chart.zip].filter(Boolean).join(', ')]
|
|
95
|
+
.filter(Boolean)
|
|
96
|
+
.join(' · ');
|
|
97
|
+
const visit = chart.lastVisit ? [words.lastVisit(chart.lastVisit), chart.pharmacy].filter(Boolean).join(' · ') : words.noVisits;
|
|
98
|
+
return (_jsxs(Pressable, { role: "radio", "aria-checked": props.pickedChart === chart.uid, onPress: () => {
|
|
99
|
+
props.pickChart(chart.uid);
|
|
100
|
+
}, className: `gap-0.5 rounded-control border px-3 py-2 ${props.pickedChart === chart.uid ? 'border-action bg-muted' : 'border-line-control bg-surface'}`, children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.chartNamed(`${chart.firstName} ${chart.lastName}`, chart.uid) }), reach ? _jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: reach }) : null, _jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: visit })] }, chart.uid));
|
|
101
|
+
}) }), searchLink ? (_jsxs(View, { className: "flex-row flex-wrap gap-1", children: [_jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: words.noChartFits }), _jsx(Text, { role: "link", onPress: () => {
|
|
102
|
+
props.openLink(searchLink);
|
|
103
|
+
}, className: "font-ui text-xs text-action underline", children: words.orderInTreat })] })) : null, _jsxs(View, { className: "flex-row flex-wrap justify-end gap-2", children: [_jsx(StaffButton, { label: words.backToOrder, disabled: props.busy, onPress: props.backToOrder }), _jsx(StaffButton, { label: words.stageOnChart, look: "primary", loading: props.busy, disabled: !props.pickedChart || !props.ready, onPress: props.confirm })] })] }));
|
|
104
|
+
}
|
|
105
|
+
/** The Order form, as the web dashboard and the mobile app both show it in their own dialog. */
|
|
106
|
+
export function OrderForm(props) {
|
|
107
|
+
const { words, medicines, editing, viewing, charts, lookupError } = props;
|
|
108
|
+
const name = editing?.drugName ?? '';
|
|
109
|
+
const title = charts ? words.chartTitle : viewing ? words.sendTitle(name) : editing ? words.editTitle(name) : words.title;
|
|
110
|
+
const refused = refusalParts(props.refusal);
|
|
111
|
+
return (_jsxs(View, { role: "group", accessibilityLabel: title, className: "gap-4", children: [_jsx(Text, { role: "heading", className: "font-ui text-base font-medium text-ink", children: title }), lookupError ? (_jsx(Line, { text: [words.lookup(lookupError, SHORTEST_TERM), lookupError.ref ? words.reference(lookupError.ref) : ''].filter(Boolean).join(' '), error: true })) : null, props.refusal ? (_jsxs(View, { role: "alert", className: "flex-row flex-wrap gap-1", children: [_jsx(Text, { className: "font-ui text-xs text-error-ink", children: refused.text }), refused.link ? (_jsx(Text, { role: "link", onPress: () => {
|
|
112
|
+
props.openLink(refused.link);
|
|
113
|
+
}, className: "font-ui text-xs text-error-ink underline", children: words.openInTreat })) : null] })) : null, props.postFailed ? _jsx(Line, { text: words.postFailed, error: true }) : null, charts ? (_jsx(ChartPick, { props: props, charts: charts.charts, searchLink: charts.searchLink })) : (_jsxs(_Fragment, { children: [medicines.map((medicine, index) => (_jsxs(View, { role: "group", accessibilityLabel: words.medicationN(index + 1), className: "gap-3 border-t border-line-control pt-3", children: [_jsxs(View, { className: "flex-row items-center justify-between", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.medicationN(index + 1) }), medicines.length > 1 ? (_jsx(StaffButton, { label: words.remove, look: "danger", onPress: () => {
|
|
114
|
+
props.removeMedication(medicine.key);
|
|
115
|
+
} })) : null] }), medicine.rounds.map((item, round) => (_jsx(Round, { props: props, medicine: medicine, item: item, round: round + 1 }, item.key))), editing || viewing ? null : (_jsx(StaffButton, { label: words.addRound, onPress: () => {
|
|
116
|
+
props.addRound(medicine.key);
|
|
117
|
+
} })), _jsx(PharmacySearch, { props: props, medicine: medicine })] }, medicine.key))), editing || viewing ? null : _jsx(StaffButton, { label: words.addMedication, onPress: props.addMedication }), _jsx(View, { className: "flex-row flex-wrap justify-end gap-2", children: viewing ? (_jsxs(_Fragment, { children: [_jsx(StaffButton, { label: words.edit, disabled: props.busy, onPress: props.edit }), props.mayReachPharmacy ? (_jsx(StaffButton, { label: words.send, look: "primary", loading: props.busy, onPress: props.confirm })) : null] })) : (_jsx(StaffButton, { label: editing ? words.update : words.create, look: "primary", loading: props.busy, disabled: !props.ready, onPress: props.confirm })) })] }))] }));
|
|
118
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type RowTag } from '../helpers/ordersMenu.ts';
|
|
2
|
+
import type { OrdersMenuView } from '../hooks/useOrdersMenu.ts';
|
|
3
|
+
/** Every word the Orders menu shows, which each app passes in. */
|
|
4
|
+
export interface OrdersMenuWords {
|
|
5
|
+
button: (count: number) => string;
|
|
6
|
+
/** The open menu's name. */
|
|
7
|
+
menu: string;
|
|
8
|
+
newOrder: string;
|
|
9
|
+
staged: (count: number) => string;
|
|
10
|
+
noStaged: string;
|
|
11
|
+
current: (count: number) => string;
|
|
12
|
+
noCurrent: string;
|
|
13
|
+
refills: (count: number) => string;
|
|
14
|
+
noRefills: string;
|
|
15
|
+
past: (count: number) => string;
|
|
16
|
+
noPast: string;
|
|
17
|
+
stagedTitle: string;
|
|
18
|
+
currentTitle: string;
|
|
19
|
+
refillsTitle: string;
|
|
20
|
+
pastTitle: string;
|
|
21
|
+
back: string;
|
|
22
|
+
readingCards: string;
|
|
23
|
+
cardsNotRead: string;
|
|
24
|
+
reference: (ref: string) => string;
|
|
25
|
+
readAgain: string;
|
|
26
|
+
refillsFailed: string;
|
|
27
|
+
pastFailed: string;
|
|
28
|
+
/** A refill to the same pharmacy that did not stage. */
|
|
29
|
+
stageFailed: string;
|
|
30
|
+
queued: string;
|
|
31
|
+
queuedSendFirst: (pharmacy: string) => string;
|
|
32
|
+
queuedSendOtherFirst: string;
|
|
33
|
+
edit: string;
|
|
34
|
+
send: string;
|
|
35
|
+
delete: string;
|
|
36
|
+
setName: (name: string, rounds: number) => string;
|
|
37
|
+
sentInRounds: (date: string, rounds: number) => string;
|
|
38
|
+
lastOrdered: (date: string) => string;
|
|
39
|
+
tag: (tag: RowTag, day: string) => string;
|
|
40
|
+
actions: string;
|
|
41
|
+
cancelRx: string;
|
|
42
|
+
discontinue: string;
|
|
43
|
+
changePharmacy: string;
|
|
44
|
+
refill: string;
|
|
45
|
+
stageSamePharmacy: string;
|
|
46
|
+
stageNewPharmacy: string;
|
|
47
|
+
reorder: string;
|
|
48
|
+
statusFilter: string;
|
|
49
|
+
showOrdersThatAre: string;
|
|
50
|
+
status: (status: string) => string;
|
|
51
|
+
deselectAll: string;
|
|
52
|
+
confirmDelete: (name: string) => string;
|
|
53
|
+
deleteFailed: string;
|
|
54
|
+
openInTreat: string;
|
|
55
|
+
keepIt: string;
|
|
56
|
+
confirmCancel: (name: string) => string;
|
|
57
|
+
confirmCancelBody: (pharmacy: string) => string;
|
|
58
|
+
confirmDiscontinue: (name: string) => string;
|
|
59
|
+
confirmDiscontinueBody: string;
|
|
60
|
+
confirmChangePharmacy: (name: string) => string;
|
|
61
|
+
confirmChangePharmacyBody: (pharmacy: string) => string;
|
|
62
|
+
reason: string;
|
|
63
|
+
actionFailed: string;
|
|
64
|
+
}
|
|
65
|
+
export interface OrdersMenuProps extends OrdersMenuView {
|
|
66
|
+
words: OrdersMenuWords;
|
|
67
|
+
/** Opens a link, such as a refusal's way into Treat. */
|
|
68
|
+
openLink: (url: string) => void;
|
|
69
|
+
}
|
|
70
|
+
/** The Orders menu: staged cards and sent orders from Treat, and what staff can do with them. */
|
|
71
|
+
export declare function OrdersMenu(props: OrdersMenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ScrollView, Text, TextInput, View, Pressable } from 'react-native';
|
|
3
|
+
import { cancellableUids, cardWords, dayWords, isQueued, refusalParts, setName } from "../helpers/medicationOrder.js";
|
|
4
|
+
import { cardKey, firstOf, pharmacyNameOf, pharmacyWords, rowTags, stagedPharmacy, STATUS_LIST, statusCount, } from "../helpers/ordersMenu.js";
|
|
5
|
+
import { StaffButton } from "./StaffButton.js";
|
|
6
|
+
const TAG_TONES = {
|
|
7
|
+
available: 'bg-success text-success-ink',
|
|
8
|
+
ended: 'bg-error text-error-ink',
|
|
9
|
+
plain: 'bg-muted text-ink-secondary',
|
|
10
|
+
warning: 'bg-warning text-warning-ink',
|
|
11
|
+
};
|
|
12
|
+
function Line({ text, error = false }) {
|
|
13
|
+
return (_jsx(Text, { role: error ? 'alert' : 'status', className: `font-ui text-xs ${error ? 'text-error-ink' : 'text-ink-secondary'}`, children: text }));
|
|
14
|
+
}
|
|
15
|
+
/** A card or an order in a list: its name, what else it says, its tags, then its buttons at the end. */
|
|
16
|
+
function Row({ name, lines, tags = [], words, children }) {
|
|
17
|
+
return (_jsxs(View, { role: "listitem", className: "gap-1 border-b border-line-subtle py-2", children: [_jsx(Text, { className: "font-ui text-sm text-ink", children: name }), lines.map((line) => (_jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: line }, line))), tags.length > 0 ? (_jsx(View, { className: "flex-row flex-wrap gap-1", children: tags.map((tag) => {
|
|
18
|
+
const label = words.tag(tag, tag.values.day ? dayWords(tag.values.day) : '');
|
|
19
|
+
return (_jsx(Text, { className: `rounded-control px-1.5 py-0.5 font-ui text-xs ${TAG_TONES[tag.tone]}`, children: label }, label));
|
|
20
|
+
}) })) : null, children] }));
|
|
21
|
+
}
|
|
22
|
+
function rowName(row, words) {
|
|
23
|
+
return row.set ? words.setName(setName(row), row.set.rounds) : (firstOf(row).drugName ?? '');
|
|
24
|
+
}
|
|
25
|
+
function rowLines(row, words) {
|
|
26
|
+
const first = firstOf(row);
|
|
27
|
+
const sent = new Date(first.sentAt).toLocaleDateString();
|
|
28
|
+
return [
|
|
29
|
+
pharmacyWords(first),
|
|
30
|
+
row.set ? words.sentInRounds(sent, row.set.rounds) : words.lastOrdered(sent),
|
|
31
|
+
].filter(Boolean);
|
|
32
|
+
}
|
|
33
|
+
function DeleteConfirm({ card, ...props }) {
|
|
34
|
+
const { words } = props;
|
|
35
|
+
const refusal = props.deleteRefused === null ? null : refusalParts(props.deleteRefused);
|
|
36
|
+
return (_jsxs(View, { role: "alertdialog", accessibilityLabel: words.confirmDelete(card.drugName), className: "gap-2", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: words.confirmDelete(card.drugName) }), refusal ? (_jsxs(Text, { role: "alert", className: "font-ui text-xs text-error-ink", children: [refusal.text, refusal.link ? (_jsx(Text, { role: "link", className: "underline", onPress: () => {
|
|
37
|
+
props.openLink(refusal.link);
|
|
38
|
+
}, children: ` ${words.openInTreat}` })) : null] })) : null, props.deleteFailed ? _jsx(Line, { text: words.deleteFailed, error: true }) : null, _jsxs(View, { className: "flex-row flex-wrap justify-end gap-2", children: [_jsx(StaffButton, { label: words.keepIt, disabled: props.deleting, onPress: props.cancelDelete }), _jsx(StaffButton, { label: words.delete, look: "danger", loading: props.deleting, onPress: props.confirmDelete })] })] }));
|
|
39
|
+
}
|
|
40
|
+
function ActionConfirm({ asked: pending, ...props }) {
|
|
41
|
+
const { words } = props;
|
|
42
|
+
const name = rowName(pending.row, words);
|
|
43
|
+
const pharmacy = pharmacyNameOf(firstOf(pending.row));
|
|
44
|
+
const text = {
|
|
45
|
+
cancel: { title: words.confirmCancel(name), body: words.confirmCancelBody(pharmacy), confirm: words.cancelRx },
|
|
46
|
+
discontinue: { title: words.confirmDiscontinue(name), body: words.confirmDiscontinueBody, confirm: words.discontinue },
|
|
47
|
+
pharmacy: {
|
|
48
|
+
title: words.confirmChangePharmacy(name),
|
|
49
|
+
body: words.confirmChangePharmacyBody(pharmacy),
|
|
50
|
+
confirm: words.changePharmacy,
|
|
51
|
+
},
|
|
52
|
+
}[pending.action];
|
|
53
|
+
return (_jsxs(View, { role: "alertdialog", accessibilityLabel: text.title, className: "gap-2", children: [_jsx(Text, { className: "font-ui text-sm font-medium text-ink", children: text.title }), _jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: text.body }), pending.action === 'pharmacy' ? null : (_jsx(TextInput, { accessibilityLabel: words.reason, placeholder: words.reason, value: props.reason, onChangeText: props.setReason, multiline: true, maxLength: 500, className: "min-h-16 rounded-control border border-line-control bg-surface px-3 py-2 font-ui text-sm text-ink" })), props.actionFailed ? _jsx(Line, { text: words.actionFailed, error: true }) : null, _jsxs(View, { className: "flex-row flex-wrap justify-end gap-2", children: [_jsx(StaffButton, { label: words.keepIt, disabled: props.acting, onPress: props.cancelAction }), _jsx(StaffButton, { label: text.confirm, look: pending.action === 'pharmacy' ? 'primary' : 'danger', loading: props.acting, onPress: props.runAction })] })] }));
|
|
54
|
+
}
|
|
55
|
+
function StagedList(props) {
|
|
56
|
+
const { words, cards } = props;
|
|
57
|
+
const pharmacy = stagedPharmacy(cards);
|
|
58
|
+
const waits = pharmacy ? words.queuedSendFirst(pharmacy) : words.queuedSendOtherFirst;
|
|
59
|
+
return (_jsx(View, { role: "list", children: cards.map((card) => {
|
|
60
|
+
const queued = isQueued(card);
|
|
61
|
+
return (_jsx(Row, { name: cardWords(card), lines: queued ? [words.queued, waits] : [], words: words, children: _jsxs(View, { className: "flex-row flex-wrap justify-end gap-2", children: [_jsx(StaffButton, { label: words.delete, look: "danger", onPress: () => {
|
|
62
|
+
props.askDelete(card);
|
|
63
|
+
} }), _jsx(StaffButton, { label: words.edit, disabled: !props.canOrder, onPress: () => {
|
|
64
|
+
props.editCard(card);
|
|
65
|
+
} }), props.mayReachPharmacy ? (_jsx(StaffButton, { label: words.send, look: "primary", disabled: queued || !props.canOrder, onPress: () => {
|
|
66
|
+
props.sendCard(card);
|
|
67
|
+
} })) : null] }) }, cardKey(card)));
|
|
68
|
+
}) }));
|
|
69
|
+
}
|
|
70
|
+
function OrderRows({ shown: list, ...props }) {
|
|
71
|
+
const { words, lists, today } = props;
|
|
72
|
+
const rows = list === 'past' ? props.shownPast : list === 'current' ? lists.current : lists.refills;
|
|
73
|
+
if (props.pastFailed)
|
|
74
|
+
return _jsx(Line, { text: list === 'refills' ? words.refillsFailed : words.pastFailed, error: true });
|
|
75
|
+
return (_jsx(View, { role: "list", children: rows.map((row) => (_jsxs(Row, { name: rowName(row, words), lines: rowLines(row, words), tags: rowTags(row, list, today), words: words, children: [list === 'current' ? (_jsx(View, { className: "flex-row flex-wrap justify-end gap-2", children: props.actionsFor === row.key ? (_jsxs(_Fragment, { children: [props.mayReachPharmacy ? (_jsx(StaffButton, { label: words.cancelRx, look: "danger", disabled: cancellableUids(row).length === 0, onPress: () => {
|
|
76
|
+
props.askAction('cancel', row);
|
|
77
|
+
} })) : null, _jsx(StaffButton, { label: words.discontinue, onPress: () => {
|
|
78
|
+
props.askAction('discontinue', row);
|
|
79
|
+
} }), props.mayReachPharmacy ? (_jsx(StaffButton, { label: words.changePharmacy, disabled: cancellableUids(row).length === 0, onPress: () => {
|
|
80
|
+
props.askAction('pharmacy', row);
|
|
81
|
+
} })) : null] })) : (_jsx(StaffButton, { label: words.actions, onPress: () => {
|
|
82
|
+
props.showActions(row);
|
|
83
|
+
} })) })) : null, list === 'refills' && props.stageFailed === row.key ? _jsx(Line, { text: words.stageFailed, error: true }) : null, list === 'refills' ? (_jsx(View, { className: "flex-row flex-wrap justify-end gap-2", children: props.refillChoicesFor === row.key ? (_jsxs(_Fragment, { children: [_jsx(StaffButton, { label: words.stageNewPharmacy, disabled: props.staging !== null || !props.canOrder, onPress: () => {
|
|
84
|
+
props.stageNewPharmacy(row);
|
|
85
|
+
} }), _jsx(StaffButton, { label: words.stageSamePharmacy, look: "primary", loading: props.staging === row.key, disabled: props.staging !== null || !props.canOrder, onPress: () => {
|
|
86
|
+
props.stageSamePharmacy(row);
|
|
87
|
+
} })] })) : (_jsx(StaffButton, { label: words.refill, disabled: props.staging !== null, onPress: () => {
|
|
88
|
+
props.showRefillChoices(row);
|
|
89
|
+
} })) })) : null, list === 'past' ? (_jsx(View, { className: "flex-row flex-wrap justify-end gap-2", children: _jsx(StaffButton, { label: words.reorder, disabled: !props.canOrder, onPress: () => {
|
|
90
|
+
props.reorder(row);
|
|
91
|
+
} }) })) : null] }, row.key))) }));
|
|
92
|
+
}
|
|
93
|
+
function StatusFilter(props) {
|
|
94
|
+
const { words } = props;
|
|
95
|
+
return (_jsxs(View, { role: "group", accessibilityLabel: words.showOrdersThatAre, className: "gap-1 rounded-control bg-muted p-2", children: [_jsx(Text, { className: "font-ui text-xs text-ink-secondary", children: words.showOrdersThatAre }), STATUS_LIST.map((status) => {
|
|
96
|
+
const checked = props.ticked.has(status);
|
|
97
|
+
const label = `${words.status(status)} (${String(statusCount(props.lists.past, status, props.today))})`;
|
|
98
|
+
return (_jsxs(Pressable, { role: "checkbox", "aria-checked": checked, accessibilityLabel: label, onPress: () => {
|
|
99
|
+
props.toggleStatus(status);
|
|
100
|
+
}, className: "flex-row items-center gap-2 py-1", children: [_jsx(Text, { "aria-hidden": true, className: `h-4 w-4 rounded-sm border border-line-control text-center font-ui text-xs ${checked ? 'bg-action text-action-ink' : 'bg-surface'}`, children: checked ? '✓' : '' }), _jsx(Text, { className: "font-ui text-sm text-ink", children: label })] }, status));
|
|
101
|
+
}), _jsx(View, { className: "flex-row justify-end", children: _jsx(StaffButton, { label: words.deselectAll, disabled: props.ticked.size === 0, onPress: props.deselectAll }) })] }));
|
|
102
|
+
}
|
|
103
|
+
/** The Orders menu: staged cards and sent orders from Treat, and what staff can do with them. */
|
|
104
|
+
export function OrdersMenu(props) {
|
|
105
|
+
const { words, list, lists, cards } = props;
|
|
106
|
+
const confirm = props.toDelete ? (_jsx(DeleteConfirm, { ...props, card: props.toDelete })) : props.pending ? (_jsx(ActionConfirm, { ...props, asked: props.pending })) : null;
|
|
107
|
+
const titles = { staged: words.stagedTitle, current: words.currentTitle, refills: words.refillsTitle, past: words.pastTitle };
|
|
108
|
+
const item = (shown, count, some, none) => ({
|
|
109
|
+
list: shown,
|
|
110
|
+
label: count ? some(count) : none,
|
|
111
|
+
empty: count === 0,
|
|
112
|
+
});
|
|
113
|
+
const top = [
|
|
114
|
+
item('staged', cards.length, words.staged, words.noStaged),
|
|
115
|
+
...(props.pastFailed
|
|
116
|
+
? []
|
|
117
|
+
: [
|
|
118
|
+
item('current', lists.current.length, words.current, words.noCurrent),
|
|
119
|
+
item('refills', lists.refills.length, words.refills, words.noRefills),
|
|
120
|
+
item('past', lists.past.length, words.past, words.noPast),
|
|
121
|
+
]),
|
|
122
|
+
];
|
|
123
|
+
return (_jsxs(View, { className: "relative self-end", children: [_jsx(StaffButton, { label: words.button(props.count), loading: props.reading && !props.open, onPress: props.toggle }), confirm ? (_jsx(View, { className: "absolute bottom-full right-0 z-10 mb-2 w-80 max-w-[90vw] rounded-control border border-line-control bg-surface p-3", children: confirm })) : null, props.open && !confirm ? (_jsx(ScrollView, { role: "group", accessibilityLabel: words.menu, className: "absolute bottom-full right-0 z-10 mb-2 max-h-96 w-80 max-w-[90vw] rounded-control border border-line-control bg-surface p-2", children: list === null ? (_jsxs(View, { className: "gap-1", children: [props.canOrder ? _jsx(StaffButton, { label: words.newOrder, look: "primary", onPress: props.newOrder }) : null, top.map((item) => (_jsx(StaffButton, { label: item.label, disabled: item.empty, onPress: () => {
|
|
124
|
+
props.show(item.list);
|
|
125
|
+
} }, item.list))), props.pastFailed ? (_jsxs(View, { className: "flex-row flex-wrap items-center justify-between gap-2", children: [_jsx(Line, { text: words.pastFailed, error: true }), _jsx(StaffButton, { label: words.readAgain, loading: props.reading, onPress: () => void props.refetch() })] })) : null, props.cardsFailed === null ? (props.reading && props.count === 0 ? _jsx(Line, { text: words.readingCards }) : null) : (_jsxs(View, { className: "flex-row flex-wrap items-center justify-between gap-2", children: [_jsx(Line, { text: [words.cardsNotRead, props.cardsFailed ? words.reference(props.cardsFailed) : ''].filter(Boolean).join(' '), error: true }), _jsx(StaffButton, { label: words.readAgain, loading: props.reading, onPress: () => void props.refetch() })] }))] })) : (_jsxs(View, { className: "gap-2", children: [_jsxs(View, { className: "flex-row flex-wrap items-center justify-between gap-2", children: [_jsx(StaffButton, { label: words.back, onPress: () => {
|
|
126
|
+
props.show(null);
|
|
127
|
+
} }), _jsx(Text, { role: "heading", className: "font-ui text-sm font-semibold text-ink", children: titles[list] }), list === 'past' ? _jsx(StaffButton, { label: words.statusFilter, onPress: props.toggleFilter }) : null] }), list === 'past' && props.filterOpen ? _jsx(StatusFilter, { ...props }) : null, list === 'staged' ? _jsx(StagedList, { ...props }) : _jsx(OrderRows, { ...props, shown: list })] })) })) : null] }));
|
|
128
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RegimenOption } from '../helpers/regimenChoice.ts';
|
|
2
|
+
/** Every word a regimen choice note shows, which each app passes in. */
|
|
3
|
+
export interface RegimenChoiceWords {
|
|
4
|
+
/** The name of the group of buttons. */
|
|
5
|
+
group: string;
|
|
6
|
+
/** A button's words, from the option's regimen and product. */
|
|
7
|
+
stage: (option: string) => string;
|
|
8
|
+
picked: (number: number) => string;
|
|
9
|
+
replaced: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RegimenChoiceProps {
|
|
12
|
+
options: readonly RegimenOption[];
|
|
13
|
+
picked: number | null;
|
|
14
|
+
/** No option can be picked: one was, or a newer choice note replaced this one. */
|
|
15
|
+
closed: boolean;
|
|
16
|
+
/** The pick waits on usrx's answer. */
|
|
17
|
+
waiting: boolean;
|
|
18
|
+
replaced: boolean;
|
|
19
|
+
words: RegimenChoiceWords;
|
|
20
|
+
onPick: (number: number) => void;
|
|
21
|
+
}
|
|
22
|
+
/** usrx's regimen choice note: a button per regimen, each staging its Treat card unsent. */
|
|
23
|
+
export declare function RegimenChoice({ options, picked, closed, waiting, replaced, words, onPick }: RegimenChoiceProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { optionLabel } from "../helpers/regimenChoice.js";
|
|
4
|
+
import { StaffButton } from "./StaffButton.js";
|
|
5
|
+
/** usrx's regimen choice note: a button per regimen, each staging its Treat card unsent. */
|
|
6
|
+
export function RegimenChoice({ options, picked, closed, waiting, replaced, words, onPick }) {
|
|
7
|
+
if (options.length === 0)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsxs(View, { role: "group", accessibilityLabel: words.group, className: "gap-2", children: [options.map((option) => {
|
|
10
|
+
const busy = waiting && picked === option.number;
|
|
11
|
+
const label = words.stage(optionLabel(option));
|
|
12
|
+
return (_jsx(StaffButton, { label: label, loading: busy, disabled: closed, onPress: () => {
|
|
13
|
+
onPick(option.number);
|
|
14
|
+
} }, option.number));
|
|
15
|
+
}), picked !== null || replaced ? (_jsx(Text, { className: "font-ui text-xs font-medium text-ink-secondary", children: picked === null ? words.replaced : words.picked(picked) })) : null] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ImageSourcePropType } from 'react-native';
|
|
2
|
+
export declare const AVATAR_SIZE = 32;
|
|
3
|
+
export interface SkipAvatarProps {
|
|
4
|
+
skipMark: ImageSourcePropType;
|
|
5
|
+
}
|
|
6
|
+
/** Skip's mark beside a line of Skip's or Skip's typing dots. */
|
|
7
|
+
export declare function SkipAvatar({ skipMark }: SkipAvatarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
// An image from require needs its size in style: the web draws it at its own size otherwise.
|
|
4
|
+
export const AVATAR_SIZE = 32;
|
|
5
|
+
/** Skip's mark beside a line of Skip's or Skip's typing dots. */
|
|
6
|
+
export function SkipAvatar({ skipMark }) {
|
|
7
|
+
return (_jsx(Image, { source: skipMark, "aria-hidden": true, style: { width: AVATAR_SIZE, height: AVATAR_SIZE }, className: "rounded-control" }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** primary: the action a row is for. secondary: any other. danger: one that removes something. */
|
|
2
|
+
export type StaffButtonLook = 'primary' | 'secondary' | 'danger';
|
|
3
|
+
export interface StaffButtonProps {
|
|
4
|
+
label: string;
|
|
5
|
+
/** What a screen reader names the button, which holds its label, when the label alone does not say what it is for. */
|
|
6
|
+
name?: string | undefined;
|
|
7
|
+
look?: StaffButtonLook;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Shows only the spinner, the label kept in place unseen so the button keeps its size and name (CURRENT-LOOK, Buttons). */
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
onPress: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The one button of the Skips staff features, on the web dashboard and in the mobile app: brand's button corners, at
|
|
15
|
+
* the compact height. A row of them sits at the end of its note, its main action last. A list of choices stacks them
|
|
16
|
+
* at full width, its label wrapping.
|
|
17
|
+
*/
|
|
18
|
+
export declare function StaffButton({ label, name, look, disabled, loading, onPress }: StaffButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ActivityIndicator, Pressable, Text } from 'react-native';
|
|
3
|
+
import { useColor } from "./parts.js";
|
|
4
|
+
const STAFF_LOOK = {
|
|
5
|
+
primary: { box: 'border border-action bg-action active:bg-action-pressed', text: 'text-action-ink' },
|
|
6
|
+
secondary: { box: 'border border-line-control bg-surface active:bg-muted', text: 'text-ink' },
|
|
7
|
+
danger: { box: 'border border-line-control bg-surface active:bg-muted', text: 'text-error-ink' },
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The one button of the Skips staff features, on the web dashboard and in the mobile app: brand's button corners, at
|
|
11
|
+
* the compact height. A row of them sits at the end of its note, its main action last. A list of choices stacks them
|
|
12
|
+
* at full width, its label wrapping.
|
|
13
|
+
*/
|
|
14
|
+
export function StaffButton({ label, name = label, look = 'secondary', disabled = false, loading = false, onPress }) {
|
|
15
|
+
const ink = useColor(look === 'primary' ? 'action-ink' : 'ink');
|
|
16
|
+
return (_jsxs(Pressable, { role: "button", accessibilityLabel: name, disabled: disabled || loading, "aria-busy": loading, onPress: onPress, className: `min-h-control-compact justify-center rounded-control px-3 py-1.5 ${STAFF_LOOK[look].box} ${disabled ? 'opacity-60' : ''}`, children: [_jsx(Text, { className: `font-ui text-sm font-medium ${STAFF_LOOK[look].text} ${loading ? 'opacity-0' : ''}`, children: label }), loading ? _jsx(ActivityIndicator, { "aria-hidden": true, size: "small", color: ink, className: "absolute inset-0" }) : null] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type ImageSourcePropType } from 'react-native';
|
|
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';
|
|
5
|
+
/** Every word the website's welcome shows, which the website passes in. */
|
|
6
|
+
export interface WelcomeWords {
|
|
7
|
+
logIn: string;
|
|
8
|
+
continueHere: string;
|
|
9
|
+
choiceNotSent: string;
|
|
10
|
+
emailLabel: string;
|
|
11
|
+
emailPlaceholder: string;
|
|
12
|
+
emailSubmit: string;
|
|
13
|
+
emailError: string;
|
|
14
|
+
terms: string;
|
|
15
|
+
changeEmail: string;
|
|
16
|
+
nameLabel: string;
|
|
17
|
+
nameSubmit: string;
|
|
18
|
+
nameError: string;
|
|
19
|
+
codeLabel: string;
|
|
20
|
+
codeSubmit: string;
|
|
21
|
+
resend: string;
|
|
22
|
+
resendWait: string;
|
|
23
|
+
codeNoMatch: string;
|
|
24
|
+
codeRanOut: string;
|
|
25
|
+
typing: string;
|
|
26
|
+
}
|
|
27
|
+
type PillLook = 'solid' | 'stroked' | 'link';
|
|
28
|
+
export interface PillProps {
|
|
29
|
+
label: string;
|
|
30
|
+
look?: PillLook;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
back?: boolean;
|
|
34
|
+
onPress: () => void;
|
|
35
|
+
}
|
|
36
|
+
/** The chat's button: the member sign-in's, as wide as its column, or a link. */
|
|
37
|
+
export declare function Pill({ label, look, disabled, loading, back, onPress, }: PillProps): import("react").JSX.Element;
|
|
38
|
+
export interface WelcomeChoiceProps {
|
|
39
|
+
words: WelcomeWords;
|
|
40
|
+
onLogIn: () => void;
|
|
41
|
+
onContinueHere: () => void;
|
|
42
|
+
}
|
|
43
|
+
/** The choice under Skip's welcome: log in as a member, or go on here as someone new. */
|
|
44
|
+
export declare function WelcomeChoice({ words, onLogIn, onContinueHere, }: WelcomeChoiceProps): import("react").JSX.Element;
|
|
45
|
+
export interface ChoicesProps {
|
|
46
|
+
items: ChoiceItem[];
|
|
47
|
+
question: string;
|
|
48
|
+
sending: string | null;
|
|
49
|
+
holding?: boolean;
|
|
50
|
+
failed: boolean;
|
|
51
|
+
words: WelcomeWords;
|
|
52
|
+
onChoose: (answer: ChoiceItem) => void;
|
|
53
|
+
}
|
|
54
|
+
/** The answers to Skip's question, all drawn alike. One answer only: while one is on its way, none can be pressed. */
|
|
55
|
+
export declare function Choices({ items, question, sending, holding, failed, words, onChoose, }: ChoicesProps): import("react").JSX.Element;
|
|
56
|
+
export interface EmailStepProps {
|
|
57
|
+
words: WelcomeWords;
|
|
58
|
+
field: StepFieldState;
|
|
59
|
+
}
|
|
60
|
+
/** The email asked for after Continue here, and again for a visitor changing it, with the terms they agree to. */
|
|
61
|
+
export declare function EmailStep({ words, field }: EmailStepProps): import("react").JSX.Element;
|
|
62
|
+
export interface NameStepProps {
|
|
63
|
+
words: WelcomeWords;
|
|
64
|
+
field: StepFieldState;
|
|
65
|
+
onChangeEmail: () => void;
|
|
66
|
+
}
|
|
67
|
+
/** The name asked of a visitor the Skips App does not know, with the way back to change a mistyped email. */
|
|
68
|
+
export declare function NameStep({ words, field, onChangeEmail }: NameStepProps): import("react").JSX.Element;
|
|
69
|
+
/** The code emailed to the visitor, in one field that a paste and the phone's own code suggestion fill. */
|
|
70
|
+
export interface CodeStepProps {
|
|
71
|
+
words: WelcomeWords;
|
|
72
|
+
length: number;
|
|
73
|
+
noMatch: boolean;
|
|
74
|
+
ranOut: boolean;
|
|
75
|
+
entry: CodeEntry;
|
|
76
|
+
secondsLeft: number;
|
|
77
|
+
onSubmit: (code: string) => void;
|
|
78
|
+
onResend: () => void;
|
|
79
|
+
onChangeEmail: () => void;
|
|
80
|
+
}
|
|
81
|
+
export declare function CodeStep({ words, length, noMatch, ranOut, entry, secondsLeft, onSubmit, onResend, onChangeEmail, }: CodeStepProps): import("react").JSX.Element;
|
|
82
|
+
export declare const DOT_REST_OPACITY = 0.35;
|
|
83
|
+
export declare const DOT_RISE = 3;
|
|
84
|
+
export declare const DOT_STILL_OPACITY = 0.6;
|
|
85
|
+
/** Skip writing a reply: three dots rising in turn in Skip's bubble beside Skip's mark, announced as a status. */
|
|
86
|
+
export interface SkipTypingProps {
|
|
87
|
+
label: string;
|
|
88
|
+
skipMark: ImageSourcePropType;
|
|
89
|
+
}
|
|
90
|
+
export declare function SkipTyping({ label, skipMark }: SkipTypingProps): import("react").JSX.Element;
|
|
91
|
+
export {};
|