@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.
- package/dist/_chunks/notes-panel-CCz0J140.js +370 -0
- package/dist/_chunks/sparkline-DJtZBe7O.js +501 -0
- package/dist/agent-catalog.json +27 -1
- package/dist/agent-i18n/en.json +4 -2
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/notes-panel/notes-panel.d.ts +45 -2
- package/dist/components/sparkline/index.js +1 -1
- package/dist/components/sparkline/sparkline.d.ts +24 -0
- package/dist/host-compat.css +4 -1
- package/dist/i18n/locales/ar.d.ts +2 -0
- package/dist/i18n/locales/ar.js +2 -0
- package/dist/i18n/locales/de.d.ts +2 -0
- package/dist/i18n/locales/de.js +2 -0
- package/dist/i18n/locales/el.d.ts +2 -0
- package/dist/i18n/locales/el.js +2 -0
- package/dist/i18n/locales/en.d.ts +2 -0
- package/dist/i18n/locales/en.js +2 -0
- package/dist/i18n/locales/es.d.ts +2 -0
- package/dist/i18n/locales/es.js +2 -0
- package/dist/i18n/locales/fr.d.ts +2 -0
- package/dist/i18n/locales/fr.js +2 -0
- package/dist/i18n/locales/hi.d.ts +2 -0
- package/dist/i18n/locales/hi.js +2 -0
- package/dist/i18n/locales/it.d.ts +2 -0
- package/dist/i18n/locales/it.js +2 -0
- package/dist/i18n/locales/ja.d.ts +2 -0
- package/dist/i18n/locales/ja.js +2 -0
- package/dist/i18n/locales/nl.d.ts +2 -0
- package/dist/i18n/locales/nl.js +2 -0
- package/dist/i18n/locales/pl.d.ts +2 -0
- package/dist/i18n/locales/pl.js +2 -0
- package/dist/i18n/locales/pt.d.ts +2 -0
- package/dist/i18n/locales/pt.js +2 -0
- package/dist/i18n/locales/ro.d.ts +2 -0
- package/dist/i18n/locales/ro.js +2 -0
- package/dist/i18n/locales/ru.d.ts +2 -0
- package/dist/i18n/locales/ru.js +2 -0
- package/dist/i18n/locales/sq.d.ts +2 -0
- package/dist/i18n/locales/sq.js +2 -0
- package/dist/i18n/locales/sv.d.ts +2 -0
- package/dist/i18n/locales/sv.js +2 -0
- package/dist/i18n/locales/tr.d.ts +2 -0
- package/dist/i18n/locales/tr.js +2 -0
- package/dist/i18n/locales/zh.d.ts +2 -0
- package/dist/i18n/locales/zh.js +2 -0
- package/dist/index.js +2 -2
- package/dist/locales/ar.json +2 -0
- package/dist/locales/de.json +2 -0
- package/dist/locales/el.json +2 -0
- package/dist/locales/en.json +2 -0
- package/dist/locales/es.json +2 -0
- package/dist/locales/fr.json +2 -0
- package/dist/locales/hi.json +2 -0
- package/dist/locales/it.json +2 -0
- package/dist/locales/ja.json +2 -0
- package/dist/locales/nl.json +2 -0
- package/dist/locales/pl.json +2 -0
- package/dist/locales/pt.json +2 -0
- package/dist/locales/ro.json +2 -0
- package/dist/locales/ru.json +2 -0
- package/dist/locales/sq.json +2 -0
- package/dist/locales/sv.json +2 -0
- package/dist/locales/tr.json +2 -0
- package/dist/locales/zh.json +2 -0
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/notes-panel-CTcOLLVo.js +0 -324
- package/dist/_chunks/sparkline-DLq7xwic.js +0 -394
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
import { jsx as i, jsxs as G } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as Y, useId as ee, useMemo as x, useRef as te, useState as $, useEffect as j, useImperativeHandle as re } from "react";
|
|
3
|
-
import { c as B } from "./index-D2ZczOXr.js";
|
|
4
|
-
import { useTranslation as ne } from "react-i18next";
|
|
5
|
-
import ae from "react-apexcharts";
|
|
6
|
-
import T from "apexcharts";
|
|
7
|
-
import { g as L, u as se } from "./apexcharts-theme-B_AxGC_h.js";
|
|
8
|
-
import { m as oe } from "./annotation-marker-CsUJGZjQ.js";
|
|
9
|
-
import { u as ie } from "./registry-DvAUVLHh.js";
|
|
10
|
-
function de(r) {
|
|
11
|
-
if (r.length < 2)
|
|
12
|
-
return { slope: 0, direction: "steady" };
|
|
13
|
-
const a = r.length, d = (a - 1) / 2, m = r.reduce((n, o) => n + o, 0) / a;
|
|
14
|
-
let c = 0, h = 0;
|
|
15
|
-
for (let n = 0; n < a; n++) {
|
|
16
|
-
const o = n - d;
|
|
17
|
-
c += o * (r[n] - m), h += o * o;
|
|
18
|
-
}
|
|
19
|
-
const l = h === 0 ? 0 : c / h, I = 0.01 * (Math.max(...r) - Math.min(...r) || 1), f = Math.abs(l) < I ? "steady" : l > 0 ? "increasing" : "decreasing";
|
|
20
|
-
return { slope: l, direction: f };
|
|
21
|
-
}
|
|
22
|
-
const ce = {
|
|
23
|
-
id: "sparkline",
|
|
24
|
-
capabilities: [],
|
|
25
|
-
state: {},
|
|
26
|
-
actions: {
|
|
27
|
-
update_series: {
|
|
28
|
-
// Replacing the rendered series mutates what the chart displays — write,
|
|
29
|
-
// not read.
|
|
30
|
-
safety: "write",
|
|
31
|
-
argsType: "{ data: number[] }",
|
|
32
|
-
argsSchema: {
|
|
33
|
-
type: "object",
|
|
34
|
-
properties: {
|
|
35
|
-
data: {
|
|
36
|
-
type: "array",
|
|
37
|
-
items: { type: "number" },
|
|
38
|
-
description: "The new data points to render."
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
required: ["data"]
|
|
42
|
-
},
|
|
43
|
-
idempotent: !0,
|
|
44
|
-
descriptionKey: "ui.agent.sparkline.actions.updateSeries",
|
|
45
|
-
description: "Replace the sparkline data without remounting.",
|
|
46
|
-
invoke: (r, a) => {
|
|
47
|
-
r.updateSeries(a.data);
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
export_png: {
|
|
51
|
-
// Pure getter — returns an image of the current chart, no state change.
|
|
52
|
-
safety: "read",
|
|
53
|
-
returns: "string",
|
|
54
|
-
returnsSchema: {
|
|
55
|
-
type: "string",
|
|
56
|
-
description: "A PNG image of the sparkline encoded as a data URI."
|
|
57
|
-
},
|
|
58
|
-
descriptionKey: "ui.agent.sparkline.actions.exportPng",
|
|
59
|
-
description: "Return a PNG data URI of the sparkline.",
|
|
60
|
-
invoke: (r) => r.dataURI()
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
domHooks: {
|
|
64
|
-
root: { attr: "data-component", value: "sparkline" },
|
|
65
|
-
instanceId: {
|
|
66
|
-
attr: "data-component-id",
|
|
67
|
-
sourceProp: "id",
|
|
68
|
-
description: "Sourced from the id prop."
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}, V = B("ds:relative ds:inline-block ds:w-full", {
|
|
72
|
-
variants: {
|
|
73
|
-
size: {
|
|
74
|
-
xs: "ds:h-6",
|
|
75
|
-
sm: "ds:h-8",
|
|
76
|
-
md: "ds:h-10",
|
|
77
|
-
// Applied when an explicit `height` prop is given: the wrapper
|
|
78
|
-
// grows with the svg instead of clipping at the size's fixed height.
|
|
79
|
-
auto: ""
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
defaultVariants: { size: "md" }
|
|
83
|
-
}), le = B("", {
|
|
84
|
-
variants: {
|
|
85
|
-
tone: {
|
|
86
|
-
neutral: "ds:[--annotation-color:var(--muted-foreground)]",
|
|
87
|
-
info: "ds:[--annotation-color:var(--info)]",
|
|
88
|
-
success: "ds:[--annotation-color:var(--success)]",
|
|
89
|
-
/* `--warning-readable`, not `--warning`: a 1.5px dashed line is a
|
|
90
|
-
* non-text graphic (WCAG 1.4.11, 3:1), and yellow-500 is ~1.6:1 on a
|
|
91
|
-
* light card. The token aliases back to `--warning` in dark. */
|
|
92
|
-
warning: "ds:[--annotation-color:var(--warning-readable)]",
|
|
93
|
-
error: "ds:[--annotation-color:var(--destructive)]",
|
|
94
|
-
accent: "ds:[--annotation-color:var(--accent)]"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
defaultVariants: { tone: "neutral" }
|
|
98
|
-
}), ue = {
|
|
99
|
-
increasing: "↑",
|
|
100
|
-
decreasing: "↓",
|
|
101
|
-
steady: "→"
|
|
102
|
-
}, pe = {
|
|
103
|
-
xs: 24,
|
|
104
|
-
sm: 32,
|
|
105
|
-
md: 40
|
|
106
|
-
}, w = 2, W = 2.5;
|
|
107
|
-
function me(r) {
|
|
108
|
-
return Number.isFinite(r) ? Math.min(1, Math.max(0, r)) : 0;
|
|
109
|
-
}
|
|
110
|
-
function he(r) {
|
|
111
|
-
return r.filter((a) => a != null);
|
|
112
|
-
}
|
|
113
|
-
function fe() {
|
|
114
|
-
return typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
115
|
-
}
|
|
116
|
-
const ge = Y(
|
|
117
|
-
({
|
|
118
|
-
id: r,
|
|
119
|
-
data: a,
|
|
120
|
-
variant: d = "line",
|
|
121
|
-
size: m = "md",
|
|
122
|
-
label: c,
|
|
123
|
-
color: h,
|
|
124
|
-
showEndpoint: l = !1,
|
|
125
|
-
showTooltip: C = !1,
|
|
126
|
-
width: I,
|
|
127
|
-
height: f,
|
|
128
|
-
annotations: n,
|
|
129
|
-
className: o,
|
|
130
|
-
...O
|
|
131
|
-
}, K) => {
|
|
132
|
-
var E;
|
|
133
|
-
const { t: u, i18n: S } = ne(), z = ee(), g = x(
|
|
134
|
-
() => `sparkline-${z.replace(/[^a-zA-Z0-9-_]/g, "")}`,
|
|
135
|
-
[z]
|
|
136
|
-
), k = te(null), [D, Z] = $(0), s = x(() => he(a), [a]), { direction: N } = de(s), _ = x(() => {
|
|
137
|
-
const e = n && n.length > 0 ? u("sparkline.annotations", {
|
|
138
|
-
list: n.map((p) => p.label).join(", ")
|
|
139
|
-
}) : "", t = (p) => e ? `${p}. ${e}` : p;
|
|
140
|
-
if (s.length === 0)
|
|
141
|
-
return t(u("sparkline.noData", "No data"));
|
|
142
|
-
const v = (p) => new Intl.NumberFormat(S.language).format(p), b = u(`sparkline.direction.${N}`), F = {
|
|
143
|
-
min: v(Math.min(...s)),
|
|
144
|
-
max: v(Math.max(...s)),
|
|
145
|
-
current: v(s[s.length - 1]),
|
|
146
|
-
direction: b
|
|
147
|
-
};
|
|
148
|
-
return t(c ? u("sparkline.summary", { label: c, ...F }) : u("sparkline.summaryNoLabel", F));
|
|
149
|
-
}, [s, n, c, N, S.language, u]), [y, q] = $(
|
|
150
|
-
() => {
|
|
151
|
-
try {
|
|
152
|
-
return L();
|
|
153
|
-
} catch {
|
|
154
|
-
return {};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
);
|
|
158
|
-
j(() => {
|
|
159
|
-
let e;
|
|
160
|
-
const t = new MutationObserver(() => {
|
|
161
|
-
clearTimeout(e), e = setTimeout(() => {
|
|
162
|
-
try {
|
|
163
|
-
q(L());
|
|
164
|
-
} catch {
|
|
165
|
-
}
|
|
166
|
-
}, 50);
|
|
167
|
-
});
|
|
168
|
-
return t.observe(document.documentElement, {
|
|
169
|
-
attributes: !0,
|
|
170
|
-
attributeFilter: ["class"]
|
|
171
|
-
}), () => {
|
|
172
|
-
clearTimeout(e), t.disconnect();
|
|
173
|
-
};
|
|
174
|
-
}, []), j(() => {
|
|
175
|
-
const e = k.current;
|
|
176
|
-
if (!e) return;
|
|
177
|
-
const t = new ResizeObserver((v) => {
|
|
178
|
-
const b = v[0];
|
|
179
|
-
b && Z(Math.floor(b.contentRect.width));
|
|
180
|
-
});
|
|
181
|
-
return t.observe(e), () => t.disconnect();
|
|
182
|
-
}, []), se(k);
|
|
183
|
-
const R = x(
|
|
184
|
-
() => ({
|
|
185
|
-
updateSeries(e) {
|
|
186
|
-
var t;
|
|
187
|
-
(t = T.getChartByID(g)) == null || t.updateSeries([{ data: e }]);
|
|
188
|
-
},
|
|
189
|
-
updateOptions(e) {
|
|
190
|
-
var t;
|
|
191
|
-
(t = T.getChartByID(g)) == null || t.updateOptions(e);
|
|
192
|
-
},
|
|
193
|
-
async dataURI() {
|
|
194
|
-
const e = T.getChartByID(g);
|
|
195
|
-
return e ? (await e.dataURI()).imgURI : "";
|
|
196
|
-
}
|
|
197
|
-
}),
|
|
198
|
-
[g]
|
|
199
|
-
);
|
|
200
|
-
re(K, () => R, [R]), ie(ce, R, r);
|
|
201
|
-
const M = h ?? ((E = y.colors) == null ? void 0 : E[0]) ?? "currentColor";
|
|
202
|
-
if (s.length === 0)
|
|
203
|
-
return /* @__PURE__ */ i(
|
|
204
|
-
"div",
|
|
205
|
-
{
|
|
206
|
-
ref: k,
|
|
207
|
-
role: "img",
|
|
208
|
-
"aria-label": _,
|
|
209
|
-
dir: "ltr",
|
|
210
|
-
className: V({
|
|
211
|
-
size: f !== void 0 ? "auto" : m,
|
|
212
|
-
className: o
|
|
213
|
-
}),
|
|
214
|
-
"data-component": "sparkline",
|
|
215
|
-
"data-component-id": r,
|
|
216
|
-
...O
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
const P = fe(), A = a.length > s.length, H = A ? a.flatMap((e, t) => e == null ? [] : [{ x: t, y: e }]) : s, J = {
|
|
220
|
-
...y,
|
|
221
|
-
chart: {
|
|
222
|
-
...y.chart,
|
|
223
|
-
id: g,
|
|
224
|
-
type: d,
|
|
225
|
-
sparkline: { enabled: !0 },
|
|
226
|
-
toolbar: { show: !1 },
|
|
227
|
-
animations: {
|
|
228
|
-
enabled: !P,
|
|
229
|
-
// A gapped series is re-rendered as {x, y} pairs, and Apex's
|
|
230
|
-
// update tween interpolates between the old and new paths point by
|
|
231
|
-
// point. Across a width change the two have different lengths and
|
|
232
|
-
// the tween emits `d="… NaN …"` for a few frames. The finished
|
|
233
|
-
// render is correct either way; switching the tween off keeps the
|
|
234
|
-
// console clean.
|
|
235
|
-
dynamicAnimation: { enabled: !P && !A }
|
|
236
|
-
},
|
|
237
|
-
zoom: { enabled: !1 },
|
|
238
|
-
parentHeightOffset: 0
|
|
239
|
-
},
|
|
240
|
-
colors: [M],
|
|
241
|
-
stroke: {
|
|
242
|
-
curve: "smooth",
|
|
243
|
-
width: d === "bar" ? 0 : 2
|
|
244
|
-
},
|
|
245
|
-
fill: {
|
|
246
|
-
opacity: d === "area" ? 0.15 : 1
|
|
247
|
-
},
|
|
248
|
-
xaxis: {
|
|
249
|
-
crosshairs: { show: !1 },
|
|
250
|
-
// Pin the extent to the slot count so a gap at either end still holds
|
|
251
|
-
// its place — otherwise the plot would rescale to the measurements
|
|
252
|
-
// and the annotation fractions would no longer mean the same thing.
|
|
253
|
-
...A ? { type: "numeric", min: 0, max: a.length - 1 } : {}
|
|
254
|
-
},
|
|
255
|
-
tooltip: { enabled: C },
|
|
256
|
-
markers: l ? {
|
|
257
|
-
size: [0],
|
|
258
|
-
discrete: [
|
|
259
|
-
{
|
|
260
|
-
// An index into the SERIES, whose holes have already been
|
|
261
|
-
// removed — so this is the last MEASURED point, never a slot
|
|
262
|
-
// the parameter was not measured at.
|
|
263
|
-
seriesIndex: 0,
|
|
264
|
-
dataPointIndex: H.length - 1,
|
|
265
|
-
fillColor: M,
|
|
266
|
-
strokeColor: M,
|
|
267
|
-
size: 4
|
|
268
|
-
}
|
|
269
|
-
]
|
|
270
|
-
} : { size: 0 },
|
|
271
|
-
grid: {
|
|
272
|
-
...y.grid,
|
|
273
|
-
show: !1,
|
|
274
|
-
// ApexCharts grid.padding uses physical keys (not CSS logical properties).
|
|
275
|
-
// The chart wrapper enforces dir="ltr" so these always resolve correctly.
|
|
276
|
-
padding: {
|
|
277
|
-
top: w,
|
|
278
|
-
right: w,
|
|
279
|
-
bottom: w,
|
|
280
|
-
left: w
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}, Q = I ?? (D > 0 ? D : "100%"), X = f ?? pe[m ?? "md"], U = n != null && n.length ? n : void 0;
|
|
284
|
-
return /* @__PURE__ */ G(
|
|
285
|
-
"div",
|
|
286
|
-
{
|
|
287
|
-
ref: k,
|
|
288
|
-
role: "img",
|
|
289
|
-
"aria-label": _,
|
|
290
|
-
dir: "ltr",
|
|
291
|
-
className: V({
|
|
292
|
-
size: f !== void 0 ? "auto" : m,
|
|
293
|
-
className: o
|
|
294
|
-
}),
|
|
295
|
-
"data-component": "sparkline",
|
|
296
|
-
"data-component-id": r,
|
|
297
|
-
...O,
|
|
298
|
-
children: [
|
|
299
|
-
/* @__PURE__ */ i(
|
|
300
|
-
ae,
|
|
301
|
-
{
|
|
302
|
-
type: d,
|
|
303
|
-
series: [{ data: H }],
|
|
304
|
-
options: J,
|
|
305
|
-
width: Q,
|
|
306
|
-
height: X,
|
|
307
|
-
"aria-hidden": "true"
|
|
308
|
-
}
|
|
309
|
-
),
|
|
310
|
-
U && /* Drawn over the plot rather than through ApexCharts' own xaxis
|
|
311
|
-
annotations: a fraction of the measured extent is the one
|
|
312
|
-
positioning rule that survives series of different lengths, which
|
|
313
|
-
is what makes a column of sparklines share an x. */
|
|
314
|
-
/* The inset lives on a div: an <svg> is a replaced element, so
|
|
315
|
-
left+right do not size it and it would fall back to its intrinsic
|
|
316
|
-
300px. The div is the plot box; the svg fills it. The 2px MUST
|
|
317
|
-
equal PLOT_EDGE_PADDING — Tailwind needs a static literal, so the
|
|
318
|
-
two cannot share one source; change them together or the first and
|
|
319
|
-
last annotation drift off the first and last data point. */
|
|
320
|
-
/* @__PURE__ */ i("div", { className: "ds:pointer-events-none ds:absolute ds:inset-y-0 ds:inset-x-[2px]", children: /* @__PURE__ */ i(
|
|
321
|
-
"svg",
|
|
322
|
-
{
|
|
323
|
-
"aria-hidden": "true",
|
|
324
|
-
focusable: "false",
|
|
325
|
-
"data-testid": "sparkline-annotations",
|
|
326
|
-
className: "ds:size-full",
|
|
327
|
-
children: U.map((e) => {
|
|
328
|
-
const t = me(e.position);
|
|
329
|
-
return (
|
|
330
|
-
/* A nested viewport placed at a percentage of the plot: the
|
|
331
|
-
one positioning rule that needs no measurement, so a column
|
|
332
|
-
of sparklines shares an x whatever their widths. */
|
|
333
|
-
/* @__PURE__ */ G(
|
|
334
|
-
"svg",
|
|
335
|
-
{
|
|
336
|
-
x: `${t * 100}%`,
|
|
337
|
-
y: "0",
|
|
338
|
-
width: "1",
|
|
339
|
-
height: "100%",
|
|
340
|
-
overflow: "visible",
|
|
341
|
-
"data-annotation-id": e.id,
|
|
342
|
-
"data-annotation-position": t,
|
|
343
|
-
className: le({ tone: e.tone }),
|
|
344
|
-
children: [
|
|
345
|
-
/* @__PURE__ */ i(
|
|
346
|
-
"line",
|
|
347
|
-
{
|
|
348
|
-
x1: 0,
|
|
349
|
-
x2: 0,
|
|
350
|
-
y1: 0,
|
|
351
|
-
y2: "100%",
|
|
352
|
-
className: "ds:[stroke:var(--annotation-color)] ds:[stroke-dasharray:2_3] ds:[stroke-width:1]"
|
|
353
|
-
}
|
|
354
|
-
),
|
|
355
|
-
/* @__PURE__ */ i(
|
|
356
|
-
"path",
|
|
357
|
-
{
|
|
358
|
-
d: oe(
|
|
359
|
-
e.shape ?? "diamond",
|
|
360
|
-
0,
|
|
361
|
-
W,
|
|
362
|
-
W
|
|
363
|
-
),
|
|
364
|
-
className: "ds:[fill:var(--annotation-color)]"
|
|
365
|
-
}
|
|
366
|
-
)
|
|
367
|
-
]
|
|
368
|
-
},
|
|
369
|
-
e.id
|
|
370
|
-
)
|
|
371
|
-
);
|
|
372
|
-
})
|
|
373
|
-
}
|
|
374
|
-
) }),
|
|
375
|
-
l && /* @__PURE__ */ i(
|
|
376
|
-
"span",
|
|
377
|
-
{
|
|
378
|
-
"aria-hidden": "true",
|
|
379
|
-
className: "ds:pointer-events-none ds:absolute ds:end-0 ds:top-0 ds:text-[length:var(--font-size-xs)] ds:leading-none",
|
|
380
|
-
children: ue[N]
|
|
381
|
-
}
|
|
382
|
-
)
|
|
383
|
-
]
|
|
384
|
-
}
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
);
|
|
388
|
-
ge.displayName = "Sparkline";
|
|
389
|
-
export {
|
|
390
|
-
ge as S,
|
|
391
|
-
ce as s,
|
|
392
|
-
de as u
|
|
393
|
-
};
|
|
394
|
-
//# sourceMappingURL=sparkline-DLq7xwic.js.map
|