@selectwin/kit 0.1.218 → 0.1.219

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.
@@ -3,10 +3,12 @@ import { SelectChartSeries } from './chartUtils';
3
3
  /** What the hover card shows for one slot (see `tooltip`). */
4
4
  export interface SelectColumnTooltip {
5
5
  title?: ReactNode;
6
+ /** `total` (0.1.219): a linha da soma, sem o ponto da cor e com o fio acima. */
6
7
  rows: {
7
8
  label: ReactNode;
8
9
  value: ReactNode;
9
10
  color?: string;
11
+ total?: boolean;
10
12
  }[];
11
13
  }
12
14
  type SelectColumnChartOwnProps = {
@@ -36,7 +38,19 @@ type SelectColumnChartOwnProps = {
36
38
  average?: boolean | {
37
39
  label?: string;
38
40
  };
41
+ /** 0.1.219: o nome do gráfico ("Mensagens por dia, por canal"). Com ele, o gráfico entra no Tab e anda pelas setas. */
42
+ label?: string;
43
+ /** 0.1.219: o ponto que o foco do teclado acende primeiro (padrão: o último, o mais recente). */
44
+ start?: number;
45
+ /** 0.1.219: o nome inteiro de cada ponto ("24/10, 14h–15h"), na dica e na tabela; o eixo segue com `labels`. */
46
+ titles?: string[];
47
+ /** 0.1.219: os números da dica e da tabela ("1.204"); o eixo segue com `format` ("1,2 mil"). Padrão: `format`. */
48
+ formatValue?: (n: number) => string;
49
+ /** 0.1.219: a linha da soma na dica padrão, com este rótulo ("no total"). */
50
+ total?: string;
51
+ /** 0.1.219: com `label`, a tabela escondida com todos os números; o texto é o cabeçalho da 1ª coluna ("Dia"). */
52
+ table?: string;
39
53
  };
40
54
  export type SelectColumnChartProps = SelectColumnChartOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectColumnChartOwnProps>;
41
- export declare function SelectColumnChart({ series, labels, height, format, stacked, marker, tooltip, compare, average, className, ...rest }: SelectColumnChartProps): import("react").JSX.Element;
55
+ export declare function SelectColumnChart({ series, labels, height, format, stacked, marker, tooltip, compare, average, label, start, titles, formatValue, total, table, className, ...rest }: SelectColumnChartProps): import("react").JSX.Element;
42
56
  export {};
@@ -1,222 +1,250 @@
1
1
  /* empty css */
2
2
  import { CHART_PAD as e, chartColor as t, formatCompact as n, niceTicks as r, useChartSize as i, yAxisPad as a } from "./chartUtils.js";
3
- import { ChartTooltip as o, useChartTooltip as ee } from "./chartTip.js";
4
- import { useId as te, useState as ne } from "react";
3
+ import { ChartTooltip as o } from "./chartTip.js";
4
+ import { tipSpeech as ee, useChartPointer as te } from "./internal/chartPointer.js";
5
+ import { useId as ne } from "react";
5
6
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
7
  //#region src/SelectColumnChart.tsx
7
- var l = 6.4, re = 12, u = .45, d = 3;
8
- function f({ series: f, labels: p, height: m = 240, format: h = n, stacked: g = !1, marker: _, tooltip: v, compare: y, average: b, className: x, ...S }) {
9
- var C;
10
- let { ref: w, width: T } = i(m), E = ee(), D = te(), [O, k] = ne(null), A = p.length, j = f.length || 1, M = p.map((e, t) => f.reduce((e, n) => e + (n.data[t] ?? 0), 0)), N = y ? p.map((e, t) => y.data[t] ?? 0) : [], ie = Math.max(0, ...g ? M : f.flatMap((e) => e.data), ...N), { max: P, values: F } = r(ie, 4), I = {
8
+ var re = 6.4, ie = 12, ae = .45, l = 3;
9
+ function u({ series: u, labels: d, height: f = 240, format: p = n, stacked: m = !1, marker: h, tooltip: g, compare: _, average: v, label: y, start: oe, titles: b, formatValue: x = p, total: S, table: C, className: w, ...se }) {
10
+ var T;
11
+ let { ref: E, width: D } = i(f), O = ne(), k = d.length, A = u.length || 1, j = d.map((e, t) => u.reduce((e, n) => e + (n.data[t] ?? 0), 0)), M = _ ? d.map((e, t) => _.data[t] ?? 0) : [], ce = Math.max(0, ...m ? j : u.flatMap((e) => e.data), ...M), { max: N, values: P } = r(ce, 4), F = {
11
12
  ...e,
12
- left: a(F.map(h), w.current)
13
- }, L = Math.max(0, T - I.left - I.right), R = m - I.top - I.bottom, z = I.top + R, B = A ? L / A : 0, V = (e) => z - e / P * R, H = y ? 1.45 : 1, ae = Math.min(B * .72, j * 40 * H), U = Math.min(B * (y ? .62 : .5) / H, 44), W = g ? U : ae / H / j, G = y ? (g ? U : W * j) * u : 0, K = Math.min(30, 600 / Math.max(1, A)), q = (e, t) => e.pattern === "hatch" ? `url(#${D}-p${t})` : `url(#${D}-c${t})`, J = (e) => e.edge ? {
13
+ left: a(P.map(p), E.current)
14
+ }, I = Math.max(0, D - F.left - F.right), L = f - F.top - F.bottom, R = F.top + L, z = k ? I / k : 0, B = (e) => R - e / N * L, V = _ ? 1.45 : 1, le = Math.min(z * .72, A * 40 * V), H = Math.min(z * (_ ? .62 : .5) / V, 44), U = m ? H : le / V / A, W = _ ? (m ? H : U * A) * ae : 0, G = Math.min(30, 600 / Math.max(1, k)), K = (e, t) => e.pattern === "hatch" ? `url(#${O}-p${t})` : `url(#${O}-c${t})`, q = (e) => e.edge ? {
14
15
  stroke: e.edge,
15
16
  strokeWidth: 1
16
- } : {}, Y = _ && A > 0 ? Math.min(A - 1, Math.max(0, _.index)) : null, oe = p.reduce((e, t) => Math.max(e, t.length), 0), X = B > 0 ? Math.max(1, Math.ceil((oe * l + re) / B)) : 1, se = Y ?? 0, ce = (e) => X === 1 || ((e - se) % X + X) % X === 0, Z = g ? M : ((C = f[0]) == null ? void 0 : C.data) ?? [], Q = b && Z.length > 0 ? Z.reduce((e, t) => e + (t ?? 0), 0) / Z.length : null, le = typeof b == "object" && b.label ? b.label : "Média", ue = (e, n) => {
17
- if (v) {
18
- let t = v(e);
17
+ } : {}, J = h && k > 0 ? Math.min(k - 1, Math.max(0, h.index)) : null, ue = d.reduce((e, t) => Math.max(e, t.length), 0), Y = z > 0 ? Math.max(1, Math.ceil((ue * re + ie) / z)) : 1, de = J ?? 0, fe = (e) => Y === 1 || ((e - de) % Y + Y) % Y === 0, X = m ? j : ((T = u[0]) == null ? void 0 : T.data) ?? [], Z = v && X.length > 0 ? X.reduce((e, t) => e + (t ?? 0), 0) / X.length : null, pe = typeof v == "object" && v.label ? v.label : "Média", me = (e, n) => {
18
+ if (g) {
19
+ let t = g(e);
19
20
  return t ? {
20
21
  title: t.title ?? n,
21
22
  rows: t.rows
22
23
  } : null;
23
24
  }
24
- let r = f.map((n, r) => ({
25
+ let r = u.map((n, r) => ({
25
26
  label: n.name,
26
- value: h(n.data[e] ?? 0),
27
+ value: x(n.data[e] ?? 0),
27
28
  color: n.color ?? t(r)
28
29
  }));
29
- return y && r.push({
30
- label: y.name,
31
- value: h(N[e] ?? 0),
30
+ return _ && r.push({
31
+ label: _.name,
32
+ value: x(M[e] ?? 0),
32
33
  color: "var(--select-chart-compare)"
34
+ }), S != null && r.push({
35
+ label: S,
36
+ value: x(j[e] ?? 0),
37
+ total: !0
33
38
  }), {
34
39
  title: n,
35
40
  rows: r
36
41
  };
37
- }, $ = (e) => `select-chart__slot${O != null && O !== e ? " select-chart__slot--dim" : ""}`;
42
+ }, { active: Q, props: he } = te({
43
+ count: k,
44
+ indexAt: (e) => z > 0 && e >= F.left ? Math.min(k - 1, Math.floor((e - F.left) / z)) : null,
45
+ start: oe,
46
+ focusable: y != null
47
+ }), ge = (e) => {
48
+ let t = m ? B(j[e] ?? 0) : Math.min(...u.map((t) => B(t.data[e] ?? 0)));
49
+ return _ ? Math.min(t, B(M[e] ?? 0)) : t;
50
+ }, $ = Q == null ? null : me(Q, (b == null ? void 0 : b[Q]) ?? d[Q] ?? ""), _e = (e) => `select-chart__slot${Q != null && Q !== e ? " select-chart__slot--dim" : ""}`;
38
51
  return /* @__PURE__ */ c("div", {
39
- ...S,
40
- className: `select-chart-wrap${x ? " " + x : ""}`,
41
- ref: w,
42
- children: [T > 0 && /* @__PURE__ */ c("svg", {
43
- width: T,
44
- height: m,
45
- className: "select-chart",
46
- children: [
47
- /* @__PURE__ */ s("defs", { children: f.map((e, n) => {
48
- let r = e.color ?? t(n);
49
- return e.pattern === "hatch" ? /* @__PURE__ */ c("pattern", {
50
- id: `${D}-p${n}`,
51
- width: 6,
52
- height: 6,
53
- patternUnits: "userSpaceOnUse",
54
- patternTransform: "rotate(45)",
55
- children: [/* @__PURE__ */ s("rect", {
52
+ ...se,
53
+ className: `select-chart-wrap${w ? " " + w : ""}`,
54
+ ref: E,
55
+ children: [
56
+ D > 0 && /* @__PURE__ */ c("svg", {
57
+ width: D,
58
+ height: f,
59
+ className: "select-chart",
60
+ ...y == null ? {} : {
61
+ role: "img",
62
+ "aria-label": y
63
+ },
64
+ ...he,
65
+ children: [
66
+ /* @__PURE__ */ s("defs", { children: u.map((e, n) => {
67
+ let r = e.color ?? t(n);
68
+ return e.pattern === "hatch" ? /* @__PURE__ */ c("pattern", {
69
+ id: `${O}-p${n}`,
56
70
  width: 6,
57
71
  height: 6,
58
- fill: r,
59
- fillOpacity: .16
60
- }), /* @__PURE__ */ s("line", {
61
- x1: 0,
62
- y1: 0,
63
- x2: 0,
64
- y2: 6,
65
- stroke: r,
66
- strokeWidth: 2.5
67
- })]
68
- }, n) : /* @__PURE__ */ c("linearGradient", {
69
- id: `${D}-c${n}`,
70
- x1: "0",
71
- y1: "0",
72
- x2: "0",
73
- y2: "1",
74
- children: [/* @__PURE__ */ s("stop", {
75
- offset: "0%",
76
- stopColor: r,
77
- stopOpacity: 1
78
- }), /* @__PURE__ */ s("stop", {
79
- offset: "100%",
80
- stopColor: r,
81
- stopOpacity: .62
82
- })]
83
- }, n);
84
- }) }),
85
- F.map((e, t) => /* @__PURE__ */ c("g", { children: [/* @__PURE__ */ s("line", {
86
- x1: I.left,
87
- x2: T - I.right,
88
- y1: V(e),
89
- y2: V(e),
90
- className: t === 0 ? "select-chart__axis" : "select-chart__grid"
91
- }), /* @__PURE__ */ s("text", {
92
- x: I.left - 8,
93
- y: V(e),
94
- className: "select-chart__ylabel",
95
- dominantBaseline: "middle",
96
- textAnchor: "end",
97
- children: h(e)
98
- })] }, t)),
99
- p.map((e, t) => {
100
- let n = I.left + B * t, r = (g ? W : W * j) + (y ? G + d : 0), i = n + B / 2 - r / 2, a = i + (y ? G + d : 0), o = y ? /* @__PURE__ */ s("rect", {
101
- x: i,
102
- y: V(N[t] ?? 0),
103
- width: G,
104
- height: Math.max(0, z - V(N[t] ?? 0)),
105
- rx: Math.min(3, G / 2),
106
- className: "select-chart__compare",
107
- style: { animationDelay: `${Math.round(t * K)}ms` }
108
- }) : null;
109
- if (g) {
110
- let e = 0;
72
+ patternUnits: "userSpaceOnUse",
73
+ patternTransform: "rotate(45)",
74
+ children: [/* @__PURE__ */ s("rect", {
75
+ width: 6,
76
+ height: 6,
77
+ fill: r,
78
+ fillOpacity: .16
79
+ }), /* @__PURE__ */ s("line", {
80
+ x1: 0,
81
+ y1: 0,
82
+ x2: 0,
83
+ y2: 6,
84
+ stroke: r,
85
+ strokeWidth: 2.5
86
+ })]
87
+ }, n) : /* @__PURE__ */ c("linearGradient", {
88
+ id: `${O}-c${n}`,
89
+ x1: "0",
90
+ y1: "0",
91
+ x2: "0",
92
+ y2: "1",
93
+ children: [/* @__PURE__ */ s("stop", {
94
+ offset: "0%",
95
+ stopColor: r,
96
+ stopOpacity: 1
97
+ }), /* @__PURE__ */ s("stop", {
98
+ offset: "100%",
99
+ stopColor: r,
100
+ stopOpacity: .62
101
+ })]
102
+ }, n);
103
+ }) }),
104
+ P.map((e, t) => /* @__PURE__ */ c("g", { children: [/* @__PURE__ */ s("line", {
105
+ x1: F.left,
106
+ x2: D - F.right,
107
+ y1: B(e),
108
+ y2: B(e),
109
+ className: t === 0 ? "select-chart__axis" : "select-chart__grid"
110
+ }), /* @__PURE__ */ s("text", {
111
+ x: F.left - 8,
112
+ y: B(e),
113
+ className: "select-chart__ylabel",
114
+ dominantBaseline: "middle",
115
+ textAnchor: "end",
116
+ children: p(e)
117
+ })] }, t)),
118
+ d.map((e, t) => {
119
+ let n = F.left + z * t, r = (m ? U : U * A) + (_ ? W + l : 0), i = n + z / 2 - r / 2, a = i + (_ ? W + l : 0), o = _ ? /* @__PURE__ */ s("rect", {
120
+ x: i,
121
+ y: B(M[t] ?? 0),
122
+ width: W,
123
+ height: Math.max(0, R - B(M[t] ?? 0)),
124
+ rx: Math.min(3, W / 2),
125
+ className: "select-chart__compare",
126
+ style: { animationDelay: `${Math.round(t * G)}ms` }
127
+ }) : null;
128
+ if (m) {
129
+ let e = 0;
130
+ return /* @__PURE__ */ c("g", {
131
+ className: _e(t),
132
+ children: [o, u.map((n, r) => {
133
+ let i = (n.data[t] ?? 0) / N * L, o = R - e - i;
134
+ return e += i, i <= 0 ? null : /* @__PURE__ */ s("rect", {
135
+ x: a,
136
+ y: o,
137
+ width: U,
138
+ height: i,
139
+ rx: Math.min(3, U / 2),
140
+ fill: K(n, r),
141
+ ...q(n),
142
+ className: "select-chart__bar",
143
+ style: { animationDelay: `${Math.round(t * G)}ms` }
144
+ }, r);
145
+ })]
146
+ }, t);
147
+ }
111
148
  return /* @__PURE__ */ c("g", {
112
- className: $(t),
113
- children: [o, f.map((n, r) => {
114
- let i = (n.data[t] ?? 0) / P * R, o = z - e - i;
115
- return e += i, i <= 0 ? null : /* @__PURE__ */ s("rect", {
116
- x: a,
117
- y: o,
118
- width: W,
119
- height: i,
120
- rx: Math.min(3, W / 2),
121
- fill: q(n, r),
122
- ...J(n),
149
+ className: _e(t),
150
+ children: [o, u.map((e, n) => {
151
+ let r = (e.data[t] ?? 0) / N * L;
152
+ return /* @__PURE__ */ s("rect", {
153
+ x: a + n * U + U * .1,
154
+ y: R - r,
155
+ width: U * .8,
156
+ height: Math.max(0, r),
157
+ rx: 3,
158
+ fill: K(e, n),
159
+ ...q(e),
123
160
  className: "select-chart__bar",
124
- style: { animationDelay: `${Math.round(t * K)}ms` }
125
- }, r);
161
+ style: { animationDelay: `${Math.round((t + n / A) * G)}ms` }
162
+ }, n);
126
163
  })]
127
164
  }, t);
128
- }
129
- return /* @__PURE__ */ c("g", {
130
- className: $(t),
131
- children: [o, f.map((e, n) => {
132
- let r = (e.data[t] ?? 0) / P * R;
133
- return /* @__PURE__ */ s("rect", {
134
- x: a + n * W + W * .1,
135
- y: z - r,
136
- width: W * .8,
137
- height: Math.max(0, r),
138
- rx: 3,
139
- fill: q(e, n),
140
- ...J(e),
141
- className: "select-chart__bar",
142
- style: { animationDelay: `${Math.round((t + n / j) * K)}ms` }
143
- }, n);
144
- })]
145
- }, t);
146
- }),
147
- Q != null && Q > 0 && /* @__PURE__ */ c("g", {
148
- pointerEvents: "none",
149
- children: [/* @__PURE__ */ s("line", {
150
- x1: I.left,
151
- x2: T - I.right,
152
- y1: V(Q),
153
- y2: V(Q),
154
- className: "select-chart__avg"
155
- }), /* @__PURE__ */ s("text", {
156
- x: I.left + 6,
157
- y: V(Q) - 6,
158
- className: "select-chart__avglabel",
159
- children: `${le} ${h(Q)}`
160
- })]
161
- }),
162
- _ && Y != null && (() => {
163
- let e = I.left + B * Y + (_.edge === "end" ? B : B / 2), t = e > T - I.right - 44;
164
- return /* @__PURE__ */ c("g", {
165
- className: "select-chart__marker",
165
+ }),
166
+ Z != null && Z > 0 && /* @__PURE__ */ c("g", {
166
167
  pointerEvents: "none",
167
168
  children: [/* @__PURE__ */ s("line", {
168
- x1: e,
169
- x2: e,
170
- y1: I.top - 4,
171
- y2: z
172
- }), _.label && /* @__PURE__ */ s("text", {
173
- x: t ? e - 6 : e + 6,
174
- y: I.top + 6,
175
- textAnchor: t ? "end" : "start",
176
- children: _.label
169
+ x1: F.left,
170
+ x2: D - F.right,
171
+ y1: B(Z),
172
+ y2: B(Z),
173
+ className: "select-chart__avg"
174
+ }), /* @__PURE__ */ s("text", {
175
+ x: F.left + 6,
176
+ y: B(Z) - 6,
177
+ className: "select-chart__avglabel",
178
+ children: `${pe} ${p(Z)}`
177
179
  })]
178
- });
179
- })(),
180
- p.map((e, t) => ce(t) ? /* @__PURE__ */ s("text", {
181
- x: I.left + B * t + B / 2,
182
- y: m - I.bottom + 16,
183
- className: "select-chart__xlabel",
184
- textAnchor: "middle",
185
- children: e
186
- }, t) : null),
187
- p.map((e, t) => {
188
- let n = g ? V(M[t] ?? 0) : Math.min(...f.map((e) => V(e.data[t] ?? 0))), r = y ? Math.min(n, V(N[t] ?? 0)) : n;
189
- return /* @__PURE__ */ s("rect", {
190
- x: I.left + B * t,
191
- y: I.top,
192
- width: B,
193
- height: R,
194
- fill: "transparent",
195
- onMouseEnter: () => {
196
- k(t);
197
- let n = ue(t, e);
198
- if (!n) {
199
- E.hide();
200
- return;
201
- }
202
- E.show({
203
- x: I.left + B * t + B / 2,
204
- y: r,
205
- place: r < I.top + 52 ? "bottom" : "top",
206
- title: n.title,
207
- rows: n.rows
208
- });
209
- },
210
- onMouseLeave: () => {
211
- k(null), E.hide();
212
- }
213
- }, `h${t}`);
214
- })
215
- ]
216
- }), /* @__PURE__ */ s(o, { tip: E.tip })]
180
+ }),
181
+ h && J != null && (() => {
182
+ let e = F.left + z * J + (h.edge === "end" ? z : z / 2), t = e > D - F.right - 44;
183
+ return /* @__PURE__ */ c("g", {
184
+ className: "select-chart__marker",
185
+ pointerEvents: "none",
186
+ children: [/* @__PURE__ */ s("line", {
187
+ x1: e,
188
+ x2: e,
189
+ y1: F.top - 4,
190
+ y2: R
191
+ }), h.label && /* @__PURE__ */ s("text", {
192
+ x: t ? e - 6 : e + 6,
193
+ y: F.top + 6,
194
+ textAnchor: t ? "end" : "start",
195
+ children: h.label
196
+ })]
197
+ });
198
+ })(),
199
+ d.map((e, t) => fe(t) ? /* @__PURE__ */ s("text", {
200
+ x: F.left + z * t + z / 2,
201
+ y: f - F.bottom + 16,
202
+ className: "select-chart__xlabel",
203
+ textAnchor: "middle",
204
+ children: e
205
+ }, t) : null),
206
+ /* @__PURE__ */ s("rect", {
207
+ x: F.left,
208
+ y: F.top,
209
+ width: I,
210
+ height: L,
211
+ fill: "transparent"
212
+ })
213
+ ]
214
+ }),
215
+ /* @__PURE__ */ s(o, { tip: $ && Q != null ? {
216
+ x: F.left + z * Q + z / 2,
217
+ y: ge(Q),
218
+ place: ge(Q) < F.top + 52 ? "bottom" : "top",
219
+ title: $.title,
220
+ rows: $.rows
221
+ } : null }),
222
+ y != null && /* @__PURE__ */ s("span", {
223
+ className: "select-visually-hidden",
224
+ "aria-live": "polite",
225
+ children: $ ? ee($.title, $.rows) : ""
226
+ }),
227
+ y != null && C != null && /* @__PURE__ */ c("table", {
228
+ className: "select-visually-hidden",
229
+ children: [
230
+ /* @__PURE__ */ s("caption", { children: y }),
231
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
232
+ scope: "col",
233
+ children: C
234
+ }), u.map((e, t) => /* @__PURE__ */ s("th", {
235
+ scope: "col",
236
+ children: e.name
237
+ }, t))] }) }),
238
+ /* @__PURE__ */ s("tbody", { children: d.map((e, t) => /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
239
+ scope: "row",
240
+ children: (b == null ? void 0 : b[t]) ?? e
241
+ }), u.map((e, n) => /* @__PURE__ */ s("td", { children: x(e.data[t] ?? 0) }, n))] }, t)) })
242
+ ]
243
+ })
244
+ ]
217
245
  });
218
246
  }
219
247
  //#endregion
220
- export { f as SelectColumnChart };
248
+ export { u as SelectColumnChart };
221
249
 
222
250
  //# sourceMappingURL=SelectColumnChart.js.map
@@ -0,0 +1,19 @@
1
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ import { SelectColumnTooltip } from './SelectColumnChart';
3
+ type SelectSparkBarsOwnProps = {
4
+ data: number[];
5
+ /** A altura das barras, em px (padrão 96). */
6
+ height?: number;
7
+ color?: string;
8
+ /** Os rótulos embaixo, espalhados ("12/10", "19/10", "25/10"). */
9
+ labels?: ReactNode[];
10
+ /** O nome do gráfico: com ele, o gráfico entra no Tab e anda pelas setas. */
11
+ label?: string;
12
+ /** A dica de cada barra (o título e as linhas); `null` para nenhuma. */
13
+ tooltip?: (index: number) => SelectColumnTooltip | null;
14
+ /** A barra que o foco do teclado acende primeiro (padrão: a última). */
15
+ start?: number;
16
+ };
17
+ export type SelectSparkBarsProps = SelectSparkBarsOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectSparkBarsOwnProps>;
18
+ export declare function SelectSparkBars({ data, height, color, labels, label, tooltip, start, className, ...rest }: SelectSparkBarsProps): import("react").JSX.Element;
19
+ export {};
@@ -0,0 +1,98 @@
1
+ /* empty css */
2
+ import { chartColor as e, useChartSize as t } from "./chartUtils.js";
3
+ import { FloatingChartTooltip as n } from "./chartTip.js";
4
+ import { tipSpeech as r, useChartPointer as i } from "./internal/chartPointer.js";
5
+ import { useId as a, useReducer as o } from "react";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ //#region src/SelectSparkBars.tsx
8
+ function l({ data: l, height: u = 96, color: d, labels: f, label: p, tooltip: m, start: h, className: g, ..._ }) {
9
+ var v;
10
+ let { ref: y, width: b } = t(u), x = a(), [, S] = o((e) => e + 1, 0), C = d ?? e(0), w = l.length, T = Math.max(...l, 1), E = w > 0 && b > 0 ? Math.min(12, Math.max(1.5, (b - (w > 60 ? 1.5 : 3) * (w - 1)) / w)) : 0, D = w > 1 ? (b - E * w) / (w - 1) : 0, O = (e) => e * (E + D), k = (e) => u - e / T * (u - 8), { active: A, props: j } = i({
11
+ count: w,
12
+ indexAt: (e) => Math.floor((e + D / 2) / (E + D || 1)),
13
+ start: h,
14
+ focusable: p != null
15
+ }), M = A != null && m ? m(A) : null, N = M && A != null ? (v = y.current) == null ? void 0 : v.getBoundingClientRect() : void 0, P = A == null ? 0 : k(l[A] ?? 0), F = N != null && N.top + P < 96, I = w - 1;
16
+ return /* @__PURE__ */ c("div", {
17
+ ..._,
18
+ ref: y,
19
+ className: `select-sparkbars${g ? " " + g : ""}`,
20
+ children: [
21
+ b > 0 && w > 0 && /* @__PURE__ */ c("svg", {
22
+ width: b,
23
+ height: u,
24
+ className: "select-chart",
25
+ ...p == null ? { "aria-hidden": !0 } : {
26
+ role: "img",
27
+ "aria-label": p
28
+ },
29
+ ...j,
30
+ children: [
31
+ /* @__PURE__ */ s("defs", { children: /* @__PURE__ */ c("linearGradient", {
32
+ id: `${x}-glow`,
33
+ x1: "0",
34
+ y1: "0",
35
+ x2: "0",
36
+ y2: "1",
37
+ children: [/* @__PURE__ */ s("stop", {
38
+ offset: "0%",
39
+ stopColor: C,
40
+ stopOpacity: .16
41
+ }), /* @__PURE__ */ s("stop", {
42
+ offset: "100%",
43
+ stopColor: C,
44
+ stopOpacity: 0
45
+ })]
46
+ }) }),
47
+ /* @__PURE__ */ s("rect", {
48
+ x: 0,
49
+ y: k(T) - 4,
50
+ width: O(I) + E,
51
+ height: u - k(T) + 4,
52
+ rx: 6,
53
+ fill: `url(#${x}-glow)`
54
+ }),
55
+ l.map((e, t) => /* @__PURE__ */ s("rect", {
56
+ className: `select-sparkbars__bar${A != null && A !== t ? " is-dim" : ""}`,
57
+ x: O(t),
58
+ y: k(e),
59
+ width: E,
60
+ height: u - k(e),
61
+ rx: E > 3 ? 1.5 : 0,
62
+ fill: C
63
+ }, t)),
64
+ /* @__PURE__ */ s("circle", {
65
+ className: "select-sparkbars__end",
66
+ cx: O(I) + E / 2,
67
+ cy: k(l[I] ?? 0) - 5,
68
+ r: 4,
69
+ fill: C
70
+ })
71
+ ]
72
+ }),
73
+ f != null && f.length > 0 && /* @__PURE__ */ s("div", {
74
+ className: "select-sparkbars__labels",
75
+ children: f.map((e, t) => /* @__PURE__ */ s("span", { children: e }, t))
76
+ }),
77
+ p != null && /* @__PURE__ */ s("span", {
78
+ className: "select-visually-hidden",
79
+ "aria-live": "polite",
80
+ children: M ? r(M.title, M.rows) : ""
81
+ }),
82
+ /* @__PURE__ */ s(n, {
83
+ tip: M && N && A != null ? {
84
+ x: N.left + O(A) + E / 2,
85
+ y: F ? N.top + u + 2 : N.top + P - 6,
86
+ place: F ? "bottom" : "top",
87
+ title: M.title,
88
+ rows: M.rows
89
+ } : null,
90
+ onDismiss: S
91
+ })
92
+ ]
93
+ });
94
+ }
95
+ //#endregion
96
+ export { l as SelectSparkBars };
97
+
98
+ //# sourceMappingURL=SelectSparkBars.js.map
@@ -3,6 +3,8 @@ export interface ChartTipRow {
3
3
  label: ReactNode;
4
4
  value: ReactNode;
5
5
  color?: string;
6
+ /** 0.1.219: a linha da soma (sem o ponto, com o fio acima). */
7
+ total?: boolean;
6
8
  }
7
9
  export interface ChartTipState {
8
10
  x: number;
package/dist/index.d.ts CHANGED
@@ -148,6 +148,7 @@ export type { SelectNumberedListProps, SelectNumberedItemProps } from './SelectN
148
148
  export type { SelectAssistantProps, SelectAssistantSuggestion, SelectChatMessageProps, SelectChatTurnProps, SelectChatTypingProps } from './SelectAssistant';
149
149
  export { SelectChartCard } from './SelectChartCard';
150
150
  export { SelectSparkline } from './SelectSparkline';
151
+ export { SelectSparkBars } from './SelectSparkBars';
151
152
  export { SelectBarChart } from './SelectBarChart';
152
153
  export { SelectLineChart } from './SelectLineChart';
153
154
  export { SelectStackedArea } from './SelectStackedArea';
@@ -317,6 +318,7 @@ export type { SelectFilterDef } from './SelectFilterBar';
317
318
  export type { SelectTagOption } from './SelectTagSelect';
318
319
  export type { SelectChartSeries, SelectBarDatum, SelectDonutSegment, SelectFunnelStage } from './chartUtils';
319
320
  export type { SelectColumnChartProps, SelectColumnTooltip } from './SelectColumnChart';
321
+ export type { SelectSparkBarsProps } from './SelectSparkBars';
320
322
  export type { SelectChartLegendProps, SelectChartLegendItem } from './SelectChartLegend';
321
323
  export type { SelectShareBarProps, SelectShareItem } from './SelectShareBar';
322
324
  export type { SelectChartTipRow } from './SelectChartTipRows';