@devgateway/dvz-ui-react 1.4.0 → 1.5.1

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.
Files changed (120) hide show
  1. package/dist/cjs/common.css +1 -1
  2. package/dist/cjs/embeddable/big-number-trend/index.js +1 -1
  3. package/dist/cjs/embeddable/body/index.js +1 -1
  4. package/dist/cjs/embeddable/chart/Bar.js +1 -1
  5. package/dist/cjs/embeddable/chart/Line.js +1 -1
  6. package/dist/cjs/embeddable/chart/colors/ColorProvider.js +1 -1
  7. package/dist/cjs/embeddable/chart/colors/ManualColors.js +1 -1
  8. package/dist/cjs/embeddable/chart/colors/SystemColors.js +1 -1
  9. package/dist/cjs/embeddable/chart/data/Bar.js +1 -1
  10. package/dist/cjs/embeddable/chart/data/Line.js +1 -1
  11. package/dist/cjs/embeddable/chart/data/Utils.js +1 -1
  12. package/dist/cjs/embeddable/d3Map/BaseLayer.js +1 -1
  13. package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
  14. package/dist/cjs/embeddable/d3Map/FlowLayer.js +1 -1
  15. package/dist/cjs/embeddable/data/DataContext.js +1 -1
  16. package/dist/cjs/embeddable/featuredtabs/index.js +1 -1
  17. package/dist/cjs/embeddable/filter/index.js +1 -1
  18. package/dist/cjs/embeddable/filtered-posts/NoData.js +11 -0
  19. package/dist/cjs/embeddable/filtered-posts/index.js +1 -0
  20. package/dist/cjs/embeddable/index.js +1 -1
  21. package/dist/cjs/embeddable/inlinelist/index.js +1 -1
  22. package/dist/cjs/embeddable/map/MapDataFrame.js +1 -1
  23. package/dist/cjs/embeddable/map/index.js +2 -2
  24. package/dist/cjs/embeddable/map/map.js +4 -4
  25. package/dist/cjs/embeddable/posts-filter/PostsFilterDropdown.js +1 -0
  26. package/dist/cjs/embeddable/posts-filter/index.js +1 -0
  27. package/dist/cjs/embeddable/posts-filters-reset-button/index.js +1 -0
  28. package/dist/cjs/embeddable/posts-pagination/index.js +1 -0
  29. package/dist/cjs/embeddable/reducers/data-api.js +1 -1
  30. package/dist/cjs/embeddable/reducers/data.js +1 -1
  31. package/dist/cjs/embeddable/showcase/index.js +1 -1
  32. package/dist/cjs/embeddable/time-line/mobile.js +1 -1
  33. package/dist/cjs/embeddable/vertical-featuredtabs/index.js +2 -2
  34. package/dist/cjs/index.js +1 -1
  35. package/dist/cjs/layout/ClassicHeader.js +1 -1
  36. package/dist/cjs/layout/CustomSemanticSearch.js +1 -1
  37. package/dist/cjs/layout/Header.js +3 -3
  38. package/dist/cjs/layout/Layout.js +1 -1
  39. package/dist/cjs/layout/SearchControl.js +1 -1
  40. package/dist/cjs/styles.css +1 -1
  41. package/dist/cjs/translations/am.json.js +1 -0
  42. package/dist/cjs/utils/data.js +1 -1
  43. package/dist/esm/common.css +1 -1
  44. package/dist/esm/embeddable/big-number-trend/index.js +36 -36
  45. package/dist/esm/embeddable/body/index.js +141 -95
  46. package/dist/esm/embeddable/chart/Bar.js +390 -382
  47. package/dist/esm/embeddable/chart/Line.js +101 -102
  48. package/dist/esm/embeddable/chart/colors/ColorProvider.js +42 -39
  49. package/dist/esm/embeddable/chart/colors/ManualColors.js +40 -29
  50. package/dist/esm/embeddable/chart/colors/SystemColors.js +28 -17
  51. package/dist/esm/embeddable/chart/data/Bar.js +112 -114
  52. package/dist/esm/embeddable/chart/data/Line.js +126 -126
  53. package/dist/esm/embeddable/chart/data/Utils.js +32 -26
  54. package/dist/esm/embeddable/d3Map/BaseLayer.js +3 -8
  55. package/dist/esm/embeddable/d3Map/DataLayer.js +2 -9
  56. package/dist/esm/embeddable/d3Map/FlowLayer.js +12 -15
  57. package/dist/esm/embeddable/data/DataContext.js +1 -0
  58. package/dist/esm/embeddable/featuredtabs/index.js +128 -124
  59. package/dist/esm/embeddable/filter/index.js +207 -206
  60. package/dist/esm/embeddable/filtered-posts/NoData.js +31 -0
  61. package/dist/esm/embeddable/filtered-posts/index.js +123 -0
  62. package/dist/esm/embeddable/index.js +34 -31
  63. package/dist/esm/embeddable/inlinelist/index.js +82 -70
  64. package/dist/esm/embeddable/map/MapDataFrame.js +17 -14
  65. package/dist/esm/embeddable/map/index.js +180 -169
  66. package/dist/esm/embeddable/map/map.js +520 -437
  67. package/dist/esm/embeddable/posts-filter/PostsFilterDropdown.js +190 -0
  68. package/dist/esm/embeddable/posts-filter/index.js +215 -0
  69. package/dist/esm/embeddable/posts-filters-reset-button/index.js +33 -0
  70. package/dist/esm/embeddable/posts-pagination/index.js +69 -0
  71. package/dist/esm/embeddable/reducers/data-api.js +40 -25
  72. package/dist/esm/embeddable/reducers/data.js +180 -99
  73. package/dist/esm/embeddable/showcase/index.js +1 -1
  74. package/dist/esm/embeddable/time-line/mobile.js +158 -182
  75. package/dist/esm/embeddable/vertical-featuredtabs/index.js +177 -168
  76. package/dist/esm/index.js +69 -25
  77. package/dist/esm/layout/ClassicHeader.js +62 -62
  78. package/dist/esm/layout/CustomSemanticSearch.js +40 -102
  79. package/dist/esm/layout/Header.js +152 -144
  80. package/dist/esm/layout/Layout.js +4 -3
  81. package/dist/esm/layout/SearchControl.js +130 -113
  82. package/dist/esm/styles.css +1 -1
  83. package/dist/esm/translations/am.json.js +46 -0
  84. package/dist/esm/utils/data.js +4 -9
  85. package/dist/types/dvz-ui/src/countries.d.ts +7 -0
  86. package/dist/types/dvz-ui/src/embeddable/chart/colors/ManualColors.d.ts +1 -1
  87. package/dist/types/dvz-ui/src/embeddable/chart/colors/SystemColors.d.ts +1 -1
  88. package/dist/types/dvz-ui/src/embeddable/data/DataContext.d.ts +1 -0
  89. package/dist/types/dvz-ui/src/embeddable/featuredtabs/index.d.ts +1 -0
  90. package/dist/types/dvz-ui/src/embeddable/filtered-posts/NoData.d.ts +7 -0
  91. package/dist/types/dvz-ui/src/embeddable/filtered-posts/index.d.ts +21 -0
  92. package/dist/types/dvz-ui/src/embeddable/inlinelist/index.d.ts +2 -0
  93. package/dist/types/dvz-ui/src/embeddable/map/MapDataFrame.d.ts +1 -6
  94. package/dist/types/dvz-ui/src/embeddable/map/map.d.ts +1 -0
  95. package/dist/types/dvz-ui/src/embeddable/posts-filter/PostsFilterDropdown.d.ts +21 -0
  96. package/dist/types/dvz-ui/src/embeddable/posts-filter/index.d.ts +25 -0
  97. package/dist/types/dvz-ui/src/embeddable/posts-filters-reset-button/index.d.ts +3 -0
  98. package/dist/types/dvz-ui/src/embeddable/posts-pagination/index.d.ts +10 -0
  99. package/dist/types/dvz-ui/src/embeddable/reducers/data-api.d.ts +11 -0
  100. package/dist/types/dvz-ui/src/embeddable/reducers/post-reducer.d.ts +158 -0
  101. package/dist/types/dvz-ui/src/embeddable/time-line/mobile.d.ts +1 -2
  102. package/dist/types/dvz-ui/src/embeddable/vertical-featuredtabs/index.d.ts +1 -0
  103. package/dist/types/dvz-ui/src/index.d.ts +3 -0
  104. package/dist/types/dvz-ui/src/layout/Header.d.ts +2 -2
  105. package/dist/types/dvz-ui/src/translations/am.json.d.ts +39 -0
  106. package/package.json +7 -5
  107. package/dist/cjs/embeddable/posts-with-filters/DropDownFilter.js +0 -1
  108. package/dist/cjs/embeddable/posts-with-filters/Post.js +0 -1
  109. package/dist/cjs/embeddable/posts-with-filters/index.js +0 -1
  110. package/dist/esm/embeddable/posts-with-filters/DropDownFilter.js +0 -25
  111. package/dist/esm/embeddable/posts-with-filters/Post.js +0 -51
  112. package/dist/esm/embeddable/posts-with-filters/index.js +0 -206
  113. package/dist/types/dvz-ui/src/embeddable/posts-with-filters/DropDownFilter.d.ts +0 -4
  114. package/dist/types/dvz-ui/src/embeddable/posts-with-filters/Post.d.ts +0 -5
  115. package/dist/types/dvz-ui/src/embeddable/posts-with-filters/index.d.ts +0 -21
  116. /package/dist/cjs/{utils/countries.js → countries.js} +0 -0
  117. /package/dist/cjs/embeddable/{posts-with-filters → filtered-posts}/utils.js +0 -0
  118. /package/dist/esm/{utils/countries.js → countries.js} +0 -0
  119. /package/dist/esm/embeddable/{posts-with-filters → filtered-posts}/utils.js +0 -0
  120. /package/dist/types/dvz-ui/src/embeddable/{posts-with-filters → filtered-posts}/utils.d.ts +0 -0
@@ -1,45 +1,56 @@
1
- import x from "./Colors.js";
2
- class O extends x {
3
- constructor(t, a, o, m, y, n, b, v, u, e = {}, f, g, c) {
4
- if (super(o, m, y, v, u), this._manualColor = {}, this._manualColor[g] = e ? e.Overall : null, t != "csv") {
5
- const _ = (i) => {
6
- h = [...n][i] ? [...n][i].items : [], e != null && e != null && Object.keys(e).forEach((r) => {
7
- const l = h.filter((s) => s.code === r);
1
+ import I from "./Colors.js";
2
+ class j extends I {
3
+ constructor(s, h, n, p, g, i, c, y, _, t = {}, o, v, b, u) {
4
+ if (super(n, p, g, y, _), this._manualColor = {}, this._manualColor[v] = t ? t.Overall : null, s != "csv") {
5
+ const m = (e) => {
6
+ f = [...i][e] ? [...i][e].items : [], t != null && t != null && Object.keys(t).forEach((a) => {
7
+ const l = f.filter((r) => r.code === a);
8
8
  if (l.length > 0 && l[0].labels) {
9
- let s;
10
- f && (s = l[0].labels[f.toUpperCase()]), s ? this._manualColor[s] = e[r] : this._manualColor[l[0].value] = e[r];
9
+ let r;
10
+ o && (r = l[0].labels[o.toUpperCase()]), r ? this._manualColor[r] = t[a] : this._manualColor[l[0].value] = t[a];
11
11
  }
12
12
  });
13
- }, C = () => {
14
- h = b, Object.keys(e).forEach((i) => {
15
- const r = [...h].filter((l) => l.value === i);
16
- if (r.length > 0 && r[0].labels) {
17
- const l = c[i];
18
- c && l && (this._manualColor[l] = e[i]);
19
- let s;
20
- f && (s = r[0].labels[f.toUpperCase()]), s ? this._manualColor[s] = e[i] : this._manualColor[r[0].label] = e[i];
13
+ }, x = (e) => e == null ? void 0 : e.map((l) => {
14
+ const r = l.group.label;
15
+ return l.label.includes(r) ? l : {
16
+ ...l,
17
+ label: `${r} - ${l.label}`
18
+ };
19
+ }), B = () => {
20
+ var e;
21
+ return c && c.size > 0 ? c : ((e = u == null ? void 0 : u.metadata) == null ? void 0 : e.measures.length) > 0 ? (u.metadata.measures = x(
22
+ u.metadata.measures
23
+ ), u.metadata.measures) : [];
24
+ }, d = () => {
25
+ f = B(), Object.keys(t).forEach((e) => {
26
+ const a = [...f].filter((l) => l.value === e);
27
+ if (a.length > 0 && a[0].labels) {
28
+ const l = b[e];
29
+ b && l && (this._manualColor[l] = t[e]);
30
+ let r;
31
+ o && (r = a[0].labels[o.toUpperCase()]), r ? this._manualColor[r] = t[e] : this._manualColor[a[0].label] = t[e];
21
32
  }
22
33
  });
23
34
  };
24
- let h = [];
25
- const p = o === "index" ? 0 : 1;
26
- n ? n.size == 1 && p == 1 ? u == "measure" ? _(0) : C() : _(p) : C();
35
+ let f = [];
36
+ const C = h === "line" ? 1 : n === "index" ? 0 : 1;
37
+ i ? i.size == 1 && C == 1 ? _ == "measure" ? m(0) : d() : m(C) : d();
27
38
  } else
28
- this._manualColor = e;
39
+ this._manualColor = t;
29
40
  }
30
- getColor(t, a) {
41
+ getColor(s, h) {
31
42
  if (this.colorBy === "index") {
32
- const o = this._manualColor[t] || this._manualColor[a[this.indexBy]];
33
- return o || "#5555";
43
+ const n = this._manualColor[s] || this._manualColor[h[this.indexBy]];
44
+ return n || "#5555";
34
45
  }
35
- return this.colorBy === "id" && this._manualColor[t] ? this._manualColor[t] : "#5555";
46
+ return this.colorBy === "id" && this._manualColor[s] ? this._manualColor[s] : "#5555";
36
47
  }
37
- getColorByIndex(t) {
48
+ getColorByIndex(s) {
38
49
  }
39
- getColorByKey(t) {
40
- return this._manualColor[t] ? this._manualColor[t] : "#5555";
50
+ getColorByKey(s) {
51
+ return this._manualColor[s] ? this._manualColor[s] : "#5555";
41
52
  }
42
53
  }
43
54
  export {
44
- O as default
55
+ j as default
45
56
  };
@@ -1,25 +1,36 @@
1
- import M from "./Colors.js";
2
- const l = "#9F9F9F";
3
- class b extends M {
4
- constructor(r, e, i, a, y, c, f, p, h, t) {
5
- super(i, a, y, c, f), this.colorMap = {}, this._colorBy = e == "line" ? "id" : i, this._indexBy && p && [...p].forEach((o) => {
6
- o && o.items && o.items.forEach((s) => {
7
- t && s.labels && s.labels[t.toUpperCase()] ? this.colorMap[s.labels[t.toUpperCase()]] = s.categoryStyle : this.colorMap[s.value] = s.categoryStyle;
1
+ import x from "./Colors.js";
2
+ const c = "#9F9F9F";
3
+ class M extends x {
4
+ constructor(e, h, u, i, y, b, C, a, o, s, t) {
5
+ super(u, i, y, b, C), this.colorMap = {}, this._colorBy = h == "line" ? "id" : u;
6
+ const n = (r) => r == null ? void 0 : r.map((p) => {
7
+ const f = p.group.label;
8
+ return p.label.includes(f) ? p : {
9
+ ...p,
10
+ label: `${f} - ${p.label}`
11
+ };
12
+ }), g = () => {
13
+ var r;
14
+ return o && o.size > 0 ? o : ((r = t == null ? void 0 : t.metadata) == null ? void 0 : r.measures.length) > 0 ? (t.metadata.measures = n(t.metadata.measures), t.metadata.measures) : [];
15
+ };
16
+ this._indexBy && (a == null ? void 0 : a.size) > 0 && [...a].forEach((r) => {
17
+ r && r.items && r.items.forEach((l) => {
18
+ s && l.labels && l.labels[s.toUpperCase()] ? this.colorMap[l.labels[s.toUpperCase()]] = l.categoryStyle : this.colorMap[l.value] = l.categoryStyle;
8
19
  });
9
- }), h && [...h].forEach((o) => {
10
- o && o.styles && (t && o.labels && o.labels[t.toUpperCase()] ? this.colorMap[o.labels[t.toUpperCase()]] = o.styles : this.colorMap[o.label] = o.styles);
11
- });
20
+ }), o && (o = g(), [...o].forEach((r) => {
21
+ r && r.styles && (s && r.labels && r.labels[s.toUpperCase()] ? this.colorMap[r.labels[s.toUpperCase()]] = r.styles : this.colorMap[r.label] = r.styles);
22
+ }));
12
23
  }
13
- getColor(r, e) {
14
- return this._colorBy === "index" ? this.colorMap[e[this._indexBy]] ? this.colorMap[e[this._indexBy]].color : l : this.colorMap[r] ? this.colorMap[r].color : l;
24
+ getColor(e, h) {
25
+ return this._colorBy === "index" ? this.colorMap[h[this._indexBy]] ? this.colorMap[h[this._indexBy]].color : c : this.colorMap[e] ? this.colorMap[e].color : c;
15
26
  }
16
- getColorByIndex(r) {
17
- return this.colorMap[r] ? this.colorMap[r].color : l;
27
+ getColorByIndex(e) {
28
+ return this.colorMap[e] ? this.colorMap[e].color : c;
18
29
  }
19
- getColorByKey(r) {
20
- return this.colorMap[r] ? this.colorMap[r].color : l;
30
+ getColorByKey(e) {
31
+ return this.colorMap[e] ? this.colorMap[e].color : c;
21
32
  }
22
33
  }
23
34
  export {
24
- b as default
35
+ M as default
25
36
  };
@@ -1,203 +1,201 @@
1
- import { jsx as F, Fragment as P } from "react/jsx-runtime";
2
- import K from "react";
3
- import { measuresMap as U, typesMap as q, getTranslatedValue as _, alphaSort as J, dateSort as V, numericSort as T } from "./Utils.js";
1
+ import { jsx as J, Fragment as P } from "react/jsx-runtime";
2
+ import F from "react";
3
+ import { measuresMap as U, typesMap as q, getTranslatedValue as N, alphaSort as V, dateSort as _, numericSort as T } from "./Utils.js";
4
4
  const z = (a) => {
5
- const { data: t, measures: d, swap: w, dimensions: b, locale: E, customLabels: O } = a;
5
+ const { data: t, measures: v, swap: w, dimensions: g, locale: E, customLabels: O } = a;
6
6
  let n = {};
7
- const A = b.filter((x) => x != ""), C = /* @__PURE__ */ new Set();
8
- if (A.length == 0 && t) {
9
- const x = U(t), M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set();
10
- let c = [], r;
7
+ const R = g.filter((j) => j != ""), C = /* @__PURE__ */ new Set();
8
+ if (R.length == 0 && t) {
9
+ const j = U(t), A = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set();
10
+ let u = [], r;
11
11
  if (t.metadata && t.metadata.measures) {
12
- const h = t.metadata.measures.filter((o) => d.includes(o.value)).sort((o, y) => o.position != null && y.position != null && o.position != y.position ? o.position - y.position : 0);
13
- c = [], r = "measure", M.add("measure");
14
- const B = {};
12
+ const y = t.metadata.measures.filter((o) => v.includes(o.value)).sort((o, p) => o.position != null && p.position != null && o.position != p.position ? o.position - p.position : 0);
13
+ u = [], r = "measure", A.add("measure");
14
+ const x = {};
15
15
  Object.keys(t).forEach((o) => {
16
- B[o] = t[o];
17
- }), h.forEach((o) => {
18
- const y = {}, v = O[o.value] || _(x[o.value], E);
19
- y.type = "measure", y.measureFieldName = o.value, y.measure = v, y[v] = t[o.value], y.variables = B, c.push(y), N.add(v), C.add(x[o.value]);
16
+ x[o] = t[o];
17
+ }), y.forEach((o) => {
18
+ const p = {}, b = O[o.value] || N(j[o.value], E);
19
+ p.type = "measure", p.measureFieldName = o.value, p.measure = b, p[b] = t[o.value], p.variables = x, u.push(p), M.add(b), C.add(j[o.value]);
20
20
  }), n = {
21
- categories: M,
21
+ categories: A,
22
22
  indexBy: r,
23
- keys: Array.from(N),
23
+ keys: Array.from(M),
24
24
  measuresMetadata: C,
25
- data: c
25
+ data: u
26
26
  };
27
27
  }
28
28
  }
29
29
  return n;
30
30
  }, G = (a) => {
31
- const { data: t, measures: d, dimensions: w, overallLabel: b } = a;
31
+ const { data: t, measures: v, dimensions: w, overallLabel: g } = a;
32
32
  if (w.length == 1 && t.children) {
33
- if (!(t.children.filter((O) => O.value == b).length > 0)) {
33
+ if (!(t.children.filter((O) => O.value == g).length > 0)) {
34
34
  const O = {};
35
- O.type = w[0], O.value = b, O.label = b, Object.keys(t).forEach((n) => {
35
+ O.type = w[0], O.value = g, O.label = g, Object.keys(t).forEach((n) => {
36
36
  ["children", "metadata", "type", "value"].includes(n) || (O[n] = t[n]);
37
37
  }), t.children = [O, ...t.children];
38
38
  }
39
39
  } else w.length == 2 && t.children && t.children.forEach((E) => {
40
- if (!(E.children.filter((n) => n.value == b).length > 0)) {
40
+ if (!(E.children.filter((n) => n.value == g).length > 0)) {
41
41
  const n = {};
42
- n.type = w[1], n.value = b, n.label = b, Object.keys(E).forEach((A) => {
43
- ["children", "metadata", "type", "value"].includes(A) || (n[A] = E[A]);
42
+ n.type = w[1], n.value = g, n.label = g, Object.keys(E).forEach((R) => {
43
+ ["children", "metadata", "type", "value"].includes(R) || (n[R] = E[R]);
44
44
  }), E.children = [n, ...E.children];
45
45
  }
46
46
  });
47
47
  return t;
48
48
  }, Q = (a) => {
49
- var c;
49
+ var u;
50
50
  let t = {};
51
51
  const {
52
- data: d,
52
+ data: v,
53
53
  measures: w,
54
- swap: b,
54
+ swap: g,
55
55
  dimensions: E,
56
56
  includeOverall: O,
57
57
  locale: n,
58
- customLabels: A,
58
+ customLabels: R,
59
59
  colorBy: C,
60
- hiddenBars: x
61
- } = a, M = E.filter((r) => r != ""), N = (c = d == null ? void 0 : d.metadata) == null ? void 0 : c.measures.filter((r) => w.includes(r.value)).sort((r, h) => r.position != null && h.position != null && r.position != h.position ? r.position - h.position : 0);
62
- if (O && w.length == 1 && G(a), M.length == 0 && d)
60
+ hiddenBars: j
61
+ } = a, A = E.filter((r) => r != ""), M = (u = v == null ? void 0 : v.metadata) == null ? void 0 : u.measures.filter((r) => w.includes(r.value)).sort((r, y) => r.position != null && y.position != null && r.position != y.position ? r.position - y.position : 0);
62
+ if (O && w.length == 1 && G(a), A.length == 0 && v)
63
63
  t = z(a);
64
- else if (d && d.children && M.length > 0) {
65
- const r = U(d), h = q(d), B = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), v = [];
66
- let R;
67
- b && M.length == 1 && w.length > 0 ? (R = "measure", N.forEach((s) => {
68
- const u = {};
69
- u.measure = A[s.value] || _(r[s.value], n), o.add(r[s.value]), d.children.forEach((m) => {
70
- const f = _(
71
- h[m.type].items.filter((i) => i.value === m.value)[0],
64
+ else if (v && v.children && A.length > 0) {
65
+ const r = U(v), y = q(v), x = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), b = [];
66
+ let B;
67
+ g && A.length == 1 && w.length > 0 ? (B = "measure", M.forEach((s) => {
68
+ const c = {};
69
+ c.measure = R[s.value] || N(r[s.value], n), o.add(r[s.value]), v.children.forEach((m) => {
70
+ const f = N(
71
+ y[m.type].items.filter((i) => i.value === m.value)[0],
72
72
  n
73
73
  ) || m.value, e = {};
74
74
  Object.keys(m).forEach((i) => {
75
75
  e[i] = m[i];
76
- }), e[m.type] = m.value.toString(), u.variables = e, B.add(h[m.type]), u[f] = m[s.value], y.add(f);
77
- }), v.push({ ...u });
78
- })) : (d.children[0] && (R = d.children[0].type), d.children.forEach((s) => {
79
- const u = {}, m = {};
80
- m[s.type] = _(
81
- h[s.type] && h[s.type].items ? h[s.type].items.filter((f) => f.value === s.value)[0] : s.value,
76
+ }), e[m.type] = m.value.toString(), c.variables = e, x.add(y[m.type]), c[f] = m[s.value], p.add(f);
77
+ }), b.push({ ...c });
78
+ })) : (v.children[0] && (B = v.children[0].type), v.children.forEach((s) => {
79
+ const c = {}, m = {};
80
+ m[s.type] = N(
81
+ y[s.type] && y[s.type].items ? y[s.type].items.filter((f) => f.value === s.value)[0] : s.value,
82
82
  n
83
83
  ) || s.value, Object.keys(s).forEach((f) => {
84
- u[f] = s[f];
85
- }), B.add(h[s.type]), u[s.type] = s.value.toString(), N.map((f) => {
86
- const e = A[f.value] || _(r[f.value], n);
87
- m[e] = s[f.value], o.add(r[f.value]), y.add(e);
88
- }), v.push({ ...m, variables: u, parent_variables: u });
84
+ c[f] = s[f];
85
+ }), x.add(y[s.type]), c[s.type] = s.value.toString(), M.map((f) => {
86
+ const e = R[f.value] || N(r[f.value], n);
87
+ m[e] = s[f.value], o.add(r[f.value]), p.add(e);
88
+ }), b.push({ ...m, variables: c, parent_variables: c });
89
89
  }));
90
- const D = Array.from(y);
91
- let g = x && v ? v.filter((s) => x.indexOf(s[R]) == -1) : v;
92
- a.sort == "alphabetically" && (g = g.sort(
93
- (s, u) => J(a.sortReverse, n, s[R], u[R])
94
- )), a.sort == "date" && (g = g.sort(
95
- (s, u) => V(a.sortReverse, s[R], u[R])
96
- )), a.sort == "values" && (g = g.sort((s, u) => {
97
- const m = Math.max(...D.map((e) => s[e])), f = Math.max(...D.map((e) => u[e]));
90
+ const D = Array.from(p);
91
+ let S = j && b ? b.filter((s) => j.indexOf(s[B]) == -1) : b;
92
+ a.sort == "alphabetically" && (S = S.sort(
93
+ (s, c) => V(a.sortReverse, n, s[B], c[B])
94
+ )), a.sort == "date" && (S = S.sort(
95
+ (s, c) => _(a.sortReverse, s[B], c[B])
96
+ )), a.sort == "values" && (S = S.sort((s, c) => {
97
+ const m = Math.max(...D.map((e) => s[e])), f = Math.max(...D.map((e) => c[e]));
98
98
  return T(a.sortReverse, m, f);
99
99
  })), t = {
100
- metadata: d.metadata,
101
- indexBy: R,
102
- dimensionsMetadata: B,
100
+ metadata: v.metadata,
101
+ indexBy: B,
102
+ dimensionsMetadata: x,
103
103
  measuresMetadata: o,
104
104
  keys: D,
105
- data: g
105
+ data: S
106
106
  };
107
107
  }
108
- return K.Children.map(
108
+ return F.Children.map(
109
109
  a.children,
110
- (r) => K.cloneElement(r, { options: t })
110
+ (r) => F.cloneElement(r, { options: t })
111
111
  );
112
112
  }, W = (a) => {
113
- var M, N;
113
+ var A, M;
114
114
  const {
115
115
  data: t,
116
- measures: d,
116
+ measures: v,
117
117
  includeOverall: w,
118
- dimensions: b,
118
+ dimensions: g,
119
119
  hiddenBars: E,
120
120
  colorBy: O,
121
121
  locale: n,
122
- customLabels: A
123
- } = a, C = b.filter((c) => c != "");
124
- let x = {};
122
+ customLabels: R
123
+ } = a, C = g.filter((u) => u != "");
124
+ let j = {};
125
125
  if (w && G(a), C.length == 0 && t)
126
- x = z(a);
126
+ j = z(a);
127
127
  else if (t && t.children && t.children.length > 0 && C.length > 0) {
128
128
  U(t);
129
- const c = q(t), r = d[0], h = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Set(), o = [], y = [], v = t.children[0].type;
130
- let R = 0, D, g;
129
+ const u = q(t), r = v[0], y = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set(), o = [], p = [], b = t.children[0].type;
130
+ let B = 0, D, S;
131
131
  t.children.forEach((e) => {
132
132
  const i = { variables: {} };
133
- if (g = _(
134
- c[e.type] && c[e.type].items ? c[e.type].items.filter((l) => l.value === e.value)[0] : e.value,
133
+ if (S = N(
134
+ u[e.type] && u[e.type].items ? u[e.type].items.filter((l) => l.value === e.value)[0] : e.value,
135
135
  n
136
- ) || e.value, i[e.type] = g, i[g] = e[r], D = new Object(), D[e.type] = g, i.parent_variables = D, Object.keys(e).forEach((l) => {
136
+ ) || e.value, i[e.type] = S, i[S] = e[r], D = new Object(), D[e.type] = S, i.parent_variables = D, Object.keys(e).forEach((l) => {
137
137
  D[l] = e[l];
138
- }), h.add(c[e.type]), e.children || B.add(g), e.children)
138
+ }), y.add(u[e.type]), e.children || x.add(S), e.children)
139
139
  e.children.forEach((l) => {
140
- D = new Object(), h.add(c[l.type]);
141
- const S = _(
142
- c[l.type] && c[l.type].items ? c[l.type].items.filter((p) => p.value === l.value)[0] : l.value,
140
+ D = new Object(), y.add(u[l.type]);
141
+ const h = N(
142
+ u[l.type] && u[l.type].items ? u[l.type].items.filter((d) => d.value === l.value)[0] : l.value,
143
143
  n
144
144
  ) || l.value;
145
- D[e.type] = g, D[l.type] = S, Object.keys(l).forEach((p) => {
146
- D[p] = l[p];
147
- }), i.variables[S] = D, B.add(S), R += l[r], y.push(l[r]), i[S] = l[r];
145
+ D[e.type] = S, D[l.type] = h, Object.keys(l).forEach((d) => {
146
+ D[d] = l[d];
147
+ }), i.variables[h] = D, x.add(h), B += l[r], p.push(l[r]), i[h] = l[r];
148
148
  });
149
149
  else {
150
150
  const l = new Object();
151
- l[e.type] = g, h.add(c[e.type]), Object.keys(t).forEach((S) => {
152
- l[S] = e[S];
151
+ l[e.type] = S, y.add(u[e.type]), Object.keys(t).forEach((h) => {
152
+ l[h] = e[h];
153
153
  }), i.variables = l;
154
154
  }
155
155
  o.push(i);
156
156
  });
157
- const s = n.toUpperCase(), u = O == "id" ? o : o.filter((e) => E.indexOf(e[v]) == -1), m = Array.from(B);
158
- a.sort == "alphabetically" ? u.sort(
159
- (e, i) => J(a.sortReverse, n, e[v], i[v])
160
- ) : a.sort == "date" ? u.sort(
161
- (e, i) => V(a.sortReverse, e[v], i[v])
162
- ) : a.sort == "values" && u.sort((e, i) => {
163
- if (a.sortSecondDimension == "_total") {
164
- const l = Math.max(...m.map((p) => e[p])), S = Math.max(...m.map((p) => i[p]));
165
- return T(a.sortReverse, l, S);
166
- } else {
167
- const l = Object.keys(e).reduce((p, j) => j !== v && j !== "variables" && j !== "parent_variables" && !isNaN(e[j]) ? p + (e[j] || 0) : p, 0), S = Object.keys(i).reduce((p, j) => j !== v && j !== "variables" && j !== "parent_variables" && !isNaN(i[j]) ? p + (i[j] || 0) : p, 0);
168
- return T(a.sortReverse, l, S);
169
- }
157
+ const s = n.toUpperCase(), c = O == "id" ? o : o.filter((e) => E.indexOf(e[b]) == -1), m = Array.from(x);
158
+ a.sort == "alphabetically" ? c.sort(
159
+ (e, i) => V(a.sortReverse, n, e[b], i[b])
160
+ ) : a.sort == "date" ? c.sort(
161
+ (e, i) => _(a.sortReverse, e[b], i[b])
162
+ ) : a.sort == "values" ? c.sort((e, i) => {
163
+ const l = m.map((d) => e[d]).filter((d) => d).reduce((d, K) => d + K), h = m.map((d) => i[d]).filter((d) => d).reduce((d, K) => d + K);
164
+ return console.log(m.map((d) => e[d])), l == null ? 1 : h == null ? -1 : T(a.sortReverse, l, h);
165
+ }) : c.sort((e, i) => {
166
+ const l = e[a.sort], h = i[a.sort];
167
+ return l == null ? 1 : h == null ? -1 : T(a.sortReverse, l, h);
170
168
  });
171
- const f = [...B];
172
- ((N = (M = t == null ? void 0 : t.metadata) == null ? void 0 : M.types) == null ? void 0 : N.length) > 1 && f.sort((e, i) => {
173
- var l, S;
169
+ const f = [...x];
170
+ ((M = (A = t == null ? void 0 : t.metadata) == null ? void 0 : A.types) == null ? void 0 : M.length) > 1 && f.sort((e, i) => {
171
+ var l, h;
174
172
  if (a.sortSecondDimension == "date")
175
- return V(a.sortReverseSecondDimension, e, i);
173
+ return _(a.sortReverseSecondDimension, e, i);
176
174
  if (a.sortSecondDimension == "alphabetically")
177
- return J(a.sortReverseSecondDimension, n, e, i);
175
+ return V(a.sortReverseSecondDimension, n, e, i);
178
176
  {
179
- const p = t.metadata.types[1].items.filter(
177
+ const d = t.metadata.types[1].items.filter(
180
178
  (L) => L.value == e || L.labels && L.labels[s] == e
181
- ), j = t.metadata.types[1].items.filter(
179
+ ), K = t.metadata.types[1].items.filter(
182
180
  (L) => L.value == i || L.labels && L.labels[s] == i
183
- ), H = (l = p[0]) == null ? void 0 : l.position, I = (S = j[0]) == null ? void 0 : S.position;
181
+ ), H = (l = d[0]) == null ? void 0 : l.position, I = (h = K[0]) == null ? void 0 : h.position;
184
182
  return H - I;
185
183
  }
186
- }), x = {
184
+ }), j = {
187
185
  metadata: t.metadata,
188
- dimensionsMetadata: h,
189
- indexBy: v,
186
+ dimensionsMetadata: y,
187
+ indexBy: b,
190
188
  keys: O == "index" ? f : f.filter((e) => E.indexOf(e) == -1),
191
- data: u
189
+ data: c
192
190
  };
193
191
  }
194
- return /* @__PURE__ */ F(P, { children: K.Children.map(
192
+ return /* @__PURE__ */ J(P, { children: F.Children.map(
195
193
  a.children,
196
- (c) => K.cloneElement(c, { options: x })
194
+ (u) => F.cloneElement(u, { options: j })
197
195
  ) });
198
196
  }, $ = (a) => {
199
- const { data: t, measures: d, dimensions: w } = a, b = JSON.parse(JSON.stringify(t));
200
- return w.length === 1 ? /* @__PURE__ */ F(Q, { ...a, data: b }) : /* @__PURE__ */ F(W, { ...a, data: b });
197
+ const { data: t, measures: v, dimensions: w } = a, g = JSON.parse(JSON.stringify(t));
198
+ return w.length === 1 ? /* @__PURE__ */ J(Q, { ...a, data: g }) : /* @__PURE__ */ J(W, { ...a, data: g });
201
199
  };
202
200
  export {
203
201
  $ as default