@photonhealth/react 0.0.0-stage → 2.0.0-rc.1
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/LICENSE +15 -0
- package/README.md +84 -2
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/tailwind.d.ts +3 -0
- package/dist/adapters/tailwind.d.ts.map +1 -0
- package/dist/adapters/tailwind.js +123 -0
- package/dist/adapters/tailwind.js.map +1 -0
- package/dist/components/ChangeList.d.ts +21 -0
- package/dist/components/ChangeList.d.ts.map +1 -0
- package/dist/components/ChangeList.js +40 -0
- package/dist/components/ChangeList.js.map +1 -0
- package/dist/components/PhotonOrder.d.ts +46 -0
- package/dist/components/PhotonOrder.d.ts.map +1 -0
- package/dist/components/PhotonOrder.js +270 -0
- package/dist/components/PhotonOrder.js.map +1 -0
- package/dist/components/PhotonPatient.d.ts +48 -0
- package/dist/components/PhotonPatient.d.ts.map +1 -0
- package/dist/components/PhotonPatient.js +83 -0
- package/dist/components/PhotonPatient.js.map +1 -0
- package/dist/components/PhotonPrescription.d.ts +43 -0
- package/dist/components/PhotonPrescription.d.ts.map +1 -0
- package/dist/components/PhotonPrescription.js +364 -0
- package/dist/components/PhotonPrescription.js.map +1 -0
- package/dist/components/ScreeningAlerts.d.ts +6 -0
- package/dist/components/ScreeningAlerts.d.ts.map +1 -0
- package/dist/components/ScreeningAlerts.js +11 -0
- package/dist/components/ScreeningAlerts.js.map +1 -0
- package/dist/components/SignedIn.d.ts +12 -0
- package/dist/components/SignedIn.d.ts.map +1 -0
- package/dist/components/SignedIn.js +84 -0
- package/dist/components/SignedIn.js.map +1 -0
- package/dist/components/TreatmentPicker.d.ts +45 -0
- package/dist/components/TreatmentPicker.d.ts.map +1 -0
- package/dist/components/TreatmentPicker.js +279 -0
- package/dist/components/TreatmentPicker.js.map +1 -0
- package/dist/components/activity.d.ts +7 -0
- package/dist/components/activity.d.ts.map +1 -0
- package/dist/components/activity.js +24 -0
- package/dist/components/activity.js.map +1 -0
- package/dist/components/display.d.ts +90 -0
- package/dist/components/display.d.ts.map +1 -0
- package/dist/components/display.js +223 -0
- package/dist/components/display.js.map +1 -0
- package/dist/components/flow.d.ts +35 -0
- package/dist/components/flow.d.ts.map +1 -0
- package/dist/components/flow.js +53 -0
- package/dist/components/flow.js.map +1 -0
- package/dist/components/format.d.ts +26 -0
- package/dist/components/format.d.ts.map +1 -0
- package/dist/components/format.js +61 -0
- package/dist/components/format.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/open.d.ts +47 -0
- package/dist/components/open.d.ts.map +1 -0
- package/dist/components/open.js +73 -0
- package/dist/components/open.js.map +1 -0
- package/dist/components/patient/Benefits.d.ts +25 -0
- package/dist/components/patient/Benefits.d.ts.map +1 -0
- package/dist/components/patient/Benefits.js +47 -0
- package/dist/components/patient/Benefits.js.map +1 -0
- package/dist/components/patient/Clinical.d.ts +55 -0
- package/dist/components/patient/Clinical.d.ts.map +1 -0
- package/dist/components/patient/Clinical.js +117 -0
- package/dist/components/patient/Clinical.js.map +1 -0
- package/dist/components/patient/IntakeForm.d.ts +10 -0
- package/dist/components/patient/IntakeForm.d.ts.map +1 -0
- package/dist/components/patient/IntakeForm.js +324 -0
- package/dist/components/patient/IntakeForm.js.map +1 -0
- package/dist/components/patient/Summary.d.ts +48 -0
- package/dist/components/patient/Summary.d.ts.map +1 -0
- package/dist/components/patient/Summary.js +80 -0
- package/dist/components/patient/Summary.js.map +1 -0
- package/dist/components/patient/fields.d.ts +43 -0
- package/dist/components/patient/fields.d.ts.map +1 -0
- package/dist/components/patient/fields.js +71 -0
- package/dist/components/patient/fields.js.map +1 -0
- package/dist/components/patient/query.d.ts +23 -0
- package/dist/components/patient/query.d.ts.map +1 -0
- package/dist/components/patient/query.js +65 -0
- package/dist/components/patient/query.js.map +1 -0
- package/dist/components/search.d.ts +154 -0
- package/dist/components/search.d.ts.map +1 -0
- package/dist/components/search.js +295 -0
- package/dist/components/search.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useLatestCallback.d.ts +7 -0
- package/dist/hooks/useLatestCallback.d.ts.map +1 -0
- package/dist/hooks/useLatestCallback.js +14 -0
- package/dist/hooks/useLatestCallback.js.map +1 -0
- package/dist/hooks/useLive.d.ts +15 -0
- package/dist/hooks/useLive.d.ts.map +1 -0
- package/dist/hooks/useLive.js +6 -0
- package/dist/hooks/useLive.js.map +1 -0
- package/dist/hooks/useOnChange.d.ts +11 -0
- package/dist/hooks/useOnChange.d.ts.map +1 -0
- package/dist/hooks/useOnChange.js +28 -0
- package/dist/hooks/useOnChange.js.map +1 -0
- package/dist/hooks/useSession.d.ts +7 -0
- package/dist/hooks/useSession.d.ts.map +1 -0
- package/dist/hooks/useSession.js +10 -0
- package/dist/hooks/useSession.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/primitives/PhotonProvider.d.ts +58 -0
- package/dist/primitives/PhotonProvider.d.ts.map +1 -0
- package/dist/primitives/PhotonProvider.js +91 -0
- package/dist/primitives/PhotonProvider.js.map +1 -0
- package/dist/primitives/defaults.d.ts +3 -0
- package/dist/primitives/defaults.d.ts.map +1 -0
- package/dist/primitives/defaults.js +67 -0
- package/dist/primitives/defaults.js.map +1 -0
- package/dist/primitives/icons.d.ts +6 -0
- package/dist/primitives/icons.d.ts.map +1 -0
- package/dist/primitives/icons.js +6 -0
- package/dist/primitives/icons.js.map +1 -0
- package/dist/primitives/index.d.ts +5 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +5 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/select.d.ts +7 -0
- package/dist/primitives/select.d.ts.map +1 -0
- package/dist/primitives/select.js +16 -0
- package/dist/primitives/select.js.map +1 -0
- package/dist/primitives/types.d.ts +276 -0
- package/dist/primitives/types.d.ts.map +1 -0
- package/dist/primitives/types.js +3 -0
- package/dist/primitives/types.js.map +1 -0
- package/dist/styles.css +611 -0
- package/dist/test-utils/contract.d.ts +17 -0
- package/dist/test-utils/contract.d.ts.map +1 -0
- package/dist/test-utils/contract.js +261 -0
- package/dist/test-utils/contract.js.map +1 -0
- package/package.json +74 -4
- package/src/adapters/index.ts +1 -0
- package/src/adapters/tailwind.tsx +544 -0
- package/src/components/ChangeList.tsx +85 -0
- package/src/components/PhotonOrder.tsx +493 -0
- package/src/components/PhotonPatient.tsx +184 -0
- package/src/components/PhotonPrescription.tsx +605 -0
- package/src/components/ScreeningAlerts.tsx +28 -0
- package/src/components/SignedIn.tsx +144 -0
- package/src/components/TreatmentPicker.tsx +350 -0
- package/src/components/activity.ts +23 -0
- package/src/components/display.ts +278 -0
- package/src/components/flow.ts +67 -0
- package/src/components/format.ts +73 -0
- package/src/components/index.ts +5 -0
- package/src/components/open.ts +100 -0
- package/src/components/patient/Benefits.tsx +125 -0
- package/src/components/patient/Clinical.tsx +210 -0
- package/src/components/patient/IntakeForm.tsx +532 -0
- package/src/components/patient/Summary.tsx +310 -0
- package/src/components/patient/fields.tsx +144 -0
- package/src/components/patient/query.ts +77 -0
- package/src/components/search.tsx +377 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useLatestCallback.ts +16 -0
- package/src/hooks/useLive.ts +21 -0
- package/src/hooks/useOnChange.ts +34 -0
- package/src/hooks/useSession.ts +11 -0
- package/src/index.ts +19 -0
- package/src/primitives/PhotonProvider.tsx +153 -0
- package/src/primitives/defaults.tsx +409 -0
- package/src/primitives/icons.tsx +37 -0
- package/src/primitives/index.ts +4 -0
- package/src/primitives/select.ts +15 -0
- package/src/primitives/types.ts +276 -0
- package/src/styles.css +611 -0
- package/src/test-utils/contract.tsx +410 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Photon Health
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @photonhealth/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Photon's prescribing cards for React: `PhotonOrder`, `PhotonPatient` and `PhotonPrescription`, each bound to a live
|
|
4
|
+
object from [`@photonhealth/client`](https://www.npmjs.com/package/@photonhealth/client), under one
|
|
5
|
+
`PhotonProvider`. The cards render through a small set of building blocks that default to unstyled HTML inheriting
|
|
6
|
+
your page's styles, so they look like the app they're in. They render only cards, with no page chrome, so they fit a
|
|
7
|
+
page, a dialog or a side panel.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Release candidates are published under the `rc` tag:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @photonhealth/react@rc @photonhealth/client@rc react react-dom
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { PhotonOrder, PhotonProvider } from "@photonhealth/react";
|
|
21
|
+
import "@photonhealth/react/styles.css"; // optional: structural styles that inherit the page
|
|
22
|
+
|
|
23
|
+
<PhotonProvider clientId="…" environment="neutron">
|
|
24
|
+
<PhotonOrder patient="pat_…" onSent={() => closeDialog()} />
|
|
25
|
+
</PhotonProvider>;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## PhotonProvider
|
|
29
|
+
|
|
30
|
+
| Prop | What |
|
|
31
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
32
|
+
| `clientId` | The Auth0 client the provider signs the prescriber in with (public). |
|
|
33
|
+
| `environment` | With `clientId`: `neutron` (sandbox) or `photon` (production, the default). |
|
|
34
|
+
| `organization` | Sign in straight to this organization (`org_…`), skipping the organization picker. |
|
|
35
|
+
| `client` | Or your own instance: `photon({ environment, auth: { getToken } })` from `@photonhealth/client`, when you sign in. |
|
|
36
|
+
| `components` | Building blocks mapped to your design system. The rest fall back to the unstyled defaults. |
|
|
37
|
+
| `onAuth` | `({ ok, error }) => void`: whether the API accepted the token (e.g. sign out on `unauthorized`). |
|
|
38
|
+
|
|
39
|
+
On load the provider signs in on its own when it can: it finishes a sign-in coming back from Auth0, or renews a
|
|
40
|
+
stored session. Otherwise the first card shows **Sign in to Photon**. The cards never sign out; your app can, with
|
|
41
|
+
`usePhoton().session.signOut()`. `useSession()` gives your own UI the prescriber's name, email and organization.
|
|
42
|
+
|
|
43
|
+
The access token stays in memory; `localStorage` keeps the refresh token so a reload signs back in. A script on your
|
|
44
|
+
page can read that refresh token, so treat XSS on a page with a provider as a token leak. Auth0's refresh token
|
|
45
|
+
rotation is the guard.
|
|
46
|
+
|
|
47
|
+
## The cards
|
|
48
|
+
|
|
49
|
+
Each record a card takes (`patient`, `prescription`, `order`) is one prop, and can be:
|
|
50
|
+
|
|
51
|
+
| Given | Means |
|
|
52
|
+
| --------------------------------------- | -------------------------------------------------------- |
|
|
53
|
+
| a live object (`Patient`, …) | Used as given, with no fetch |
|
|
54
|
+
| its id: `"pat_…"` or `{ id }` | Read (`get`); changes nothing |
|
|
55
|
+
| its id with fields: `{ id, … }` | That record updated (`update`): only those fields change |
|
|
56
|
+
| fields without an id: `{ demographic }` | Synced (`sync`): the server finds, matches or creates |
|
|
57
|
+
|
|
58
|
+
- **`PhotonOrder`**: who it's for, their prescriptions, and sending them. Props: `order`, `patient`, `fixed`,
|
|
59
|
+
`onPatient`, `onOrder`, `onSent`. Start from a template with
|
|
60
|
+
`order={{ patient: { id }, prescriptions: { add: [{ templateId }] } }}`.
|
|
61
|
+
- **`PhotonPatient`**: find or add a patient, or edit one. Props: `patient`, `locked`, `fixed`, `onPatient`.
|
|
62
|
+
- **`PhotonPrescription`**: one prescription: the drug, sig and dispense, screening, and Sign. Props:
|
|
63
|
+
`prescription`, `patient`, `locked`, `onPrescription`, `onSigned`.
|
|
64
|
+
|
|
65
|
+
Events hand you the live object once the server has saved it. `obj.url()` in any of them is a link back to the work.
|
|
66
|
+
|
|
67
|
+
## Your own design system
|
|
68
|
+
|
|
69
|
+
The cards draw only with building blocks (`PhotonComponents`): Stack, Row, Grid, Text, Card, Button, Input, Select,
|
|
70
|
+
Alert, Badge and so on, each with small, semantic props. Map any of them through `PhotonProvider`'s `components`.
|
|
71
|
+
|
|
72
|
+
- Using Tailwind? `@photonhealth/react/tailwind` maps them to class strings for the default theme.
|
|
73
|
+
- Check your own set against the contract the cards rely on (a Button never submits a surrounding form, Inputs are
|
|
74
|
+
labelled, a critical Alert is announced, …) in a Vitest file, in jsdom with `@testing-library/react`:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
// @vitest-environment jsdom
|
|
78
|
+
import { buildingBlocksContract } from "@photonhealth/react/test-utils/contract";
|
|
79
|
+
|
|
80
|
+
buildingBlocksContract([["mine", myComponents]]);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
ISC
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../src/adapters/tailwind.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,gBAAgB,EAAa,MAAM,wBAAwB,CAAC;AA2EzF,eAAO,MAAM,kBAAkB,EAAE,gBAkdhC,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { Icon } from "../primitives/icons.js";
|
|
4
|
+
import { CHOICE_ACTION } from "../primitives/types.js";
|
|
5
|
+
import { openOnEnter } from "../primitives/select.js";
|
|
6
|
+
/**
|
|
7
|
+
* Stock Tailwind v4 building blocks — default palette only (slate / indigo /
|
|
8
|
+
* status colours), no config, no plugins.
|
|
9
|
+
*
|
|
10
|
+
* import { tailwindComponents } from "@photonhealth/react/tailwind";
|
|
11
|
+
* <PhotonProvider client={ph} components={tailwindComponents}>
|
|
12
|
+
*
|
|
13
|
+
* No dependency on Tailwind: these are just class strings. Point your Tailwind
|
|
14
|
+
* build at them so the classes get generated, e.g. in your CSS:
|
|
15
|
+
* @source "../node_modules/@photonhealth/react/src/adapters";
|
|
16
|
+
*/
|
|
17
|
+
const cx = (...parts) => parts.filter(Boolean).join(" ");
|
|
18
|
+
const gap = { "1": "gap-1", "2": "gap-2", "3": "gap-3", "4": "gap-4", "6": "gap-6" };
|
|
19
|
+
const items = { start: "items-start", center: "items-center", end: "items-end", stretch: "items-stretch" };
|
|
20
|
+
const justify = { start: "justify-start", between: "justify-between", end: "justify-end" };
|
|
21
|
+
const alertTone = {
|
|
22
|
+
neutral: "border-slate-300 bg-slate-50 text-slate-800",
|
|
23
|
+
info: "border-indigo-300 bg-indigo-50 text-indigo-900",
|
|
24
|
+
success: "border-emerald-300 bg-emerald-50 text-emerald-900",
|
|
25
|
+
warning: "border-amber-300 bg-amber-50 text-amber-900",
|
|
26
|
+
critical: "border-red-300 bg-red-50 text-red-900",
|
|
27
|
+
};
|
|
28
|
+
const badgeTone = {
|
|
29
|
+
neutral: "bg-slate-100 text-slate-700 ring-slate-200",
|
|
30
|
+
info: "bg-indigo-50 text-indigo-700 ring-indigo-200",
|
|
31
|
+
success: "bg-emerald-50 text-emerald-700 ring-emerald-200",
|
|
32
|
+
warning: "bg-amber-50 text-amber-800 ring-amber-200",
|
|
33
|
+
critical: "bg-red-50 text-red-700 ring-red-200",
|
|
34
|
+
};
|
|
35
|
+
const buttonVariant = {
|
|
36
|
+
primary: "bg-indigo-600 text-white hover:bg-indigo-500 shadow-sm",
|
|
37
|
+
secondary: "bg-white text-indigo-600 ring-1 ring-inset ring-indigo-600 hover:bg-indigo-50 active:bg-indigo-100",
|
|
38
|
+
ghost: "bg-transparent text-indigo-600 hover:bg-indigo-50 active:bg-indigo-100",
|
|
39
|
+
danger: "bg-red-600 text-white hover:bg-red-500 shadow-sm",
|
|
40
|
+
};
|
|
41
|
+
const buttonSize = { sm: "px-2.5 py-1.5 text-sm", md: "px-3.5 py-2 text-sm", lg: "px-5 py-2.5 text-base" };
|
|
42
|
+
const focus = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";
|
|
43
|
+
const control = "block w-full rounded-md bg-white px-3 py-2 text-slate-900 ring-1 ring-inset ring-slate-300 placeholder:text-slate-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 focus:outline-none disabled:bg-slate-50 disabled:text-slate-500";
|
|
44
|
+
function Field({ label, note, invalid, children, }) {
|
|
45
|
+
const id = useId();
|
|
46
|
+
const noteId = note ? `${id}-note` : undefined;
|
|
47
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [label && (_jsx("label", { htmlFor: id, className: "text-sm font-medium text-slate-900", children: label })), children(id, noteId), _jsx("span", { id: noteId, className: cx("min-h-5 text-sm", invalid ? "text-red-600" : "text-slate-500"), children: note })] }));
|
|
48
|
+
}
|
|
49
|
+
export const tailwindComponents = {
|
|
50
|
+
Stack: ({ gap: g = "4", align = "stretch", children }) => (_jsx("div", { className: cx("flex flex-col", gap[g], items[align]), children: children })),
|
|
51
|
+
Row: ({ gap: g = "3", align = "center", justify: j = "start", children }) => (_jsx("div", { className: cx("flex flex-wrap", gap[g], items[align], justify[j]), children: children })),
|
|
52
|
+
Grid: ({ min = "12rem", gap: g = "4", children }) => (_jsx("div", { className: cx("grid", gap[g]), style: { gridTemplateColumns: `repeat(auto-fit, minmax(min(${min}, 100%), 1fr))` }, children: children })),
|
|
53
|
+
Container: ({ as: As = "div", children }) => (_jsx(As, { className: "mx-auto max-w-[35rem] px-4 py-8 text-slate-900", children: children })),
|
|
54
|
+
PageHeader: ({ title, description }) => (_jsxs("header", { children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight text-slate-900", children: title }), description && _jsx("p", { className: "mt-1 text-sm text-slate-600", children: description })] })),
|
|
55
|
+
Text: ({ tone = "default", children }) => (_jsx("span", { className: tone === "tertiary" ? "text-sm text-slate-500" : tone === "secondary" ? "text-slate-600" : undefined, children: children })),
|
|
56
|
+
Card: ({ divided, children }) => (_jsx("section", { className: cx("rounded-lg bg-white shadow-sm ring-1", "ring-slate-200", divided && "divide-y divide-slate-200"), children: children })),
|
|
57
|
+
CardHeader: ({ title, description, action }) => (_jsxs("div", { className: "flex items-start justify-between gap-4 px-4 py-3", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-base font-semibold text-slate-900", children: title }), description && _jsx("p", { className: "mt-0.5 text-sm text-slate-600", children: description })] }), action && _jsx("div", { className: "shrink-0", children: action })] })),
|
|
58
|
+
CardBody: ({ children }) => _jsx("div", { className: "px-4 py-4", children: children }),
|
|
59
|
+
CardFooter: ({ start, children }) => (_jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2 px-4 py-3", children: [start && _jsx("div", { className: "mr-auto", children: start }), children] })),
|
|
60
|
+
Spinner: ({ label }) => (_jsxs("span", { role: "status", className: "inline-flex items-center gap-2 text-sm text-slate-500", children: [_jsx("span", { "aria-hidden": true, className: "size-4 animate-spin rounded-full border-2 border-slate-300 border-t-indigo-600 motion-reduce:animate-none" }), label] })),
|
|
61
|
+
Button: ({ variant = "primary", size = "md", loading, disabled, className, type = "button", children, icon, tone, ...rest }) => (_jsxs("button", { ...rest, type: type, disabled: disabled || loading, "aria-busy": loading || undefined, className: cx("inline-flex items-center justify-center gap-2 rounded-md font-semibold disabled:cursor-not-allowed disabled:opacity-50", buttonVariant[variant], tone === "critical" && "text-red-600 hover:bg-red-50 active:bg-red-100", icon && !children ? "size-9 p-0" : buttonSize[size], focus, className), children: [loading && (_jsx("span", { className: "size-3 animate-spin rounded-full border-2 border-current border-t-transparent motion-reduce:animate-none", "aria-hidden": true })), icon && !children ? (_jsx(Icon, { name: icon, className: "size-5" })) : (_jsxs(_Fragment, { children: [icon && _jsx(Icon, { name: icon, className: "size-4 shrink-0" }), children] }))] })),
|
|
62
|
+
Input: ({ label, helper, invalid, errorMessage, className, loading, ...rest }) => (_jsx(Field, { label: label, note: invalid && errorMessage ? errorMessage : helper, invalid: invalid, children: (id, noteId) => (_jsxs("span", { className: "relative block", children: [_jsx("input", { ...rest, id: id, "aria-invalid": invalid || undefined, "aria-describedby": noteId, "aria-busy": loading || undefined, className: cx(control, invalid && "ring-red-500", loading && "pr-9", className) }), loading && (_jsx("span", { "aria-hidden": true, className: "absolute top-1/2 right-3 size-4 -translate-y-1/2 animate-spin rounded-full border-2 border-slate-300 border-t-indigo-600 motion-reduce:animate-none" }))] })) })),
|
|
63
|
+
Textarea: ({ label, helper, invalid, errorMessage, className, ...rest }) => (_jsx(Field, { label: label, note: invalid && errorMessage ? errorMessage : helper, invalid: invalid, children: (id, noteId) => (_jsx("textarea", { ...rest, id: id, "aria-invalid": invalid || undefined, "aria-describedby": noteId, className: cx(control, "resize-y", className) })) })),
|
|
64
|
+
Checkbox: ({ label, checked, onChange, disabled }) => (_jsxs("label", { className: "inline-flex items-center gap-2 text-sm text-slate-900", children: [_jsx("input", { type: "checkbox", className: "size-4 rounded border-slate-300 accent-indigo-600", checked: checked, disabled: disabled, onChange: (e) => onChange(e.target.checked) }), label] })),
|
|
65
|
+
// Safari draws a native <select> itself and ignores the ring / padding below (Photon-Health/prescribe#15).
|
|
66
|
+
Select: ({ label, options, value, onChange, placeholder = "Select…", helper, disabled, invalid, errorMessage }) => (_jsx(Field, { label: label, note: invalid && errorMessage ? errorMessage : helper, invalid: invalid, children: (id, noteId) => (_jsxs("select", { id: id, value: value ?? "", disabled: disabled, "aria-invalid": invalid || undefined, "aria-describedby": noteId, onChange: (e) => e.target.value && onChange(e.target.value), onKeyDown: openOnEnter, className: cx(control, "pr-8"), children: [_jsx("option", { value: "", disabled: true, children: placeholder }), options.map((o) => (_jsx("option", { value: o.value, children: o.label }, o.value)))] })) })),
|
|
67
|
+
RadioGroup: ({ label, options, value, onChange, horizontal }) => {
|
|
68
|
+
const name = useId();
|
|
69
|
+
return (_jsxs("fieldset", { children: [_jsx("legend", { className: "text-sm font-medium text-slate-900", children: label }), _jsx("div", { className: cx("mt-2 flex gap-4", horizontal ? "flex-row flex-wrap" : "flex-col"), children: options.map((o) => (_jsxs("label", { className: "inline-flex items-center gap-2 text-sm text-slate-900", children: [_jsx("input", { type: "radio", name: name, className: "size-4 accent-indigo-600", checked: value === o.value, onChange: () => onChange(o.value) }), o.label] }, o.value))) })] }));
|
|
70
|
+
},
|
|
71
|
+
// Rows like OptionList's: separate cards; keyboard focus reads as its selected row (inset indigo ring).
|
|
72
|
+
ChoiceList: ({ label, choices, onChoose, disabled, pendingKey, action, activeKey, id }) => {
|
|
73
|
+
// A field that keeps the cursor drives this list: its rows are options it points at, not buttons.
|
|
74
|
+
const inField = activeKey !== undefined;
|
|
75
|
+
const base = "group flex w-full items-center gap-3 rounded-md px-4 py-3 text-left";
|
|
76
|
+
const choiceRest = "bg-white ring-1 ring-slate-200 ring-inset hover:bg-slate-50 disabled:opacity-50";
|
|
77
|
+
const actionRest = "text-sm font-medium text-indigo-600 hover:bg-slate-50 disabled:opacity-50";
|
|
78
|
+
const lit = "bg-indigo-50 ring-2 ring-indigo-600 ring-inset";
|
|
79
|
+
const focus = "focus-visible:bg-indigo-50 focus-visible:ring-2 focus-visible:ring-indigo-600 focus-visible:ring-inset focus-visible:outline-none";
|
|
80
|
+
const row = (key, active, onPick, body) => {
|
|
81
|
+
const rest = key === CHOICE_ACTION ? actionRest : choiceRest;
|
|
82
|
+
return inField ? (_jsx("li", { id: id ? `${id}-${key}` : undefined, role: "option", "aria-selected": active, "aria-busy": key === pendingKey || undefined, className: `${base} ${rest} cursor-pointer ${active ? lit : ""}`, onClick: disabled ? undefined : onPick, children: body }, key)) : (_jsx("li", { children: _jsx("button", { type: "button", disabled: disabled, "aria-busy": key === pendingKey || undefined, onClick: onPick, className: `${base} ${rest} ${focus} aria-busy:bg-indigo-50 aria-busy:ring-2 aria-busy:ring-indigo-600`, children: body }) }, key));
|
|
83
|
+
};
|
|
84
|
+
const glyph = (active) => (_jsx(Icon, { name: "return", className: `size-4 shrink-0 text-indigo-600 ${active ? "visible" : "invisible group-focus-visible:visible"}` }));
|
|
85
|
+
return (_jsxs("ul", { "aria-label": label, role: inField ? "listbox" : undefined, className: "flex flex-col gap-2", children: [choices.map((c) => row(c.key, c.key === activeKey, () => onChoose(c.key), _jsxs(_Fragment, { children: [_jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("span", { className: "flex flex-wrap items-baseline gap-x-2", children: [_jsx("span", { className: "text-sm text-slate-900", children: c.label }), c.meta && _jsx("span", { className: "text-xs text-slate-500", children: c.meta })] }), c.description && _jsx("span", { className: "text-xs text-slate-500", children: c.description })] }), glyph(c.key === activeKey)] }))), action &&
|
|
86
|
+
row(CHOICE_ACTION, activeKey === CHOICE_ACTION, action.onChoose, _jsxs(_Fragment, { children: [action.icon && _jsx(Icon, { name: action.icon, className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1", children: action.label }), glyph(activeKey === CHOICE_ACTION)] }))] }));
|
|
87
|
+
},
|
|
88
|
+
OptionList: function TailwindOptionList({ label, options, activeKey, activeSelected, onSelect, onKeyDown, disabled, children, }) {
|
|
89
|
+
return (_jsx("div", { tabIndex: 0, "aria-label": label, onKeyDown: onKeyDown, className: "outline-none", children: _jsx("ul", { "aria-label": label, className: "flex flex-col gap-2", children: options.map((o) => {
|
|
90
|
+
const active = o.key === activeKey;
|
|
91
|
+
// Top right: a spinner while its choice is saved, else (a row that opens) the chevron.
|
|
92
|
+
const trailing = o.loading ? (_jsx("span", { "aria-hidden": true, className: "ml-auto size-4 shrink-0 animate-spin rounded-full border-2 border-slate-300 border-t-indigo-600 motion-reduce:animate-none" })) : active || o.direct ? null : (_jsx(Icon, { name: "chevron", className: "ml-auto size-4 shrink-0 self-center text-slate-400" }));
|
|
93
|
+
const row = (_jsxs("span", { className: "flex w-full items-center gap-2.5", children: [_jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: cx("text-sm text-slate-900", active && "font-semibold"), children: o.label }), o.description && _jsx("span", { className: "text-xs text-slate-500", children: o.description })] }), trailing] }));
|
|
94
|
+
return (_jsx("li", { children: active && !o.direct ? (_jsxs("div", { "aria-current": "true", "aria-busy": o.loading || undefined, className: cx("flex flex-col gap-3 rounded-md px-4 pt-3.5 pb-4", activeSelected
|
|
95
|
+
? "bg-indigo-50 ring-2 ring-indigo-600 ring-inset"
|
|
96
|
+
: "bg-white ring-1 ring-slate-200"), children: [row, children] })) : (_jsx("button", { type: "button", disabled: disabled, "aria-label": o.ariaLabel, "aria-current": active || undefined, "aria-busy": o.loading || undefined, onClick: () => onSelect(o.key), className: cx("flex w-full rounded-md px-4 py-3 text-left hover:bg-slate-50 disabled:opacity-50", active && activeSelected
|
|
97
|
+
? "bg-indigo-50 ring-2 ring-indigo-600 ring-inset"
|
|
98
|
+
: "bg-white ring-1 ring-slate-200", focus), children: row })) }, o.key));
|
|
99
|
+
}) }) }));
|
|
100
|
+
},
|
|
101
|
+
ActionBar: ({ children }) => _jsx("div", { className: "flex items-center justify-end gap-4", children: children }),
|
|
102
|
+
// In a narrow container (a phone, a dialog, a side panel) the chips share the row evenly, for thumbs.
|
|
103
|
+
// Chips in a grid of equal columns: every chip the same width, a partial last row too. How many across goes by
|
|
104
|
+
// the longest label (and its detail): short 3 (4 on a wider card), medium 2, longer 1 (2).
|
|
105
|
+
ToggleGroup: function TailwindToggleGroup({ label, options, value, onChange, disabled }) {
|
|
106
|
+
const id = useId();
|
|
107
|
+
const longest = Math.max(0, ...options.map((o) => o.label.length + (o.detail ? o.detail.length + 1 : 0)));
|
|
108
|
+
const columns = longest <= 15 ? "grid-cols-3 @md:grid-cols-4" : longest <= 24 ? "grid-cols-2" : "grid-cols-1 @md:grid-cols-2";
|
|
109
|
+
return (_jsxs("div", { className: "@container flex flex-col gap-2", children: [_jsx("div", { id: id, className: "text-xs font-semibold text-slate-700", children: label }), _jsx("div", { role: "group", "aria-labelledby": id, className: cx("grid gap-2", columns), children: options.map((o) => {
|
|
110
|
+
const selected = o.value === value;
|
|
111
|
+
return (_jsxs("button", { type: "button", "aria-pressed": selected, "aria-label": o.ariaLabel, "data-muted": o.muted || undefined, disabled: disabled, onClick: () => onChange(o.value), className: cx("flex min-w-0 flex-wrap items-baseline justify-center gap-x-1.5 rounded-md px-2 py-2 text-center text-sm disabled:opacity-50", selected
|
|
112
|
+
? "bg-indigo-600 font-semibold text-white hover:bg-indigo-500"
|
|
113
|
+
: "bg-white font-medium text-slate-900 ring-1 ring-slate-300 hover:bg-slate-50", o.muted && !selected && "text-slate-400 ring-slate-200", focus), children: [o.label, o.detail && (_jsx("span", { className: cx("text-xs font-normal", selected ? "text-indigo-100" : "text-slate-500"), children: o.detail }))] }, o.value));
|
|
114
|
+
}) })] }));
|
|
115
|
+
},
|
|
116
|
+
Alert: ({ tone = "info", title, description, onDismiss }) => (_jsxs("div", { role: tone === "warning" || tone === "critical" ? "alert" : "status", className: cx("flex items-start justify-between gap-3 rounded-md border px-4 py-3 text-sm", alertTone[tone]), children: [_jsxs("div", { children: [_jsx("p", { className: "font-semibold", children: title }), description && _jsx("div", { className: "mt-1", children: description })] }), onDismiss && (_jsx("button", { type: "button", onClick: onDismiss, "aria-label": "Dismiss", className: cx("rounded px-1 opacity-70 hover:opacity-100", focus), children: _jsx(Icon, { name: "close", className: "size-3.5" }) }))] })),
|
|
117
|
+
Badge: ({ tone = "neutral", children, icon, onRemove, removeLabel = "Remove" }) => (_jsxs("span", { className: cx("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset", badgeTone[tone]), children: [icon && _jsx(Icon, { name: icon, className: "size-3" }), children, onRemove && (_jsx("button", { type: "button", "aria-label": removeLabel, onClick: onRemove, className: cx("-mr-1 rounded-full px-1 opacity-60 hover:opacity-100", focus), children: _jsx(Icon, { name: "close", className: "size-3.5" }) }))] })),
|
|
118
|
+
Disclosure: ({ summary, open, onOpenChange, children }) => {
|
|
119
|
+
const id = useId();
|
|
120
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": id, onClick: () => onOpenChange(!open), className: cx("flex w-full items-center gap-1.5 rounded-md text-left text-sm text-slate-600 hover:text-slate-900", focus), children: [_jsx(Icon, { name: "chevron", className: cx("size-4 shrink-0 transition-transform motion-reduce:transition-none", open && "rotate-90") }), _jsx("span", { children: summary })] }), open && _jsx("div", { id: id, children: children })] }));
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=tailwind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../src/adapters/tailwind.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAyB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAoC,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;;;;;GAUG;AAEH,MAAM,EAAE,GAAG,CAAC,GAAG,KAA4C,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhG,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,CAAC;AAC9F,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAW,CAAC;AACpH,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,aAAa,EAAW,CAAC;AAEpG,MAAM,SAAS,GAAyB;IACtC,OAAO,EAAE,6CAA6C;IACtD,IAAI,EAAE,gDAAgD;IACtD,OAAO,EAAE,mDAAmD;IAC5D,OAAO,EAAE,6CAA6C;IACtD,QAAQ,EAAE,uCAAuC;CAClD,CAAC;AACF,MAAM,SAAS,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AI,EAAC,QAAQ,gBACD,WAAW,EACvB,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAE,EAAE,CAAC,sDAAsD,EAAE,KAAK,CAAC,YAE5E,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,UAAU,GAAG,GACnC,CACV,IACI,CACR;IACD,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE;QACxD,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;QACnB,OAAO,CACL,eAAK,SAAS,EAAC,qBAAqB,aAClC,kBACE,IAAI,EAAC,QAAQ,mBACE,IAAI,mBACJ,EAAE,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAClC,SAAS,EAAE,EAAE,CACX,mGAAmG,EACnG,KAAK,CACN,aAED,KAAC,IAAI,IACH,IAAI,EAAC,SAAS,EACd,SAAS,EAAE,EAAE,CAAC,oEAAoE,EAAE,IAAI,IAAI,WAAW,CAAC,GACxG,EACF,yBAAO,OAAO,GAAQ,IACf,EACR,IAAI,IAAI,cAAK,EAAE,EAAE,EAAE,YAAG,QAAQ,GAAO,IAClC,CACP,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ChangeOption, ClassifiedChanges } from "@photonhealth/client";
|
|
2
|
+
import { type SearchHandle } from "./search.tsx";
|
|
3
|
+
/**
|
|
4
|
+
* Renders any ChangeSet the same way in every component:
|
|
5
|
+
* needsChoice → the server's options as search results (closest first; onChoose re-sends)
|
|
6
|
+
* blocking → critical, with the server's reason
|
|
7
|
+
* advisories → dismissible info (COST_SAVINGS, PRODUCT_PREFERENCE, …)
|
|
8
|
+
* Applied INFO changes are not shown — they already took effect. `handleRef` reaches the first choice's
|
|
9
|
+
* results — from the field that asked (e.g. Add allergy), so its keys work on them.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ChangeList({ changes, onChoose, busy, handleRef, onBack, }: {
|
|
12
|
+
changes: ClassifiedChanges;
|
|
13
|
+
onChoose?: (option: ChangeOption) => void;
|
|
14
|
+
busy?: boolean;
|
|
15
|
+
handleRef?: {
|
|
16
|
+
current: SearchHandle | null;
|
|
17
|
+
};
|
|
18
|
+
/** Esc in the first choice's results: back to the field that asked. */
|
|
19
|
+
onBack?: () => void;
|
|
20
|
+
}): import("react").JSX.Element | null;
|
|
21
|
+
//# sourceMappingURL=ChangeList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangeList.d.ts","sourceRoot":"","sources":["../../src/components/ChangeList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAGhE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,MAAM,GACP,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7C,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,sCAyDA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useComponents } from "../primitives/index.js";
|
|
3
|
+
import { orderedOptions } from "./display.js";
|
|
4
|
+
import { SearchResults } from "./search.js";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
/**
|
|
7
|
+
* Renders any ChangeSet the same way in every component:
|
|
8
|
+
* needsChoice → the server's options as search results (closest first; onChoose re-sends)
|
|
9
|
+
* blocking → critical, with the server's reason
|
|
10
|
+
* advisories → dismissible info (COST_SAVINGS, PRODUCT_PREFERENCE, …)
|
|
11
|
+
* Applied INFO changes are not shown — they already took effect. `handleRef` reaches the first choice's
|
|
12
|
+
* results — from the field that asked (e.g. Add allergy), so its keys work on them.
|
|
13
|
+
*/
|
|
14
|
+
export function ChangeList({ changes, onChoose, busy, handleRef, onBack, }) {
|
|
15
|
+
const { Alert, Stack } = useComponents();
|
|
16
|
+
const [dismissed, setDismissed] = useState(new Set());
|
|
17
|
+
// The server can report the same problem once per affected field; show it once.
|
|
18
|
+
const unique = (list) => {
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
return list.filter((c) => {
|
|
21
|
+
const id = `${c.label}|${c.reason ?? ""}`;
|
|
22
|
+
return seen.has(id) ? false : (seen.add(id), true);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const needsChoice = unique(changes.needsChoice);
|
|
26
|
+
const blocking = unique(changes.blocking);
|
|
27
|
+
const advisories = unique(changes.advisories).filter((c) => !dismissed.has(c.key));
|
|
28
|
+
if (!needsChoice.length && !blocking.length && !advisories.length)
|
|
29
|
+
return null;
|
|
30
|
+
return (_jsxs(Stack, { gap: "2", children: [needsChoice.map((change, i) => {
|
|
31
|
+
// Only options that say where their pick goes can be sent back.
|
|
32
|
+
const options = orderedOptions({ options: change.options.filter((o) => o.path) }, change.inputText);
|
|
33
|
+
return (_jsx(SearchResults, { label: change.label, busy: busy, disabled: !onChoose, results: options.map((o, j) => ({
|
|
34
|
+
key: String(j),
|
|
35
|
+
label: o.displayName,
|
|
36
|
+
description: o.reason ?? undefined,
|
|
37
|
+
})), onPick: (key) => onChoose?.(options[Number(key)]), handleRef: i === 0 ? handleRef : undefined, onBack: i === 0 ? onBack : undefined }, `${change.key}-${i}`));
|
|
38
|
+
}), blocking.map((change, i) => (_jsx(Alert, { tone: "critical", title: change.label, description: change.reason ?? undefined }, `${change.key}-${i}`))), advisories.map((change) => (_jsx(Alert, { tone: "info", title: change.label, description: change.reason ?? undefined, onDismiss: () => setDismissed((d) => new Set(d).add(change.key)) }, change.key)))] }));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=ChangeList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangeList.js","sourceRoot":"","sources":["../../src/components/ChangeList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAqB,MAAM,aAAc,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,MAAM,GAQP;IACC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAC;IACzC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAc,IAAI,GAAG,EAAE,CAAC,CAAC;IACnE,gFAAgF;IAChF,MAAM,MAAM,GAAG,CAAkE,IAAS,EAAE,EAAE;QAC5F,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YACvB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,MAAM,W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AAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAC1C,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IAX/B,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAYzB,CACH,CAAC;YACJ,CAAC,CAAC,EACD,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3B,KAAC,KAAK,IAEJ,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,WAAW,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS,IAHlC,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAIzB,CACH,CAAC,EACD,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC1B,KAAC,KAAK,IAEJ,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,WAAW,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS,EACvC,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAJ3D,MAAM,CAAC,GAAG,CAKf,CACH,CAAC,IACI,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Order, Patient, type OrderInput, type PatientInput } from "@photonhealth/client";
|
|
2
|
+
import { type Given } from "./open.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The order is the treatment: who it's for, their prescriptions, and sending them — on one card, bound to a
|
|
5
|
+
* live Order from @photonhealth/client: the one given (live, used as given; or opened from what's given, see `Given`),
|
|
6
|
+
* else a new order for the patient given, or for someone to find or add. The rules are the objects'; this renders
|
|
7
|
+
* them, plus what's only about the screen: which line is focused, and the Sent summary. Send shows once the order
|
|
8
|
+
* is ready and everything is saved.
|
|
9
|
+
*
|
|
10
|
+
* It renders only cards: no page, landmark or app chrome, so it sits in a page, a dialog or a side panel.
|
|
11
|
+
*/
|
|
12
|
+
export interface PhotonOrderProps {
|
|
13
|
+
/**
|
|
14
|
+
* The order: a live Order (used as given), its id (`"ord_…"` or `{ id }`: read), its id with fields (that order
|
|
15
|
+
* updated — e.g. prescriptions added), or what's known of one (synced): `{ patient: { id }, prescriptions: {
|
|
16
|
+
* add: [{ templateId: "tmp_…" }, { id: "rx_…" }] } }` — new lines from a template, existing prescriptions (the
|
|
17
|
+
* order takes their patient). Without prescriptions, it starts with one empty line.
|
|
18
|
+
*/
|
|
19
|
+
order?: Order | Given<OrderInput> | null;
|
|
20
|
+
/**
|
|
21
|
+
* Who a new order is for, when `order` doesn't say — given as a patient card's `patient` is. Without one,
|
|
22
|
+
* someone to find or add.
|
|
23
|
+
*/
|
|
24
|
+
patient?: Patient | Given<PatientInput> | null;
|
|
25
|
+
/**
|
|
26
|
+
* The order's patient, once it has a record and each time that record changes from the backend; `null` on
|
|
27
|
+
* "Change patient".
|
|
28
|
+
*/
|
|
29
|
+
onPatient?: (patient: Patient | null) => void;
|
|
30
|
+
/** The order was sent from this card — once per order; e.g. to close the dialog it's in. */
|
|
31
|
+
onSent?: (order: Order) => void;
|
|
32
|
+
/**
|
|
33
|
+
* The order this card shows — given, opened, or the next one (after "Change patient" on a saved draft) — once
|
|
34
|
+
* it, its patient or a prescription has a record, and each time one of those records changes from the
|
|
35
|
+
* backend (a line created or signed, the draft saved, sent). Its ids are what a URL keeps.
|
|
36
|
+
*/
|
|
37
|
+
onOrder?: (order: Order) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The order's patient is fixed: "Change patient" is hidden — e.g. embedded beside the host's own view of that
|
|
40
|
+
* patient. The patient and the prescriptions stay editable. (An order handed in, or with existing
|
|
41
|
+
* prescriptions, is fixed anyway.)
|
|
42
|
+
*/
|
|
43
|
+
fixed?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function PhotonOrder(props: PhotonOrderProps): import("react").JSX.Element;
|
|
46
|
+
//# sourceMappingURL=PhotonOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhotonOrder.d.ts","sourceRoot":"","sources":["../../src/components/PhotonOrder.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,EACL,OAAO,EAGP,KAAK,UAAU,EAEf,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAA4D,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAOjG;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,4FAA4F;IAC5F,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAMlD"}
|