@plenustech/design-system 0.2.3 → 0.2.4
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/components/charts/ChartGauge/ChartGauge.cjs +2 -0
- package/dist/components/charts/ChartGauge/ChartGauge.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/ChartGauge.js +307 -0
- package/dist/components/charts/ChartGauge/ChartGauge.js.map +1 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.cjs +2 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.js +76 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.js.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.cjs +2 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.js +107 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.js.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeReading.cjs +2 -0
- package/dist/components/charts/ChartGauge/gaugeReading.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeReading.js +112 -0
- package/dist/components/charts/ChartGauge/gaugeReading.js.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeScale.cjs +2 -0
- package/dist/components/charts/ChartGauge/gaugeScale.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeScale.js +57 -0
- package/dist/components/charts/ChartGauge/gaugeScale.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMap.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.js +523 -0
- package/dist/components/charts/ChartMap/ChartMap.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.js +124 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.js +102 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapTable.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMapTable.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapTable.js +118 -0
- package/dist/components/charts/ChartMap/ChartMapTable.js.map +1 -0
- package/dist/components/charts/ChartMap/mapGeometry.cjs +2 -0
- package/dist/components/charts/ChartMap/mapGeometry.cjs.map +1 -0
- package/dist/components/charts/ChartMap/mapGeometry.js +113 -0
- package/dist/components/charts/ChartMap/mapGeometry.js.map +1 -0
- package/dist/components/charts/ChartMap/mapLabels.cjs +2 -0
- package/dist/components/charts/ChartMap/mapLabels.cjs.map +1 -0
- package/dist/components/charts/ChartMap/mapLabels.js +80 -0
- package/dist/components/charts/ChartMap/mapLabels.js.map +1 -0
- package/dist/components/charts/ChartMap/mapScales.cjs +2 -0
- package/dist/components/charts/ChartMap/mapScales.cjs.map +1 -0
- package/dist/components/charts/ChartMap/mapScales.js +131 -0
- package/dist/components/charts/ChartMap/mapScales.js.map +1 -0
- package/dist/components/charts/ChartMap/polylabel.cjs +2 -0
- package/dist/components/charts/ChartMap/polylabel.cjs.map +1 -0
- package/dist/components/charts/ChartMap/polylabel.js +50 -0
- package/dist/components/charts/ChartMap/polylabel.js.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.cjs +2 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.js +703 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.js.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.cjs +2 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.js +124 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.js.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.cjs +2 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.js +42 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.js.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.cjs +2 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.js +109 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.js.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTime.cjs +2 -0
- package/dist/components/charts/ChartTimeline/timelineTime.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTime.js +91 -0
- package/dist/components/charts/ChartTimeline/timelineTime.js.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.cjs +2 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.js +77 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.js.map +1 -0
- package/dist/components/charts/core/ChartLegend.cjs +1 -1
- package/dist/components/charts/core/ChartLegend.cjs.map +1 -1
- package/dist/components/charts/core/ChartLegend.js +37 -25
- package/dist/components/charts/core/ChartLegend.js.map +1 -1
- package/dist/components/charts/core/useChartMetrics.cjs +1 -1
- package/dist/components/charts/core/useChartMetrics.cjs.map +1 -1
- package/dist/components/charts/core/useChartMetrics.js +20 -25
- package/dist/components/charts/core/useChartMetrics.js.map +1 -1
- package/dist/components/data-display/List/List.cjs.map +1 -1
- package/dist/components/data-display/List/List.js.map +1 -1
- package/dist/components/data-display/List/List.module.css.cjs +1 -1
- package/dist/components/data-display/List/List.module.css.js +34 -24
- package/dist/components/data-display/List/List.module.css.js.map +1 -1
- package/dist/components/data-display/List/ListingOptions.cjs +1 -1
- package/dist/components/data-display/List/ListingOptions.cjs.map +1 -1
- package/dist/components/data-display/List/ListingOptions.js +98 -74
- package/dist/components/data-display/List/ListingOptions.js.map +1 -1
- package/dist/components/data-display/List/useListing.cjs.map +1 -1
- package/dist/components/data-display/List/useListing.js.map +1 -1
- package/dist/components/forms/ComboBox/ComboBox.cjs.map +1 -1
- package/dist/components/forms/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/navigation/TabsNav/TabsNav.cjs +2 -0
- package/dist/components/navigation/TabsNav/TabsNav.cjs.map +1 -0
- package/dist/components/navigation/TabsNav/TabsNav.js +21 -0
- package/dist/components/navigation/TabsNav/TabsNav.js.map +1 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.cjs +2 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.cjs.map +1 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.js +18 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.js.map +1 -0
- package/dist/components/overlays/Dialog/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/components/overlays/Dialog/DialogFrame.cjs +1 -1
- package/dist/components/overlays/Dialog/DialogFrame.cjs.map +1 -1
- package/dist/components/overlays/Dialog/DialogFrame.js +30 -30
- package/dist/components/overlays/Dialog/DialogFrame.js.map +1 -1
- package/dist/components/overlays/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer/Drawer.js.map +1 -1
- package/dist/design-system.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +184 -174
- package/dist/index.js.map +1 -1
- package/dist/types/components/charts/ChartGauge/ChartGauge.d.ts +83 -0
- package/dist/types/components/charts/ChartGauge/gaugeLayout.d.ts +64 -0
- package/dist/types/components/charts/ChartGauge/gaugeReading.d.ts +97 -0
- package/dist/types/components/charts/ChartGauge/gaugeScale.d.ts +38 -0
- package/dist/types/components/charts/ChartGauge/index.d.ts +2 -0
- package/dist/types/components/charts/ChartMap/ChartMap.d.ts +104 -0
- package/dist/types/components/charts/ChartMap/ChartMapLegend.d.ts +44 -0
- package/dist/types/components/charts/ChartMap/ChartMapTable.d.ts +38 -0
- package/dist/types/components/charts/ChartMap/index.d.ts +4 -0
- package/dist/types/components/charts/ChartMap/mapGeometry.d.ts +56 -0
- package/dist/types/components/charts/ChartMap/mapLabels.d.ts +51 -0
- package/dist/types/components/charts/ChartMap/mapScales.d.ts +76 -0
- package/dist/types/components/charts/ChartMap/polylabel.d.ts +9 -0
- package/dist/types/components/charts/ChartTimeline/ChartTimeline.d.ts +137 -0
- package/dist/types/components/charts/ChartTimeline/ChartTimelineTable.d.ts +25 -0
- package/dist/types/components/charts/ChartTimeline/index.d.ts +2 -0
- package/dist/types/components/charts/ChartTimeline/timelineLayout.d.ts +70 -0
- package/dist/types/components/charts/ChartTimeline/timelineTime.d.ts +16 -0
- package/dist/types/components/charts/ChartTimeline/timelineTooltip.d.ts +45 -0
- package/dist/types/components/charts/core/ChartLegend.d.ts +3 -1
- package/dist/types/components/data-display/List/List.d.ts +1 -1
- package/dist/types/components/data-display/List/useListing.d.ts +7 -1
- package/dist/types/components/forms/ComboBox/ComboBox.d.ts +7 -1
- package/dist/types/components/navigation/TabsNav/TabsNav.d.ts +20 -0
- package/dist/types/components/navigation/TabsNav/index.d.ts +2 -0
- package/dist/types/components/overlays/Dialog/Dialog.d.ts +19 -7
- package/dist/types/components/overlays/Dialog/DialogFrame.d.ts +8 -2
- package/dist/types/components/overlays/Drawer/Drawer.d.ts +2 -2
- package/dist/types/index.d.ts +9 -1
- package/dist/types/utils/formatters/formatarDuracao.d.ts +5 -0
- package/dist/types/utils/formatters/index.d.ts +1 -0
- package/dist/utils/formatters/formatarDuracao.cjs +2 -0
- package/dist/utils/formatters/formatarDuracao.cjs.map +1 -0
- package/dist/utils/formatters/formatarDuracao.js +10 -0
- package/dist/utils/formatters/formatarDuracao.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import { jsx as r, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import { sum as Kt } from "d3-array";
|
|
3
|
+
import { geoPath as vt } from "d3-geo";
|
|
4
|
+
import { scaleSqrt as Ut } from "d3-scale";
|
|
5
|
+
import { useId as Be, useRef as zt, useMemo as b, useState as se, useEffect as Vt } from "react";
|
|
6
|
+
import { ChartMapLegend as qt } from "./ChartMapLegend.js";
|
|
7
|
+
import { ChartMapTable as Gt } from "./ChartMapTable.js";
|
|
8
|
+
import { regionsOf as Wt, naturalHeight as Xt, fitProjection as Jt, projectedParts as Qt, projectedBounds as Yt } from "./mapGeometry.js";
|
|
9
|
+
import { calloutWidth as Zt, CALLOUT_GAP as Rt, planLabels as ea } from "./mapLabels.js";
|
|
10
|
+
import { buildMapScale as ta } from "./mapScales.js";
|
|
11
|
+
import n from "./ChartMap.module.css.js";
|
|
12
|
+
import { useChartMetrics as xt } from "../core/useChartMetrics.js";
|
|
13
|
+
import { useSeriesToggle as yt } from "../core/useSeriesToggle.js";
|
|
14
|
+
import { formatarNumero as aa, formatarPercentual as na } from "../../../utils/formatters/formatarNumero.js";
|
|
15
|
+
import { resolveSeriesColors as sa } from "../palette/seriesColor.js";
|
|
16
|
+
import { Button as ia } from "../../actions/Button/Button.js";
|
|
17
|
+
import { EmptyState as ra } from "../../feedback/EmptyState/EmptyState.js";
|
|
18
|
+
import { IconChartBar as oa } from "../../icons/icons.js";
|
|
19
|
+
import { ChartTooltip as la } from "../ChartTooltip/ChartTooltip.js";
|
|
20
|
+
import { measureLabel as ca } from "../core/measureText.js";
|
|
21
|
+
const da = { type: "sequential" }, ua = 640, Ce = 160, ha = 240, ma = "repeating-linear-gradient(45deg, var(--pl-chart-no-data-hatch) 0 1.5px, var(--pl-chart-no-data) 1.5px 4px)", pa = "var(--pl-color-surface-subtle)", fa = (l) => na(l, { casasDecimais: 1 }), ga = (l, s, o) => `${l} ${l === 1 ? s : o}`;
|
|
22
|
+
function va(l) {
|
|
23
|
+
return l > 1e3 ? 0.25 : l > 100 ? 0.5 : 0.8;
|
|
24
|
+
}
|
|
25
|
+
function xa() {
|
|
26
|
+
try {
|
|
27
|
+
return process.env.NODE_ENV !== "production";
|
|
28
|
+
} catch {
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function ya({ all: l, callouts: s, fixedHeight: o, font: x, labels: C, maxHeight: N, target: d, valueOf: y, width: $ }) {
|
|
33
|
+
const E = (f) => ca(f, x), ve = x.size + 1, p = (f) => {
|
|
34
|
+
const K = o ? N : Math.round(Math.min(N, Math.max(Ce, Xt(d, f)))), H = Jt(d, l, f, K);
|
|
35
|
+
if (!C)
|
|
36
|
+
return { height: K, plan: { callouts: [], inside: [] }, projection: H };
|
|
37
|
+
const xe = d.map((P) => {
|
|
38
|
+
let G;
|
|
39
|
+
return {
|
|
40
|
+
bounds: Yt(P, H),
|
|
41
|
+
id: P.id,
|
|
42
|
+
get parts() {
|
|
43
|
+
return G ?? (G = Qt(P, H)), G;
|
|
44
|
+
},
|
|
45
|
+
title: P.label,
|
|
46
|
+
value: y(P)
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
height: K,
|
|
51
|
+
plan: ea(xe, {
|
|
52
|
+
callouts: s,
|
|
53
|
+
calloutStep: x.lineHeight,
|
|
54
|
+
height: K,
|
|
55
|
+
lineHeight: ve,
|
|
56
|
+
measure: E,
|
|
57
|
+
right: f
|
|
58
|
+
}),
|
|
59
|
+
projection: H
|
|
60
|
+
};
|
|
61
|
+
}, _ = p($);
|
|
62
|
+
if (_.plan.callouts.length === 0)
|
|
63
|
+
return _;
|
|
64
|
+
const L = Math.ceil(Math.max(..._.plan.callouts.map((f) => Zt(f, E))) + Rt + 4);
|
|
65
|
+
return p(Math.max($ - L, $ / 2));
|
|
66
|
+
}
|
|
67
|
+
function Ka({
|
|
68
|
+
accent: l,
|
|
69
|
+
colorScale: s = da,
|
|
70
|
+
data: o = [],
|
|
71
|
+
defaultHiddenSeries: x,
|
|
72
|
+
emptyMessage: C = "Sem dados",
|
|
73
|
+
featureIdKey: N = "id",
|
|
74
|
+
featureLabelKey: d,
|
|
75
|
+
featureNameKey: y = "properties.name",
|
|
76
|
+
focus: $,
|
|
77
|
+
formatPercent: E = fa,
|
|
78
|
+
formatTooltipValue: ve,
|
|
79
|
+
formatValue: p = aa,
|
|
80
|
+
geometry: _,
|
|
81
|
+
height: L = 440,
|
|
82
|
+
hiddenClasses: f,
|
|
83
|
+
hiddenSeries: K,
|
|
84
|
+
legend: H = "bottom",
|
|
85
|
+
legendAlign: xe = "center",
|
|
86
|
+
markerMaxSize: P = 20,
|
|
87
|
+
markerMinSize: G = 3,
|
|
88
|
+
markers: $t,
|
|
89
|
+
markerValueLabel: ye = "Valor",
|
|
90
|
+
noDataLabel: W = "Sem dado",
|
|
91
|
+
noDataStyle: _e = "hatch",
|
|
92
|
+
onHiddenClassesChange: Le,
|
|
93
|
+
onHiddenSeriesChange: kt,
|
|
94
|
+
onHoverRegion: w,
|
|
95
|
+
onMarkerClick: $e,
|
|
96
|
+
onRegionClick: ke,
|
|
97
|
+
regionLabels: Me = "visible",
|
|
98
|
+
selectedRegion: X,
|
|
99
|
+
showDataLabels: be = "hidden",
|
|
100
|
+
showShare: Ke = !1,
|
|
101
|
+
showTableToggle: Mt = !0,
|
|
102
|
+
showTooltip: bt = !0,
|
|
103
|
+
smallRegionLabels: Ue = "callout",
|
|
104
|
+
subtitle: ze,
|
|
105
|
+
title: ie,
|
|
106
|
+
valueLabel: Ne = "Valor"
|
|
107
|
+
}) {
|
|
108
|
+
var pt;
|
|
109
|
+
const Ve = Be(), qe = Be(), Ge = `${Be().replace(/[^\w-]/g, "")}-hatch`, we = xt(), U = xt(), We = zt(null), J = yt({ defaultHiddenSeries: x, hiddenSeries: K, onHiddenSeriesChange: kt }), Nt = b(() => f == null ? void 0 : f.map(String), [f]), wt = yt({
|
|
110
|
+
hiddenSeries: Nt,
|
|
111
|
+
onHiddenSeriesChange: Le && ((e) => Le(e.map(Number)))
|
|
112
|
+
}), [Q, Tt] = se(null), [Xe, Je] = se(null), [Qe, re] = se(null), [Te, Ot] = se(null), [Y, St] = se(!1), g = b(
|
|
113
|
+
() => Wt(_, { idKey: N, labelKey: d, nameKey: y }),
|
|
114
|
+
[N, d, y, _]
|
|
115
|
+
), Oe = ($ ?? []).join("\0"), { context: Ye, inPlay: oe } = b(() => {
|
|
116
|
+
const e = new Set(Oe ? Oe.split("\0") : []), t = g.filter((a) => e.has(a.id));
|
|
117
|
+
return t.length > 0 ? { context: g.filter((a) => !e.has(a.id)), inPlay: t } : { context: [], inPlay: g };
|
|
118
|
+
}, [Oe, g]), Se = s.type === "categorical" ? J : wt, Ze = Se.isHidden, { entries: m, ranked: F, scale: k } = b(() => {
|
|
119
|
+
const e = /* @__PURE__ */ new Map();
|
|
120
|
+
o.forEach((i) => {
|
|
121
|
+
e.has(i.id) || e.set(i.id, i);
|
|
122
|
+
});
|
|
123
|
+
const t = oe.map((i) => {
|
|
124
|
+
const c = e.get(i.id), M = c == null ? void 0 : c.value;
|
|
125
|
+
return {
|
|
126
|
+
category: (c == null ? void 0 : c.category) ?? null,
|
|
127
|
+
region: i,
|
|
128
|
+
value: typeof M == "number" && Number.isFinite(M) ? M : null
|
|
129
|
+
};
|
|
130
|
+
}), a = ta(s, t.flatMap((i) => i.value ?? []), p, l), u = t.filter((i) => i.value !== null).sort((i, c) => c.value - i.value), h = new Map(u.map((i, c) => [i.region.id, c + 1])), S = t.map((i) => {
|
|
131
|
+
const c = a.keyOf(i), M = h.get(i.region.id), I = a.numeric ? i.value === null ? void 0 : p(i.value) : a.labelOf(i), B = s.type === "none" ? i.region.name : [i.region.name, I ?? W, M && `${M}º de ${u.length}`].filter(Boolean).join(", ");
|
|
132
|
+
return {
|
|
133
|
+
...i,
|
|
134
|
+
description: B,
|
|
135
|
+
fill: a.fillOf(i),
|
|
136
|
+
hidden: c !== void 0 && Ze(c),
|
|
137
|
+
key: c,
|
|
138
|
+
rank: M,
|
|
139
|
+
valueText: I
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
entries: S,
|
|
144
|
+
ranked: S.filter((i) => i.rank !== void 0).sort((i, c) => i.rank - c.rank),
|
|
145
|
+
scale: a
|
|
146
|
+
};
|
|
147
|
+
}, [l, s, o, p, oe, Ze, W]), Ie = Kt(F, (e) => e.value), le = s.type === "none" ? 0 : m.filter((e) => e.fill === void 0).length, ce = b(() => {
|
|
148
|
+
const e = new Set(g.map((t) => t.id));
|
|
149
|
+
return o.filter((t) => !e.has(t.id)).map((t) => t.id).join(", ");
|
|
150
|
+
}, [o, g]);
|
|
151
|
+
Vt(() => {
|
|
152
|
+
ce && xa() && console.warn(`ChartMap "${ie}": ${ce.split(", ").length} dado(s) sem região na geometria, fora do desenho: ${ce}.`);
|
|
153
|
+
}, [ce, ie]);
|
|
154
|
+
const z = $t ?? [], Re = b(() => sa(z, { accent: l }), [l, z]), de = new Set(
|
|
155
|
+
z.flatMap(
|
|
156
|
+
(e) => e.points.filter(
|
|
157
|
+
(t) => [t.latitude, t.longitude, t.value].every(Number.isFinite) && t.value >= 0
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
), et = de.size > 0, V = g.length === 0 || !et && (k.numeric ? F.length === 0 : s.type === "categorical" && m.every((e) => e.fill === void 0)), He = H === "right" && we.width >= ua, Z = H === "right" && !He ? "bottom" : H, R = U.width, ee = L === "fill", tt = ee ? Math.max(U.height, Ce) : L, at = Me !== "hidden", nt = be !== "hidden" && k.numeric, T = b(() => {
|
|
161
|
+
if (R === 0 || V)
|
|
162
|
+
return;
|
|
163
|
+
const e = new Map(m.map((t) => [t.region.id, t.valueText]));
|
|
164
|
+
return ya({
|
|
165
|
+
all: g,
|
|
166
|
+
callouts: Ue === "callout",
|
|
167
|
+
fixedHeight: ee,
|
|
168
|
+
font: U.font,
|
|
169
|
+
labels: at,
|
|
170
|
+
maxHeight: tt,
|
|
171
|
+
target: oe,
|
|
172
|
+
valueOf: (t) => nt ? e.get(t.id) : void 0,
|
|
173
|
+
width: R
|
|
174
|
+
});
|
|
175
|
+
}, [V, m, ee, oe, at, tt, U.font, g, Ue, nt, R]), A = T == null ? void 0 : T.projection, st = (T == null ? void 0 : T.height) ?? 0, j = b(() => {
|
|
176
|
+
if (!A)
|
|
177
|
+
return /* @__PURE__ */ new Map();
|
|
178
|
+
const e = vt(A);
|
|
179
|
+
return new Map(g.map((t) => [t.id, e(t.shape) ?? ""]));
|
|
180
|
+
}, [A, g]), Ae = Ut().domain([0, Math.max(...[...de].map((e) => e.value), 1)]).range([0, P]), De = A ? z.flatMap(
|
|
181
|
+
(e, t) => J.isHidden(e.id) ? [] : e.points.flatMap((a, u) => {
|
|
182
|
+
const h = de.has(a) ? A([a.longitude, a.latitude]) : null;
|
|
183
|
+
return h ? [
|
|
184
|
+
{
|
|
185
|
+
color: Re[t],
|
|
186
|
+
key: `marker:${t}:${u}`,
|
|
187
|
+
point: a,
|
|
188
|
+
radius: Math.max(G, Ae(a.value)),
|
|
189
|
+
series: e,
|
|
190
|
+
x: h[0],
|
|
191
|
+
y: h[1]
|
|
192
|
+
}
|
|
193
|
+
] : [];
|
|
194
|
+
})
|
|
195
|
+
).sort((e, t) => t.radius - e.radius) : [], D = ke !== void 0, te = $e !== void 0, it = D || te, Ee = (e) => `region:${e}`, ue = [
|
|
196
|
+
...D ? m.map((e, t) => Ee(t)) : [],
|
|
197
|
+
...te ? De.map((e) => e.key) : []
|
|
198
|
+
], he = m.findIndex((e) => e.region.id === X), Pe = ue.includes(Qe ?? "") ? Qe : D && he >= 0 ? Ee(he) : ue[0], ae = (e) => e != null && e.startsWith("region:") ? m[Number(e.slice(7))] : void 0, me = (e) => De.find((t) => t.key === e), ne = ae(Xe), pe = me(Xe), O = (Q == null ? void 0 : Q.kind) === "region" ? Q.entry : void 0, It = (O == null ? void 0 : O.region.id) ?? (ne == null ? void 0 : ne.region.id), Ht = (e) => ({
|
|
199
|
+
category: e.category,
|
|
200
|
+
feature: e.region.feature,
|
|
201
|
+
id: e.region.id,
|
|
202
|
+
name: e.region.name,
|
|
203
|
+
value: e.value
|
|
204
|
+
}), At = ({ point: e, series: t }) => ({
|
|
205
|
+
id: e.id,
|
|
206
|
+
series: t.id,
|
|
207
|
+
value: e.value
|
|
208
|
+
}), Dt = ({ point: e, series: t }) => `${e.label}, ${t.label}, ${p(e.value)}`;
|
|
209
|
+
function fe(e) {
|
|
210
|
+
var t, a;
|
|
211
|
+
return ((a = (t = e.target).getAttribute) == null ? void 0 : a.call(t, "data-mark")) ?? null;
|
|
212
|
+
}
|
|
213
|
+
function rt(e) {
|
|
214
|
+
const t = ae(e), a = me(e);
|
|
215
|
+
Tt(t ? { entry: t, kind: "region" } : a ? { kind: "marker", marker: a } : null), w == null || w((t == null ? void 0 : t.region.id) ?? null);
|
|
216
|
+
}
|
|
217
|
+
function ot(e) {
|
|
218
|
+
const t = ae(e), a = me(e);
|
|
219
|
+
t && ke ? (re(e), ke(Ht(t))) : a && $e && (re(e), $e(At(a)));
|
|
220
|
+
}
|
|
221
|
+
function Et(e, [t, a]) {
|
|
222
|
+
if (!A)
|
|
223
|
+
return;
|
|
224
|
+
const u = vt(A), h = (I) => {
|
|
225
|
+
const B = ae(I), q = me(I);
|
|
226
|
+
return B ? u.centroid(B.region.shape) : q ? [q.x, q.y] : [0, 0];
|
|
227
|
+
}, [S, i] = h(e);
|
|
228
|
+
let c, M = 1 / 0;
|
|
229
|
+
return ue.forEach((I) => {
|
|
230
|
+
if (I === e)
|
|
231
|
+
return;
|
|
232
|
+
const [B, q] = h(I), ft = (B - S) * t + (q - i) * a, gt = ft + 2 * Math.abs((B - S) * a - (q - i) * t);
|
|
233
|
+
ft > 1 && gt < M && (M = gt, c = I);
|
|
234
|
+
}), c;
|
|
235
|
+
}
|
|
236
|
+
function Pt(e) {
|
|
237
|
+
var u, h;
|
|
238
|
+
const t = fe(e), a = {
|
|
239
|
+
ArrowDown: [0, 1],
|
|
240
|
+
ArrowLeft: [-1, 0],
|
|
241
|
+
ArrowRight: [1, 0],
|
|
242
|
+
ArrowUp: [0, -1]
|
|
243
|
+
};
|
|
244
|
+
if (!(!t || !ue.includes(t))) {
|
|
245
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
246
|
+
e.preventDefault(), ot(t);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (e.key in a) {
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
const S = Et(t, a[e.key]);
|
|
252
|
+
S && (re(S), (h = (u = We.current) == null ? void 0 : u.querySelector(`[data-mark="${S}"]`)) == null || h.focus());
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const lt = {
|
|
257
|
+
onBlur: () => {
|
|
258
|
+
Je(null), w == null || w(null);
|
|
259
|
+
},
|
|
260
|
+
onClick: (e) => ot(fe(e)),
|
|
261
|
+
onFocus: (e) => {
|
|
262
|
+
var a;
|
|
263
|
+
const t = fe(e);
|
|
264
|
+
Je(t), re(t), w == null || w(((a = ae(t)) == null ? void 0 : a.region.id) ?? null);
|
|
265
|
+
},
|
|
266
|
+
onKeyDown: Pt,
|
|
267
|
+
onMouseOut: () => rt(null),
|
|
268
|
+
onMouseOver: (e) => rt(fe(e))
|
|
269
|
+
}, ge = va(g.length), ct = (T == null ? void 0 : T.plan) ?? { callouts: [], inside: [] }, dt = U.font.size + 1, ut = _e === "hatch" ? `url(#${Ge})` : "var(--pl-chart-no-data)", Ft = b(
|
|
270
|
+
() => m.map((e, t) => {
|
|
271
|
+
const a = Ee(t), u = Te !== null && e.key !== Te;
|
|
272
|
+
return /* @__PURE__ */ r(
|
|
273
|
+
"path",
|
|
274
|
+
{
|
|
275
|
+
"aria-label": e.description,
|
|
276
|
+
"aria-pressed": D && X !== void 0 ? e.region.id === X : void 0,
|
|
277
|
+
className: `${n.region} ${D ? n.clickable : ""} ${u ? n.dimmed : ""}`,
|
|
278
|
+
d: j.get(e.region.id),
|
|
279
|
+
"data-mark": a,
|
|
280
|
+
fill: e.hidden ? pa : e.fill ?? ut,
|
|
281
|
+
role: D ? "button" : void 0,
|
|
282
|
+
strokeWidth: ge,
|
|
283
|
+
tabIndex: D ? a === Pe ? 0 : -1 : void 0
|
|
284
|
+
},
|
|
285
|
+
t
|
|
286
|
+
);
|
|
287
|
+
}),
|
|
288
|
+
[m, Te, ut, j, D, X, ge, Pe]
|
|
289
|
+
), jt = b(
|
|
290
|
+
() => Ye.map((e, t) => /* @__PURE__ */ r("path", { className: n.context, d: j.get(e.id), strokeWidth: ge }, t)),
|
|
291
|
+
[Ye, j, ge]
|
|
292
|
+
), Bt = (() => {
|
|
293
|
+
const e = ga(m.length, "região", "regiões"), t = le > 0 ? ` ${le} sem dado.` : "", a = it ? " Use as setas para percorrer as marcas." : "";
|
|
294
|
+
if (!k.numeric || F.length === 0)
|
|
295
|
+
return `Mapa de ${e}.${t}${a}`;
|
|
296
|
+
const [u, h] = [F[0], F[F.length - 1]];
|
|
297
|
+
return `Mapa de ${e}. Maior valor: ${u.region.name}, ${p(u.value)}. Menor: ${h.region.name}, ${p(h.value)}.${t}${a}`;
|
|
298
|
+
})();
|
|
299
|
+
function ht(e, t) {
|
|
300
|
+
return `${n.label} ${t ? n.labelOnHover : ""} ${It === e ? n.labelActive : ""}`;
|
|
301
|
+
}
|
|
302
|
+
const Fe = A && /* @__PURE__ */ v(
|
|
303
|
+
"svg",
|
|
304
|
+
{
|
|
305
|
+
"aria-describedby": qe,
|
|
306
|
+
"aria-labelledby": Ve,
|
|
307
|
+
className: `${n.canvas} ${ee ? n.canvasFill : ""}`,
|
|
308
|
+
height: st,
|
|
309
|
+
ref: We,
|
|
310
|
+
role: it ? "group" : "img",
|
|
311
|
+
viewBox: `0 0 ${R} ${st}`,
|
|
312
|
+
width: R,
|
|
313
|
+
children: [
|
|
314
|
+
/* @__PURE__ */ r("defs", { children: /* @__PURE__ */ v("pattern", { height: 6, id: Ge, patternTransform: "rotate(45)", patternUnits: "userSpaceOnUse", width: 6, children: [
|
|
315
|
+
/* @__PURE__ */ r("rect", { className: n.hatchBackground, height: 6, width: 6 }),
|
|
316
|
+
/* @__PURE__ */ r("line", { className: n.hatchLine, x1: 0, x2: 0, y1: 0, y2: 6 })
|
|
317
|
+
] }) }),
|
|
318
|
+
/* @__PURE__ */ r("g", { "aria-hidden": "true", className: n.passThrough, children: jt }),
|
|
319
|
+
/* @__PURE__ */ r("g", { ...lt, children: Ft }),
|
|
320
|
+
/* @__PURE__ */ v("g", { "aria-hidden": "true", className: n.passThrough, children: [
|
|
321
|
+
he >= 0 && /* @__PURE__ */ r("path", { className: n.selectedOutline, d: j.get(m[he].region.id) }),
|
|
322
|
+
O && /* @__PURE__ */ r("path", { className: n.hoverOutline, d: j.get(O.region.id) }),
|
|
323
|
+
ne && /* @__PURE__ */ r("path", { className: n.focusOutline, d: j.get(ne.region.id) })
|
|
324
|
+
] }),
|
|
325
|
+
/* @__PURE__ */ v("g", { ...lt, children: [
|
|
326
|
+
De.map((e) => /* @__PURE__ */ r(
|
|
327
|
+
"circle",
|
|
328
|
+
{
|
|
329
|
+
"aria-label": Dt(e),
|
|
330
|
+
className: `${n.marker} ${te ? n.clickable : ""}`,
|
|
331
|
+
cx: e.x,
|
|
332
|
+
cy: e.y,
|
|
333
|
+
"data-mark": e.key,
|
|
334
|
+
fill: e.color,
|
|
335
|
+
r: e.radius,
|
|
336
|
+
role: te ? "button" : "img",
|
|
337
|
+
tabIndex: te ? e.key === Pe ? 0 : -1 : void 0
|
|
338
|
+
},
|
|
339
|
+
e.key
|
|
340
|
+
)),
|
|
341
|
+
pe && /* @__PURE__ */ r(
|
|
342
|
+
"circle",
|
|
343
|
+
{
|
|
344
|
+
"aria-hidden": "true",
|
|
345
|
+
className: n.focusOutline,
|
|
346
|
+
cx: pe.x,
|
|
347
|
+
cy: pe.y,
|
|
348
|
+
r: pe.radius + 3
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
] }),
|
|
352
|
+
/* @__PURE__ */ v("g", { "aria-hidden": "true", className: n.passThrough, children: [
|
|
353
|
+
ct.inside.map((e) => /* @__PURE__ */ v("text", { className: ht(e.id, Me === "onHover"), x: e.x, y: e.y, children: [
|
|
354
|
+
/* @__PURE__ */ r("tspan", { dominantBaseline: "central", x: e.x, y: e.value ? e.y - dt / 2 : e.y, children: e.title }),
|
|
355
|
+
e.value && /* @__PURE__ */ r(
|
|
356
|
+
"tspan",
|
|
357
|
+
{
|
|
358
|
+
className: `${n.labelValue} ${be === "onHover" ? n.valueOnHover : ""}`,
|
|
359
|
+
dominantBaseline: "central",
|
|
360
|
+
x: e.x,
|
|
361
|
+
y: e.y + dt / 2,
|
|
362
|
+
children: e.value
|
|
363
|
+
}
|
|
364
|
+
)
|
|
365
|
+
] }, e.id)),
|
|
366
|
+
ct.callouts.map((e) => /* @__PURE__ */ v("g", { className: ht(e.id, Me === "onHover"), children: [
|
|
367
|
+
/* @__PURE__ */ r(
|
|
368
|
+
"path",
|
|
369
|
+
{
|
|
370
|
+
className: n.leader,
|
|
371
|
+
d: `M${e.anchor[0]},${e.anchor[1]}L${e.x - 12},${e.y}L${e.x - 4},${e.y}`
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
/* @__PURE__ */ r("circle", { className: n.leaderDot, cx: e.anchor[0], cy: e.anchor[1], r: 1.8 }),
|
|
375
|
+
/* @__PURE__ */ v("text", { className: n.callout, dominantBaseline: "central", x: e.x, y: e.y, children: [
|
|
376
|
+
e.title,
|
|
377
|
+
e.value && /* @__PURE__ */ r(
|
|
378
|
+
"tspan",
|
|
379
|
+
{
|
|
380
|
+
className: `${n.labelValue} ${be === "onHover" ? n.valueOnHover : ""}`,
|
|
381
|
+
dx: 5,
|
|
382
|
+
children: e.value
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
] })
|
|
386
|
+
] }, e.id))
|
|
387
|
+
] })
|
|
388
|
+
]
|
|
389
|
+
}
|
|
390
|
+
), Ct = $a(Q, {
|
|
391
|
+
formatPercent: E,
|
|
392
|
+
formatTooltipValue: ve ?? p,
|
|
393
|
+
markerValueLabel: ye,
|
|
394
|
+
noDataLabel: W,
|
|
395
|
+
rankedCount: F.length,
|
|
396
|
+
scale: k,
|
|
397
|
+
showShare: Ke,
|
|
398
|
+
total: Ie,
|
|
399
|
+
valueLabel: Ne,
|
|
400
|
+
colorScale: s
|
|
401
|
+
}), je = /* @__PURE__ */ new Map();
|
|
402
|
+
m.forEach((e) => e.key !== void 0 && je.set(e.key, (je.get(e.key) ?? 0) + 1));
|
|
403
|
+
const mt = Z !== "none" && /* @__PURE__ */ r(
|
|
404
|
+
qt,
|
|
405
|
+
{
|
|
406
|
+
align: xe,
|
|
407
|
+
entries: k.entries.map((e) => ({
|
|
408
|
+
...e,
|
|
409
|
+
count: je.get(e.key) ?? 0,
|
|
410
|
+
hidden: Se.isHidden(e.key)
|
|
411
|
+
})),
|
|
412
|
+
formatValue: p,
|
|
413
|
+
gradient: k.gradient,
|
|
414
|
+
indicator: (O == null ? void 0 : O.value) == null || (pt = k.gradient) == null ? void 0 : pt.position(O.value),
|
|
415
|
+
markerSeries: z.map((e, t) => ({
|
|
416
|
+
color: Re[t],
|
|
417
|
+
hidden: J.isHidden(e.id),
|
|
418
|
+
key: e.id,
|
|
419
|
+
label: e.label
|
|
420
|
+
})),
|
|
421
|
+
markerSizes: et ? { maximum: Ae.domain()[1], radiusOf: (e) => Math.max(G, Ae(e)) } : void 0,
|
|
422
|
+
markerValueLabel: ye,
|
|
423
|
+
noData: le > 0 ? { color: _e === "hatch" ? ma : "var(--pl-chart-no-data)", count: le, label: W } : void 0,
|
|
424
|
+
onHighlight: (e) => Ot(e),
|
|
425
|
+
onToggle: Se.toggle,
|
|
426
|
+
onToggleMarkerSeries: J.toggle,
|
|
427
|
+
position: Z,
|
|
428
|
+
style: He ? { width: Math.min(ha, Math.round(we.width * 0.3)) } : void 0,
|
|
429
|
+
valueLabel: Ne
|
|
430
|
+
}
|
|
431
|
+
), _t = m.filter((e) => !e.hidden).map((e) => ({
|
|
432
|
+
classLabel: s.type === "classes" ? k.labelOf(e) : void 0,
|
|
433
|
+
id: e.region.id,
|
|
434
|
+
name: e.region.name,
|
|
435
|
+
rank: e.rank,
|
|
436
|
+
selected: e.region.id === X,
|
|
437
|
+
share: e.value !== null && Ie > 0 ? e.value / Ie : void 0,
|
|
438
|
+
value: e.value,
|
|
439
|
+
valueText: e.valueText
|
|
440
|
+
})), Lt = z.flatMap(
|
|
441
|
+
(e) => J.isHidden(e.id) ? [] : e.points.filter((t) => de.has(t)).map((t) => ({ key: `${e.id}:${t.id}`, name: t.label, series: e.label, value: p(t.value) }))
|
|
442
|
+
);
|
|
443
|
+
return /* @__PURE__ */ v("figure", { className: n.figure, children: [
|
|
444
|
+
/* @__PURE__ */ v("figcaption", { className: n.header, children: [
|
|
445
|
+
/* @__PURE__ */ v("span", { className: n.heading, children: [
|
|
446
|
+
/* @__PURE__ */ r("span", { className: n.title, id: Ve, children: ie }),
|
|
447
|
+
ze && /* @__PURE__ */ r("span", { className: n.subtitle, children: ze })
|
|
448
|
+
] }),
|
|
449
|
+
Mt && !V && /* @__PURE__ */ r(
|
|
450
|
+
ia,
|
|
451
|
+
{
|
|
452
|
+
"aria-pressed": Y,
|
|
453
|
+
className: n.tableToggle,
|
|
454
|
+
onClick: () => St((e) => !e),
|
|
455
|
+
size: "sm",
|
|
456
|
+
variant: "secondary",
|
|
457
|
+
children: "Ver como tabela"
|
|
458
|
+
}
|
|
459
|
+
)
|
|
460
|
+
] }),
|
|
461
|
+
/* @__PURE__ */ r("span", { className: n.visuallyHidden, id: qe, children: Bt }),
|
|
462
|
+
/* @__PURE__ */ v("div", { className: `${n.body} ${He && !Y ? n.bodyRow : ""}`, ref: we.ref, children: [
|
|
463
|
+
Z === "top" && !Y && !V && mt,
|
|
464
|
+
V ? /* @__PURE__ */ r("div", { className: n.empty, children: /* @__PURE__ */ r(ra, { icon: /* @__PURE__ */ r(oa, {}), size: "sm", title: C }) }) : Y ? /* @__PURE__ */ r(
|
|
465
|
+
Gt,
|
|
466
|
+
{
|
|
467
|
+
markerRows: Lt,
|
|
468
|
+
markerValueLabel: ye,
|
|
469
|
+
maxHeight: typeof L == "number" ? Math.max(L, Ce) : void 0,
|
|
470
|
+
noDataLabel: W,
|
|
471
|
+
regionRows: _t,
|
|
472
|
+
showClasses: s.type === "classes",
|
|
473
|
+
showRank: k.numeric,
|
|
474
|
+
showShare: Ke && k.numeric,
|
|
475
|
+
showValue: s.type !== "none",
|
|
476
|
+
formatPercent: E,
|
|
477
|
+
title: ie,
|
|
478
|
+
valueLabel: Ne
|
|
479
|
+
}
|
|
480
|
+
) : /* @__PURE__ */ r("div", { className: `${n.plot} ${ee ? n.plotFill : ""}`, ref: U.ref, children: Fe && (bt ? /* @__PURE__ */ r(la, { ...Ct, children: Fe }) : Fe) }),
|
|
481
|
+
(Z === "bottom" || Z === "right") && !Y && !V && mt
|
|
482
|
+
] })
|
|
483
|
+
] });
|
|
484
|
+
}
|
|
485
|
+
function $a(l, s) {
|
|
486
|
+
if (l === null)
|
|
487
|
+
return { rows: [] };
|
|
488
|
+
if (l.kind === "marker") {
|
|
489
|
+
const { color: y, point: $, series: E } = l.marker;
|
|
490
|
+
return {
|
|
491
|
+
columns: [{ format: s.formatTooltipValue }],
|
|
492
|
+
computed: "none",
|
|
493
|
+
rows: [{ color: y, label: s.markerValueLabel, values: [$.value] }],
|
|
494
|
+
subtitle: E.label,
|
|
495
|
+
title: $.label
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
const { entry: o } = l, { region: x } = o, C = x.label !== x.name ? x.label : void 0, N = (y, $) => ({ format: () => $, label: y, values: [0] }), d = [];
|
|
499
|
+
if (s.colorScale.type === "none")
|
|
500
|
+
d.push({ label: C ?? x.name, values: [] });
|
|
501
|
+
else if (!s.scale.numeric)
|
|
502
|
+
d.push(
|
|
503
|
+
o.valueText ? { ...N(s.valueLabel, o.valueText), color: o.fill } : { label: s.noDataLabel, values: [] }
|
|
504
|
+
);
|
|
505
|
+
else if (o.value === null)
|
|
506
|
+
d.push({ label: s.noDataLabel, values: [] });
|
|
507
|
+
else {
|
|
508
|
+
d.push({ color: o.fill, label: s.valueLabel, values: [o.value] });
|
|
509
|
+
const y = s.colorScale.type === "classes" ? s.scale.labelOf(o) : void 0;
|
|
510
|
+
y && d.push(N("Faixa", y)), s.showShare && s.total > 0 && d.push({ format: s.formatPercent, label: "% do total", values: [o.value / s.total] }), d.push(N("Posição", `${o.rank}º de ${s.rankedCount}`));
|
|
511
|
+
}
|
|
512
|
+
return o.hidden && d.push({ label: "Oculta pela legenda", values: [] }), {
|
|
513
|
+
columns: [{ format: s.formatTooltipValue }],
|
|
514
|
+
computed: "none",
|
|
515
|
+
rows: d,
|
|
516
|
+
subtitle: C,
|
|
517
|
+
title: x.name
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
export {
|
|
521
|
+
Ka as ChartMap
|
|
522
|
+
};
|
|
523
|
+
//# sourceMappingURL=ChartMap.js.map
|