@kiva/kv-components 7.6.0 → 7.6.2

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
- function p(e, t, r) {
2
- return (Math.random() * (t - e) + e).toFixed(r) * 1;
1
+ function p(e, o, r) {
2
+ return (Math.random() * (o - e) + e).toFixed(r) * 1;
3
3
  }
4
4
  const d = Array.from(
5
5
  { length: 20 },
@@ -12,18 +12,18 @@ const d = Array.from(
12
12
  800,
13
13
  1e3
14
14
  ];
15
- function M(e, t, r) {
16
- if (!e || !t || !r || r < 1 || !Array.isArray(e) || !Array.isArray(t) || e.length !== 2 || t.length !== 2)
15
+ function M(e, o, r) {
16
+ if (!e || !o || !r || r < 1 || !Array.isArray(e) || !Array.isArray(o) || e.length !== 2 || o.length !== 2)
17
17
  return [];
18
- const n = t[0] - e[0], l = t[1] - e[1], i = n / r, a = l / r;
19
- let o = 0, s = 0;
18
+ const n = o[0] - e[0], s = o[1] - e[1], i = n / r, a = s / r;
19
+ let t = 0, l = 0;
20
20
  const c = [];
21
- for (; Math.abs(o) < Math.abs(n) || Math.abs(s) < Math.abs(l); )
22
- c.push([e[0] + o, e[1] + s]), Math.abs(o) < Math.abs(n) && (o += i), Math.abs(s) < Math.abs(l) && (s += a);
23
- return c[c.length - 1] = [t[0], t[1]], c;
21
+ for (; Math.abs(t) < Math.abs(n) || Math.abs(l) < Math.abs(s); )
22
+ c.push([e[0] + t, e[1] + l]), Math.abs(t) < Math.abs(n) && (t += i), Math.abs(l) < Math.abs(s) && (l += a);
23
+ return c[c.length - 1] = [o[0], o[1]], c;
24
24
  }
25
- function b(e, t, r) {
26
- return new Promise((l) => {
25
+ function b(e, o, r) {
26
+ return new Promise((s) => {
27
27
  e.addSource("endpoint", {
28
28
  type: "geojson",
29
29
  data: {
@@ -34,9 +34,9 @@ function b(e, t, r) {
34
34
  ]
35
35
  }
36
36
  });
37
- const i = (a, o, s, c = !1) => {
38
- const y = M(a, o, 100);
39
- let g = 0;
37
+ const i = (a, t, l, c = !1) => {
38
+ const f = M(a, t, 100);
39
+ let h = 0;
40
40
  const u = {
41
41
  type: "FeatureCollection",
42
42
  features: [{
@@ -47,7 +47,7 @@ function b(e, t, r) {
47
47
  }
48
48
  }]
49
49
  };
50
- e.addSource(`startPoint${s}`, {
50
+ e.addSource(`startPoint${l}`, {
51
51
  type: "geojson",
52
52
  data: {
53
53
  type: "Point",
@@ -57,7 +57,7 @@ function b(e, t, r) {
57
57
  ]
58
58
  }
59
59
  }), e.addLayer({
60
- id: `line-animation${s}`,
60
+ id: `line-animation${l}`,
61
61
  type: "line",
62
62
  source: {
63
63
  type: "geojson",
@@ -72,26 +72,26 @@ function b(e, t, r) {
72
72
  "line-width": 2
73
73
  }
74
74
  });
75
- const h = () => {
76
- if (g < y.length)
77
- u.features[0].geometry.coordinates.push(y[g]), e.getSource(`line-animation${s}`).setData(u), requestAnimationFrame(h), g += 1;
75
+ const y = () => {
76
+ if (h < f.length)
77
+ u.features[0].geometry.coordinates.push(f[h]), e.getSource(`line-animation${l}`).setData(u), requestAnimationFrame(y), h += 1;
78
78
  else {
79
- const f = u.features[0].geometry.coordinates;
80
- f.shift(), f.shift(), f.length > 0 ? (u.features[0].geometry.coordinates = f, e.getSource(`line-animation${s}`).setData(u), requestAnimationFrame(h)) : (e.removeLayer(`line-animation${s}`), e.removeSource(`line-animation${s}`), e.removeSource(`startPoint${s}`), c && (e.removeSource("endpoint"), l()));
79
+ const g = u.features[0].geometry.coordinates;
80
+ g.shift(), g.shift(), g.length > 0 ? (u.features[0].geometry.coordinates = g, e.getSource(`line-animation${l}`).setData(u), requestAnimationFrame(y)) : (e.removeLayer(`line-animation${l}`), e.removeSource(`line-animation${l}`), e.removeSource(`startPoint${l}`), c && (e.removeSource("endpoint"), s()));
81
81
  }
82
82
  };
83
- h();
83
+ y();
84
84
  };
85
- t.forEach((a, o) => {
86
- i(a, r, o, o === t.length - 1);
85
+ o.forEach((a, t) => {
86
+ i(a, r, t, t === o.length - 1);
87
87
  });
88
88
  });
89
89
  }
90
- function $(e, t) {
90
+ function $(e, o) {
91
91
  const r = {
92
92
  type: "FeatureCollection"
93
93
  };
94
- r.features = t.map((n) => ({
94
+ r.features = o.map((n) => ({
95
95
  type: "Feature",
96
96
  properties: {
97
97
  message: "test",
@@ -103,19 +103,19 @@ function $(e, t) {
103
103
  coordinates: n.location
104
104
  }
105
105
  })), r.features.forEach((n) => {
106
- const l = document.createElement("div");
107
- l.className = "map-marker", l.style.backgroundImage = `url(${n.properties.image})`, l.style.width = `${n.properties.iconSize[0]}px`, l.style.height = `${n.properties.iconSize[1]}px`, new maplibregl.Marker({ element: l }).setLngLat(n.geometry.coordinates).addTo(e);
106
+ const s = document.createElement("div");
107
+ s.className = "map-marker", s.style.backgroundImage = `url(${n.properties.image})`, s.style.width = `${n.properties.iconSize[0]}px`, s.style.height = `${n.properties.iconSize[1]}px`, new maplibregl.Marker({ element: s }).setLngLat(n.geometry.coordinates).addTo(e);
108
108
  });
109
109
  }
110
- function A(e, t) {
110
+ function A(e, o) {
111
111
  return new Promise((r) => {
112
- const n = t.map((o) => o.location), l = n.length;
112
+ const n = o.map((t) => t.location), s = n.length;
113
113
  let i = 0;
114
- const a = (o) => {
114
+ const a = (t) => {
115
115
  e.flyTo({
116
116
  // These options control the ending camera position: centered at
117
117
  // the target, at zoom level 9, and north up.
118
- center: n[o],
118
+ center: n[t],
119
119
  zoom: 4,
120
120
  bearing: 0,
121
121
  // These options control the flight curve, making it move
@@ -127,48 +127,48 @@ function A(e, t) {
127
127
  // change the speed at which it zooms out
128
128
  // This can be any easing function: it takes a number between
129
129
  // 0 and 1 and returns another number between 0 and 1.
130
- easing(s) {
131
- return s;
130
+ easing(l) {
131
+ return l;
132
132
  },
133
133
  // this animation is considered essential with respect to prefers-reduced-motion
134
134
  essential: !0
135
135
  }, { flyEnd: !0 });
136
136
  };
137
- e.on("moveend", (o) => {
138
- o.flyEnd === !0 && b(e, d, n[i]).then(() => {
139
- i < l - 1 ? (i += 1, a(i)) : r();
137
+ e.on("moveend", (t) => {
138
+ t.flyEnd === !0 && b(e, d, n[i]).then(() => {
139
+ i < s - 1 ? (i += 1, a(i)) : r();
140
140
  });
141
141
  }), a(i);
142
142
  });
143
143
  }
144
- const F = (e, t, r) => {
145
- const n = Math.floor((t - e) / r), l = [];
146
- if (n <= 0) return [[e, t]];
144
+ const F = (e, o, r) => {
145
+ const n = Math.floor((o - e) / r), s = [];
146
+ if (n <= 0) return [[e, o]];
147
147
  for (let i = 0; i < r; i += 1) {
148
- let a = e + i * n, o = a + n < t ? a + n : t;
149
- if (i > 0 && (a += 1 * i, o += 1 * i), i > 0 && o > t && (o = t), i === r - 1 && (o < t || o > t) && (o = t), l.push([a, o]), o >= t) break;
148
+ let a = e + i * n, t = a + n < o ? a + n : o;
149
+ if (i > 0 && (a += 1 * i, t += 1 * i), i > 0 && t > o && (t = o), i === r - 1 && (t < o || t > o) && (t = o), s.push([a, t]), t >= o) break;
150
150
  }
151
- return l;
152
- }, S = (e, t, r) => {
153
- const n = [];
154
- t.forEach((a) => {
155
- n.push(a.value);
151
+ return s;
152
+ }, S = (e, o, r, n) => {
153
+ const s = [];
154
+ o.forEach((t) => {
155
+ s.push(t.value);
156
156
  });
157
- const l = Math.max(...n), i = F(1, l, 6);
158
- if (i.length === 1) {
159
- const [a, o] = i[0];
160
- for (let s = 0; s < o; s += 1) {
161
- const c = s + 1;
162
- if (e && e >= c && e < c + 1)
163
- return r.colors.brand[m[s]];
157
+ const i = Math.max(...s), a = F(1, i, 6);
158
+ if (a.length === 1) {
159
+ const [t, l] = a[0];
160
+ for (let c = 0; c < l; c += 1) {
161
+ const f = c + 1;
162
+ if (e && e >= f && e < f + 1)
163
+ return r.colors.brand[m[c]];
164
164
  }
165
165
  } else
166
- for (let a = 0; a < i.length; a += 1) {
167
- const [o, s] = i[a];
168
- if (e && e >= o && e <= s)
169
- return r.colors.brand[m[a]];
166
+ for (let t = 0; t < a.length; t += 1) {
167
+ const [l, c] = a[t];
168
+ if (e && e >= l && e <= c)
169
+ return r.colors.brand[m[t]];
170
170
  }
171
- return r.colors.gray[300];
171
+ return n || r.colors.gray[300];
172
172
  };
173
173
  export {
174
174
  A as animationCoordinator,
package/dist/vue/KvMap.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import n from "@kiva/kv-tokens";
2
2
  import { generateMapMarkers as l, animationCoordinator as h, getCountryColor as r } from "../utils/mapUtils.js";
3
- import { openBlock as c, createElementBlock as m, normalizeStyle as d, createElementVNode as p } from "vue";
3
+ import { openBlock as c, createElementBlock as d, normalizeStyle as m, createElementVNode as p } from "vue";
4
4
  import "./KvMap.css";
5
5
  import u from "../_virtual/_plugin-vue_export-helper.js";
6
6
  const f = {
@@ -140,6 +140,21 @@ const f = {
140
140
  showFundraisingLoans: {
141
141
  type: Boolean,
142
142
  default: !1
143
+ },
144
+ /**
145
+ * Show tooltips on fundraising loan circles
146
+ * Working for leaflet only
147
+ */
148
+ showTooltips: {
149
+ type: Boolean,
150
+ default: !0
151
+ },
152
+ /**
153
+ * Default base color for countries without loans
154
+ */
155
+ defaultBaseColor: {
156
+ type: String,
157
+ default: null
143
158
  }
144
159
  },
145
160
  data() {
@@ -323,12 +338,14 @@ const f = {
323
338
  countryStyle(e) {
324
339
  return {
325
340
  color: n.colors.white,
326
- fillColor: r(e.lenderLoans, this.countriesData, n),
341
+ // eslint-disable-next-line max-len
342
+ fillColor: r(e.lenderLoans, this.countriesData, n, this.defaultBaseColor),
327
343
  weight: 1,
328
344
  fillOpacity: 1
329
345
  };
330
346
  },
331
347
  onEachCountryFeature(e, t) {
348
+ if (!this.showTooltips) return;
332
349
  const i = e.lenderLoans ? `${e.lenderLoans} loan${e.lenderLoans > 1 ? "s" : ""}` : "0 loans", a = `${e.properties.name} <br/> ${i}`;
333
350
  t.bindTooltip(a, {
334
351
  sticky: !0
@@ -345,7 +362,8 @@ const f = {
345
362
  resetHighlight(e) {
346
363
  const t = e.target, { feature: i } = t;
347
364
  t.setStyle({
348
- fillColor: r(i.lenderLoans, this.countriesData, n)
365
+ // eslint-disable-next-line max-len
366
+ fillColor: r(i.lenderLoans, this.countriesData, n, this.defaultBaseColor)
349
367
  });
350
368
  },
351
369
  circleMapClicked(e) {
@@ -354,9 +372,9 @@ const f = {
354
372
  }
355
373
  }, b = ["id"];
356
374
  function g(e, t, i, a, s, o) {
357
- return c(), m("div", {
375
+ return c(), d("div", {
358
376
  class: "tw-relative tw-block tw-w-full",
359
- style: d(o.mapDimensions)
377
+ style: m(o.mapDimensions)
360
378
  }, [
361
379
  p("div", {
362
380
  id: `kv-map-holder-${i.mapId}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "7.6.0",
3
+ "version": "7.6.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,6 +14,14 @@
14
14
  "./vue/*": "./dist/vue/*.js",
15
15
  "./vue/*.js": "./dist/vue/*.js"
16
16
  },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/kiva/kv-ui-elements.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/kiva/kv-ui-elements/issues"
23
+ },
24
+ "homepage": "https://github.com/kiva/kv-ui-elements/tree/main/%40kiva/kv-components#readme",
17
25
  "devDependencies": {
18
26
  "@apollo/client": "^3.13.1",
19
27
  "@babel/core": "^7.14.8",
@@ -21,7 +29,7 @@
21
29
  "@babel/preset-env": "^7.24.8",
22
30
  "@babel/preset-react": "^7.24.7",
23
31
  "@babel/preset-typescript": "^7.24.7",
24
- "@kiva/kv-tokens": "^3.6.0",
32
+ "@kiva/kv-tokens": "^3.6.1",
25
33
  "@kiva/vite-plugin-vue-lib-css": "^2.0.0",
26
34
  "@laynezh/vite-plugin-lib-assets": "^0.6.1",
27
35
  "@mdi/js": "^7.4.47",
@@ -115,5 +123,5 @@
115
123
  "embla-carousel-fade",
116
124
  "popper.js"
117
125
  ],
118
- "gitHead": "76df0f5473e78a4d36bba8e19c3388cc8a055921"
126
+ "gitHead": "f68de2ef6e9d2b237b7779a5cb0971a29c845e4a"
119
127
  }