@selectwin/kit 0.1.217 → 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.
- package/dist/SelectChartTipRows.d.ts +13 -0
- package/dist/SelectChartTipRows.js +31 -0
- package/dist/SelectGauge.d.ts +8 -1
- package/dist/SelectGauge.js +47 -37
- package/dist/SelectShareBar.d.ts +8 -1
- package/dist/SelectShareBar.js +99 -60
- package/dist/SelectTooltip.d.ts +6 -1
- package/dist/SelectTooltip.js +37 -37
- package/dist/chartTip.js +29 -44
- package/dist/index.d.ts +2 -0
- package/dist/index.js +90 -89
- package/dist/style.css +1 -1
- package/package.json +67 -67
|
@@ -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
|
package/dist/SelectGauge.d.ts
CHANGED
|
@@ -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>>;
|
package/dist/SelectGauge.js
CHANGED
|
@@ -1,74 +1,84 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
7
|
+
function a(e) {
|
|
7
8
|
return Number.isFinite(e) ? Math.max(0, Math.min(100, e)) : 0;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
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
|
|
14
|
-
let [
|
|
15
|
-
return `M ${
|
|
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
|
|
18
|
-
let
|
|
19
|
-
value:
|
|
20
|
-
format:
|
|
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__ */
|
|
23
|
-
ref:
|
|
24
|
-
...
|
|
25
|
-
className: `select-gauge${
|
|
26
|
-
style: { width: `${
|
|
27
|
-
children: [/* @__PURE__ */
|
|
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: `${
|
|
37
|
+
aspectRatio: `${u} / ${T}`
|
|
32
38
|
},
|
|
33
|
-
|
|
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 ${
|
|
46
|
+
viewBox: `0 0 ${u} ${T}`,
|
|
37
47
|
className: "select-chart",
|
|
38
48
|
"aria-hidden": "true",
|
|
39
|
-
children: [/* @__PURE__ */
|
|
49
|
+
children: [/* @__PURE__ */ r("path", {
|
|
40
50
|
className: "select-gauge__track",
|
|
41
|
-
d:
|
|
51
|
+
d: s(C, w, S, 0, 1),
|
|
42
52
|
fill: "none",
|
|
43
|
-
strokeWidth:
|
|
53
|
+
strokeWidth: b,
|
|
44
54
|
strokeLinecap: "round"
|
|
45
|
-
}),
|
|
55
|
+
}), y > 0 && /* @__PURE__ */ r("path", {
|
|
46
56
|
className: "select-gauge__arc",
|
|
47
|
-
d:
|
|
57
|
+
d: s(C, w, S, 0, y / 100),
|
|
48
58
|
fill: "none",
|
|
49
|
-
stroke:
|
|
50
|
-
strokeWidth:
|
|
59
|
+
stroke: f ?? "var(--select-chart-1)",
|
|
60
|
+
strokeWidth: b,
|
|
51
61
|
strokeLinecap: "round",
|
|
52
62
|
pathLength: 1
|
|
53
63
|
})]
|
|
54
|
-
}), /* @__PURE__ */
|
|
64
|
+
}), /* @__PURE__ */ i("div", {
|
|
55
65
|
className: "select-gauge__center",
|
|
56
|
-
children: [/* @__PURE__ */
|
|
66
|
+
children: [/* @__PURE__ */ r("span", {
|
|
57
67
|
className: "select-gauge__value",
|
|
58
|
-
ref:
|
|
59
|
-
children:
|
|
60
|
-
}),
|
|
68
|
+
ref: E,
|
|
69
|
+
children: p(y)
|
|
70
|
+
}), o != null && /* @__PURE__ */ r("span", {
|
|
61
71
|
className: "select-gauge__label",
|
|
62
|
-
children:
|
|
72
|
+
children: o
|
|
63
73
|
})]
|
|
64
74
|
})]
|
|
65
|
-
}),
|
|
75
|
+
})), l != null && /* @__PURE__ */ r("div", {
|
|
66
76
|
className: "select-gauge__caption",
|
|
67
|
-
children:
|
|
77
|
+
children: l
|
|
68
78
|
})]
|
|
69
79
|
});
|
|
70
80
|
});
|
|
71
81
|
//#endregion
|
|
72
|
-
export {
|
|
82
|
+
export { l as SelectGauge };
|
|
73
83
|
|
|
74
84
|
//# sourceMappingURL=SelectGauge.js.map
|
package/dist/SelectShareBar.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/SelectShareBar.js
CHANGED
|
@@ -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 {
|
|
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
|
|
7
|
-
let
|
|
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),
|
|
12
|
-
if (
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
19
|
-
e.count != null && /* @__PURE__ */ i
|
|
20
|
-
e.valueText != null && /* @__PURE__ */ i
|
|
21
|
-
|
|
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__ */
|
|
25
|
-
|
|
41
|
+
e.tip != null && /* @__PURE__ */ a("span", { children: e.tip }),
|
|
42
|
+
n != null && /* @__PURE__ */ a("span", {
|
|
26
43
|
className: "select-sharebar__tipaction",
|
|
27
|
-
children:
|
|
44
|
+
children: n
|
|
28
45
|
})
|
|
29
46
|
]
|
|
30
47
|
});
|
|
31
|
-
},
|
|
48
|
+
}, I = (t, n) => t == null ? n : /* @__PURE__ */ a(e, {
|
|
32
49
|
content: t,
|
|
33
50
|
children: n
|
|
34
51
|
});
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
...
|
|
37
|
-
className: `select-sharebar select-sharebar--${
|
|
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
|
-
(
|
|
56
|
+
(c != null || l != null) && /* @__PURE__ */ o("div", {
|
|
40
57
|
className: "select-sharebar__head",
|
|
41
|
-
children: [/* @__PURE__ */
|
|
58
|
+
children: [/* @__PURE__ */ a("span", { children: c }), l != null && /* @__PURE__ */ a("span", { children: l })]
|
|
42
59
|
}),
|
|
43
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ a("div", {
|
|
61
|
+
ref: D,
|
|
44
62
|
className: "select-sharebar__track",
|
|
45
|
-
role:
|
|
46
|
-
"aria-label":
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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${
|
|
81
|
+
className: `select-sharebar__seg select-sharebar__seg--btn${k(t.key) ? " is-dim" : ""}`,
|
|
52
82
|
style: {
|
|
53
|
-
width: `${t.value /
|
|
83
|
+
width: `${t.value / w * 100}%`,
|
|
54
84
|
background: t.color
|
|
55
85
|
},
|
|
56
|
-
"aria-label": `${t.label}: ${
|
|
57
|
-
"aria-pressed":
|
|
58
|
-
onClick: () =>
|
|
59
|
-
}) : /* @__PURE__ */
|
|
60
|
-
className: `select-sharebar__seg${
|
|
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 /
|
|
92
|
+
width: `${t.value / w * 100}%`,
|
|
63
93
|
background: t.color
|
|
64
94
|
}
|
|
65
95
|
})
|
|
66
96
|
}, t.key))
|
|
67
97
|
}),
|
|
68
|
-
|
|
98
|
+
u === "chips" ? /* @__PURE__ */ a("ul", {
|
|
69
99
|
className: "select-sharebar__chips",
|
|
70
|
-
children:
|
|
71
|
-
let t = /* @__PURE__ */ i
|
|
72
|
-
/* @__PURE__ */
|
|
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__ */
|
|
107
|
+
/* @__PURE__ */ a("span", {
|
|
78
108
|
className: "select-sharebar__label",
|
|
79
109
|
children: e.label
|
|
80
110
|
}),
|
|
81
|
-
e.count != null && /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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${
|
|
93
|
-
"aria-pressed":
|
|
94
|
-
onClick: () =>
|
|
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__ */
|
|
126
|
+
}) : /* @__PURE__ */ a("span", {
|
|
97
127
|
className: "select-sharebar__chip",
|
|
98
128
|
children: t
|
|
99
129
|
})) }, e.key);
|
|
100
130
|
})
|
|
101
|
-
}) : /* @__PURE__ */
|
|
102
|
-
className:
|
|
103
|
-
children:
|
|
104
|
-
className:
|
|
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__ */
|
|
140
|
+
/* @__PURE__ */ a("span", {
|
|
107
141
|
className: "select-sharebar__dot",
|
|
108
142
|
style: { background: e.color },
|
|
109
143
|
"aria-hidden": "true"
|
|
110
144
|
}),
|
|
111
|
-
|
|
145
|
+
I(e.tip == null ? null : /* @__PURE__ */ a("span", {
|
|
112
146
|
className: "select-sharebar__tip",
|
|
113
147
|
children: e.tip
|
|
114
|
-
}), /* @__PURE__ */
|
|
148
|
+
}), /* @__PURE__ */ a("span", {
|
|
115
149
|
className: "select-sharebar__label",
|
|
116
150
|
children: e.label
|
|
117
151
|
})),
|
|
118
|
-
e.valueText != null && /* @__PURE__ */
|
|
152
|
+
e.valueText != null && /* @__PURE__ */ a("span", {
|
|
119
153
|
className: "select-sharebar__value",
|
|
120
154
|
children: e.valueText
|
|
121
155
|
}),
|
|
122
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ o("span", {
|
|
123
157
|
className: "select-sharebar__pct",
|
|
124
|
-
children: [
|
|
158
|
+
children: [O(e.value), "%"]
|
|
125
159
|
})
|
|
126
160
|
]
|
|
127
161
|
}, e.key))
|
|
128
162
|
}),
|
|
129
|
-
|
|
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:
|
|
170
|
+
children: m
|
|
132
171
|
})
|
|
133
172
|
]
|
|
134
173
|
});
|
|
135
174
|
}
|
|
136
175
|
//#endregion
|
|
137
|
-
export {
|
|
176
|
+
export { s as SelectShareBar };
|
|
138
177
|
|
|
139
178
|
//# sourceMappingURL=SelectShareBar.js.map
|
package/dist/SelectTooltip.d.ts
CHANGED
|
@@ -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;
|
package/dist/SelectTooltip.js
CHANGED
|
@@ -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 [
|
|
19
|
-
d() && (
|
|
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
|
-
|
|
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
|
-
|
|
26
|
+
A.current && clearTimeout(A.current);
|
|
27
27
|
}, []);
|
|
28
|
-
let
|
|
28
|
+
let L = t(() => {
|
|
29
29
|
var t;
|
|
30
|
-
let n = ((t =
|
|
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
|
-
|
|
36
|
+
M({
|
|
37
37
|
top: i.top,
|
|
38
38
|
left: i.left
|
|
39
39
|
});
|
|
40
40
|
}, [h]);
|
|
41
41
|
return i(() => {
|
|
42
|
-
if (!
|
|
43
|
-
|
|
42
|
+
if (!D) {
|
|
43
|
+
M(null);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
if (!
|
|
49
|
-
let e = () =>
|
|
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
|
-
}, [
|
|
54
|
-
if (!
|
|
53
|
+
}, [D, L]), n(() => {
|
|
54
|
+
if (!D) return;
|
|
55
55
|
let e = (e) => {
|
|
56
|
-
e.key === "Escape" && (
|
|
56
|
+
e.key === "Escape" && (w(!1), S(!1));
|
|
57
57
|
};
|
|
58
58
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
59
|
-
}, [
|
|
60
|
-
if (!
|
|
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 =
|
|
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
|
-
}, [
|
|
67
|
+
}, [C]), /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
|
|
68
68
|
className: "select-tip__trigger",
|
|
69
|
-
ref:
|
|
70
|
-
onMouseEnter:
|
|
71
|
-
onMouseLeave:
|
|
69
|
+
ref: O,
|
|
70
|
+
onMouseEnter: P,
|
|
71
|
+
onMouseLeave: F,
|
|
72
72
|
onFocusCapture: (e) => {
|
|
73
|
-
f(e.target) &&
|
|
73
|
+
f(e.target) && S(!0);
|
|
74
74
|
},
|
|
75
|
-
onBlurCapture:
|
|
76
|
-
onClick: _ ?
|
|
75
|
+
onBlurCapture: F,
|
|
76
|
+
onClick: _ ? I : void 0,
|
|
77
77
|
tabIndex: y ? 0 : void 0,
|
|
78
|
-
"aria-describedby":
|
|
78
|
+
"aria-describedby": D ? N : void 0,
|
|
79
79
|
children: m
|
|
80
|
-
}),
|
|
81
|
-
ref:
|
|
82
|
-
id:
|
|
80
|
+
}), D && u(/* @__PURE__ */ c("div", {
|
|
81
|
+
ref: k,
|
|
82
|
+
id: N,
|
|
83
83
|
role: "tooltip",
|
|
84
|
-
className: `select select-tip${
|
|
85
|
-
style:
|
|
84
|
+
className: `select select-tip${C ? " select-tip--pinned" : ""}`,
|
|
85
|
+
style: j ? {
|
|
86
86
|
position: "fixed",
|
|
87
|
-
top:
|
|
88
|
-
left:
|
|
87
|
+
top: j.top,
|
|
88
|
+
left: j.left
|
|
89
89
|
} : {
|
|
90
90
|
position: "fixed",
|
|
91
91
|
top: 0,
|