@alfadocs/ui-kit 1.0.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 (137) hide show
  1. package/dist/_chunks/{actions-cell-renderer-DaL80uqL.js → actions-cell-renderer-ClGCSQnA.js} +600 -565
  2. package/dist/_chunks/{ai-consent-banner-BXD7W6FI.js → ai-consent-banner-DKgFfSzc.js} +2 -2
  3. package/dist/_chunks/{alert-Cxaqd-QO.js → alert-DS22ha1n.js} +103 -98
  4. package/dist/_chunks/{annotation-marker-qt5R9WZX.js → annotation-marker-CsUJGZjQ.js} +7 -5
  5. package/dist/_chunks/{audio-recorder-BjnB7V8n.js → audio-recorder-sRsGS-0V.js} +2 -2
  6. package/dist/_chunks/{booking-DSOK-bnR.js → booking-D8fCzcUd.js} +2 -2
  7. package/dist/_chunks/{care-plan-card-BrwhyIJI.js → care-plan-card-DjjVnBYz.js} +2 -2
  8. package/dist/_chunks/{care-plan-entry-card-DWEdCQM3.js → care-plan-entry-card-BVhpvd-P.js} +2 -2
  9. package/dist/_chunks/{collapsible-BrnRiCC6.js → collapsible-CGL9ontS.js} +65 -61
  10. package/dist/_chunks/{document-preview-DXsCEj4U.js → document-preview-DAczwybt.js} +2 -2
  11. package/dist/_chunks/{document-scanner-cS_ispQs.js → document-scanner-BRYIc3A-.js} +2 -2
  12. package/dist/_chunks/{entity-summary-BILN4wEG.js → entity-summary-BS6n7Iah.js} +2 -2
  13. package/dist/_chunks/{face-scheme-CjQAHvSP.js → face-scheme-Cou2efl7.js} +2 -2
  14. package/dist/_chunks/{file-manager-B9LZzT5E.js → file-manager-CNSLiuLo.js} +2 -2
  15. package/dist/_chunks/{freemium-paywall-Dr2342_S.js → freemium-paywall-DsT7MaLd.js} +2 -2
  16. package/dist/_chunks/link-cell-renderer-_DlEZHLI.js +772 -0
  17. package/dist/_chunks/{marketplace-app-shell-pCHBp8bo.js → marketplace-app-shell-DQC9Gpm0.js} +2 -2
  18. package/dist/_chunks/{muscle-scheme-kgCX5qfO.js → muscle-scheme-yfzP_xoJ.js} +2 -2
  19. package/dist/_chunks/notes-panel-CCz0J140.js +370 -0
  20. package/dist/_chunks/{patient-details-UmNcxL0c.js → patient-details-l7pnsUq9.js} +2 -2
  21. package/dist/_chunks/{patient-search-vtRTSdf6.js → patient-search-H54Utav2.js} +2 -2
  22. package/dist/_chunks/{patient-table-QEVsFvwq.js → patient-table-DXk0wW8Q.js} +243 -239
  23. package/dist/_chunks/payment-automation-upsell-C4LIw1iQ.js +305 -0
  24. package/dist/_chunks/{payment-form-BoGxEmGn.js → payment-form-CyKT20xZ.js} +2 -2
  25. package/dist/_chunks/{payment-request-card-CygO1anM.js → payment-request-card-CN30J6yM.js} +107 -138
  26. package/dist/_chunks/{pdf-viewer-CcOuR2wj.js → pdf-viewer-DHg8SfUI.js} +2 -2
  27. package/dist/_chunks/{practice-results-yKbwIxqa.js → practice-results-qvJRkvLn.js} +2 -2
  28. package/dist/_chunks/receipt-euro-C6k4Gzhr.js +36 -0
  29. package/dist/_chunks/{reviews-panel-DmOjvmyH.js → reviews-panel-BfUJhx3m.js} +2 -2
  30. package/dist/_chunks/{sign-document-cH9CboWB.js → sign-document-D70TEUw9.js} +2 -2
  31. package/dist/_chunks/{signature-request-BzXTV_RH.js → signature-request-BlNCXpRN.js} +2 -2
  32. package/dist/_chunks/sparkline-DJtZBe7O.js +501 -0
  33. package/dist/_chunks/{warning-stack-DKeAfj5M.js → warning-stack-IVf0oxh2.js} +2 -2
  34. package/dist/_chunks/{workflow-map-SIfAhmWz.js → workflow-map-ByyBYj6Y.js} +2 -2
  35. package/dist/agent-catalog.json +237 -7
  36. package/dist/agent-i18n/en.json +17 -5
  37. package/dist/components/ai-consent-banner/index.js +1 -1
  38. package/dist/components/alert/alert.d.ts +20 -0
  39. package/dist/components/alert/index.d.ts +1 -1
  40. package/dist/components/alert/index.js +1 -1
  41. package/dist/components/annotation-marker/index.js +1 -1
  42. package/dist/components/audio-recorder/index.js +1 -1
  43. package/dist/components/booking/index.js +1 -1
  44. package/dist/components/care-plan-card/index.js +1 -1
  45. package/dist/components/care-plan-entry-card/index.js +1 -1
  46. package/dist/components/collapsible/index.js +1 -1
  47. package/dist/components/data-table/filters/select-filter.d.ts +6 -0
  48. package/dist/components/data-table/hooks/use-presentational-aria-fix.d.ts +19 -0
  49. package/dist/components/data-table/index.js +2 -2
  50. package/dist/components/document-preview/index.js +1 -1
  51. package/dist/components/document-scanner/index.js +1 -1
  52. package/dist/components/entity-summary/index.js +1 -1
  53. package/dist/components/face-scheme/index.js +1 -1
  54. package/dist/components/file-manager/index.js +1 -1
  55. package/dist/components/freemium-paywall/index.js +1 -1
  56. package/dist/components/muscle-scheme/index.js +1 -1
  57. package/dist/components/notes-panel/index.js +1 -1
  58. package/dist/components/notes-panel/notes-panel.d.ts +45 -2
  59. package/dist/components/patient-details/index.js +1 -1
  60. package/dist/components/patient-search/index.js +1 -1
  61. package/dist/components/patient-table/index.js +1 -1
  62. package/dist/components/payment-card/index.js +1 -1
  63. package/dist/components/payment-form/index.js +1 -1
  64. package/dist/components/pdf-viewer/index.js +1 -1
  65. package/dist/components/practice-results/index.js +1 -1
  66. package/dist/components/reviews-panel/index.js +1 -1
  67. package/dist/components/sign-document/index.js +1 -1
  68. package/dist/components/skeleton-scheme/index.js +1 -1
  69. package/dist/components/sparkline/index.d.ts +1 -1
  70. package/dist/components/sparkline/index.js +1 -1
  71. package/dist/components/sparkline/sparkline.d.ts +60 -3
  72. package/dist/components/warning-stack/index.js +1 -1
  73. package/dist/components/workflow/index.js +1 -1
  74. package/dist/host-compat.css +13 -1
  75. package/dist/i18n/locales/ar.d.ts +3 -0
  76. package/dist/i18n/locales/ar.js +3 -0
  77. package/dist/i18n/locales/de.d.ts +3 -0
  78. package/dist/i18n/locales/de.js +3 -0
  79. package/dist/i18n/locales/el.d.ts +3 -0
  80. package/dist/i18n/locales/el.js +3 -0
  81. package/dist/i18n/locales/en.d.ts +3 -0
  82. package/dist/i18n/locales/en.js +3 -0
  83. package/dist/i18n/locales/es.d.ts +3 -0
  84. package/dist/i18n/locales/es.js +3 -0
  85. package/dist/i18n/locales/fr.d.ts +3 -0
  86. package/dist/i18n/locales/fr.js +3 -0
  87. package/dist/i18n/locales/hi.d.ts +3 -0
  88. package/dist/i18n/locales/hi.js +3 -0
  89. package/dist/i18n/locales/it.d.ts +3 -0
  90. package/dist/i18n/locales/it.js +3 -0
  91. package/dist/i18n/locales/ja.d.ts +3 -0
  92. package/dist/i18n/locales/ja.js +3 -0
  93. package/dist/i18n/locales/nl.d.ts +3 -0
  94. package/dist/i18n/locales/nl.js +3 -0
  95. package/dist/i18n/locales/pl.d.ts +3 -0
  96. package/dist/i18n/locales/pl.js +3 -0
  97. package/dist/i18n/locales/pt.d.ts +3 -0
  98. package/dist/i18n/locales/pt.js +3 -0
  99. package/dist/i18n/locales/ro.d.ts +3 -0
  100. package/dist/i18n/locales/ro.js +3 -0
  101. package/dist/i18n/locales/ru.d.ts +3 -0
  102. package/dist/i18n/locales/ru.js +3 -0
  103. package/dist/i18n/locales/sq.d.ts +3 -0
  104. package/dist/i18n/locales/sq.js +3 -0
  105. package/dist/i18n/locales/sv.d.ts +3 -0
  106. package/dist/i18n/locales/sv.js +3 -0
  107. package/dist/i18n/locales/tr.d.ts +3 -0
  108. package/dist/i18n/locales/tr.js +3 -0
  109. package/dist/i18n/locales/zh.d.ts +3 -0
  110. package/dist/i18n/locales/zh.js +3 -0
  111. package/dist/index.js +974 -1268
  112. package/dist/locales/ar.json +3 -0
  113. package/dist/locales/de.json +3 -0
  114. package/dist/locales/el.json +3 -0
  115. package/dist/locales/en.json +3 -0
  116. package/dist/locales/es.json +3 -0
  117. package/dist/locales/fr.json +3 -0
  118. package/dist/locales/hi.json +3 -0
  119. package/dist/locales/it.json +3 -0
  120. package/dist/locales/ja.json +3 -0
  121. package/dist/locales/nl.json +3 -0
  122. package/dist/locales/pl.json +3 -0
  123. package/dist/locales/pt.json +3 -0
  124. package/dist/locales/ro.json +3 -0
  125. package/dist/locales/ru.json +3 -0
  126. package/dist/locales/sq.json +3 -0
  127. package/dist/locales/sv.json +3 -0
  128. package/dist/locales/tr.json +3 -0
  129. package/dist/locales/zh.json +3 -0
  130. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  131. package/dist/patterns/payment-automation-upsell/index.js +5 -0
  132. package/dist/patterns/signature-request/index.js +1 -1
  133. package/dist/tokens.css +1 -1
  134. package/package.json +5 -1
  135. package/dist/_chunks/link-cell-renderer-Bt-mXeQY.js +0 -728
  136. package/dist/_chunks/notes-panel-CTcOLLVo.js +0 -324
  137. package/dist/_chunks/sparkline-DcXqRZoq.js +0 -283
@@ -1,324 +0,0 @@
1
- import { jsxs as y, jsx as i } from "react/jsx-runtime";
2
- import { forwardRef as ne, useRef as o, useState as V, useId as ie, useCallback as ae, useImperativeHandle as re, useMemo as se } from "react";
3
- import { useTranslation as oe } from "react-i18next";
4
- import { u as le } from "./registry-DvAUVLHh.js";
5
- import { C as ce } from "./clinical-note-card-D63x_AkK.js";
6
- import { R as de } from "./rich-text-editor-CfeXPPWs.js";
7
- import { T as pe } from "./text-area-Bt3p7Pt0.js";
8
- import { B as ue } from "./button-CPGiR_bH.js";
9
- import { C as me } from "./checkbox-BuZ1u__2.js";
10
- import { P as ge } from "./panel-header-D313n_9-.js";
11
- import { c as he } from "./createLucideIcon-DhHxpK9K.js";
12
- /**
13
- * @license lucide-react v1.22.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */
18
- const fe = [
19
- ["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" }],
20
- ["path", { d: "M2 6h4", key: "aawbzj" }],
21
- ["path", { d: "M2 10h4", key: "l0bgd4" }],
22
- ["path", { d: "M2 14h4", key: "1gsvsf" }],
23
- ["path", { d: "M2 18h4", key: "1bu2t1" }],
24
- [
25
- "path",
26
- {
27
- 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",
28
- key: "pqwjuv"
29
- }
30
- ]
31
- ], be = he("notebook-pen", fe), ye = {
32
- id: "notes-panel",
33
- // 'submit' backs add_note (compose + commit a note). pin / flag are toggles
34
- // with no dedicated capability in the closed vocabulary.
35
- capabilities: ["submit"],
36
- state: {
37
- notes: {
38
- type: "Array<{ id?: string; pinned: boolean; flagged: boolean; clinical: boolean }>",
39
- descriptionKey: "ui.agent.notesPanel.state.notes",
40
- description: "Timeline note ids + pinned / flagged / clinical flags. Never the note body or author (both PHI).",
41
- read: (n) => n.getNotes()
42
- },
43
- canAddClinical: {
44
- type: "boolean",
45
- descriptionKey: "ui.agent.notesPanel.state.canAddClinical",
46
- description: "Whether the current user may write clinical notes (the practice_add_clinical_note permission gate).",
47
- read: (n) => n.canAddClinical()
48
- }
49
- },
50
- actions: {
51
- add_note: {
52
- // Writes a clinical/admin note body — patient-identifiable content. PHI.
53
- safety: "phi",
54
- argsType: "{ content: string; clinical: boolean }",
55
- argsSchema: {
56
- type: "object",
57
- properties: {
58
- content: {
59
- type: "string",
60
- description: "Note body. Rich HTML for the rich composer, else plain text."
61
- },
62
- clinical: {
63
- type: "boolean",
64
- description: "Whether the note is clinical. Requires the clinical-note permission; the submission is dropped when the gate is closed."
65
- }
66
- },
67
- required: ["content", "clinical"]
68
- },
69
- openWorld: !0,
70
- descriptionKey: "ui.agent.notesPanel.actions.addNote",
71
- description: "Compose and commit a new note. A clinical note requires the clinical-note permission (read canAddClinical first).",
72
- examples: [
73
- {
74
- args: { content: "Patient reported improvement.", clinical: !0 },
75
- note: "Add a clinical note."
76
- }
77
- ],
78
- invoke: (n, a) => {
79
- n.addNote(a);
80
- }
81
- },
82
- toggle_pin: {
83
- // Re-orders the timeline (pinned notes lead) — reversible view write.
84
- safety: "write",
85
- argsType: "{ id: string }",
86
- argsSchema: {
87
- type: "object",
88
- properties: { id: { type: "string" } },
89
- required: ["id"]
90
- },
91
- idempotent: !1,
92
- descriptionKey: "ui.agent.notesPanel.actions.togglePin",
93
- description: "Toggle the pinned state of the note with the given id.",
94
- invoke: (n, a) => {
95
- n.togglePin(a.id);
96
- }
97
- },
98
- toggle_flag: {
99
- safety: "write",
100
- argsType: "{ id: string }",
101
- argsSchema: {
102
- type: "object",
103
- properties: { id: { type: "string" } },
104
- required: ["id"]
105
- },
106
- idempotent: !1,
107
- descriptionKey: "ui.agent.notesPanel.actions.toggleFlag",
108
- description: "Toggle the flagged state of the note with the given id.",
109
- invoke: (n, a) => {
110
- n.toggleFlag(a.id);
111
- }
112
- }
113
- },
114
- domHooks: {
115
- root: {
116
- attr: "data-component",
117
- value: "notes-panel",
118
- description: "Marks the NotesPanel region."
119
- },
120
- instanceId: {
121
- attr: "data-component-id",
122
- sourceProp: "id",
123
- description: "Sourced from the id prop. Required to address a specific notes panel from the agent."
124
- }
125
- }
126
- };
127
- function T(n) {
128
- return n ? /<img\b/i.test(n) ? !0 : n.replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").trim().length > 0 : !1;
129
- }
130
- const _e = ne(
131
- function({
132
- id: a,
133
- notes: v,
134
- onAddNote: r,
135
- composer: p = "rich",
136
- editorToolbar: z = "standard",
137
- redactor: A,
138
- imageUploadUrl: K,
139
- showClinicalToggle: w = !0,
140
- canAddClinicalNote: u = !0,
141
- clinicalGatedReason: S,
142
- defaultClinical: x = !1,
143
- onRequestAiDraft: L,
144
- aiDraftFormat: B,
145
- aiPrivacyNotice: W,
146
- onDictate: D,
147
- onProofread: E,
148
- onAutoFormat: G,
149
- onTogglePin: m,
150
- onToggleFlag: g,
151
- title: Y,
152
- composerPlaceholder: F,
153
- addNoteLabel: J,
154
- emptyState: O,
155
- className: Q,
156
- "aria-label": P,
157
- ...U
158
- }, X) {
159
- const { t: s } = oe(), k = o(null), [l, N] = V(""), [h, R] = V(x), Z = Y ?? s("notesPanel.title", { defaultValue: "Notes" }), j = ie(), M = F ?? s("notesPanel.placeholder", { defaultValue: "Add a note…" }), H = s("notesPanel.composerLabel", {
160
- defaultValue: "New note"
161
- }), $ = p === "rich" ? T(l) : l.trim().length > 0, ee = ae(() => {
162
- var e, t;
163
- if (r) {
164
- if (p === "rich") {
165
- const d = ((e = k.current) == null ? void 0 : e.getHTML()) ?? l;
166
- if (!T(d)) return;
167
- r({ content: d, clinical: h }), (t = k.current) == null || t.clear();
168
- } else {
169
- const d = l.trim();
170
- if (!d) return;
171
- r({ content: d, clinical: h });
172
- }
173
- N(""), R(x);
174
- }
175
- }, [p, l, h, x, r]), _ = [...v].sort(
176
- (e, t) => Number(t.pinned ?? !1) - Number(e.pinned ?? !1)
177
- ), q = o(v);
178
- q.current = v;
179
- const c = o(r);
180
- c.current = r;
181
- const f = o(m);
182
- f.current = m;
183
- const b = o(g);
184
- b.current = g;
185
- const C = o(u);
186
- C.current = u;
187
- const I = o(null);
188
- re(X, () => I.current, []);
189
- const te = se(
190
- () => ({
191
- // Ids + flags only — never the note body or author (both PHI).
192
- getNotes: () => q.current.map((e) => ({
193
- id: e.id,
194
- pinned: !!e.pinned,
195
- flagged: !!e.flagged,
196
- clinical: !!e.clinical
197
- })),
198
- canAddNote: () => !!c.current,
199
- canAddClinical: () => C.current,
200
- addNote: (e) => {
201
- var t;
202
- e.clinical && !C.current || (t = c.current) == null || t.call(c, e);
203
- },
204
- togglePin: (e) => {
205
- var t;
206
- return (t = f.current) == null ? void 0 : t.call(f, e);
207
- },
208
- toggleFlag: (e) => {
209
- var t;
210
- return (t = b.current) == null ? void 0 : t.call(b, e);
211
- }
212
- }),
213
- []
214
- );
215
- return le(ye, te, a), /* @__PURE__ */ y(
216
- "section",
217
- {
218
- ref: I,
219
- "data-component": "notes-panel",
220
- "data-component-id": a,
221
- "aria-labelledby": P ? void 0 : j,
222
- "aria-label": P,
223
- className: ["ds:flex ds:flex-col", Q].filter(Boolean).join(" "),
224
- ...U,
225
- children: [
226
- /* @__PURE__ */ i(
227
- ge,
228
- {
229
- title: Z,
230
- icon: /* @__PURE__ */ i(be, { "aria-hidden": "true" }),
231
- headingId: P ? void 0 : j,
232
- sticky: !0,
233
- divider: !0
234
- }
235
- ),
236
- /* @__PURE__ */ y("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)] ds:p-[var(--spacing-md)]", children: [
237
- r ? /* @__PURE__ */ y("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
238
- p === "rich" ? /* @__PURE__ */ i(
239
- de,
240
- {
241
- ref: k,
242
- ariaLabel: H,
243
- placeholder: M,
244
- toolbar: z,
245
- minHeight: "sm",
246
- redactor: A,
247
- imageUploadUrl: K,
248
- onChange: ({ html: e }) => N(e),
249
- onRequestAiDraft: L,
250
- aiDraftFormat: B,
251
- aiPrivacyNotice: W,
252
- onDictate: D,
253
- onProofread: E,
254
- onAutoFormat: G
255
- }
256
- ) : /* @__PURE__ */ i(
257
- pe,
258
- {
259
- value: l,
260
- onChange: (e) => N(e.target.value),
261
- placeholder: M,
262
- autoResize: !0,
263
- minRows: 2,
264
- maxRows: 6,
265
- "aria-label": H
266
- }
267
- ),
268
- /* @__PURE__ */ y(
269
- "div",
270
- {
271
- className: [
272
- "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-sm)]",
273
- w ? "ds:justify-between" : "ds:justify-end"
274
- ].join(" "),
275
- children: [
276
- w ? /* @__PURE__ */ i(
277
- me,
278
- {
279
- size: "sm",
280
- label: s("notesPanel.clinicalToggle", {
281
- defaultValue: "Clinical note"
282
- }),
283
- checked: h,
284
- onCheckedChange: (e) => R(e === !0),
285
- disabled: !u,
286
- disabledReason: u ? void 0 : S ?? s("notesPanel.clinicalGated", {
287
- defaultValue: "You do not have permission to write clinical notes."
288
- })
289
- }
290
- ) : null,
291
- /* @__PURE__ */ i(
292
- ue,
293
- {
294
- type: "button",
295
- size: "sm",
296
- onClick: ee,
297
- disabled: !$,
298
- children: J ?? s("notesPanel.add", { defaultValue: "Add note" })
299
- }
300
- )
301
- ]
302
- }
303
- )
304
- ] }) : null,
305
- _.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) => /* @__PURE__ */ i("li", { className: "ds:flex ds:flex-col", children: /* @__PURE__ */ i(
306
- ce,
307
- {
308
- surface: "elevated",
309
- truncate: !0,
310
- ...e,
311
- onTogglePin: m && e.id ? () => m(e.id) : void 0,
312
- onToggleFlag: g && e.id ? () => g(e.id) : void 0
313
- }
314
- ) }, e.id ?? t)) }) : O ?? /* @__PURE__ */ i("p", { className: "ds:m-0 type-body-sm ds:text-[color:var(--muted-foreground)]", children: s("notesPanel.empty", { defaultValue: "No notes yet." }) })
315
- ] })
316
- ]
317
- }
318
- );
319
- }
320
- );
321
- export {
322
- _e as N
323
- };
324
- //# sourceMappingURL=notes-panel-CTcOLLVo.js.map
@@ -1,283 +0,0 @@
1
- import { jsx as w, jsxs as F } from "react/jsx-runtime";
2
- import { forwardRef as G, useId as L, useMemo as v, useRef as K, useState as A, useEffect as H, useImperativeHandle as V } from "react";
3
- import { c as Z } from "./index-D2ZczOXr.js";
4
- import { useTranslation as $ } from "react-i18next";
5
- import q from "react-apexcharts";
6
- import R from "apexcharts";
7
- import { g as U, u as J } from "./apexcharts-theme-B_AxGC_h.js";
8
- import { u as Q } from "./registry-DvAUVLHh.js";
9
- function X(n) {
10
- if (n.length < 2)
11
- return { slope: 0, direction: "steady" };
12
- const t = n.length, a = (t - 1) / 2, c = n.reduce((s, o) => s + o, 0) / t;
13
- let i = 0, l = 0;
14
- for (let s = 0; s < t; s++) {
15
- const o = s - a;
16
- i += o * (n[s] - c), l += o * o;
17
- }
18
- const d = l === 0 ? 0 : i / l, b = 0.01 * (Math.max(...n) - Math.min(...n) || 1), u = Math.abs(d) < b ? "steady" : d > 0 ? "increasing" : "decreasing";
19
- return { slope: d, direction: u };
20
- }
21
- const Y = {
22
- id: "sparkline",
23
- capabilities: [],
24
- state: {},
25
- actions: {
26
- update_series: {
27
- // Replacing the rendered series mutates what the chart displays — write,
28
- // not read.
29
- safety: "write",
30
- argsType: "{ data: number[] }",
31
- argsSchema: {
32
- type: "object",
33
- properties: {
34
- data: {
35
- type: "array",
36
- items: { type: "number" },
37
- description: "The new data points to render."
38
- }
39
- },
40
- required: ["data"]
41
- },
42
- idempotent: !0,
43
- descriptionKey: "ui.agent.sparkline.actions.updateSeries",
44
- description: "Replace the sparkline data without remounting.",
45
- invoke: (n, t) => {
46
- n.updateSeries(t.data);
47
- }
48
- },
49
- export_png: {
50
- // Pure getter — returns an image of the current chart, no state change.
51
- safety: "read",
52
- returns: "string",
53
- returnsSchema: {
54
- type: "string",
55
- description: "A PNG image of the sparkline encoded as a data URI."
56
- },
57
- descriptionKey: "ui.agent.sparkline.actions.exportPng",
58
- description: "Return a PNG data URI of the sparkline.",
59
- invoke: (n) => n.dataURI()
60
- }
61
- },
62
- domHooks: {
63
- root: { attr: "data-component", value: "sparkline" },
64
- instanceId: {
65
- attr: "data-component-id",
66
- sourceProp: "id",
67
- description: "Sourced from the id prop."
68
- }
69
- }
70
- }, D = Z("ds:relative ds:inline-block ds:w-full", {
71
- variants: {
72
- size: {
73
- xs: "ds:h-6",
74
- sm: "ds:h-8",
75
- md: "ds:h-10",
76
- // Applied when an explicit `height` prop is given: the wrapper
77
- // grows with the svg instead of clipping at the size's fixed height.
78
- auto: ""
79
- }
80
- },
81
- defaultVariants: { size: "md" }
82
- }), ee = {
83
- increasing: "↑",
84
- decreasing: "↓",
85
- steady: "→"
86
- }, te = {
87
- xs: 24,
88
- sm: 32,
89
- md: 40
90
- };
91
- function re() {
92
- return typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
93
- }
94
- const ne = G(
95
- ({
96
- id: n,
97
- data: t,
98
- variant: a = "line",
99
- size: c = "md",
100
- label: i,
101
- color: l,
102
- showEndpoint: d = !1,
103
- showTooltip: M = !1,
104
- width: b,
105
- height: u,
106
- className: s,
107
- ...o
108
- }, P) => {
109
- var z;
110
- const { t: p, i18n: C } = $(), S = L(), m = v(
111
- () => `sparkline-${S.replace(/[^a-zA-Z0-9-_]/g, "")}`,
112
- [S]
113
- ), h = K(null), [T, _] = A(0), { direction: k } = X(t), N = v(() => {
114
- if (t.length === 0)
115
- return p("sparkline.noData", "No data");
116
- const e = (y) => new Intl.NumberFormat(C.language).format(y), r = p(`sparkline.direction.${k}`), g = {
117
- min: e(Math.min(...t)),
118
- max: e(Math.max(...t)),
119
- current: e(t[t.length - 1]),
120
- direction: r
121
- };
122
- return i ? p("sparkline.summary", { label: i, ...g }) : p("sparkline.summaryNoLabel", g);
123
- }, [t, i, k, C.language, p]), [f, E] = A(
124
- () => {
125
- try {
126
- return U();
127
- } catch {
128
- return {};
129
- }
130
- }
131
- );
132
- H(() => {
133
- let e;
134
- const r = new MutationObserver(() => {
135
- clearTimeout(e), e = setTimeout(() => {
136
- try {
137
- E(U());
138
- } catch {
139
- }
140
- }, 50);
141
- });
142
- return r.observe(document.documentElement, {
143
- attributes: !0,
144
- attributeFilter: ["class"]
145
- }), () => {
146
- clearTimeout(e), r.disconnect();
147
- };
148
- }, []), H(() => {
149
- const e = h.current;
150
- if (!e) return;
151
- const r = new ResizeObserver((g) => {
152
- const y = g[0];
153
- y && _(Math.floor(y.contentRect.width));
154
- });
155
- return r.observe(e), () => r.disconnect();
156
- }, []), J(h);
157
- const x = v(
158
- () => ({
159
- updateSeries(e) {
160
- var r;
161
- (r = R.getChartByID(m)) == null || r.updateSeries([{ data: e }]);
162
- },
163
- updateOptions(e) {
164
- var r;
165
- (r = R.getChartByID(m)) == null || r.updateOptions(e);
166
- },
167
- async dataURI() {
168
- const e = R.getChartByID(m);
169
- return e ? (await e.dataURI()).imgURI : "";
170
- }
171
- }),
172
- [m]
173
- );
174
- V(P, () => x, [x]), Q(Y, x, n);
175
- const I = l ?? ((z = f.colors) == null ? void 0 : z[0]) ?? "currentColor";
176
- if (t.length === 0)
177
- return /* @__PURE__ */ w(
178
- "div",
179
- {
180
- ref: h,
181
- role: "img",
182
- "aria-label": N,
183
- dir: "ltr",
184
- className: D({
185
- size: u !== void 0 ? "auto" : c,
186
- className: s
187
- }),
188
- ...o
189
- }
190
- );
191
- const O = re(), W = {
192
- ...f,
193
- chart: {
194
- ...f.chart,
195
- id: m,
196
- type: a,
197
- sparkline: { enabled: !0 },
198
- toolbar: { show: !1 },
199
- animations: {
200
- enabled: !O,
201
- dynamicAnimation: { enabled: !O }
202
- },
203
- zoom: { enabled: !1 },
204
- parentHeightOffset: 0
205
- },
206
- colors: [I],
207
- stroke: {
208
- curve: "smooth",
209
- width: a === "bar" ? 0 : 2
210
- },
211
- fill: {
212
- opacity: a === "area" ? 0.15 : 1
213
- },
214
- xaxis: {
215
- crosshairs: { show: !1 }
216
- },
217
- tooltip: { enabled: M },
218
- markers: d ? {
219
- size: [0],
220
- discrete: [
221
- {
222
- seriesIndex: 0,
223
- dataPointIndex: t.length - 1,
224
- fillColor: I,
225
- strokeColor: I,
226
- size: 4
227
- }
228
- ]
229
- } : { size: 0 },
230
- grid: {
231
- ...f.grid,
232
- show: !1,
233
- // ApexCharts grid.padding uses physical keys (not CSS logical properties).
234
- // The chart wrapper enforces dir="ltr" so these always resolve correctly.
235
- padding: { top: 2, right: 2, bottom: 2, left: 2 }
236
- }
237
- }, j = b ?? (T > 0 ? T : "100%"), B = u ?? te[c ?? "md"];
238
- return /* @__PURE__ */ F(
239
- "div",
240
- {
241
- ref: h,
242
- role: "img",
243
- "aria-label": N,
244
- dir: "ltr",
245
- className: D({
246
- size: u !== void 0 ? "auto" : c,
247
- className: s
248
- }),
249
- "data-component": "sparkline",
250
- "data-component-id": n,
251
- ...o,
252
- children: [
253
- /* @__PURE__ */ w(
254
- q,
255
- {
256
- type: a,
257
- series: [{ data: t }],
258
- options: W,
259
- width: j,
260
- height: B,
261
- "aria-hidden": "true"
262
- }
263
- ),
264
- d && /* @__PURE__ */ w(
265
- "span",
266
- {
267
- "aria-hidden": "true",
268
- className: "ds:pointer-events-none ds:absolute ds:end-0 ds:top-0 ds:text-[length:var(--font-size-xs)] ds:leading-none",
269
- children: ee[k]
270
- }
271
- )
272
- ]
273
- }
274
- );
275
- }
276
- );
277
- ne.displayName = "Sparkline";
278
- export {
279
- ne as S,
280
- Y as s,
281
- X as u
282
- };
283
- //# sourceMappingURL=sparkline-DcXqRZoq.js.map