@caipira/tamandua 0.0.59 → 0.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { _ as e } from "./ChartTreemap.vue_vue_type_script_setup_true_lang-C5rtKK6M.js";
2
- import { p as m } from "./plugin-BHLqWB9f.js";
1
+ import { _ as e } from "./ChartTreemap.vue_vue_type_script_setup_true_lang-DKaI62CD.js";
2
+ import { p as m } from "./plugin-B97_3CZA.js";
3
3
  export {
4
4
  e as ChartTreemap,
5
5
  m as ChartTreemapPlugin
@@ -0,0 +1,308 @@
1
+ import { defineComponent as P, ref as M, onMounted as z, openBlock as N, createElementBlock as I, Fragment as R, createElementVNode as T, normalizeStyle as V, unref as D, renderSlot as E, createBlock as L, resolveDynamicComponent as O, normalizeProps as F, mergeProps as H, createTextVNode as W, toDisplayString as X } from "vue";
2
+ import { r as Y, s as q } from "./transform-DSaNEFMr.js";
3
+ import { u as j, o as Z, c as G } from "./floating-ui.vue-B5QcGNjh.js";
4
+ function J(e) {
5
+ var t = 0, r = e.children, a = r && r.length;
6
+ if (!a)
7
+ t = 1;
8
+ else
9
+ for (; --a >= 0; )
10
+ t += r[a].value;
11
+ e.value = t;
12
+ }
13
+ function K() {
14
+ return this.eachAfter(J);
15
+ }
16
+ function Q(e, t) {
17
+ let r = -1;
18
+ for (const a of this)
19
+ e.call(t, a, ++r, this);
20
+ return this;
21
+ }
22
+ function U(e, t) {
23
+ for (var r = this, a = [r], o, i, l = -1; r = a.pop(); )
24
+ if (e.call(t, r, ++l, this), o = r.children)
25
+ for (i = o.length - 1; i >= 0; --i)
26
+ a.push(o[i]);
27
+ return this;
28
+ }
29
+ function ee(e, t) {
30
+ for (var r = this, a = [r], o = [], i, l, u, d = -1; r = a.pop(); )
31
+ if (o.push(r), i = r.children)
32
+ for (l = 0, u = i.length; l < u; ++l)
33
+ a.push(i[l]);
34
+ for (; r = o.pop(); )
35
+ e.call(t, r, ++d, this);
36
+ return this;
37
+ }
38
+ function te(e, t) {
39
+ let r = -1;
40
+ for (const a of this)
41
+ if (e.call(t, a, ++r, this))
42
+ return a;
43
+ }
44
+ function ne(e) {
45
+ return this.eachAfter(function(t) {
46
+ for (var r = +e(t.data) || 0, a = t.children, o = a && a.length; --o >= 0; )
47
+ r += a[o].value;
48
+ t.value = r;
49
+ });
50
+ }
51
+ function re(e) {
52
+ return this.eachBefore(function(t) {
53
+ t.children && t.children.sort(e);
54
+ });
55
+ }
56
+ function ae(e) {
57
+ for (var t = this, r = oe(t, e), a = [t]; t !== r; )
58
+ t = t.parent, a.push(t);
59
+ for (var o = a.length; e !== r; )
60
+ a.splice(o, 0, e), e = e.parent;
61
+ return a;
62
+ }
63
+ function oe(e, t) {
64
+ if (e === t)
65
+ return e;
66
+ var r = e.ancestors(), a = t.ancestors(), o = null;
67
+ for (e = r.pop(), t = a.pop(); e === t; )
68
+ o = e, e = r.pop(), t = a.pop();
69
+ return o;
70
+ }
71
+ function ie() {
72
+ for (var e = this, t = [e]; e = e.parent; )
73
+ t.push(e);
74
+ return t;
75
+ }
76
+ function le() {
77
+ return Array.from(this);
78
+ }
79
+ function ue() {
80
+ var e = [];
81
+ return this.eachBefore(function(t) {
82
+ t.children || e.push(t);
83
+ }), e;
84
+ }
85
+ function se() {
86
+ var e = this, t = [];
87
+ return e.each(function(r) {
88
+ r !== e && t.push({ source: r.parent, target: r });
89
+ }), t;
90
+ }
91
+ function* ce() {
92
+ var e = this, t, r = [e], a, o, i;
93
+ do
94
+ for (t = r.reverse(), r = []; e = t.pop(); )
95
+ if (yield e, a = e.children)
96
+ for (o = 0, i = a.length; o < i; ++o)
97
+ r.push(a[o]);
98
+ while (r.length);
99
+ }
100
+ function $(e, t) {
101
+ e instanceof Map ? (e = [void 0, e], t === void 0 && (t = he)) : t === void 0 && (t = de);
102
+ for (var r = new C(e), a, o = [r], i, l, u, d; a = o.pop(); )
103
+ if ((l = t(a.data)) && (d = (l = Array.from(l)).length))
104
+ for (a.children = l, u = d - 1; u >= 0; --u)
105
+ o.push(i = l[u] = new C(l[u])), i.parent = a, i.depth = a.depth + 1;
106
+ return r.eachBefore(ge);
107
+ }
108
+ function fe() {
109
+ return $(this).eachBefore(pe);
110
+ }
111
+ function de(e) {
112
+ return e.children;
113
+ }
114
+ function he(e) {
115
+ return Array.isArray(e) ? e[1] : null;
116
+ }
117
+ function pe(e) {
118
+ e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
119
+ }
120
+ function ge(e) {
121
+ var t = 0;
122
+ do
123
+ e.height = t;
124
+ while ((e = e.parent) && e.height < ++t);
125
+ }
126
+ function C(e) {
127
+ this.data = e, this.depth = this.height = 0, this.parent = null;
128
+ }
129
+ C.prototype = $.prototype = {
130
+ constructor: C,
131
+ count: K,
132
+ each: Q,
133
+ eachAfter: ee,
134
+ eachBefore: U,
135
+ find: te,
136
+ sum: ne,
137
+ sort: re,
138
+ path: ae,
139
+ ancestors: ie,
140
+ descendants: le,
141
+ leaves: ue,
142
+ links: se,
143
+ copy: fe,
144
+ [Symbol.iterator]: ce
145
+ };
146
+ function ve(e) {
147
+ if (typeof e != "function")
148
+ throw new Error();
149
+ return e;
150
+ }
151
+ function x() {
152
+ return 0;
153
+ }
154
+ function S(e) {
155
+ return function() {
156
+ return e;
157
+ };
158
+ }
159
+ function me(e) {
160
+ e.x0 = Math.round(e.x0), e.y0 = Math.round(e.y0), e.x1 = Math.round(e.x1), e.y1 = Math.round(e.y1);
161
+ }
162
+ function ye(e, t, r, a, o) {
163
+ for (var i = e.children, l, u = -1, d = i.length, m = e.value && (a - t) / e.value; ++u < d; )
164
+ l = i[u], l.y0 = r, l.y1 = o, l.x0 = t, l.x1 = t += l.value * m;
165
+ }
166
+ function be(e, t, r, a, o) {
167
+ for (var i = e.children, l, u = -1, d = i.length, m = e.value && (o - r) / e.value; ++u < d; )
168
+ l = i[u], l.x0 = t, l.x1 = a, l.y0 = r, l.y1 = r += l.value * m;
169
+ }
170
+ var we = (1 + Math.sqrt(5)) / 2;
171
+ function _e(e, t, r, a, o, i) {
172
+ for (var l = [], u = t.children, d, m, s = 0, y = 0, n = u.length, g, v, f = t.value, c, p, w, _, A, k, b; s < n; ) {
173
+ g = o - r, v = i - a;
174
+ do
175
+ c = u[y++].value;
176
+ while (!c && y < n);
177
+ for (p = w = c, k = Math.max(v / g, g / v) / (f * e), b = c * c * k, A = Math.max(w / b, b / p); y < n; ++y) {
178
+ if (c += m = u[y].value, m < p && (p = m), m > w && (w = m), b = c * c * k, _ = Math.max(w / b, b / p), _ > A) {
179
+ c -= m;
180
+ break;
181
+ }
182
+ A = _;
183
+ }
184
+ l.push(d = { value: c, dice: g < v, children: u.slice(s, y) }), d.dice ? ye(d, r, a, o, f ? a += v * c / f : i) : be(d, r, a, f ? r += g * c / f : o, i), f -= c, s = y;
185
+ }
186
+ return l;
187
+ }
188
+ const ke = function e(t) {
189
+ function r(a, o, i, l, u) {
190
+ _e(t, a, o, i, l, u);
191
+ }
192
+ return r.ratio = function(a) {
193
+ return e((a = +a) > 1 ? a : 1);
194
+ }, r;
195
+ }(we);
196
+ function Be() {
197
+ var e = ke, t = !1, r = 1, a = 1, o = [0], i = x, l = x, u = x, d = x, m = x;
198
+ function s(n) {
199
+ return n.x0 = n.y0 = 0, n.x1 = r, n.y1 = a, n.eachBefore(y), o = [0], t && n.eachBefore(me), n;
200
+ }
201
+ function y(n) {
202
+ var g = o[n.depth], v = n.x0 + g, f = n.y0 + g, c = n.x1 - g, p = n.y1 - g;
203
+ c < v && (v = c = (v + c) / 2), p < f && (f = p = (f + p) / 2), n.x0 = v, n.y0 = f, n.x1 = c, n.y1 = p, n.children && (g = o[n.depth + 1] = i(n) / 2, v += m(n) - g, f += l(n) - g, c -= u(n) - g, p -= d(n) - g, c < v && (v = c = (v + c) / 2), p < f && (f = p = (f + p) / 2), e(n, v, f, c, p));
204
+ }
205
+ return s.round = function(n) {
206
+ return arguments.length ? (t = !!n, s) : t;
207
+ }, s.size = function(n) {
208
+ return arguments.length ? (r = +n[0], a = +n[1], s) : [r, a];
209
+ }, s.tile = function(n) {
210
+ return arguments.length ? (e = ve(n), s) : e;
211
+ }, s.padding = function(n) {
212
+ return arguments.length ? s.paddingInner(n).paddingOuter(n) : s.paddingInner();
213
+ }, s.paddingInner = function(n) {
214
+ return arguments.length ? (i = typeof n == "function" ? n : S(+n), s) : i;
215
+ }, s.paddingOuter = function(n) {
216
+ return arguments.length ? s.paddingTop(n).paddingRight(n).paddingBottom(n).paddingLeft(n) : s.paddingTop();
217
+ }, s.paddingTop = function(n) {
218
+ return arguments.length ? (l = typeof n == "function" ? n : S(+n), s) : l;
219
+ }, s.paddingRight = function(n) {
220
+ return arguments.length ? (u = typeof n == "function" ? n : S(+n), s) : u;
221
+ }, s.paddingBottom = function(n) {
222
+ return arguments.length ? (d = typeof n == "function" ? n : S(+n), s) : d;
223
+ }, s.paddingLeft = function(n) {
224
+ return arguments.length ? (m = typeof n == "function" ? n : S(+n), s) : m;
225
+ }, s;
226
+ }
227
+ function Me(e) {
228
+ for (var t = e.length / 6 | 0, r = new Array(t), a = 0; a < t; )
229
+ r[a] = "#" + e.slice(a * 6, ++a * 6);
230
+ return r;
231
+ }
232
+ const xe = (e) => Y(e[e.length - 1]);
233
+ var Se = new Array(3).concat(
234
+ "fc8d59ffffbf99d594",
235
+ "d7191cfdae61abdda42b83ba",
236
+ "d7191cfdae61ffffbfabdda42b83ba",
237
+ "d53e4ffc8d59fee08be6f59899d5943288bd",
238
+ "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
239
+ "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
240
+ "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
241
+ "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
242
+ "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
243
+ ).map(Me);
244
+ const Ae = xe(Se), Te = /* @__PURE__ */ T("svg", null, null, -1);
245
+ let Ce = 0;
246
+ const Re = /* @__PURE__ */ P({
247
+ name: "TChartTreemap",
248
+ __name: "ChartTreemap",
249
+ props: {
250
+ data: {}
251
+ },
252
+ setup(e) {
253
+ const t = e, r = M(0), a = M(0), o = `tamandua-chart-treemap-${++Ce}`, i = M(), l = M(), u = M(), { floatingStyles: d, update: m } = j(l, i, {
254
+ middleware: [Z(10), G()]
255
+ }), s = (f) => {
256
+ u.value = f;
257
+ }, y = () => {
258
+ !i.value || i.value.style.display === "none" || (i.value.style.display = "none");
259
+ }, n = () => {
260
+ !i.value || i.value.style.display === "block" || (i.value.style.display = "block");
261
+ }, g = (f) => {
262
+ r.value = f.pageX, a.value = f.pageY, m();
263
+ }, v = () => {
264
+ const c = parseInt(
265
+ q(`div#${o}`).style("width"),
266
+ 10
267
+ ), p = 350, w = q(`div#${o} svg`).attr("width", c).attr("height", p).append("g"), _ = $(t.data).sum((h) => h?.value ?? 0).sort(
268
+ (h, B) => (B.value ?? 0) - (h.value ?? 0)
269
+ ), k = Be().size([c, p]).padding(1)(_), b = Ae;
270
+ w.selectAll("rect").data(k.leaves()).enter().append("rect").attr("x", (h) => h.x0).attr("y", (h) => h.y0).attr("width", (h) => h.x1 - h.x0).attr("height", (h) => h.y1 - h.y0).attr("fill", (h, B) => h.data.color ? h.data.color : h.parent?.data?.color ? h.parent?.data?.color : b(B / 7)).on("mouseover", (h, B) => s(B.data));
271
+ };
272
+ return z(() => {
273
+ v();
274
+ }), (f, c) => (N(), I(R, null, [
275
+ T("div", {
276
+ id: o,
277
+ class: "w-full",
278
+ onMousemove: g,
279
+ onMouseenter: n,
280
+ onMouseleave: y
281
+ }, [
282
+ Te,
283
+ T("div", {
284
+ ref_key: "reference",
285
+ ref: l,
286
+ class: "w-1 h-1 absolute",
287
+ style: V({
288
+ left: `${r.value}px`,
289
+ top: `${a.value}px`
290
+ })
291
+ }, null, 4)
292
+ ], 32),
293
+ T("div", {
294
+ ref_key: "tooltip",
295
+ ref: i,
296
+ style: V(D(d)),
297
+ class: "hidden absolute select-none bg-caipira-primary border-color text-base px-2 py-1 rounded-sm"
298
+ }, [
299
+ u.value?.tooltipSlotName && f.$slots.hasOwnProperty(u.value.tooltipSlotName) ? E(f.$slots, u.value.tooltipSlotName, { key: 0 }) : u.value?.tooltipSlotComponent ? (N(), L(O(u.value.tooltipSlotComponent), F(H({ key: 1 }, u.value.tooltipSlotComponentProps)), null, 16)) : (N(), I(R, { key: 2 }, [
300
+ W(X(u.value?.label), 1)
301
+ ], 64))
302
+ ], 4)
303
+ ], 64));
304
+ }
305
+ });
306
+ export {
307
+ Re as _
308
+ };
@@ -2,7 +2,7 @@ import { _ as e } from "./Avatar.vue_vue_type_script_setup_true_lang-BbcM5CB3.js
2
2
  import { _ as a } from "./Backdrop.vue_vue_type_script_setup_true_lang-OaEBTmYK.js";
3
3
  import { B as s } from "./Button-uTiKL1_J.js";
4
4
  import { _ as f } from "./ChartLine.vue_vue_type_style_index_0_lang-DO_gKCe4.js";
5
- import { _ as n } from "./ChartTreemap.vue_vue_type_script_setup_true_lang-C5rtKK6M.js";
5
+ import { _ as n } from "./ChartTreemap.vue_vue_type_script_setup_true_lang-DKaI62CD.js";
6
6
  import { D as u } from "./Drawer-Cl9_4uHA.js";
7
7
  import { _ as l } from "./Dropdown.vue_vue_type_script_setup_true_lang-pjG__bX2.js";
8
8
  import { _ as c } from "./FileDrop.vue_vue_type_script_setup_true_lang-DLEH_LLX.js";
@@ -1,5 +1,5 @@
1
1
  import { r } from "./register-component-B-fdqewb.js";
2
- import { _ as s } from "./ChartTreemap.vue_vue_type_script_setup_true_lang-C5rtKK6M.js";
2
+ import { _ as s } from "./ChartTreemap.vue_vue_type_script_setup_true_lang-DKaI62CD.js";
3
3
  const m = {
4
4
  install(o) {
5
5
  r(o, s);
@@ -7,7 +7,7 @@ import { p as r } from "./plugin-D3ADZgWc.js";
7
7
  import "./transform-DSaNEFMr.js";
8
8
  import "./ChartLine.vue_vue_type_style_index_0_lang-DO_gKCe4.js";
9
9
  import { p as o } from "./plugin-DDXOF4cU.js";
10
- import { p as n } from "./plugin-BHLqWB9f.js";
10
+ import { p as n } from "./plugin-B97_3CZA.js";
11
11
  import "./Drawer-Cl9_4uHA.js";
12
12
  import { p as m } from "./plugin-CNwzCYlr.js";
13
13
  import { p as u } from "./plugin-CNqL90UL.js";
package/dist/plugins.js CHANGED
@@ -7,7 +7,7 @@ import { p as S } from "./plugin-D3ADZgWc.js";
7
7
  import "./transform-DSaNEFMr.js";
8
8
  import "./ChartLine.vue_vue_type_style_index_0_lang-DO_gKCe4.js";
9
9
  import { p as v } from "./plugin-DDXOF4cU.js";
10
- import { p as D } from "./plugin-BHLqWB9f.js";
10
+ import { p as D } from "./plugin-B97_3CZA.js";
11
11
  import "./Drawer-Cl9_4uHA.js";
12
12
  import { p as L } from "./plugin-CNwzCYlr.js";
13
13
  import { p as A } from "./plugin-CNqL90UL.js";
package/dist/tamandua.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as n } from "./plugins-Bq2A0z18.js";
1
+ import { p as n } from "./plugins-B1SFJH99.js";
2
2
  const o = {
3
3
  install(s) {
4
4
  for (const i in n)
@@ -5,15 +5,35 @@ declare const _default: {
5
5
  name: string;
6
6
  children: ({
7
7
  value: number;
8
- label: string;
9
- tooltipSlot: string;
8
+ tooltipSlotName: string;
9
+ tooltipSlotComponent?: undefined;
10
+ tooltipSlotComponentProps?: undefined;
11
+ label?: undefined;
12
+ } | {
13
+ value: number;
14
+ tooltipSlotComponent: import('vue').Raw<{
15
+ props: {
16
+ label: {
17
+ type: StringConstructor;
18
+ required: boolean;
19
+ };
20
+ };
21
+ setup(): {};
22
+ template: string;
23
+ }>;
24
+ tooltipSlotComponentProps: {
25
+ label: string;
26
+ };
27
+ tooltipSlotName?: undefined;
28
+ label?: undefined;
10
29
  } | {
11
30
  value: number;
12
31
  label: string;
13
- tooltipSlot?: undefined;
32
+ tooltipSlotName?: undefined;
33
+ tooltipSlotComponent?: undefined;
34
+ tooltipSlotComponentProps?: undefined;
14
35
  })[];
15
36
  };
16
- options: {};
17
37
  };
18
38
  };
19
39
  export default _default;
@@ -1,14 +1,15 @@
1
- export type Node = {
2
- children?: Node[];
1
+ export type ChartTreemapNode = {
2
+ children?: ChartTreemapNode[];
3
3
  color?: string;
4
- label: string;
5
- tooltipSlot?: string;
4
+ label?: string;
5
+ tooltipSlotName?: string;
6
+ tooltipSlotComponent?: any;
7
+ tooltipSlotComponentProps?: Record<string, any>;
6
8
  value: number;
7
9
  };
8
10
  export type ChartTreemapProps = {
9
11
  data: {
10
12
  name: string;
11
- children: Node[];
13
+ children: ChartTreemapNode[];
12
14
  };
13
- options: never;
14
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caipira/tamandua",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "private": false,
5
5
  "description": "UI library for the Caipira ecosystem",
6
6
  "license": "GPL-3.0-only",
@@ -1,309 +0,0 @@
1
- import { defineComponent as z, ref as M, onMounted as D, openBlock as C, createElementBlock as I, Fragment as R, createElementVNode as T, normalizeStyle as V, unref as E, renderSlot as L, createTextVNode as O, toDisplayString as F } from "vue";
2
- import { r as H, s as q } from "./transform-DSaNEFMr.js";
3
- import { u as P, o as W, c as X } from "./floating-ui.vue-B5QcGNjh.js";
4
- function Y(e) {
5
- var t = 0, r = e.children, a = r && r.length;
6
- if (!a)
7
- t = 1;
8
- else
9
- for (; --a >= 0; )
10
- t += r[a].value;
11
- e.value = t;
12
- }
13
- function j() {
14
- return this.eachAfter(Y);
15
- }
16
- function Z(e, t) {
17
- let r = -1;
18
- for (const a of this)
19
- e.call(t, a, ++r, this);
20
- return this;
21
- }
22
- function G(e, t) {
23
- for (var r = this, a = [r], o, i, u = -1; r = a.pop(); )
24
- if (e.call(t, r, ++u, this), o = r.children)
25
- for (i = o.length - 1; i >= 0; --i)
26
- a.push(o[i]);
27
- return this;
28
- }
29
- function J(e, t) {
30
- for (var r = this, a = [r], o = [], i, u, l, d = -1; r = a.pop(); )
31
- if (o.push(r), i = r.children)
32
- for (u = 0, l = i.length; u < l; ++u)
33
- a.push(i[u]);
34
- for (; r = o.pop(); )
35
- e.call(t, r, ++d, this);
36
- return this;
37
- }
38
- function K(e, t) {
39
- let r = -1;
40
- for (const a of this)
41
- if (e.call(t, a, ++r, this))
42
- return a;
43
- }
44
- function Q(e) {
45
- return this.eachAfter(function(t) {
46
- for (var r = +e(t.data) || 0, a = t.children, o = a && a.length; --o >= 0; )
47
- r += a[o].value;
48
- t.value = r;
49
- });
50
- }
51
- function U(e) {
52
- return this.eachBefore(function(t) {
53
- t.children && t.children.sort(e);
54
- });
55
- }
56
- function ee(e) {
57
- for (var t = this, r = te(t, e), a = [t]; t !== r; )
58
- t = t.parent, a.push(t);
59
- for (var o = a.length; e !== r; )
60
- a.splice(o, 0, e), e = e.parent;
61
- return a;
62
- }
63
- function te(e, t) {
64
- if (e === t)
65
- return e;
66
- var r = e.ancestors(), a = t.ancestors(), o = null;
67
- for (e = r.pop(), t = a.pop(); e === t; )
68
- o = e, e = r.pop(), t = a.pop();
69
- return o;
70
- }
71
- function ne() {
72
- for (var e = this, t = [e]; e = e.parent; )
73
- t.push(e);
74
- return t;
75
- }
76
- function re() {
77
- return Array.from(this);
78
- }
79
- function ae() {
80
- var e = [];
81
- return this.eachBefore(function(t) {
82
- t.children || e.push(t);
83
- }), e;
84
- }
85
- function ie() {
86
- var e = this, t = [];
87
- return e.each(function(r) {
88
- r !== e && t.push({ source: r.parent, target: r });
89
- }), t;
90
- }
91
- function* oe() {
92
- var e = this, t, r = [e], a, o, i;
93
- do
94
- for (t = r.reverse(), r = []; e = t.pop(); )
95
- if (yield e, a = e.children)
96
- for (o = 0, i = a.length; o < i; ++o)
97
- r.push(a[o]);
98
- while (r.length);
99
- }
100
- function N(e, t) {
101
- e instanceof Map ? (e = [void 0, e], t === void 0 && (t = fe)) : t === void 0 && (t = le);
102
- for (var r = new $(e), a, o = [r], i, u, l, d; a = o.pop(); )
103
- if ((u = t(a.data)) && (d = (u = Array.from(u)).length))
104
- for (a.children = u, l = d - 1; l >= 0; --l)
105
- o.push(i = u[l] = new $(u[l])), i.parent = a, i.depth = a.depth + 1;
106
- return r.eachBefore(ce);
107
- }
108
- function ue() {
109
- return N(this).eachBefore(se);
110
- }
111
- function le(e) {
112
- return e.children;
113
- }
114
- function fe(e) {
115
- return Array.isArray(e) ? e[1] : null;
116
- }
117
- function se(e) {
118
- e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
119
- }
120
- function ce(e) {
121
- var t = 0;
122
- do
123
- e.height = t;
124
- while ((e = e.parent) && e.height < ++t);
125
- }
126
- function $(e) {
127
- this.data = e, this.depth = this.height = 0, this.parent = null;
128
- }
129
- $.prototype = N.prototype = {
130
- constructor: $,
131
- count: j,
132
- each: Z,
133
- eachAfter: J,
134
- eachBefore: G,
135
- find: K,
136
- sum: Q,
137
- sort: U,
138
- path: ee,
139
- ancestors: ne,
140
- descendants: re,
141
- leaves: ae,
142
- links: ie,
143
- copy: ue,
144
- [Symbol.iterator]: oe
145
- };
146
- function de(e) {
147
- if (typeof e != "function")
148
- throw new Error();
149
- return e;
150
- }
151
- function x() {
152
- return 0;
153
- }
154
- function A(e) {
155
- return function() {
156
- return e;
157
- };
158
- }
159
- function he(e) {
160
- e.x0 = Math.round(e.x0), e.y0 = Math.round(e.y0), e.x1 = Math.round(e.x1), e.y1 = Math.round(e.y1);
161
- }
162
- function pe(e, t, r, a, o) {
163
- for (var i = e.children, u, l = -1, d = i.length, m = e.value && (a - t) / e.value; ++l < d; )
164
- u = i[l], u.y0 = r, u.y1 = o, u.x0 = t, u.x1 = t += u.value * m;
165
- }
166
- function ge(e, t, r, a, o) {
167
- for (var i = e.children, u, l = -1, d = i.length, m = e.value && (o - r) / e.value; ++l < d; )
168
- u = i[l], u.x0 = t, u.x1 = a, u.y0 = r, u.y1 = r += u.value * m;
169
- }
170
- var ve = (1 + Math.sqrt(5)) / 2;
171
- function me(e, t, r, a, o, i) {
172
- for (var u = [], l = t.children, d, m, f = 0, y = 0, n = l.length, g, v, c = t.value, s, p, w, _, S, k, b; f < n; ) {
173
- g = o - r, v = i - a;
174
- do
175
- s = l[y++].value;
176
- while (!s && y < n);
177
- for (p = w = s, k = Math.max(v / g, g / v) / (c * e), b = s * s * k, S = Math.max(w / b, b / p); y < n; ++y) {
178
- if (s += m = l[y].value, m < p && (p = m), m > w && (w = m), b = s * s * k, _ = Math.max(w / b, b / p), _ > S) {
179
- s -= m;
180
- break;
181
- }
182
- S = _;
183
- }
184
- u.push(d = { value: s, dice: g < v, children: l.slice(f, y) }), d.dice ? pe(d, r, a, o, c ? a += v * s / c : i) : ge(d, r, a, c ? r += g * s / c : o, i), c -= s, f = y;
185
- }
186
- return u;
187
- }
188
- const ye = function e(t) {
189
- function r(a, o, i, u, l) {
190
- me(t, a, o, i, u, l);
191
- }
192
- return r.ratio = function(a) {
193
- return e((a = +a) > 1 ? a : 1);
194
- }, r;
195
- }(ve);
196
- function be() {
197
- var e = ye, t = !1, r = 1, a = 1, o = [0], i = x, u = x, l = x, d = x, m = x;
198
- function f(n) {
199
- return n.x0 = n.y0 = 0, n.x1 = r, n.y1 = a, n.eachBefore(y), o = [0], t && n.eachBefore(he), n;
200
- }
201
- function y(n) {
202
- var g = o[n.depth], v = n.x0 + g, c = n.y0 + g, s = n.x1 - g, p = n.y1 - g;
203
- s < v && (v = s = (v + s) / 2), p < c && (c = p = (c + p) / 2), n.x0 = v, n.y0 = c, n.x1 = s, n.y1 = p, n.children && (g = o[n.depth + 1] = i(n) / 2, v += m(n) - g, c += u(n) - g, s -= l(n) - g, p -= d(n) - g, s < v && (v = s = (v + s) / 2), p < c && (c = p = (c + p) / 2), e(n, v, c, s, p));
204
- }
205
- return f.round = function(n) {
206
- return arguments.length ? (t = !!n, f) : t;
207
- }, f.size = function(n) {
208
- return arguments.length ? (r = +n[0], a = +n[1], f) : [r, a];
209
- }, f.tile = function(n) {
210
- return arguments.length ? (e = de(n), f) : e;
211
- }, f.padding = function(n) {
212
- return arguments.length ? f.paddingInner(n).paddingOuter(n) : f.paddingInner();
213
- }, f.paddingInner = function(n) {
214
- return arguments.length ? (i = typeof n == "function" ? n : A(+n), f) : i;
215
- }, f.paddingOuter = function(n) {
216
- return arguments.length ? f.paddingTop(n).paddingRight(n).paddingBottom(n).paddingLeft(n) : f.paddingTop();
217
- }, f.paddingTop = function(n) {
218
- return arguments.length ? (u = typeof n == "function" ? n : A(+n), f) : u;
219
- }, f.paddingRight = function(n) {
220
- return arguments.length ? (l = typeof n == "function" ? n : A(+n), f) : l;
221
- }, f.paddingBottom = function(n) {
222
- return arguments.length ? (d = typeof n == "function" ? n : A(+n), f) : d;
223
- }, f.paddingLeft = function(n) {
224
- return arguments.length ? (m = typeof n == "function" ? n : A(+n), f) : m;
225
- }, f;
226
- }
227
- function we(e) {
228
- for (var t = e.length / 6 | 0, r = new Array(t), a = 0; a < t; )
229
- r[a] = "#" + e.slice(a * 6, ++a * 6);
230
- return r;
231
- }
232
- const _e = (e) => H(e[e.length - 1]);
233
- var ke = new Array(3).concat(
234
- "fc8d59ffffbf99d594",
235
- "d7191cfdae61abdda42b83ba",
236
- "d7191cfdae61ffffbfabdda42b83ba",
237
- "d53e4ffc8d59fee08be6f59899d5943288bd",
238
- "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
239
- "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
240
- "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
241
- "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
242
- "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
243
- ).map(we);
244
- const Be = _e(ke), Me = /* @__PURE__ */ T("svg", null, null, -1);
245
- let xe = 0;
246
- const $e = /* @__PURE__ */ z({
247
- name: "TChartTreemap",
248
- __name: "ChartTreemap",
249
- props: {
250
- data: {},
251
- options: {}
252
- },
253
- setup(e) {
254
- const t = e, r = `tamandua-chart-treemap-${++xe}`, a = M(0), o = M(0), i = M(), u = M(), l = M(), { floatingStyles: d, update: m } = P(u, i, {
255
- middleware: [W(10), X()]
256
- }), f = (c) => {
257
- l.value = c;
258
- }, y = () => {
259
- !i.value || i.value.style.display === "none" || (i.value.style.display = "none");
260
- }, n = () => {
261
- !i.value || i.value.style.display === "block" || (i.value.style.display = "block");
262
- }, g = (c) => {
263
- a.value = c.pageX, o.value = c.pageY, m();
264
- }, v = () => {
265
- const s = parseInt(
266
- q(`div#${r}`).style("width"),
267
- 10
268
- ), p = 350, w = q(`div#${r} svg`).attr("width", s).attr("height", p).append("g"), _ = N(t.data).sum((h) => h?.value ?? 0).sort(
269
- (h, B) => (B.value ?? 0) - (h.value ?? 0)
270
- ), k = be().size([s, p]).padding(1)(_), b = Be;
271
- w.selectAll("rect").data(k.leaves()).enter().append("rect").attr("x", (h) => h.x0).attr("y", (h) => h.y0).attr("width", (h) => h.x1 - h.x0).attr("height", (h) => h.y1 - h.y0).attr("fill", (h, B) => h.data.color ? h.data.color : h.parent?.data?.color ? h.parent?.data?.color : b(B / 7)).on("mouseover", (h, B) => f(B.data));
272
- };
273
- return D(() => {
274
- v();
275
- }), (c, s) => (C(), I(R, null, [
276
- T("div", {
277
- id: r,
278
- class: "w-full",
279
- onMousemove: g,
280
- onMouseenter: n,
281
- onMouseleave: y
282
- }, [
283
- Me,
284
- T("div", {
285
- ref_key: "reference",
286
- ref: u,
287
- class: "w-1 h-1 absolute",
288
- style: V({
289
- left: `${a.value}px`,
290
- top: `${o.value}px`
291
- })
292
- }, null, 4)
293
- ], 32),
294
- T("div", {
295
- ref_key: "tooltip",
296
- ref: i,
297
- style: V(E(d)),
298
- class: "hidden absolute select-none bg-caipira-primary border-color text-base px-2 py-1 rounded-sm"
299
- }, [
300
- l.value?.tooltipSlot && c.$slots.hasOwnProperty(l.value.tooltipSlot) ? L(c.$slots, l.value.tooltipSlot, { key: 0 }) : (C(), I(R, { key: 1 }, [
301
- O(F(l.value?.label), 1)
302
- ], 64))
303
- ], 4)
304
- ], 64));
305
- }
306
- });
307
- export {
308
- $e as _
309
- };