@opengis/bi 1.2.7 → 1.2.10

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,356 +0,0 @@
1
- import { c as F, l as G, p as T, b as A, V as P, a as Z, d as q, e as D } from "./vs-list-_I6Z56hC.js";
2
- import { _ as x, V as K, c as W, e as j } from "./import-file-DnbEvuUN.js";
3
- import { createElementBlock as p, createCommentVNode as S, openBlock as c, createElementVNode as r, normalizeClass as I, Fragment as N, renderList as R, toDisplayString as O, normalizeStyle as J, createStaticVNode as Q, resolveComponent as g, withDirectives as M, createBlock as k, resolveDynamicComponent as U, createVNode as z, vShow as C } from "vue";
4
- const X = {
5
- components: { legendIcon: G, closeIcon: F },
6
- props: {
7
- mapId: { type: String },
8
- colors: { type: Array },
9
- sizes: { type: Array, default: () => [] },
10
- cluster: { type: [Boolean, String] },
11
- color: { type: String, default: "gray" },
12
- colorTitle: { type: String },
13
- sizesTitle: { type: String },
14
- resizeItem: { type: [Boolean, String], default: !1 },
15
- changeOpacityItem: { type: [Boolean, String], default: !1 }
16
- },
17
- data() {
18
- return {
19
- isOpenLegend: !1,
20
- palette: T
21
- // palette: ['#69D2E7', 'yellow', '#FE4365'],
22
- };
23
- },
24
- computed: {
25
- borderRadius() {
26
- return this.cluster ? "rounded-sm" : "rounded-full";
27
- },
28
- sortedSizes() {
29
- return [...this.sizes].sort((e, s) => e - s);
30
- },
31
- maxWidht() {
32
- var n;
33
- const e = ((n = this.sizes) == null ? void 0 : n.length) - 1;
34
- return this.calcSize(e);
35
- }
36
- },
37
- methods: {
38
- sizeClass(e) {
39
- return this.resizeItem ? `h-[${this.calcSize(e)}] w-[${this.calcSize(e)}] ${this.borderRadius}` : `h-[10px] ${this.borderRadius}`;
40
- },
41
- calcSize(e) {
42
- return `${10 + e * 2}px`;
43
- },
44
- getOpacity(e) {
45
- return (e + 1) / this.sortedSizes.length;
46
- }
47
- }
48
- }, Y = {
49
- key: 0,
50
- class: "absolute flex items-end w-fit bottom-[10px] max-w-[80%] left-[50%] translate-x-[-50%] bg-[rgba(255,255,255,0.7)] p-[10px] rounded"
51
- }, $ = { class: "w-[80px] mr-[10px]" }, tt = ["title"], et = { class: "text-[10px] mb-[2px] text-[#1F2937] font-normal leading-[1.2]" };
52
- function st(e, s, n, o, t, a) {
53
- var h;
54
- return (h = n.sizes) != null && h.length ? (c(), p("div", Y, [
55
- r("div", $, [
56
- s[0] || (s[0] = r("p", { class: "text-[10px] mb-[2px] text-[#1F2937] leading-[1.2]" }, " Дані відсутні ", -1)),
57
- r("div", {
58
- class: I([a.sizeClass(e.index), "w-full border border-gray-500"])
59
- }, null, 2)
60
- ]),
61
- a.sortedSizes.length ? (c(!0), p(N, { key: 0 }, R(a.sortedSizes, (d, i) => {
62
- var u, m, w, f, y, b, v, _;
63
- return c(), p("div", {
64
- class: "w-[80px]",
65
- title: i === ((u = a.sortedSizes) == null ? void 0 : u.length) - 1 ? ">" + d : i == ((m = a.sortedSizes) == null ? void 0 : m.length) - 1 ? ">" + a.sortedSizes[((w = a.sortedSizes) == null ? void 0 : w.length) - 1] : d + "-" + a.sortedSizes[i + 1]
66
- }, [
67
- r("p", et, O(i === ((f = a.sortedSizes) == null ? void 0 : f.length) - 1 ? ">" + parseInt(d) : i == ((y = a.sortedSizes) == null ? void 0 : y.length) - 1 ? ">" + parseInt(a.sortedSizes[((b = a.sortedSizes) == null ? void 0 : b.length) - 1]) : parseInt(d) + "-" + parseInt(a.sortedSizes[i + 1])), 1),
68
- r("div", {
69
- class: I([a.sizeClass(i), "w-full border border-r-0 border-gray-500"]),
70
- style: J({
71
- backgroundColor: ((_ = (v = t.palette) == null ? void 0 : v[n.color]) == null ? void 0 : _[i]) || n.color
72
- })
73
- }, null, 6)
74
- ], 8, tt);
75
- }), 256)) : S("", !0)
76
- ])) : S("", !0);
77
- }
78
- const ot = /* @__PURE__ */ x(X, [["render", st]]), rt = {}, nt = {
79
- xmlns: "http://www.w3.org/2000/svg",
80
- width: "24",
81
- height: "24",
82
- viewBox: "0 0 24 24",
83
- fill: "none",
84
- stroke: "currentColor",
85
- "stroke-width": "2",
86
- "stroke-linecap": "round",
87
- "stroke-linejoin": "round",
88
- class: "icon icon-tabler icons-tabler-outline icon-tabler-map"
89
- };
90
- function at(e, s) {
91
- return c(), p("svg", nt, s[0] || (s[0] = [
92
- r("path", {
93
- stroke: "none",
94
- d: "M0 0h24v24H0z",
95
- fill: "none"
96
- }, null, -1),
97
- r("path", { d: "M3 7l6 -3l6 3l6 -3v13l-6 3l-6 -3l-6 3v-13" }, null, -1),
98
- r("path", { d: "M9 4v13" }, null, -1),
99
- r("path", { d: "M15 7v13" }, null, -1)
100
- ]));
101
- }
102
- const lt = /* @__PURE__ */ x(rt, [["render", at]]), it = {}, ct = {
103
- xmlns: "http://www.w3.org/2000/svg",
104
- width: "24",
105
- height: "24",
106
- viewBox: "0 0 24 24",
107
- fill: "none",
108
- stroke: "currentColor",
109
- "stroke-width": "2",
110
- "stroke-linecap": "round",
111
- "stroke-linejoin": "round",
112
- class: "icon icon-tabler icons-tabler-outline icon-tabler-table"
113
- };
114
- function pt(e, s) {
115
- return c(), p("svg", ct, s[0] || (s[0] = [
116
- r("path", {
117
- stroke: "none",
118
- d: "M0 0h24v24H0z",
119
- fill: "none"
120
- }, null, -1),
121
- r("path", { d: "M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z" }, null, -1),
122
- r("path", { d: "M3 10h18" }, null, -1),
123
- r("path", { d: "M10 3v18" }, null, -1)
124
- ]));
125
- }
126
- const dt = /* @__PURE__ */ x(it, [["render", pt]]), ht = {}, ut = {
127
- xmlns: "http://www.w3.org/2000/svg",
128
- width: "24",
129
- height: "24",
130
- viewBox: "0 0 24 24",
131
- fill: "none",
132
- stroke: "currentColor",
133
- "stroke-width": "2",
134
- "stroke-linecap": "round",
135
- "stroke-linejoin": "round",
136
- class: "icon icon-tabler icons-tabler-outline icon-tabler-align-box-left-stretch"
137
- };
138
- function mt(e, s) {
139
- return c(), p("svg", ut, s[0] || (s[0] = [
140
- Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"></path><path d="M9 17h-2"></path><path d="M13 12h-6"></path><path d="M11 7h-4"></path>', 5)
141
- ]));
142
- }
143
- const gt = /* @__PURE__ */ x(ht, [["render", mt]]), ft = {
144
- mixins: [W, D],
145
- components: {
146
- VsMapSetting: q,
147
- VsClusterLegend: ot,
148
- VsMapGoHome: Z,
149
- VsList: P,
150
- VsMapSlotLayers: A,
151
- // VsListbar,
152
- VsBar: K
153
- },
154
- data() {
155
- return {
156
- baseColor: "pink",
157
- kattotg: "",
158
- options: [
159
- { id: "map", text: "Карта", component: lt },
160
- { id: "table", text: "Таблиця", component: dt },
161
- { id: "chart", text: "Віджет", component: gt }
162
- ],
163
- activeTab: "map",
164
- mapId: `map-${Math.floor(Math.random() * 1e3)}`,
165
- layerId: `layer${Math.floor(Math.random() * 1e3)}`,
166
- map: null,
167
- hoverData: null,
168
- data: null,
169
- coordinatesByMouse: [],
170
- showSetting: !1,
171
- popup: null,
172
- color: "#69D2E7",
173
- label: "<div><icon-map/></div>"
174
- };
175
- },
176
- async mounted() {
177
- await this.getMapData(), await this.createMap();
178
- },
179
- watch: {
180
- kattotg() {
181
- this.loadHandler();
182
- }
183
- },
184
- methods: {
185
- async getMapData() {
186
- const e = await j.get(
187
- `/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`
188
- );
189
- this.data = e.data, this.$emit("update:widgetData", this.data), setTimeout(() => {
190
- var s;
191
- return (s = this.map) == null ? void 0 : s.resize();
192
- });
193
- },
194
- async loadHandler() {
195
- var o, t, a, h;
196
- this.baseColor = ((o = this.data.style) == null ? void 0 : o.color) || "blue";
197
- const e = ["case"];
198
- (h = (a = (t = this.data) == null ? void 0 : t.sizes) == null ? void 0 : a.toReversed()) == null || h.forEach((d, i) => {
199
- var u, m;
200
- e.push([">", ["get", "metric"], d]), e.push((m = (u = T[this.baseColor]) == null ? void 0 : u.toReversed()) == null ? void 0 : m[i]), i++;
201
- }), e.push("gray");
202
- const s = {
203
- type: "polygon",
204
- color: e,
205
- opacity: 0.4
206
- };
207
- Object.assign(s, this.data.style || {}), this.map.getSource("bi") || this.addVtileLayer({
208
- id: "bi",
209
- url: `${window.location.origin}/api/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,
210
- style: s
211
- }), this.map.getLayer("highlighted") && this.map.removeLayer("highlighted"), this.map.getSource("highlighted") && this.map.removeSource("highlighted");
212
- const n = ["case"];
213
- this.kattotg && n.push(
214
- ["==", ["to-string", ["get", "name"]], String(this.kattotg)],
215
- "red"
216
- ), n.push("transparent"), this.map.addLayer({
217
- id: "highlighted",
218
- type: "fill",
219
- source: "bi",
220
- "source-layer": "bi",
221
- paint: {
222
- "fill-color": n,
223
- "fill-opacity": 0.6
224
- }
225
- });
226
- },
227
- async createMap() {
228
- var s, n;
229
- const e = {
230
- version: 8,
231
- glyphs: "https://cdn.softpro.ua/data/fonts/{fontstack}/{range}.pbf",
232
- sources: {},
233
- layers: []
234
- };
235
- this.map = await new maplibregl.Map({
236
- container: this.mapId,
237
- style: e,
238
- center: [31, 48.5],
239
- zoom: ((n = (s = this.data) == null ? void 0 : s.style) == null ? void 0 : n.zoom) || 5,
240
- minZoom: 3,
241
- maxZoom: 20,
242
- attributionControl: !1
243
- }), this.map.addControl(
244
- new maplibregl.NavigationControl({
245
- visualizePitch: !0
246
- })
247
- ), this.map.on("load", () => {
248
- this.loadHandler();
249
- }), this.map.on("mousemove", (o) => {
250
- this.moveMouseHadler(o);
251
- }), this.map.on("mouseout", () => {
252
- var o;
253
- this.showLegend = !1, this.showSetting = !1, this.coordinatesByMouse = 0, (o = this.popup) == null || o.remove();
254
- });
255
- },
256
- moveMouseHadler(e) {
257
- var s;
258
- try {
259
- const n = this.map.queryRenderedFeatures(e.point), o = ((s = n[0]) == null ? void 0 : s.properties) || {};
260
- if (!n.length) {
261
- this.map.getCanvas().style.cursor = "", this.popupElement && this.popupElement.remove();
262
- return;
263
- }
264
- this.map.getCanvas().style.cursor = "pointer", this.popupElement && this.popupElement.remove(), this.popupElement = document.createElement("div"), this.popupElement.className = "absolute text-gray-800 border border-gray-200 rounded-lg shadow-md min-w-28", this.popupElement.style.backgroundColor = "rgba(255, 255, 255, 0.7)", this.popupElement.innerHTML = `<div class="px-2 py-1 text-sm font-semibold text-gray-800 border-b border-gray-200 border-solid rounded-t-lg">
265
- ${(o == null ? void 0 : o.x) || (o == null ? void 0 : o.title) || (o == null ? void 0 : o.name) || ""}
266
- </div>
267
-
268
- <div class="flex justify-between items-center text-xs px-2 py-0.5 text-gray-500 ">
269
- <span class="flex items-center">
270
- <span class="font-medium mr-[6px]">Значення</span>
271
- </span>
272
- <span>${(o == null ? void 0 : o.metric) || 0}</span>
273
- </div>`;
274
- const t = this.map.project(e.lngLat);
275
- this.popupElement.style.left = `${t.x}px`, this.popupElement.style.top = `${t.y - 60}px`, this.map.getContainer().appendChild(this.popupElement);
276
- } catch (n) {
277
- console.error(n);
278
- }
279
- }
280
- }
281
- }, yt = { class: "h-full" }, bt = { class: "flex items-start justify-between mb-[6px] w-full" }, vt = { class: "text-gray-800 font-[600]" }, _t = { class: "flex gap-2" }, xt = ["onClick"], wt = ["id"], zt = ["id"], St = { class: "absolute flex flex-col right-[10px] top-[105px] gap-1" }, Mt = { class: "h-[calc(250px)]" };
282
- function kt(e, s, n, o, t, a) {
283
- var f, y, b, v, _, V, L, E, B, H;
284
- const h = g("VsMapSetting"), d = g("VsMapSlotLayers"), i = g("VsMapGoHome"), u = g("VsClusterLegend"), m = g("VsList"), w = g("VsBar");
285
- return c(), p("div", yt, [
286
- r("div", bt, [
287
- r("h3", vt, O(e.title), 1),
288
- r("div", _t, [
289
- (c(!0), p(N, null, R(t.options, (l) => (c(), p("button", {
290
- class: I(["p-1 text-gray-700 border rounded", [t.activeTab === (l == null ? void 0 : l.id) ? "ring-2 ring-blue-500" : ""]]),
291
- onClick: (Ct) => t.activeTab = l == null ? void 0 : l.id
292
- }, [
293
- (c(), k(U(l == null ? void 0 : l.component), {
294
- height: "16",
295
- width: "16"
296
- }))
297
- ], 10, xt))), 256))
298
- ])
299
- ]),
300
- M(r("div", {
301
- class: "relative w-full h-[calc(100%-40px)]",
302
- id: `wrapper-${t.mapId}`
303
- }, [
304
- r("div", {
305
- id: t.mapId,
306
- class: "h-full w-full flex items-end min-h-[250px]"
307
- }, null, 8, zt),
308
- t.showSetting ? (c(), k(h, {
309
- key: 0,
310
- map: t.map,
311
- coordinates: t.coordinatesByMouse
312
- }, null, 8, ["map", "coordinates"])) : S("", !0),
313
- z(d, { map: t.map }, null, 8, ["map"]),
314
- r("div", St, [
315
- z(i, {
316
- map: t.map,
317
- bbox: (f = t.data) == null ? void 0 : f.bounds
318
- }, null, 8, ["map", "bbox"])
319
- ]),
320
- z(u, {
321
- mapId: t.mapId,
322
- colors: (y = t.data) == null ? void 0 : y.colors,
323
- sizes: (b = t.data) == null ? void 0 : b.sizes,
324
- color: t.baseColor,
325
- changeOpacityItem: "true",
326
- cluster: "true"
327
- }, null, 8, ["mapId", "colors", "sizes", "color"])
328
- ], 8, wt), [
329
- [C, t.activeTab == "map"]
330
- ]),
331
- M(z(m, {
332
- mapId: t.mapId,
333
- source: (v = t.data) == null ? void 0 : v.rows,
334
- total: ((_ = t.data) == null ? void 0 : _.total) || 0,
335
- count: ((V = t.data) == null ? void 0 : V.count) || 0,
336
- onKattotg: s[0] || (s[0] = (l) => t.kattotg = l)
337
- }, null, 8, ["mapId", "source", "total", "count"]), [
338
- [C, t.activeTab == "table"]
339
- ]),
340
- M(r("div", Mt, [
341
- (E = (L = t.data) == null ? void 0 : L.rows) != null && E.length ? (c(), k(w, {
342
- key: 0,
343
- source: (H = (B = t.data) == null ? void 0 : B.rows) == null ? void 0 : H.map((l) => ({
344
- title: l == null ? void 0 : l.title,
345
- metric: l == null ? void 0 : l.metric
346
- }))
347
- }, null, 8, ["source"])) : S("", !0)
348
- ], 512), [
349
- [C, t.activeTab == "chart"]
350
- ])
351
- ]);
352
- }
353
- const Et = /* @__PURE__ */ x(ft, [["render", kt]]);
354
- export {
355
- Et as default
356
- };