@alfadocs/ui-kit 0.80.0 → 0.81.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.
@@ -1,13 +1,13 @@
1
- import { jsxs as S, jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as X, useId as tt, useMemo as d, useRef as et, useState as $, useEffect as G, useImperativeHandle as rt } from "react";
3
- import { c as at } from "./index-D2ZczOXr.js";
4
- import { useTranslation as ot } from "react-i18next";
5
- import nt from "react-apexcharts";
6
- import U from "apexcharts";
7
- import { u as it, g as k } from "./apexcharts-theme-BJigns_V.js";
8
- import { u as st } from "./use-prefers-reduced-motion-BMwIQRjB.js";
9
- import { u as ct } from "./registry-DvAUVLHh.js";
10
- const dt = {
1
+ import { jsxs as S, jsx as d } from "react/jsx-runtime";
2
+ import { forwardRef as et, useId as rt, useMemo as c, useRef as at, useState as U, useEffect as k, useImperativeHandle as ot } from "react";
3
+ import { c as nt } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as it } from "react-i18next";
5
+ import st from "react-apexcharts";
6
+ import H from "apexcharts";
7
+ import { u as ct, g as _ } from "./apexcharts-theme-BJigns_V.js";
8
+ import { u as dt } from "./use-prefers-reduced-motion-BMwIQRjB.js";
9
+ import { u as lt } from "./registry-DvAUVLHh.js";
10
+ const mt = {
11
11
  id: "chart",
12
12
  capabilities: [],
13
13
  state: {},
@@ -75,7 +75,7 @@ const dt = {
75
75
  description: "Sourced from the id prop."
76
76
  }
77
77
  }
78
- }, lt = at("ds:relative ds:block ds:w-full", {
78
+ }, ut = nt("ds:relative ds:block ds:w-full", {
79
79
  variants: {
80
80
  density: {
81
81
  compact: "ds:min-h-[var(--chart-min-height-compact)]",
@@ -87,20 +87,20 @@ const dt = {
87
87
  }
88
88
  },
89
89
  defaultVariants: { density: "comfortable" }
90
- }), mt = [
90
+ }), pt = [
91
91
  "verticalLines",
92
92
  "horizontalLines",
93
93
  "slantedLines",
94
94
  "squares",
95
95
  "circles"
96
- ], ut = ["line", "bar", "area"], pt = ["pie", "donut", "radialBar"];
96
+ ], ht = ["line", "bar", "area"], ft = ["pie", "donut", "radialBar"];
97
97
  function T(o) {
98
- return pt.includes(o);
98
+ return ft.includes(o);
99
99
  }
100
- function ht(o) {
101
- return ut.includes(o);
100
+ function bt(o) {
101
+ return ht.includes(o);
102
102
  }
103
- function ft(o, l) {
103
+ function gt(o, l) {
104
104
  return T(l) ? [
105
105
  {
106
106
  name: "",
@@ -108,45 +108,46 @@ function ft(o, l) {
108
108
  }
109
109
  ] : o;
110
110
  }
111
- const bt = X(
111
+ const yt = et(
112
112
  ({
113
113
  title: o,
114
114
  id: l,
115
115
  type: r,
116
116
  series: h,
117
- categories: g,
118
- labels: y,
117
+ categories: y,
118
+ labels: f,
119
119
  height: O,
120
- width: H,
120
+ width: M,
121
121
  patterns: A = !1,
122
122
  colors: v,
123
123
  toolbar: x = !1,
124
- locale: _,
124
+ locale: j,
125
125
  radialValueFormatter: m,
126
- density: M,
127
- className: j
128
- }, D) => {
129
- const { t: a, i18n: W } = ot(), N = tt(), u = d(
130
- () => `chart-${N.replace(/[^a-zA-Z0-9-_]/g, "")}`,
131
- [N]
132
- ), R = `${u}-summary`, I = et(null), [P, q] = $(0);
133
- it(I);
134
- const p = _ ?? W.language ?? "en", [z, Y] = $(
126
+ valueFormatter: N,
127
+ density: D,
128
+ className: W
129
+ }, q) => {
130
+ const { t: a, i18n: Y } = it(), P = rt(), u = c(
131
+ () => `chart-${P.replace(/[^a-zA-Z0-9-_]/g, "")}`,
132
+ [P]
133
+ ), R = `${u}-summary`, I = at(null), [z, Z] = U(0);
134
+ ct(I);
135
+ const p = j ?? Y.language ?? "en", [B, K] = U(
135
136
  () => {
136
137
  try {
137
- return k();
138
+ return _();
138
139
  } catch {
139
140
  return {};
140
141
  }
141
142
  }
142
143
  );
143
- G(() => {
144
+ k(() => {
144
145
  if (typeof document > "u") return;
145
146
  let t;
146
147
  const e = new MutationObserver(() => {
147
148
  clearTimeout(t), t = setTimeout(() => {
148
149
  try {
149
- Y(k());
150
+ K(_());
150
151
  } catch {
151
152
  }
152
153
  }, 50);
@@ -157,36 +158,39 @@ const bt = X(
157
158
  }), () => {
158
159
  clearTimeout(t), e.disconnect();
159
160
  };
160
- }, []), G(() => {
161
+ }, []), k(() => {
161
162
  const t = I.current;
162
163
  if (!t || typeof ResizeObserver > "u") return;
163
164
  const e = new ResizeObserver((n) => {
164
165
  const i = n[0];
165
- i && q(Math.floor(i.contentRect.width));
166
+ i && Z(Math.floor(i.contentRect.width));
166
167
  });
167
168
  return e.observe(t), () => e.disconnect();
168
169
  }, []);
169
- const C = d(
170
+ const C = c(
170
171
  () => ({
171
172
  async dataURI() {
172
- const t = U.getChartByID(u);
173
+ const t = H.getChartByID(u);
173
174
  return t ? (await t.dataURI()).imgURI : "";
174
175
  },
175
176
  updateSeries(t) {
176
- const e = U.getChartByID(u);
177
+ const e = H.getChartByID(u);
177
178
  e && (T(r), e.updateSeries(t));
178
179
  }
179
180
  }),
180
181
  [u, r]
181
182
  );
182
- rt(D, () => C, [C]), ct(dt, C, l);
183
- const w = typeof document < "u" && document.documentElement.dir === "rtl", B = d(
184
- () => ft(h, r),
183
+ ot(q, () => C, [C]), lt(mt, C, l);
184
+ const w = typeof document < "u" && document.documentElement.dir === "rtl", E = c(
185
+ () => gt(h, r),
185
186
  [h, r]
186
- ), f = d(
187
+ ), $ = c(
187
188
  () => new Intl.NumberFormat(p),
188
189
  [p]
189
- ), E = d(
190
+ ), b = c(
191
+ () => N ?? ((t) => $.format(t)),
192
+ [N, $]
193
+ ), G = c(
190
194
  () => ({
191
195
  name: p,
192
196
  options: {
@@ -205,9 +209,9 @@ const bt = X(
205
209
  }
206
210
  }),
207
211
  [p, a]
208
- ), L = st(), Z = d(() => {
209
- var n, i, b;
210
- const t = z, e = {
212
+ ), L = dt(), V = c(() => {
213
+ var n, i, g;
214
+ const t = B, e = {
211
215
  ...t,
212
216
  chart: {
213
217
  ...t.chart,
@@ -218,11 +222,17 @@ const bt = X(
218
222
  enabled: !L,
219
223
  dynamicAnimation: { enabled: !L }
220
224
  },
221
- locales: [E],
225
+ locales: [G],
222
226
  defaultLocale: p,
223
227
  parentHeightOffset: 0
224
228
  },
225
- labels: y,
229
+ // Only set `labels` when the consumer actually supplied them (slice
230
+ // charts). Emitting `labels: undefined` crashes ApexCharts' bar
231
+ // renderer — `parseDataAxisCharts` reads `labels.length` and throws
232
+ // "Cannot read properties of undefined (reading 'length')", which
233
+ // aborts the render and leaves a blank chart. Absent is safe; area /
234
+ // line tolerate the undefined but bar does not, so never pass it.
235
+ ...f ? { labels: f } : {},
226
236
  legend: {
227
237
  ...t.legend,
228
238
  position: "bottom",
@@ -236,21 +246,21 @@ const bt = X(
236
246
  tooltip: {
237
247
  ...t.tooltip,
238
248
  y: {
239
- formatter: (s) => f.format(s)
249
+ formatter: (s) => b(s)
240
250
  }
241
251
  },
242
252
  noData: {
243
253
  text: a("chart.noData")
244
254
  }
245
255
  };
246
- if (v && v.length > 0 && (e.colors = v), ht(r) && (e.xaxis = {
256
+ if (v && v.length > 0 && (e.colors = v), bt(r) && (e.xaxis = {
247
257
  ...t.xaxis,
248
- categories: g ?? []
258
+ categories: y ?? []
249
259
  }, e.yaxis = {
250
260
  ...t.yaxis,
251
261
  opposite: w,
252
262
  labels: {
253
- formatter: (s) => f.format(s)
263
+ formatter: (s) => b(s)
254
264
  }
255
265
  }, e.stroke = {
256
266
  curve: "smooth",
@@ -264,8 +274,8 @@ const bt = X(
264
274
  dataLabels: {
265
275
  ...((n = s.radialBar) == null ? void 0 : n.dataLabels) ?? {},
266
276
  value: {
267
- ...((b = (i = s.radialBar) == null ? void 0 : i.dataLabels) == null ? void 0 : b.value) ?? {},
268
- formatter: (Q) => m(Number(Q))
277
+ ...((g = (i = s.radialBar) == null ? void 0 : i.dataLabels) == null ? void 0 : g.value) ?? {},
278
+ formatter: (tt) => m(Number(tt))
269
279
  }
270
280
  }
271
281
  }
@@ -275,7 +285,7 @@ const bt = X(
275
285
  type: "pattern",
276
286
  opacity: r === "area" ? 0.3 : 1,
277
287
  pattern: {
278
- style: [...mt],
288
+ style: [...pt],
279
289
  strokeWidth: 2
280
290
  }
281
291
  } : r === "area" && (e.fill = {
@@ -283,45 +293,45 @@ const bt = X(
283
293
  opacity: 0.3
284
294
  }), e;
285
295
  }, [
286
- z,
296
+ B,
287
297
  u,
288
298
  x,
289
299
  L,
290
- E,
300
+ G,
291
301
  p,
292
- y,
293
302
  f,
303
+ b,
294
304
  a,
295
305
  r,
296
- g,
306
+ y,
297
307
  w,
298
308
  A,
299
309
  v,
300
310
  m
301
- ]), K = H ?? (P > 0 ? P : "100%"), F = O ?? 320, V = d(() => {
302
- const t = T(r) ? y ?? [] : g ?? [], e = B;
311
+ ]), F = M ?? (z > 0 ? z : "100%"), J = O ?? 320, Q = c(() => {
312
+ const t = T(r) ? f ?? [] : y ?? [], e = E;
303
313
  return /* @__PURE__ */ S("table", { id: R, className: "ds:sr-only", children: [
304
- /* @__PURE__ */ c("caption", { children: o }),
305
- /* @__PURE__ */ c("thead", { children: /* @__PURE__ */ S("tr", { children: [
306
- /* @__PURE__ */ c("th", { scope: "col", children: a("chart.table.series") }),
307
- t.map((n, i) => /* @__PURE__ */ c("th", { scope: "col", children: n }, `${n}-${i}`))
314
+ /* @__PURE__ */ d("caption", { children: o }),
315
+ /* @__PURE__ */ d("thead", { children: /* @__PURE__ */ S("tr", { children: [
316
+ /* @__PURE__ */ d("th", { scope: "col", children: a("chart.table.series") }),
317
+ t.map((n, i) => /* @__PURE__ */ d("th", { scope: "col", children: n }, `${n}-${i}`))
308
318
  ] }) }),
309
- /* @__PURE__ */ c("tbody", { children: e.map((n, i) => /* @__PURE__ */ S("tr", { children: [
310
- /* @__PURE__ */ c("th", { scope: "row", children: n.name || a("chart.table.value") }),
311
- n.data.map((b, s) => /* @__PURE__ */ c("td", { children: r === "radialBar" && m ? m(b) : f.format(b) }, `${i}-${s}`))
319
+ /* @__PURE__ */ d("tbody", { children: e.map((n, i) => /* @__PURE__ */ S("tr", { children: [
320
+ /* @__PURE__ */ d("th", { scope: "row", children: n.name || a("chart.table.value") }),
321
+ n.data.map((g, s) => /* @__PURE__ */ d("td", { children: r === "radialBar" && m ? m(g) : b(g) }, `${i}-${s}`))
312
322
  ] }, `${n.name}-${i}`)) })
313
323
  ] });
314
324
  }, [
315
325
  r,
316
- B,
326
+ E,
327
+ f,
317
328
  y,
318
- g,
319
329
  R,
320
330
  o,
321
331
  a,
322
- f,
332
+ b,
323
333
  m
324
- ]), J = d(() => (T(r), h), [h, r]);
334
+ ]), X = c(() => (T(r), h), [h, r]);
325
335
  return /* @__PURE__ */ S(
326
336
  "div",
327
337
  {
@@ -329,24 +339,24 @@ const bt = X(
329
339
  role: "img",
330
340
  "aria-label": o,
331
341
  "aria-describedby": R,
332
- className: lt({
342
+ className: ut({
333
343
  // Explicit height wins over the density min-height unless the
334
344
  // caller also asked for a density explicitly.
335
- density: M ?? (O !== void 0 ? "none" : void 0),
336
- className: j
345
+ density: D ?? (O !== void 0 ? "none" : void 0),
346
+ className: W
337
347
  }),
338
348
  "data-component": "chart",
339
349
  "data-component-id": l,
340
350
  children: [
341
- V,
342
- /* @__PURE__ */ c(
343
- nt,
351
+ Q,
352
+ /* @__PURE__ */ d(
353
+ st,
344
354
  {
345
355
  type: r,
346
- series: J,
347
- options: Z,
348
- width: K,
349
- height: F,
356
+ series: X,
357
+ options: V,
358
+ width: F,
359
+ height: J,
350
360
  "aria-hidden": "true"
351
361
  }
352
362
  )
@@ -355,10 +365,10 @@ const bt = X(
355
365
  );
356
366
  }
357
367
  );
358
- bt.displayName = "Chart";
368
+ yt.displayName = "Chart";
359
369
  export {
360
- bt as C,
361
- lt as a,
362
- dt as c
370
+ yt as C,
371
+ ut as a,
372
+ mt as c
363
373
  };
364
- //# sourceMappingURL=chart-CMr3eW62.js.map
374
+ //# sourceMappingURL=chart-CpkpA74k.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "packageVersion": "0.80.0",
3
+ "packageVersion": "0.81.0",
4
4
  "components": [
5
5
  {
6
6
  "kind": "component",
@@ -50,6 +50,16 @@ export interface ChartProps extends VariantProps<typeof chartVariants> {
50
50
  * Ignored for every other chart type. Defaults to ApexCharts' `${value}%`.
51
51
  */
52
52
  radialValueFormatter?: (value: number) => string;
53
+ /**
54
+ * Formats the numeric value of each data point wherever it is surfaced as
55
+ * text — the tooltip, the value (y) axis on categorical charts, and the
56
+ * screen-reader summary table. Use it to append a unit or currency symbol,
57
+ * e.g. `(v) => new Intl.NumberFormat(locale, { style: 'currency', currency:
58
+ * 'EUR' }).format(v)`. Defaults to `Intl.NumberFormat(locale)` (grouped
59
+ * number, no unit). Does not apply to a `radialBar` ring centre — use
60
+ * `radialValueFormatter` for that.
61
+ */
62
+ valueFormatter?: (value: number) => string;
53
63
  /** Extra class names on the wrapper. */
54
64
  className?: string;
55
65
  }
@@ -1,4 +1,4 @@
1
- import { C as t, c as s, a as c } from "../../_chunks/chart-CMr3eW62.js";
1
+ import { C as t, c as s, a as c } from "../../_chunks/chart-CpkpA74k.js";
2
2
  export {
3
3
  t as Chart,
4
4
  s as chartAgent,
package/dist/index.js CHANGED
@@ -162,7 +162,7 @@ import { S as Al } from "./_chunks/separator-CYU_bGFn.js";
162
162
  import { T as fl } from "./_chunks/theme-root-BOO73p5t.js";
163
163
  import { C as Cl, U as Sl, a as xl, b as Tl, c as ul } from "./_chunks/unit-converter-CSLWFDQh.js";
164
164
  import { V as Il } from "./_chunks/visually-hidden-BHxEUGyT.js";
165
- import { C as bl, c as Rl, a as _l } from "./_chunks/chart-CMr3eW62.js";
165
+ import { C as bl, c as Rl, a as _l } from "./_chunks/chart-CpkpA74k.js";
166
166
  import { A as hl, a as Dl } from "./_chunks/ai-prompt-input-DziJCGLe.js";
167
167
  import { A as Ml, a as Ol } from "./_chunks/audio-recorder-Cc3KuL9y.js";
168
168
  import { A as yl } from "./_chunks/audio-visualiser-l6zPd0AG.js";