@sjvair/monitor-map 3.0.2 → 3.0.3
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.
- package/dist/lib/LoadScreen.js +14 -14
- package/dist/lib/{src/MapView.js → MainMapView.js} +2 -2
- package/dist/lib/MapLegend.js +13 -0
- package/dist/lib/MonitorDetailPanel.js +169 -0
- package/dist/lib/MonitorMapLayout.js +91 -0
- package/dist/lib/_virtual/_rolldown/runtime.js +11 -0
- package/dist/lib/assets/logos/airgradient-blue.js +4 -0
- package/dist/lib/assets/logos/airnow-compact.js +4 -0
- package/dist/lib/assets/logos/carb-compact.js +4 -0
- package/dist/lib/assets/logos/purpleair-compact.js +4 -0
- package/dist/lib/assets/logos/sjvair.js +4 -0
- package/dist/lib/collocation-sites/CollocationTooltip.js +1 -1
- package/dist/lib/collocation-sites/collocations-map-integration.svelte.js +20 -20
- package/dist/lib/components/DataBox.js +1 -1
- package/dist/lib/components/DisplayOption.js +1 -1
- package/dist/lib/components/MapLayersDisplayOptions.js +44 -35
- package/dist/lib/components/SegmentedControl.js +4 -4
- package/dist/lib/components/ToggleSwitch.js +1 -1
- package/dist/lib/components/ui/button/button.js +4 -4
- package/dist/lib/components/ui/range-calendar/range-calendar-caption.js +57 -54
- package/dist/lib/components/ui/range-calendar/range-calendar-cell.js +19 -18
- package/dist/lib/components/ui/range-calendar/range-calendar-day.js +19 -18
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-body.js +17 -16
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-head.js +17 -16
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-row.js +19 -18
- package/dist/lib/components/ui/range-calendar/range-calendar-grid.js +19 -18
- package/dist/lib/components/ui/range-calendar/range-calendar-head-cell.js +19 -18
- package/dist/lib/components/ui/range-calendar/range-calendar-header.js +19 -18
- package/dist/lib/components/ui/range-calendar/range-calendar-month-select.js +31 -31
- package/dist/lib/components/ui/range-calendar/range-calendar-month.js +19 -19
- package/dist/lib/components/ui/range-calendar/range-calendar-months.js +19 -19
- package/dist/lib/components/ui/range-calendar/range-calendar-nav.js +19 -19
- package/dist/lib/components/ui/range-calendar/range-calendar-next-button.js +27 -26
- package/dist/lib/components/ui/range-calendar/range-calendar-prev-button.js +27 -26
- package/dist/lib/components/ui/range-calendar/range-calendar-year-select.js +29 -29
- package/dist/lib/components/ui/range-calendar/range-calendar.js +154 -154
- package/dist/lib/data-chart/DataChart.js +76 -76
- package/dist/lib/ev-stations/components/EvStationClusterTooltip.js +16 -0
- package/dist/lib/ev-stations/components/EvStationTooltip.js +120 -0
- package/dist/lib/ev-stations/components/EvStationsDisplayOptions.js +41 -0
- package/dist/lib/ev-stations/data-maps.js +4 -0
- package/dist/lib/ev-stations/ev-station-icons.js +32 -0
- package/dist/lib/ev-stations/ev-stations-cluster-renderer.js +118 -0
- package/dist/lib/ev-stations/ev-stations-map-integration.svelte.js +181 -0
- package/dist/lib/ev-stations/ev-stations.svelte.js +33 -0
- package/dist/lib/ev-stations/zip-codes.js +136 -0
- package/dist/lib/hms/components/HMSFireLegend.js +35 -0
- package/dist/lib/index.js +19 -17
- package/dist/lib/map/Map.js +1 -1
- package/dist/lib/map/MapStyleDisplayOptions.js +16 -16
- package/dist/lib/map/Menu.js +23 -24
- package/dist/lib/map/integrations/map-icon-manager.js +3 -0
- package/dist/lib/map/utils.js +16 -13
- package/dist/lib/monitors/components/MonitorClusterTooltip.js +4 -4
- package/dist/lib/monitors/components/MonitorMarkersLegend.js +35 -0
- package/dist/lib/monitors/components/MonitorSubscriptionManager.js +1 -1
- package/dist/lib/monitors/components/MonitorTooltip.js +1 -1
- package/dist/lib/monitors/components/MonitorWidgetModal.js +1 -1
- package/dist/lib/monitors/components/MonitorsDisplayOptions.js +21 -21
- package/dist/lib/monitors/monitors-icon-manager.svelte.js +9 -9
- package/dist/lib/monitors/monitors-map-integration.svelte.js +36 -36
- package/dist/lib/monitors/monitors.svelte.js +38 -42
- package/dist/lib/router-context.js +13 -0
- package/dist/lib/routes.js +10 -0
- package/dist/lib/search/Search.js +124 -0
- package/dist/lib/search/service.js +90 -0
- package/dist/lib/sjvair-sjv.avif +0 -0
- package/dist/lib/sjvair-sjv.webp +0 -0
- package/dist/lib/sjvair-sjv2.avif +0 -0
- package/dist/lib/sjvair-sjv2.webp +0 -0
- package/dist/lib/utils.js +9 -3
- package/package.json +37 -36
- package/src/lib/LoadScreen.svelte +5 -5
- package/src/lib/MainMapView.svelte +1 -0
- package/src/lib/MapLegend.svelte +15 -0
- package/src/lib/MonitorDetailPanel.svelte +152 -0
- package/src/lib/MonitorMapLayout.svelte +193 -0
- package/src/lib/components/MapLayersDisplayOptions.svelte +6 -2
- package/src/lib/hms/components/HMSFireLegend.svelte +21 -0
- package/src/lib/index.ts +34 -0
- package/src/lib/map/Map.svelte +1 -0
- package/src/lib/map/Menu.svelte +4 -7
- package/src/lib/map/integrations/map-icon-manager.ts +4 -1
- package/src/lib/monitors/monitors.svelte.ts +1 -3
- package/src/lib/router-context.ts +48 -0
- package/src/lib/routes.ts +8 -0
- package/src/lib/search/Search.svelte +189 -0
- package/src/lib/search/service.ts +101 -0
- package/src/lib/utils.ts +11 -0
- package/dist/lib/assets/icons/adjustment-horizontal.js +0 -4
- package/dist/lib/node_modules/@internationalized/date/dist/private/CalendarDate.js +0 -122
- package/dist/lib/node_modules/@internationalized/date/dist/private/DateFormatter.js +0 -84
- package/dist/lib/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js +0 -91
- package/dist/lib/node_modules/@internationalized/date/dist/private/conversion.js +0 -104
- package/dist/lib/node_modules/@internationalized/date/dist/private/manipulation.js +0 -159
- package/dist/lib/node_modules/@internationalized/date/dist/private/queries.js +0 -32
- package/dist/lib/node_modules/@internationalized/date/dist/private/string.js +0 -37
- package/dist/lib/node_modules/@internationalized/date/dist/private/utils.js +0 -6
- package/dist/lib/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/lib/node_modules/tailwind-merge/dist/bundle-mjs.js +0 -1723
- package/dist/lib/node_modules/tailwind-variants/dist/chunk-LQJYWU4O.js +0 -70
- package/dist/lib/node_modules/tailwind-variants/dist/chunk-RZF76H2U.js +0 -166
- package/dist/lib/node_modules/tailwind-variants/dist/index.js +0 -19
- package/dist/lib/node_modules/uplot/dist/uPlot.esm.js +0 -2147
- package/dist/lib/src/MonitorDetailPanel.js +0 -169
- package/dist/lib/src/router.js +0 -9
- package/dist/monitor-map/MonitorDetailPanel.css +0 -1
- package/dist/monitor-map/assets/MonitorDetailPanel-BU_pXZjp.js +0 -15
- package/dist/monitor-map/assets/validate-routes-CgbRa8fT.js +0 -1
- package/dist/monitor-map/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-greek-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-latin-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/monitor-map/lungs.svg +0 -99
- package/dist/monitor-map/sjvair-air.avif +0 -0
- package/dist/monitor-map/sjvair-air.png +0 -0
- package/dist/monitor-map/sjvair-air.webp +0 -0
- package/dist/monitor-map/sjvair-air2.avif +0 -0
- package/dist/monitor-map/sjvair-air2.png +0 -0
- package/dist/monitor-map/sjvair-air2.webp +0 -0
- package/dist/monitor-map/sjvair-icon.avif +0 -0
- package/dist/monitor-map/sjvair-icon.png +0 -0
- package/dist/monitor-map/sjvair-icon.webp +0 -0
- package/dist/monitor-map/sjvair-icon2.avif +0 -0
- package/dist/monitor-map/sjvair-icon2.png +0 -0
- package/dist/monitor-map/sjvair-icon2.webp +0 -0
- package/dist/monitor-map/sjvair-sjv.avif +0 -0
- package/dist/monitor-map/sjvair-sjv.png +0 -0
- package/dist/monitor-map/sjvair-sjv.webp +0 -0
- package/dist/monitor-map/sjvair-sjv2.avif +0 -0
- package/dist/monitor-map/sjvair-sjv2.png +0 -0
- package/dist/monitor-map/sjvair-sjv2.webp +0 -0
- package/dist/monitor-map/sjvairMonitorMap.css +0 -1
- package/dist/monitor-map/sjvairMonitorMap.js +0 -4042
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
|
+
import "svelte/internal/disclose-version";
|
|
3
|
+
import * as t from "svelte/internal/client";
|
|
4
|
+
//#region src/lib/monitors/components/MonitorMarkersLegend.svelte
|
|
5
|
+
var n = t.from_html("<div class=\"w-1/5 shrink-0 h-[0.5em] border-l border-black last:relative last:right-px\"><span> </span></div>"), r = t.from_html("<div class=\"min-w-50 flex flex-col bg-white rounded shadow py-[0.5em] px-[1.5em]\"><p class=\"text-center whitespace-nowrap font-semibold\"> </p> <div class=\"map-legend-bar inline-block h-[1.5em] svelte-6hvosy\"> </div> <div class=\"flex mb-[1.5em]\"><div class=\"w-1/5 shrink-0 h-[0.5em] border-l border-black\"><span class=\"relative top-[0.5em] right-[0.3em]\">0</span></div> <!></div></div>"), i = {
|
|
6
|
+
hash: "svelte-6hvosy",
|
|
7
|
+
code: ".map-legend-bar.svelte-6hvosy {background:linear-gradient(\n 90deg,\n #00e400 0%,\n #ffff00 20%,\n #ff7e00 40%,\n #ff0000 60%,\n #8f3f97 80%,\n #7e0023 100%\n );}"
|
|
8
|
+
};
|
|
9
|
+
function a(a, o) {
|
|
10
|
+
t.push(o, !0), t.append_styles(a, i);
|
|
11
|
+
let s = t.derived(() => e.pollutant === "pm25" ? "PM 2.5" : "Ozone"), c = t.derived(() => e.pollutant === "pm25" ? [
|
|
12
|
+
12,
|
|
13
|
+
35,
|
|
14
|
+
55,
|
|
15
|
+
150,
|
|
16
|
+
250
|
|
17
|
+
] : [
|
|
18
|
+
55,
|
|
19
|
+
71,
|
|
20
|
+
86,
|
|
21
|
+
106,
|
|
22
|
+
201
|
|
23
|
+
]);
|
|
24
|
+
var l = r(), u = t.child(l), d = t.child(u);
|
|
25
|
+
t.reset(u);
|
|
26
|
+
var f = t.sibling(u, 4), p = t.sibling(t.child(f), 2);
|
|
27
|
+
t.each(p, 17, () => t.get(c), t.index, (e, r, i) => {
|
|
28
|
+
var a = n(), o = t.child(a);
|
|
29
|
+
t.set_class(o, 1, `relative top-[0.5em] ${i >= 3 ? "right-[0.8em]" : "right-[0.5em]"}`);
|
|
30
|
+
var s = t.child(o, !0);
|
|
31
|
+
t.reset(o), t.reset(a), t.template_effect(() => t.set_text(s, t.get(r))), t.append(e, a);
|
|
32
|
+
}), t.reset(f), t.reset(l), t.template_effect(() => t.set_text(d, `${t.get(s) ?? ""} Concentration`)), t.append(a, l), t.pop();
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { a as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
|
-
import * as t from "svelte/internal/client";
|
|
3
2
|
import "svelte/internal/disclose-version";
|
|
3
|
+
import * as t from "svelte/internal/client";
|
|
4
4
|
import { BellCheckIcon as n, BellOffIcon as r, ChevronDownIcon as i } from "@lucide/svelte";
|
|
5
5
|
import { getSubscriptions as a, subscribe as o, unsubscribe as s } from "@sjvair/sdk/account";
|
|
6
6
|
//#region src/lib/monitors/components/MonitorSubscriptionManager.svelte
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
2
|
import { getCurrentLevel as t } from "../monitor-utils.js";
|
|
3
3
|
import n from "../../components/DataBox.js";
|
|
4
|
-
import * as r from "svelte/internal/client";
|
|
5
4
|
import "svelte/internal/disclose-version";
|
|
5
|
+
import * as r from "svelte/internal/client";
|
|
6
6
|
import { format as i, formatDistanceToNow as a } from "date-fns";
|
|
7
7
|
//#region src/lib/monitors/components/MonitorTooltip.svelte
|
|
8
8
|
var o = r.from_html("<div class=\"flex gap-2\"><!> <div class=\"flex flex-col\"><p> </p> <h1 class=\"text-lg font-bold underline\"> </h1> <div class=\"mt-auto\"><p class=\"text-base leading-none\">Last updated</p> <p class=\"text-base leading-none\"> </p></div></div></div>");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { portal as e } from "../../actions.js";
|
|
2
|
-
import * as t from "svelte/internal/client";
|
|
3
2
|
import "svelte/internal/disclose-version";
|
|
3
|
+
import * as t from "svelte/internal/client";
|
|
4
4
|
import { SquareX as n } from "@lucide/svelte";
|
|
5
5
|
import { origin as r } from "@sjvair/sdk/http";
|
|
6
6
|
//#region src/lib/monitors/components/MonitorWidgetModal.svelte
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import n from "../../components/
|
|
4
|
-
import r from "
|
|
5
|
-
import i from "
|
|
6
|
-
import * as a from "svelte/internal/client";
|
|
1
|
+
import e from "../../components/DisplayOption.js";
|
|
2
|
+
import t from "../../components/SegmentedControl.js";
|
|
3
|
+
import n from "../../components/ToggleSwitch.js";
|
|
4
|
+
import { monitorsManager as r } from "../monitors.svelte.js";
|
|
5
|
+
import { monitorsMapIntegration as i } from "../monitors-map-integration.svelte.js";
|
|
7
6
|
import "svelte/internal/disclose-version";
|
|
7
|
+
import * as a from "svelte/internal/client";
|
|
8
8
|
//#region src/lib/monitors/components/MonitorsDisplayOptions.svelte
|
|
9
9
|
var o = a.from_html("<img class=\"w-3\"/>"), s = a.from_html("<label class=\"flex gap-1 cursor-pointer whitespace-nowrap select-none\"><input type=\"checkbox\"/> <!> </label>"), c = a.from_html("<p class=\"text-lg font-bold underline\">Air Monitors</p> <div class=\"mb-2 w-full text-xs\"><div class=\"w-fit\"><!></div> <!></div> <!>", 1);
|
|
10
10
|
function l(l, u) {
|
|
@@ -15,38 +15,38 @@ function l(l, u) {
|
|
|
15
15
|
}, {
|
|
16
16
|
label: "Ozone",
|
|
17
17
|
value: "o3"
|
|
18
|
-
}], f = a.derived(() =>
|
|
18
|
+
}], f = a.derived(() => r.pollutant && r.pollutant === "pm25" ? Object.entries(i.displayOptions) : Object.entries(i.displayOptions).filter(([e, t]) => e === "inactive" || r.meta?.asIter.monitors.some((e) => e.label === t.label && r.pollutant && r.pollutant in e.entries)));
|
|
19
19
|
a.user_effect(() => {
|
|
20
|
-
|
|
21
|
-
}),
|
|
22
|
-
children: (
|
|
20
|
+
r.list = [], r.latest = null, r.update();
|
|
21
|
+
}), e(l, {
|
|
22
|
+
children: (e, l) => {
|
|
23
23
|
var u = c(), p = a.sibling(a.first_child(u), 2), m = a.child(p);
|
|
24
|
-
|
|
24
|
+
n(a.child(m), {
|
|
25
25
|
id: "monitor-clusters",
|
|
26
26
|
label: "Marker Clusters",
|
|
27
27
|
get value() {
|
|
28
|
-
return
|
|
28
|
+
return i.clustered;
|
|
29
29
|
},
|
|
30
30
|
set value(e) {
|
|
31
|
-
|
|
31
|
+
i.clustered = e;
|
|
32
32
|
}
|
|
33
33
|
}), a.reset(m);
|
|
34
|
-
var h = a.sibling(m, 2), g = (
|
|
35
|
-
|
|
34
|
+
var h = a.sibling(m, 2), g = (e) => {
|
|
35
|
+
t(e, {
|
|
36
36
|
segmentLabel: "Pollutant:",
|
|
37
37
|
get options() {
|
|
38
38
|
return d;
|
|
39
39
|
},
|
|
40
40
|
get group() {
|
|
41
|
-
return
|
|
41
|
+
return r.pollutant;
|
|
42
42
|
},
|
|
43
|
-
set group(
|
|
44
|
-
|
|
43
|
+
set group(e) {
|
|
44
|
+
r.pollutant = e;
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
|
-
a.if(h, (
|
|
49
|
-
|
|
48
|
+
a.if(h, (e) => {
|
|
49
|
+
r.pollutant && e(g);
|
|
50
50
|
}), a.reset(p);
|
|
51
51
|
var _ = a.sibling(p, 2);
|
|
52
52
|
a.each(_, 17, () => a.get(f), ([e, t]) => t.label, (e, t) => {
|
|
@@ -67,7 +67,7 @@ function l(l, u) {
|
|
|
67
67
|
a.reset(l), a.template_effect(() => {
|
|
68
68
|
a.set_attribute(l, "for", a.get(c)), a.set_attribute(u, "id", a.get(c)), a.set_attribute(u, "name", i().label), a.set_text(p, ` ${i().label ?? ""}`);
|
|
69
69
|
}), a.bind_checked(u, () => i().value, (e) => i().value = e), a.append(e, l);
|
|
70
|
-
}), a.append(
|
|
70
|
+
}), a.append(e, u);
|
|
71
71
|
},
|
|
72
72
|
$$slots: { default: !0 }
|
|
73
73
|
}), a.pop();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mapManager as e } from "../map/map.svelte.js";
|
|
2
|
+
import { monitorsManager as t } from "./monitors.svelte.js";
|
|
3
3
|
import { asDataURI as n, circle as r, square as i, triangle as a } from "../map/icons.js";
|
|
4
4
|
import { MapIconManager as o } from "../map/integrations/map-icon-manager.js";
|
|
5
5
|
import * as s from "svelte/internal/client";
|
|
@@ -27,9 +27,9 @@ var p = class extends o {
|
|
|
27
27
|
constructor() {
|
|
28
28
|
super(), s.effect_root(() => {
|
|
29
29
|
s.user_effect(() => {
|
|
30
|
-
if (
|
|
30
|
+
if (t.levels) {
|
|
31
31
|
let r = [
|
|
32
|
-
...
|
|
32
|
+
...t.levels,
|
|
33
33
|
{
|
|
34
34
|
name: "default",
|
|
35
35
|
color: u
|
|
@@ -39,16 +39,16 @@ var p = class extends o {
|
|
|
39
39
|
color: d
|
|
40
40
|
}
|
|
41
41
|
];
|
|
42
|
-
for (let
|
|
42
|
+
for (let t of ["inside", "outside"]) for (let [i, a] of Object.entries(c)) for (let o of r) {
|
|
43
43
|
let r = [
|
|
44
44
|
this.idPrefix,
|
|
45
|
-
|
|
45
|
+
t,
|
|
46
46
|
o.name,
|
|
47
47
|
i
|
|
48
|
-
].filter(Boolean).join("-"), s = n(this.transformSvg(a(o.color, l,
|
|
48
|
+
].filter(Boolean).join("-"), s = n(this.transformSvg(a(o.color, l, t === "inside" ? "#000000" : void 0)));
|
|
49
49
|
if (this.icons.has(r)) {
|
|
50
|
-
let
|
|
51
|
-
|
|
50
|
+
let t = this.icons.get(r);
|
|
51
|
+
t.image.src !== s && (t.image.src = s, e.map?.hasImage(r) && this.updateImage(t, e.map));
|
|
52
52
|
continue;
|
|
53
53
|
} else {
|
|
54
54
|
let e = new Image();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mapManager as e } from "../map/map.svelte.js";
|
|
2
|
+
import { monitorsManager as t } from "./monitors.svelte.js";
|
|
3
3
|
import { clickManager as n } from "../map/integrations/click-manager.js";
|
|
4
4
|
import { MapIconLayerIntegration as r } from "../map/integrations/map-geojson-integration.svelte.js";
|
|
5
5
|
import { MonitorsIconManager as i, getIconId as a } from "./monitors-icon-manager.svelte.js";
|
|
@@ -90,38 +90,38 @@ var m = {
|
|
|
90
90
|
set selectedMonitorId(e) {
|
|
91
91
|
f.set(this.#r, e, !0);
|
|
92
92
|
}
|
|
93
|
-
handleMonitorClick = (
|
|
93
|
+
handleMonitorClick = (t) => {
|
|
94
94
|
if (!this.onMonitorClick) return;
|
|
95
|
-
let n = [...
|
|
95
|
+
let n = [...t].sort((e, t) => (t.properties?.order ?? 0) - (e.properties?.order ?? 0))[0];
|
|
96
96
|
if (!n?.properties?.id || (this.selectedMonitorId = n.properties.id, this.onMonitorClick(this.selectedMonitorId), n.geometry.type !== "Point")) return;
|
|
97
97
|
let r = n.geometry.coordinates;
|
|
98
|
-
|
|
98
|
+
e.map?.easeTo({
|
|
99
99
|
center: r,
|
|
100
|
-
zoom: Math.max(
|
|
100
|
+
zoom: Math.max(e.map.getZoom(), 12)
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
103
|
#i = f.derived(() => {
|
|
104
|
-
if (!
|
|
105
|
-
let
|
|
106
|
-
return Array.from(
|
|
104
|
+
if (!t.meta || !t.latest || !t.pollutant) return [];
|
|
105
|
+
let e = t.meta.entryType(t.pollutant).asIter.levels;
|
|
106
|
+
return Array.from(t.latest.values().map((t) => {
|
|
107
107
|
let n = {
|
|
108
108
|
type: "Feature",
|
|
109
109
|
properties: {
|
|
110
110
|
icon: "outside-default-square",
|
|
111
|
-
id:
|
|
112
|
-
is_active:
|
|
113
|
-
is_sjvair:
|
|
114
|
-
location:
|
|
115
|
-
name:
|
|
116
|
-
order: l(
|
|
117
|
-
type:
|
|
118
|
-
value:
|
|
111
|
+
id: t.id,
|
|
112
|
+
is_active: t.is_active,
|
|
113
|
+
is_sjvair: t.is_sjvair,
|
|
114
|
+
location: t.location,
|
|
115
|
+
name: t.name,
|
|
116
|
+
order: l(t),
|
|
117
|
+
type: t.type,
|
|
118
|
+
value: t.latest.value
|
|
119
119
|
},
|
|
120
|
-
geometry:
|
|
120
|
+
geometry: t.position
|
|
121
121
|
};
|
|
122
|
-
if (
|
|
123
|
-
let r = c(
|
|
124
|
-
r && (n.properties.icon = a(
|
|
122
|
+
if (e) {
|
|
123
|
+
let r = c(t.latest.value, e);
|
|
124
|
+
r && (n.properties.icon = a(t, r));
|
|
125
125
|
}
|
|
126
126
|
return n;
|
|
127
127
|
}));
|
|
@@ -185,7 +185,7 @@ var m = {
|
|
|
185
185
|
set featuresByType(e) {
|
|
186
186
|
f.set(this.#o, e);
|
|
187
187
|
}
|
|
188
|
-
#s = f.derived(() => !
|
|
188
|
+
#s = f.derived(() => !t.meta || !t.pollutant ? [] : t.meta.entryType(t.pollutant).asIter.levels ?? []);
|
|
189
189
|
get clusterIconThresholds() {
|
|
190
190
|
return f.get(this.#s);
|
|
191
191
|
}
|
|
@@ -225,27 +225,27 @@ var m = {
|
|
|
225
225
|
constructor() {
|
|
226
226
|
super(), f.effect_root(() => {
|
|
227
227
|
f.user_effect(() => {
|
|
228
|
-
let
|
|
229
|
-
|
|
228
|
+
let t = this.filters;
|
|
229
|
+
e.map && (this.clustered ? this.renderer.syncFilter() : e.map.getLayer(this.referenceId) && e.map.setFilter(this.referenceId, t));
|
|
230
230
|
}), f.user_effect(() => {
|
|
231
|
-
let
|
|
232
|
-
!
|
|
231
|
+
let t = this.features;
|
|
232
|
+
!e.map || this.clustered || e.setDataSource(this.referenceId, t);
|
|
233
233
|
}), f.user_effect(() => {
|
|
234
|
-
this.featuresByType, !(!
|
|
234
|
+
this.featuresByType, !(!e.map || !this.clustered) && this.renderer.syncFeatures();
|
|
235
235
|
}), f.user_effect(() => {
|
|
236
|
-
let
|
|
237
|
-
!
|
|
236
|
+
let t = this.clusterIconThresholds;
|
|
237
|
+
!e.map || !this.clustered || !t.length || this.renderer.syncThresholds();
|
|
238
238
|
}), f.user_effect(() => {
|
|
239
239
|
this.clustered;
|
|
240
|
-
let
|
|
241
|
-
!p(() =>
|
|
240
|
+
let t = Object.keys(this.featuresByType).length > 0;
|
|
241
|
+
!p(() => e.map) || !t || p(() => this.apply());
|
|
242
242
|
}), f.user_effect(() => {
|
|
243
|
-
this.selectedMonitorId,
|
|
243
|
+
this.selectedMonitorId, e.map && p(() => this.applySelectedState());
|
|
244
244
|
});
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
apply() {
|
|
248
|
-
|
|
248
|
+
e.map && (this.tooltipManager.has(this.referenceId) || this.tooltipManager.register(this.referenceId, d), this.clustered ? (e.map.getLayer(this.referenceId) && e.map.removeLayer(this.referenceId), e.map.getSource(this.referenceId) && e.map.removeSource(this.referenceId), n.unregister([this.referenceId]), this.tooltipManager.disable(), this.renderer.remove(), this.icons.loadIcons().then(() => {
|
|
249
249
|
this.renderer.apply(this.handleMonitorClick), this.tooltipManager.enable(), this.applySelectedState();
|
|
250
250
|
})) : (this.tooltipManager.disable(), this.renderer.remove(), this.tooltipManager.enable(), n.unregister([this.referenceId]), super.apply(), this.icons.loadIcons().then(() => {
|
|
251
251
|
n.register([this.referenceId], this.handleMonitorClick), this.applySelectedState();
|
|
@@ -255,15 +255,15 @@ var m = {
|
|
|
255
255
|
n.unregister([this.referenceId]), this.renderer.remove(), super.remove();
|
|
256
256
|
}
|
|
257
257
|
applySelectedState() {
|
|
258
|
-
if (!
|
|
259
|
-
let
|
|
258
|
+
if (!e.map) return;
|
|
259
|
+
let t = this.clustered ? this.renderer.unclusteredLayerIds : [this.referenceId], n = this.selectedMonitorId ? [
|
|
260
260
|
"match",
|
|
261
261
|
["get", "id"],
|
|
262
262
|
this.selectedMonitorId,
|
|
263
263
|
1.3,
|
|
264
264
|
1
|
|
265
265
|
] : 1;
|
|
266
|
-
for (let r of
|
|
266
|
+
for (let r of t) e.map.getLayer(r) && e.map.setLayoutProperty(r, "icon-size", n);
|
|
267
267
|
}
|
|
268
268
|
}();
|
|
269
269
|
//#endregion
|
|
@@ -1,68 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as e from "svelte/internal/client";
|
|
2
|
+
import { XMap as t } from "@tstk/builtin-extensions";
|
|
3
3
|
import { getMonitors as n, getMonitorsLatest as r, getMonitorsMeta as i } from "@sjvair/sdk";
|
|
4
|
-
import {
|
|
5
|
-
import { Interval as o } from "@tstk/utils";
|
|
4
|
+
import { Interval as a } from "@tstk/utils";
|
|
6
5
|
//#region src/lib/monitors/monitors.svelte.ts
|
|
7
|
-
var
|
|
8
|
-
autoUpdate = new
|
|
9
|
-
#e =
|
|
6
|
+
var o = class {
|
|
7
|
+
autoUpdate = new a(async () => await this.update(), 120 * 1e3);
|
|
8
|
+
#e = e.state(!1);
|
|
10
9
|
get initialized() {
|
|
11
|
-
return
|
|
10
|
+
return e.get(this.#e);
|
|
12
11
|
}
|
|
13
|
-
set initialized(
|
|
14
|
-
|
|
12
|
+
set initialized(t) {
|
|
13
|
+
e.set(this.#e, t, !0);
|
|
15
14
|
}
|
|
16
|
-
#t =
|
|
15
|
+
#t = e.state(null);
|
|
17
16
|
get latest() {
|
|
18
|
-
return
|
|
17
|
+
return e.get(this.#t);
|
|
19
18
|
}
|
|
20
|
-
set latest(
|
|
21
|
-
|
|
19
|
+
set latest(t) {
|
|
20
|
+
e.set(this.#t, t, !0);
|
|
22
21
|
}
|
|
23
|
-
#n =
|
|
22
|
+
#n = e.state(null);
|
|
24
23
|
get list() {
|
|
25
|
-
return
|
|
24
|
+
return e.get(this.#n);
|
|
26
25
|
}
|
|
27
|
-
set list(
|
|
28
|
-
|
|
26
|
+
set list(t) {
|
|
27
|
+
e.set(this.#n, t, !0);
|
|
29
28
|
}
|
|
30
|
-
#r =
|
|
29
|
+
#r = e.state(null);
|
|
31
30
|
get meta() {
|
|
32
|
-
return
|
|
31
|
+
return e.get(this.#r);
|
|
33
32
|
}
|
|
34
|
-
set meta(
|
|
35
|
-
|
|
33
|
+
set meta(t) {
|
|
34
|
+
e.set(this.#r, t, !0);
|
|
36
35
|
}
|
|
37
|
-
#i =
|
|
36
|
+
#i = e.state(null);
|
|
38
37
|
get pollutant() {
|
|
39
|
-
return
|
|
38
|
+
return e.get(this.#i);
|
|
40
39
|
}
|
|
41
|
-
set pollutant(
|
|
42
|
-
|
|
40
|
+
set pollutant(t) {
|
|
41
|
+
e.set(this.#i, t, !0);
|
|
43
42
|
}
|
|
44
|
-
#a =
|
|
43
|
+
#a = e.derived(() => this.meta?.entryType(this.pollutant ?? this.meta.default_pollutant).asIter.levels || null);
|
|
45
44
|
get levels() {
|
|
46
|
-
return
|
|
45
|
+
return e.get(this.#a);
|
|
47
46
|
}
|
|
48
|
-
set levels(
|
|
49
|
-
|
|
47
|
+
set levels(t) {
|
|
48
|
+
e.set(this.#a, t);
|
|
50
49
|
}
|
|
51
|
-
async init() {
|
|
52
|
-
|
|
53
|
-
[this.list, this.meta] = await Promise.all([n(), i()]);
|
|
54
|
-
let t = e.search.pollutant;
|
|
55
|
-
this.pollutant = t === "pm25" || t === "o3" ? t : this.meta.default_pollutant, this.latest = await c(this.pollutant), this.autoUpdate.start(), this.initialized = !0;
|
|
50
|
+
async init(e) {
|
|
51
|
+
this.initialized ||= ([this.list, this.meta] = await Promise.all([n(), i()]), this.pollutant = e === "pm25" || e === "o3" ? e : this.meta.default_pollutant, this.latest = await s(this.pollutant), this.autoUpdate.start(), !0);
|
|
56
52
|
}
|
|
57
53
|
async update() {
|
|
58
|
-
this.initialized && ([this.list, this.latest] = await Promise.all([n(),
|
|
54
|
+
this.initialized && ([this.list, this.latest] = await Promise.all([n(), s(this.pollutant || this.meta?.default_pollutant || "pm25")]));
|
|
59
55
|
}
|
|
60
56
|
};
|
|
61
|
-
async function
|
|
62
|
-
let
|
|
63
|
-
for (let e of
|
|
64
|
-
return
|
|
57
|
+
async function s(e) {
|
|
58
|
+
let n = await r(e), i = new t();
|
|
59
|
+
for (let e of n) i.set(e.id, e);
|
|
60
|
+
return i;
|
|
65
61
|
}
|
|
66
|
-
var
|
|
62
|
+
var c = new o();
|
|
67
63
|
//#endregion
|
|
68
|
-
export {
|
|
64
|
+
export { c as monitorsManager };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getContext as e, setContext as t } from "svelte";
|
|
2
|
+
//#region src/lib/router-context.ts
|
|
3
|
+
var n = Symbol("monitor-map-router");
|
|
4
|
+
function r(e) {
|
|
5
|
+
t(n, e);
|
|
6
|
+
}
|
|
7
|
+
function i() {
|
|
8
|
+
let t = e(n);
|
|
9
|
+
if (!t) throw Error("monitor-map router context not found. Wrap your app root with provideMonitorMapRouter(...) before rendering monitor-map components.");
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as ROUTER_KEY, r as provideMonitorMapRouter, i as useMonitorMapRouter };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { mapManager as e } from "../map/map.svelte.js";
|
|
2
|
+
import { monitorsMapIntegration as t } from "../monitors/monitors-map-integration.svelte.js";
|
|
3
|
+
import { useMonitorMapRouter as n } from "../router-context.js";
|
|
4
|
+
import { debounce as r } from "../utils.js";
|
|
5
|
+
import { geocode as i, monitorSearch as a } from "./service.js";
|
|
6
|
+
import "svelte/internal/disclose-version";
|
|
7
|
+
import * as o from "svelte/internal/client";
|
|
8
|
+
import { onDestroy as s } from "svelte";
|
|
9
|
+
import { Marker as c } from "@maptiler/sdk";
|
|
10
|
+
import { SearchIcon as l } from "@lucide/svelte";
|
|
11
|
+
//#region src/lib/search/Search.svelte
|
|
12
|
+
var u = o.from_html("<button class=\"px-2 text-gray-400 hover:text-gray-600 text-xl leading-none cursor-pointer\" aria-label=\"Clear search\">×</button>"), d = o.from_html("<img class=\"w-10 h-10 object-contain mr-3 shrink-0\"/>"), f = o.from_html("<button class=\"flex items-center w-full h-12 px-4 hover:brightness-95 bg-white text-left\"><!> <span class=\"text-sm truncate\"> </span></button>"), p = o.from_html("<p class=\"text-xs text-muted-foreground truncate\"> </p>"), m = o.from_html("<button class=\"flex items-center w-full h-12 px-4 hover:brightness-95 bg-white text-left\"><span class=\"svg-icon location-on bg-brand w-6 h-6 shrink-0 mr-3\"></span> <div class=\"min-w-0\"><p class=\"text-sm font-medium truncate\"> </p> <!></div></button>"), h = o.from_html("<div><div class=\"flex items-center w-full h-12 shrink-0\"><button class=\"w-12 h-12 shrink-0 flex items-center justify-center rounded-full bg-brand border-4 border-white\" aria-label=\"Open search\"><!></button> <div class=\"overflow-hidden w-full h-full flex items-center\"><input type=\"text\" placeholder=\"Search monitors or locations...\" class=\"h-full px-2 text-sm bg-transparent border-none outline-none w-full\"/> <!></div></div> <div></div></div>");
|
|
13
|
+
function g(g, _) {
|
|
14
|
+
o.push(_, !0);
|
|
15
|
+
let { navigate: v, basePath: y } = n(), b = o.state(!0), x = o.state(""), S = o.state(o.proxy([])), C = o.state(null), w = o.state(null);
|
|
16
|
+
function T(e) {
|
|
17
|
+
function t(t) {
|
|
18
|
+
!o.get(b) && !e.contains(t.target) && (o.set(b, !0), o.set(x, ""), o.set(S, [], !0));
|
|
19
|
+
}
|
|
20
|
+
return document.addEventListener("click", t, !0), { destroy() {
|
|
21
|
+
document.removeEventListener("click", t, !0);
|
|
22
|
+
} };
|
|
23
|
+
}
|
|
24
|
+
async function E() {
|
|
25
|
+
o.get(b) && (o.set(b, !1), o.get(w)?.focus());
|
|
26
|
+
}
|
|
27
|
+
function D() {
|
|
28
|
+
o.set(x, ""), o.set(S, [], !0), o.get(C)?.remove(), o.set(C, null);
|
|
29
|
+
}
|
|
30
|
+
async function O() {
|
|
31
|
+
let e = o.get(x);
|
|
32
|
+
if (!e) {
|
|
33
|
+
o.set(S, [], !0), o.get(C)?.remove(), o.set(C, null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let t = await a(e);
|
|
37
|
+
if (o.get(x) === e) if (t.length) o.set(S, t, !0);
|
|
38
|
+
else if (e.length > 4) {
|
|
39
|
+
let t = await i(e);
|
|
40
|
+
if (o.get(x) !== e) return;
|
|
41
|
+
o.set(S, t, !0);
|
|
42
|
+
} else o.set(S, [], !0);
|
|
43
|
+
}
|
|
44
|
+
let k = r(O, 500);
|
|
45
|
+
async function A(n) {
|
|
46
|
+
if (o.set(b, !0), o.set(x, ""), o.set(S, [], !0), o.get(C)?.remove(), o.set(C, null), e.map && n.monitor.position) {
|
|
47
|
+
let { coordinates: t } = n.monitor.position, r = [t[0], t[1]];
|
|
48
|
+
e.map.flyTo({
|
|
49
|
+
center: r,
|
|
50
|
+
zoom: 12
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
await v(`${y}/monitor/:id`, { params: { id: n.monitor.id } }), t.selectedMonitorId = n.monitor.id;
|
|
54
|
+
}
|
|
55
|
+
function j(t) {
|
|
56
|
+
let { feature: n } = t;
|
|
57
|
+
if (o.get(C)?.remove(), o.set(C, null), e.map) {
|
|
58
|
+
let t = [n.center[0], n.center[1]];
|
|
59
|
+
o.set(C, new c().setLngLat(t).addTo(e.map));
|
|
60
|
+
let r = n.place_type?.[0] === "address";
|
|
61
|
+
e.map.flyTo({
|
|
62
|
+
center: t,
|
|
63
|
+
...r && { zoom: 16 }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
o.set(S, [], !0), o.set(b, !0);
|
|
67
|
+
}
|
|
68
|
+
s(() => {
|
|
69
|
+
o.get(C)?.remove();
|
|
70
|
+
});
|
|
71
|
+
var M = h(), N = o.child(M), P = o.child(N);
|
|
72
|
+
l(o.child(P), {
|
|
73
|
+
size: "24",
|
|
74
|
+
color: "#FFFFFF"
|
|
75
|
+
}), o.reset(P);
|
|
76
|
+
var F = o.sibling(P, 2), I = o.child(F);
|
|
77
|
+
o.remove_input_defaults(I), o.bind_this(I, (e) => o.set(w, e), () => o.get(w));
|
|
78
|
+
var L = o.sibling(I, 2), R = (e) => {
|
|
79
|
+
var t = u();
|
|
80
|
+
o.delegated("click", t, D), o.append(e, t);
|
|
81
|
+
};
|
|
82
|
+
o.if(L, (e) => {
|
|
83
|
+
o.get(x) && !o.get(b) && e(R);
|
|
84
|
+
}), o.reset(F), o.reset(N);
|
|
85
|
+
var z = o.sibling(N, 2);
|
|
86
|
+
o.each(z, 21, () => o.get(S), (e) => e.type === "monitor" ? e.monitor.id : e.feature.place_name, (e, t) => {
|
|
87
|
+
var n = o.comment(), r = o.first_child(n), i = (e) => {
|
|
88
|
+
var n = f(), r = o.child(n), i = (e) => {
|
|
89
|
+
var n = d();
|
|
90
|
+
o.template_effect(() => {
|
|
91
|
+
o.set_attribute(n, "src", o.get(t).logo.url), o.set_attribute(n, "alt", o.get(t).logo.alt);
|
|
92
|
+
}), o.append(e, n);
|
|
93
|
+
};
|
|
94
|
+
o.if(r, (e) => {
|
|
95
|
+
o.get(t).logo.url && e(i);
|
|
96
|
+
});
|
|
97
|
+
var a = o.sibling(r, 2), s = o.child(a, !0);
|
|
98
|
+
o.reset(a), o.reset(n), o.template_effect(() => o.set_text(s, o.get(t).monitor.name)), o.delegated("click", n, () => A(o.get(t))), o.append(e, n);
|
|
99
|
+
}, a = (e) => {
|
|
100
|
+
let n = o.derived(() => o.get(t).feature.place_name.indexOf(","));
|
|
101
|
+
var r = m(), i = o.sibling(o.child(r), 2), a = o.child(i), s = o.child(a, !0);
|
|
102
|
+
o.reset(a);
|
|
103
|
+
var c = o.sibling(a, 2), l = (e) => {
|
|
104
|
+
var r = p(), i = o.child(r, !0);
|
|
105
|
+
o.reset(r), o.template_effect((e) => o.set_text(i, e), [() => o.get(t).feature.place_name.substring(o.get(n) + 1).trim()]), o.append(e, r);
|
|
106
|
+
};
|
|
107
|
+
o.if(c, (e) => {
|
|
108
|
+
o.get(n) >= 0 && e(l);
|
|
109
|
+
}), o.reset(i), o.reset(r), o.template_effect((e) => o.set_text(s, e), [() => o.get(t).feature.place_name.substring(0, o.get(n) < 0 ? void 0 : o.get(n))]), o.delegated("click", r, () => j(o.get(t))), o.append(e, r);
|
|
110
|
+
};
|
|
111
|
+
o.if(r, (e) => {
|
|
112
|
+
o.get(t).type === "monitor" ? e(i) : e(a, -1);
|
|
113
|
+
}), o.append(e, n);
|
|
114
|
+
}), o.reset(z), o.reset(M), o.action(M, (e) => T?.(e)), o.template_effect(() => {
|
|
115
|
+
o.set_class(M, 1, o.clsx([
|
|
116
|
+
"flex flex-col bg-white shadow-md overflow-hidden transition-all duration-300 select-none",
|
|
117
|
+
o.get(b) ? "w-12 h-12 rounded-full" : "w-90 rounded-3xl",
|
|
118
|
+
!o.get(b) && o.get(S).length ? "max-h-90" : "max-h-12"
|
|
119
|
+
])), o.set_attribute(I, "tabindex", o.get(b) ? -1 : 0), o.set_class(z, 1, o.clsx(["overflow-y-auto transition-all duration-300 divide-y divide-gray-100", o.get(b) ? "max-h-0" : "max-h-80"]));
|
|
120
|
+
}), o.delegated("click", P, E), o.delegated("input", I, k), o.bind_value(I, () => o.get(x), (e) => o.set(x, e)), o.append(g, M), o.pop();
|
|
121
|
+
}
|
|
122
|
+
o.delegate(["click", "input"]);
|
|
123
|
+
//#endregion
|
|
124
|
+
export { g as default };
|