@alfadocs/ui-kit 1.1.0 → 1.2.0

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 (68) hide show
  1. package/dist/_chunks/notes-panel-CCz0J140.js +370 -0
  2. package/dist/_chunks/sparkline-DJtZBe7O.js +501 -0
  3. package/dist/agent-catalog.json +27 -1
  4. package/dist/agent-i18n/en.json +4 -2
  5. package/dist/components/notes-panel/index.js +1 -1
  6. package/dist/components/notes-panel/notes-panel.d.ts +45 -2
  7. package/dist/components/sparkline/index.js +1 -1
  8. package/dist/components/sparkline/sparkline.d.ts +24 -0
  9. package/dist/host-compat.css +4 -1
  10. package/dist/i18n/locales/ar.d.ts +2 -0
  11. package/dist/i18n/locales/ar.js +2 -0
  12. package/dist/i18n/locales/de.d.ts +2 -0
  13. package/dist/i18n/locales/de.js +2 -0
  14. package/dist/i18n/locales/el.d.ts +2 -0
  15. package/dist/i18n/locales/el.js +2 -0
  16. package/dist/i18n/locales/en.d.ts +2 -0
  17. package/dist/i18n/locales/en.js +2 -0
  18. package/dist/i18n/locales/es.d.ts +2 -0
  19. package/dist/i18n/locales/es.js +2 -0
  20. package/dist/i18n/locales/fr.d.ts +2 -0
  21. package/dist/i18n/locales/fr.js +2 -0
  22. package/dist/i18n/locales/hi.d.ts +2 -0
  23. package/dist/i18n/locales/hi.js +2 -0
  24. package/dist/i18n/locales/it.d.ts +2 -0
  25. package/dist/i18n/locales/it.js +2 -0
  26. package/dist/i18n/locales/ja.d.ts +2 -0
  27. package/dist/i18n/locales/ja.js +2 -0
  28. package/dist/i18n/locales/nl.d.ts +2 -0
  29. package/dist/i18n/locales/nl.js +2 -0
  30. package/dist/i18n/locales/pl.d.ts +2 -0
  31. package/dist/i18n/locales/pl.js +2 -0
  32. package/dist/i18n/locales/pt.d.ts +2 -0
  33. package/dist/i18n/locales/pt.js +2 -0
  34. package/dist/i18n/locales/ro.d.ts +2 -0
  35. package/dist/i18n/locales/ro.js +2 -0
  36. package/dist/i18n/locales/ru.d.ts +2 -0
  37. package/dist/i18n/locales/ru.js +2 -0
  38. package/dist/i18n/locales/sq.d.ts +2 -0
  39. package/dist/i18n/locales/sq.js +2 -0
  40. package/dist/i18n/locales/sv.d.ts +2 -0
  41. package/dist/i18n/locales/sv.js +2 -0
  42. package/dist/i18n/locales/tr.d.ts +2 -0
  43. package/dist/i18n/locales/tr.js +2 -0
  44. package/dist/i18n/locales/zh.d.ts +2 -0
  45. package/dist/i18n/locales/zh.js +2 -0
  46. package/dist/index.js +2 -2
  47. package/dist/locales/ar.json +2 -0
  48. package/dist/locales/de.json +2 -0
  49. package/dist/locales/el.json +2 -0
  50. package/dist/locales/en.json +2 -0
  51. package/dist/locales/es.json +2 -0
  52. package/dist/locales/fr.json +2 -0
  53. package/dist/locales/hi.json +2 -0
  54. package/dist/locales/it.json +2 -0
  55. package/dist/locales/ja.json +2 -0
  56. package/dist/locales/nl.json +2 -0
  57. package/dist/locales/pl.json +2 -0
  58. package/dist/locales/pt.json +2 -0
  59. package/dist/locales/ro.json +2 -0
  60. package/dist/locales/ru.json +2 -0
  61. package/dist/locales/sq.json +2 -0
  62. package/dist/locales/sv.json +2 -0
  63. package/dist/locales/tr.json +2 -0
  64. package/dist/locales/zh.json +2 -0
  65. package/dist/tokens.css +1 -1
  66. package/package.json +1 -1
  67. package/dist/_chunks/notes-panel-CTcOLLVo.js +0 -324
  68. package/dist/_chunks/sparkline-DLq7xwic.js +0 -394
@@ -0,0 +1,370 @@
1
+ import { jsxs as p, jsx as i } from "react/jsx-runtime";
2
+ import { forwardRef as se, useRef as r, useState as T, useId as oe, useCallback as le, useEffect as ce, useImperativeHandle as de, useMemo as ue } from "react";
3
+ import { c as pe } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as fe } from "react-i18next";
5
+ import { u as me } from "./registry-DvAUVLHh.js";
6
+ import { C as ge } from "./clinical-note-card-D63x_AkK.js";
7
+ import { R as he } from "./rich-text-editor-CfeXPPWs.js";
8
+ import { T as be } from "./text-area-Bt3p7Pt0.js";
9
+ import { B as ve } from "./button-CPGiR_bH.js";
10
+ import { C as ye } from "./checkbox-BuZ1u__2.js";
11
+ import { P as xe } from "./panel-header-D313n_9-.js";
12
+ import { c as Pe } from "./createLucideIcon-DhHxpK9K.js";
13
+ /**
14
+ * @license lucide-react v1.22.0 - ISC
15
+ *
16
+ * This source code is licensed under the ISC license.
17
+ * See the LICENSE file in the root directory of this source tree.
18
+ */
19
+ const ke = [
20
+ ["path", { d: "M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4", key: "re6nr2" }],
21
+ ["path", { d: "M2 6h4", key: "aawbzj" }],
22
+ ["path", { d: "M2 10h4", key: "l0bgd4" }],
23
+ ["path", { d: "M2 14h4", key: "1gsvsf" }],
24
+ ["path", { d: "M2 18h4", key: "1bu2t1" }],
25
+ [
26
+ "path",
27
+ {
28
+ d: "M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",
29
+ key: "pqwjuv"
30
+ }
31
+ ]
32
+ ], Ce = Pe("notebook-pen", ke), Ne = {
33
+ id: "notes-panel",
34
+ // 'submit' backs add_note (compose + commit a note). pin / flag are toggles
35
+ // with no dedicated capability in the closed vocabulary.
36
+ capabilities: ["submit"],
37
+ state: {
38
+ notes: {
39
+ type: "Array<{ id?: string; pinned: boolean; flagged: boolean; clinical: boolean }>",
40
+ descriptionKey: "ui.agent.notesPanel.state.notes",
41
+ description: "Timeline note ids + pinned / flagged / clinical flags. Never the note body or author (both PHI).",
42
+ read: (n) => n.getNotes()
43
+ },
44
+ canAddClinical: {
45
+ type: "boolean",
46
+ descriptionKey: "ui.agent.notesPanel.state.canAddClinical",
47
+ description: "Whether the current user may write clinical notes (the practice_add_clinical_note permission gate).",
48
+ read: (n) => n.canAddClinical()
49
+ },
50
+ currentNoteId: {
51
+ type: "string | null",
52
+ descriptionKey: "ui.agent.notesPanel.state.currentNoteId",
53
+ description: "Id of the note the host has addressed — the one marked, scrolled to and focused. Null when none is. An id only, never note content.",
54
+ read: (n) => n.getCurrentNoteId()
55
+ }
56
+ },
57
+ actions: {
58
+ add_note: {
59
+ // Writes a clinical/admin note body — patient-identifiable content. PHI.
60
+ safety: "phi",
61
+ argsType: "{ content: string; clinical: boolean }",
62
+ argsSchema: {
63
+ type: "object",
64
+ properties: {
65
+ content: {
66
+ type: "string",
67
+ description: "Note body. Rich HTML for the rich composer, else plain text."
68
+ },
69
+ clinical: {
70
+ type: "boolean",
71
+ description: "Whether the note is clinical. Requires the clinical-note permission; the submission is dropped when the gate is closed."
72
+ }
73
+ },
74
+ required: ["content", "clinical"]
75
+ },
76
+ openWorld: !0,
77
+ descriptionKey: "ui.agent.notesPanel.actions.addNote",
78
+ description: "Compose and commit a new note. A clinical note requires the clinical-note permission (read canAddClinical first).",
79
+ examples: [
80
+ {
81
+ args: { content: "Patient reported improvement.", clinical: !0 },
82
+ note: "Add a clinical note."
83
+ }
84
+ ],
85
+ invoke: (n, s) => {
86
+ n.addNote(s);
87
+ }
88
+ },
89
+ toggle_pin: {
90
+ // Re-orders the timeline (pinned notes lead) — reversible view write.
91
+ safety: "write",
92
+ argsType: "{ id: string }",
93
+ argsSchema: {
94
+ type: "object",
95
+ properties: { id: { type: "string" } },
96
+ required: ["id"]
97
+ },
98
+ idempotent: !1,
99
+ descriptionKey: "ui.agent.notesPanel.actions.togglePin",
100
+ description: "Toggle the pinned state of the note with the given id.",
101
+ invoke: (n, s) => {
102
+ n.togglePin(s.id);
103
+ }
104
+ },
105
+ toggle_flag: {
106
+ safety: "write",
107
+ argsType: "{ id: string }",
108
+ argsSchema: {
109
+ type: "object",
110
+ properties: { id: { type: "string" } },
111
+ required: ["id"]
112
+ },
113
+ idempotent: !1,
114
+ descriptionKey: "ui.agent.notesPanel.actions.toggleFlag",
115
+ description: "Toggle the flagged state of the note with the given id.",
116
+ invoke: (n, s) => {
117
+ n.toggleFlag(s.id);
118
+ }
119
+ }
120
+ },
121
+ domHooks: {
122
+ root: {
123
+ attr: "data-component",
124
+ value: "notes-panel",
125
+ description: "Marks the NotesPanel region."
126
+ },
127
+ instanceId: {
128
+ attr: "data-component-id",
129
+ sourceProp: "id",
130
+ description: "Sourced from the id prop. Required to address a specific notes panel from the agent."
131
+ }
132
+ }
133
+ }, we = pe(
134
+ "ds:flex ds:flex-col ds:rounded-[var(--radius-md)] ds:border-s-2 ds:ps-[var(--spacing-sm)]",
135
+ {
136
+ variants: {
137
+ current: {
138
+ true: "ds:border-[color:var(--info)] ds:bg-[color:var(--info)]/10 ds:focus:outline-[length:var(--focus-ring-width)] ds:focus:outline-solid ds:focus:outline-[color:var(--ring)] ds:focus:outline-offset-[length:var(--focus-ring-offset)]",
139
+ false: "ds:border-transparent"
140
+ }
141
+ },
142
+ defaultVariants: { current: !1 }
143
+ }
144
+ );
145
+ function z(n) {
146
+ return n ? /<img\b/i.test(n) ? !0 : n.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").trim().length > 0 : !1;
147
+ }
148
+ const Se = se(
149
+ function({
150
+ id: s,
151
+ notes: x,
152
+ onAddNote: l,
153
+ currentNoteId: c,
154
+ currentNoteKey: S,
155
+ composer: f = "rich",
156
+ editorToolbar: L = "standard",
157
+ redactor: B,
158
+ imageUploadUrl: W,
159
+ showClinicalToggle: I = !0,
160
+ canAddClinicalNote: m = !0,
161
+ clinicalGatedReason: E,
162
+ defaultClinical: P = !1,
163
+ onRequestAiDraft: D,
164
+ aiDraftFormat: G,
165
+ aiPrivacyNotice: Y,
166
+ onDictate: F,
167
+ onProofread: J,
168
+ onAutoFormat: O,
169
+ onTogglePin: g,
170
+ onToggleFlag: h,
171
+ title: Q,
172
+ composerPlaceholder: U,
173
+ addNoteLabel: X,
174
+ emptyState: Z,
175
+ className: $,
176
+ "aria-label": k,
177
+ ...ee
178
+ }, te) {
179
+ const { t: o } = fe(), C = r(null), [d, N] = T(""), [b, j] = T(P), ne = Q ?? o("notesPanel.title", { defaultValue: "Notes" }), V = oe(), M = U ?? o("notesPanel.placeholder", { defaultValue: "Add a note…" }), H = o("notesPanel.composerLabel", {
180
+ defaultValue: "New note"
181
+ }), ae = f === "rich" ? z(d) : d.trim().length > 0, ie = le(() => {
182
+ var e, t;
183
+ if (l) {
184
+ if (f === "rich") {
185
+ const a = ((e = C.current) == null ? void 0 : e.getHTML()) ?? d;
186
+ if (!z(a)) return;
187
+ l({ content: a, clinical: b }), (t = C.current) == null || t.clear();
188
+ } else {
189
+ const a = d.trim();
190
+ if (!a) return;
191
+ l({ content: a, clinical: b });
192
+ }
193
+ N(""), j(P);
194
+ }
195
+ }, [f, d, b, P, l]), _ = [...x].sort(
196
+ (e, t) => Number(t.pinned ?? !1) - Number(e.pinned ?? !1)
197
+ ), w = r(null);
198
+ ce(() => {
199
+ var e, t;
200
+ c && ((e = w.current) == null || e.scrollIntoView({ block: "center" }), (t = w.current) == null || t.focus());
201
+ }, [c, S]);
202
+ const q = r(x);
203
+ q.current = x;
204
+ const u = r(l);
205
+ u.current = l;
206
+ const v = r(g);
207
+ v.current = g;
208
+ const y = r(h);
209
+ y.current = h;
210
+ const R = r(m);
211
+ R.current = m;
212
+ const A = r(c);
213
+ A.current = c;
214
+ const K = r(null);
215
+ de(te, () => K.current, []);
216
+ const re = ue(
217
+ () => ({
218
+ // Ids + flags only — never the note body or author (both PHI).
219
+ getNotes: () => q.current.map((e) => ({
220
+ id: e.id,
221
+ pinned: !!e.pinned,
222
+ flagged: !!e.flagged,
223
+ clinical: !!e.clinical
224
+ })),
225
+ canAddNote: () => !!u.current,
226
+ canAddClinical: () => R.current,
227
+ getCurrentNoteId: () => A.current ?? null,
228
+ addNote: (e) => {
229
+ var t;
230
+ e.clinical && !R.current || (t = u.current) == null || t.call(u, e);
231
+ },
232
+ togglePin: (e) => {
233
+ var t;
234
+ return (t = v.current) == null ? void 0 : t.call(v, e);
235
+ },
236
+ toggleFlag: (e) => {
237
+ var t;
238
+ return (t = y.current) == null ? void 0 : t.call(y, e);
239
+ }
240
+ }),
241
+ []
242
+ );
243
+ return me(Ne, re, s), /* @__PURE__ */ p(
244
+ "section",
245
+ {
246
+ ref: K,
247
+ "data-component": "notes-panel",
248
+ "data-component-id": s,
249
+ "aria-labelledby": k ? void 0 : V,
250
+ "aria-label": k,
251
+ className: ["ds:flex ds:flex-col", $].filter(Boolean).join(" "),
252
+ ...ee,
253
+ children: [
254
+ /* @__PURE__ */ i(
255
+ xe,
256
+ {
257
+ title: ne,
258
+ icon: /* @__PURE__ */ i(Ce, { "aria-hidden": "true" }),
259
+ headingId: k ? void 0 : V,
260
+ sticky: !0,
261
+ divider: !0
262
+ }
263
+ ),
264
+ /* @__PURE__ */ p("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
265
+ l ? /* @__PURE__ */ p("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
266
+ f === "rich" ? /* @__PURE__ */ i(
267
+ he,
268
+ {
269
+ ref: C,
270
+ ariaLabel: H,
271
+ placeholder: M,
272
+ toolbar: L,
273
+ minHeight: "sm",
274
+ redactor: B,
275
+ imageUploadUrl: W,
276
+ onChange: ({ html: e }) => N(e),
277
+ onRequestAiDraft: D,
278
+ aiDraftFormat: G,
279
+ aiPrivacyNotice: Y,
280
+ onDictate: F,
281
+ onProofread: J,
282
+ onAutoFormat: O
283
+ }
284
+ ) : /* @__PURE__ */ i(
285
+ be,
286
+ {
287
+ value: d,
288
+ onChange: (e) => N(e.target.value),
289
+ placeholder: M,
290
+ autoResize: !0,
291
+ minRows: 2,
292
+ maxRows: 6,
293
+ "aria-label": H
294
+ }
295
+ ),
296
+ /* @__PURE__ */ p(
297
+ "div",
298
+ {
299
+ className: [
300
+ "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]",
301
+ I ? "ds:justify-between" : "ds:justify-end"
302
+ ].join(" "),
303
+ children: [
304
+ I ? /* @__PURE__ */ i(
305
+ ye,
306
+ {
307
+ size: "sm",
308
+ label: o("notesPanel.clinicalToggle", {
309
+ defaultValue: "Clinical note"
310
+ }),
311
+ checked: b,
312
+ onCheckedChange: (e) => j(e === !0),
313
+ disabled: !m,
314
+ disabledReason: m ? void 0 : E ?? o("notesPanel.clinicalGated", {
315
+ defaultValue: "You do not have permission to write clinical notes."
316
+ })
317
+ }
318
+ ) : null,
319
+ /* @__PURE__ */ i(
320
+ ve,
321
+ {
322
+ type: "button",
323
+ size: "sm",
324
+ onClick: ie,
325
+ disabled: !ae,
326
+ children: X ?? o("notesPanel.add", { defaultValue: "Add note" })
327
+ }
328
+ )
329
+ ]
330
+ }
331
+ )
332
+ ] }) : null,
333
+ _.length > 0 ? /* @__PURE__ */ i("ul", { className: "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-sm)] ds:p-0", children: _.map((e, t) => {
334
+ const a = c != null && e.id === c;
335
+ return /* @__PURE__ */ p(
336
+ "li",
337
+ {
338
+ ref: a ? w : void 0,
339
+ tabIndex: a ? -1 : void 0,
340
+ "aria-current": a ? "true" : void 0,
341
+ className: we({ current: a }),
342
+ children: [
343
+ a ? /* @__PURE__ */ i("span", { className: "ds:sr-only", children: o("notesPanel.current", {
344
+ defaultValue: "Current note"
345
+ }) }) : null,
346
+ /* @__PURE__ */ i(
347
+ ge,
348
+ {
349
+ surface: "elevated",
350
+ truncate: !a,
351
+ ...e,
352
+ onTogglePin: g && e.id ? () => g(e.id) : void 0,
353
+ onToggleFlag: h && e.id ? () => h(e.id) : void 0
354
+ }
355
+ )
356
+ ]
357
+ },
358
+ e.id ?? t
359
+ );
360
+ }) }) : Z ?? /* @__PURE__ */ i("p", { className: "ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]", children: o("notesPanel.empty", { defaultValue: "No notes yet." }) })
361
+ ] })
362
+ ]
363
+ }
364
+ );
365
+ }
366
+ );
367
+ export {
368
+ Se as N
369
+ };
370
+ //# sourceMappingURL=notes-panel-CCz0J140.js.map