@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.
Files changed (180) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +84 -2
  3. package/dist/adapters/index.d.ts +2 -0
  4. package/dist/adapters/index.d.ts.map +1 -0
  5. package/dist/adapters/index.js +2 -0
  6. package/dist/adapters/index.js.map +1 -0
  7. package/dist/adapters/tailwind.d.ts +3 -0
  8. package/dist/adapters/tailwind.d.ts.map +1 -0
  9. package/dist/adapters/tailwind.js +123 -0
  10. package/dist/adapters/tailwind.js.map +1 -0
  11. package/dist/components/ChangeList.d.ts +21 -0
  12. package/dist/components/ChangeList.d.ts.map +1 -0
  13. package/dist/components/ChangeList.js +40 -0
  14. package/dist/components/ChangeList.js.map +1 -0
  15. package/dist/components/PhotonOrder.d.ts +46 -0
  16. package/dist/components/PhotonOrder.d.ts.map +1 -0
  17. package/dist/components/PhotonOrder.js +270 -0
  18. package/dist/components/PhotonOrder.js.map +1 -0
  19. package/dist/components/PhotonPatient.d.ts +48 -0
  20. package/dist/components/PhotonPatient.d.ts.map +1 -0
  21. package/dist/components/PhotonPatient.js +83 -0
  22. package/dist/components/PhotonPatient.js.map +1 -0
  23. package/dist/components/PhotonPrescription.d.ts +43 -0
  24. package/dist/components/PhotonPrescription.d.ts.map +1 -0
  25. package/dist/components/PhotonPrescription.js +364 -0
  26. package/dist/components/PhotonPrescription.js.map +1 -0
  27. package/dist/components/ScreeningAlerts.d.ts +6 -0
  28. package/dist/components/ScreeningAlerts.d.ts.map +1 -0
  29. package/dist/components/ScreeningAlerts.js +11 -0
  30. package/dist/components/ScreeningAlerts.js.map +1 -0
  31. package/dist/components/SignedIn.d.ts +12 -0
  32. package/dist/components/SignedIn.d.ts.map +1 -0
  33. package/dist/components/SignedIn.js +84 -0
  34. package/dist/components/SignedIn.js.map +1 -0
  35. package/dist/components/TreatmentPicker.d.ts +45 -0
  36. package/dist/components/TreatmentPicker.d.ts.map +1 -0
  37. package/dist/components/TreatmentPicker.js +279 -0
  38. package/dist/components/TreatmentPicker.js.map +1 -0
  39. package/dist/components/activity.d.ts +7 -0
  40. package/dist/components/activity.d.ts.map +1 -0
  41. package/dist/components/activity.js +24 -0
  42. package/dist/components/activity.js.map +1 -0
  43. package/dist/components/display.d.ts +90 -0
  44. package/dist/components/display.d.ts.map +1 -0
  45. package/dist/components/display.js +223 -0
  46. package/dist/components/display.js.map +1 -0
  47. package/dist/components/flow.d.ts +35 -0
  48. package/dist/components/flow.d.ts.map +1 -0
  49. package/dist/components/flow.js +53 -0
  50. package/dist/components/flow.js.map +1 -0
  51. package/dist/components/format.d.ts +26 -0
  52. package/dist/components/format.d.ts.map +1 -0
  53. package/dist/components/format.js +61 -0
  54. package/dist/components/format.js.map +1 -0
  55. package/dist/components/index.d.ts +6 -0
  56. package/dist/components/index.d.ts.map +1 -0
  57. package/dist/components/index.js +6 -0
  58. package/dist/components/index.js.map +1 -0
  59. package/dist/components/open.d.ts +47 -0
  60. package/dist/components/open.d.ts.map +1 -0
  61. package/dist/components/open.js +73 -0
  62. package/dist/components/open.js.map +1 -0
  63. package/dist/components/patient/Benefits.d.ts +25 -0
  64. package/dist/components/patient/Benefits.d.ts.map +1 -0
  65. package/dist/components/patient/Benefits.js +47 -0
  66. package/dist/components/patient/Benefits.js.map +1 -0
  67. package/dist/components/patient/Clinical.d.ts +55 -0
  68. package/dist/components/patient/Clinical.d.ts.map +1 -0
  69. package/dist/components/patient/Clinical.js +117 -0
  70. package/dist/components/patient/Clinical.js.map +1 -0
  71. package/dist/components/patient/IntakeForm.d.ts +10 -0
  72. package/dist/components/patient/IntakeForm.d.ts.map +1 -0
  73. package/dist/components/patient/IntakeForm.js +324 -0
  74. package/dist/components/patient/IntakeForm.js.map +1 -0
  75. package/dist/components/patient/Summary.d.ts +48 -0
  76. package/dist/components/patient/Summary.d.ts.map +1 -0
  77. package/dist/components/patient/Summary.js +80 -0
  78. package/dist/components/patient/Summary.js.map +1 -0
  79. package/dist/components/patient/fields.d.ts +43 -0
  80. package/dist/components/patient/fields.d.ts.map +1 -0
  81. package/dist/components/patient/fields.js +71 -0
  82. package/dist/components/patient/fields.js.map +1 -0
  83. package/dist/components/patient/query.d.ts +23 -0
  84. package/dist/components/patient/query.d.ts.map +1 -0
  85. package/dist/components/patient/query.js +65 -0
  86. package/dist/components/patient/query.js.map +1 -0
  87. package/dist/components/search.d.ts +154 -0
  88. package/dist/components/search.d.ts.map +1 -0
  89. package/dist/components/search.js +295 -0
  90. package/dist/components/search.js.map +1 -0
  91. package/dist/hooks/index.d.ts +5 -0
  92. package/dist/hooks/index.d.ts.map +1 -0
  93. package/dist/hooks/index.js +5 -0
  94. package/dist/hooks/index.js.map +1 -0
  95. package/dist/hooks/useLatestCallback.d.ts +7 -0
  96. package/dist/hooks/useLatestCallback.d.ts.map +1 -0
  97. package/dist/hooks/useLatestCallback.js +14 -0
  98. package/dist/hooks/useLatestCallback.js.map +1 -0
  99. package/dist/hooks/useLive.d.ts +15 -0
  100. package/dist/hooks/useLive.d.ts.map +1 -0
  101. package/dist/hooks/useLive.js +6 -0
  102. package/dist/hooks/useLive.js.map +1 -0
  103. package/dist/hooks/useOnChange.d.ts +11 -0
  104. package/dist/hooks/useOnChange.d.ts.map +1 -0
  105. package/dist/hooks/useOnChange.js +28 -0
  106. package/dist/hooks/useOnChange.js.map +1 -0
  107. package/dist/hooks/useSession.d.ts +7 -0
  108. package/dist/hooks/useSession.d.ts.map +1 -0
  109. package/dist/hooks/useSession.js +10 -0
  110. package/dist/hooks/useSession.js.map +1 -0
  111. package/dist/index.d.ts +20 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +19 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/primitives/PhotonProvider.d.ts +58 -0
  116. package/dist/primitives/PhotonProvider.d.ts.map +1 -0
  117. package/dist/primitives/PhotonProvider.js +91 -0
  118. package/dist/primitives/PhotonProvider.js.map +1 -0
  119. package/dist/primitives/defaults.d.ts +3 -0
  120. package/dist/primitives/defaults.d.ts.map +1 -0
  121. package/dist/primitives/defaults.js +67 -0
  122. package/dist/primitives/defaults.js.map +1 -0
  123. package/dist/primitives/icons.d.ts +6 -0
  124. package/dist/primitives/icons.d.ts.map +1 -0
  125. package/dist/primitives/icons.js +6 -0
  126. package/dist/primitives/icons.js.map +1 -0
  127. package/dist/primitives/index.d.ts +5 -0
  128. package/dist/primitives/index.d.ts.map +1 -0
  129. package/dist/primitives/index.js +5 -0
  130. package/dist/primitives/index.js.map +1 -0
  131. package/dist/primitives/select.d.ts +7 -0
  132. package/dist/primitives/select.d.ts.map +1 -0
  133. package/dist/primitives/select.js +16 -0
  134. package/dist/primitives/select.js.map +1 -0
  135. package/dist/primitives/types.d.ts +276 -0
  136. package/dist/primitives/types.d.ts.map +1 -0
  137. package/dist/primitives/types.js +3 -0
  138. package/dist/primitives/types.js.map +1 -0
  139. package/dist/styles.css +611 -0
  140. package/dist/test-utils/contract.d.ts +17 -0
  141. package/dist/test-utils/contract.d.ts.map +1 -0
  142. package/dist/test-utils/contract.js +261 -0
  143. package/dist/test-utils/contract.js.map +1 -0
  144. package/package.json +74 -4
  145. package/src/adapters/index.ts +1 -0
  146. package/src/adapters/tailwind.tsx +544 -0
  147. package/src/components/ChangeList.tsx +85 -0
  148. package/src/components/PhotonOrder.tsx +493 -0
  149. package/src/components/PhotonPatient.tsx +184 -0
  150. package/src/components/PhotonPrescription.tsx +605 -0
  151. package/src/components/ScreeningAlerts.tsx +28 -0
  152. package/src/components/SignedIn.tsx +144 -0
  153. package/src/components/TreatmentPicker.tsx +350 -0
  154. package/src/components/activity.ts +23 -0
  155. package/src/components/display.ts +278 -0
  156. package/src/components/flow.ts +67 -0
  157. package/src/components/format.ts +73 -0
  158. package/src/components/index.ts +5 -0
  159. package/src/components/open.ts +100 -0
  160. package/src/components/patient/Benefits.tsx +125 -0
  161. package/src/components/patient/Clinical.tsx +210 -0
  162. package/src/components/patient/IntakeForm.tsx +532 -0
  163. package/src/components/patient/Summary.tsx +310 -0
  164. package/src/components/patient/fields.tsx +144 -0
  165. package/src/components/patient/query.ts +77 -0
  166. package/src/components/search.tsx +377 -0
  167. package/src/hooks/index.ts +4 -0
  168. package/src/hooks/useLatestCallback.ts +16 -0
  169. package/src/hooks/useLive.ts +21 -0
  170. package/src/hooks/useOnChange.ts +34 -0
  171. package/src/hooks/useSession.ts +11 -0
  172. package/src/index.ts +19 -0
  173. package/src/primitives/PhotonProvider.tsx +153 -0
  174. package/src/primitives/defaults.tsx +409 -0
  175. package/src/primitives/icons.tsx +37 -0
  176. package/src/primitives/index.ts +4 -0
  177. package/src/primitives/select.ts +15 -0
  178. package/src/primitives/types.ts +276 -0
  179. package/src/styles.css +611 -0
  180. package/src/test-utils/contract.tsx +410 -0
@@ -0,0 +1,409 @@
1
+ import { useId, type ReactNode } from "react";
2
+ import { Icon } from "./icons.tsx";
3
+ import { CHOICE_ACTION, type PhotonComponents } from "./types.ts";
4
+ import { openOnEnter } from "./select.ts";
5
+
6
+ /**
7
+ * Unstyled defaults: plain semantic HTML with stable `prx-*` class names and
8
+ * data attributes. They carry no design of their own — `@photonhealth/react/styles.css`
9
+ * adds only structure (spacing, borders) at zero specificity, in em units, with
10
+ * inherited fonts and colours — so the cards look like whatever page they're in.
11
+ */
12
+
13
+ const cx = (...parts: (string | false | null | undefined)[]) => parts.filter(Boolean).join(" ");
14
+
15
+ function Field({
16
+ label,
17
+ helper,
18
+ invalid,
19
+ errorMessage,
20
+ children,
21
+ }: {
22
+ label?: string;
23
+ helper?: string;
24
+ invalid?: boolean;
25
+ errorMessage?: string;
26
+ children: (ids: { id: string; describedBy?: string }) => ReactNode;
27
+ }) {
28
+ const id = useId();
29
+ const note = invalid && errorMessage ? errorMessage : helper;
30
+ const noteId = note ? `${id}-note` : undefined;
31
+ return (
32
+ <div className="prx-field" data-invalid={invalid || undefined}>
33
+ {label && (
34
+ <label className="prx-label" htmlFor={id}>
35
+ {label}
36
+ </label>
37
+ )}
38
+ {children({ id, describedBy: noteId })}
39
+ <span className="prx-note" id={noteId} role={invalid ? "alert" : undefined}>
40
+ {note}
41
+ </span>
42
+ </div>
43
+ );
44
+ }
45
+
46
+ export const defaultComponents: PhotonComponents = {
47
+ Stack: ({ gap = "4", align = "stretch", children }) => (
48
+ <div className="prx-stack" data-gap={gap} data-align={align}>
49
+ {children}
50
+ </div>
51
+ ),
52
+ Row: ({ gap = "3", align = "center", justify = "start", children }) => (
53
+ <div className="prx-row" data-gap={gap} data-align={align} data-justify={justify}>
54
+ {children}
55
+ </div>
56
+ ),
57
+ Grid: ({ min = "12em", gap = "4", children }) => (
58
+ <div
59
+ className="prx-grid"
60
+ data-gap={gap}
61
+ style={{ gridTemplateColumns: `repeat(auto-fit, minmax(min(${min}, 100%), 1fr))` }}
62
+ >
63
+ {children}
64
+ </div>
65
+ ),
66
+ Container: ({ as: As = "div", children }) => <As className="prx-container">{children}</As>,
67
+ PageHeader: ({ title, description }) => (
68
+ <header className="prx-page-header">
69
+ <h1>{title}</h1>
70
+ {description && <p>{description}</p>}
71
+ </header>
72
+ ),
73
+ Text: ({ tone = "default", children }) => (
74
+ <span className="prx-text" data-tone={tone}>
75
+ {children}
76
+ </span>
77
+ ),
78
+ Card: ({ divided, children }) => (
79
+ <section className="prx-card" data-divided={divided || undefined}>
80
+ {children}
81
+ </section>
82
+ ),
83
+ CardHeader: ({ title, description, action }) => (
84
+ <div className="prx-card-header">
85
+ <div>
86
+ <h2 className="prx-card-title">{title}</h2>
87
+ {description && <p className="prx-card-description">{description}</p>}
88
+ </div>
89
+ {action && <div className="prx-card-action">{action}</div>}
90
+ </div>
91
+ ),
92
+ CardBody: ({ children }) => <div className="prx-card-body">{children}</div>,
93
+ CardFooter: ({ start, children }) => (
94
+ <div className="prx-card-footer">
95
+ {start && <div className="prx-card-footer-start">{start}</div>}
96
+ {children}
97
+ </div>
98
+ ),
99
+ Button: ({
100
+ variant = "primary",
101
+ size = "md",
102
+ loading,
103
+ disabled,
104
+ className,
105
+ children,
106
+ icon,
107
+ tone,
108
+ type = "button",
109
+ ...rest
110
+ }) => (
111
+ <button
112
+ {...rest}
113
+ type={type}
114
+ className={cx("prx-button", className)}
115
+ data-variant={variant}
116
+ data-tone={tone}
117
+ data-size={size}
118
+ data-loading={loading || undefined}
119
+ disabled={disabled || loading}
120
+ aria-busy={loading || undefined}
121
+ data-icon={icon && !children ? "" : undefined}
122
+ >
123
+ {icon && <Icon name={icon} className="prx-icon" />}
124
+ {children}
125
+ </button>
126
+ ),
127
+ Input: ({ label, helper, invalid, errorMessage, className, loading, ...rest }) => (
128
+ <Field label={label} helper={helper} invalid={invalid} errorMessage={errorMessage}>
129
+ {({ id, describedBy }) => (
130
+ <span className="prx-input-wrap">
131
+ <input
132
+ {...rest}
133
+ id={id}
134
+ className={cx("prx-input", className)}
135
+ aria-invalid={invalid || undefined}
136
+ aria-describedby={describedBy}
137
+ aria-busy={loading || undefined}
138
+ />
139
+ {loading && <span className="prx-spinner" aria-hidden="true" />}
140
+ </span>
141
+ )}
142
+ </Field>
143
+ ),
144
+ Textarea: ({ label, helper, invalid, errorMessage, className, ...rest }) => (
145
+ <Field label={label} helper={helper} invalid={invalid} errorMessage={errorMessage}>
146
+ {({ id, describedBy }) => (
147
+ <textarea
148
+ {...rest}
149
+ id={id}
150
+ className={cx("prx-input", className)}
151
+ aria-invalid={invalid || undefined}
152
+ aria-describedby={describedBy}
153
+ />
154
+ )}
155
+ </Field>
156
+ ),
157
+ Checkbox: ({ label, checked, onChange, disabled }) => (
158
+ <label className="prx-check">
159
+ <input type="checkbox" checked={checked} disabled={disabled} onChange={(e) => onChange(e.target.checked)} />
160
+ <span>{label}</span>
161
+ </label>
162
+ ),
163
+ Select: ({ label, options, value, onChange, placeholder = "Select…", helper, disabled, invalid, errorMessage }) => (
164
+ <Field label={label} helper={helper} invalid={invalid} errorMessage={errorMessage}>
165
+ {({ id, describedBy }) => (
166
+ <select
167
+ id={id}
168
+ className="prx-input prx-select"
169
+ value={value ?? ""}
170
+ disabled={disabled}
171
+ aria-invalid={invalid || undefined}
172
+ aria-describedby={describedBy}
173
+ onChange={(e) => e.target.value && onChange(e.target.value as never)}
174
+ onKeyDown={openOnEnter}
175
+ >
176
+ <option value="" disabled>
177
+ {placeholder}
178
+ </option>
179
+ {options.map((o) => (
180
+ <option key={o.value} value={o.value}>
181
+ {o.label}
182
+ </option>
183
+ ))}
184
+ </select>
185
+ )}
186
+ </Field>
187
+ ),
188
+ RadioGroup: ({ label, options, value, onChange, horizontal }) => {
189
+ const name = useId();
190
+ return (
191
+ <fieldset className="prx-radio-group" data-horizontal={horizontal || undefined}>
192
+ <legend className="prx-label">{label}</legend>
193
+ {options.map((o) => (
194
+ <label key={o.value} className="prx-check">
195
+ <input type="radio" name={name} checked={value === o.value} onChange={() => onChange(o.value)} />
196
+ <span>{o.label}</span>
197
+ </label>
198
+ ))}
199
+ </fieldset>
200
+ );
201
+ },
202
+ ChoiceList: ({ label, choices, onChoose, disabled, pendingKey, action, activeKey, id }) => {
203
+ // A field that keeps the cursor drives this list, so its rows are options it points at rather than
204
+ // buttons the keys move between.
205
+ const inField = activeKey !== undefined;
206
+ const row = (key: string, active: boolean, onPick: () => void, body: ReactNode) =>
207
+ inField ? (
208
+ <li
209
+ key={key}
210
+ id={id ? `${id}-${key}` : undefined}
211
+ role="option"
212
+ aria-selected={active}
213
+ aria-busy={key === pendingKey || undefined}
214
+ className={`prx-choice${key === CHOICE_ACTION ? " prx-choice-action" : ""}${active ? " prx-choice-active" : ""}`}
215
+ onClick={disabled ? undefined : onPick}
216
+ >
217
+ {body}
218
+ </li>
219
+ ) : (
220
+ <li key={key}>
221
+ <button
222
+ type="button"
223
+ className={`prx-choice${key === CHOICE_ACTION ? " prx-choice-action" : ""}`}
224
+ disabled={disabled}
225
+ aria-busy={key === pendingKey || undefined}
226
+ onClick={onPick}
227
+ >
228
+ {body}
229
+ </button>
230
+ </li>
231
+ );
232
+ return (
233
+ <ul className="prx-choices" aria-label={label} role={inField ? "listbox" : undefined}>
234
+ {choices.map((c) =>
235
+ row(
236
+ c.key,
237
+ c.key === activeKey,
238
+ () => onChoose(c.key),
239
+ <>
240
+ <span className="prx-choice-text">
241
+ <span className="prx-choice-line">
242
+ <span>{c.label}</span>
243
+ {c.meta && <span className="prx-choice-description">{c.meta}</span>}
244
+ </span>
245
+ {c.description && <span className="prx-choice-description">{c.description}</span>}
246
+ </span>
247
+ <Icon name="return" className="prx-choice-return" />
248
+ </>,
249
+ ),
250
+ )}
251
+ {action &&
252
+ row(
253
+ CHOICE_ACTION,
254
+ activeKey === CHOICE_ACTION,
255
+ action.onChoose,
256
+ <>
257
+ {action.icon && <Icon name={action.icon} className="prx-icon" />}
258
+ <span className="prx-choice-text">{action.label}</span>
259
+ <Icon name="return" className="prx-choice-return" />
260
+ </>,
261
+ )}
262
+ </ul>
263
+ );
264
+ },
265
+ OptionList: ({ label, options, activeKey, activeSelected, onSelect, onKeyDown, disabled, children }) => {
266
+ return (
267
+ <div className="prx-options" tabIndex={0} aria-label={label} onKeyDown={onKeyDown}>
268
+ <ul className="prx-options-list" aria-label={label}>
269
+ {options.map((o) => {
270
+ const text = (
271
+ <span className="prx-option-text">
272
+ <span className="prx-option-label">{o.label}</span>
273
+ {o.description && <span className="prx-choice-description">{o.description}</span>}
274
+ </span>
275
+ );
276
+ const active = o.key === activeKey;
277
+ return (
278
+ <li key={o.key}>
279
+ {active && !o.direct ? (
280
+ <div
281
+ className="prx-option"
282
+ data-active=""
283
+ data-selected={activeSelected || undefined}
284
+ aria-current="true"
285
+ aria-busy={o.loading || undefined}
286
+ >
287
+ <div className="prx-option-row">
288
+ {text}
289
+ {o.loading && <span className="prx-spinner prx-option-chevron" aria-hidden="true" />}
290
+ </div>
291
+ {children}
292
+ </div>
293
+ ) : (
294
+ <button
295
+ type="button"
296
+ className="prx-option"
297
+ data-active={active ? "" : undefined}
298
+ data-selected={(active && activeSelected) || undefined}
299
+ aria-current={active || undefined}
300
+ aria-busy={o.loading || undefined}
301
+ disabled={disabled}
302
+ aria-label={o.ariaLabel}
303
+ onClick={() => onSelect(o.key)}
304
+ >
305
+ <span className="prx-option-row">
306
+ {text}
307
+ {o.loading ? (
308
+ <span className="prx-spinner prx-option-chevron" aria-hidden="true" />
309
+ ) : (
310
+ !o.direct && <Icon name="chevron" className="prx-icon prx-option-chevron" />
311
+ )}
312
+ </span>
313
+ </button>
314
+ )}
315
+ </li>
316
+ );
317
+ })}
318
+ </ul>
319
+ </div>
320
+ );
321
+ },
322
+ ActionBar: ({ children }) => <div className="prx-action-bar">{children}</div>,
323
+ ToggleGroup: ({ label, options, value, onChange, disabled }) => {
324
+ const id = useId();
325
+ return (
326
+ <div className="prx-toggle-group">
327
+ <div className="prx-toggle-label" id={id}>
328
+ <strong>{label}</strong>
329
+ </div>
330
+ <div className="prx-toggles" role="group" aria-labelledby={id}>
331
+ {options.map((o) => (
332
+ <button
333
+ key={o.value}
334
+ type="button"
335
+ className="prx-toggle"
336
+ aria-pressed={o.value === value}
337
+ aria-label={o.ariaLabel}
338
+ data-muted={o.muted || undefined}
339
+ disabled={disabled}
340
+ onClick={() => onChange(o.value)}
341
+ >
342
+ {o.label}
343
+ {o.detail && <span className="prx-choice-description">{o.detail}</span>}
344
+ </button>
345
+ ))}
346
+ </div>
347
+ </div>
348
+ );
349
+ },
350
+ Alert: ({ tone = "info", title, description, onDismiss }) => (
351
+ <div className="prx-alert" data-tone={tone} role={tone === "warning" || tone === "critical" ? "alert" : "status"}>
352
+ <div>
353
+ <strong className="prx-alert-title">{title}</strong>
354
+ {description && <div className="prx-alert-description">{description}</div>}
355
+ </div>
356
+ {onDismiss && (
357
+ <button
358
+ type="button"
359
+ className="prx-button"
360
+ data-variant="ghost"
361
+ data-size="sm"
362
+ onClick={onDismiss}
363
+ aria-label="Dismiss"
364
+ >
365
+ <Icon name="close" className="prx-icon" />
366
+ </button>
367
+ )}
368
+ </div>
369
+ ),
370
+ Badge: ({ tone = "neutral", children, icon, onRemove, removeLabel = "Remove" }) => (
371
+ <span className="prx-badge" data-tone={tone}>
372
+ {icon && <Icon name={icon} className="prx-icon" />}
373
+ {children}
374
+ {onRemove && (
375
+ <button type="button" className="prx-badge-remove" aria-label={removeLabel} onClick={onRemove}>
376
+ <Icon name="close" className="prx-icon" />
377
+ </button>
378
+ )}
379
+ </span>
380
+ ),
381
+ Spinner: ({ label }) => (
382
+ <span className="prx-spinner-status" role="status">
383
+ <span className="prx-spinner" aria-hidden="true" />
384
+ {label}
385
+ </span>
386
+ ),
387
+ Disclosure: ({ summary, open, onOpenChange, children }) => {
388
+ const id = useId();
389
+ return (
390
+ <div className="prx-disclosure" data-open={open || undefined}>
391
+ <button
392
+ type="button"
393
+ className="prx-disclosure-toggle"
394
+ aria-expanded={open}
395
+ aria-controls={id}
396
+ onClick={() => onOpenChange(!open)}
397
+ >
398
+ <Icon name="chevron" className="prx-icon prx-disclosure-chevron" />
399
+ <span>{summary}</span>
400
+ </button>
401
+ {open && (
402
+ <div className="prx-disclosure-body" id={id}>
403
+ {children}
404
+ </div>
405
+ )}
406
+ </div>
407
+ );
408
+ },
409
+ };
@@ -0,0 +1,37 @@
1
+ import type { SVGProps } from "react";
2
+
3
+ /** Minimal line icons for icon-only buttons, removable chips and disclosures. Sized by the caller; colour follows text. */
4
+ export function Icon({
5
+ name,
6
+ ...props
7
+ }: { name: "add" | "close" | "edit" | "trash" | "check" | "chevron" | "return" } & SVGProps<SVGSVGElement>) {
8
+ return (
9
+ <svg
10
+ viewBox="0 0 24 24"
11
+ fill="none"
12
+ stroke="currentColor"
13
+ strokeWidth={2}
14
+ strokeLinecap="round"
15
+ aria-hidden="true"
16
+ {...props}
17
+ >
18
+ {name === "add" ? (
19
+ <path d="M12 5v14M5 12h14" />
20
+ ) : name === "edit" ? (
21
+ <path d="M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4" strokeLinejoin="round" />
22
+ ) : name === "check" ? (
23
+ <path d="M5 12.5l4.5 4.5L19 7.5" strokeLinejoin="round" />
24
+ ) : name === "trash" ? (
25
+ <path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6" strokeLinejoin="round" />
26
+ ) : name === "return" ? (
27
+ // The Return key's own glyph: what pressing it here would take.
28
+ <path d="M20 6v5a3 3 0 0 1-3 3H5m0 0l4-4m-4 4l4 4" strokeLinejoin="round" />
29
+ ) : name === "chevron" ? (
30
+ // Points right (closed); callers rotate it 90° when open.
31
+ <path d="M9 6l6 6-6 6" strokeLinejoin="round" />
32
+ ) : (
33
+ <path d="M6 6l12 12M18 6L6 18" />
34
+ )}
35
+ </svg>
36
+ );
37
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./types.ts";
2
+ export * from "./defaults.tsx";
3
+ export * from "./icons.tsx";
4
+ export * from "./PhotonProvider.tsx";
@@ -0,0 +1,15 @@
1
+ import type { KeyboardEvent } from "react";
2
+
3
+ /**
4
+ * A native <select>'s onKeyDown: Enter opens its list, as ↓ or a click does (browsers open it on Space / Alt+↓
5
+ * only). Where the browser won't show it (no showPicker, or a frame that may not), Enter does nothing.
6
+ */
7
+ export function openOnEnter(e: KeyboardEvent<HTMLSelectElement>) {
8
+ if (e.key !== "Enter" || e.altKey || e.metaKey || e.ctrlKey || e.shiftKey) return;
9
+ e.preventDefault();
10
+ try {
11
+ e.currentTarget.showPicker?.();
12
+ } catch {
13
+ // Not allowed here (e.g. a cross-origin frame): the list still opens with Space / Alt+↓.
14
+ }
15
+ }