@devgateway/dvz-ui-react 1.9.6 → 1.9.8

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,165 +1,169 @@
1
- import { jsx as J, Fragment as Q } from "react/jsx-runtime";
2
- import F from "react";
3
- import { measuresMap as q, typesMap as G, alphaSort as K, numericSort as U, dateSort as T, getTranslatedValue as V } from "./Utils.js";
4
- const H = (t) => {
5
- const { data: e, measures: l, swap: m, dimensions: u, locale: v, customLabels: d } = t;
6
- let i = {};
7
- const h = u.filter((y) => y != ""), A = /* @__PURE__ */ new Set();
8
- if (h.length == 0 && e) {
9
- const y = q(e), D = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set();
1
+ import { jsx as T, Fragment as X } from "react/jsx-runtime";
2
+ import J from "react";
3
+ import { measuresMap as z, typesMap as Q, alphaSort as V, numericSort as Y, dateSort as q, getTranslatedValue as G } from "./Utils.js";
4
+ const U = (t) => {
5
+ const { data: e, measures: s, swap: y, dimensions: f, locale: v, customLabels: c } = t;
6
+ let l = {};
7
+ const S = f.filter((h) => h != ""), L = /* @__PURE__ */ new Set();
8
+ if (S.length == 0 && e) {
9
+ const h = z(e), D = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Set();
10
10
  let E = [], j;
11
11
  if (e.metadata && e.metadata.measures) {
12
- const r = e.metadata.measures.filter((a) => l.includes(a.value)).sort((a, c) => a.position != null && c.position != null && a.position != c.position ? a.position - c.position : 0);
12
+ const N = e.metadata.measures.filter((n) => s.includes(n.value)).sort((n, r) => n.position != null && r.position != null && n.position != r.position ? n.position - r.position : 0);
13
13
  E = [], j = "measure", D.add("measure");
14
- const S = {};
15
- Object.keys(e).forEach((a) => {
16
- S[a] = e[a];
17
- }), r.forEach((a) => {
18
- const c = {}, L = d[a.value] || V(y[a.value], v);
19
- c.type = "measure", c.measureFieldName = a.value, c.measure = L, c[L] = e[a.value], c.variables = S, E.push(c), R.add(L), A.add(y[a.value]);
20
- }), i = {
14
+ const o = {};
15
+ Object.keys(e).forEach((n) => {
16
+ o[n] = e[n];
17
+ }), N.forEach((n) => {
18
+ const r = {}, O = c[n.value] || G(h[n.value], v);
19
+ r.type = "measure", r.measureFieldName = n.value, r.measure = O, r[O] = e[n.value], r.variables = o, E.push(r), B.add(O), L.add(h[n.value]);
20
+ }), l = {
21
21
  categories: D,
22
22
  indexBy: j,
23
- keys: Array.from(R),
24
- measuresMetadata: A,
23
+ keys: Array.from(B),
24
+ measuresMetadata: L,
25
25
  data: E
26
26
  };
27
27
  }
28
28
  }
29
- return i;
30
- }, P = (t) => {
31
- const { data: e, measures: l, dimensions: m, overallLabel: u } = t;
32
- if (m.length == 1 && e.children) {
33
- if (!(e.children.filter((d) => d.value == u).length > 0)) {
34
- const d = {};
35
- d.type = m[0], d.value = u, d.label = u, Object.keys(e).forEach((i) => {
36
- ["children", "metadata", "type", "value"].includes(i) || (d[i] = e[i]);
37
- }), e.children = [d, ...e.children];
29
+ return l;
30
+ }, W = (t) => {
31
+ const { data: e, measures: s, dimensions: y, overallLabel: f } = t;
32
+ if (y.length == 1 && e.children) {
33
+ if (!(e.children.filter((c) => c.value == f).length > 0)) {
34
+ const c = {};
35
+ c.type = y[0], c.value = f, c.label = f, Object.keys(e).forEach((l) => {
36
+ ["children", "metadata", "type", "value"].includes(l) || (c[l] = e[l]);
37
+ }), e.children = [c, ...e.children];
38
38
  }
39
- } else m.length == 2 && e.children && e.children.forEach((v) => {
40
- if (!(v.children.filter((i) => i.value == u).length > 0)) {
41
- const i = {};
42
- i.type = m[1], i.value = u, i.label = u, Object.keys(v).forEach((h) => {
43
- ["children", "metadata", "type", "value"].includes(h) || (i[h] = v[h]);
44
- }), v.children = [i, ...v.children];
39
+ } else y.length == 2 && e.children && e.children.forEach((v) => {
40
+ if (!(v.children.filter((l) => l.value == f).length > 0)) {
41
+ const l = {};
42
+ l.type = y[1], l.value = f, l.label = f, Object.keys(v).forEach((S) => {
43
+ ["children", "metadata", "type", "value"].includes(S) || (l[S] = v[S]);
44
+ }), v.children = [l, ...v.children];
45
45
  }
46
46
  });
47
47
  return e;
48
- }, W = (t) => {
49
- var R, E, j;
48
+ }, Z = (t) => {
49
+ var E, j, N;
50
50
  let e = {};
51
51
  const {
52
- data: l,
53
- measures: m,
54
- swap: u,
52
+ data: s,
53
+ measures: y,
54
+ swap: f,
55
55
  dimensions: v,
56
- includeOverall: d,
57
- locale: i,
58
- customLabels: h,
59
- colorBy: A,
60
- hiddenBars: y
61
- } = t, D = v.filter((r) => r != "");
62
- if (l.metadata.measures.filter((r) => m.includes(r.value)).sort((r, S) => r.position != null && S.position != null && r.position != S.position ? r.position - S.position : 0), d && m.length == 1 && P(t), D.length == 0 && l)
63
- e = H(t);
64
- else if (l && l.children && l.children.length > 0 && D.length > 0) {
65
- const r = q(l), S = G(l), a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set(), O = [], B = l.children[0].type, x = ((j = (E = (R = l == null ? void 0 : l.metadata) == null ? void 0 : R.types) == null ? void 0 : E.find((o) => o.dimension == D[0])) == null ? void 0 : j.items) || [];
66
- t.sort == "alphabetically" ? x.sort(
67
- (o, g) => K(t.sortReverse, i, o.value, g.value)
68
- ) : t.sort == "values" ? x.sort(
69
- (o, g) => U(t.sortReverse, o.value, g.value)
70
- ) : t.sort == "date" && x.sort(
71
- (o, g) => T(t.sortReverse, o.value, g.value)
72
- ), m.forEach((o) => {
73
- const g = { variables: {} };
74
- g.id = V(r[o], i), g.label = h[o] || V(r[o], i);
75
- const N = [];
76
- x.forEach((s) => {
77
- const n = l.children.find((f) => f.value === s.value);
78
- if (n) {
79
- const f = {};
80
- Object.keys(n).forEach((C) => {
81
- f[C] = n[C];
82
- }), f.value = n[o], f[n.type] = n.value.toString(), c.add(S[n.type]), N.push({ x: n.value, y: n[o], variables: f }), g.data = N;
56
+ includeOverall: c,
57
+ locale: l,
58
+ customLabels: S,
59
+ colorBy: L,
60
+ hiddenBars: h
61
+ } = t, D = v.filter((o) => o != ""), B = s.metadata.measures.filter((o) => y.includes(o.value)).sort((o, n) => o.position != null && n.position != null && o.position != n.position ? o.position - n.position : 0);
62
+ if (c && y.length == 1 && W(t), D.length == 0 && s)
63
+ e = U(t);
64
+ else if (s && s.children && s.children.length > 0 && D.length > 0) {
65
+ const o = z(s), n = Q(s), r = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set(), w = [], A = s.children[0].type, p = ((N = (j = (E = s == null ? void 0 : s.metadata) == null ? void 0 : E.types) == null ? void 0 : j.find((d) => d.dimension == D[0])) == null ? void 0 : N.items) || [];
66
+ t.sort == "alphabetically" ? p.sort(
67
+ (d, u) => V(t.sortReverse, l, d.value, u.value)
68
+ ) : t.sort == "values" ? p.sort(
69
+ (d, u) => Y(t.sortReverse, d.value, u.value)
70
+ ) : t.sort == "date" && p.sort(
71
+ (d, u) => q(t.sortReverse, d.value, u.value)
72
+ ), B.forEach((d) => {
73
+ const u = d.value, R = { variables: {} }, a = S[u] || G(o[u], l);
74
+ R.id = a, R.label = a, R.measure = u, R.measureFieldName = u, C.add(o[u]), F.add(a);
75
+ const i = [];
76
+ p.forEach((x) => {
77
+ const g = s.children.find((M) => M.value === x.value);
78
+ if (g) {
79
+ const M = {};
80
+ Object.keys(g).forEach((m) => {
81
+ M[m] = g[m];
82
+ }), M.value = g[u], M[g.type] = g.value.toString(), O.add(n[g.type]), i.push({ x: g.value, y: g[u], variables: M }), R.data = i;
83
83
  }
84
- }), O.push(g);
84
+ }), w.push(R);
85
85
  });
86
- const k = Array.from(M);
87
- let I = (y == null ? void 0 : y.length) > 0 && (O == null ? void 0 : O.length) > 0 ? O.filter((o) => y.indexOf(o[B]) == -1) : O;
86
+ const I = Array.from(F);
87
+ let K = (h == null ? void 0 : h.length) > 0 && (w == null ? void 0 : w.length) > 0 ? w.filter((d) => h.indexOf(d[A]) == -1) : w;
88
88
  e = {
89
- metadata: l.metadata,
90
- indexBy: B,
91
- categories: a,
92
- dimensionsMetadata: c,
93
- measuresMetadata: L,
94
- keys: k,
95
- data: I
89
+ metadata: s.metadata,
90
+ indexBy: A,
91
+ categories: r,
92
+ dimensionsMetadata: O,
93
+ measuresMetadata: C,
94
+ keys: I,
95
+ data: K
96
96
  };
97
97
  }
98
- return F.Children.map(
98
+ return J.Children.map(
99
99
  t.children,
100
- (r) => F.cloneElement(r, { options: e })
100
+ (o) => J.cloneElement(o, { options: e })
101
101
  );
102
- }, X = (t) => {
103
- var y, D, R, E, j, r, S;
102
+ }, _ = (t) => {
103
+ var D, B, E, j, N, o, n;
104
104
  const {
105
105
  data: e,
106
- measures: l,
107
- includeOverall: m,
108
- dimensions: u,
106
+ measures: s,
107
+ includeOverall: y,
108
+ dimensions: f,
109
109
  hiddenBars: v,
110
- colorBy: d,
111
- locale: i
112
- } = t, h = u.filter((a) => a != "");
113
- let A = {};
114
- if (m && P(t), h.length == 0 && e)
115
- A = H(t);
116
- else if (e && e.children && e.children.length > 0 && h.length > 0) {
117
- const a = q(e), c = G(e), L = l[0], M = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), B = [], x = [], k = (y = e.children[0]) == null ? void 0 : y.type, I = ((E = (R = (D = e == null ? void 0 : e.metadata) == null ? void 0 : D.types) == null ? void 0 : R.find((s) => s.dimension == h[0])) == null ? void 0 : E.items) || [], o = ((S = (r = (j = e == null ? void 0 : e.metadata) == null ? void 0 : j.types) == null ? void 0 : r.find((s) => s.dimension == h[1])) == null ? void 0 : S.items) || [];
118
- t.sortSecondDimension == "alphabetically" ? o.sort(
119
- (s, n) => K(t.sortReverseSecondDimension, i, s.value, n.value)
120
- ) : t.sortSecondDimension == "date" && o.sort(
121
- (s, n) => T(t.sortReverseSecondDimension, s.value, n.value)
122
- ), O.add(a[L]), o.forEach((s) => {
123
- const n = { variables: {} };
124
- n.id = s.value, n.label = s.value;
125
- const f = [];
126
- I.forEach((C) => {
127
- const b = e.children.find((w) => w.value === C.value);
128
- M.add(c[b == null ? void 0 : b.type]);
129
- const p = b == null ? void 0 : b.children.find((w) => w.value === s.value);
130
- if (p) {
131
- M.add(c[p == null ? void 0 : p.type]);
132
- const w = {};
133
- Object.keys(p).forEach((z) => {
134
- w[z] = p[z];
135
- }), w.value = p[l[0]], w[b.type] = b.value.toString(), w[p.type] = p.value.toString(), f.push({ x: b.value, y: p[l[0]], variables: w }), B.indexOf(b.value) == -1 && B.push(b.value);
110
+ colorBy: c,
111
+ locale: l,
112
+ customLabels: S = {}
113
+ } = t, L = f.filter((r) => r != "");
114
+ let h = {};
115
+ if (y && W(t), L.length == 0 && e)
116
+ h = U(t);
117
+ else if (e && e.children && e.children.length > 0 && L.length > 0) {
118
+ const r = z(e), O = Q(e), C = s[0], F = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), A = [], p = [], I = (D = e.children[0]) == null ? void 0 : D.type, K = ((j = (E = (B = e == null ? void 0 : e.metadata) == null ? void 0 : B.types) == null ? void 0 : E.find((a) => a.dimension == L[0])) == null ? void 0 : j.items) || [], d = ((n = (o = (N = e == null ? void 0 : e.metadata) == null ? void 0 : N.types) == null ? void 0 : o.find((a) => a.dimension == L[1])) == null ? void 0 : n.items) || [];
119
+ t.sortSecondDimension == "alphabetically" ? d.sort(
120
+ (a, i) => V(t.sortReverseSecondDimension, l, a.value, i.value)
121
+ ) : t.sortSecondDimension == "date" && d.sort(
122
+ (a, i) => q(t.sortReverseSecondDimension, a.value, i.value)
123
+ ), w.add(r[C]), d.forEach((a) => {
124
+ const i = { variables: {} }, x = S && S[a.value] || G(a, l) || a.value;
125
+ i.id = x, i.label = x, i.code = a.code || a.value, i.value = a.value, A.push(x);
126
+ const g = [];
127
+ K.forEach((M) => {
128
+ var H;
129
+ const m = e.children.find((b) => b.value === M.value);
130
+ if (m) {
131
+ F.add(O[m == null ? void 0 : m.type]);
132
+ const b = (H = m == null ? void 0 : m.children) == null ? void 0 : H.find((k) => k.value === a.value);
133
+ if (b) {
134
+ F.add(O[b == null ? void 0 : b.type]);
135
+ const k = {};
136
+ Object.keys(b).forEach((P) => {
137
+ k[P] = b[P];
138
+ }), k.value = b[s[0]], k[m.type] = m.value.toString(), k[b.type] = b.value.toString(), g.push({ x: m.value, y: b[s[0]], variables: k }), A.indexOf(m.value) == -1 && A.push(m.value);
139
+ }
136
140
  }
137
- }), n.data = f, x.push(n);
138
- }), x.forEach((s) => {
139
- B.forEach((n) => {
140
- s.data.find((f) => f.x == n) || s.data.push({ x: n, y: null, variables: {} });
141
+ }), i.data = g, p.push(i);
142
+ }), p.forEach((a) => {
143
+ A.forEach((i) => {
144
+ a.data.find((x) => x.x == i) || a.data.push({ x: i, y: null, variables: {} });
141
145
  });
142
- }), x.forEach((s) => {
143
- s.data.sort((n, f) => t.sort == "alphabetically" ? K(t.sortReverse, i, n.x, f.x) : t.sort == "date" ? T(t.sortReverse, n.x, f.x) : 0);
146
+ }), p.forEach((a) => {
147
+ a.data.sort((i, x) => t.sort == "alphabetically" ? V(t.sortReverse, l, i.x, x.x) : t.sort == "date" ? q(t.sortReverse, i.x, x.x) : 0);
144
148
  });
145
- const g = d == "id" ? x : x.filter((s) => v.indexOf(s[k]) == -1), N = [...B];
146
- A = {
149
+ const u = c == "id" ? p : p.filter((a) => v.indexOf(a[I]) == -1), R = [...A];
150
+ h = {
147
151
  metadata: e.metadata,
148
- dimensionsMetadata: M,
149
- measuresMetadata: O,
150
- indexBy: k,
151
- keys: d == "index" ? N : N.filter((s) => v.indexOf(s) == -1),
152
- data: g
152
+ dimensionsMetadata: F,
153
+ measuresMetadata: w,
154
+ indexBy: I,
155
+ keys: c == "index" ? R : R.filter((a) => v.indexOf(a) == -1),
156
+ data: u
153
157
  };
154
158
  }
155
- return /* @__PURE__ */ J(Q, { children: F.Children.map(
159
+ return /* @__PURE__ */ T(X, { children: J.Children.map(
156
160
  t.children,
157
- (a) => F.cloneElement(a, { options: A })
161
+ (r) => J.cloneElement(r, { options: h })
158
162
  ) });
159
- }, $ = (t) => {
160
- const { data: e, measures: l, dimensions: m } = t, u = JSON.parse(JSON.stringify(e));
161
- return m.length === 1 ? /* @__PURE__ */ J(W, { ...t, data: u }) : /* @__PURE__ */ J(X, { ...t, data: u });
163
+ }, ae = (t) => {
164
+ const { data: e, measures: s, dimensions: y } = t, f = JSON.parse(JSON.stringify(e));
165
+ return y.length === 1 ? /* @__PURE__ */ T(Z, { ...t, data: f }) : /* @__PURE__ */ T(_, { ...t, data: f });
162
166
  };
163
167
  export {
164
- $ as default
168
+ ae as default
165
169
  };
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import b from "string-template";
4
- const f = /(\%)[\(]([A-z0-9,.]+)\)/gi, g = /(\#)[\(]([A-z0-9,.]+)\)/gi, h = /(\#C)[\(]([A-z0-9,.]+)\)/gi, x = /(\$)[\(]([A-z0-9,.]+)\)/gi, A = [
3
+ import g from "string-template";
4
+ const f = /(\%)[\(]([A-z0-9,.]+)\)/gi, b = /(\#)[\(]([A-z0-9,.]+)\)/gi, h = /(\#C)[\(]([A-z0-9,.]+)\)/gi, x = /(\$)[\(]([A-z0-9,.]+)\)/gi, A = [
5
5
  {
6
6
  name: "USD Dollar",
7
7
  code: "USD",
@@ -32,28 +32,32 @@ const f = /(\%)[\(]([A-z0-9,.]+)\)/gi, g = /(\#)[\(]([A-z0-9,.]+)\)/gi, h = /(\#
32
32
  code: "KES",
33
33
  symbol: "KSh"
34
34
  }
35
- ], i = (r, t, o, e, s) => {
36
- let n, c = t;
37
- for (; (n = r.exec(t)) !== null; ) {
38
- const l = n[2], u = (p, d = 2) => s.formatNumber(e ? p / 100 : p, {
39
- maximumFractionDigits: d,
40
- ...o
41
- }), m = l.split(","), y = m.length > 0 && m[0] ? u.apply(void 0, m) : "No Data";
42
- c = c.replaceAll(n[0], y);
35
+ ], m = (t, n, r, c, l) => {
36
+ let e, o = n;
37
+ for (; (e = t.exec(n)) !== null; ) {
38
+ const a = e[2], p = (u, y = 2) => l.formatNumber(c ? u / 100 : u, {
39
+ maximumFractionDigits: y,
40
+ ...r
41
+ }), i = a.split(","), d = i.length > 0 && i[0] ? p.apply(void 0, i) : "No Data";
42
+ o = o.replaceAll(e[0], d);
43
43
  }
44
- return c;
45
- }, S = (r, t) => {
46
- let o, e = t;
47
- for (; (o = r.exec(t)) !== null; )
48
- if (o.length > 2) {
49
- const s = o[0], n = o[2], c = A.find((l) => a(l.code) == a(n) || a(l.name) == a(n) || a(l.symbol) == a(n));
50
- c && (e = e.replaceAll(s, c.symbol));
44
+ return o;
45
+ }, E = (t, n) => {
46
+ let r, c = n;
47
+ for (; (r = t.exec(n)) !== null; )
48
+ if (r.length > 2) {
49
+ const l = r[0], e = r[2], o = A.find((a) => s(a.code) == s(e) || s(a.name) == s(e) || s(a.symbol) == s(e));
50
+ o && (c = c.replaceAll(l, o.symbol));
51
51
  }
52
- return e;
53
- }, a = (r) => r && r.trim().toLowerCase(), D = (r, t, o) => {
54
- let e = b(r, t).replace(/(?:\r\n|\r|\n)/g, "<br>");
55
- return e = i(f, e, { style: "percent" }, !0, o), e = i(g, e, { style: "decimal" }, !1, o), e = i(h, e, { notation: "compact" }, !1, o), e = S(x, e), e;
52
+ return c;
53
+ }, s = (t) => t && t.trim().toLowerCase(), N = (t, n, r) => {
54
+ const c = {};
55
+ Object.keys(n).forEach((o) => {
56
+ c[o] = n[o], c[o.replace(/\s+/g, "_")] = n[o];
57
+ });
58
+ let l = t.replace(/\{([^}]+)\}/g, (o, a) => `{${a.replace(/\s+/g, "_")}}`), e = g(l, c).replace(/(?:\r\n|\r|\n)/g, "<br>");
59
+ return e = m(f, e, { style: "percent" }, !0, r), e = m(b, e, { style: "decimal" }, !1, r), e = m(h, e, { notation: "compact" }, !1, r), e = E(x, e), e;
56
60
  };
57
61
  export {
58
- D as formatContent
62
+ N as formatContent
59
63
  };
@@ -1,50 +1,81 @@
1
- import O from "./Colors.js";
2
- class D extends O {
3
- constructor(i, _, r, C, v, h, u, g, a, e, f, x, p) {
4
- if (super(r, C, v, g, a), this._manualColor = {}, this._manualColor[x] = e ? e.Overall : null, i != "csv") {
5
- const y = (t) => {
6
- const o = [...h][t];
7
- o && (c = o.items), e != null && e != null && Object.keys(e).forEach((s) => {
8
- const l = c.filter((n) => n.code === s);
9
- if (l.length > 0 && l[0].labels) {
10
- let n;
11
- f && (n = l[0].labels[f.toUpperCase()]), n ? this._manualColor[n] = e[s] : this._manualColor[l[0].value] = e[s];
1
+ import D from "./Colors.js";
2
+ class A extends D {
3
+ constructor(n, l, h, g, j, f, d, E, b, o, C, p, t) {
4
+ if (super(h, g, j, E, b), this.type = l, this._manualColor = {}, p && (this._manualColor[p] = o ? o.Overall : null), n != "csv") {
5
+ const m = (u) => {
6
+ const _ = (f ? [...f] : [])[u];
7
+ let s = [];
8
+ _ && (s = _.items || []), o != null && o != null && Object.keys(o).forEach((e) => {
9
+ const c = s.filter((i) => i.code === e || i.value === e || i.id === e || i.label === e), r = o[e];
10
+ if (this._manualColor[e] = r, c.length > 0) {
11
+ const i = c[0];
12
+ i.value !== void 0 && (this._manualColor[i.value] = r), i.label !== void 0 && (this._manualColor[i.label] = r), i.code !== void 0 && (this._manualColor[i.code] = r), i.id !== void 0 && (this._manualColor[i.id] = r);
13
+ const B = t && (t[e] || i.value && t[i.value] || i.code && t[i.code]);
14
+ if (B && (this._manualColor[B] = r), i.labels) {
15
+ let y;
16
+ C && (y = i.labels[C.toUpperCase()]), y && (this._manualColor[y] = r), Object.values(i.labels).forEach((O) => {
17
+ O && (this._manualColor[O] = r);
18
+ });
19
+ }
12
20
  }
13
21
  });
14
- }, b = () => {
15
- c = u, Object.keys(e).forEach((t) => {
16
- const o = [...c].filter((s) => s.value === t);
17
- if (o.length > 0 && o[0].labels) {
18
- const s = p[t];
19
- p && s && (this._manualColor[s] = e[t]);
20
- let l;
21
- f && (l = o[0].labels[f.toUpperCase()]), l ? this._manualColor[l] = e[t] : this._manualColor[o[0].label] = e[t];
22
+ }, x = () => {
23
+ const u = d ? [...d] : [];
24
+ o != null && o != null && Object.keys(o).forEach((a) => {
25
+ const _ = u.filter((e) => e.value === a || e.code === a || e.id === a || e.label === a), s = o[a];
26
+ if (this._manualColor[a] = s, _.length > 0) {
27
+ const e = _[0];
28
+ e.value !== void 0 && (this._manualColor[e.value] = s), e.label !== void 0 && (this._manualColor[e.label] = s), e.code !== void 0 && (this._manualColor[e.code] = s), e.id !== void 0 && (this._manualColor[e.id] = s);
29
+ const c = t && (t[a] || e.value && t[e.value] || e.code && t[e.code]);
30
+ if (c && (this._manualColor[c] = s), e.labels) {
31
+ let r;
32
+ C && (r = e.labels[C.toUpperCase()]), r && (this._manualColor[r] = s), Object.values(e.labels).forEach((i) => {
33
+ i && (this._manualColor[i] = s);
34
+ });
35
+ }
22
36
  }
23
37
  });
24
- }, B = () => {
25
- Object.keys(e).forEach((t) => {
26
- this._manualColor[t] = e[t];
38
+ }, z = () => {
39
+ Object.keys(o).forEach((u) => {
40
+ this._manualColor[u] = o[u];
27
41
  });
28
- };
29
- let c = [];
30
- const m = _ == "line" ? 1 : r === "index" ? 0 : 1;
31
- !h && !u ? B() : h ? h.size == 1 && m == 1 ? a == "measure" ? y(0) : b() : y(m) : b();
42
+ }, v = l == "line" ? 1 : h === "index" ? 0 : 1;
43
+ !f && !d ? z() : !f || f.size === 0 ? x() : f.size == 1 && v == 1 ? b == "measure" ? m(0) : x() : f.size == 1 && v == 0 ? m(0) : m(v);
32
44
  } else
33
- this._manualColor = e && e[r] ? e[r] : {};
45
+ this._manualColor = o && o[h] ? o[h] : {};
34
46
  }
35
- getColor(i, _) {
47
+ getColor(n, l) {
48
+ if (this._manualColor[n])
49
+ return this._manualColor[n];
50
+ if (l) {
51
+ if (this.indexBy && l[this.indexBy] && this._manualColor[l[this.indexBy]])
52
+ return this._manualColor[l[this.indexBy]];
53
+ if (l.id && this._manualColor[l.id])
54
+ return this._manualColor[l.id];
55
+ if (l.label && this._manualColor[l.label])
56
+ return this._manualColor[l.label];
57
+ if (l.value && this._manualColor[l.value])
58
+ return this._manualColor[l.value];
59
+ if (l.code && this._manualColor[l.code])
60
+ return this._manualColor[l.code];
61
+ if (l.measure && this._manualColor[l.measure])
62
+ return this._manualColor[l.measure];
63
+ if (l.measureFieldName && this._manualColor[l.measureFieldName])
64
+ return this._manualColor[l.measureFieldName];
65
+ }
36
66
  if (this.colorBy === "index") {
37
- const r = this._manualColor[i] || this._manualColor[_[this.indexBy]];
38
- return r || "#5555";
67
+ const h = this._manualColor[n] || l && this.indexBy && this._manualColor[l[this.indexBy]];
68
+ return h || "#5555";
39
69
  }
40
- return this.colorBy === "id" && this._manualColor[i] ? this._manualColor[i] : "#5555";
70
+ return this.colorBy === "id" && this._manualColor[n] ? this._manualColor[n] : "#5555";
41
71
  }
42
- getColorByIndex(i) {
72
+ getColorByIndex(n) {
73
+ return this._manualColor[n] ? this._manualColor[n] : "#5555";
43
74
  }
44
- getColorByKey(i) {
45
- return this._manualColor[i] ? this._manualColor[i] : "#5555";
75
+ getColorByKey(n) {
76
+ return this._manualColor[n] ? this._manualColor[n] : "#5555";
46
77
  }
47
78
  }
48
79
  export {
49
- D as default
80
+ A as default
50
81
  };