@selectwin/kit 0.1.216 → 0.1.218

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.
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SelectChartTipRow {
3
+ label: ReactNode;
4
+ value: ReactNode;
5
+ /** A cor da série ou da parte (o ponto à esquerda). */
6
+ color?: string;
7
+ /** A linha da soma: sem o ponto, com o espaço dele. */
8
+ total?: boolean;
9
+ }
10
+ export declare function SelectChartTipRows({ title, rows }: {
11
+ title?: ReactNode;
12
+ rows: readonly SelectChartTipRow[];
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ /* empty css */
2
+ import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ //#region src/SelectChartTipRows.tsx
4
+ function r({ title: r, rows: i }) {
5
+ let a = i.some((e) => e.color != null);
6
+ return /* @__PURE__ */ n(e, { children: [r != null && /* @__PURE__ */ t("span", {
7
+ className: "select-chart__tiptitle",
8
+ children: r
9
+ }), i.map((e, r) => /* @__PURE__ */ n("span", {
10
+ className: `select-chart__tiprow${e.total ? " select-chart__tiprow--total" : ""}`,
11
+ children: [
12
+ a && /* @__PURE__ */ t("span", {
13
+ className: "select-chart__tipdot",
14
+ style: e.color != null && !e.total ? { background: e.color } : { visibility: "hidden" },
15
+ "aria-hidden": "true"
16
+ }),
17
+ /* @__PURE__ */ t("span", {
18
+ className: "select-chart__tiplabel",
19
+ children: e.label
20
+ }),
21
+ /* @__PURE__ */ t("span", {
22
+ className: "select-chart__tipval",
23
+ children: e.value
24
+ })
25
+ ]
26
+ }, r))] });
27
+ }
28
+ //#endregion
29
+ export { r as SelectChartTipRows };
30
+
31
+ //# sourceMappingURL=SelectChartTipRows.js.map
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithoutRef } from 'react';
1
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
2
  type SelectGaugeOwnProps = {
3
3
  /** Percentage 0–100 (drives the arc sweep). */
4
4
  value: number;
@@ -12,6 +12,13 @@ type SelectGaugeOwnProps = {
12
12
  color?: string;
13
13
  /** Format the center number (default "NN%"). */
14
14
  format?: (n: number) => string;
15
+ /**
16
+ * 0.1.218: os números por trás da proporção ("1.204 entregues · 3 a caminho"), numa dica que abre no mouse, no foco do
17
+ * teclado (o medidor entra na ordem do Tab) e no toque, e fecha no Esc. Para quem lê tela, é a descrição do medidor.
18
+ */
19
+ tip?: ReactNode;
20
+ /** 0.1.218: o nome do medidor para o leitor de tela ("98% entregues"); padrão: o número e o `label`. */
21
+ ariaLabel?: string;
15
22
  };
16
23
  export type SelectGaugeProps = SelectGaugeOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectGaugeOwnProps>;
17
24
  export declare const SelectGauge: import('react').ForwardRefExoticComponent<SelectGaugeOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectGaugeOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,74 +1,84 @@
1
1
  /* empty css */
2
- import { useCountUp as e } from "./internal/useSelectReveal.js";
3
- import { forwardRef as t } from "react";
4
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
2
+ import { SelectTooltip as e } from "./SelectTooltip.js";
3
+ import { useCountUp as t } from "./internal/useSelectReveal.js";
4
+ import { forwardRef as n } from "react";
5
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
6
  //#region src/SelectGauge.tsx
6
- function i(e) {
7
+ function a(e) {
7
8
  return Number.isFinite(e) ? Math.max(0, Math.min(100, e)) : 0;
8
9
  }
9
- function a(e, t, n, r) {
10
+ function o(e, t, n, r) {
10
11
  let i = Math.PI + r * Math.PI;
11
12
  return [e + n * Math.cos(i), t + n * Math.sin(i)];
12
13
  }
13
- function o(e, t, n, r, i) {
14
- let [o, s] = a(e, t, n, r), [c, l] = a(e, t, n, i);
15
- return `M ${o.toFixed(2)} ${s.toFixed(2)} A ${n} ${n} 0 0 1 ${c.toFixed(2)} ${l.toFixed(2)}`;
14
+ function s(e, t, n, r, i) {
15
+ let [a, s] = o(e, t, n, r), [c, l] = o(e, t, n, i);
16
+ return `M ${a.toFixed(2)} ${s.toFixed(2)} A ${n} ${n} 0 0 1 ${c.toFixed(2)} ${l.toFixed(2)}`;
16
17
  }
17
- var s = (e) => `${e.toLocaleString("pt-BR", { maximumFractionDigits: +(e < 10) })}%`, c = t(function({ value: t, label: a, caption: c, size: l = 220, thickness: u, color: d, format: f = s, className: p, ...m }, h) {
18
- let g = i(t), _ = u ?? Math.max(8, Math.round(l * .075)), v = _ / 2 + 2, y = l / 2 - v, b = l / 2, x = l / 2, S = x + v, C = e({
19
- value: g,
20
- format: f
18
+ var c = (e) => `${e.toLocaleString("pt-BR", { maximumFractionDigits: +(e < 10) })}%`, l = n(function({ value: n, label: o, caption: l, size: u = 220, thickness: d, color: f, format: p = c, tip: m, ariaLabel: h, className: g, ..._ }, v) {
19
+ let y = a(n), b = d ?? Math.max(8, Math.round(u * .075)), x = b / 2 + 2, S = u / 2 - x, C = u / 2, w = u / 2, T = w + x, E = t({
20
+ value: y,
21
+ format: p
22
+ }), D = (t) => m == null ? t : /* @__PURE__ */ r(e, {
23
+ content: m,
24
+ focusable: !0,
25
+ openOnClick: !0,
26
+ children: t
21
27
  });
22
- return /* @__PURE__ */ r("div", {
23
- ref: h,
24
- ...m,
25
- className: `select-gauge${p ? " " + p : ""}`,
26
- style: { width: `${l / 16}rem` },
27
- children: [/* @__PURE__ */ r("div", {
28
+ return /* @__PURE__ */ i("div", {
29
+ ref: v,
30
+ ..._,
31
+ className: `select-gauge${g ? " " + g : ""}`,
32
+ style: { width: `${u / 16}rem` },
33
+ children: [D(/* @__PURE__ */ i("div", {
28
34
  className: "select-gauge__ring",
29
35
  style: {
30
36
  width: "100%",
31
- aspectRatio: `${l} / ${S}`
37
+ aspectRatio: `${u} / ${T}`
32
38
  },
33
- children: [/* @__PURE__ */ r("svg", {
39
+ ...m == null ? {} : {
40
+ role: "img",
41
+ "aria-label": h ?? [p(y), o].filter(Boolean).join(" ")
42
+ },
43
+ children: [/* @__PURE__ */ i("svg", {
34
44
  width: "100%",
35
45
  height: "100%",
36
- viewBox: `0 0 ${l} ${S}`,
46
+ viewBox: `0 0 ${u} ${T}`,
37
47
  className: "select-chart",
38
48
  "aria-hidden": "true",
39
- children: [/* @__PURE__ */ n("path", {
49
+ children: [/* @__PURE__ */ r("path", {
40
50
  className: "select-gauge__track",
41
- d: o(b, x, y, 0, 1),
51
+ d: s(C, w, S, 0, 1),
42
52
  fill: "none",
43
- strokeWidth: _,
53
+ strokeWidth: b,
44
54
  strokeLinecap: "round"
45
- }), g > 0 && /* @__PURE__ */ n("path", {
55
+ }), y > 0 && /* @__PURE__ */ r("path", {
46
56
  className: "select-gauge__arc",
47
- d: o(b, x, y, 0, g / 100),
57
+ d: s(C, w, S, 0, y / 100),
48
58
  fill: "none",
49
- stroke: d ?? "var(--select-chart-1)",
50
- strokeWidth: _,
59
+ stroke: f ?? "var(--select-chart-1)",
60
+ strokeWidth: b,
51
61
  strokeLinecap: "round",
52
62
  pathLength: 1
53
63
  })]
54
- }), /* @__PURE__ */ r("div", {
64
+ }), /* @__PURE__ */ i("div", {
55
65
  className: "select-gauge__center",
56
- children: [/* @__PURE__ */ n("span", {
66
+ children: [/* @__PURE__ */ r("span", {
57
67
  className: "select-gauge__value",
58
- ref: C,
59
- children: f(g)
60
- }), a != null && /* @__PURE__ */ n("span", {
68
+ ref: E,
69
+ children: p(y)
70
+ }), o != null && /* @__PURE__ */ r("span", {
61
71
  className: "select-gauge__label",
62
- children: a
72
+ children: o
63
73
  })]
64
74
  })]
65
- }), c != null && /* @__PURE__ */ n("div", {
75
+ })), l != null && /* @__PURE__ */ r("div", {
66
76
  className: "select-gauge__caption",
67
- children: c
77
+ children: l
68
78
  })]
69
79
  });
70
80
  });
71
81
  //#endregion
72
- export { c as SelectGauge };
82
+ export { l as SelectGauge };
73
83
 
74
84
  //# sourceMappingURL=SelectGauge.js.map
@@ -31,7 +31,14 @@ type SelectShareBarOwnProps = {
31
31
  selectHint?: ReactNode;
32
32
  /** A mesma linha na parte escolhida. Padrão: "Clique de novo para ver todas." */
33
33
  clearHint?: ReactNode;
34
+ /**
35
+ * 0.1.218: a legenda mostra também as partes em zero ("Falharam · 0 · 0%"), para quem acompanha um lote ver que nada
36
+ * falhou. A barra segue só com as partes que existem.
37
+ */
38
+ showEmpty?: boolean;
39
+ /** 0.1.218: o nome do gráfico para quem lê tela ("Status das 1.240 mensagens"), antes das partes. */
40
+ ariaLabel?: string;
34
41
  };
35
42
  export type SelectShareBarProps = SelectShareBarOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectShareBarOwnProps>;
36
- export declare function SelectShareBar({ items, label, aside, legend, size, onSelect, selected, hint, selectHint, clearHint, className, ...rest }: SelectShareBarProps): import("react").JSX.Element | null;
43
+ export declare function SelectShareBar({ items, label, aside, legend, size, onSelect, selected, hint, selectHint, clearHint, showEmpty, ariaLabel, className, ...rest }: SelectShareBarProps): import("react").JSX.Element | null;
37
44
  export {};
@@ -1,139 +1,178 @@
1
1
  /* empty css */
2
2
  import { SelectTooltip as e } from "./SelectTooltip.js";
3
3
  import { chartColor as t } from "./chartUtils.js";
4
- import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import { useRef as n, useState as r } from "react";
5
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
5
6
  //#region src/SelectShareBar.tsx
6
- function a({ items: a, label: o, aside: s, legend: c = "list", size: l = "sm", onSelect: u, selected: d, hint: f, selectHint: p = "Clique para filtrar.", clearHint: m = "Clique de novo para ver todas.", className: h, ...g }) {
7
- let _ = a.map((e, n) => ({
7
+ function s({ items: s, label: c, aside: l, legend: u = "list", size: d = "sm", onSelect: f, selected: p, hint: m, selectHint: h = "Clique para filtrar.", clearHint: g = "Clique de novo para ver todas.", showEmpty: _ = !1, ariaLabel: v, className: y, ...b }) {
8
+ let x = s.map((e, n) => ({
8
9
  ...e,
9
10
  key: e.key ?? e.label,
10
11
  color: e.color ?? t(n)
11
- })).filter((e) => e.value > 0), v = _.reduce((e, t) => e + t.value, 0);
12
- if (v <= 0) return null;
13
- let y = (e) => Math.round(e / v * 100), b = (e) => d != null && d !== e, x = (e, t) => {
14
- let a = u ? d === e.key ? m : p : null;
15
- return !t && e.tip == null && a == null ? null : /* @__PURE__ */ i("span", {
12
+ })), S = x.filter((e) => e.value > 0), C = _ ? x : S, w = S.reduce((e, t) => e + t.value, 0), [T, E] = r(null), D = n(null);
13
+ if (w <= 0) return null;
14
+ let O = (e) => Math.round(e / w * 100), k = (e) => p != null && p !== e, A = !f && S.length > 0, j = (e) => Math.min(S.length - 1, Math.max(0, e)), M = (e) => {
15
+ var t;
16
+ let n = [...((t = D.current) == null ? void 0 : t.querySelectorAll(".select-sharebar__seg")) ?? []], r = n.findIndex((t) => e <= t.getBoundingClientRect().right + 1);
17
+ return r < 0 ? n.length - 1 : r;
18
+ }, N = (e) => {
19
+ if (e.key === "Escape") {
20
+ E(null);
21
+ return;
22
+ }
23
+ let t = T ?? 0, n = {
24
+ ArrowRight: t + 1,
25
+ ArrowLeft: t - 1,
26
+ Home: 0,
27
+ End: S.length - 1
28
+ }[e.key];
29
+ n !== void 0 && (e.preventDefault(), E(j(n)));
30
+ }, P = T == null ? void 0 : S[T], F = (e, t) => {
31
+ let n = f ? p === e.key ? g : h : null;
32
+ return !t && e.tip == null && n == null ? null : /* @__PURE__ */ o("span", {
16
33
  className: "select-sharebar__tip",
17
34
  children: [
18
- t && /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r("strong", { children: e.label }), /* @__PURE__ */ i("span", { children: [
19
- e.count != null && /* @__PURE__ */ i(n, { children: [e.count, " · "] }),
20
- e.valueText != null && /* @__PURE__ */ i(n, { children: [e.valueText, " · "] }),
21
- y(e.value),
35
+ t && /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("strong", { children: e.label }), /* @__PURE__ */ o("span", { children: [
36
+ e.count != null && /* @__PURE__ */ o(i, { children: [e.count, " · "] }),
37
+ e.valueText != null && /* @__PURE__ */ o(i, { children: [e.valueText, " · "] }),
38
+ O(e.value),
22
39
  "%"
23
40
  ] })] }),
24
- e.tip != null && /* @__PURE__ */ r("span", { children: e.tip }),
25
- a != null && /* @__PURE__ */ r("span", {
41
+ e.tip != null && /* @__PURE__ */ a("span", { children: e.tip }),
42
+ n != null && /* @__PURE__ */ a("span", {
26
43
  className: "select-sharebar__tipaction",
27
- children: a
44
+ children: n
28
45
  })
29
46
  ]
30
47
  });
31
- }, S = (t, n) => t == null ? n : /* @__PURE__ */ r(e, {
48
+ }, I = (t, n) => t == null ? n : /* @__PURE__ */ a(e, {
32
49
  content: t,
33
50
  children: n
34
51
  });
35
- return /* @__PURE__ */ i("div", {
36
- ...g,
37
- className: `select-sharebar select-sharebar--${l}${c === "chips" ? " select-sharebar--chips" : ""}${h ? " " + h : ""}`,
52
+ return /* @__PURE__ */ o("div", {
53
+ ...b,
54
+ className: `select-sharebar select-sharebar--${d}${u === "chips" ? " select-sharebar--chips" : ""}${y ? " " + y : ""}`,
38
55
  children: [
39
- (o != null || s != null) && /* @__PURE__ */ i("div", {
56
+ (c != null || l != null) && /* @__PURE__ */ o("div", {
40
57
  className: "select-sharebar__head",
41
- children: [/* @__PURE__ */ r("span", { children: o }), s != null && /* @__PURE__ */ r("span", { children: s })]
58
+ children: [/* @__PURE__ */ a("span", { children: c }), l != null && /* @__PURE__ */ a("span", { children: l })]
42
59
  }),
43
- /* @__PURE__ */ r("div", {
60
+ /* @__PURE__ */ a("div", {
61
+ ref: D,
44
62
  className: "select-sharebar__track",
45
- role: u ? "group" : "img",
46
- "aria-label": _.map((e) => `${e.label} ${y(e.value)}%`).join(", "),
47
- children: _.map((t) => /* @__PURE__ */ r(e, {
48
- content: x(t, !0),
49
- children: u ? /* @__PURE__ */ r("button", {
63
+ role: f ? "group" : "img",
64
+ "aria-label": [v, S.map((e) => `${e.label} ${O(e.value)}%`).join(", ")].filter(Boolean).join(": "),
65
+ ...A ? {
66
+ tabIndex: 0,
67
+ onKeyDown: N,
68
+ onFocus: () => E((e) => e ?? 0),
69
+ onBlur: () => E(null),
70
+ onPointerMove: (e) => E(M(e.clientX)),
71
+ onPointerDown: (e) => E(M(e.clientX)),
72
+ onPointerLeave: (e) => {
73
+ e.pointerType === "mouse" && E(null);
74
+ }
75
+ } : {},
76
+ children: S.map((t, n) => /* @__PURE__ */ a(e, {
77
+ content: F(t, !0),
78
+ ...A && T != null ? { open: T === n } : {},
79
+ children: f ? /* @__PURE__ */ a("button", {
50
80
  type: "button",
51
- className: `select-sharebar__seg select-sharebar__seg--btn${b(t.key) ? " is-dim" : ""}`,
81
+ className: `select-sharebar__seg select-sharebar__seg--btn${k(t.key) ? " is-dim" : ""}`,
52
82
  style: {
53
- width: `${t.value / v * 100}%`,
83
+ width: `${t.value / w * 100}%`,
54
84
  background: t.color
55
85
  },
56
- "aria-label": `${t.label}: ${y(t.value)}%`,
57
- "aria-pressed": d === t.key,
58
- onClick: () => u(t.key)
59
- }) : /* @__PURE__ */ r("span", {
60
- className: `select-sharebar__seg${b(t.key) ? " is-dim" : ""}`,
86
+ "aria-label": `${t.label}: ${O(t.value)}%`,
87
+ "aria-pressed": p === t.key,
88
+ onClick: () => f(t.key)
89
+ }) : /* @__PURE__ */ a("span", {
90
+ className: `select-sharebar__seg${k(t.key) || T != null && T !== n ? " is-dim" : ""}`,
61
91
  style: {
62
- width: `${t.value / v * 100}%`,
92
+ width: `${t.value / w * 100}%`,
63
93
  background: t.color
64
94
  }
65
95
  })
66
96
  }, t.key))
67
97
  }),
68
- c === "chips" ? /* @__PURE__ */ r("ul", {
98
+ u === "chips" ? /* @__PURE__ */ a("ul", {
69
99
  className: "select-sharebar__chips",
70
- children: _.map((e) => {
71
- let t = /* @__PURE__ */ i(n, { children: [
72
- /* @__PURE__ */ r("span", {
100
+ children: C.map((e) => {
101
+ let t = /* @__PURE__ */ o(i, { children: [
102
+ /* @__PURE__ */ a("span", {
73
103
  className: "select-sharebar__dot",
74
104
  style: { background: e.color },
75
105
  "aria-hidden": "true"
76
106
  }),
77
- /* @__PURE__ */ r("span", {
107
+ /* @__PURE__ */ a("span", {
78
108
  className: "select-sharebar__label",
79
109
  children: e.label
80
110
  }),
81
- e.count != null && /* @__PURE__ */ r("span", {
111
+ e.count != null && /* @__PURE__ */ a("span", {
82
112
  className: "select-sharebar__count",
83
113
  children: e.count
84
114
  }),
85
- e.valueText != null && /* @__PURE__ */ r("span", {
115
+ e.valueText != null && /* @__PURE__ */ a("span", {
86
116
  className: "select-sharebar__chipvalue",
87
117
  children: e.valueText
88
118
  })
89
119
  ] });
90
- return /* @__PURE__ */ r("li", { children: S(x(e, !1), u ? /* @__PURE__ */ r("button", {
120
+ return /* @__PURE__ */ a("li", { children: I(F(e, !1), f ? /* @__PURE__ */ a("button", {
91
121
  type: "button",
92
- className: `select-sharebar__chip select-sharebar__chip--btn${d === e.key ? " is-selected" : ""}${b(e.key) ? " is-dim" : ""}`,
93
- "aria-pressed": d === e.key,
94
- onClick: () => u(e.key),
122
+ className: `select-sharebar__chip select-sharebar__chip--btn${p === e.key ? " is-selected" : ""}${k(e.key) ? " is-dim" : ""}`,
123
+ "aria-pressed": p === e.key,
124
+ onClick: () => f(e.key),
95
125
  children: t
96
- }) : /* @__PURE__ */ r("span", {
126
+ }) : /* @__PURE__ */ a("span", {
97
127
  className: "select-sharebar__chip",
98
128
  children: t
99
129
  })) }, e.key);
100
130
  })
101
- }) : /* @__PURE__ */ r("ul", {
102
- className: "select-sharebar__legend",
103
- children: _.map((e) => /* @__PURE__ */ i("li", {
104
- className: "select-sharebar__item",
131
+ }) : /* @__PURE__ */ a("ul", {
132
+ className: `select-sharebar__legend${P ? " has-active" : ""}`,
133
+ children: C.map((e) => /* @__PURE__ */ o("li", {
134
+ className: `select-sharebar__item${(P == null ? void 0 : P.key) === e.key ? " is-active" : ""}`,
135
+ ...A ? {
136
+ onMouseEnter: () => E(e.value > 0 ? S.indexOf(e) : null),
137
+ onMouseLeave: () => E(null)
138
+ } : {},
105
139
  children: [
106
- /* @__PURE__ */ r("span", {
140
+ /* @__PURE__ */ a("span", {
107
141
  className: "select-sharebar__dot",
108
142
  style: { background: e.color },
109
143
  "aria-hidden": "true"
110
144
  }),
111
- S(e.tip == null ? null : /* @__PURE__ */ r("span", {
145
+ I(e.tip == null ? null : /* @__PURE__ */ a("span", {
112
146
  className: "select-sharebar__tip",
113
147
  children: e.tip
114
- }), /* @__PURE__ */ r("span", {
148
+ }), /* @__PURE__ */ a("span", {
115
149
  className: "select-sharebar__label",
116
150
  children: e.label
117
151
  })),
118
- e.valueText != null && /* @__PURE__ */ r("span", {
152
+ e.valueText != null && /* @__PURE__ */ a("span", {
119
153
  className: "select-sharebar__value",
120
154
  children: e.valueText
121
155
  }),
122
- /* @__PURE__ */ i("span", {
156
+ /* @__PURE__ */ o("span", {
123
157
  className: "select-sharebar__pct",
124
- children: [y(e.value), "%"]
158
+ children: [O(e.value), "%"]
125
159
  })
126
160
  ]
127
161
  }, e.key))
128
162
  }),
129
- f != null && /* @__PURE__ */ r("p", {
163
+ A && /* @__PURE__ */ a("span", {
164
+ className: "select-sharebar__live",
165
+ "aria-live": "polite",
166
+ children: P ? `${P.label}: ${O(P.value)}%` : ""
167
+ }),
168
+ m != null && /* @__PURE__ */ a("p", {
130
169
  className: "select-sharebar__hint",
131
- children: f
170
+ children: m
132
171
  })
133
172
  ]
134
173
  });
135
174
  }
136
175
  //#endregion
137
- export { a as SelectShareBar };
176
+ export { s as SelectShareBar };
138
177
 
139
178
  //# sourceMappingURL=SelectShareBar.js.map
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { SelectPlacement } from './positioning';
3
- export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, focusable, }: {
3
+ export declare function SelectTooltip({ content, children, placement, delay, openOnClick, disabled, focusable, open: openProp, }: {
4
4
  content: ReactNode;
5
5
  children: ReactNode;
6
6
  placement?: SelectPlacement;
@@ -14,4 +14,9 @@ export declare function SelectTooltip({ content, children, placement, delay, ope
14
14
  disabled?: boolean;
15
15
  /** 0.1.215: o embrulho recebe o foco (o filho não é focável): o Tab chega na dica, e ela abre no foco do teclado. */
16
16
  focusable?: boolean;
17
+ /**
18
+ * 0.1.218: o aberto controlado por quem usa (o gráfico que anda pelas partes com as setas acende a dica da parte
19
+ * atual). Com ele, o mouse e o foco não abrem nem fecham sozinhos.
20
+ */
21
+ open?: boolean;
17
22
  }): import("react").JSX.Element;
@@ -14,78 +14,78 @@ function f(e) {
14
14
  return !0;
15
15
  }
16
16
  }
17
- function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1, focusable: y = !1 }) {
18
- let [b, x] = o(!1), [S, C] = o(!1), [w, T] = o(!1), E = !v && (S || b && !w), D = a(null), O = a(null), k = a(null), [A, j] = o(null), M = r(), N = () => {
19
- d() && (k.current && clearTimeout(k.current), k.current = setTimeout(() => x(!0), g));
20
- }, P = () => {
21
- k.current && clearTimeout(k.current), x(!1), T(!1);
17
+ function p({ content: p, children: m, placement: h = "top", delay: g = 250, openOnClick: _ = !1, disabled: v = !1, focusable: y = !1, open: b }) {
18
+ let [x, S] = o(!1), [C, w] = o(!1), [T, E] = o(!1), D = !v && (b ?? (C || x && !T)), O = a(null), k = a(null), A = a(null), [j, M] = o(null), N = r(), P = () => {
19
+ d() && (A.current && clearTimeout(A.current), A.current = setTimeout(() => S(!0), g));
22
20
  }, F = () => {
23
- _ && (k.current && clearTimeout(k.current), E ? (C(!1), x(!1), T(!0)) : C(!0));
21
+ A.current && clearTimeout(A.current), S(!1), E(!1);
22
+ }, I = () => {
23
+ _ && (A.current && clearTimeout(A.current), D ? (w(!1), S(!1), E(!0)) : w(!0));
24
24
  };
25
25
  n(() => () => {
26
- k.current && clearTimeout(k.current);
26
+ A.current && clearTimeout(A.current);
27
27
  }, []);
28
- let I = t(() => {
28
+ let L = t(() => {
29
29
  var t;
30
- let n = ((t = D.current) == null ? void 0 : t.firstElementChild) ?? D.current, r = O.current;
30
+ let n = ((t = O.current) == null ? void 0 : t.firstElementChild) ?? O.current, r = k.current;
31
31
  if (!n || !r) return;
32
32
  let i = e(n.getBoundingClientRect(), {
33
33
  width: r.offsetWidth,
34
34
  height: r.offsetHeight
35
35
  }, h, 6);
36
- j({
36
+ M({
37
37
  top: i.top,
38
38
  left: i.left
39
39
  });
40
40
  }, [h]);
41
41
  return i(() => {
42
- if (!E) {
43
- j(null);
42
+ if (!D) {
43
+ M(null);
44
44
  return;
45
45
  }
46
- I();
47
- }, [E, I]), n(() => {
48
- if (!E) return;
49
- let e = () => I();
46
+ L();
47
+ }, [D, L]), n(() => {
48
+ if (!D) return;
49
+ let e = () => L();
50
50
  return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
51
51
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
52
52
  };
53
- }, [E, I]), n(() => {
54
- if (!E) return;
53
+ }, [D, L]), n(() => {
54
+ if (!D) return;
55
55
  let e = (e) => {
56
- e.key === "Escape" && (C(!1), x(!1));
56
+ e.key === "Escape" && (w(!1), S(!1));
57
57
  };
58
58
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
59
- }, [E]), n(() => {
60
- if (!S) return;
59
+ }, [D]), n(() => {
60
+ if (!C) return;
61
61
  let e = (e) => {
62
62
  var t, n;
63
63
  let r = e.target;
64
- (t = D.current) != null && t.contains(r) || (n = O.current) != null && n.contains(r) || (C(!1), x(!1));
64
+ (t = O.current) != null && t.contains(r) || (n = k.current) != null && n.contains(r) || (w(!1), S(!1));
65
65
  };
66
66
  return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
67
- }, [S]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
67
+ }, [C]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
68
68
  className: "select-tip__trigger",
69
- ref: D,
70
- onMouseEnter: N,
71
- onMouseLeave: P,
69
+ ref: O,
70
+ onMouseEnter: P,
71
+ onMouseLeave: F,
72
72
  onFocusCapture: (e) => {
73
- f(e.target) && x(!0);
73
+ f(e.target) && S(!0);
74
74
  },
75
- onBlurCapture: P,
76
- onClick: _ ? F : void 0,
75
+ onBlurCapture: F,
76
+ onClick: _ ? I : void 0,
77
77
  tabIndex: y ? 0 : void 0,
78
- "aria-describedby": E ? M : void 0,
78
+ "aria-describedby": D ? N : void 0,
79
79
  children: m
80
- }), E && u(/* @__PURE__ */ c("div", {
81
- ref: O,
82
- id: M,
80
+ }), D && u(/* @__PURE__ */ c("div", {
81
+ ref: k,
82
+ id: N,
83
83
  role: "tooltip",
84
- className: `select select-tip${S ? " select-tip--pinned" : ""}`,
85
- style: A ? {
84
+ className: `select select-tip${C ? " select-tip--pinned" : ""}`,
85
+ style: j ? {
86
86
  position: "fixed",
87
- top: A.top,
88
- left: A.left
87
+ top: j.top,
88
+ left: j.left
89
89
  } : {
90
90
  position: "fixed",
91
91
  top: 0,